Re: [FFmpeg-devel] [PATCH v3 3/3] avcodec: estimate output bitrate for ffv1/huffyuv codecs
On 11.03.2017 16:29, Michael Niedermayer wrote: On Tue, Mar 07, 2017 at 03:39:19PM +0100, Tobias Rapp wrote: Allows to get a more realistic total bitrate (and estimated file size) in avi_write_header. Previously a static default value of 200k was assumed. Signed-off-by: Tobias Rapp--- libavcodec/ffv1enc.c | 3 +++ libavcodec/huffyuvenc.c| 3 +++ tests/ref/vsynth/vsynth1-ffv1 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth1-ffvhuff | 2 +- tests/ref/vsynth/vsynth1-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth1-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth1-ffvhuff444| 2 +- tests/ref/vsynth/vsynth1-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth1-huffyuv | 2 +- tests/ref/vsynth/vsynth1-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth1-huffyuvbgra | 2 +- tests/ref/vsynth/vsynth2-ffv1 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth2-ffvhuff | 2 +- tests/ref/vsynth/vsynth2-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth2-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth2-ffvhuff444| 2 +- tests/ref/vsynth/vsynth2-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth2-huffyuv | 2 +- tests/ref/vsynth/vsynth2-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth2-huffyuvbgra | 2 +- tests/ref/vsynth/vsynth3-ffv1 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth3-ffvhuff | 2 +- tests/ref/vsynth/vsynth3-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth3-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth3-ffvhuff444| 2 +- tests/ref/vsynth/vsynth3-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth3-huffyuv | 2 +- tests/ref/vsynth/vsynth3-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth3-huffyuvbgra | 2 +- tests/ref/vsynth/vsynth_lena-ffv1 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff444| 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth_lena-huffyuv | 2 +- tests/ref/vsynth/vsynth_lena-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth_lena-huffyuvbgra | 2 +- 62 files changed, 66 insertions(+), 60 deletions(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 35f54c6..b57e8ba 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -894,6 +894,9 @@ slices_ok: } } +// estimate compressed bitrate assuming 40% output size +avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 2 / 5; + return 0; } diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 89639b7..ddbaf14 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -446,6 +446,9 @@ FF_ENABLE_DEPRECATION_WARNINGS s->picture_number=0; +// estimate compressed bitrate assuming 60% output size +avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 3 / 5; i dont like this, the value is basically random, and not the bitrate OK, then consider this patch as dropped. IMHO the current static value of 20 is even worse but I can do the estimation outside of avcodec and pass it to the encoder/muxer via the "b" option. Regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v3 3/3] avcodec: estimate output bitrate for ffv1/huffyuv codecs
On Tue, Mar 07, 2017 at 03:39:19PM +0100, Tobias Rapp wrote: > Allows to get a more realistic total bitrate (and estimated file size) > in avi_write_header. Previously a static default value of 200k was > assumed. > > Signed-off-by: Tobias Rapp> --- > libavcodec/ffv1enc.c | 3 +++ > libavcodec/huffyuvenc.c| 3 +++ > tests/ref/vsynth/vsynth1-ffv1 | 2 +- > tests/ref/vsynth/vsynth1-ffv1-v0 | 2 +- > tests/ref/vsynth/vsynth1-ffv1-v3-bgr0 | 2 +- > tests/ref/vsynth/vsynth1-ffv1-v3-rgb48 | 2 +- > tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p | 2 +- > tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10 | 2 +- > tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16 | 2 +- > tests/ref/vsynth/vsynth1-ffvhuff | 2 +- > tests/ref/vsynth/vsynth1-ffvhuff420p12 | 2 +- > tests/ref/vsynth/vsynth1-ffvhuff422p10left | 2 +- > tests/ref/vsynth/vsynth1-ffvhuff444| 2 +- > tests/ref/vsynth/vsynth1-ffvhuff444p16 | 2 +- > tests/ref/vsynth/vsynth1-huffyuv | 2 +- > tests/ref/vsynth/vsynth1-huffyuvbgr24 | 2 +- > tests/ref/vsynth/vsynth1-huffyuvbgra | 2 +- > tests/ref/vsynth/vsynth2-ffv1 | 2 +- > tests/ref/vsynth/vsynth2-ffv1-v0 | 2 +- > tests/ref/vsynth/vsynth2-ffv1-v3-bgr0 | 2 +- > tests/ref/vsynth/vsynth2-ffv1-v3-rgb48 | 2 +- > tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p | 2 +- > tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10 | 2 +- > tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16 | 2 +- > tests/ref/vsynth/vsynth2-ffvhuff | 2 +- > tests/ref/vsynth/vsynth2-ffvhuff420p12 | 2 +- > tests/ref/vsynth/vsynth2-ffvhuff422p10left | 2 +- > tests/ref/vsynth/vsynth2-ffvhuff444| 2 +- > tests/ref/vsynth/vsynth2-ffvhuff444p16 | 2 +- > tests/ref/vsynth/vsynth2-huffyuv | 2 +- > tests/ref/vsynth/vsynth2-huffyuvbgr24 | 2 +- > tests/ref/vsynth/vsynth2-huffyuvbgra | 2 +- > tests/ref/vsynth/vsynth3-ffv1 | 2 +- > tests/ref/vsynth/vsynth3-ffv1-v0 | 2 +- > tests/ref/vsynth/vsynth3-ffv1-v3-bgr0 | 2 +- > tests/ref/vsynth/vsynth3-ffv1-v3-rgb48 | 2 +- > tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p | 2 +- > tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10 | 2 +- > tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16 | 2 +- > tests/ref/vsynth/vsynth3-ffvhuff | 2 +- > tests/ref/vsynth/vsynth3-ffvhuff420p12 | 2 +- > tests/ref/vsynth/vsynth3-ffvhuff422p10left | 2 +- > tests/ref/vsynth/vsynth3-ffvhuff444| 2 +- > tests/ref/vsynth/vsynth3-ffvhuff444p16 | 2 +- > tests/ref/vsynth/vsynth3-huffyuv | 2 +- > tests/ref/vsynth/vsynth3-huffyuvbgr24 | 2 +- > tests/ref/vsynth/vsynth3-huffyuvbgra | 2 +- > tests/ref/vsynth/vsynth_lena-ffv1 | 2 +- > tests/ref/vsynth/vsynth_lena-ffv1-v0 | 2 +- > tests/ref/vsynth/vsynth_lena-ffv1-v3-bgr0 | 2 +- > tests/ref/vsynth/vsynth_lena-ffv1-v3-rgb48 | 2 +- > tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420p | 2 +- > tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv422p10 | 2 +- > tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv444p16 | 2 +- > tests/ref/vsynth/vsynth_lena-ffvhuff | 2 +- > tests/ref/vsynth/vsynth_lena-ffvhuff420p12 | 2 +- > tests/ref/vsynth/vsynth_lena-ffvhuff422p10left | 2 +- > tests/ref/vsynth/vsynth_lena-ffvhuff444| 2 +- > tests/ref/vsynth/vsynth_lena-ffvhuff444p16 | 2 +- > tests/ref/vsynth/vsynth_lena-huffyuv | 2 +- > tests/ref/vsynth/vsynth_lena-huffyuvbgr24 | 2 +- > tests/ref/vsynth/vsynth_lena-huffyuvbgra | 2 +- > 62 files changed, 66 insertions(+), 60 deletions(-) > > diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c > index 35f54c6..b57e8ba 100644 > --- a/libavcodec/ffv1enc.c > +++ b/libavcodec/ffv1enc.c > @@ -894,6 +894,9 @@ slices_ok: > } > } > > +// estimate compressed bitrate assuming 40% output size > +avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 2 / 5; > + > return 0; > } > > diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c > index 89639b7..ddbaf14 100644 > --- a/libavcodec/huffyuvenc.c > +++ b/libavcodec/huffyuvenc.c > @@ -446,6 +446,9 @@ FF_ENABLE_DEPRECATION_WARNINGS > > s->picture_number=0; > > +// estimate compressed bitrate assuming 60% output size > +avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 3 / 5; i dont like this, the value is basically random, and not the bitrate [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When the tyrant has disposed of foreign enemies by conquest or treaty, and there is nothing more to fear from them, then he is always stirring up some war or other, in order that the people may require a leader. -- Plato
[FFmpeg-devel] [PATCH v3 3/3] avcodec: estimate output bitrate for ffv1/huffyuv codecs
Allows to get a more realistic total bitrate (and estimated file size) in avi_write_header. Previously a static default value of 200k was assumed. Signed-off-by: Tobias Rapp--- libavcodec/ffv1enc.c | 3 +++ libavcodec/huffyuvenc.c| 3 +++ tests/ref/vsynth/vsynth1-ffv1 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth1-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth1-ffvhuff | 2 +- tests/ref/vsynth/vsynth1-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth1-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth1-ffvhuff444| 2 +- tests/ref/vsynth/vsynth1-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth1-huffyuv | 2 +- tests/ref/vsynth/vsynth1-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth1-huffyuvbgra | 2 +- tests/ref/vsynth/vsynth2-ffv1 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth2-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth2-ffvhuff | 2 +- tests/ref/vsynth/vsynth2-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth2-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth2-ffvhuff444| 2 +- tests/ref/vsynth/vsynth2-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth2-huffyuv | 2 +- tests/ref/vsynth/vsynth2-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth2-huffyuvbgra | 2 +- tests/ref/vsynth/vsynth3-ffv1 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth3-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth3-ffvhuff | 2 +- tests/ref/vsynth/vsynth3-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth3-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth3-ffvhuff444| 2 +- tests/ref/vsynth/vsynth3-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth3-huffyuv | 2 +- tests/ref/vsynth/vsynth3-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth3-huffyuvbgra | 2 +- tests/ref/vsynth/vsynth_lena-ffv1 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v0 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-bgr0 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-rgb48 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv420p | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv422p10 | 2 +- tests/ref/vsynth/vsynth_lena-ffv1-v3-yuv444p16 | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff420p12 | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff422p10left | 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff444| 2 +- tests/ref/vsynth/vsynth_lena-ffvhuff444p16 | 2 +- tests/ref/vsynth/vsynth_lena-huffyuv | 2 +- tests/ref/vsynth/vsynth_lena-huffyuvbgr24 | 2 +- tests/ref/vsynth/vsynth_lena-huffyuvbgra | 2 +- 62 files changed, 66 insertions(+), 60 deletions(-) diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 35f54c6..b57e8ba 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -894,6 +894,9 @@ slices_ok: } } +// estimate compressed bitrate assuming 40% output size +avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 2 / 5; + return 0; } diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 89639b7..ddbaf14 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -446,6 +446,9 @@ FF_ENABLE_DEPRECATION_WARNINGS s->picture_number=0; +// estimate compressed bitrate assuming 60% output size +avctx->bit_rate = ff_guess_coded_bitrate(avctx) * 3 / 5; + return 0; } static int encode_422_bitstream(HYuvContext *s, int offset, int count) diff --git a/tests/ref/vsynth/vsynth1-ffv1 b/tests/ref/vsynth/vsynth1-ffv1 index 001f10a..64229db 100644 --- a/tests/ref/vsynth/vsynth1-ffv1 +++ b/tests/ref/vsynth/vsynth1-ffv1 @@ -1,4 +1,4 @@ -26b1296a0ef80a3b5c8b63cc57c52bc2 *tests/data/fate/vsynth1-ffv1.avi +69e340b652a8f4327dd3206694038895 *tests/data/fate/vsynth1-ffv1.avi 2691268 tests/data/fate/vsynth1-ffv1.avi c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffv1.out.rawvideo stddev:0.00 PSNR:999.99 MAXDIFF:0 bytes: 7603200/ 7603200 diff --git