Message ID | 20191111141624.26287-1-derek.buitenhuis@gmail.com |
---|---|
State | Superseded |
Headers | show |
On 11/11/2019 11:16 AM, Derek Buitenhuis wrote: > Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> > --- > libavcodec/librav1e.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c > index 5052cac896..11c1d09e36 100644 > --- a/libavcodec/librav1e.c > +++ b/libavcodec/librav1e.c > @@ -329,6 +329,10 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx) > } > } > > + /* We can't easily represent this behavior with AVOptions, so do it here. */ > + if (!avctx->bit_rate && ctx->quantizer < 0) > + ctx->quantizer = 100; Looks like the default of 100 is done in the library itself, if rav1e_config_parse_int() isn't called for either quantizer or bitrate. If you remove this chunk and leave the one below, the output bitstreams when calling this encoder with no arguments vs using -qp 100 are the same. > + > if (avctx->bit_rate && ctx->quantizer < 0) { > int max_quantizer = avctx->qmax >= 0 ? avctx->qmax : 255; > > @@ -533,7 +537,7 @@ retry: > #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM > > static const AVOption options[] = { > - { "qp", "use constant quantizer mode", OFFSET(quantizer), AV_OPT_TYPE_INT, { .i64 = 100 }, -1, 255, VE }, > + { "qp", "use constant quantizer mode (defaults to 100 if no bit rate is set)", OFFSET(quantizer), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, VE }, > { "speed", "what speed preset to use", OFFSET(speed), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 10, VE }, > { "tiles", "number of tiles encode with", OFFSET(tiles), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE }, > { "tile-rows", "number of tiles rows to encode with", OFFSET(tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE },
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 5052cac896..11c1d09e36 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -329,6 +329,10 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx) } } + /* We can't easily represent this behavior with AVOptions, so do it here. */ + if (!avctx->bit_rate && ctx->quantizer < 0) + ctx->quantizer = 100; + if (avctx->bit_rate && ctx->quantizer < 0) { int max_quantizer = avctx->qmax >= 0 ? avctx->qmax : 255; @@ -533,7 +537,7 @@ retry: #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "qp", "use constant quantizer mode", OFFSET(quantizer), AV_OPT_TYPE_INT, { .i64 = 100 }, -1, 255, VE }, + { "qp", "use constant quantizer mode (defaults to 100 if no bit rate is set)", OFFSET(quantizer), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, VE }, { "speed", "what speed preset to use", OFFSET(speed), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 10, VE }, { "tiles", "number of tiles encode with", OFFSET(tiles), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE }, { "tile-rows", "number of tiles rows to encode with", OFFSET(tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT64_MAX, VE },
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> --- libavcodec/librav1e.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)