ff_MPV_common_init initializes Picture.f, so call it.

s->m.mb_type must be set to NULL before ff_MPV_common_end, because it
attempts to free it.
---
Fixes a crash. Probably should be squashed with the previous commit,
or moved before it.
---
 libavcodec/svq1enc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 23bc4fc..a9b53d1 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -509,6 +509,9 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
            s->rd_total / (double)(avctx->width * avctx->height *
                                   avctx->frame_number));
 
+    s->m.mb_type = NULL;
+    ff_MPV_common_end(&s->m);
+
     av_freep(&s->m.me.scratchpad);
     av_freep(&s->m.me.map);
     av_freep(&s->m.me.score_map);
@@ -531,6 +534,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
 static av_cold int svq1_encode_init(AVCodecContext *avctx)
 {
     SVQ1Context *const s = avctx->priv_data;
+    int r;
 
     ff_dsputil_init(&s->dsp, avctx);
     ff_hpeldsp_init(&s->hdsp, avctx->flags);
@@ -554,6 +558,10 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
 
     s->avctx               = avctx;
     s->m.avctx             = avctx;
+
+    if ((r = ff_MPV_common_init(&s->m)) < 0)
+        return r;
+
     s->m.picture_structure = PICT_FRAME;
     s->m.me.temp           =
     s->m.me.scratchpad     = av_mallocz((avctx->width + 64) *
-- 
1.9.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to