summaryrefslogtreecommitdiff
path: root/libavcodec/encode.c
diff options
context:
space:
mode:
authorZhong Li <zhong.li@intel.com>2018-06-28 17:01:46 +0800
committerZhong Li <zhong.li@intel.com>2018-08-27 16:54:40 +0800
commitd91370e0f12a3fedd477616011566d9f2fb5e3e5 (patch)
treee8d0090cc930ebe650437b882f22216e8c976b2d /libavcodec/encode.c
parent3aacb0d196d1c89c386fe26a5df8d994a3eef619 (diff)
lavc/encode: fix frame_number double-counted
Encoder frame_number may be double-counted if some frames are cached and then flushed. Take qsv encoder (some frames are cached firsty for asynchronism) as example, ./ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv -i in.mp4 -vframes 100 -c:v h264_qsv out.mp4 frame_number passed to encoder is double-counted and larger than the accurate value. Libx264 encoding with B frames can also reproduce it. Signed-off-by: Zhong Li <zhong.li@intel.com>
Diffstat (limited to 'libavcodec/encode.c')
-rw-r--r--libavcodec/encode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 0ebd8dd6a5..d12c42526b 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -234,8 +234,8 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
if (ret >= 0)
avpkt->data = avpkt->buf->data;
}
-
- avctx->frame_number++;
+ if (frame)
+ avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr) {
@@ -329,7 +329,8 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
avpkt->data = avpkt->buf->data;
}
- avctx->frame_number++;
+ if (frame)
+ avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr)