From f6774f905fb3cfdc319523ac640be30b14c1bc55 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 31 Mar 2014 17:46:29 +0000 Subject: mpegvideo: operate with pointers to AVFrames instead of whole structs The most interesting parts are initialization in ff_MPV_common_init() and uninitialization in ff_MPV_common_end(). ff_mpeg_unref_picture and ff_thread_release_buffer have additional NULL checks for Picture.f, because these functions can be called on uninitialized or partially initialized Pictures. NULL pointer checks are added to ff_thread_release_buffer() stub function. Signed-off-by: Vittorio Giovara --- libavcodec/svq1enc.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'libavcodec/svq1enc.c') diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 7dc407fb96..b937b27979 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -287,11 +287,11 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, s->m.avctx = s->avctx; s->m.current_picture_ptr = &s->m.current_picture; s->m.last_picture_ptr = &s->m.last_picture; - s->m.last_picture.f.data[0] = ref_plane; + s->m.last_picture.f->data[0] = ref_plane; s->m.linesize = - s->m.last_picture.f.linesize[0] = - s->m.new_picture.f.linesize[0] = - s->m.current_picture.f.linesize[0] = stride; + s->m.last_picture.f->linesize[0] = + s->m.new_picture.f->linesize[0] = + s->m.current_picture.f->linesize[0] = stride; s->m.width = width; s->m.height = height; s->m.mb_width = block_width; @@ -339,7 +339,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, s->m.me.dia_size = s->avctx->dia_size; s->m.first_slice_line = 1; for (y = 0; y < block_height; y++) { - s->m.new_picture.f.data[0] = src - y * 16 * stride; // ugly + s->m.new_picture.f->data[0] = src - y * 16 * stride; // ugly s->m.mb_y = y; for (i = 0; i < 16 && i + 16 * y < height; i++) { @@ -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 ret; ff_dsputil_init(&s->dsp, avctx); ff_hpeldsp_init(&s->hdsp, avctx->flags); @@ -554,6 +558,12 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) s->avctx = avctx; s->m.avctx = avctx; + + if ((ret = ff_MPV_common_init(&s->m)) < 0) { + svq1_encode_end(avctx); + return ret; + } + s->m.picture_structure = PICT_FRAME; s->m.me.temp = s->m.me.scratchpad = av_mallocz((avctx->width + 64) * -- cgit v1.2.3