diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-10-15 13:38:10 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-15 15:49:31 +0200 |
commit | 17085a0251a1493f6447aa3d2ee06fda2c9402f0 (patch) | |
tree | d627e3d5bdcf01ed711249c30247c74dd7087367 /libavcodec | |
parent | 51c810e62b63a1451b337b1cba0141b386066668 (diff) | |
parent | 7ea1b3472a61de4aa4d41b571e99418e4997ad41 (diff) | |
download | ffmpeg-17085a0251a1493f6447aa3d2ee06fda2c9402f0.tar.gz |
Merge commit '7ea1b3472a61de4aa4d41b571e99418e4997ad41'
* commit '7ea1b3472a61de4aa4d41b571e99418e4997ad41':
lavc: deprecate the use of AVCodecContext.time_base for decoding
Conflicts:
libavcodec/avcodec.h
libavcodec/h264.c
libavcodec/mpegvideo_parser.c
libavcodec/utils.c
libavcodec/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 11 | ||||
-rw-r--r-- | libavcodec/cavsdec.c | 3 | ||||
-rw-r--r-- | libavcodec/dirac.c | 3 | ||||
-rw-r--r-- | libavcodec/dvdec.c | 2 | ||||
-rw-r--r-- | libavcodec/eacmv.c | 2 | ||||
-rw-r--r-- | libavcodec/eamad.c | 2 | ||||
-rw-r--r-- | libavcodec/eatgq.c | 2 | ||||
-rw-r--r-- | libavcodec/eatgv.c | 2 | ||||
-rw-r--r-- | libavcodec/eatqi.c | 2 | ||||
-rw-r--r-- | libavcodec/h261dec.c | 2 | ||||
-rw-r--r-- | libavcodec/h264.c | 6 | ||||
-rw-r--r-- | libavcodec/h264_slice.c | 2 | ||||
-rw-r--r-- | libavcodec/hevc.c | 2 | ||||
-rw-r--r-- | libavcodec/ituh263dec.c | 20 | ||||
-rw-r--r-- | libavcodec/libschroedingerdec.c | 4 | ||||
-rw-r--r-- | libavcodec/mpeg12dec.c | 7 | ||||
-rw-r--r-- | libavcodec/mpeg4videodec.c | 32 | ||||
-rw-r--r-- | libavcodec/mpegvideo_parser.c | 11 | ||||
-rw-r--r-- | libavcodec/options.c | 1 | ||||
-rw-r--r-- | libavcodec/pthread_frame.c | 1 | ||||
-rw-r--r-- | libavcodec/utils.c | 10 | ||||
-rw-r--r-- | libavcodec/vaapi_mpeg4.c | 2 | ||||
-rw-r--r-- | libavcodec/vc1.c | 10 | ||||
-rw-r--r-- | libavcodec/vdpau_mpeg4.c | 2 | ||||
-rw-r--r-- | libavcodec/version.h | 5 | ||||
-rw-r--r-- | libavcodec/vp3.c | 2 |
26 files changed, 87 insertions, 61 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 27d6e55d61..4b56b55abc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1347,7 +1347,8 @@ typedef struct AVCodecContext { * timebase should be 1/framerate and timestamp increments should be * identically 1. * - encoding: MUST be set by user. - * - decoding: Set by libavcodec. + * - decoding: the use of this field for decoding is deprecated. + * Use framerate instead. */ AVRational time_base; @@ -2988,6 +2989,14 @@ typedef struct AVCodecContext { */ int initial_padding; + /* + * - decoding: For codecs that store a framerate value in the compressed + * bitstream, the decoder may export it here. { 0, 1} when + * unknown. + * - encoding: unused + */ + AVRational framerate; + /** * Timebase in which pkt_dts/pts and AVPacket.dts/pts are. * Code outside libavcodec should access this field using: diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 34b65e6890..42306cc8a4 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -1147,8 +1147,7 @@ static int decode_seq_header(AVSContext *h) h->low_delay = get_bits1(&h->gb); h->mb_width = (h->width + 15) >> 4; h->mb_height = (h->height + 15) >> 4; - h->avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_code].num; - h->avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_code].den; + h->avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_code]; h->avctx->width = h->width; h->avctx->height = h->height; if (!h->top_qp) diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c index c1f69372c6..07db919be4 100644 --- a/libavcodec/dirac.c +++ b/libavcodec/dirac.c @@ -174,8 +174,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, /* [DIRAC_STD] Table 10.3 values 9-10 */ frame_rate = dirac_frame_rate[source->frame_rate_index - 9]; } - av_reduce(&avctx->time_base.num, &avctx->time_base.den, - frame_rate.den, frame_rate.num, 1 << 30); + avctx->framerate = frame_rate; /* [DIRAC_STD] 10.3.6 Pixel Aspect Ratio. * pixel_aspect_ratio(video_params) */ diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 5751135409..3af14b823c 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -382,7 +382,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, void *data, s->frame->key_frame = 1; s->frame->pict_type = AV_PICTURE_TYPE_I; avctx->pix_fmt = s->sys->pix_fmt; - avctx->time_base = s->sys->time_base; + avctx->framerate = av_inv_q(s->sys->time_base); ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height); if (ret < 0) diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index 4a1af8cf43..d1b7c68595 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -154,7 +154,7 @@ static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t * fps = AV_RL16(&buf[10]); if (fps > 0) - s->avctx->time_base = (AVRational){ 1, fps }; + s->avctx->framerate = (AVRational){ fps, 1 }; pal_start = AV_RL16(&buf[12]); pal_count = AV_RL16(&buf[14]); diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index c768b9361e..813a2d1cdb 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -257,7 +257,7 @@ static int decode_frame(AVCodecContext *avctx, inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG); bytestream2_skip(&gb, 10); - av_reduce(&avctx->time_base.num, &avctx->time_base.den, + av_reduce(&avctx->framerate.den, &avctx->framerate.num, bytestream2_get_le16(&gb), 1000, 1<<30); width = bytestream2_get_le16(&gb); diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index 34cb6428b0..771dc2fb1a 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -53,7 +53,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx) s->avctx = avctx; ff_init_scantable_permutation(idct_permutation, FF_IDCT_PERM_NONE); ff_init_scantable(idct_permutation, &s->scantable, ff_zigzag_direct); - avctx->time_base = (AVRational){1, 15}; + avctx->framerate = (AVRational){ 15, 1 }; avctx->pix_fmt = AV_PIX_FMT_YUV420P; return 0; } diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index b84af809f3..b4d3d1d27d 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -55,7 +55,7 @@ static av_cold int tgv_decode_init(AVCodecContext *avctx) { TgvContext *s = avctx->priv_data; s->avctx = avctx; - avctx->time_base = (AVRational){1, 15}; + avctx->framerate = (AVRational){ 15, 1 }; avctx->pix_fmt = AV_PIX_FMT_PAL8; s->last_frame = av_frame_alloc(); diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index b8e4d7c5d4..34fc30dbba 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -56,7 +56,7 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx) ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE); ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct); s->qscale = 1; - avctx->time_base = (AVRational){1, 15}; + avctx->framerate = (AVRational){ 15, 1 }; avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_mpeg12_init_vlcs(); return 0; diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index ead81fce81..9064f1a012 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -492,7 +492,7 @@ static int h261_decode_picture_header(H261Context *h) i += 32; s->picture_number = (s->picture_number & ~31) + i; - s->avctx->time_base = (AVRational) { 1001, 30000 }; + s->avctx->framerate = (AVRational) { 30000, 1001 }; /* PTYPE starts here */ skip_bits1(&s->gb); /* split screen off */ diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 0405779284..6aa174daf1 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -688,10 +688,10 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) ff_h264_reset_sei(h); if (avctx->codec_id == AV_CODEC_ID_H264) { if (avctx->ticks_per_frame == 1) { - if(h->avctx->time_base.den < INT_MAX/2) { - h->avctx->time_base.den *= 2; + if(h->avctx->framerate.num < INT_MAX/2) { + h->avctx->framerate.num *= 2; } else - h->avctx->time_base.num /= 2; + h->avctx->framerate.den /= 2; } avctx->ticks_per_frame = 2; } diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index ffb7de5237..64aebfa16e 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1170,7 +1170,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) int64_t den = h->sps.time_scale; if (h->x264_build < 44U) den *= 2; - av_reduce(&h->avctx->time_base.num, &h->avctx->time_base.den, + av_reduce(&h->avctx->framerate.den, &h->avctx->framerate.num, h->sps.num_units_in_tick, den, 1 << 30); } diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index 8446e197be..36f147a392 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -351,7 +351,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) } if (num != 0 && den != 0) - av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den, + av_reduce(&s->avctx->framerate.den, &s->avctx->framerate.num, num, den, 1 << 30); return 0; diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 70a8ffe7d7..4a07ac2af1 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -82,7 +82,7 @@ void ff_h263_show_pict_info(MpegEncContext *s){ s->modified_quant ? " MQ" : "", s->loop_filter ? " LOOP" : "", s->h263_slice_structured ? " SS" : "", - s->avctx->time_base.den, s->avctx->time_base.num + s->avctx->framerate.num, s->avctx->framerate.den ); } } @@ -948,7 +948,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s) s->width = width; s->height = height; s->avctx->sample_aspect_ratio= (AVRational){12,11}; - s->avctx->time_base= (AVRational){1001, 30000}; + s->avctx->framerate = (AVRational){ 30000, 1001 }; } else { int ufep; @@ -1047,18 +1047,18 @@ int ff_h263_decode_picture_header(MpegEncContext *s) if(s->custom_pcf){ int gcd; - s->avctx->time_base.den= 1800000; - s->avctx->time_base.num= 1000 + get_bits1(&s->gb); - s->avctx->time_base.num*= get_bits(&s->gb, 7); - if(s->avctx->time_base.num == 0){ + s->avctx->framerate.num = 1800000; + s->avctx->framerate.den = 1000 + get_bits1(&s->gb); + s->avctx->framerate.den *= get_bits(&s->gb, 7); + if(s->avctx->framerate.den == 0){ av_log(s, AV_LOG_ERROR, "zero framerate\n"); return -1; } - gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num); - s->avctx->time_base.den /= gcd; - s->avctx->time_base.num /= gcd; + gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num); + s->avctx->framerate.den /= gcd; + s->avctx->framerate.num /= gcd; }else{ - s->avctx->time_base= (AVRational){1001, 30000}; + s->avctx->framerate = (AVRational){ 30000, 1001 }; } } diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index f20633a29e..dca3379203 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -195,8 +195,8 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avctx) return; } - avctx->time_base.den = p_schro_params->format->frame_rate_numerator; - avctx->time_base.num = p_schro_params->format->frame_rate_denominator; + avctx->framerate.num = p_schro_params->format->frame_rate_numerator; + avctx->framerate.den = p_schro_params->format->frame_rate_denominator; } static int libschroedinger_decode_frame(AVCodecContext *avctx, diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 0add65dff7..1f7fca59e5 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1308,15 +1308,14 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) { // MPEG-1 fps - avctx->time_base.den = ff_mpeg12_frame_rate_tab[s->frame_rate_index].num; - avctx->time_base.num = ff_mpeg12_frame_rate_tab[s->frame_rate_index].den; + avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index]; // MPEG-1 aspect avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255); avctx->ticks_per_frame = 1; } else { // MPEG-2 // MPEG-2 fps - av_reduce(&s->avctx->time_base.den, - &s->avctx->time_base.num, + av_reduce(&s->avctx->framerate.num, + &s->avctx->framerate.den, ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num * 2, ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, 1 << 30); diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 22812926c8..47ac523699 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -1760,23 +1760,24 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) check_marker(gb, "before time_increment_resolution"); - s->avctx->time_base.den = get_bits(gb, 16); - if (!s->avctx->time_base.den) { - av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n"); - s->avctx->time_base.num = 0; + s->avctx->framerate.num = get_bits(gb, 16); + if (!s->avctx->framerate.num) { + av_log(s->avctx, AV_LOG_ERROR, "framerate==0\n"); return -1; } - ctx->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1; + ctx->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1; if (ctx->time_increment_bits < 1) ctx->time_increment_bits = 1; check_marker(gb, "before fixed_vop_rate"); if (get_bits1(gb) != 0) /* fixed_vop_rate */ - s->avctx->time_base.num = get_bits(gb, ctx->time_increment_bits); + s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits); else - s->avctx->time_base.num = 1; + s->avctx->framerate.den = 1; + + s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1})); ctx->t_frame = 0; @@ -2036,7 +2037,7 @@ no_cplx_est: if (s->avctx->debug&FF_DEBUG_PICT_INFO) { av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\n", - s->avctx->time_base.num, s->avctx->time_base.den, + s->avctx->framerate.den, s->avctx->framerate.num, ctx->time_increment_bits, s->quant_precision, s->progressive_sequence, @@ -2264,8 +2265,9 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) av_log(s->avctx, AV_LOG_ERROR, "my guess is %d bits ;)\n", ctx->time_increment_bits); - if (s->avctx->time_base.den && 4*s->avctx->time_base.den < 1<<ctx->time_increment_bits) { - s->avctx->time_base.den = 1<<ctx->time_increment_bits; + if (s->avctx->framerate.num && 4*s->avctx->framerate.num < 1<<ctx->time_increment_bits) { + s->avctx->framerate.num = 1<<ctx->time_increment_bits; + s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1})); } } @@ -2277,19 +2279,19 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) if (s->pict_type != AV_PICTURE_TYPE_B) { s->last_time_base = s->time_base; s->time_base += time_incr; - s->time = s->time_base * s->avctx->time_base.den + time_increment; + s->time = s->time_base * s->avctx->framerate.num + time_increment; if (s->workaround_bugs & FF_BUG_UMP4) { if (s->time < s->last_non_b_time) { /* header is not mpeg-4-compatible, broken encoder, * trying to workaround */ s->time_base++; - s->time += s->avctx->time_base.den; + s->time += s->avctx->framerate.num; } } s->pp_time = s->time - s->last_non_b_time; s->last_non_b_time = s->time; } else { - s->time = (s->last_time_base + time_incr) * s->avctx->time_base.den + time_increment; + s->time = (s->last_time_base + time_incr) * s->avctx->framerate.num + time_increment; s->pb_time = s->pp_time - (s->last_non_b_time - s->time); if (s->pp_time <= s->pb_time || s->pp_time <= s->pp_time - s->pb_time || @@ -2315,8 +2317,8 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) } } - if (s->avctx->time_base.num) - pts = ROUNDED_DIV(s->time, s->avctx->time_base.num); + if (s->avctx->framerate.den) + pts = ROUNDED_DIV(s->time, s->avctx->framerate.den); else pts = AV_NOPTS_VALUE; if (s->avctx->debug&FF_DEBUG_PTS) diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index 44bf26d31f..668a94660b 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -70,8 +70,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, did_set_size=1; } frame_rate_index = buf[3] & 0xf; - pc->frame_rate.den = avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_index].num; - pc->frame_rate.num = avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_index].den; + pc->frame_rate = avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_index]; bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6); avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO; } @@ -95,8 +94,8 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18); if(did_set_size) ff_set_dimensions(avctx, pc->width, pc->height); - avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1) * 2; - avctx->time_base.num = pc->frame_rate.num * (frame_rate_ext_d + 1); + avctx->framerate.num = pc->frame_rate.num * (frame_rate_ext_n + 1) * 2; + avctx->framerate.den = pc->frame_rate.den * (frame_rate_ext_d + 1); avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; } break; @@ -150,6 +149,10 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, ((avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && bit_rate != 0x3FFFF) || vbv_delay != 0xFFFF)) { avctx->bit_rate = 400*bit_rate; } +#if FF_API_AVCTX_TIMEBASE + if (avctx->framerate.num) + avctx->time_base = av_inv_q(avctx->framerate); +#endif } static int mpegvideo_parse(AVCodecParserContext *s, diff --git a/libavcodec/options.c b/libavcodec/options.c index ec9830face..5d818a2031 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -106,6 +106,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) av_opt_set_defaults2(s, flags, flags); s->time_base = (AVRational){0,1}; + s->framerate = (AVRational){ 0, 1 }; s->get_buffer2 = avcodec_default_get_buffer2; s->get_format = avcodec_default_get_format; s->execute = avcodec_default_execute; diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 1db46fcf96..e4f92d9dfd 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -198,6 +198,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, if (dst != src) { dst->time_base = src->time_base; + dst->framerate = src->framerate; dst->width = src->width; dst->height = src->height; dst->pix_fmt = src->pix_fmt; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1b5e3e01d6..12d0196947 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1674,6 +1674,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code } } } + +#if FF_API_AVCTX_TIMEBASE + if (avctx->framerate.num > 0 && avctx->framerate.den > 0) + avctx->time_base = av_inv_q(avctx->framerate); +#endif } end: ff_unlock_avcodec(); @@ -2384,6 +2389,11 @@ fail: * make sure it's set correctly */ av_assert0(!picture->extended_data || picture->extended_data == picture->data); +#if FF_API_AVCTX_TIMEBASE + if (avctx->framerate.num > 0 && avctx->framerate.den > 0) + avctx->time_base = av_inv_q(avctx->framerate); +#endif + return ret; } diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 19adb2b501..23556af995 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -88,7 +88,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan; pic_param->vop_fcode_forward = s->f_code; pic_param->vop_fcode_backward = s->b_code; - pic_param->vop_time_increment_resolution = avctx->time_base.den; + pic_param->vop_time_increment_resolution = avctx->framerate.num; pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s); pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob; pic_param->TRB = s->pb_time; diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 77c4b57d3e..b03eb94167 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -478,19 +478,19 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) if (get_bits1(gb)) { //framerate stuff if (get_bits1(gb)) { - v->s.avctx->time_base.num = 32; - v->s.avctx->time_base.den = get_bits(gb, 16) + 1; + v->s.avctx->framerate.den = 32; + v->s.avctx->framerate.num = get_bits(gb, 16) + 1; } else { int nr, dr; nr = get_bits(gb, 8); dr = get_bits(gb, 4); if (nr > 0 && nr < 8 && dr > 0 && dr < 3) { - v->s.avctx->time_base.num = ff_vc1_fps_dr[dr - 1]; - v->s.avctx->time_base.den = ff_vc1_fps_nr[nr - 1] * 1000; + v->s.avctx->framerate.den = ff_vc1_fps_dr[dr - 1]; + v->s.avctx->framerate.num = ff_vc1_fps_nr[nr - 1] * 1000; } } if (v->broadcast) { // Pulldown may be present - v->s.avctx->time_base.den *= 2; + v->s.avctx->framerate.num *= 2; v->s.avctx->ticks_per_frame = 2; } } diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index fbbacbc3af..2a036b61dd 100644 --- a/libavcodec/vdpau_mpeg4.c +++ b/libavcodec/vdpau_mpeg4.c @@ -61,7 +61,7 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, info->trb[0] = s->pb_time; info->trd[1] = s->pp_field_time >> 1; info->trb[1] = s->pb_field_time >> 1; - info->vop_time_increment_resolution = s->avctx->time_base.den; + info->vop_time_increment_resolution = s->avctx->framerate.num; info->vop_fcode_forward = s->f_code; info->vop_fcode_backward = s->b_code; info->resync_marker_disable = !ctx->resync_marker; diff --git a/libavcodec/version.h b/libavcodec/version.h index 5532a57f4d..ab52d5cf16 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 56 -#define LIBAVCODEC_VERSION_MINOR 6 +#define LIBAVCODEC_VERSION_MINOR 7 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -178,5 +178,8 @@ #ifndef FF_API_AUDIOENC_DELAY #define FF_API_AUDIOENC_DELAY (LIBAVCODEC_VERSION_MAJOR < 58) #endif +#ifndef FF_API_AVCTX_TIMEBASE +#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 4a72d0dbbd..8aca83ae09 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -2269,7 +2269,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) av_log(avctx, AV_LOG_ERROR, "Invalid framerate\n"); return AVERROR_INVALIDDATA; } - av_reduce(&avctx->time_base.num, &avctx->time_base.den, + av_reduce(&avctx->framerate.den, &avctx->framerate.num, fps.den, fps.num, 1 << 30); } |