summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo_enc.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2017-02-01 14:21:36 +0100
committerClément Bœsch <u@pkh.me>2017-02-01 14:21:36 +0100
commit566bfd59c963938e183d523be9216b3f95ad8a09 (patch)
tree1c22e7de6792dbe4477340cbc2fc5722fad2153b /libavcodec/mpegvideo_enc.c
parente4d65434633b67fd03d379fe9d0ab9dc97d767dc (diff)
parentd639dcdae022130078c9c84b7b691c5e9694786c (diff)
downloadffmpeg-566bfd59c963938e183d523be9216b3f95ad8a09.tar.gz
Merge commit 'd639dcdae022130078c9c84b7b691c5e9694786c'
* commit 'd639dcdae022130078c9c84b7b691c5e9694786c': ratecontrol: Move Xvid-related functions to the place they are actually used Merged-by: Clément Bœsch <u@pkh.me>
Diffstat (limited to 'libavcodec/mpegvideo_enc.c')
-rw-r--r--libavcodec/mpegvideo_enc.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 10b4c5b8c4..cdda73b654 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -64,6 +64,7 @@
#include "bytestream.h"
#include "wmv2.h"
#include "rv10.h"
+#include "libxvid.h"
#include <limits.h>
#include "sp5x.h"
@@ -1027,9 +1028,32 @@ FF_ENABLE_DEPRECATION_WARNINGS
31, 0);
}
+#if FF_API_RC_STRATEGY
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (!s->rc_strategy)
+ s->rc_strategy = s->avctx->rc_strategy;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
if (ff_rate_control_init(s) < 0)
return -1;
+#if FF_API_RC_STRATEGY
+ av_assert0(MPV_RC_STRATEGY_XVID == FF_RC_STRATEGY_XVID);
+#endif
+
+ if ((s->avctx->flags & AV_CODEC_FLAG_PASS2) && s->rc_strategy == MPV_RC_STRATEGY_XVID) {
+#if CONFIG_LIBXVID
+ ret = ff_xvid_rate_control_init(s);
+#else
+ ret = AVERROR(ENOSYS);
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n");
+#endif
+ if (ret < 0)
+ return ret;
+ }
+
#if FF_API_ERROR_RATE
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->error_rate)
@@ -1123,6 +1147,10 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
int i;
ff_rate_control_uninit(s);
+#if CONFIG_LIBXVID
+ if ((avctx->flags & AV_CODEC_FLAG_PASS2) && s->rc_strategy == MPV_RC_STRATEGY_XVID)
+ ff_xvid_rate_control_uninit(s);
+#endif
ff_mpv_common_end(s);
if (CONFIG_MJPEG_ENCODER &&
@@ -3629,8 +3657,15 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
s->current_picture.f->quality = s->next_lambda;
if(!dry_run) s->next_lambda= 0;
} else if (!s->fixed_qscale) {
+ int quality;
+#if CONFIG_LIBXVID
+ if ((s->avctx->flags & AV_CODEC_FLAG_PASS2) && s->rc_strategy == MPV_RC_STRATEGY_XVID)
+ quality = ff_xvid_rate_estimate_qscale(s, dry_run);
+ else
+#endif
+ quality = ff_rate_estimate_qscale(s, dry_run);
s->current_picture_ptr->f->quality =
- s->current_picture.f->quality = ff_rate_estimate_qscale(s, dry_run);
+ s->current_picture.f->quality = quality;
if (s->current_picture.f->quality < 0)
return -1;
}