max_pkt_size += mb_width * mb_height * 3 * 4
* s->mjpeg_hsample[0] * s->mjpeg_vsample[0];
}
- if ((ret = ff_alloc_packet(pkt, max_pkt_size)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", max_pkt_size);
- return ret;
+
- if (!s->edge_emu_buffer &&
- (ret = ff_mpv_frame_size_alloc(s, pict->linesize[0])) < 0) {
- av_log(avctx, AV_LOG_ERROR, "failed to allocate context scratch buffers.\n");
- return ret;
++ if (!s->rd_scratchpad) {
++ int alloc_size = FFALIGN(FFABS(pict->linesize[0]) + 64, 32);
++ s->me.scratchpad =
++ s->rd_scratchpad = av_mallocz(alloc_size * 4 * 16 * 2);
++ if (!s->rd_scratchpad) {
++ av_log(avctx, AV_LOG_ERROR, "failed to allocate context scratch buffers.\n");
++ return ret;
++ }
}
+ if ((ret = ff_alloc_packet2(avctx, pkt, max_pkt_size)) < 0)
+ return ret;
+
init_put_bits(&s->pb, pkt->data, pkt->size);
av_frame_unref(p);
return 0;
}
- int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize)
+ static int frame_size_alloc(MpegEncContext *s, int linesize)
{
- int alloc_size = FFALIGN(FFABS(linesize) + 32, 32);
+ int alloc_size = FFALIGN(FFABS(linesize) + 64, 32);
// edge emu needs blocksize + filter length - 1
// (= 17x17 for halfpel / 21x21 for h264)