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) + 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;
+ }
// edge emu needs blocksize + filter length - 1
// (= 17x17 for halfpel / 21x21 for h264)
// VC1 computes luma and chroma simultaneously and needs 19X19 + 9x9
// at uvlinesize. It supports only YUV420 so 24x24 is enough
// linesize * interlaced * MBsize
- FF_ALLOCZ_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size * 2 * 24,
+ // 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_OR_GOTO(avctx, me->scratchpad, alloc_size * 2 * 16 * 3,
++ 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:
}
if (dst->avctx->codec_tag == AV_RL32("VCR2")) {
// exchange uv
- int16_t (*tmp)[64];
- tmp = dst->pblocks[4];
- dst->pblocks[4] = dst->pblocks[5];
- dst->pblocks[5] = tmp;
+ 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;