]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/utils.c
Merge commit '87f98a2b9d4c7218ad82bb45347a53b65e5244f3'
[ffmpeg] / libavcodec / utils.c
index 96f177d870542f906e68c9f554f5e78ef45053e3..4245b1a8132cfdabfe7ca45d55a8a31218eb9ca4 100644 (file)
@@ -428,11 +428,18 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
 
     *width  = FFALIGN(*width, w_align);
     *height = FFALIGN(*height, h_align);
-    if (s->codec_id == AV_CODEC_ID_H264 || s->lowres)
+    if (s->codec_id == AV_CODEC_ID_H264 || s->lowres) {
         // some of the optimized chroma MC reads one line too much
         // which is also done in mpeg decoders with lowres > 0
         *height += 2;
 
+        // H.264 uses edge emulation for out of frame motion vectors, for this
+        // it requires a temporary area large enough to hold a 21x21 block,
+        // increasing witdth ensure that the temporary area is large enough,
+        // the next rounded up width is 32
+        *width = FFMAX(*width, 32);
+    }
+
     for (i = 0; i < 4; i++)
         linesize_align[i] = STRIDE_ALIGN;
 }