diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-08-17 17:34:30 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-08-17 22:03:02 +0200 |
commit | ceb8773e168316b55c906e72650e1d3f197acebf (patch) | |
tree | 92302cadd9d538ffb7062b6da4ff19954e9a1c0d /libavcodec/libvpxenc.c | |
parent | 1ee7a2955f3ebd49a34ab4b9880889c4e0b5e423 (diff) | |
download | ffmpeg-streaming-ceb8773e168316b55c906e72650e1d3f197acebf.zip ffmpeg-streaming-ceb8773e168316b55c906e72650e1d3f197acebf.tar.gz |
libvpxenc: Fix CQ encoding without a specified bitrate
Also print a warning if neither quality nor bitrate is specified
and use the libvpx default bitrate in this case.
The idea of using the default bitrate is from Luca Barbato
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libvpxenc.c')
-rw-r--r-- | libavcodec/libvpxenc.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index b438301..38d1d65 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -270,8 +270,21 @@ static av_cold int vp8_init(AVCodecContext *avctx) enccfg.rc_end_usage = VPX_CBR; else if (ctx->crf) enccfg.rc_end_usage = VPX_CQ; - enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000, - AV_ROUND_NEAR_INF); + + if (avctx->bit_rate) { + enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000, + AV_ROUND_NEAR_INF); + } else { + if (enccfg.rc_end_usage == VPX_CQ) { + enccfg.rc_target_bitrate = 1000000; + } else { + 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", + enccfg.rc_target_bitrate); + } + } + if (avctx->qmin > 0) enccfg.rc_min_quantizer = avctx->qmin; if (avctx->qmax > 0) |