diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-10-13 06:55:40 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-10-13 08:00:03 +0400 |
commit | f884ef00de362a5460a9c58318d009bcae440cc8 (patch) | |
tree | 955b7a1dc3f2bf89fb9332d0e732aac9e52b0e29 /libavcodec/libx264.c | |
parent | c1847c932b1576e8224c38e112a5fd29fa8a6098 (diff) | |
parent | 47a1d794dba02239f9eeb37e9dfd4dfdb634c3b7 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (31 commits)
tiffenc: initialize forgotten avctx.
avplay: free the active audio packet at exit.
avplay: free rdft data used for spectrogram analysis.
log.h: make AVClass a named struct
fix ac3 encoder documentation
vc1: more prettyprinting cosmetics
vc1: prettyprint some tables
vc1: K&R formatting cosmetics
AVOptions: bump minor and add APIchanges entry.
cmdutils/avtools: simplify show_help() by using av_opt_child_class_next()
AVOptions: rename FF_OPT_TYPE_* => AV_OPT_TYPE_*
Remove all uses of deprecated AVOptions API.
AVOptions: add av_opt_next, deprecate av_next_option.
AVOptions: add functions for evaluating option strings.
AVOptions: split get_number().
AVOptions: add av_opt_get*, deprecate av_get*.
AVOptions: add av_opt_set*().
AVOptions: add new API for enumerating children.
rv34: move inverse transform functions to DSP context
flvenc: Write the right metadata entry count
...
Conflicts:
avconv.c
cmdutils.c
doc/APIchanges
ffplay.c
ffprobe.c
libavcodec/ac3dec.c
libavcodec/h264.c
libavcodec/libvpxenc.c
libavcodec/libx264.c
libavcodec/mpeg12enc.c
libavcodec/options.c
libavdevice/libdc1394.c
libavdevice/v4l2.c
libavfilter/vf_drawtext.c
libavformat/flvdec.c
libavformat/mpegtsenc.c
libavformat/options.c
libavutil/avutil.h
libavutil/opt.c
libswscale/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libx264.c')
-rw-r--r-- | libavcodec/libx264.c | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 894a63eadb..7410112172 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -127,30 +127,6 @@ static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, return p - buf; } -static int avfmt2_csp(int avfmt) -{ - switch (avfmt) { - case PIX_FMT_YUV420P: - case PIX_FMT_YUVJ420P: - case PIX_FMT_YUV420P9: - case PIX_FMT_YUV420P10: - return X264_CSP_I420; -#ifdef X264_CSP_I444 - case PIX_FMT_YUV444P: - return X264_CSP_I444; -#endif -#ifdef X264_CSP_BGR - case PIX_FMT_BGR24: - return X264_CSP_BGR; - - case PIX_FMT_RGB24: - return X264_CSP_RGB; -#endif - default: - return X264_CSP_NONE; - } -} - static int avfmt2_num_planes(int avfmt) { switch (avfmt) { @@ -181,7 +157,7 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize; x264_picture_init( &x4->pic ); - x4->pic.img.i_csp = avfmt2_csp(ctx->pix_fmt); + x4->pic.img.i_csp = x4->params.i_csp; if (x264_bit_depth > 8) x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH; x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); @@ -271,6 +247,29 @@ static av_cold int X264_close(AVCodecContext *avctx) } \ } while (0); +static int convert_pix_fmt(enum PixelFormat pix_fmt) +{ + switch (pix_fmt) { + case PIX_FMT_YUV420P: + case PIX_FMT_YUVJ420P: + case PIX_FMT_YUV420P9: + case PIX_FMT_YUV420P10: return X264_CSP_I420; + case PIX_FMT_YUV422P: + case PIX_FMT_YUV422P10: return X264_CSP_I422; + case PIX_FMT_YUV444P: + case PIX_FMT_YUV444P9: + case PIX_FMT_YUV444P10: return X264_CSP_I444; +#ifdef X264_CSP_BGR + case PIX_FMT_BGR24: + return X264_CSP_BGR; + + case PIX_FMT_RGB24: + return X264_CSP_RGB; +#endif + }; + return 0; +} + #define PARSE_X264_OPT(name, var)\ if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\ av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\ @@ -300,6 +299,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.pf_log = X264_log; x4->params.p_log_private = avctx; x4->params.i_log_level = X264_LOG_DEBUG; + x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt); OPT_STR("weightp", x4->wpredp); @@ -533,8 +533,6 @@ static av_cold int X264_init(AVCodecContext *avctx) avctx->crf = x4->params.rc.f_rf_constant; #endif - x4->params.i_csp = avfmt2_csp(avctx->pix_fmt); - x4->enc = x264_encoder_open(&x4->params); if (!x4->enc) return -1; @@ -561,9 +559,8 @@ static av_cold int X264_init(AVCodecContext *avctx) static const enum PixelFormat pix_fmts_8bit[] = { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, -#ifdef X264_CSP_I444 + PIX_FMT_YUV422P, PIX_FMT_YUV444P, -#endif #ifdef X264_CSP_BGR PIX_FMT_BGR24, PIX_FMT_RGB24, @@ -572,10 +569,13 @@ static const enum PixelFormat pix_fmts_8bit[] = { }; static const enum PixelFormat pix_fmts_9bit[] = { PIX_FMT_YUV420P9, + PIX_FMT_YUV444P9, PIX_FMT_NONE }; static const enum PixelFormat pix_fmts_10bit[] = { PIX_FMT_YUV420P10, + PIX_FMT_YUV422P10, + PIX_FMT_YUV444P10, PIX_FMT_NONE }; @@ -592,52 +592,52 @@ static av_cold void X264_init_static(AVCodec *codec) #define OFFSET(x) offsetof(X264Context, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), FF_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE}, - { "tune", "Tune the encoding params (cf. x264 --fullhelp)", OFFSET(tune), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "profile", "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, { 1 }, 0, 1, VE}, - {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - {"x264opts", "x264 options", OFFSET(x264opts), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - { "crf", "Select the quality for constant quality mode", OFFSET(crf), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, - { "crf_max", "In CRF mode, prevents VBV from lowering quality beyond this point.",OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, - { "qp", "Constant quantization parameter rate control method",OFFSET(cqp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, - { "aq-mode", "AQ method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "aq_mode"}, - { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_AQ_NONE}, INT_MIN, INT_MAX, VE, "aq_mode" }, - { "variance", "Variance AQ (complexity mask)", 0, FF_OPT_TYPE_CONST, {X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, - { "autovariance", "Auto-variance AQ (experimental)", 0, FF_OPT_TYPE_CONST, {X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, - { "aq-strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {-1}, -1, FLT_MAX, VE}, - { "psy", "Use psychovisual optimizations.", OFFSET(psy), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "psy-rd", "Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.", OFFSET(psy_rd), FF_OPT_TYPE_STRING, {0 }, 0, 0, VE}, - { "rc-lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, - { "weightb", "Weighted prediction for B-frames.", OFFSET(weightb), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "weightp", "Weighted prediction analysis method.", OFFSET(weightp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "weightp" }, - { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_NONE}, INT_MIN, INT_MAX, VE, "weightp" }, - { "simple", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX, VE, "weightp" }, - { "smart", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" }, - { "ssim", "Calculate and print SSIM stats.", OFFSET(ssim), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "intra-refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), FF_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE }, - { "b-pyramid", "Keep some B-frames as references.", OFFSET(b_pyramid), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "b_pyramid" }, - { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX, VE, "b_pyramid" }, - { "strict", "Strictly hierarchical pyramid", 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX, VE, "b_pyramid" }, - { "normal", "Non-strict (not Blu-ray compatible)", 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX, VE, "b_pyramid" }, - { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), FF_OPT_TYPE_INT, {-1}, -1, 1, VE }, - { "8x8dct", "High profile 8x8 transform.", OFFSET(dct8x8), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "fast-pskip", NULL, OFFSET(fast_pskip), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "aud", "Use access unit delimiters.", OFFSET(aud), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "deblock", "Loop filter parameters, in <alpha:beta> form.", OFFSET(deblock), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, + { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), AV_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE}, + { "tune", "Tune the encoding params (cf. x264 --fullhelp)", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "profile", "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), AV_OPT_TYPE_INT, { 1 }, 0, 1, VE}, + {"level", "Specify level (as defined by Annex A)", OFFSET(level), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"x264opts", "x264 options", OFFSET(x264opts), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + { "crf", "Select the quality for constant quality mode", OFFSET(crf), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, + { "crf_max", "In CRF mode, prevents VBV from lowering quality beyond this point.",OFFSET(crf_max), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, + { "qp", "Constant quantization parameter rate control method",OFFSET(cqp), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + { "aq-mode", "AQ method", OFFSET(aq_mode), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "aq_mode"}, + { "none", NULL, 0, AV_OPT_TYPE_CONST, {X264_AQ_NONE}, INT_MIN, INT_MAX, VE, "aq_mode" }, + { "variance", "Variance AQ (complexity mask)", 0, AV_OPT_TYPE_CONST, {X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, + { "autovariance", "Auto-variance AQ (experimental)", 0, AV_OPT_TYPE_CONST, {X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, + { "aq-strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, {-1}, -1, FLT_MAX, VE}, + { "psy", "Use psychovisual optimizations.", OFFSET(psy), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "psy-rd", "Strength of psychovisual optimization, in <psy-rd>:<psy-trellis> format.", OFFSET(psy_rd), AV_OPT_TYPE_STRING, {0 }, 0, 0, VE}, + { "rc-lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + { "weightb", "Weighted prediction for B-frames.", OFFSET(weightb), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "weightp", "Weighted prediction analysis method.", OFFSET(weightp), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "weightp" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, {X264_WEIGHTP_NONE}, INT_MIN, INT_MAX, VE, "weightp" }, + { "simple", NULL, 0, AV_OPT_TYPE_CONST, {X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX, VE, "weightp" }, + { "smart", NULL, 0, AV_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" }, + { "ssim", "Calculate and print SSIM stats.", OFFSET(ssim), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "intra-refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), AV_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE }, + { "b-pyramid", "Keep some B-frames as references.", OFFSET(b_pyramid), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "b_pyramid" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, {X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX, VE, "b_pyramid" }, + { "strict", "Strictly hierarchical pyramid", 0, AV_OPT_TYPE_CONST, {X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX, VE, "b_pyramid" }, + { "normal", "Non-strict (not Blu-ray compatible)", 0, AV_OPT_TYPE_CONST, {X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX, VE, "b_pyramid" }, + { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), AV_OPT_TYPE_INT, {-1}, -1, 1, VE }, + { "8x8dct", "High profile 8x8 transform.", OFFSET(dct8x8), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "aud", "Use access unit delimiters.", OFFSET(aud), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "deblock", "Loop filter parameters, in <alpha:beta> form.", OFFSET(deblock), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, { "partitions", "A comma-separated list of partitions to consider. " - "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all", OFFSET(partitions), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "direct-pred", "Direct MV prediction mode", OFFSET(direct_pred), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "direct-pred" }, - { "none", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_NONE }, 0, 0, VE, "direct-pred" }, - { "spatial", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_SPATIAL }, 0, 0, VE, "direct-pred" }, - { "temporal", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" }, - { "auto", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_AUTO }, 0, 0, VE, "direct-pred" }, - { "slice-max-size","Constant quantization parameter rate control method",OFFSET(slice_max_size), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all", OFFSET(partitions), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "direct-pred", "Direct MV prediction mode", OFFSET(direct_pred), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "direct-pred" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_NONE }, 0, 0, VE, "direct-pred" }, + { "spatial", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_SPATIAL }, 0, 0, VE, "direct-pred" }, + { "temporal", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" }, + { "auto", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_AUTO }, 0, 0, VE, "direct-pred" }, + { "slice-max-size","Constant quantization parameter rate control method",OFFSET(slice_max_size), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, { NULL }, }; |