summaryrefslogtreecommitdiff
path: root/libavcodec/svq1enc.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2014-03-31 17:46:29 +0000
committerVittorio Giovara <vittorio.giovara@gmail.com>2014-04-09 02:12:19 +0200
commitf6774f905fb3cfdc319523ac640be30b14c1bc55 (patch)
tree6f0db53a2febce58c562d383e1f3f61c9c256275 /libavcodec/svq1enc.c
parent60fd7d36c47d62d4c603bf16c213b1a924f5cfcf (diff)
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 <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/svq1enc.c')
-rw-r--r--libavcodec/svq1enc.c20
1 files changed, 15 insertions, 5 deletions
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) *