]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libvpxenc.c
celp_math: Move ff_cos() to the only place it is used
[ffmpeg] / libavcodec / libvpxenc.c
index 7986f6a0e2c3003ebbb5b07ff55252ef94e59f35..3808ac02ec55b7e20738c191eb5f34731577e76a 100644 (file)
@@ -31,6 +31,7 @@
 #include "avcodec.h"
 #include "internal.h"
 #include "libavutil/base64.h"
+#include "libavutil/common.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 
@@ -244,11 +245,16 @@ static av_cold int vp8_init(AVCodecContext *avctx)
     else
         enccfg.g_pass = VPX_RC_ONE_PASS;
 
+    if (!avctx->bit_rate)
+        avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
+    else
+        enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
+                                              AV_ROUND_NEAR_INF);
+
     if (avctx->rc_min_rate == avctx->rc_max_rate &&
         avctx->rc_min_rate == avctx->bit_rate)
         enccfg.rc_end_usage = VPX_CBR;
-    enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
-                                              AV_ROUND_NEAR_INF);
+
     if (avctx->qmin > 0)
         enccfg.rc_min_quantizer = avctx->qmin;
     if (avctx->qmax > 0)
@@ -568,7 +574,7 @@ static const AVCodecDefault defaults[] = {
 AVCodec ff_libvpx_encoder = {
     .name           = "libvpx",
     .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = CODEC_ID_VP8,
+    .id             = AV_CODEC_ID_VP8,
     .priv_data_size = sizeof(VP8Context),
     .init           = vp8_init,
     .encode2        = vp8_encode,