aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/decode.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2023-01-24 00:35:54 +0100
committerMarton Balint <cus@passwd.hu>2023-02-13 00:36:46 +0100
commit6b6f7db81932f94876ff4bcfd2da0582b8ab897e (patch)
tree6aaa307f71042d91c6b19736f1cdc6498fd794e5 /libavcodec/decode.c
parente506ea3ce1de0c782b2b833398240c8e19a02bb4 (diff)
downloadffmpeg-6b6f7db81932f94876ff4bcfd2da0582b8ab897e.tar.gz
avcodec: add AVCodecContext.frame_num as 64 bit variant to frame_number
Frame counters can overflow relatively easily (INT_MAX number of frames is slightly more than 1 year for 60 fps content), so make sure we use 64 bit values for them. Also deprecate the old 32 bit frame_number attribute. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r--libavcodec/decode.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 93ecd36c2b..be2be81089 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -711,11 +711,16 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
goto fail;
}
- avctx->frame_number++;
+ avctx->frame_num++;
+#if FF_API_AVCTX_FRAME_NUMBER
+FF_DISABLE_DEPRECATION_WARNINGS
+ avctx->frame_number = avctx->frame_num;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED) {
- if (avctx->frame_number == 1) {
+ if (avctx->frame_num == 1) {
avci->initial_format = frame->format;
switch(avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
@@ -732,7 +737,7 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
}
}
- if (avctx->frame_number > 1) {
+ if (avctx->frame_num > 1) {
changed = avci->initial_format != frame->format;
switch(avctx->codec_type) {
@@ -749,9 +754,9 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
if (changed) {
avci->changed_frames_dropped++;
- av_log(avctx, AV_LOG_INFO, "dropped changed frame #%d pts %"PRId64
+ av_log(avctx, AV_LOG_INFO, "dropped changed frame #%"PRId64" pts %"PRId64
" drop count: %d \n",
- avctx->frame_number, frame->pts,
+ avctx->frame_num, frame->pts,
avci->changed_frames_dropped);
ret = AVERROR_INPUT_CHANGED;
goto fail;
@@ -916,7 +921,12 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
}
if (*got_sub_ptr)
- avctx->frame_number++;
+ avctx->frame_num++;
+#if FF_API_AVCTX_FRAME_NUMBER
+FF_DISABLE_DEPRECATION_WARNINGS
+ avctx->frame_number = avctx->frame_num;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
return ret;