Message ID | CAB0OVGrR6T77qr2T1yeqrKqk6DU4Tp9ndxxxTwyp2e2y8dQmbA@mail.gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [FFmpeg-devel] lavc/aom: Force default qmax to 0 if crf was set to 0 | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
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@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 >
Am Sa., 20. März 2021 um 19:06 Uhr schrieb James Almer <jamrial@gmail.com>: > > 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@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". I hope "aomenc" is ok. New patch attached. Thank you for the review, Carl Eugen
On 3/20/2021 3:30 PM, Carl Eugen Hoyos wrote: > Am Sa., 20. März 2021 um 19:06 Uhr schrieb James Almer <jamrial@gmail.com>: >> >> 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@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". > > I hope "aomenc" is ok. > > New patch attached. > > Thank you for the review, Carl Eugen Should be ok.
Am So., 21. März 2021 um 02:04 Uhr schrieb James Almer <jamrial@gmail.com>: > > On 3/20/2021 3:30 PM, Carl Eugen Hoyos wrote: > > Am Sa., 20. März 2021 um 19:06 Uhr schrieb James Almer <jamrial@gmail.com>: > >> > >> 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@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". > > > > I hope "aomenc" is ok. > > > > New patch attached. > > > > Thank you for the review, Carl Eugen > > Should be ok. Pushed. Thank you, Carl Eugen
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; if (avctx->bit_rate) { enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,