* 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>
... | ... |
@@ -15,6 +15,10 @@ libavutil: 2014-08-09 |
15 | 15 |
|
16 | 16 |
API changes, most recent first: |
17 | 17 |
|
18 |
+2014-10-xx - xxxxxxx - lavc 56.5.0 - avcodec.h |
|
19 |
+ Replace AVCodecContext.time_base used for decoding |
|
20 |
+ with AVCodecContext.framerate. |
|
21 |
+ |
|
18 | 22 |
2014-10-xx - xxxxxxx - lavc 56.4.0 - avcodec.h |
19 | 23 |
Add AV_HWACCEL_FLAG_IGNORE_LEVEL flag to av_vdpau_bind_context(). |
20 | 24 |
|
... | ... |
@@ -1347,7 +1347,8 @@ typedef struct AVCodecContext { |
1347 | 1347 |
* timebase should be 1/framerate and timestamp increments should be |
1348 | 1348 |
* identically 1. |
1349 | 1349 |
* - encoding: MUST be set by user. |
1350 |
- * - decoding: Set by libavcodec. |
|
1350 |
+ * - decoding: the use of this field for decoding is deprecated. |
|
1351 |
+ * Use framerate instead. |
|
1351 | 1352 |
*/ |
1352 | 1353 |
AVRational time_base; |
1353 | 1354 |
|
... | ... |
@@ -2988,6 +2989,14 @@ typedef struct AVCodecContext { |
2988 | 2988 |
*/ |
2989 | 2989 |
int initial_padding; |
2990 | 2990 |
|
2991 |
+ /* |
|
2992 |
+ * - decoding: For codecs that store a framerate value in the compressed |
|
2993 |
+ * bitstream, the decoder may export it here. { 0, 1} when |
|
2994 |
+ * unknown. |
|
2995 |
+ * - encoding: unused |
|
2996 |
+ */ |
|
2997 |
+ AVRational framerate; |
|
2998 |
+ |
|
2991 | 2999 |
/** |
2992 | 3000 |
* Timebase in which pkt_dts/pts and AVPacket.dts/pts are. |
2993 | 3001 |
* Code outside libavcodec should access this field using: |
... | ... |
@@ -1147,8 +1147,7 @@ static int decode_seq_header(AVSContext *h) |
1147 | 1147 |
h->low_delay = get_bits1(&h->gb); |
1148 | 1148 |
h->mb_width = (h->width + 15) >> 4; |
1149 | 1149 |
h->mb_height = (h->height + 15) >> 4; |
1150 |
- h->avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_code].num; |
|
1151 |
- h->avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_code].den; |
|
1150 |
+ h->avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_code]; |
|
1152 | 1151 |
h->avctx->width = h->width; |
1153 | 1152 |
h->avctx->height = h->height; |
1154 | 1153 |
if (!h->top_qp) |
... | ... |
@@ -174,8 +174,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, |
174 | 174 |
/* [DIRAC_STD] Table 10.3 values 9-10 */ |
175 | 175 |
frame_rate = dirac_frame_rate[source->frame_rate_index - 9]; |
176 | 176 |
} |
177 |
- av_reduce(&avctx->time_base.num, &avctx->time_base.den, |
|
178 |
- frame_rate.den, frame_rate.num, 1 << 30); |
|
177 |
+ avctx->framerate = frame_rate; |
|
179 | 178 |
|
180 | 179 |
/* [DIRAC_STD] 10.3.6 Pixel Aspect Ratio. |
181 | 180 |
* pixel_aspect_ratio(video_params) */ |
... | ... |
@@ -382,7 +382,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, void *data, |
382 | 382 |
s->frame->key_frame = 1; |
383 | 383 |
s->frame->pict_type = AV_PICTURE_TYPE_I; |
384 | 384 |
avctx->pix_fmt = s->sys->pix_fmt; |
385 |
- avctx->time_base = s->sys->time_base; |
|
385 |
+ avctx->framerate = av_inv_q(s->sys->time_base); |
|
386 | 386 |
|
387 | 387 |
ret = ff_set_dimensions(avctx, s->sys->width, s->sys->height); |
388 | 388 |
if (ret < 0) |
... | ... |
@@ -154,7 +154,7 @@ static int cmv_process_header(CmvContext *s, const uint8_t *buf, const uint8_t * |
154 | 154 |
|
155 | 155 |
fps = AV_RL16(&buf[10]); |
156 | 156 |
if (fps > 0) |
157 |
- s->avctx->time_base = (AVRational){ 1, fps }; |
|
157 |
+ s->avctx->framerate = (AVRational){ fps, 1 }; |
|
158 | 158 |
|
159 | 159 |
pal_start = AV_RL16(&buf[12]); |
160 | 160 |
pal_count = AV_RL16(&buf[14]); |
... | ... |
@@ -257,7 +257,7 @@ static int decode_frame(AVCodecContext *avctx, |
257 | 257 |
inter = (chunk_type == MADm_TAG || chunk_type == MADe_TAG); |
258 | 258 |
bytestream2_skip(&gb, 10); |
259 | 259 |
|
260 |
- av_reduce(&avctx->time_base.num, &avctx->time_base.den, |
|
260 |
+ av_reduce(&avctx->framerate.den, &avctx->framerate.num, |
|
261 | 261 |
bytestream2_get_le16(&gb), 1000, 1<<30); |
262 | 262 |
|
263 | 263 |
width = bytestream2_get_le16(&gb); |
... | ... |
@@ -53,7 +53,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx) |
53 | 53 |
s->avctx = avctx; |
54 | 54 |
ff_init_scantable_permutation(idct_permutation, FF_IDCT_PERM_NONE); |
55 | 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 | 57 |
avctx->pix_fmt = AV_PIX_FMT_YUV420P; |
58 | 58 |
return 0; |
59 | 59 |
} |
... | ... |
@@ -55,7 +55,7 @@ static av_cold int tgv_decode_init(AVCodecContext *avctx) |
55 | 55 |
{ |
56 | 56 |
TgvContext *s = avctx->priv_data; |
57 | 57 |
s->avctx = avctx; |
58 |
- avctx->time_base = (AVRational){1, 15}; |
|
58 |
+ avctx->framerate = (AVRational){ 15, 1 }; |
|
59 | 59 |
avctx->pix_fmt = AV_PIX_FMT_PAL8; |
60 | 60 |
|
61 | 61 |
s->last_frame = av_frame_alloc(); |
... | ... |
@@ -56,7 +56,7 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx) |
56 | 56 |
ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE); |
57 | 57 |
ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct); |
58 | 58 |
s->qscale = 1; |
59 |
- avctx->time_base = (AVRational){1, 15}; |
|
59 |
+ avctx->framerate = (AVRational){ 15, 1 }; |
|
60 | 60 |
avctx->pix_fmt = AV_PIX_FMT_YUV420P; |
61 | 61 |
ff_mpeg12_init_vlcs(); |
62 | 62 |
return 0; |
... | ... |
@@ -492,7 +492,7 @@ static int h261_decode_picture_header(H261Context *h) |
492 | 492 |
i += 32; |
493 | 493 |
s->picture_number = (s->picture_number & ~31) + i; |
494 | 494 |
|
495 |
- s->avctx->time_base = (AVRational) { 1001, 30000 }; |
|
495 |
+ s->avctx->framerate = (AVRational) { 30000, 1001 }; |
|
496 | 496 |
|
497 | 497 |
/* PTYPE starts here */ |
498 | 498 |
skip_bits1(&s->gb); /* split screen off */ |
... | ... |
@@ -688,10 +688,10 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx) |
688 | 688 |
ff_h264_reset_sei(h); |
689 | 689 |
if (avctx->codec_id == AV_CODEC_ID_H264) { |
690 | 690 |
if (avctx->ticks_per_frame == 1) { |
691 |
- if(h->avctx->time_base.den < INT_MAX/2) { |
|
692 |
- h->avctx->time_base.den *= 2; |
|
691 |
+ if(h->avctx->framerate.num < INT_MAX/2) { |
|
692 |
+ h->avctx->framerate.num *= 2; |
|
693 | 693 |
} else |
694 |
- h->avctx->time_base.num /= 2; |
|
694 |
+ h->avctx->framerate.den /= 2; |
|
695 | 695 |
} |
696 | 696 |
avctx->ticks_per_frame = 2; |
697 | 697 |
} |
... | ... |
@@ -1170,7 +1170,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) |
1170 | 1170 |
int64_t den = h->sps.time_scale; |
1171 | 1171 |
if (h->x264_build < 44U) |
1172 | 1172 |
den *= 2; |
1173 |
- av_reduce(&h->avctx->time_base.num, &h->avctx->time_base.den, |
|
1173 |
+ av_reduce(&h->avctx->framerate.den, &h->avctx->framerate.num, |
|
1174 | 1174 |
h->sps.num_units_in_tick, den, 1 << 30); |
1175 | 1175 |
} |
1176 | 1176 |
|
... | ... |
@@ -351,7 +351,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps) |
351 | 351 |
} |
352 | 352 |
|
353 | 353 |
if (num != 0 && den != 0) |
354 |
- av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den, |
|
354 |
+ av_reduce(&s->avctx->framerate.den, &s->avctx->framerate.num, |
|
355 | 355 |
num, den, 1 << 30); |
356 | 356 |
|
357 | 357 |
return 0; |
... | ... |
@@ -82,7 +82,7 @@ void ff_h263_show_pict_info(MpegEncContext *s){ |
82 | 82 |
s->modified_quant ? " MQ" : "", |
83 | 83 |
s->loop_filter ? " LOOP" : "", |
84 | 84 |
s->h263_slice_structured ? " SS" : "", |
85 |
- s->avctx->time_base.den, s->avctx->time_base.num |
|
85 |
+ s->avctx->framerate.num, s->avctx->framerate.den |
|
86 | 86 |
); |
87 | 87 |
} |
88 | 88 |
} |
... | ... |
@@ -948,7 +948,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s) |
948 | 948 |
s->width = width; |
949 | 949 |
s->height = height; |
950 | 950 |
s->avctx->sample_aspect_ratio= (AVRational){12,11}; |
951 |
- s->avctx->time_base= (AVRational){1001, 30000}; |
|
951 |
+ s->avctx->framerate = (AVRational){ 30000, 1001 }; |
|
952 | 952 |
} else { |
953 | 953 |
int ufep; |
954 | 954 |
|
... | ... |
@@ -1047,18 +1047,18 @@ int ff_h263_decode_picture_header(MpegEncContext *s) |
1047 | 1047 |
|
1048 | 1048 |
if(s->custom_pcf){ |
1049 | 1049 |
int gcd; |
1050 |
- s->avctx->time_base.den= 1800000; |
|
1051 |
- s->avctx->time_base.num= 1000 + get_bits1(&s->gb); |
|
1052 |
- s->avctx->time_base.num*= get_bits(&s->gb, 7); |
|
1053 |
- if(s->avctx->time_base.num == 0){ |
|
1050 |
+ s->avctx->framerate.num = 1800000; |
|
1051 |
+ s->avctx->framerate.den = 1000 + get_bits1(&s->gb); |
|
1052 |
+ s->avctx->framerate.den *= get_bits(&s->gb, 7); |
|
1053 |
+ if(s->avctx->framerate.den == 0){ |
|
1054 | 1054 |
av_log(s, AV_LOG_ERROR, "zero framerate\n"); |
1055 | 1055 |
return -1; |
1056 | 1056 |
} |
1057 |
- gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num); |
|
1058 |
- s->avctx->time_base.den /= gcd; |
|
1059 |
- s->avctx->time_base.num /= gcd; |
|
1057 |
+ gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num); |
|
1058 |
+ s->avctx->framerate.den /= gcd; |
|
1059 |
+ s->avctx->framerate.num /= gcd; |
|
1060 | 1060 |
}else{ |
1061 |
- s->avctx->time_base= (AVRational){1001, 30000}; |
|
1061 |
+ s->avctx->framerate = (AVRational){ 30000, 1001 }; |
|
1062 | 1062 |
} |
1063 | 1063 |
} |
1064 | 1064 |
|
... | ... |
@@ -195,8 +195,8 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avctx) |
195 | 195 |
return; |
196 | 196 |
} |
197 | 197 |
|
198 |
- avctx->time_base.den = p_schro_params->format->frame_rate_numerator; |
|
199 |
- avctx->time_base.num = p_schro_params->format->frame_rate_denominator; |
|
198 |
+ avctx->framerate.num = p_schro_params->format->frame_rate_numerator; |
|
199 |
+ avctx->framerate.den = p_schro_params->format->frame_rate_denominator; |
|
200 | 200 |
} |
201 | 201 |
|
202 | 202 |
static int libschroedinger_decode_frame(AVCodecContext *avctx, |
... | ... |
@@ -1308,15 +1308,14 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) |
1308 | 1308 |
|
1309 | 1309 |
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) { |
1310 | 1310 |
// MPEG-1 fps |
1311 |
- avctx->time_base.den = ff_mpeg12_frame_rate_tab[s->frame_rate_index].num; |
|
1312 |
- avctx->time_base.num = ff_mpeg12_frame_rate_tab[s->frame_rate_index].den; |
|
1311 |
+ avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index]; |
|
1313 | 1312 |
// MPEG-1 aspect |
1314 | 1313 |
avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255); |
1315 | 1314 |
avctx->ticks_per_frame = 1; |
1316 | 1315 |
} else { // MPEG-2 |
1317 | 1316 |
// MPEG-2 fps |
1318 |
- av_reduce(&s->avctx->time_base.den, |
|
1319 |
- &s->avctx->time_base.num, |
|
1317 |
+ av_reduce(&s->avctx->framerate.num, |
|
1318 |
+ &s->avctx->framerate.den, |
|
1320 | 1319 |
ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num * 2, |
1321 | 1320 |
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, |
1322 | 1321 |
1 << 30); |
... | ... |
@@ -1760,23 +1760,24 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) |
1760 | 1760 |
|
1761 | 1761 |
check_marker(gb, "before time_increment_resolution"); |
1762 | 1762 |
|
1763 |
- s->avctx->time_base.den = get_bits(gb, 16); |
|
1764 |
- if (!s->avctx->time_base.den) { |
|
1765 |
- av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n"); |
|
1766 |
- s->avctx->time_base.num = 0; |
|
1763 |
+ s->avctx->framerate.num = get_bits(gb, 16); |
|
1764 |
+ if (!s->avctx->framerate.num) { |
|
1765 |
+ av_log(s->avctx, AV_LOG_ERROR, "framerate==0\n"); |
|
1767 | 1766 |
return -1; |
1768 | 1767 |
} |
1769 | 1768 |
|
1770 |
- ctx->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1; |
|
1769 |
+ ctx->time_increment_bits = av_log2(s->avctx->framerate.num - 1) + 1; |
|
1771 | 1770 |
if (ctx->time_increment_bits < 1) |
1772 | 1771 |
ctx->time_increment_bits = 1; |
1773 | 1772 |
|
1774 | 1773 |
check_marker(gb, "before fixed_vop_rate"); |
1775 | 1774 |
|
1776 | 1775 |
if (get_bits1(gb) != 0) /* fixed_vop_rate */ |
1777 |
- s->avctx->time_base.num = get_bits(gb, ctx->time_increment_bits); |
|
1776 |
+ s->avctx->framerate.den = get_bits(gb, ctx->time_increment_bits); |
|
1778 | 1777 |
else |
1779 |
- s->avctx->time_base.num = 1; |
|
1778 |
+ s->avctx->framerate.den = 1; |
|
1779 |
+ |
|
1780 |
+ s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1})); |
|
1780 | 1781 |
|
1781 | 1782 |
ctx->t_frame = 0; |
1782 | 1783 |
|
... | ... |
@@ -2036,7 +2037,7 @@ no_cplx_est: |
2036 | 2036 |
|
2037 | 2037 |
if (s->avctx->debug&FF_DEBUG_PICT_INFO) { |
2038 | 2038 |
av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\n", |
2039 |
- s->avctx->time_base.num, s->avctx->time_base.den, |
|
2039 |
+ s->avctx->framerate.den, s->avctx->framerate.num, |
|
2040 | 2040 |
ctx->time_increment_bits, |
2041 | 2041 |
s->quant_precision, |
2042 | 2042 |
s->progressive_sequence, |
... | ... |
@@ -2264,8 +2265,9 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) |
2264 | 2264 |
|
2265 | 2265 |
av_log(s->avctx, AV_LOG_ERROR, |
2266 | 2266 |
"my guess is %d bits ;)\n", ctx->time_increment_bits); |
2267 |
- if (s->avctx->time_base.den && 4*s->avctx->time_base.den < 1<<ctx->time_increment_bits) { |
|
2268 |
- s->avctx->time_base.den = 1<<ctx->time_increment_bits; |
|
2267 |
+ if (s->avctx->framerate.num && 4*s->avctx->framerate.num < 1<<ctx->time_increment_bits) { |
|
2268 |
+ s->avctx->framerate.num = 1<<ctx->time_increment_bits; |
|
2269 |
+ s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1})); |
|
2269 | 2270 |
} |
2270 | 2271 |
} |
2271 | 2272 |
|
... | ... |
@@ -2277,19 +2279,19 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) |
2277 | 2277 |
if (s->pict_type != AV_PICTURE_TYPE_B) { |
2278 | 2278 |
s->last_time_base = s->time_base; |
2279 | 2279 |
s->time_base += time_incr; |
2280 |
- s->time = s->time_base * s->avctx->time_base.den + time_increment; |
|
2280 |
+ s->time = s->time_base * s->avctx->framerate.num + time_increment; |
|
2281 | 2281 |
if (s->workaround_bugs & FF_BUG_UMP4) { |
2282 | 2282 |
if (s->time < s->last_non_b_time) { |
2283 | 2283 |
/* header is not mpeg-4-compatible, broken encoder, |
2284 | 2284 |
* trying to workaround */ |
2285 | 2285 |
s->time_base++; |
2286 |
- s->time += s->avctx->time_base.den; |
|
2286 |
+ s->time += s->avctx->framerate.num; |
|
2287 | 2287 |
} |
2288 | 2288 |
} |
2289 | 2289 |
s->pp_time = s->time - s->last_non_b_time; |
2290 | 2290 |
s->last_non_b_time = s->time; |
2291 | 2291 |
} else { |
2292 |
- s->time = (s->last_time_base + time_incr) * s->avctx->time_base.den + time_increment; |
|
2292 |
+ s->time = (s->last_time_base + time_incr) * s->avctx->framerate.num + time_increment; |
|
2293 | 2293 |
s->pb_time = s->pp_time - (s->last_non_b_time - s->time); |
2294 | 2294 |
if (s->pp_time <= s->pb_time || |
2295 | 2295 |
s->pp_time <= s->pp_time - s->pb_time || |
... | ... |
@@ -2315,8 +2317,8 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) |
2315 | 2315 |
} |
2316 | 2316 |
} |
2317 | 2317 |
|
2318 |
- if (s->avctx->time_base.num) |
|
2319 |
- pts = ROUNDED_DIV(s->time, s->avctx->time_base.num); |
|
2318 |
+ if (s->avctx->framerate.den) |
|
2319 |
+ pts = ROUNDED_DIV(s->time, s->avctx->framerate.den); |
|
2320 | 2320 |
else |
2321 | 2321 |
pts = AV_NOPTS_VALUE; |
2322 | 2322 |
if (s->avctx->debug&FF_DEBUG_PTS) |
... | ... |
@@ -70,8 +70,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, |
70 | 70 |
did_set_size=1; |
71 | 71 |
} |
72 | 72 |
frame_rate_index = buf[3] & 0xf; |
73 |
- pc->frame_rate.den = avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_index].num; |
|
74 |
- pc->frame_rate.num = avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_index].den; |
|
73 |
+ pc->frame_rate = avctx->framerate = ff_mpeg12_frame_rate_tab[frame_rate_index]; |
|
75 | 74 |
bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6); |
76 | 75 |
avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO; |
77 | 76 |
} |
... | ... |
@@ -95,8 +94,8 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, |
95 | 95 |
bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18); |
96 | 96 |
if(did_set_size) |
97 | 97 |
ff_set_dimensions(avctx, pc->width, pc->height); |
98 |
- avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1) * 2; |
|
99 |
- avctx->time_base.num = pc->frame_rate.num * (frame_rate_ext_d + 1); |
|
98 |
+ avctx->framerate.num = pc->frame_rate.num * (frame_rate_ext_n + 1) * 2; |
|
99 |
+ avctx->framerate.den = pc->frame_rate.den * (frame_rate_ext_d + 1); |
|
100 | 100 |
avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; |
101 | 101 |
} |
102 | 102 |
break; |
... | ... |
@@ -150,6 +149,10 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, |
150 | 150 |
((avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && bit_rate != 0x3FFFF) || vbv_delay != 0xFFFF)) { |
151 | 151 |
avctx->bit_rate = 400*bit_rate; |
152 | 152 |
} |
153 |
+#if FF_API_AVCTX_TIMEBASE |
|
154 |
+ if (avctx->framerate.num) |
|
155 |
+ avctx->time_base = av_inv_q(avctx->framerate); |
|
156 |
+#endif |
|
153 | 157 |
} |
154 | 158 |
|
155 | 159 |
static int mpegvideo_parse(AVCodecParserContext *s, |
... | ... |
@@ -106,6 +106,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) |
106 | 106 |
av_opt_set_defaults2(s, flags, flags); |
107 | 107 |
|
108 | 108 |
s->time_base = (AVRational){0,1}; |
109 |
+ s->framerate = (AVRational){ 0, 1 }; |
|
109 | 110 |
s->get_buffer2 = avcodec_default_get_buffer2; |
110 | 111 |
s->get_format = avcodec_default_get_format; |
111 | 112 |
s->execute = avcodec_default_execute; |
... | ... |
@@ -198,6 +198,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, |
198 | 198 |
|
199 | 199 |
if (dst != src) { |
200 | 200 |
dst->time_base = src->time_base; |
201 |
+ dst->framerate = src->framerate; |
|
201 | 202 |
dst->width = src->width; |
202 | 203 |
dst->height = src->height; |
203 | 204 |
dst->pix_fmt = src->pix_fmt; |
... | ... |
@@ -1674,6 +1674,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code |
1674 | 1674 |
} |
1675 | 1675 |
} |
1676 | 1676 |
} |
1677 |
+ |
|
1678 |
+#if FF_API_AVCTX_TIMEBASE |
|
1679 |
+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) |
|
1680 |
+ avctx->time_base = av_inv_q(avctx->framerate); |
|
1681 |
+#endif |
|
1677 | 1682 |
} |
1678 | 1683 |
end: |
1679 | 1684 |
ff_unlock_avcodec(); |
... | ... |
@@ -2384,6 +2389,11 @@ fail: |
2384 | 2384 |
* make sure it's set correctly */ |
2385 | 2385 |
av_assert0(!picture->extended_data || picture->extended_data == picture->data); |
2386 | 2386 |
|
2387 |
+#if FF_API_AVCTX_TIMEBASE |
|
2388 |
+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) |
|
2389 |
+ avctx->time_base = av_inv_q(avctx->framerate); |
|
2390 |
+#endif |
|
2391 |
+ |
|
2387 | 2392 |
return ret; |
2388 | 2393 |
} |
2389 | 2394 |
|
... | ... |
@@ -88,7 +88,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ |
88 | 88 |
pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan; |
89 | 89 |
pic_param->vop_fcode_forward = s->f_code; |
90 | 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 | 92 |
pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s); |
93 | 93 |
pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob; |
94 | 94 |
pic_param->TRB = s->pb_time; |
... | ... |
@@ -478,19 +478,19 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) |
478 | 478 |
|
479 | 479 |
if (get_bits1(gb)) { //framerate stuff |
480 | 480 |
if (get_bits1(gb)) { |
481 |
- v->s.avctx->time_base.num = 32; |
|
482 |
- v->s.avctx->time_base.den = get_bits(gb, 16) + 1; |
|
481 |
+ v->s.avctx->framerate.den = 32; |
|
482 |
+ v->s.avctx->framerate.num = get_bits(gb, 16) + 1; |
|
483 | 483 |
} else { |
484 | 484 |
int nr, dr; |
485 | 485 |
nr = get_bits(gb, 8); |
486 | 486 |
dr = get_bits(gb, 4); |
487 | 487 |
if (nr > 0 && nr < 8 && dr > 0 && dr < 3) { |
488 |
- v->s.avctx->time_base.num = ff_vc1_fps_dr[dr - 1]; |
|
489 |
- v->s.avctx->time_base.den = ff_vc1_fps_nr[nr - 1] * 1000; |
|
488 |
+ v->s.avctx->framerate.den = ff_vc1_fps_dr[dr - 1]; |
|
489 |
+ v->s.avctx->framerate.num = ff_vc1_fps_nr[nr - 1] * 1000; |
|
490 | 490 |
} |
491 | 491 |
} |
492 | 492 |
if (v->broadcast) { // Pulldown may be present |
493 |
- v->s.avctx->time_base.den *= 2; |
|
493 |
+ v->s.avctx->framerate.num *= 2; |
|
494 | 494 |
v->s.avctx->ticks_per_frame = 2; |
495 | 495 |
} |
496 | 496 |
} |
... | ... |
@@ -61,7 +61,7 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, |
61 | 61 |
info->trb[0] = s->pb_time; |
62 | 62 |
info->trd[1] = s->pp_field_time >> 1; |
63 | 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 | 65 |
info->vop_fcode_forward = s->f_code; |
66 | 66 |
info->vop_fcode_backward = s->b_code; |
67 | 67 |
info->resync_marker_disable = !ctx->resync_marker; |
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
#include "libavutil/version.h" |
30 | 30 |
|
31 | 31 |
#define LIBAVCODEC_VERSION_MAJOR 56 |
32 |
-#define LIBAVCODEC_VERSION_MINOR 6 |
|
32 |
+#define LIBAVCODEC_VERSION_MINOR 7 |
|
33 | 33 |
#define LIBAVCODEC_VERSION_MICRO 100 |
34 | 34 |
|
35 | 35 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
... | ... |
@@ -178,5 +178,8 @@ |
178 | 178 |
#ifndef FF_API_AUDIOENC_DELAY |
179 | 179 |
#define FF_API_AUDIOENC_DELAY (LIBAVCODEC_VERSION_MAJOR < 58) |
180 | 180 |
#endif |
181 |
+#ifndef FF_API_AVCTX_TIMEBASE |
|
182 |
+#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59) |
|
183 |
+#endif |
|
181 | 184 |
|
182 | 185 |
#endif /* AVCODEC_VERSION_H */ |
... | ... |
@@ -2269,7 +2269,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb) |
2269 | 2269 |
av_log(avctx, AV_LOG_ERROR, "Invalid framerate\n"); |
2270 | 2270 |
return AVERROR_INVALIDDATA; |
2271 | 2271 |
} |
2272 |
- av_reduce(&avctx->time_base.num, &avctx->time_base.den, |
|
2272 |
+ av_reduce(&avctx->framerate.den, &avctx->framerate.num, |
|
2273 | 2273 |
fps.den, fps.num, 1 << 30); |
2274 | 2274 |
} |
2275 | 2275 |
|