]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '194be1f43ea391eb986732707435176e579265aa'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 18 Jun 2014 16:18:25 +0000 (18:18 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 18 Jun 2014 17:49:17 +0000 (19:49 +0200)
* commit '194be1f43ea391eb986732707435176e579265aa':
  lavf: switch to AVStream.time_base as the hint for the muxer timebase

Conflicts:
doc/APIchanges
libavformat/filmstripenc.c
libavformat/movenc.c
libavformat/mxfenc.c
libavformat/oggenc.c
libavformat/swf.h
libavformat/version.h
tests/ref/lavf/mkv

Merged-by: Michael Niedermayer <michaelni@gmx.at>
18 files changed:
1  2 
doc/APIchanges
libavformat/avformat.h
libavformat/avienc.c
libavformat/filmstripenc.c
libavformat/framehash.c
libavformat/movenc.c
libavformat/mpegtsenc.c
libavformat/mux.c
libavformat/mxfenc.c
libavformat/oggenc.c
libavformat/riffenc.c
libavformat/rmenc.c
libavformat/swf.h
libavformat/swfenc.c
libavformat/utils.c
libavformat/version.h
libavformat/yuv4mpegenc.c
tests/ref/lavf/mxf

diff --cc doc/APIchanges
index 11027ef0d9d96373bea0119b4f4b22b8da1acb3a,51a2ff559e9ea78edc7abbb0c97e305dc580c50b..ed9d560bfd3de27240a36904a7cf5c5ba09bf26b
@@@ -15,13 -13,11 +15,18 @@@ libavutil:     2012-10-2
  
  API changes, most recent first:
  
+ 2014-xx-xx - xxxxxxx - lavf 55.20.0 - avformat.h
+   The proper way for providing a hint about the desired timebase to the muxers
+   is now setting AVStream.time_base, instead of AVStream.codec.time_base as was
+   done previously. The old method is now deprecated.
 +2014-06-10 - xxxxxxx - lavf 55.43.100 - avformat.h
 +  New field int64_t max_analyze_duration2 instead of deprecated
 +  int max_analyze_duration.
 +
 +2014-05-30 - xxxxxxx - lavu 52.89.100 - opt.h
 +  Add av_opt_copy()
 +
  2014-04-xx - xxxxxxx - lavc 55.54.0 - avcodec.h
    Add AVCodecContext.side_data_only_packets to allow encoders to output packets
    with only side data. This option may become mandatory in the future, so all
Simple merge
index 461d3aa6117fc6e0568c2511ad7e3e9b7491cfb7,417a8e99d2ef97bce762685d52be62f71e682456..c45bac28c4401a7e4741f396c0847db99152b8ee
@@@ -155,9 -144,9 +155,10 @@@ static int avi_write_header(AVFormatCon
      AVIOContext *pb = s->pb;
      int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
      AVCodecContext *video_enc;
+     AVStream *video_st = NULL;
      int64_t list1, list2, strh, strf;
      AVDictionaryEntry *t = NULL;
 +    int padding;
  
      if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
          av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
index 85d49beec70f8456b415eac61b27c096cd6ec23e,8d1d2d83657162d2c03243a5bb69cd34fc92cb20..7c9bc6dcc0982771806bb08fdb9ec233627e153e
@@@ -64,7 -64,8 +64,8 @@@ static int write_trailer(AVFormatContex
      avio_wb16(pb, st->codec->width);
      avio_wb16(pb, st->codec->height);
      avio_wb16(pb, 0);  // leading
-     avio_wb16(pb, st->codec->time_base.den / st->codec->time_base.num);
+     // TODO: should be avg_frame_rate
 -    avio_wb16(pb, 1/av_q2d(st->time_base));
++    avio_wb16(pb, st->time_base.den / st->time_base.num);
      for (i = 0; i < 16; i++)
          avio_w8(pb, 0x00);  // reserved
  
index f075c404fc650e34730053f5dd7dac8740f8d513,6a6da98ae43588bebca02ae16f975704532cc23e..a8357b04ae4d7d2b09d2400d6d3ea112583e665b
  int ff_framehash_write_header(AVFormatContext *s)
  {
      int i;
 +
 +    if (s->nb_streams && !(s->flags & AVFMT_FLAG_BITEXACT))
 +        avio_printf(s->pb, "#software: %s\n", LIBAVFORMAT_IDENT);
      for (i = 0; i < s->nb_streams; i++) {
          AVStream *st = s->streams[i];
-         avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
          avio_printf(s->pb, "#tb %d: %d/%d\n", i, st->time_base.num, st->time_base.den);
          avio_flush(s->pb);
      }
index 55c7e523e99d6f2bf28065873008bf20e313ebbd,f5c36fcec1d0ea53b3bbaf8a6c1ef0af163f56b1..bb515747adba26ba266f60884ca564a097a7eed4
@@@ -899,20 -806,20 +899,20 @@@ static int mov_get_dv_codec_tag(AVForma
  {
      int tag;
  
 -    if (track->enc->width == 720) /* SD */
 -        if (track->enc->height == 480) /* NTSC */
 +    if (track->enc->width == 720) /* SD */
 +        if (track->enc->height == 480) /* NTSC */
              if  (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
              else                                            tag = MKTAG('d','v','c',' ');
 -        else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
 +       }else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
          else if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
          else                                                tag = MKTAG('d','v','p','p');
 -    else if (track->enc->height == 720) /* HD 720 line */
 +    } else if (track->enc->height == 720) { /* HD 720 line */
-         if  (track->enc->time_base.den == 50)               tag = MKTAG('d','v','h','q');
+         if  (track->st->time_base.den == 50)                tag = MKTAG('d','v','h','q');
          else                                                tag = MKTAG('d','v','h','p');
 -    else if (track->enc->height == 1080) /* HD 1080 line */
 +    } else if (track->enc->height == 1080) { /* HD 1080 line */
-         if  (track->enc->time_base.den == 25)               tag = MKTAG('d','v','h','5');
+         if  (track->st->time_base.den == 25)                tag = MKTAG('d','v','h','5');
          else                                                tag = MKTAG('d','v','h','6');
 -    else {
 +    else {
          av_log(s, AV_LOG_ERROR, "unsupported height for dv codec\n");
          return 0;
      }
@@@ -4025,13 -3402,7 +4027,13 @@@ static int mov_write_header(AVFormatCon
                  }
                  track->height = track->tag >> 24 == 'n' ? 486 : 576;
              }
 -            track->timescale = st->time_base.den;
 +            if (mov->video_track_timescale) {
 +                track->timescale = mov->video_track_timescale;
 +            } else {
-                 track->timescale = st->codec->time_base.den;
++                track->timescale = st->time_base.den;
 +                while(track->timescale < 10000)
 +                    track->timescale *= 2;
 +            }
              if (track->mode == MODE_MOV && track->timescale > 100000)
                  av_log(s, AV_LOG_WARNING,
                         "WARNING codec timebase is very high. If duration is too long,\n"
                  goto error;
              }
          } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
-             track->timescale = st->codec->time_base.den;
+             track->timescale = st->time_base.den;
          } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
-             track->timescale = st->codec->time_base.den;
+             track->timescale = st->time_base.den;
 +        } else {
 +            track->timescale = MOV_TIMESCALE;
          }
          if (!track->height)
              track->height = st->codec->height;
index f0d9cd2780ccb0145868bc883c3c440092aced4e,838702e8fa851b2d4ef7e94af687548c46c00dcc..a4a32e0e167d55ba95d5244427084847a3b71534
@@@ -710,11 -589,10 +716,12 @@@ static int mpegts_write_header(AVFormat
              }
          } else {
              // max delta PCR 0.1s
+             // TODO: should be avg_frame_rate
              service->pcr_packet_period =
-                 pcr_st->codec->time_base.den/(10*pcr_st->codec->time_base.num);
+                 ts_st->user_tb.den / (10 * ts_st->user_tb.num);
          }
 +        if(!service->pcr_packet_period)
 +            service->pcr_packet_period = 1;
      }
  
      // output a PCR as soon as possible
Simple merge
index 6f3226b968d8f4cd34f074f30391b80123d6e3e2,841e7277911c7cd0f9d5552ddee447f03824bd1a..95726232cfa582a05817a40a7eb0e035530238bd
@@@ -1683,45 -1428,36 +1683,46 @@@ static int mxf_write_header(AVFormatCon
              return AVERROR(ENOMEM);
          st->priv_data = sc;
  
 +        if ((i == 0) ^ (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)) {
 +            av_log(s, AV_LOG_ERROR, "there must be exactly one video stream and it must be the first one\n");
 +            return -1;
 +        }
 +
          if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-             AVRational rate, tbc = st->codec->time_base;
 -            if (i != 0) {
 -                av_log(s, AV_LOG_ERROR, "video stream must be first track\n");
 -                return -1;
 -            }
+             // TODO: should be avg_frame_rate
 -            if (fabs(av_q2d(st->time_base) - 1/25.0) < 0.0001) {
 -                samples_per_frame = PAL_samples_per_frame;
 -                mxf->time_base = (AVRational){ 1, 25 };
 -                mxf->timecode_base = 25;
 -            } else if (fabs(av_q2d(st->time_base) - 1001/30000.0) < 0.0001) {
 -                samples_per_frame = NTSC_samples_per_frame;
 -                mxf->time_base = (AVRational){ 1001, 30000 };
 -                mxf->timecode_base = 30;
 -            } else {
 -                av_log(s, AV_LOG_ERROR, "unsupported video frame rate\n");
 -                return -1;
++            AVRational rate, tbc = st->time_base;
 +            // Default component depth to 8
 +            sc->component_depth = 8;
 +            mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num;
 +            spf = ff_mxf_get_samples_per_frame(s, tbc);
 +            if (!spf) {
 +                av_log(s, AV_LOG_ERROR, "Unsupported video frame rate %d/%d\n",
 +                       tbc.den, tbc.num);
 +                return AVERROR(EINVAL);
              }
 +            mxf->time_base = spf->time_base;
 +            rate = av_inv_q(mxf->time_base);
              avpriv_set_pts_info(st, 64, mxf->time_base.num, mxf->time_base.den);
 +            if (!tcr)
 +                tcr = av_dict_get(st->metadata, "timecode", NULL, 0);
 +            if (tcr)
 +                ret = av_timecode_init_from_string(&mxf->tc, rate, tcr->value, s);
 +            else
 +                ret = av_timecode_init(&mxf->tc, rate, 0, 0, s);
 +            if (ret < 0)
 +                return ret;
 +            sc->video_bit_rate = st->codec->bit_rate ? st->codec->bit_rate : st->codec->rc_max_rate;
              if (s->oformat == &ff_mxf_d10_muxer) {
 -                if (st->codec->bit_rate == 50000000)
 +                if (sc->video_bit_rate == 50000000) {
                      if (mxf->time_base.den == 25) sc->index = 3;
                      else                          sc->index = 5;
 -                else if (st->codec->bit_rate == 40000000)
 +                } else if (sc->video_bit_rate == 40000000) {
                      if (mxf->time_base.den == 25) sc->index = 7;
                      else                          sc->index = 9;
 -                else if (st->codec->bit_rate == 30000000)
 +                } else if (sc->video_bit_rate == 30000000) {
                      if (mxf->time_base.den == 25) sc->index = 11;
                      else                          sc->index = 13;
 -                else {
 +                else {
                      av_log(s, AV_LOG_ERROR, "error MXF D-10 only support 30/40/50 mbit/s\n");
                      return -1;
                  }
index 6c50fc3521e5e640c8d5a47e15b939e39fac21fa,19c77595f4c32323cfaa863d9aef9696c3972c5c..f6a6d7d96dff21a7a96a315e8566cde808992a5a
@@@ -432,8 -428,7 +432,8 @@@ static int ogg_write_header(AVFormatCon
                  avpriv_set_pts_info(st, 64, 1, 48000);
              else
                  avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
-         } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
-             avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
++        }
          if (st->codec->codec_id != AV_CODEC_ID_VORBIS &&
              st->codec->codec_id != AV_CODEC_ID_THEORA &&
              st->codec->codec_id != AV_CODEC_ID_SPEEX  &&
Simple merge
index 17192ff275dbeac7e5e3a3488e0198abb256e062,9ff9f318a5e924d9b83b047da9a1fb4b9d4075bb..2e50ed338ceb77ed7821abe41c30397f1fbbd346
@@@ -309,12 -309,9 +309,14 @@@ static int rm_write_header(AVFormatCont
      int n;
      AVCodecContext *codec;
  
 +    if (s->nb_streams > 2) {
 +        av_log(s, AV_LOG_ERROR, "At most 2 streams are currently supported for muxing in RM\n");
 +        return AVERROR_PATCHWELCOME;
 +    }
 +
      for(n=0;n<s->nb_streams;n++) {
+         AVStream *st = s->streams[n];
          s->streams[n]->id = n;
          codec = s->streams[n]->codec;
          stream = &rm->streams[n];
index c1667b3c24c411aecc3e92007ccbdc7b9226c0a9,8eb3f70541f9760194155c4abdcc17ca2614fa50..93a094c26d56ab0e1930609af28d729738e858c0
@@@ -132,13 -76,7 +132,14 @@@ typedef struct SWFContext 
      int tag;
      AVFifoBuffer *audio_fifo;
      AVCodecContext *audio_enc, *video_enc;
+     AVStream *video_st;
 +#if CONFIG_ZLIB
 +    AVIOContext *zpb;
 +#define ZBUF_SIZE 4096
 +    uint8_t *zbuf_in;
 +    uint8_t *zbuf_out;
 +    z_stream zstream;
 +#endif
  } SWFContext;
  
  extern const AVCodecTag ff_swf_codec_tags[];
Simple merge
index 723eff6bd81e232ec30aa19dac33ef0dfbe5e9dd,ab6c6bf0c978ef53e197d40936ebf4dbde750cb1..517d919e1dc4ef926224b2e017b8380d01dbcbe6
@@@ -3735,12 -2661,16 +3735,17 @@@ AVStream *avformat_new_stream(AVFormatC
          av_free(st);
          return NULL;
      }
 +    st->info->last_dts = AV_NOPTS_VALUE;
  
      st->codec = avcodec_alloc_context3(c);
-     if (s->iformat)
+     if (s->iformat) {
          /* no default bitrate if decoding */
          st->codec->bit_rate = 0;
+         /* default pts setting is MPEG-like */
+         avpriv_set_pts_info(st, 33, 1, 90000);
+     }
      st->index      = s->nb_streams;
      st->start_time = AV_NOPTS_VALUE;
      st->duration   = AV_NOPTS_VALUE;
       * but durations get some timestamps, formats with some unknown
       * timestamps have their first few packets buffered and the
       * timestamps corrected before they are returned to the user */
 -    st->cur_dts       = 0;
 +    st->cur_dts       = s->iformat ? RELATIVE_TS_BASE : 0;
      st->first_dts     = AV_NOPTS_VALUE;
      st->probe_packets = MAX_PROBE_PACKETS;
 +    st->pts_wrap_reference = AV_NOPTS_VALUE;
 +    st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
  
-     /* default pts setting is MPEG-like */
-     avpriv_set_pts_info(st, 33, 1, 90000);
      st->last_IP_pts = AV_NOPTS_VALUE;
 +    st->last_dts_for_order_check = AV_NOPTS_VALUE;
      for (i = 0; i < MAX_REORDER_DELAY + 1; i++)
          st->pts_buffer[i] = AV_NOPTS_VALUE;
  
index e9cc16de4796f0195cc9018b9dbb3973a063a74b,1a017ce36280cde99cb4a610f0c71ddbd29695c0..67393e051e6bec865da4fcf39b15d6b3bf9f700a
@@@ -30,8 -30,8 +30,8 @@@
  #include "libavutil/version.h"
  
  #define LIBAVFORMAT_VERSION_MAJOR 55
- #define LIBAVFORMAT_VERSION_MINOR 43
 -#define LIBAVFORMAT_VERSION_MINOR 20
 -#define LIBAVFORMAT_VERSION_MICRO  0
++#define LIBAVFORMAT_VERSION_MINOR 44
 +#define LIBAVFORMAT_VERSION_MICRO 100
  
  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                 LIBAVFORMAT_VERSION_MINOR, \
  #ifndef FF_API_LAVF_FRAC
  #define FF_API_LAVF_FRAC                (LIBAVFORMAT_VERSION_MAJOR < 57)
  #endif
+ #ifndef FF_API_LAVF_CODEC_TB
+ #define FF_API_LAVF_CODEC_TB            (LIBAVFORMAT_VERSION_MAJOR < 57)
+ #endif
  
 +#ifndef FF_API_ALLOC_OUTPUT_CONTEXT
 +#define FF_API_ALLOC_OUTPUT_CONTEXT    (LIBAVFORMAT_VERSION_MAJOR < 56)
 +#endif
 +#ifndef FF_API_FORMAT_PARAMETERS
 +#define FF_API_FORMAT_PARAMETERS       (LIBAVFORMAT_VERSION_MAJOR < 56)
 +#endif
 +#ifndef FF_API_NEW_STREAM
 +#define FF_API_NEW_STREAM              (LIBAVFORMAT_VERSION_MAJOR < 56)
 +#endif
 +#ifndef FF_API_SET_PTS_INFO
 +#define FF_API_SET_PTS_INFO            (LIBAVFORMAT_VERSION_MAJOR < 56)
 +#endif
 +#ifndef FF_API_CLOSE_INPUT_FILE
 +#define FF_API_CLOSE_INPUT_FILE        (LIBAVFORMAT_VERSION_MAJOR < 56)
 +#endif
 +#ifndef FF_API_READ_PACKET
 +#define FF_API_READ_PACKET             (LIBAVFORMAT_VERSION_MAJOR < 56)
 +#endif
 +#ifndef FF_API_ASS_SSA
 +#define FF_API_ASS_SSA                 (LIBAVFORMAT_VERSION_MAJOR < 56)
 +#endif
 +#ifndef FF_API_R_FRAME_RATE
 +#define FF_API_R_FRAME_RATE            1
 +#endif
  #endif /* AVFORMAT_VERSION_H */
Simple merge
index 1390612b75d3f069ec77217d853dd7c72814f9a2,09e3c36bbc8f069774cfdedc5837ff93a7fa4afb..27991ffbb6f8b2b37fc00882e4f027b894959fa4
@@@ -1,9 -1,3 +1,9 @@@
 -051b982c1b5799eb107339735a090c70 *./tests/data/lavf/lavf.mxf
 -525881 ./tests/data/lavf/lavf.mxf
 -./tests/data/lavf/lavf.mxf CRC=0x773f059a
 +103403355e6dec356c7342ee2d034691 *./tests/data/lavf/lavf.mxf
 +525369 ./tests/data/lavf/lavf.mxf
 +./tests/data/lavf/lavf.mxf CRC=0xdbfff6f1
 +f61e4c8481610f30b2f5e2279e254f6b *./tests/data/lavf/lavf.mxf
 +560697 ./tests/data/lavf/lavf.mxf
- ./tests/data/lavf/lavf.mxf CRC=0x3ff4178e
++./tests/data/lavf/lavf.mxf CRC=0x11a6178e
 +a586dad4ff94136be460afb02ff6101e *./tests/data/lavf/lavf.mxf
 +525369 ./tests/data/lavf/lavf.mxf
 +./tests/data/lavf/lavf.mxf CRC=0xdbfff6f1