@@ -456,8 +456,6 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
int drop = 0;
bytestream2_init(&s->g, avpkt->data, avpkt->size);
- if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
- return ret;
/* check if this frame is even supposed to change */
if (avpkt->size < 8) {
@@ -492,6 +490,9 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
start_line = 0;
height = s->avctx->height;
}
+ if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
+ return ret;
+
row_ptr = s->frame->linesize[0] * start_line;
switch (avctx->bits_per_coded_sample) {
@@ -553,6 +554,13 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
}
done:
+ if (drop) {
+ // ff_reget_buffer() isn't needed when frames don't change, so just update
+ // frame props.
+ ret = ff_decode_frame_props(avctx, s->frame);
+ if (ret < 0)
+ return ret;
+ }
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
if (drop)
ff_reget_buffer() will attempt to create a writable copy of the frame, which is not needed when the decoder intends to return a reference to the same buffer as the previous frame. Should reduce data copy, hopefully achieving a similar speed up as a9dacdeea6168787a142209bd19fdd74aefc9dd6 without dropping frames. Signed-off-by: James Almer <jamrial@gmail.com> --- And this hopefully works around the other side of the issue. libavcodec/qtrle.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)