summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-06-08 21:16:36 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-06-08 21:16:36 +0200
commite05fda99f7a4e1e80479b4e9b4a92e33dd0c06be (patch)
treea19ac75cb8ff278c7fc69d2dfffdb29b796f62d1 /libavcodec/mpegvideo.c
parentdb8ae37a783aba18d8f869dae1824a3e3f984bf8 (diff)
parentf8716a1408f4f4ec63857b7015fbd62f9eac344a (diff)
Merge commit 'f8716a1408f4f4ec63857b7015fbd62f9eac344a'
* commit 'f8716a1408f4f4ec63857b7015fbd62f9eac344a': mpegvideo: Rework frame_size_alloc function Conflicts: libavcodec/mpegvideo.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 6af7ad5d75..a6511e755b 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -361,16 +361,16 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s)
ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
}
-static int frame_size_alloc(MpegEncContext *s, int linesize)
+int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
+ ScratchpadContext *sc, int linesize)
{
int alloc_size = FFALIGN(FFABS(linesize) + 64, 32);
- ScratchpadContext *sc = &s->sc;
- if (s->avctx->hwaccel || s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
+ if (avctx->hwaccel || avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
return 0;
if (linesize < 24) {
- av_log(s->avctx, AV_LOG_ERROR, "Image too small, temporary buffers cannot function\n");
+ av_log(avctx, AV_LOG_ERROR, "Image too small, temporary buffers cannot function\n");
return AVERROR_PATCHWELCOME;
}
@@ -380,15 +380,15 @@ static int frame_size_alloc(MpegEncContext *s, int linesize)
// at uvlinesize. It supports only YUV420 so 24x24 is enough
// linesize * interlaced * MBsize
// we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines
- FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->sc.edge_emu_buffer, alloc_size, 4 * 68,
+ FF_ALLOCZ_ARRAY_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size, 4 * 68,
fail);
- FF_ALLOCZ_ARRAY_OR_GOTO(s->avctx, s->me.scratchpad, alloc_size, 4 * 16 * 2,
+ FF_ALLOCZ_ARRAY_OR_GOTO(avctx, me->scratchpad, alloc_size, 4 * 16 * 2,
fail)
- s->me.temp = s->me.scratchpad;
- sc->rd_scratchpad = s->me.scratchpad;
- sc->b_scratchpad = s->me.scratchpad;
- sc->obmc_scratchpad = s->me.scratchpad + 16;
+ me->temp = me->scratchpad;
+ sc->rd_scratchpad = me->scratchpad;
+ sc->b_scratchpad = me->scratchpad;
+ sc->obmc_scratchpad = me->scratchpad + 16;
return 0;
fail:
@@ -468,7 +468,8 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
}
if (!s->sc.edge_emu_buffer &&
- (ret = frame_size_alloc(s, pic->f->linesize[0])) < 0) {
+ (ret = ff_mpeg_framesize_alloc(s->avctx, &s->me, &s->sc,
+ pic->f->linesize[0])) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"get_buffer() failed to allocate context scratch buffers.\n");
ff_mpeg_unref_picture(s->avctx, pic);
@@ -847,7 +848,8 @@ int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src)
FFSWAP(void *, dst->pblocks[4], dst->pblocks[5]);
}
if (!dst->sc.edge_emu_buffer &&
- (ret = frame_size_alloc(dst, dst->linesize)) < 0) {
+ (ret = ff_mpeg_framesize_alloc(dst->avctx, &dst->me,
+ &dst->sc, dst->linesize)) < 0) {
av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context "
"scratch buffers.\n");
return ret;
@@ -978,7 +980,8 @@ do {\
// linesize dependend scratch buffer allocation
if (!s->sc.edge_emu_buffer)
if (s1->linesize) {
- if (frame_size_alloc(s, s1->linesize) < 0) {
+ if (ff_mpeg_framesize_alloc(s->avctx, &s->me,
+ &s->sc, s1->linesize) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate context "
"scratch buffers.\n");
return AVERROR(ENOMEM);