[FFmpeg-devel] [PATCH v3 3/3] avcodec: estimate output bitrate for ffv1/huffyuv codecs

Michael Niedermayer michael at niedermayer.cc
Sat Mar 11 17:29:57 EET 2017


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 <t.rapp at noa-archive.com>
> ---
>  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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170311/d9dc6b84/attachment.sig>


More information about the ffmpeg-devel mailing list