[FFmpeg-devel] [PATCH]lavc/aom: Force default qmax to 0 if crf was set to 0

James Almer jamrial at gmail.com
Sat Mar 20 20:05:51 EET 2021


On 3/20/2021 2:51 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes lossless aom encoding in some cases for me, it is
> still possible to force lossy encoding with crf == 0 and qmax > 0.
> 
> Please comment, Carl Eugen


> From a7b9b60d7091bbf0af84b8eda8bc84ce858d071e Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> Date: Sat, 20 Mar 2021 18:47:52 +0100
> Subject: [PATCH] lavc/aom: Force default qmax to 0 if crf was set to 0.

libaomenc, not just "aom".

> 
> Fixes lossless encoding.
> ---
>  libavcodec/libaomenc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index 2c3c3eb185..a8f0420230 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -640,6 +640,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
>          if (!avctx->bit_rate)
>              enccfg.rc_end_usage = AOM_Q;
>      }
> +    if (!ctx->crf && avctx->qmax == -1)
> +        avctx->qmax = 0;

Don't change avctx, instead set enccfg.rc_max_quantizer directly, but do 
it below alongside the existing avctx->qmax check.

>  
>      if (avctx->bit_rate) {
>          enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
> -- 
> 2.30.1
> 


More information about the ffmpeg-devel mailing list