[FFmpeg-devel] [PATCH] Adds support for constant quality mode in VP9.

2014-08-26 Thread Deb Mukherjee
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


[FFmpeg-devel] [PATCH] Adds support for setting aq_mode in libvpx encoder

2014-08-25 Thread Deb Mukherjee
Sets aq_mode in the [0, 3] range for the libvpx encode wrapper.
0: none
1: variance aq
2: complexity aq
3: cyclic refresh aq
---
 doc/encoders.texi  | 5 -
 libavcodec/libvpxenc.c | 9 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 8df80c4..44b49ce 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1330,7 +1330,7 @@ ffmpeg -i INPUT -codec:v libtheora -b:v 1000k OUTPUT.ogg
 
 @section libvpx
 
-VP8 format supported through libvpx.
+VP8/VP9 format supported through libvpx.
 
 Requires the presence of the libvpx headers and library during configuration.
 You need to explicitly configure the build with @code{--enable-libvpx}.
@@ -1442,6 +1442,9 @@ g_lag_in_frames
 @item vp8flags error_resilient
 g_error_resilient
 
+@item aq_mode
+@code{VP9E_SET_AQ_MODE}
+
 @end table
 
 For more information about libvpx see:
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 830a793..43015d6 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -96,6 +96,7 @@ typedef struct VP8EncoderContext {
 int tile_columns;
 int tile_rows;
 int frame_parallel;
+int aq_mode;
 } VP8Context;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -123,6 +124,7 @@ static const char *const ctlidstr[] = {
 [VP9E_SET_TILE_COLUMNS]= VP9E_SET_TILE_COLUMNS,
 [VP9E_SET_TILE_ROWS]   = VP9E_SET_TILE_ROWS,
 [VP9E_SET_FRAME_PARALLEL_DECODING] = VP9E_SET_FRAME_PARALLEL_DECODING,
+[VP9E_SET_AQ_MODE] = VP9E_SET_AQ_MODE,
 #endif
 };
 
@@ -444,6 +446,8 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 codecctl_int(avctx, VP9E_SET_TILE_ROWS, ctx-tile_rows);
 if (ctx-frame_parallel = 0)
 codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING, 
ctx-frame_parallel);
+if (ctx-aq_mode = 0)
+codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx-aq_mode);
 }
 #endif
 
@@ -803,6 +807,11 @@ static const AVOption vp9_options[] = {
 { tile-columns,Number of tile columns to use, log2, 
OFFSET(tile_columns),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
 { tile-rows,   Number of tile rows to use, log2,
OFFSET(tile_rows),   AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE},
 { frame-parallel,  Enable frame parallel decodability features, 
OFFSET(frame_parallel),  AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
+{ aq-mode, adaptive quantization mode,  
OFFSET(aq_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 3, VE},
+{ none,NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, 
aq_mode }, \
+{ variance,NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, 
aq_mode }, \
+{ complexity,  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, 
aq_mode }, \
+{ cyclic,  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, 
aq_mode }, \
 LEGACY_OPTIONS
 { NULL }
 };
-- 
2.1.0.rc2.206.gedb03e5

___
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.

2014-08-22 Thread Deb Mukherjee
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


[FFmpeg-devel] [PATCH] Adds support for setting aq_mode in libvpx encoder

2014-08-22 Thread Deb Mukherjee
Sets aq_mode in the [0, 3] range for the libvpx encode wrapper.
0: none
1: variance aq
2: complexity aq
3: cyclic refresh aq
---
 doc/encoders.texi  | 5 -
 libavcodec/libvpxenc.c | 9 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 8df80c4..44b49ce 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1330,7 +1330,7 @@ ffmpeg -i INPUT -codec:v libtheora -b:v 1000k OUTPUT.ogg
 
 @section libvpx
 
-VP8 format supported through libvpx.
+VP8/VP9 format supported through libvpx.
 
 Requires the presence of the libvpx headers and library during configuration.
 You need to explicitly configure the build with @code{--enable-libvpx}.
@@ -1442,6 +1442,9 @@ g_lag_in_frames
 @item vp8flags error_resilient
 g_error_resilient
 
+@item aq_mode
+@code{VP9E_SET_AQ_MODE}
+
 @end table
 
 For more information about libvpx see:
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 830a793..43015d6 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -96,6 +96,7 @@ typedef struct VP8EncoderContext {
 int tile_columns;
 int tile_rows;
 int frame_parallel;
+int aq_mode;
 } VP8Context;
 
 /** String mappings for enum vp8e_enc_control_id */
@@ -123,6 +124,7 @@ static const char *const ctlidstr[] = {
 [VP9E_SET_TILE_COLUMNS]= VP9E_SET_TILE_COLUMNS,
 [VP9E_SET_TILE_ROWS]   = VP9E_SET_TILE_ROWS,
 [VP9E_SET_FRAME_PARALLEL_DECODING] = VP9E_SET_FRAME_PARALLEL_DECODING,
+[VP9E_SET_AQ_MODE] = VP9E_SET_AQ_MODE,
 #endif
 };
 
@@ -444,6 +446,8 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 codecctl_int(avctx, VP9E_SET_TILE_ROWS, ctx-tile_rows);
 if (ctx-frame_parallel = 0)
 codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING, 
ctx-frame_parallel);
+if (ctx-aq_mode = 0)
+codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx-aq_mode);
 }
 #endif
 
@@ -803,6 +807,11 @@ static const AVOption vp9_options[] = {
 { tile-columns,Number of tile columns to use, log2, 
OFFSET(tile_columns),AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
 { tile-rows,   Number of tile rows to use, log2,
OFFSET(tile_rows),   AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE},
 { frame-parallel,  Enable frame parallel decodability features, 
OFFSET(frame_parallel),  AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE},
+{ aq-mode, adaptive quantization mode,  
OFFSET(aq_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 3, VE},
+{ none,NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, VE, 
aq_mode }, \
+{ variance,NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, 
aq_mode }, \
+{ complexity,  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, 
aq_mode }, \
+{ cyclic,  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, 
aq_mode }, \
 LEGACY_OPTIONS
 { NULL }
 };
-- 
2.1.0.rc2.206.gedb03e5

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Adds decode support for formats other than 420

2014-08-22 Thread Deb Mukherjee
Handles new VP9 profiles 1-3 with different color sampling and
bit-depths.
---
 libavcodec/libvpxdec.c | 69 +++---
 1 file changed, 60 insertions(+), 9 deletions(-)

diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index 94e1e4d..7c397fb 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -60,7 +60,58 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 return 0;
 }
 
-static int vp8_decode(AVCodecContext *avctx,
+// returns 0 on success, 1 on unsupported
+static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img) {
+int ret = 0;
+if (avctx-codec_id == AV_CODEC_ID_VP8) {
+if (img-fmt != VPX_IMG_FMT_I420)
+return 1;
+}
+switch (img-fmt) {
+case VPX_IMG_FMT_I420:
+avctx-pix_fmt = AV_PIX_FMT_YUV420P;
+break;
+case VPX_IMG_FMT_I422:
+avctx-pix_fmt = AV_PIX_FMT_YUV422P;
+break;
+case VPX_IMG_FMT_I444:
+avctx-pix_fmt = AV_PIX_FMT_YUV444P;
+break;
+case VPX_IMG_FMT_I42016:
+if (img-bit_depth == 10) {
+avctx-pix_fmt = AV_PIX_FMT_YUV420P10LE;
+} else if (img-bit_depth == 12) {
+avctx-pix_fmt = AV_PIX_FMT_YUV420P12LE;
+} else {
+ret = 1;
+}
+break;
+case VPX_IMG_FMT_I42216:
+if (img-bit_depth == 10) {
+avctx-pix_fmt = AV_PIX_FMT_YUV422P10LE;
+} else if (img-bit_depth == 12) {
+avctx-pix_fmt = AV_PIX_FMT_YUV422P12LE;
+} else {
+ret = 1;
+}
+break;
+case VPX_IMG_FMT_I44416:
+if (img-bit_depth == 10) {
+avctx-pix_fmt = AV_PIX_FMT_YUV444P10LE;
+} else if (img-bit_depth == 12) {
+avctx-pix_fmt = AV_PIX_FMT_YUV444P12LE;
+} else {
+ret = 1;
+}
+break;
+default:
+ret = 1;
+break;
+}
+return ret;
+}
+
+static int vpx_decode(AVCodecContext *avctx,
   void *data, int *got_frame, AVPacket *avpkt)
 {
 VP8Context *ctx = avctx-priv_data;
@@ -82,9 +133,9 @@ static int vp8_decode(AVCodecContext *avctx,
 }
 
 if ((img = vpx_codec_get_frame(ctx-decoder, iter))) {
-if (img-fmt != VPX_IMG_FMT_I420) {
-av_log(avctx, AV_LOG_ERROR, Unsupported output colorspace (%d)\n,
-   img-fmt);
+if (set_pix_fmt(avctx, img)) {
+av_log(avctx, AV_LOG_ERROR, Unsupported output colorspace (%d) / 
bit_depth (%d)\n,
+   img-fmt, img-bit_depth);
 return AVERROR_INVALIDDATA;
 }
 
@@ -104,7 +155,7 @@ static int vp8_decode(AVCodecContext *avctx,
 return avpkt-size;
 }
 
-static av_cold int vp8_free(AVCodecContext *avctx)
+static av_cold int vpx_free(AVCodecContext *avctx)
 {
 VP8Context *ctx = avctx-priv_data;
 vpx_codec_destroy(ctx-decoder);
@@ -124,8 +175,8 @@ AVCodec ff_libvpx_vp8_decoder = {
 .id = AV_CODEC_ID_VP8,
 .priv_data_size = sizeof(VP8Context),
 .init   = vp8_init,
-.close  = vp8_free,
-.decode = vp8_decode,
+.close  = vpx_free,
+.decode = vpx_decode,
 .capabilities   = CODEC_CAP_AUTO_THREADS | CODEC_CAP_DR1,
 };
 #endif /* CONFIG_LIBVPX_VP8_DECODER */
@@ -143,8 +194,8 @@ AVCodec ff_libvpx_vp9_decoder = {
 .id = AV_CODEC_ID_VP9,
 .priv_data_size = sizeof(VP8Context),
 .init   = vp9_init,
-.close  = vp8_free,
-.decode = vp8_decode,
+.close  = vpx_free,
+.decode = vpx_decode,
 .capabilities   = CODEC_CAP_AUTO_THREADS | CODEC_CAP_DR1,
 .init_static_data = ff_vp9_init_static,
 };
-- 
2.1.0.rc2.206.gedb03e5

___
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.

2014-08-21 Thread Deb Mukherjee
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