History

lavc: deprecate the use of AVCodecContext.time_base for decoding

When decoding, this field holds the inverse of the framerate that can be written in the headers for some codecs. Using a field called 'time_base' for this is very misleading, as there are no timestamps associated with it. Furthermore, this field is used for a very different purpose during encoding. Add a new field, called 'framerate', to replace the use of time_base for decoding.

Anton Khirnov committed 12 years ago

Commit 7ea1b341 parent d565fef27 files · +81 −54Browse files

Unified · Split

27 files
  1. doc/APIchanges +4 −0
  2. libavcodec/avcodec.h +10 −1
  3. libavcodec/cavsdec.c +1 −2
  4. libavcodec/dirac.c +1 −2
  5. libavcodec/dvdec.c +1 −1
  6. libavcodec/eacmv.c +1 −1
  7. libavcodec/eamad.c +1 −1
  8. libavcodec/eatgq.c +1 −1
  9. libavcodec/eatgv.c +1 −1
  10. libavcodec/eatqi.c +1 −1
  11. libavcodec/h261dec.c +1 −1
  12. libavcodec/h264.c +1 −1
  13. libavcodec/h264_slice.c +1 −1
  14. libavcodec/hevc.c +1 −1
  15. libavcodec/ituh263dec.c +10 −10
  16. libavcodec/libschroedingerdec.c +2 −2
  17. libavcodec/mpeg12dec.c +3 −4
  18. libavcodec/mpeg4videodec.c +9 −10
  19. libavcodec/mpegvideo_parser.c +7 −4
  20. libavcodec/options.c +1 −0
  21. libavcodec/pthread_frame.c +1 −0
  22. libavcodec/utils.c +10 −0
  23. libavcodec/vaapi_mpeg4.c +1 −1
  24. libavcodec/vc1.c +5 −5
  25. libavcodec/vdpau_mpeg4.c +1 −1
  26. libavcodec/version.h +4 −1
  27. libavcodec/vp3.c +1 −1
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2014-08-09 · 12 unmodified lines
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162014-10-xx - xxxxxxx - lavc 56.5.0 - avcodec.h
17 Replace AVCodecContext.time_base used for decoding
18 with AVCodecContext.framerate.
19
162014-10-xx - xxxxxxx - lavc 56.4.0 - avcodec.h202014-10-xx - xxxxxxx - lavc 56.4.0 - avcodec.h
17 Add AV_HWACCEL_FLAG_IGNORE_LEVEL flag to av_vdpau_bind_context().21 Add AV_HWACCEL_FLAG_IGNORE_LEVEL flag to av_vdpau_bind_context().
18 22
libavcodec/avcodec.h+10−1
@@ -1170,7 +1170,8 @@ typedef struct AVCodecContext { · 1169 unmodified lines
1170 * timebase should be 1/framerate and timestamp increments should be1170 * timebase should be 1/framerate and timestamp increments should be
1171 * identically 1.1171 * identically 1.
1172 * - encoding: MUST be set by user.1172 * - encoding: MUST be set by user.
1173 * - decoding: Set by libavcodec.1173 * - decoding: the use of this field for decoding is deprecated.
1174 * Use framerate instead.
1174 */1175 */
1175 AVRational time_base;1176 AVRational time_base;
1176 1177
@@ -2788,6 +2789,14 @@ typedef struct AVCodecContext { · 1611 unmodified lines
2788 * -initial_padding.2789 * -initial_padding.
2789 */2790 */
2790 int initial_padding;2791 int initial_padding;
2792
2793 /*
2794 * - decoding: For codecs that store a framerate value in the compressed
2795 * bitstream, the decoder may export it here. { 0, 1} when
2796 * unknown.
2797 * - encoding: unused
2798 */
2799 AVRational framerate;
2791} AVCodecContext;2800} AVCodecContext;
2792 2801
2793/**2802/**
libavcodec/cavsdec.c+1−2
@@ -1106,8 +1106,7 @@ static int decode_seq_header(AVSContext *h) · 1105 unmodified lines
1106 h->low_delay = get_bits1(&h->gb);1106 h->low_delay = get_bits1(&h->gb);
1107 h->mb_width = (h->width + 15) >> 4;1107 h->mb_width = (h->width + 15) >> 4;
1108 h->mb_height = (h->height + 15) >> 4;1108 h->mb_height = (h->height + 15) >> 4;
1109 h->avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_code].num;1109 h->avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_code];
1110 h->avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_code].den;
1111 h->avctx->width = h->width;1110 h->avctx->width = h->width;
1112 h->avctx->height = h->height;1111 h->avctx->height = h->height;
1113 if (!h->top_qp)1112 if (!h->top_qp)
libavcodec/dirac.c+1−2
@@ -172,8 +172,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, · 171 unmodified lines
172 /* [DIRAC_STD] Table 10.3 values 9-10 */172 /* [DIRAC_STD] Table 10.3 values 9-10 */
173 frame_rate = dirac_frame_rate[source->frame_rate_index - 9];173 frame_rate = dirac_frame_rate[source->frame_rate_index - 9];
174 }174 }
175 av_reduce(&avctx->time_base.num, &avctx->time_base.den,175 avctx->framerate = frame_rate;
176 frame_rate.den, frame_rate.num, 1 << 30);
177 176
178 /* [DIRAC_STD] 10.3.6 Pixel Aspect Ratio.177 /* [DIRAC_STD] 10.3.6 Pixel Aspect Ratio.
179 * pixel_aspect_ratio(video_params) */178 * pixel_aspect_ratio(video_params) */
libavcodec/dvdec.c+1−1
@@ -373,7 +373,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, void *data, · 372 unmodified lines
373 s->frame->key_frame = 1;373 s->frame->key_frame = 1;
374 s->frame->pict_type = AV_PICTURE_TYPE_I;374 s->frame->pict_type = AV_PICTURE_TYPE_I;
375 avctx->pix_fmt = s->sys->pix_fmt;375 avctx->pix_fmt = s->sys->pix_fmt;
376 avctx->time_base = s->sys->time_base;376 avctx->framerate = av_inv_q(s->sys->time_base);
377 377
378 ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height);378 ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height);
379 if (ret < 0)379 if (ret < 0)
libavcodec/eacmv.c+1−1
@@ -153,7 +153,7 @@ static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t * · 152 unmodified lines
153 153
154 fps = AV_RL16(&buf[10]);154 fps = AV_RL16(&buf[10]);
155 if (fps > 0)155 if (fps > 0)
156 s->avctx->time_base = (AVRational){ 1, fps };156 s->avctx->framerate = (AVRational){ fps, 1 };
157 157
158 pal_start = AV_RL16(&buf[12]);158 pal_start = AV_RL16(&buf[12]);
159 pal_count = AV_RL16(&buf[14]);159 pal_count = AV_RL16(&buf[14]);
libavcodec/eamad.c+1−1
@@ -249,7 +249,7 @@ static int decode_frame(AVCodecContext *avctx, · 248 unmodified lines
249 inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);249 inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG);
250 bytestream2_skip(&gb, 10);250 bytestream2_skip(&gb, 10);
251 251
252 av_reduce(&avctx->time_base.num, &avctx->time_base.den,252 av_reduce(&avctx->framerate.den, &avctx->framerate.num,
253 bytestream2_get_le16(&gb), 1000, 1<<30);253 bytestream2_get_le16(&gb), 1000, 1<<30);
254 254
255 width = bytestream2_get_le16(&gb);255 width = bytestream2_get_le16(&gb);
libavcodec/eatgq.c+1−1
@@ -53,7 +53,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx) · 52 unmodified lines
53 s->avctx = avctx;53 s->avctx = avctx;
54 ff_init_scantable_permutation(idct_permutation, FF_IDCT_PERM_NONE);54 ff_init_scantable_permutation(idct_permutation, FF_IDCT_PERM_NONE);
55 ff_init_scantable(idct_permutation, &s->scantable, ff_zigzag_direct);55 ff_init_scantable(idct_permutation, &s->scantable, ff_zigzag_direct);
56 avctx->time_base = (AVRational){1, 15};56 avctx->framerate = (AVRational){ 15, 1 };
57 avctx->pix_fmt = AV_PIX_FMT_YUV420P;57 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
58 return 0;58 return 0;
59}59}
libavcodec/eatgv.c+1−1
@@ -55,7 +55,7 @@ static av_cold int tgv_decode_init(AVCodecContext *avctx) · 54 unmodified lines
55{55{
56 TgvContext *s = avctx->priv_data;56 TgvContext *s = avctx->priv_data;
57 s->avctx = avctx;57 s->avctx = avctx;
58 avctx->time_base = (AVRational){1, 15};58 avctx->framerate = (AVRational){ 15, 1 };
59 avctx->pix_fmt = AV_PIX_FMT_PAL8;59 avctx->pix_fmt = AV_PIX_FMT_PAL8;
60 60
61 s->last_frame = av_frame_alloc();61 s->last_frame = av_frame_alloc();
libavcodec/eatqi.c+1−1
@@ -56,7 +56,7 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx) · 55 unmodified lines
56 ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE);56 ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE);
57 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);57 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
58 s->qscale = 1;58 s->qscale = 1;
59 avctx->time_base = (AVRational){1, 15};59 avctx->framerate = (AVRational){ 15, 1 };
60 avctx->pix_fmt = AV_PIX_FMT_YUV420P;60 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
61 ff_mpeg12_init_vlcs();61 ff_mpeg12_init_vlcs();
62 return 0;62 return 0;
libavcodec/h261dec.c+1−1
@@ -478,7 +478,7 @@ static int h261_decode_picture_header(H261Context *h) · 477 unmodified lines
478 i += 32;478 i += 32;
479 s->picture_number = (s->picture_number & ~31) + i;479 s->picture_number = (s->picture_number & ~31) + i;
480 480
481 s->avctx->time_base = (AVRational) { 1001, 30000 };481 s->avctx->framerate = (AVRational) { 30000, 1001 };
482 482
483 /* PTYPE starts here */483 /* PTYPE starts here */
484 skip_bits1(&s->gb); /* split screen off */484 skip_bits1(&s->gb); /* split screen off */
libavcodec/h264.c+1−1
@@ -656,7 +656,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) · 655 unmodified lines
656 h->frame_recovered = 0;656 h->frame_recovered = 0;
657 if (avctx->codec_id == AV_CODEC_ID_H264) {657 if (avctx->codec_id == AV_CODEC_ID_H264) {
658 if (avctx->ticks_per_frame == 1)658 if (avctx->ticks_per_frame == 1)
659 h->avctx->time_base.den *= 2;659 h->avctx->framerate.num *= 2;
660 avctx->ticks_per_frame = 2;660 avctx->ticks_per_frame = 2;
661 }661 }
662 662
libavcodec/h264_slice.c+1−1
@@ -1090,7 +1090,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) · 1089 unmodified lines
1090 int64_t den = h->sps.time_scale;1090 int64_t den = h->sps.time_scale;
1091 if (h->x264_build < 44U)1091 if (h->x264_build < 44U)
1092 den *= 2;1092 den *= 2;
1093 av_reduce(&h->avctx->time_base.num, &h->avctx->time_base.den,1093 av_reduce(&h->avctx->framerate.den, &h->avctx->framerate.num,
1094 h->sps.num_units_in_tick, den, 1 << 30);1094 h->sps.num_units_in_tick, den, 1 << 30);
1095 }1095 }
1096 1096
libavcodec/hevc.c+1−1
@@ -442,7 +442,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) · 441 unmodified lines
442 }442 }
443 443
444 if (num != 0 && den != 0)444 if (num != 0 && den != 0)
445 av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den,445 av_reduce(&s->avctx->framerate.den, &s->avctx->framerate.num,
446 num, den, 1 << 30);446 num, den, 1 << 30);
447 447
448 return 0;448 return 0;
libavcodec/ituh263dec.c+10−10
@@ -81,7 +81,7 @@ void ff_h263_show_pict_info(MpegEncContext *s){ · 80 unmodified lines
81 s->modified_quant ? " MQ" : "",81 s->modified_quant ? " MQ" : "",
82 s->loop_filter ? " LOOP" : "",82 s->loop_filter ? " LOOP" : "",
83 s->h263_slice_structured ? " SS" : "",83 s->h263_slice_structured ? " SS" : "",
84 s->avctx->time_base.den, s->avctx->time_base.num84 s->avctx->framerate.num, s->avctx->framerate.den
85 );85 );
86 }86 }
87}87}
@@ -938,7 +938,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s) · 850 unmodified lines
938 s->width = width;938 s->width = width;
939 s->height = height;939 s->height = height;
940 s->avctx->sample_aspect_ratio= (AVRational){12,11};940 s->avctx->sample_aspect_ratio= (AVRational){12,11};
941 s->avctx->time_base= (AVRational){1001, 30000};941 s->avctx->framerate = (AVRational){ 30000, 1001 };
942 } else {942 } else {
943 int ufep;943 int ufep;
944 944
@@ -1034,18 +1034,18 @@ int ff_h263_decode_picture_header(MpegEncContext *s) · 89 unmodified lines
1034 1034
1035 if(s->custom_pcf){1035 if(s->custom_pcf){
1036 int gcd;1036 int gcd;
1037 s->avctx->time_base.den= 1800000;1037 s->avctx->framerate.num = 1800000;
1038 s->avctx->time_base.num= 1000 + get_bits1(&s->gb);1038 s->avctx->framerate.den = 1000 + get_bits1(&s->gb);
1039 s->avctx->time_base.num*= get_bits(&s->gb, 7);1039 s->avctx->framerate.den *= get_bits(&s->gb, 7);
1040 if(s->avctx->time_base.num == 0){1040 if(s->avctx->framerate.den == 0){
1041 av_log(s, AV_LOG_ERROR, "zero framerate\n");1041 av_log(s, AV_LOG_ERROR, "zero framerate\n");
1042 return -1;1042 return -1;
1043 }1043 }
1044 gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num);1044 gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num);
1045 s->avctx->time_base.den /= gcd;1045 s->avctx->framerate.den /= gcd;
1046 s->avctx->time_base.num /= gcd;1046 s->avctx->framerate.num /= gcd;
1047 }else{1047 }else{
1048 s->avctx->time_base= (AVRational){1001, 30000};1048 s->avctx->framerate = (AVRational){ 30000, 1001 };
1049 }1049 }
1050 }1050 }
1051 1051
libavcodec/libschroedingerdec.c+2−2
@@ -199,8 +199,8 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avctx) · 198 unmodified lines
199 return;199 return;
200 }200 }
201 201
202 avctx->time_base.den = p_schro_params->format->frame_rate_numerator;202 avctx->framerate.num = p_schro_params->format->frame_rate_numerator;
203 avctx->time_base.num = p_schro_params->format->frame_rate_denominator;203 avctx->framerate.den = p_schro_params->format->frame_rate_denominator;
204}204}
205 205
206static int libschroedinger_decode_frame(AVCodecContext *avctx,206static int libschroedinger_decode_frame(AVCodecContext *avctx,
libavcodec/mpeg12dec.c+3−4
@@ -1257,15 +1257,14 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) · 1256 unmodified lines
1257 1257
1258 if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {1258 if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
1259 // MPEG-1 fps1259 // MPEG-1 fps
1260 avctx->time_base.den = ff_mpeg12_frame_rate_tab[s->frame_rate_index].num;1260 avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
1261 avctx->time_base.num = ff_mpeg12_frame_rate_tab[s->frame_rate_index].den;
1262 // MPEG-1 aspect1261 // MPEG-1 aspect
1263 avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);1262 avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);
1264 avctx->ticks_per_frame = 1;1263 avctx->ticks_per_frame = 1;
1265 } else { // MPEG-21264 } else { // MPEG-2
1266 // MPEG-2 fps1265 // MPEG-2 fps
1267 av_reduce(&s->avctx->time_base.den,1266 av_reduce(&s->avctx->framerate.num,
1268 &s->avctx->time_base.num,1267 &s->avctx->framerate.den,
1269 ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num * 2,1268 ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num * 2,
1270 ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,1269 ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1271 1 << 30);1270 1 << 30);
libavcodec/mpeg4videodec.c+9−10
@@ -1722,23 +1722,22 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 1721 unmodified lines
1722 1722
1723 check_marker(gb, "before time_increment_resolution");1723 check_marker(gb, "before time_increment_resolution");
1724 1724
1725 s->avctx->time_base.den = get_bits(gb, 16);1725 s->avctx->framerate.num = get_bits(gb, 16);
1726 if (!s->avctx->time_base.den) {1726 if (!s->avctx->framerate.num) {
1727 av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n");1727 av_log(s->avctx, AV_LOG_ERROR, "framerate==0\n");
1728 s->avctx->time_base.num = 0;
1729 return -1;1728 return -1;
1730 }1729 }
1731 1730
1732 ctx->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;1731 ctx->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1;
1733 if (ctx->time_increment_bits < 1)1732 if (ctx->time_increment_bits < 1)
1734 ctx->time_increment_bits = 1;1733 ctx->time_increment_bits = 1;
1735 1734
1736 check_marker(gb, "before fixed_vop_rate");1735 check_marker(gb, "before fixed_vop_rate");
1737 1736
1738 if (get_bits1(gb) != 0) /* fixed_vop_rate */1737 if (get_bits1(gb) != 0) /* fixed_vop_rate */
1739 s->avctx->time_base.num = get_bits(gb, ctx->time_increment_bits);1738 s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits);
1740 else1739 else
1741 s->avctx->time_base.num = 1;1740 s->avctx->framerate.den = 1;
1742 1741
1743 ctx->t_frame = 0;1742 ctx->t_frame = 0;
1744 1743
@@ -2126,19 +2125,19 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 381 unmodified lines
2126 if (s->pict_type != AV_PICTURE_TYPE_B) {2125 if (s->pict_type != AV_PICTURE_TYPE_B) {
2127 s->last_time_base = s->time_base;2126 s->last_time_base = s->time_base;
2128 s->time_base += time_incr;2127 s->time_base += time_incr;
2129 s->time = s->time_base * s->avctx->time_base.den + time_increment;2128 s->time = s->time_base * s->avctx->framerate.num + time_increment;
2130 if (s->workaround_bugs & FF_BUG_UMP4) {2129 if (s->workaround_bugs & FF_BUG_UMP4) {
2131 if (s->time < s->last_non_b_time) {2130 if (s->time < s->last_non_b_time) {
2132 /* header is not mpeg-4-compatible, broken encoder,2131 /* header is not mpeg-4-compatible, broken encoder,
2133 * trying to workaround */2132 * trying to workaround */
2134 s->time_base++;2133 s->time_base++;
2135 s->time += s->avctx->time_base.den;2134 s->time += s->avctx->framerate.num;
2136 }2135 }
2137 }2136 }
2138 s->pp_time = s->time - s->last_non_b_time;2137 s->pp_time = s->time - s->last_non_b_time;
2139 s->last_non_b_time = s->time;2138 s->last_non_b_time = s->time;
2140 } else {2139 } else {
2141 s->time = (s->last_time_base + time_incr) * s->avctx->time_base.den + time_increment;2140 s->time = (s->last_time_base + time_incr) * s->avctx->framerate.num + time_increment;
2142 s->pb_time = s->pp_time - (s->last_non_b_time - s->time);2141 s->pb_time = s->pp_time - (s->last_non_b_time - s->time);
2143 if (s->pp_time <= s->pb_time ||2142 if (s->pp_time <= s->pb_time ||
2144 s->pp_time <= s->pp_time - s->pb_time ||2143 s->pp_time <= s->pp_time - s->pb_time ||
libavcodec/mpegvideo_parser.c+7−4
@@ -66,8 +66,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, · 65 unmodified lines
66 did_set_size=1;66 did_set_size=1;
67 }67 }
68 frame_rate_index = buf[3] & 0xf;68 frame_rate_index = buf[3] & 0xf;
69 pc->frame_rate.den = avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_index].num;69 pc->frame_rate = avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_index];
70 pc->frame_rate.num = avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_index].den;
71 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400;70 avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400;
72 avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;71 avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
73 }72 }
@@ -91,8 +90,8 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, · 17 unmodified lines
91 avctx->bit_rate += (bit_rate_ext << 18) * 400;90 avctx->bit_rate += (bit_rate_ext << 18) * 400;
92 if(did_set_size)91 if(did_set_size)
93 ff_set_dimensions(avctx, pc->width, pc->height);92 ff_set_dimensions(avctx, pc->width, pc->height);
94 avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1) * 2;93 avctx->framerate.num = pc->frame_rate.num * (frame_rate_ext_n + 1) * 2;
95 avctx->time_base.num = pc->frame_rate.num * (frame_rate_ext_d + 1);94 avctx->framerate.den = pc->frame_rate.den * (frame_rate_ext_d + 1);
96 avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;95 avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
97 }96 }
98 break;97 break;
@@ -139,6 +138,10 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, · 40 unmodified lines
139 }138 }
140 }139 }
141 the_end: ;140 the_end: ;
141#if FF_API_AVCTX_TIMEBASE
142 if (avctx->framerate.num)
143 avctx->time_base = av_inv_q(avctx->framerate);
144#endif
142}145}
143 146
144static int mpegvideo_parse(AVCodecParserContext *s,147static int mpegvideo_parse(AVCodecParserContext *s,
libavcodec/options.c+1−0
@@ -88,6 +88,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) · 87 unmodified lines
88 av_opt_set_defaults(s);88 av_opt_set_defaults(s);
89 89
90 s->time_base = (AVRational){0,1};90 s->time_base = (AVRational){0,1};
91 s->framerate = (AVRational){ 0, 1 };
91 s->get_buffer2 = avcodec_default_get_buffer2;92 s->get_buffer2 = avcodec_default_get_buffer2;
92 s->get_format = avcodec_default_get_format;93 s->get_format = avcodec_default_get_format;
93 s->execute = avcodec_default_execute;94 s->execute = avcodec_default_execute;
libavcodec/pthread_frame.c+1−0
@@ -178,6 +178,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, · 177 unmodified lines
178 178
179 if (dst != src) {179 if (dst != src) {
180 dst->time_base = src->time_base;180 dst->time_base = src->time_base;
181 dst->framerate = src->framerate;
181 dst->width = src->width;182 dst->width = src->width;
182 dst->height = src->height;183 dst->height = src->height;
183 dst->pix_fmt = src->pix_fmt;184 dst->pix_fmt = src->pix_fmt;
libavcodec/utils.c+10−0
@@ -1262,6 +1262,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code · 1261 unmodified lines
1262 ret = AVERROR(EINVAL);1262 ret = AVERROR(EINVAL);
1263 goto free_and_end;1263 goto free_and_end;
1264 }1264 }
1265
1266#if FF_API_AVCTX_TIMEBASE
1267 if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
1268 avctx->time_base = av_inv_q(avctx->framerate);
1269#endif
1265 }1270 }
1266end:1271end:
1267 entangled_thread_counter--;1272 entangled_thread_counter--;
@@ -1674,6 +1679,11 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi · 406 unmodified lines
1674 } else1679 } else
1675 ret = 0;1680 ret = 0;
1676 1681
1682#if FF_API_AVCTX_TIMEBASE
1683 if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
1684 avctx->time_base = av_inv_q(avctx->framerate);
1685#endif
1686
1677 return ret;1687 return ret;
1678}1688}
1679 1689
libavcodec/vaapi_mpeg4.c+1−1
@@ -88,7 +88,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ · 87 unmodified lines
88 pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan;88 pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan;
89 pic_param->vop_fcode_forward = s->f_code;89 pic_param->vop_fcode_forward = s->f_code;
90 pic_param->vop_fcode_backward = s->b_code;90 pic_param->vop_fcode_backward = s->b_code;
91 pic_param->vop_time_increment_resolution = avctx->time_base.den;91 pic_param->vop_time_increment_resolution = avctx->framerate.num;
92 pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s);92 pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s);
93 pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob;93 pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob;
94 pic_param->TRB = s->pb_time;94 pic_param->TRB = s->pb_time;
libavcodec/vc1.c+5−5
@@ -485,19 +485,19 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) · 484 unmodified lines
485 485
486 if (get_bits1(gb)) { //framerate stuff486 if (get_bits1(gb)) { //framerate stuff
487 if (get_bits1(gb)) {487 if (get_bits1(gb)) {
488 v->s.avctx->time_base.num = 32;488 v->s.avctx->framerate.den = 32;
489 v->s.avctx->time_base.den = get_bits(gb, 16) + 1;489 v->s.avctx->framerate.num = get_bits(gb, 16) + 1;
490 } else {490 } else {
491 int nr, dr;491 int nr, dr;
492 nr = get_bits(gb, 8);492 nr = get_bits(gb, 8);
493 dr = get_bits(gb, 4);493 dr = get_bits(gb, 4);
494 if (nr > 0 && nr < 8 && dr > 0 && dr < 3) {494 if (nr > 0 && nr < 8 && dr > 0 && dr < 3) {
495 v->s.avctx->time_base.num = ff_vc1_fps_dr[dr - 1];495 v->s.avctx->framerate.den = ff_vc1_fps_dr[dr - 1];
496 v->s.avctx->time_base.den = ff_vc1_fps_nr[nr - 1] * 1000;496 v->s.avctx->framerate.num = ff_vc1_fps_nr[nr - 1] * 1000;
497 }497 }
498 }498 }
499 if (v->broadcast) { // Pulldown may be present499 if (v->broadcast) { // Pulldown may be present
500 v->s.avctx->time_base.den *= 2;500 v->s.avctx->framerate.num *= 2;
501 v->s.avctx->ticks_per_frame = 2;501 v->s.avctx->ticks_per_frame = 2;
502 }502 }
503 }503 }
libavcodec/vdpau_mpeg4.c+1−1
@@ -61,7 +61,7 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, · 60 unmodified lines
61 info->trb[0] = s->pb_time;61 info->trb[0] = s->pb_time;
62 info->trd[1] = s->pp_field_time >> 1;62 info->trd[1] = s->pp_field_time >> 1;
63 info->trb[1] = s->pb_field_time >> 1;63 info->trb[1] = s->pb_field_time >> 1;
64 info->vop_time_increment_resolution = s->avctx->time_base.den;64 info->vop_time_increment_resolution = s->avctx->framerate.num;
65 info->vop_fcode_forward = s->f_code;65 info->vop_fcode_forward = s->f_code;
66 info->vop_fcode_backward = s->b_code;66 info->vop_fcode_backward = s->b_code;
67 info->resync_marker_disable = !ctx->resync_marker;67 info->resync_marker_disable = !ctx->resync_marker;
libavcodec/version.h+4−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29#include "libavutil/version.h"29#include "libavutil/version.h"
30 30
31#define LIBAVCODEC_VERSION_MAJOR 5631#define LIBAVCODEC_VERSION_MAJOR 56
32#define LIBAVCODEC_VERSION_MINOR 432#define LIBAVCODEC_VERSION_MINOR 5
33#define LIBAVCODEC_VERSION_MICRO 033#define LIBAVCODEC_VERSION_MICRO 0
34 34
35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -156,5 +156,8 @@ · 120 unmodified lines
156#ifndef FF_API_AUDIOENC_DELAY156#ifndef FF_API_AUDIOENC_DELAY
157#define FF_API_AUDIOENC_DELAY (LIBAVCODEC_VERSION_MAJOR < 58)157#define FF_API_AUDIOENC_DELAY (LIBAVCODEC_VERSION_MAJOR < 58)
158#endif158#endif
159#ifndef FF_API_AVCTX_TIMEBASE
160#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59)
161#endif
159 162
160#endif /* AVCODEC_VERSION_H */163#endif /* AVCODEC_VERSION_H */
libavcodec/vp3.c+1−1
@@ -2233,7 +2233,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) · 2232 unmodified lines
2233 av_log(avctx, AV_LOG_ERROR, "Invalid framerate\n");2233 av_log(avctx, AV_LOG_ERROR, "Invalid framerate\n");
2234 return AVERROR_INVALIDDATA;2234 return AVERROR_INVALIDDATA;
2235 }2235 }
2236 av_reduce(&avctx->time_base.num, &avctx->time_base.den,2236 av_reduce(&avctx->framerate.den, &avctx->framerate.num,
2237 fps.den, fps.num, 1 << 30);2237 fps.den, fps.num, 1 << 30);
2238 }2238 }
2239 2239

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t