[FFmpeg-devel] FFV1: conspicious filesize oddities

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Oct 29 20:02:40 CET 2013


On Tue, Oct 29, 2013 at 07:52:45PM +0100, Peter B. wrote:
> Hello,
> 
> While creating FATE tests for FFV1, I've realized a peculiar filesize
> difference when encoding a certain video in yuv444p.
> 
> "ls" output shows:
> ----------------------
> 1162564 Oct 29 19:35 yuv444p10.avi
> 265940 Oct 29 19:35 yuv444p16.avi
> 881960 Oct 29 19:35 yuv444p9.avi
> 265746 Oct 29 19:41 yuv444p.avi
> ----------------------
> 
> This seems strange to me:
> 1) 16bit version is only ~200 kiB larger than the 8bit version
> 2) The 10bit version is more than 4 times (!) bigger than the 16bit version

I have the suspicion that the encoder doesn't like the data it gets for
the 10 bit case.
I tried this hack, which decreases the file size to around 500 kB,
however only _with_ the shift, without it the file size doesn't really
change. Strangely, 2-pass encoding doesn't seem to improve the situation
either, so I kind of exhausted the things I could look at quickly.
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 59d2869..c56cebb 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -390,7 +390,7 @@ static int encode_plane(FFV1Context *s, uint8_t *src, int w, int h,
         } else {
             if (s->packed_at_lsb) {
                 for (x = 0; x < w; x++) {
-                    sample[0][x] = ((uint16_t*)(src + stride*y))[x];
+                    sample[0][x] = ((uint16_t*)(src + stride*y))[x] << 6;
                 }
             } else {
                 for (x = 0; x < w; x++) {
@@ -718,6 +718,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
         } else if (!s->bits_per_raw_sample) {
             s->bits_per_raw_sample = avctx->bits_per_raw_sample;
         }
+s->bits_per_raw_sample = 16;
         if (s->bits_per_raw_sample <= 8) {
             av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample invalid\n");
             return AVERROR_INVALIDDATA;


More information about the ffmpeg-devel mailing list