[FFmpeg-cvslog] lavc: deprecate AVCodecContext.ticks_per_frame
Anton Khirnov
git at videolan.org
Mon May 15 15:16:04 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu May 4 11:50:48 2023 +0200| [7d1d61cc5f57708434ba720b03234b3dd93a4d1e] | committer: Anton Khirnov
lavc: deprecate AVCodecContext.ticks_per_frame
For encoding, this field is entirely redundant with
AVCodecContext.framerate.
For decoding, this field is entirely redundant with
AV_CODEC_PROP_FIELDS.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7d1d61cc5f57708434ba720b03234b3dd93a4d1e
---
doc/APIchanges | 5 +++++
doc/codecs.texi | 1 -
libavcodec/amfenc_av1.c | 8 +++++++-
libavcodec/amfenc_h264.c | 8 +++++++-
libavcodec/amfenc_hevc.c | 8 +++++++-
libavcodec/avcodec.h | 8 ++++++++
libavcodec/encode.c | 4 ++++
libavcodec/h264_slice.c | 2 +-
libavcodec/h264dec.c | 4 ++++
libavcodec/libaomenc.c | 8 +++++++-
libavcodec/libkvazaar.c | 8 +++++++-
libavcodec/libopenh264enc.c | 8 +++++++-
libavcodec/librav1e.c | 9 +++++++--
libavcodec/libsvtav1.c | 8 +++++++-
libavcodec/libvpxenc.c | 8 +++++++-
libavcodec/libx264.c | 8 +++++++-
libavcodec/libx265.c | 8 +++++++-
libavcodec/mfenc.c | 4 ++++
libavcodec/mpeg12dec.c | 8 ++++++++
libavcodec/mpegvideo_parser.c | 8 ++++++++
libavcodec/msmpeg4enc.c | 8 +++++++-
libavcodec/nvenc.c | 16 ++++++++++++++--
libavcodec/options_table.h | 2 ++
libavcodec/pthread_frame.c | 4 ++++
libavcodec/ratecontrol.c | 8 +++++++-
libavcodec/vc1.c | 11 ++++++++---
libavcodec/vc1_parser.c | 3 +--
libavcodec/vc1dec.c | 1 -
libavcodec/version_major.h | 1 +
libavformat/avformat.c | 15 +++++++++++++--
30 files changed, 176 insertions(+), 26 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index b048646283..d2255867a8 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,11 @@ The last version increases of all libraries were on 2023-02-09
API changes, most recent first:
+2023-05-xx - xxxxxxxxxx - lavc 60 - avcodec.h
+ Depreate AVCodecContext.ticks_per_frame in favor of
+ AVCodecContext.framerate (encoding) and
+ AV_CODEC_PROP_FIELDS (decoding).
+
2023-05-xx - xxxxxxxxxx - lavc 60.12.100 - codec_desc.h
Add AV_CODEC_PROP_FIELDS.
diff --git a/doc/codecs.texi b/doc/codecs.texi
index 1adacd2b59..f903dad754 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -775,7 +775,6 @@ Possible values:
@end table
@item rc_max_vbv_use @var{float} (@emph{encoding,video})
@item rc_min_vbv_use @var{float} (@emph{encoding,video})
- at item ticks_per_frame @var{integer} (@emph{decoding/encoding,audio,video})
@item color_primaries @var{integer} (@emph{decoding/encoding,video})
Possible values:
diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c
index 8093cb7357..ad09b7910a 100644
--- a/libavcodec/amfenc_av1.c
+++ b/libavcodec/amfenc_av1.c
@@ -117,7 +117,13 @@ static av_cold int amf_encode_init_av1(AVCodecContext* avctx)
framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den);
}
else {
- framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num * avctx->ticks_per_frame);
+FF_DISABLE_DEPRECATION_WARNINGS
+ framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ );
+FF_ENABLE_DEPRECATION_WARNINGS
}
if ((ret = ff_amf_encode_init(avctx)) < 0)
diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c
index eaf7f974f3..d2fc33971b 100644
--- a/libavcodec/amfenc_h264.c
+++ b/libavcodec/amfenc_h264.c
@@ -142,7 +142,13 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx)
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den);
} else {
- framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num * avctx->ticks_per_frame);
+FF_DISABLE_DEPRECATION_WARNINGS
+ framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ );
+FF_ENABLE_DEPRECATION_WARNINGS
}
if ((ret = ff_amf_encode_init(avctx)) != 0)
diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c
index 9b46946f1e..674a4095d6 100644
--- a/libavcodec/amfenc_hevc.c
+++ b/libavcodec/amfenc_hevc.c
@@ -109,7 +109,13 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx)
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den);
} else {
- framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num * avctx->ticks_per_frame);
+FF_DISABLE_DEPRECATION_WARNINGS
+ framerate = AMFConstructRate(avctx->time_base.den, avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ );
+FF_ENABLE_DEPRECATION_WARNINGS
}
if ((ret = ff_amf_encode_init(avctx)) < 0)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1e91b9cb53..06b1a120ab 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -556,14 +556,22 @@ typedef struct AVCodecContext {
*/
AVRational time_base;
+#if FF_API_TICKS_PER_FRAME
/**
* For some codecs, the time base is closer to the field rate than the frame rate.
* Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
* if no telecine is used ...
*
* Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
+ *
+ * @deprecated
+ * - decoding: Use AVCodecDescriptor.props & AV_CODEC_PROP_FIELDS
+ * - encoding: Set AVCodecContext.framerate instead
+ *
*/
+ attribute_deprecated
int ticks_per_frame;
+#endif
/**
* Codec delay.
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 14e2876742..ab5f889615 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -582,6 +582,8 @@ static int encode_preinit_video(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->ticks_per_frame && avctx->time_base.num &&
avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
av_log(avctx, AV_LOG_ERROR,
@@ -591,6 +593,8 @@ static int encode_preinit_video(AVCodecContext *avctx)
avctx->time_base.den);
return AVERROR(EINVAL);
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->hw_frames_ctx) {
AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 8526782560..be7a8e0b5a 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -957,7 +957,7 @@ static int h264_slice_header_init(H264Context *h)
if (h->x264_build < 44U)
den *= 2;
av_reduce(&h->avctx->framerate.den, &h->avctx->framerate.num,
- sps->num_units_in_tick * h->avctx->ticks_per_frame, den, 1 << 30);
+ sps->num_units_in_tick * 2, den, 1 << 30);
}
ff_h264_free_tables(h);
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index cdd4b98c83..521b1e2235 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -382,7 +382,11 @@ static av_cold int h264_decode_init(AVCodecContext *avctx)
return AVERROR_UNKNOWN;
}
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->ticks_per_frame = 2;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (!avctx->internal->is_copy) {
if (avctx->extradata_size > 0 && avctx->extradata) {
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 1d3a4ae64c..16747e7e92 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -1300,7 +1300,13 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt,
else if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
duration = av_rescale_q(1, av_inv_q(avctx->framerate), avctx->time_base);
else
- duration = avctx->ticks_per_frame ? avctx->ticks_per_frame : 1;
+FF_DISABLE_DEPRECATION_WARNINGS
+ duration =
+#if FF_API_TICKS_PER_FRAME
+ avctx->ticks_per_frame ? avctx->ticks_per_frame :
+#endif
+ 1;
+FF_ENABLE_DEPRECATION_WARNINGS
switch (frame->color_range) {
case AVCOL_RANGE_MPEG:
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index b3faa0a64b..2ef34dd82e 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -86,7 +86,13 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
cfg->framerate_denom = avctx->framerate.den;
} else {
cfg->framerate_num = avctx->time_base.den;
- cfg->framerate_denom = avctx->time_base.num * avctx->ticks_per_frame;
+FF_DISABLE_DEPRECATION_WARNINGS
+ cfg->framerate_denom = avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
}
cfg->target_bitrate = avctx->bit_rate;
cfg->vui.sar_width = avctx->sample_aspect_ratio.num;
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 15c3822824..5b59af6f94 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -139,7 +139,13 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
param.fMaxFrameRate = av_q2d(avctx->framerate);
} else {
- param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base) / FFMAX(avctx->ticks_per_frame, 1);
+FF_DISABLE_DEPRECATION_WARNINGS
+ param.fMaxFrameRate = 1.0 / av_q2d(avctx->time_base)
+#if FF_API_TICKS_PER_FRAME
+ / FFMAX(avctx->ticks_per_frame, 1)
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
}
param.iPicWidth = avctx->width;
param.iPicHeight = avctx->height;
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index 08affabe3e..56539435a7 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -219,10 +219,15 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx)
avctx->framerate.den, avctx->framerate.num
});
} else {
+FF_DISABLE_DEPRECATION_WARNINGS
rav1e_config_set_time_base(cfg, (RaRational) {
- avctx->time_base.num * avctx->ticks_per_frame,
- avctx->time_base.den
+ avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ , avctx->time_base.den
});
+FF_ENABLE_DEPRECATION_WARNINGS
}
if ((avctx->flags & AV_CODEC_FLAG_PASS1 || avctx->flags & AV_CODEC_FLAG_PASS2) && !avctx->bit_rate) {
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 952ed0e1e7..718a04d221 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -250,7 +250,13 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
param->frame_rate_denominator = avctx->framerate.den;
} else {
param->frame_rate_numerator = avctx->time_base.den;
- param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame;
+FF_DISABLE_DEPRECATION_WARNINGS
+ param->frame_rate_denominator = avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
}
/* 2 = IDR, closed GOP, 1 = CRA, open GOP */
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index f70cc87c41..8833df2d68 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1829,7 +1829,13 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
else if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
duration = av_rescale_q(1, av_inv_q(avctx->framerate), avctx->time_base);
else
- duration = avctx->ticks_per_frame ? avctx->ticks_per_frame : 1;
+FF_DISABLE_DEPRECATION_WARNINGS
+ duration =
+#if FF_API_TICKS_PER_FRAME
+ avctx->ticks_per_frame ? avctx->ticks_per_frame :
+#endif
+ 1;
+FF_ENABLE_DEPRECATION_WARNINGS
res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
duration, flags, ctx->deadline);
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 3aea29e995..5736f1efa7 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -1018,7 +1018,13 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.i_fps_den = avctx->framerate.den;
} else {
x4->params.i_fps_num = avctx->time_base.den;
- x4->params.i_fps_den = avctx->time_base.num * avctx->ticks_per_frame;
+FF_DISABLE_DEPRECATION_WARNINGS
+ x4->params.i_fps_den = avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
}
x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 420d0953af..873b3021ee 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -220,7 +220,13 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
ctx->params->fpsDenom = avctx->framerate.den;
} else {
ctx->params->fpsNum = avctx->time_base.den;
- ctx->params->fpsDenom = avctx->time_base.num * avctx->ticks_per_frame;
+FF_DISABLE_DEPRECATION_WARNINGS
+ ctx->params->fpsDenom = avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
}
ctx->params->sourceWidth = avctx->width;
ctx->params->sourceHeight = avctx->height;
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index f3415df10b..8d950a3109 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -659,7 +659,11 @@ static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type)
framerate = avctx->framerate;
} else {
framerate = av_inv_q(avctx->time_base);
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
framerate.den *= avctx->ticks_per_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
ff_MFSetAttributeRatio((IMFAttributes *)type, &MF_MT_FRAME_RATE, framerate.num, framerate.den);
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index ebde68a4dd..27c862ffb2 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1265,7 +1265,11 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
// MPEG-1 fps
avctx->framerate = ff_mpeg12_frame_rate_tab[s1->frame_rate_index];
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->ticks_per_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
} else { // MPEG-2
@@ -1275,7 +1279,11 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
ff_mpeg12_frame_rate_tab[s1->frame_rate_index].num * s1->frame_rate_ext.num,
ff_mpeg12_frame_rate_tab[s1->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->ticks_per_frame = 2;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
switch (s->chroma_format) {
case 1: avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break;
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index 08e5316960..1204789c67 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -145,7 +145,11 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
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;
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->ticks_per_frame = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
break;
case EXT_START_CODE:
@@ -177,7 +181,11 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
avctx->framerate.num = pc->frame_rate.num * (frame_rate_ext_n + 1);
avctx->framerate.den = pc->frame_rate.den * (frame_rate_ext_d + 1);
avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->ticks_per_frame = 2;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
break;
case 0x8: /* picture coding extension */
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index df190d376c..9828901bea 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -285,7 +285,13 @@ void ff_msmpeg4_encode_ext_header(MpegEncContext * s)
if (s->avctx->framerate.num > 0 && s->avctx->framerate.den > 0)
fps = s->avctx->framerate.num / s->avctx->framerate.den;
else
- fps = s->avctx->time_base.den / s->avctx->time_base.num / FFMAX(s->avctx->ticks_per_frame, 1);
+FF_DISABLE_DEPRECATION_WARNINGS
+ fps = s->avctx->time_base.den / s->avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ / FFMAX(s->avctx->ticks_per_frame, 1)
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
put_bits(&s->pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index b2f6253a43..c1798ce564 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1571,7 +1571,13 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
ctx->init_encode_params.frameRateDen = avctx->framerate.den;
} else {
ctx->init_encode_params.frameRateNum = avctx->time_base.den;
- ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame;
+FF_DISABLE_DEPRECATION_WARNINGS
+ ctx->init_encode_params.frameRateDen = avctx->time_base.num
+#if FF_API_TICKS_PER_FRAME
+ * avctx->ticks_per_frame
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
}
ctx->init_encode_params.enableEncodeAsync = 0;
@@ -2266,8 +2272,14 @@ static int nvenc_set_timestamp(AVCodecContext *avctx,
dts = reorder_queue_dequeue(ctx->reorder_queue, avctx, pkt);
if (avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) {
+FF_DISABLE_DEPRECATION_WARNINGS
pkt->dts = dts -
- FFMAX(ctx->encode_config.frameIntervalP - 1, 0) * FFMAX(avctx->ticks_per_frame, 1) * FFMAX(avctx->time_base.num, 1);
+ FFMAX(ctx->encode_config.frameIntervalP - 1, 0)
+#if FF_API_TICKS_PER_FRAME
+ * FFMAX(avctx->ticks_per_frame, 1)
+#endif
+ * FFMAX(avctx->time_base.num, 1);
+FF_ENABLE_DEPRECATION_WARNINGS
} else {
pkt->dts = pkt->pts;
}
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 4f5918c7f6..03059cc39c 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -276,7 +276,9 @@ static const AVOption avcodec_options[] = {
#endif
{"rc_max_vbv_use", NULL, OFFSET(rc_max_available_vbv_use), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0.0, FLT_MAX, V|E},
{"rc_min_vbv_use", NULL, OFFSET(rc_min_vbv_overflow_use), AV_OPT_TYPE_FLOAT, {.dbl = 3 }, 0.0, FLT_MAX, V|E},
+#if FF_API_TICKS_PER_FRAME
{"ticks_per_frame", NULL, OFFSET(ticks_per_frame), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, INT_MAX, A|V|E|D},
+#endif
{"color_primaries", "color primaries", OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64 = AVCOL_PRI_UNSPECIFIED }, 1, INT_MAX, V|E|D, "color_primaries_type"},
{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_BT709 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
{"unknown", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 74864e19c5..773e78ae34 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -286,7 +286,11 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
dst->level = src->level;
dst->bits_per_raw_sample = src->bits_per_raw_sample;
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
dst->ticks_per_frame = src->ticks_per_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
dst->color_primaries = src->color_primaries;
dst->color_trc = src->color_trc;
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 890ae33cb3..649f570c9d 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -60,7 +60,13 @@ static double get_fps(AVCodecContext *avctx)
if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
return av_q2d(avctx->framerate);
- return 1.0 / av_q2d(avctx->time_base) / FFMAX(avctx->ticks_per_frame, 1);
+FF_DISABLE_DEPRECATION_WARNINGS
+ return 1.0 / av_q2d(avctx->time_base)
+#if FF_API_TICKS_PER_FRAME
+ / FFMAX(avctx->ticks_per_frame, 1)
+#endif
+ ;
+FF_ENABLE_DEPRECATION_WARNINGS
}
static inline double qp2bits(RateControlEntry *rce, double qp)
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index d4014d25ab..795c6db541 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -418,6 +418,14 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace,
v->tfcntrflag, v->finterpflag);
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (v->broadcast) { // Pulldown may be present
+ v->s.avctx->ticks_per_frame = 2;
+ }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
v->psf = get_bits1(gb);
if (v->psf) { //PsF, 6.1.13
av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n");
@@ -467,9 +475,6 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
v->s.avctx->framerate.num = ff_vc1_fps_nr[nr - 1] * 1000;
}
}
- if (v->broadcast) { // Pulldown may be present
- v->s.avctx->ticks_per_frame = 2;
- }
}
if (get_bits1(gb)) {
diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index 4167215fb1..ec284dca00 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -89,11 +89,10 @@ static void vc1_extract_header(AVCodecParserContext *s, AVCodecContext *avctx,
else
s->pict_type = vpc->v.s.pict_type;
- if (avctx->ticks_per_frame > 1){
+ if (vpc->v.broadcast){
// process pulldown flags
s->repeat_pict = 1;
// Pulldown flags are only valid when 'broadcast' has been set.
- // So ticks_per_frame will be 2
if (vpc->v.rff){
// repeat field
s->repeat_pict = 2;
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 8298cefbc7..9e343d003f 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1087,7 +1087,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
// process pulldown flags
s->current_picture_ptr->f->repeat_pict = 0;
// Pulldown flags are only valid when 'broadcast' has been set.
- // So ticks_per_frame will be 2
if (v->rff) {
// repeat field
s->current_picture_ptr->f->repeat_pict = 1;
diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h
index 8c3ce43165..2f5138d079 100644
--- a/libavcodec/version_major.h
+++ b/libavcodec/version_major.h
@@ -47,6 +47,7 @@
#define FF_API_AVCTX_FRAME_NUMBER (LIBAVCODEC_VERSION_MAJOR < 61)
#define FF_API_SLICE_OFFSET (LIBAVCODEC_VERSION_MAJOR < 61)
#define FF_API_SUBFRAMES (LIBAVCODEC_VERSION_MAJOR < 61)
+#define FF_API_TICKS_PER_FRAME (LIBAVCODEC_VERSION_MAJOR < 61)
// reminder to remove CrystalHD decoders on next major bump
#define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61)
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index fea905693d..356b4de931 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -710,7 +710,6 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
AVRational dec_ctx_tb = dec_ctx->framerate.num ? av_inv_q(av_mul_q(dec_ctx->framerate, mul))
: (ist->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ? (AVRational){0, 1}
: ist->time_base);
-
enc_ctx->time_base = ist->time_base;
/*
* Avi is a special case here because it supports variable fps but
@@ -727,7 +726,11 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
|| copy_tb == AVFMT_TBCF_R_FRAMERATE) {
enc_ctx->time_base.num = ist->r_frame_rate.den;
enc_ctx->time_base.den = 2*ist->r_frame_rate.num;
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
enc_ctx->ticks_per_frame = 2;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
} else
#endif
if (copy_tb == AVFMT_TBCF_AUTO && dec_ctx->framerate.num &&
@@ -736,9 +739,13 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
|| (copy_tb == AVFMT_TBCF_DECODER &&
(dec_ctx->framerate.num || ist->codecpar->codec_type == AVMEDIA_TYPE_AUDIO))) {
enc_ctx->time_base = dec_ctx_tb;
- enc_ctx->time_base.num *= dec_ctx->ticks_per_frame;
enc_ctx->time_base.den *= 2;
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+ enc_ctx->time_base.num *= dec_ctx->ticks_per_frame;
enc_ctx->ticks_per_frame = 2;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
} else if (!(ofmt->flags & AVFMT_VARIABLE_FPS)
&& !av_match_name(ofmt->name, "mov,mp4,3gp,3g2,psp,ipod,ismv,f4v")) {
@@ -748,7 +755,11 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
|| (copy_tb == AVFMT_TBCF_DECODER &&
(dec_ctx->framerate.num || ist->codecpar->codec_type == AVMEDIA_TYPE_AUDIO))) {
enc_ctx->time_base = dec_ctx_tb;
+#if FF_API_TICKS_PER_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
enc_ctx->time_base.num *= dec_ctx->ticks_per_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
}
More information about the ffmpeg-cvslog
mailing list