[FFmpeg-devel] sanity check error in libswscale, is it needed for a very small mov?

Mo DeJong mosesdejong
Sun Jan 31 23:05:11 CET 2010


Hi all

I am trying to encode a dead simple 1x1 movie with the quicktime qtrle
encoder to test out 24 bit vs 16 bit support (I know 16 bit does not
work right now).
What I wanted to do was run this very small movie through the encoder
to compare the results to what Quicktime emits.

Encoding at 24 bpp works:

ffmpeg -y -r 2 -i m1b1_f%02d.png -vcodec qtrle -pix_fmt rgb24 m1b1_FFMPEG.mov
Input #0, image2, from 'm1b1_f%02d.png':
  Duration: 00:00:01.00, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: png, rgb24, 1x1, 2 tbr, 2 tbn, 2 tbc
Output #0, mov, to 'm1b1_FFMPEG_16bpp.mov':
    Stream #0.0: Video: qtrle, rgb24, 1x1, q=2-31, 200 kb/s, 2 tbn, 2 tbc

But, I tried to pass rgb555 and it blows up like so:

ffmpeg -y -r 2 -i m1b1_f%02d.png -vcodec qtrle -pix_fmt rgb555 m1b1_FFMPEG.mov
Input #0, image2, from 'm1b1_f%02d.png':
  Duration: 00:00:01.00, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: png, rgb24, 1x1, 2 tbr, 2 tbn, 2 tbc
swScaler: 1x1 -> 1x1 is invalid scaling dimension


After looking at that code in libswscale, it seems like the sanity
check for small file is not really needed if the input width and
height are exactly the same as the output width and height. Wtih it, I
don't see the sanity check error for my very small 1x1 movie.

diff --git a/utils.c b/utils.c
index 95edcb4..7feba84 100644
--- a/utils.c
+++ b/utils.c
@@ -828,7 +828,9 @@ SwsContext *sws_getContext(int srcW, int srcH,
enum PixelFormat srcFormat,
     }
     /* sanity check */
-    if (srcW<4 || srcH<1 || dstW<8 || dstH<1) { //FIXME check if
these are enough and try to lowwer them after fixing
the relevant
 parts of the code+    if ((srcW > 0) && (dstW > 0) && (srcW == dstW)
&& (srcH == dstH)) {
+        /* not scaling dimensions, so sanity check is easier */
+    } else if (srcW<4 || srcH<1 || dstW<8 || dstH<1) { //FIXME check
if these are enough and try to lowwer them after
fixing the r
elevant parts of the code
         av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is
invalid scaling dimension\n",
                srcW, srcH, dstW, dstH);
         return NULL;


cheers
Mo DeJong



More information about the ffmpeg-devel mailing list