diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-03-25 19:25:21 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2010-03-25 19:25:21 +0000 |
commit | f3b3b4895a280904315616ccb3001ce43baedd8f (patch) | |
tree | 4c46b47b5935c0dc4783b3efb81bb087d1b7e2a2 /libavcodec | |
parent | 4896dd57facf9293038aa8d6fa95df81f9ae549a (diff) | |
download | ffmpeg-f3b3b4895a280904315616ccb3001ce43baedd8f.tar.gz |
Enable more libx264 options, aq, psy, rc lookahead and ssim
Originally committed as revision 22670 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 46 | ||||
-rw-r--r-- | libavcodec/libx264.c | 15 | ||||
-rw-r--r-- | libavcodec/options.c | 9 |
3 files changed, 67 insertions, 3 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index cc74e66e1b..ad5ce0b13a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -30,7 +30,7 @@ #include "libavutil/avutil.h" #define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 60 +#define LIBAVCODEC_VERSION_MINOR 61 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -592,6 +592,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible #define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) +#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. +#define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. /* Unsupported options : * Syntax Arithmetic coding (SAC) @@ -2598,6 +2600,48 @@ typedef struct AVCodecContext { * - decoding: unused */ int weighted_p_pred; + + /** + * AQ mode + * 0: Disabled + * 1: Variance AQ (complexity mask) + * 2: Auto-variance AQ (experimental) + * - encoding: Set by user + * - decoding: unused + */ + int aq_mode; + + /** + * AQ strength + * Reduces blocking and blurring in flat and textured areas. + * - encoding: Set by user + * - decoding: unused + */ + float aq_strength; + + /** + * PSY RD + * Strength of psychovisual optimization + * - encoding: Set by user + * - decoding: unused + */ + float psy_rd; + + /** + * PSY trellis + * Strength of psychovisual optimization + * - encoding: Set by user + * - decoding: unused + */ + float psy_trellis; + + /** + * RC lookahead + * Number of frames for frametype and ratecontrol lookahead + * - encoding: Set by user + * - decoding: unused + */ + int rc_lookahead; } AVCodecContext; /** diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 9a4c9f4006..a5f0a533d7 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -242,6 +242,14 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_me_method = X264_ME_TESA; else x4->params.analyse.i_me_method = X264_ME_HEX; + x4->params.rc.i_aq_mode = avctx->aq_mode; + x4->params.rc.f_aq_strength = avctx->aq_strength; + x4->params.rc.i_lookahead = avctx->rc_lookahead; + + x4->params.analyse.b_psy = avctx->flags2 & CODEC_FLAG2_PSY; + x4->params.analyse.f_psy_rd = avctx->psy_rd; + x4->params.analyse.f_psy_trellis = avctx->psy_trellis; + x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; @@ -272,6 +280,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; + x4->params.analyse.b_ssim = avctx->flags & CODEC_FLAG2_SSIM; x4->params.i_log_level = X264_LOG_DEBUG; x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; @@ -291,10 +300,14 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { x264_nal_t *nal; - int nnal, s; + int nnal, s, i; s = x264_encoder_headers(x4->enc, &nal, &nnal); + for (i = 0; i < nnal; i++) + if (nal[i].i_type == NAL_SEI) + av_log(avctx, AV_LOG_INFO, "%s\n", nal[i].p_payload+25); + avctx->extradata = av_malloc(s); avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1); } diff --git a/libavcodec/options.c b/libavcodec/options.c index e44da96c58..f51e477031 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -307,7 +307,7 @@ static const AVOption options[]={ {"nr", "noise reduction", OFFSET(noise_reduction), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, {"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, {"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, -{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP|CODEC_FLAG2_BIT_RESERVOIR, 0, UINT_MAX, V|A|E|D, "flags2"}, +{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP|CODEC_FLAG2_BIT_RESERVOIR|CODEC_FLAG2_PSY, 0, UINT_MAX, V|A|E|D, "flags2"}, {"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, {"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"}, {"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"}, @@ -404,6 +404,13 @@ static const AVOption options[]={ {"colorspace", NULL, OFFSET(colorspace), FF_OPT_TYPE_INT, AVCOL_SPC_UNSPECIFIED, 1, AVCOL_SPC_NB-1, V|E|D}, {"color_range", NULL, OFFSET(color_range), FF_OPT_TYPE_INT, AVCOL_RANGE_UNSPECIFIED, 0, AVCOL_RANGE_NB-1, V|E|D}, {"chroma_sample_location", NULL, OFFSET(chroma_sample_location), FF_OPT_TYPE_INT, AVCHROMA_LOC_UNSPECIFIED, 0, AVCHROMA_LOC_NB-1, V|E|D}, +{"psy", "use psycho visual optimization", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_PSY, INT_MIN, INT_MAX, V|E, "flags2"}, +{"psy_rd", "specify psycho visual strength", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, 1.0, 0, FLT_MAX, V|E}, +{"psy_trellis", "specify psycho visual trellis", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, 0, 0, FLT_MAX, V|E}, +{"aq_mode", "specify aq method", OFFSET(aq_mode), FF_OPT_TYPE_INT, 1, 0, INT_MAX, V|E}, +{"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, 1.0, 0, FLT_MAX, V|E}, +{"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, 40, 0, INT_MAX, V|E}, +{"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SSIM, INT_MIN, INT_MAX, V|E, "flags2"}, {NULL}, }; |