Re: [FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.
On Wed, Aug 27, 2014 at 07:08:00PM -0700, James Zern wrote: On Wed, Aug 27, 2014 at 1:04 PM, Deb Mukherjee debar...@google.com wrote: Changes in the parameter mapping for libvpx to support the constant quality mode in VP9. The assumption in the patch is that if crf is provided but bitrate is 0, then the 'constant quality' mode of VP9 is used. However if both are present, the 'constrained quality' mode is used as before. --- libavcodec/libvpxenc.c | 25 +++-- 1 file changed, 19 insertions(+), 6 deletions(-) lgtm. builds all right with a recent lib and seems to have the desired effect. applied btw, if you want a git write account send me your public SSH key Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.
Changes in the parameter mapping for libvpx to support the constant quality mode in VP9. The assumption in the patch is that if crf is provided but bitrate is 0, then the 'constant quality' mode of VP9 is used. However if both are present, the 'constrained quality' mode is used as before. --- libavcodec/libvpxenc.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 830a793..3a36855 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -300,10 +300,15 @@ static av_cold int vpx_init(AVCodecContext *avctx, enccfg.g_pass = VPX_RC_ONE_PASS; if (avctx-rc_min_rate == avctx-rc_max_rate -avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) +avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) { enccfg.rc_end_usage = VPX_CBR; -else if (ctx-crf) +} else if (ctx-crf = 0) { enccfg.rc_end_usage = VPX_CQ; +#if CONFIG_LIBVPX_VP9_ENCODER +if (!avctx-bit_rate avctx-codec_id == AV_CODEC_ID_VP9) +enccfg.rc_end_usage = VPX_Q; +#endif +} if (avctx-bit_rate) { enccfg.rc_target_bitrate = av_rescale_rnd(avctx-bit_rate, 1, 1000, @@ -311,7 +316,11 @@ static av_cold int vpx_init(AVCodecContext *avctx, } else { if (enccfg.rc_end_usage == VPX_CQ) { enccfg.rc_target_bitrate = 100; +#if CONFIG_LIBVPX_VP9_ENCODER +} else if (enccfg.rc_end_usage != VPX_Q) { +#else } else { +#endif avctx-bit_rate = enccfg.rc_target_bitrate * 1000; av_log(avctx, AV_LOG_WARNING, Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n, @@ -324,7 +333,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-qmax = 0) enccfg.rc_max_quantizer = avctx-qmax; -if (enccfg.rc_end_usage == VPX_CQ) { +if (enccfg.rc_end_usage == VPX_CQ || enccfg.rc_end_usage == VPX_Q) { if (ctx-crf enccfg.rc_min_quantizer || ctx-crf enccfg.rc_max_quantizer) { av_log(avctx, AV_LOG_ERROR, CQ level must be between minimum and maximum quantizer value (%d-%d)\n, @@ -430,7 +439,8 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-codec_id == AV_CODEC_ID_VP8) codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx-slices)); codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx-mb_threshold); -codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); +if (ctx-crf = 0) +codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); if (ctx-max_intra_rate = 0) codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx-max_intra_rate); @@ -775,7 +785,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt, by the bool decoder, meaning that partitions can be decoded even \ though earlier partitions have been lost. Note that intra predicition \ is still done over the partition boundary., 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, er}, \ -{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE }, \ +{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \ #define LEGACY_OPTIONS \ {speed, , offsetof(VP8Context, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \ -- 2.1.0.rc2.206.gedb03e5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.
On Tue, Aug 26, 2014 at 10:30 AM, Deb Mukherjee debar...@google.com wrote: Changes in the parameter mapping for libvpx to support the constant quality mode in VP9. The assumption in the patch is that if crf is provided but bitrate is 0, then the 'constant quality' mode of VP9 is used. However if both are present, the 'constrained quality' mode is used as before. --- libavcodec/libvpxenc.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 830a793..3a36855 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -300,10 +300,15 @@ static av_cold int vpx_init(AVCodecContext *avctx, enccfg.g_pass = VPX_RC_ONE_PASS; if (avctx-rc_min_rate == avctx-rc_max_rate -avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) +avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) { enccfg.rc_end_usage = VPX_CBR; -else if (ctx-crf) +} else if (ctx-crf = 0) { enccfg.rc_end_usage = VPX_CQ; +#if CONFIG_LIBVPX_VP9_ENCODER +if (!avctx-bit_rate avctx-codec_id == AV_CODEC_ID_VP9) +enccfg.rc_end_usage = VPX_Q; +#endif +} if (avctx-bit_rate) { enccfg.rc_target_bitrate = av_rescale_rnd(avctx-bit_rate, 1, 1000, @@ -311,7 +316,11 @@ static av_cold int vpx_init(AVCodecContext *avctx, } else { if (enccfg.rc_end_usage == VPX_CQ) { enccfg.rc_target_bitrate = 100; +#if CONFIG_LIBVPX_VP9_ENCODER +} else if (enccfg.rc_end_usage != VPX_Q) { you could bring this up a level and avoid the '#else' +#else } else { +#endif avctx-bit_rate = enccfg.rc_target_bitrate * 1000; av_log(avctx, AV_LOG_WARNING, Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n, @@ -324,7 +333,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-qmax = 0) enccfg.rc_max_quantizer = avctx-qmax; -if (enccfg.rc_end_usage == VPX_CQ) { +if (enccfg.rc_end_usage == VPX_CQ || enccfg.rc_end_usage == VPX_Q) { This still needs to be if def'd. if (ctx-crf enccfg.rc_min_quantizer || ctx-crf enccfg.rc_max_quantizer) { av_log(avctx, AV_LOG_ERROR, CQ level must be between minimum and maximum quantizer value (%d-%d)\n, @@ -430,7 +439,8 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-codec_id == AV_CODEC_ID_VP8) codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx-slices)); codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx-mb_threshold); -codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); +if (ctx-crf = 0) +codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); if (ctx-max_intra_rate = 0) codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx-max_intra_rate); @@ -775,7 +785,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt, by the bool decoder, meaning that partitions can be decoded even \ though earlier partitions have been lost. Note that intra predicition \ is still done over the partition boundary., 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, er}, \ -{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE }, \ +{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \ #define LEGACY_OPTIONS \ {speed, , offsetof(VP8Context, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \ -- 2.1.0.rc2.206.gedb03e5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.
Changes in the parameter mapping for libvpx to support the constant quality mode in VP9. The assumption in the patch is that if crf is provided but bitrate is 0, then the 'constant quality' mode of VP9 is used. However if both are present, the 'constrained quality' mode is used as before. --- libavcodec/libvpxenc.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 830a793..bc13f70 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -300,10 +300,15 @@ static av_cold int vpx_init(AVCodecContext *avctx, enccfg.g_pass = VPX_RC_ONE_PASS; if (avctx-rc_min_rate == avctx-rc_max_rate -avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) +avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) { enccfg.rc_end_usage = VPX_CBR; -else if (ctx-crf) +} else if (ctx-crf = 0) { enccfg.rc_end_usage = VPX_CQ; +#if CONFIG_LIBVPX_VP9_ENCODER +if (!avctx-bit_rate avctx-codec_id == AV_CODEC_ID_VP9) +enccfg.rc_end_usage = VPX_Q; +#endif +} if (avctx-bit_rate) { enccfg.rc_target_bitrate = av_rescale_rnd(avctx-bit_rate, 1, 1000, @@ -311,7 +316,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, } else { if (enccfg.rc_end_usage == VPX_CQ) { enccfg.rc_target_bitrate = 100; -} else { +} else if (enccfg.rc_end_usage != VPX_Q) { avctx-bit_rate = enccfg.rc_target_bitrate * 1000; av_log(avctx, AV_LOG_WARNING, Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n, @@ -324,7 +329,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-qmax = 0) enccfg.rc_max_quantizer = avctx-qmax; -if (enccfg.rc_end_usage == VPX_CQ) { +if (enccfg.rc_end_usage == VPX_CQ || enccfg.rc_end_usage == VPX_Q) { if (ctx-crf enccfg.rc_min_quantizer || ctx-crf enccfg.rc_max_quantizer) { av_log(avctx, AV_LOG_ERROR, CQ level must be between minimum and maximum quantizer value (%d-%d)\n, @@ -430,7 +435,8 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-codec_id == AV_CODEC_ID_VP8) codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx-slices)); codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx-mb_threshold); -codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); +if (ctx-crf = 0) +codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); if (ctx-max_intra_rate = 0) codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx-max_intra_rate); @@ -775,7 +781,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt, by the bool decoder, meaning that partitions can be decoded even \ though earlier partitions have been lost. Note that intra predicition \ is still done over the partition boundary., 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, er}, \ -{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE }, \ +{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \ #define LEGACY_OPTIONS \ {speed, , offsetof(VP8Context, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \ -- 2.1.0.rc2.206.gedb03e5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.
On Fri, Aug 22, 2014 at 10:53 AM, Deb Mukherjee debar...@google.com wrote: [...] @@ -311,7 +316,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, } else { if (enccfg.rc_end_usage == VPX_CQ) { enccfg.rc_target_bitrate = 100; -} else { +} else if (enccfg.rc_end_usage != VPX_Q) { These still need to be protected as they're vp9-only and newer than what configure tests for to enable vp8. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.
On Aug 22, 2014 1:29 PM, Debargha Mukherjee debar...@google.com wrote: Unless the codec is VP9, VPX_Q will not be set. So the behavior does not change for VP8. If it's not set, then the code won't compile with older libvpx. Timothy ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.
Changes in the parameter mapping for libvpx to support the constant quality mode in VP9. The assumption in the patch is that if crf is provided but bitrate is 0, then the 'constant quality' mode of VP9 is used. However if both are present, the 'constrained quality' mode is used as before. --- libavcodec/libvpxenc.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 830a793..a6e5392 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -300,10 +300,17 @@ static av_cold int vpx_init(AVCodecContext *avctx, enccfg.g_pass = VPX_RC_ONE_PASS; if (avctx-rc_min_rate == avctx-rc_max_rate -avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) +avctx-rc_min_rate == avctx-bit_rate avctx-bit_rate) { enccfg.rc_end_usage = VPX_CBR; -else if (ctx-crf) +} else if (ctx-crf = 0) { enccfg.rc_end_usage = VPX_CQ; +#if CONFIG_LIBVPX_VP9_ENCODER +if (!avctx-bit_rate avctx-codec_id == AV_CODEC_ID_VP9) +enccfg.rc_end_usage = VPX_Q; +#endif +av_log(avctx, AV_LOG_INFO, %s usage set with cq=%d\n, + enccfg.rc_end_usage == VPX_CQ ? VPX_CQ : VPX_Q, ctx-crf); +} if (avctx-bit_rate) { enccfg.rc_target_bitrate = av_rescale_rnd(avctx-bit_rate, 1, 1000, @@ -311,7 +318,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, } else { if (enccfg.rc_end_usage == VPX_CQ) { enccfg.rc_target_bitrate = 100; -} else { +} else if (enccfg.rc_end_usage != VPX_Q) { avctx-bit_rate = enccfg.rc_target_bitrate * 1000; av_log(avctx, AV_LOG_WARNING, Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n, @@ -324,7 +331,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-qmax = 0) enccfg.rc_max_quantizer = avctx-qmax; -if (enccfg.rc_end_usage == VPX_CQ) { +if (enccfg.rc_end_usage == VPX_CQ || enccfg.rc_end_usage == VPX_Q) { if (ctx-crf enccfg.rc_min_quantizer || ctx-crf enccfg.rc_max_quantizer) { av_log(avctx, AV_LOG_ERROR, CQ level must be between minimum and maximum quantizer value (%d-%d)\n, @@ -430,7 +437,8 @@ static av_cold int vpx_init(AVCodecContext *avctx, if (avctx-codec_id == AV_CODEC_ID_VP8) codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx-slices)); codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx-mb_threshold); -codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); +if (ctx-crf = 0) +codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx-crf); if (ctx-max_intra_rate = 0) codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx-max_intra_rate); @@ -775,7 +783,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt, by the bool decoder, meaning that partitions can be decoded even \ though earlier partitions have been lost. Note that intra predicition \ is still done over the partition boundary., 0, AV_OPT_TYPE_CONST, {.i64 = VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, er}, \ -{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, VE }, \ +{ crf, Select the quality for constant quality mode, offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, VE }, \ #define LEGACY_OPTIONS \ {speed, , offsetof(VP8Context, cpu_used), AV_OPT_TYPE_INT, {.i64 = 1}, -16, 16, VE}, \ -- 2.1.0.rc2.206.gedb03e5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel