|
|
@ -343,25 +343,25 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s) |
|
|
|
ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); |
|
|
|
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) + 32, 32); |
|
|
|
int alloc_size = FFALIGN(FFABS(linesize) + 32, 32); |
|
|
|
ScratchpadContext *sc = &s->sc; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// edge emu needs blocksize + filter length - 1
|
|
|
|
// edge emu needs blocksize + filter length - 1
|
|
|
|
// (= 17x17 for halfpel / 21x21 for h264)
|
|
|
|
// (= 17x17 for halfpel / 21x21 for h264)
|
|
|
|
// VC1 computes luma and chroma simultaneously and needs 19X19 + 9x9
|
|
|
|
// VC1 computes luma and chroma simultaneously and needs 19X19 + 9x9
|
|
|
|
// at uvlinesize. It supports only YUV420 so 24x24 is enough
|
|
|
|
// at uvlinesize. It supports only YUV420 so 24x24 is enough
|
|
|
|
// linesize * interlaced * MBsize
|
|
|
|
// linesize * interlaced * MBsize
|
|
|
|
FF_ALLOCZ_OR_GOTO(s->avctx, sc->edge_emu_buffer, alloc_size * 2 * 24, |
|
|
|
FF_ALLOCZ_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size * 2 * 24, |
|
|
|
fail); |
|
|
|
fail); |
|
|
|
|
|
|
|
|
|
|
|
FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, alloc_size * 2 * 16 * 3, |
|
|
|
FF_ALLOCZ_OR_GOTO(avctx, me->scratchpad, alloc_size * 2 * 16 * 3, |
|
|
|
fail) |
|
|
|
fail) |
|
|
|
s->me.temp = s->me.scratchpad; |
|
|
|
me->temp = me->scratchpad; |
|
|
|
sc->rd_scratchpad = s->me.scratchpad; |
|
|
|
sc->rd_scratchpad = me->scratchpad; |
|
|
|
sc->b_scratchpad = s->me.scratchpad; |
|
|
|
sc->b_scratchpad = me->scratchpad; |
|
|
|
sc->obmc_scratchpad = s->me.scratchpad + 16; |
|
|
|
sc->obmc_scratchpad = me->scratchpad + 16; |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
fail: |
|
|
|
fail: |
|
|
@ -441,7 +441,8 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!s->sc.edge_emu_buffer && |
|
|
|
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, |
|
|
|
av_log(s->avctx, AV_LOG_ERROR, |
|
|
|
"get_buffer() failed to allocate context scratch buffers.\n"); |
|
|
|
"get_buffer() failed to allocate context scratch buffers.\n"); |
|
|
|
ff_mpeg_unref_picture(s->avctx, pic); |
|
|
|
ff_mpeg_unref_picture(s->avctx, pic); |
|
|
@ -804,7 +805,8 @@ int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src) |
|
|
|
dst->pblocks[5] = tmp; |
|
|
|
dst->pblocks[5] = tmp; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!dst->sc.edge_emu_buffer && |
|
|
|
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 " |
|
|
|
av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context " |
|
|
|
"scratch buffers.\n"); |
|
|
|
"scratch buffers.\n"); |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
@ -919,7 +921,8 @@ do {\ |
|
|
|
// linesize dependend scratch buffer allocation
|
|
|
|
// linesize dependend scratch buffer allocation
|
|
|
|
if (!s->sc.edge_emu_buffer) |
|
|
|
if (!s->sc.edge_emu_buffer) |
|
|
|
if (s1->linesize) { |
|
|
|
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 " |
|
|
|
av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate context " |
|
|
|
"scratch buffers.\n"); |
|
|
|
"scratch buffers.\n"); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|