[FFmpeg-cvslog] h264: allocate hwaccel privdata after the frame buffer
Hendrik Leppkes
git at videolan.org
Wed Mar 20 12:04:18 CET 2013
ffmpeg | branch: master | Hendrik Leppkes <h.leppkes at gmail.com> | Mon Mar 18 18:54:43 2013 +0100| [9c9ede44f37e291677c0db1c5fabf1c3f6106008] | committer: Anton Khirnov
h264: allocate hwaccel privdata after the frame buffer
This ensures the hwaccel privdata does not leak when a frame buffer could
not be allocated (and toggle the assert when the frame is re-used).
Having no frame buffer available is quite common when using the DXVA2
hwaccel in situations where the DXVA2 renderer is being re-allocated, for
example when moving between displays.
Signed-off-by: Anton Khirnov <anton at khirnov.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9c9ede44f37e291677c0db1c5fabf1c3f6106008
---
libavcodec/h264.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 9b196c7..98ace67 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -318,6 +318,15 @@ static int alloc_picture(H264Context *h, Picture *pic)
av_assert0(!pic->f.data[0]);
+ pic->tf.f = &pic->f;
+ ret = ff_thread_get_buffer(h->avctx, &pic->tf, pic->reference ?
+ AV_GET_BUFFER_FLAG_REF : 0);
+ if (ret < 0)
+ goto fail;
+
+ h->linesize = pic->f.linesize[0];
+ h->uvlinesize = pic->f.linesize[1];
+
if (h->avctx->hwaccel) {
const AVHWAccel *hwaccel = h->avctx->hwaccel;
av_assert0(!pic->hwaccel_picture_private);
@@ -328,14 +337,6 @@ static int alloc_picture(H264Context *h, Picture *pic)
pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data;
}
}
- pic->tf.f = &pic->f;
- ret = ff_thread_get_buffer(h->avctx, &pic->tf, pic->reference ?
- AV_GET_BUFFER_FLAG_REF : 0);
- if (ret < 0)
- goto fail;
-
- h->linesize = pic->f.linesize[0];
- h->uvlinesize = pic->f.linesize[1];
if (!h->qscale_table_pool) {
ret = init_table_pools(h);
More information about the ffmpeg-cvslog
mailing list