diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-02-27 12:23:19 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-02-29 07:12:10 +0100 |
commit | ff71a383ac884706903b2613d6f885021b69e552 (patch) | |
tree | 196b97570fc198c27998696217c09772b9be7994 | |
parent | a249f0cc23457bc73a249e1b1ca22adcfe5b0894 (diff) | |
download | ffmpeg-ff71a383ac884706903b2613d6f885021b69e552.tar.gz |
mpegvideo_enc: add qp_rd flag to mpv_flags.
Deprecate CODEC_FLAG_QP_RD.
-rw-r--r-- | libavcodec/avcodec.h | 2 | ||||
-rw-r--r-- | libavcodec/mpegvideo.h | 4 | ||||
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 17 | ||||
-rw-r--r-- | libavcodec/options.c | 4 | ||||
-rwxr-xr-x | tests/codec-regression.sh | 6 |
5 files changed, 21 insertions, 12 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index fdbb1ab6c3..2a27d8d53b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -562,7 +562,6 @@ typedef struct RcOverride{ /* Fx : Flag for h263+ extra options */ #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp. -#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation #define CODEC_FLAG_CLOSED_GOP 0x80000000 @@ -570,6 +569,7 @@ typedef struct RcOverride{ #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. #if FF_API_MPV_GLOBAL_OPTS +#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping #endif diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index b780331a9c..26c88b000c 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -701,13 +701,15 @@ typedef struct MpegEncContext { /* mpegvideo_enc common options */ #define FF_MPV_FLAG_SKIP_RD 0x0001 #define FF_MPV_FLAG_STRICT_GOP 0x0002 +#define FF_MPV_FLAG_QP_RD 0x0004 #define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x) #define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) #define FF_MPV_COMMON_OPTS \ { "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\ { "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" }, +{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" }, extern const AVOption ff_mpv_generic_options[]; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index d21ced7d59..bb348137aa 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -374,13 +374,18 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) /* Fixed QSCALE */ s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE); +#if FF_API_MPV_GLOBAL_OPTS + if (s->flags & CODEC_FLAG_QP_RD) + s->mpv_flags |= FF_MPV_FLAG_QP_RD; +#endif + s->adaptive_quant = (s->avctx->lumi_masking || s->avctx->dark_masking || s->avctx->temporal_cplx_masking || s->avctx->spatial_cplx_masking || s->avctx->p_masking || s->avctx->border_masking || - (s->flags & CODEC_FLAG_QP_RD)) && + (s->mpv_flags & FF_MPV_FLAG_QP_RD)) && !s->fixed_qscale; s->loop_filter = !!(s->flags & CODEC_FLAG_LOOP_FILTER); @@ -495,7 +500,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) return -1; } - if ((s->flags & CODEC_FLAG_QP_RD) && + if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && s->avctx->mb_decision != FF_MB_DECISION_RD) { av_log(avctx, AV_LOG_ERROR, "QP RD needs mbd=2\n"); return -1; @@ -1727,7 +1732,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, s->lambda = s->lambda_table[mb_xy]; update_qscale(s); - if (!(s->flags & CODEC_FLAG_QP_RD)) { + if (!(s->mpv_flags & FF_MPV_FLAG_QP_RD)) { s->qscale = s->current_picture_ptr->f.qscale_table[mb_xy]; s->dquant = s->qscale - last_qp; @@ -1747,7 +1752,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, } } ff_set_qscale(s, last_qp + s->dquant); - } else if (s->flags & CODEC_FLAG_QP_RD) + } else if (s->mpv_flags & FF_MPV_FLAG_QP_RD) ff_set_qscale(s, s->qscale + s->dquant); wrap_y = s->linesize; @@ -2508,7 +2513,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->mb_skipped=0; s->dquant=0; //only for QP_RD - if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){ // more than 1 MB type possible or CODEC_FLAG_QP_RD + if (mb_type & (mb_type-1) || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) { // more than 1 MB type possible or FF_MPV_FLAG_QP_RD int next_block=0; int pb_bits_count, pb2_bits_count, tex_pb_bits_count; @@ -2645,7 +2650,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ } } - if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){ + if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && dmin < INT_MAX) { if(best_s.mv_type==MV_TYPE_16X16){ //FIXME move 4mv after QPRD const int last_qp= backup_s.qscale; int qpi, qp, dc[6]; diff --git a/libavcodec/options.c b/libavcodec/options.c index 8374f9d487..de5b42a147 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -98,7 +98,9 @@ static const AVOption options[]={ {"bitexact", "use only bitexact stuff (except (i)dct)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"}, {"aic", "h263 advanced intra coding / mpeg4 ac prediction", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"}, {"cbp", "use rate distortion optimization for cbp", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, -{"qprd", "use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, +#if FF_API_MPV_GLOBAL_OPTS +{"qprd", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, {"cgop", "closed gop", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"}, {"fast", "allow non spec compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"}, diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh index d59ce07b35..6a1dee6e2d 100755 --- a/tests/codec-regression.sh +++ b/tests/codec-regression.sh @@ -38,13 +38,13 @@ fi if [ -n "$do_mpeg2_ivlc_qprd" ]; then # mpeg2 encoding intra vlc qprd -do_video_encoding mpeg2ivlc-qprd.mpg "-vb 500k -bf 2 -trellis 1 -flags +qprd+mv0 -intra_vlc 1 -cmp 2 -subcmp 2 -mbd rd -vcodec mpeg2video -f mpeg2video" +do_video_encoding mpeg2ivlc-qprd.mpg "-vb 500k -bf 2 -trellis 1 -flags +mv0 -mpv_flags +qp_rd -intra_vlc 1 -cmp 2 -subcmp 2 -mbd rd -vcodec mpeg2video -f mpeg2video" do_video_decoding fi if [ -n "$do_mpeg2_422" ]; then #mpeg2 4:2:2 encoding -do_video_encoding mpeg2_422.mpg "-vb 1000k -bf 2 -trellis 1 -flags +qprd+mv0+ildct+ilme -intra_vlc 1 -mbd rd -vcodec mpeg2video -pix_fmt yuv422p -f mpeg2video" +do_video_encoding mpeg2_422.mpg "-vb 1000k -bf 2 -trellis 1 -flags +mv0+ildct+ilme -mpv_flags +qp_rd -intra_vlc 1 -mbd rd -vcodec mpeg2video -pix_fmt yuv422p -f mpeg2video" do_video_decoding fi @@ -128,7 +128,7 @@ do_video_decoding fi if [ -n "$do_mpeg4_qprd" ]; then -do_video_encoding mpeg4-qprd.avi "-b 450k -bf 2 -trellis 1 -flags +mv4+qprd+mv0 -cmp 2 -subcmp 2 -mbd rd -an -vcodec mpeg4" +do_video_encoding mpeg4-qprd.avi "-b 450k -bf 2 -trellis 1 -flags +mv4+mv0 -mpv_flags +qp_rd -cmp 2 -subcmp 2 -mbd rd -an -vcodec mpeg4" do_video_decoding fi |