Commit 9bb11be0 authored by Vittorio Giovara's avatar Vittorio Giovara

mpegvideo: Split picture allocation for encoding and decoding

The main ff_alloc_picture() function is made more generic with all the
parameters necessary as arguments. This will allows to move most of the
related functions to a separate file later.

Right now wrappers are provided to try and minimize the number of
changes in the code.
parent f8716a14
This diff is collapsed.
...@@ -708,7 +708,11 @@ void ff_mpv_motion(MpegEncContext *s, ...@@ -708,7 +708,11 @@ void ff_mpv_motion(MpegEncContext *s,
* Allocate a Picture. * Allocate a Picture.
* The pixels are allocated/set by calling get_buffer() if shared = 0. * The pixels are allocated/set by calling get_buffer() if shared = 0.
*/ */
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared); int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
ScratchpadContext *sc, int shared, int encoding,
int chroma_x_shift, int chroma_y_shift, int out_format,
int mb_stride, int mb_height, int b8_stride,
ptrdiff_t *linesize, ptrdiff_t *uvlinesize);
int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
ScratchpadContext *sc, int linesize); ScratchpadContext *sc, int linesize);
......
...@@ -941,6 +941,13 @@ static int get_intra_count(MpegEncContext *s, uint8_t *src, ...@@ -941,6 +941,13 @@ static int get_intra_count(MpegEncContext *s, uint8_t *src,
return acc; return acc;
} }
static int alloc_picture(MpegEncContext *s, Picture *pic, int shared)
{
return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 1,
s->chroma_x_shift, s->chroma_y_shift, s->out_format,
s->mb_stride, s->mb_height, s->b8_stride,
&s->linesize, &s->uvlinesize);
}
static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
{ {
...@@ -1007,7 +1014,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) ...@@ -1007,7 +1014,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
if ((ret = av_frame_ref(pic->f, pic_arg)) < 0) if ((ret = av_frame_ref(pic->f, pic_arg)) < 0)
return ret; return ret;
} }
ret = ff_alloc_picture(s, pic, direct); ret = alloc_picture(s, pic, direct);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1387,7 +1394,7 @@ no_output_pic: ...@@ -1387,7 +1394,7 @@ no_output_pic:
pic = &s->picture[i]; pic = &s->picture[i];
pic->reference = s->reordered_input_picture[0]->reference; pic->reference = s->reordered_input_picture[0]->reference;
if (ff_alloc_picture(s, pic, 0) < 0) { if (alloc_picture(s, pic, 0) < 0) {
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment