[FFmpeg-cvslog] avcodec/asvenc: fix encoding dimensions %16 != 0
Michael Niedermayer
git at videolan.org
Sat May 31 17:24:03 CEST 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat May 31 17:07:12 2014 +0200| [e692c9672b28230419c912f90f4f3852cdd71dd0] | committer: Michael Niedermayer
avcodec/asvenc: fix encoding dimensions %16 != 0
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e692c9672b28230419c912f90f4f3852cdd71dd0
---
libavcodec/asvenc.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index b098f47..39e2315 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -181,6 +181,48 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int size, ret;
int mb_x, mb_y;
+ if (pict->width % 16 || pict->height % 16) {
+ AVFrame *clone = av_frame_alloc();
+ int i;
+
+ if (!clone)
+ return AVERROR(ENOMEM);
+ clone->format = pict->format;
+ clone->width = FFALIGN(pict->width, 16);
+ clone->height = FFALIGN(pict->height, 16);
+ ret = av_frame_get_buffer(clone, 32);
+ if (ret < 0) {
+ av_frame_free(&clone);
+ return ret;
+ }
+
+ ret = av_frame_copy(clone, pict);
+ if (ret < 0) {
+ av_frame_free(&clone);
+ return ret;
+ }
+
+ for (i = 0; i<3; i++) {
+ int x, y;
+ int w = FF_CEIL_RSHIFT(pict->width, !!i);
+ int h = FF_CEIL_RSHIFT(pict->height, !!i);
+ int w2 = FF_CEIL_RSHIFT(clone->width, !!i);
+ int h2 = FF_CEIL_RSHIFT(clone->height, !!i);
+ for (y=0; y<h; y++)
+ for (x=w; x<w2; x++)
+ clone->data[i][x + y*clone->linesize[i]] =
+ clone->data[i][w - 1 + y*clone->linesize[i]];
+ for (y=h; y<h2; y++)
+ for (x=0; x<w2; x++)
+ clone->data[i][x + y*clone->linesize[i]] =
+ clone->data[i][x + (h-1)*clone->linesize[i]];
+ }
+ ret = encode_frame(avctx, pkt, clone, got_packet);
+
+ av_frame_free(&clone);
+ return ret;
+ }
+
if ((ret = ff_alloc_packet2(avctx, pkt, a->mb_height*a->mb_width*MAX_MB_SIZE +
FF_MIN_BUFFER_SIZE)) < 0)
return ret;
More information about the ffmpeg-cvslog
mailing list