From 2e2594ca5ba64705114bc26bbb264af245352a73 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 29 Aug 2011 12:53:08 +0200 Subject: [PATCH 01/31] avconv: remove -threads option. It's only shadowing the AVOption with the same name. --- avconv.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/avconv.c b/avconv.c index 32ae3757d0..22d54ad0ab 100644 --- a/avconv.c +++ b/avconv.c @@ -190,7 +190,6 @@ static int audio_volume = 256; static int exit_on_error = 0; static int using_stdin = 0; static int verbose = 1; -static int thread_count= 1; static int64_t video_size = 0; static int64_t audio_size = 0; static int64_t extra_size = 0; @@ -2558,16 +2557,6 @@ static int opt_top_field_first(const char *opt, const char *arg) return 0; } -static int opt_thread_count(const char *opt, const char *arg) -{ - thread_count= parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); -#if !HAVE_THREADS - if (verbose >= 0) - fprintf(stderr, "Warning: not compiled with thread support, using thread emulation\n"); -#endif - return 0; -} - static int opt_audio_sample_fmt(const char *opt, const char *arg) { if (strcmp(arg, "list")) { @@ -2861,8 +2850,6 @@ static void add_input_streams(AVFormatContext *ic) InputStream *ist; char *scale = NULL; - dec->thread_count = thread_count; - input_streams = grow_array(input_streams, sizeof(*input_streams), &nb_input_streams, nb_input_streams + 1); ist = &input_streams[nb_input_streams - 1]; ist->st = st; @@ -3151,8 +3138,6 @@ static OutputStream *new_video_stream(AVFormatContext *oc) ost->bitstream_filters = video_bitstream_filters; video_bitstream_filters= NULL; - st->codec->thread_count= thread_count; - video_enc = st->codec; if(video_codec_tag) @@ -3256,8 +3241,6 @@ static OutputStream *new_audio_stream(AVFormatContext *oc) ost->bitstream_filters = audio_bitstream_filters; audio_bitstream_filters= NULL; - st->codec->thread_count= thread_count; - audio_enc = st->codec; audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; @@ -4073,7 +4056,6 @@ static const OptionDef options[] = { { "re", OPT_BOOL | OPT_EXPERT, {(void*)&rate_emu}, "read input at native frame rate", "" }, { "v", HAS_ARG, {(void*)opt_verbose}, "set the verbosity level", "number" }, { "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" }, - { "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" }, { "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" }, { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" }, { "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&audio_drift_threshold}, "audio drift threshold", "threshold" }, From dde372934a5cc1012a2dfe841b7b7db925805ca1 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 29 Aug 2011 22:47:06 +0200 Subject: [PATCH 02/31] avcodec: remove misleading comment coded_width is the width before lowres scaling, coded_height is the height before lowres scaling. --- libavcodec/avcodec.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b47d41ee78..3c7d781ad0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2278,8 +2278,7 @@ typedef struct AVCodecContext { int lowres; /** - * Bitstream width / height, may be different from width/height if lowres - * or other things are used. + * Bitstream width / height, may be different from width/height if lowres enabled. * - encoding: unused * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. */ From 3b81636f33e9df53153d7e7add02167c0544e695 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 07:52:03 +0200 Subject: [PATCH 03/31] libx264: make options compatible with x264 Replace '_' with '-', merge psy-trellis into psy-rd and rename cqp->qp Also fix typo pdy-rd -> psy-rd --- libavcodec/libx264.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index ebbb217a46..fc751a4fd8 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -46,8 +46,7 @@ typedef struct X264Context { int cqp; int aq_mode; float aq_strength; - float psy_rd; - float psy_trellis; + char *psy_rd; int rc_lookahead; int weightp; } X264Context; @@ -330,10 +329,10 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.rc.i_aq_mode = x4->aq_mode; if (x4->aq_strength >= 0) x4->params.rc.f_aq_strength = x4->aq_strength; - if (x4->psy_rd >= 0) - x4->params.analyse.f_psy_rd = x4->psy_rd; - if (x4->psy_trellis >= 0) - x4->params.analyse.f_psy_trellis = x4->psy_trellis; + if (x4->psy_rd && x264_param_parse(&x4->params, "psy-rd", x4->psy_rd) < 0) { + av_log(avctx, AV_LOG_ERROR, "Error parsing option 'psy-rd' with value '%s'.\n", x4->psy_rd); + return AVERROR(EINVAL); + } if (x4->rc_lookahead >= 0) x4->params.rc.i_lookahead = x4->rc_lookahead; if (x4->weightp >= 0) @@ -415,15 +414,14 @@ static const AVOption options[] = { { "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, { 1 }, 0, 1, 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 }, - { "cqp", "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"}, + { "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}, - { "pdy_rd", "Psy RD strength.", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, - { "psy_trellis", "Psy trellis strength", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, 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 }, + { "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-rd", "Strength of psychovisual optimization, in : 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 }, { "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" }, From faaecd47082413bcbd94a66ead544c4227fe243e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 04/31] libx264: add 'ssim' private option. Deprecate CODEC_FLAG2_SSIM. --- libavcodec/avcodec.h | 2 ++ libavcodec/libx264.c | 6 +++++- libavcodec/options.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 3c7d781ad0..6e16625842 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -623,7 +623,9 @@ typedef struct RcOverride{ #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. +#if FF_API_X264_GLOBAL_OPTS #define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. +#endif #define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. /* Unsupported options : diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index fc751a4fd8..7c4db79959 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -49,6 +49,7 @@ typedef struct X264Context { char *psy_rd; int rc_lookahead; int weightp; + int ssim; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -323,6 +324,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.rc.i_lookahead = avctx->rc_lookahead; if (avctx->weighted_p_pred >= 0) x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred; + x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM; #endif if (x4->aq_mode >= 0) @@ -338,6 +340,8 @@ static av_cold int X264_init(AVCodecContext *avctx) if (x4->weightp >= 0) x4->params.analyse.i_weighted_pred = x4->weightp; + if (x4->ssim >= 0) + x4->params.analyse.b_ssim = x4->ssim; if (x4->fastfirstpass) @@ -357,7 +361,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num; x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; - x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM; x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; @@ -426,6 +429,7 @@ static const AVOption options[] = { { "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 }, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index 784d3b11a6..1bde206663 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -445,8 +445,8 @@ static const AVOption options[]={ {"aq_mode", "specify aq method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, INT_MAX, V|E}, {"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, {"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {.dbl = 40 }, 0, INT_MAX, V|E}, -#endif {"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SSIM }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"}, #if FF_API_X264_GLOBAL_OPTS {"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E}, From 5d4a1048ee251cf7cb2da7d24f23da6d8a34459a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 05/31] libx264: add 'intra-refresh' private option. Deprecate CODEC_FLAG2_INTRA_REFRESH. --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 6 +++++- libavcodec/options.c | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 6e16625842..ea05ed4102 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -625,8 +625,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. #if FF_API_X264_GLOBAL_OPTS #define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. -#endif #define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. +#endif /* Unsupported options : * Syntax Arithmetic coding (SAC) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 7c4db79959..2cf3009e4d 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -50,6 +50,7 @@ typedef struct X264Context { int rc_lookahead; int weightp; int ssim; + int intra_refresh; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -266,7 +267,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.p_log_private = avctx; x4->params.i_log_level = X264_LOG_DEBUG; - x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; if (avctx->bit_rate) { x4->params.rc.i_bitrate = avctx->bit_rate / 1000; x4->params.rc.i_rc_method = X264_RC_ABR; @@ -325,6 +325,7 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx->weighted_p_pred >= 0) x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred; x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM; + x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; #endif if (x4->aq_mode >= 0) @@ -342,6 +343,8 @@ static av_cold int X264_init(AVCodecContext *avctx) if (x4->ssim >= 0) x4->params.analyse.b_ssim = x4->ssim; + if (x4->intra_refresh >= 0) + x4->params.b_intra_refresh = x4->intra_refresh; if (x4->fastfirstpass) @@ -430,6 +433,7 @@ static const AVOption options[] = { { "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 }, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index 1bde206663..3ae621b3f3 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -446,9 +446,7 @@ static const AVOption options[]={ {"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, {"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {.dbl = 40 }, 0, INT_MAX, V|E}, {"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SSIM }, INT_MIN, INT_MAX, V|E, "flags2"}, -#endif {"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"}, -#if FF_API_X264_GLOBAL_OPTS {"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E}, #endif {"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX }, From 34dda1251d590df559f54f67b3a3a80e3f5835d7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 06/31] libx264: add 'b-pyramid' private option. Deprecate CODEC_FLAG2_BPYRAMID. --- libavcodec/avcodec.h | 2 ++ libavcodec/libx264.c | 10 ++++++++-- libavcodec/options.c | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ea05ed4102..36d3fde0a4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -607,7 +607,9 @@ typedef struct RcOverride{ #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. #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_X264_GLOBAL_OPTS #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. +#endif #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 2cf3009e4d..7ca82d9cd1 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -51,6 +51,7 @@ typedef struct X264Context { int weightp; int ssim; int intra_refresh; + int b_pyramid; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -188,8 +189,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC; x4->params.i_bframe_adaptive = avctx->b_frame_strategy; x4->params.i_bframe_bias = avctx->bframebias; - x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE; - avctx->has_b_frames = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames; x4->params.i_keyint_min = avctx->keyint_min; if (x4->params.i_keyint_min > x4->params.i_keyint_max) @@ -326,6 +325,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred; x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM; x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; + x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE; #endif if (x4->aq_mode >= 0) @@ -345,6 +345,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_ssim = x4->ssim; if (x4->intra_refresh >= 0) x4->params.b_intra_refresh = x4->intra_refresh; + if (x4->b_pyramid >= 0) + x4->params.i_bframe_pyramid = x4->b_pyramid; if (x4->fastfirstpass) @@ -434,6 +436,10 @@ static const AVOption options[] = { { "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-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" }, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index 3ae621b3f3..6881f9cbf1 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -387,7 +387,9 @@ static const AVOption options[]={ {"bframebias", "influences how often B-frames are used", OFFSET(bframebias), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"trellis", "rate-distortion optimal quantization", OFFSET(trellis), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, {"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)", OFFSET(directpred), FF_OPT_TYPE_INT, {.dbl = 2 }, INT_MIN, INT_MAX, V|E}, +#if FF_API_X264_GLOBAL_OPTS {"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"}, {"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, {"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, From 0f29699db73d569307cac1abce64ae43647db2d2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 07/31] libx264: add 'weightb' private option. Deprecate CODEC_FLAG2_BPYRAMID. --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 7 +++++-- libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 36d3fde0a4..3b669ceb1f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -609,8 +609,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. #if FF_API_X264_GLOBAL_OPTS #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. -#endif #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames +#endif #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 7ca82d9cd1..bf2aacb5d8 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -49,6 +49,7 @@ typedef struct X264Context { char *psy_rd; int rc_lookahead; int weightp; + int weightb; int ssim; int intra_refresh; int b_pyramid; @@ -226,8 +227,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_direct_mv_pred = avctx->directpred; - x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; - if (avctx->me_method == ME_EPZS) x4->params.analyse.i_me_method = X264_ME_DIA; else if (avctx->me_method == ME_HEX) @@ -326,6 +325,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM; x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE; + x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; #endif if (x4->aq_mode >= 0) @@ -340,6 +340,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.rc.i_lookahead = x4->rc_lookahead; if (x4->weightp >= 0) x4->params.analyse.i_weighted_pred = x4->weightp; + if (x4->weightb >= 0) + x4->params.analyse.b_weighted_bipred = x4->weightb; if (x4->ssim >= 0) x4->params.analyse.b_ssim = x4->ssim; @@ -430,6 +432,7 @@ static const AVOption options[] = { { "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-rd", "Strength of psychovisual optimization, in : 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" }, diff --git a/libavcodec/options.c b/libavcodec/options.c index 6881f9cbf1..90ffb1cf8a 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -389,8 +389,8 @@ static const AVOption options[]={ {"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)", OFFSET(directpred), FF_OPT_TYPE_INT, {.dbl = 2 }, INT_MIN, INT_MAX, V|E}, #if FF_API_X264_GLOBAL_OPTS {"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"}, -#endif {"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, {"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, {"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"}, From eab21c32e34d8dc45e915c597cf974f31a95c207 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 08/31] libx264: add 'mixed-refs' private option. Deprecate CODEC_FLAG2_MIXED_REFS. --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 7 +++++-- libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 3b669ceb1f..c7c8583ac1 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -610,8 +610,8 @@ typedef struct RcOverride{ #if FF_API_X264_GLOBAL_OPTS #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames -#endif #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock +#endif #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index bf2aacb5d8..3ebc0a8ed9 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -53,6 +53,7 @@ typedef struct X264Context { int ssim; int intra_refresh; int b_pyramid; + int mixed_refs; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -244,7 +245,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; - x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; @@ -326,6 +326,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE; x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; + x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS; #endif if (x4->aq_mode >= 0) @@ -349,7 +350,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.b_intra_refresh = x4->intra_refresh; if (x4->b_pyramid >= 0) x4->params.i_bframe_pyramid = x4->b_pyramid; - + if (x4->mixed_refs >= 0) + x4->params.analyse.b_mixed_references = x4->mixed_refs; if (x4->fastfirstpass) x264_param_apply_fastfirstpass(&x4->params); @@ -443,6 +445,7 @@ static const AVOption options[] = { { "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 }, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index 90ffb1cf8a..f6fd6e545e 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -390,8 +390,8 @@ static const AVOption options[]={ #if FF_API_X264_GLOBAL_OPTS {"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"}, {"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"}, -#endif {"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, {"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"}, {"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"}, From 373257fa793b5ec2c22236a446d889018838e362 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 09/31] libx264: add '8x8dct' private option. Deprecate CODEC_FLAG2_8X8DCT. --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 6 +++++- libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c7c8583ac1..52c5fa05e6 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -611,8 +611,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock -#endif #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform +#endif #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 3ebc0a8ed9..d164dce28a 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -54,6 +54,7 @@ typedef struct X264Context { int intra_refresh; int b_pyramid; int mixed_refs; + int dct8x8; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -246,7 +247,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; - x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; x4->params.analyse.i_trellis = avctx->trellis; @@ -327,6 +327,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE; x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS; + x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; #endif if (x4->aq_mode >= 0) @@ -352,6 +353,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.i_bframe_pyramid = x4->b_pyramid; if (x4->mixed_refs >= 0) x4->params.analyse.b_mixed_references = x4->mixed_refs; + if (x4->dct8x8 >= 0) + x4->params.analyse.b_transform_8x8 = x4->dct8x8; if (x4->fastfirstpass) x264_param_apply_fastfirstpass(&x4->params); @@ -446,6 +449,7 @@ static const AVOption options[] = { { "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}, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index f6fd6e545e..a98fd8c2b4 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -391,8 +391,8 @@ static const AVOption options[]={ {"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"}, {"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"}, {"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, -#endif {"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"}, {"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"}, {"skiprd", "RD optimal MB level residual skipping", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"}, From 3b82aeeec0a320a78d548ff0147b3cdb26ea982c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 10/31] libx264: add 'fast-pskip' private option. Deprecate CODEC_FLAG2_FASTPSKIP. --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 6 +++++- libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 52c5fa05e6..2f10d245c7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -612,8 +612,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform -#endif #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip +#endif #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index d164dce28a..646a7a5915 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -55,6 +55,7 @@ typedef struct X264Context { int b_pyramid; int mixed_refs; int dct8x8; + int fast_pskip; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -247,7 +248,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA; - x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_noise_reduction = avctx->noise_reduction; @@ -328,6 +328,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED; x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS; x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; + x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; #endif if (x4->aq_mode >= 0) @@ -355,6 +356,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_mixed_references = x4->mixed_refs; if (x4->dct8x8 >= 0) x4->params.analyse.b_transform_8x8 = x4->dct8x8; + if (x4->fast_pskip >= 0) + x4->params.analyse.b_fast_pskip = x4->fast_pskip; if (x4->fastfirstpass) x264_param_apply_fastfirstpass(&x4->params); @@ -450,6 +453,7 @@ static const AVOption options[] = { { "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}, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index a98fd8c2b4..0e4d0127f7 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -392,8 +392,8 @@ static const AVOption options[]={ {"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"}, {"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, {"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, -#endif {"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"}, {"skiprd", "RD optimal MB level residual skipping", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"}, {"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, {.dbl = 20.0 }, FLT_MIN, FLT_MAX, V|E}, From cf90c5d0e0a48cbc63cd3355b2fa77a5545f0c2b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH 11/31] libx264: add 'aud' private option. Deprecate CODEC_FLAG2_AUD. --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 7 +++++-- libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2f10d245c7..d5a4cf34b6 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -613,8 +613,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip -#endif #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters +#endif #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 646a7a5915..e653de45ab 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -56,6 +56,7 @@ typedef struct X264Context { int mixed_refs; int dct8x8; int fast_pskip; + int aud; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -329,6 +330,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS; x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; + x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; #endif if (x4->aq_mode >= 0) @@ -358,6 +360,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_transform_8x8 = x4->dct8x8; if (x4->fast_pskip >= 0) x4->params.analyse.b_fast_pskip = x4->fast_pskip; + if (x4->aud >= 0) + x4->params.b_aud = x4->aud; if (x4->fastfirstpass) x264_param_apply_fastfirstpass(&x4->params); @@ -377,8 +381,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR; - x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; - x4->params.i_threads = avctx->thread_count; x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT; @@ -454,6 +456,7 @@ static const AVOption options[] = { { "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}, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index 0e4d0127f7..9f7a899a75 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -393,8 +393,8 @@ static const AVOption options[]={ {"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, {"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, {"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"}, -#endif {"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"skiprd", "RD optimal MB level residual skipping", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"}, {"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, {.dbl = 20.0 }, FLT_MIN, FLT_MAX, V|E}, {"deblockalpha", "in-loop deblocking filter alphac0 parameter", OFFSET(deblockalpha), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, -6, 6, V|E}, From 7485e547080baafdb61a8d0e7c50d8a1598bbcb6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 24 Aug 2011 16:26:15 +0200 Subject: [PATCH 12/31] lavc: deprecate CODEC_FLAG2_BRDO It's been unused for the last 3 years. --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index d5a4cf34b6..e9cf0eaa8a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -614,8 +614,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters -#endif #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization +#endif #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. From a18e04bcf989a9d7f5629c573f9d70f8a020c7a7 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Thu, 25 Aug 2011 19:47:01 -0400 Subject: [PATCH 13/31] mjpeg: treat external huffman table setup failure as codec init failure if external huffman table use requested Signed-off-by: Anton Khirnov --- libavcodec/mjpegdec.c | 4 ++-- libavcodec/mxpegdec.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 81effb4f8c..b9db777fe1 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -101,8 +101,8 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n"); init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8); if (ff_mjpeg_decode_dht(s)) { - av_log(avctx, AV_LOG_ERROR, "mjpeg: error using external huffman table, switching back to internal\n"); - build_basic_mjpeg_vlc(s); + av_log(avctx, AV_LOG_ERROR, "mjpeg: error using external huffman table\n"); + return AVERROR_INVALIDDATA; } } if (avctx->extradata_size > 9 && diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c index 92fd244ec7..fd3fef47a9 100644 --- a/libavcodec/mxpegdec.c +++ b/libavcodec/mxpegdec.c @@ -47,9 +47,7 @@ static av_cold int mxpeg_decode_init(AVCodecContext *avctx) s->picture[0].reference = s->picture[1].reference = 3; s->jpg.picture_ptr = &s->picture[0]; - ff_mjpeg_decode_init(avctx); - - return 0; + return ff_mjpeg_decode_init(avctx); } static int mxpeg_decode_app(MXpegDecodeContext *s, From d2f119a1f2d2d72b0001fcdf2cc051b022bf6528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Delm=C3=A1s?= Date: Sat, 27 Aug 2011 19:37:26 +0200 Subject: [PATCH 14/31] VC1: Support dynamic dimension changes Fixes SA00072, SA00073, SA10150, SA10151, Issue2076 Improves SA10153 Signed-off-by: Anton Khirnov --- libavcodec/vc1.c | 17 ++-- libavcodec/vc1dec.c | 202 +++++++++++++++++++++++--------------------- 2 files changed, 118 insertions(+), 101 deletions(-) diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index c3649ac383..870feaaa76 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -453,9 +453,6 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) v->finterpflag = get_bits1(gb); skip_bits1(gb); // reserved - v->s.h_edge_pos = v->s.avctx->coded_width; - v->s.v_edge_pos = v->s.avctx->coded_height; - av_log(v->s.avctx, AV_LOG_DEBUG, "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n" @@ -474,8 +471,8 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) if(get_bits1(gb)) { //Display Info - decoding is not affected by it int w, h, ar = 0; av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n"); - v->s.avctx->width = w = get_bits(gb, 14) + 1; - v->s.avctx->height = h = get_bits(gb, 14) + 1; + w = get_bits(gb, 14) + 1; + h = get_bits(gb, 14) + 1; av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h); if(get_bits1(gb)) ar = get_bits(gb, 4); @@ -485,6 +482,12 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb) w = get_bits(gb, 8) + 1; h = get_bits(gb, 8) + 1; v->s.avctx->sample_aspect_ratio = (AVRational){w, h}; + } else { + av_reduce(&v->s.avctx->sample_aspect_ratio.num, + &v->s.avctx->sample_aspect_ratio.den, + v->s.avctx->height * w, + v->s.avctx->width * h, + 1<<30); } av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", v->s.avctx->sample_aspect_ratio.num, v->s.avctx->sample_aspect_ratio.den); @@ -552,8 +555,8 @@ int vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContext * } if(get_bits1(gb)){ - avctx->coded_width = (get_bits(gb, 12)+1)<<1; - avctx->coded_height = (get_bits(gb, 12)+1)<<1; + avctx->width = avctx->coded_width = (get_bits(gb, 12)+1)<<1; + avctx->height = avctx->coded_height = (get_bits(gb, 12)+1)<<1; } if(v->extended_mv) v->extended_dmv = get_bits1(gb); diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index f4d6f997f8..095f08011b 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3551,6 +3551,58 @@ static void vc1_sprite_flush(AVCodecContext *avctx) #endif +static av_cold int vc1_decode_init_alloc_tables(VC1Context *v) +{ + MpegEncContext *s = &v->s; + int i; + + /* Allocate mb bitplanes */ + v->mv_type_mb_plane = av_malloc(s->mb_stride * s->mb_height); + v->direct_mb_plane = av_malloc(s->mb_stride * s->mb_height); + v->acpred_plane = av_malloc(s->mb_stride * s->mb_height); + v->over_flags_plane = av_malloc(s->mb_stride * s->mb_height); + + v->n_allocated_blks = s->mb_width + 2; + v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks); + v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); + v->cbp = v->cbp_base + s->mb_stride; + v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride); + v->ttblk = v->ttblk_base + s->mb_stride; + v->is_intra_base = av_malloc(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); + v->is_intra = v->is_intra_base + s->mb_stride; + v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride); + v->luma_mv = v->luma_mv_base + s->mb_stride; + + /* allocate block type info in that way so it could be used with s->block_index[] */ + v->mb_type_base = av_malloc(s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); + v->mb_type[0] = v->mb_type_base + s->b8_stride + 1; + v->mb_type[1] = v->mb_type_base + s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride + 1; + v->mb_type[2] = v->mb_type[1] + s->mb_stride * (s->mb_height + 1); + + /* Init coded blocks info */ + if (v->profile == PROFILE_ADVANCED) + { +// if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0) +// return -1; +// if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0) +// return -1; + } + + ff_intrax8_common_init(&v->x8,s); + + if (s->avctx->codec_id == CODEC_ID_WMV3IMAGE || s->avctx->codec_id == CODEC_ID_VC1IMAGE) { + for (i = 0; i < 4; i++) + if (!(v->sr_rows[i>>1][i%2] = av_malloc(v->output_width))) return -1; + } + + if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->acpred_plane || !v->over_flags_plane || + !v->block || !v->cbp_base || !v->ttblk_base || !v->is_intra_base || !v->luma_mv_base || + !v->mb_type_base) + return -1; + + return 0; +} + /** Initialize a VC1/WMV3 decoder * @todo TODO: Handle VC-1 IDUs (Transport level?) * @todo TODO: Decypher remaining bits in extra_data @@ -3560,7 +3612,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; GetBitContext gb; - int i, cur_width, cur_height; + int i; /* save the container output size for WMImage */ v->output_width = avctx->width; @@ -3580,13 +3632,9 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) avctx->idct_algo=FF_IDCT_WMV2; } - if(ff_msmpeg4_decode_init(avctx) < 0) - return -1; if (vc1_init_common(v) < 0) return -1; ff_vc1dsp_init(&v->vc1dsp); - cur_width = avctx->coded_width = avctx->width; - cur_height = avctx->coded_height = avctx->height; if (avctx->codec_id == CODEC_ID_WMV3 || avctx->codec_id == CODEC_ID_WMV3IMAGE) { int count = 0; @@ -3657,25 +3705,12 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) } v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2')); } - // Sequence header information may not have been parsed - // yet when ff_msmpeg4_decode_init was called the fist time - // above. If sequence information changes, we need to call - // it again. - if (cur_width != avctx->width || - cur_height != avctx->height) { - MPV_common_end(s); - if(ff_msmpeg4_decode_init(avctx) < 0) - return -1; - avctx->coded_width = avctx->width; - avctx->coded_height = avctx->height; - } avctx->profile = v->profile; if (v->profile == PROFILE_ADVANCED) avctx->level = v->level; avctx->has_b_frames= !!(avctx->max_b_frames); - s->low_delay = !avctx->has_b_frames; s->mb_width = (avctx->coded_width+15)>>4; s->mb_height = (avctx->coded_height+15)>>4; @@ -3696,46 +3731,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) v->top_blk_sh = 0; } - /* Allocate mb bitplanes */ - v->mv_type_mb_plane = av_malloc(s->mb_stride * s->mb_height); - v->direct_mb_plane = av_malloc(s->mb_stride * s->mb_height); - v->acpred_plane = av_malloc(s->mb_stride * s->mb_height); - v->over_flags_plane = av_malloc(s->mb_stride * s->mb_height); - - v->n_allocated_blks = s->mb_width + 2; - v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks); - v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); - v->cbp = v->cbp_base + s->mb_stride; - v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride); - v->ttblk = v->ttblk_base + s->mb_stride; - v->is_intra_base = av_malloc(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); - v->is_intra = v->is_intra_base + s->mb_stride; - v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride); - v->luma_mv = v->luma_mv_base + s->mb_stride; - - /* allocate block type info in that way so it could be used with s->block_index[] */ - v->mb_type_base = av_malloc(s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); - v->mb_type[0] = v->mb_type_base + s->b8_stride + 1; - v->mb_type[1] = v->mb_type_base + s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride + 1; - v->mb_type[2] = v->mb_type[1] + s->mb_stride * (s->mb_height + 1); - - /* Init coded blocks info */ - if (v->profile == PROFILE_ADVANCED) - { -// if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0) -// return -1; -// if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0) -// return -1; - } - - ff_intrax8_common_init(&v->x8,s); - if (avctx->codec_id == CODEC_ID_WMV3IMAGE || avctx->codec_id == CODEC_ID_VC1IMAGE) { - for (i = 0; i < 4; i++) - if (!(v->sr_rows[i>>1][i%2] = av_malloc(v->output_width))) return -1; - - s->low_delay = 1; - v->sprite_width = avctx->coded_width; v->sprite_height = avctx->coded_height; @@ -3751,6 +3747,36 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) return 0; } +/** Close a VC1/WMV3 decoder + * @warning Initial try at using MpegEncContext stuff + */ +static av_cold int vc1_decode_end(AVCodecContext *avctx) +{ + VC1Context *v = avctx->priv_data; + int i; + + if ((avctx->codec_id == CODEC_ID_WMV3IMAGE || avctx->codec_id == CODEC_ID_VC1IMAGE) + && v->sprite_output_frame.data[0]) + avctx->release_buffer(avctx, &v->sprite_output_frame); + for (i = 0; i < 4; i++) + av_freep(&v->sr_rows[i>>1][i%2]); + av_freep(&v->hrd_rate); + av_freep(&v->hrd_buffer); + MPV_common_end(&v->s); + av_freep(&v->mv_type_mb_plane); + av_freep(&v->direct_mb_plane); + av_freep(&v->acpred_plane); + av_freep(&v->over_flags_plane); + av_freep(&v->mb_type_base); + av_freep(&v->block); + av_freep(&v->cbp_base); + av_freep(&v->ttblk_base); + av_freep(&v->is_intra_base); // FIXME use v->mb_type[] + av_freep(&v->luma_mv_base); + ff_intrax8_common_end(&v->x8); + return 0; +} + /** Decode a VC1/WMV3 frame * @todo TODO: Handle VC-1 IDUs (Transport level?) @@ -3785,13 +3811,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, return 0; } - /* We need to set current_picture_ptr before reading the header, - * otherwise we cannot store anything in there. */ - if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { - int i= ff_find_unused_picture(s, 0); - s->current_picture_ptr= &s->picture[i]; - } - if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){ if (v->profile < PROFILE_ADVANCED) avctx->pix_fmt = PIX_FMT_VDPAU_WMV3; @@ -3880,6 +3899,31 @@ static int vc1_decode_frame(AVCodecContext *avctx, } } + if (s->context_initialized && + (s->width != avctx->coded_width || + s->height != avctx->coded_height)) { + vc1_decode_end(avctx); + } + + if (!s->context_initialized) { + if (ff_msmpeg4_decode_init(avctx) < 0 || vc1_decode_init_alloc_tables(v) < 0) + return -1; + + s->low_delay = !avctx->has_b_frames || v->res_sprite; + + if (v->profile == PROFILE_ADVANCED) { + s->h_edge_pos = avctx->coded_width; + s->v_edge_pos = avctx->coded_height; + } + } + + /* We need to set current_picture_ptr before reading the header, + * otherwise we cannot store anything in there. */ + if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { + int i= ff_find_unused_picture(s, 0); + s->current_picture_ptr= &s->picture[i]; + } + // do parse frame header if(v->profile < PROFILE_ADVANCED) { if(vc1_parse_frame_header(v, &s->gb) == -1) { @@ -4011,36 +4055,6 @@ err: } -/** Close a VC1/WMV3 decoder - * @warning Initial try at using MpegEncContext stuff - */ -static av_cold int vc1_decode_end(AVCodecContext *avctx) -{ - VC1Context *v = avctx->priv_data; - int i; - - if ((avctx->codec_id == CODEC_ID_WMV3IMAGE || avctx->codec_id == CODEC_ID_VC1IMAGE) - && v->sprite_output_frame.data[0]) - avctx->release_buffer(avctx, &v->sprite_output_frame); - for (i = 0; i < 4; i++) - av_freep(&v->sr_rows[i>>1][i%2]); - av_freep(&v->hrd_rate); - av_freep(&v->hrd_buffer); - MPV_common_end(&v->s); - av_freep(&v->mv_type_mb_plane); - av_freep(&v->direct_mb_plane); - av_freep(&v->acpred_plane); - av_freep(&v->over_flags_plane); - av_freep(&v->mb_type_base); - av_freep(&v->block); - av_freep(&v->cbp_base); - av_freep(&v->ttblk_base); - av_freep(&v->is_intra_base); // FIXME use v->mb_type[] - av_freep(&v->luma_mv_base); - ff_intrax8_common_end(&v->x8); - return 0; -} - static const AVProfile profiles[] = { { FF_PROFILE_VC1_SIMPLE, "Simple" }, { FF_PROFILE_VC1_MAIN, "Main" }, From 297d9cb3dc6850b83ba4e95789143833cecdfd87 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 08:26:14 +0200 Subject: [PATCH 15/31] mpeg12enc: add intra_vlc private option. Deprecate CODEC_FLAG2_INTRA_VLC. --- libavcodec/arm/asm-offsets.h | 12 ++++++------ libavcodec/avcodec.h | 2 ++ libavcodec/mpeg12enc.c | 22 ++++++++++++++++++++++ libavcodec/mpegvideo.h | 1 + libavcodec/mpegvideo_enc.c | 2 ++ libavcodec/options.c | 2 ++ libavcodec/version.h | 3 +++ 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/libavcodec/arm/asm-offsets.h b/libavcodec/arm/asm-offsets.h index 89994569c1..4864a9bdd9 100644 --- a/libavcodec/arm/asm-offsets.h +++ b/libavcodec/arm/asm-offsets.h @@ -29,11 +29,11 @@ #endif /* MpegEncContext */ -#define Y_DC_SCALE 0xa8 -#define C_DC_SCALE 0xac -#define AC_PRED 0xb0 -#define BLOCK_LAST_INDEX 0xb4 -#define H263_AIC 0xe4 -#define INTER_SCANTAB_RASTER_END 0x12c +#define Y_DC_SCALE 0xac +#define C_DC_SCALE 0xb0 +#define AC_PRED 0xb4 +#define BLOCK_LAST_INDEX 0xb8 +#define H263_AIC 0xe8 +#define INTER_SCANTAB_RASTER_END 0x130 #endif /* AVCODEC_ARM_ASM_OFFSETS_H */ diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e9cf0eaa8a..408438e62f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -616,7 +616,9 @@ typedef struct RcOverride{ #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization #endif +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. +#endif #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 6602d81f6c..eca57d0df7 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -33,6 +33,8 @@ #include "mpeg12data.h" #include "bytestream.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" static const uint8_t inv_non_linear_qscale[13] = { 0, 2, 4, 6, 8, @@ -925,6 +927,24 @@ static void mpeg1_encode_block(MpegEncContext *s, put_bits(&s->pb, table_vlc[112][1], table_vlc[112][0]); } +#define OFFSET(x) offsetof(MpegEncContext, x) +#define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM +static const AVOption options[] = { + { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { NULL }, +}; + +#define mpeg12_class(x)\ +static const AVClass mpeg## x ##_class = {\ + .class_name = "mpeg" #x "video encoder",\ + .item_name = av_default_item_name,\ + .option = options,\ + .version = LIBAVUTIL_VERSION_INT,\ +}; + +mpeg12_class(1) +mpeg12_class(2) + AVCodec ff_mpeg1video_encoder = { .name = "mpeg1video", .type = AVMEDIA_TYPE_VIDEO, @@ -937,6 +957,7 @@ AVCodec ff_mpeg1video_encoder = { .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), + .priv_class = &mpeg1_class, }; AVCodec ff_mpeg2video_encoder = { @@ -951,4 +972,5 @@ AVCodec ff_mpeg2video_encoder = { .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), + .priv_class = &mpeg2_class, }; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 47c8e8a38d..0790b075f0 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -199,6 +199,7 @@ typedef struct MotionEstContext{ * MpegEncContext. */ typedef struct MpegEncContext { + AVClass *class; struct AVCodecContext *avctx; /* the following parameters must be initialized before encoding */ int width, height;///< picture size. must be a multiple of 16 diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 6ca48d8fb3..42fd6609c9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -336,7 +336,9 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->obmc= !!(s->flags & CODEC_FLAG_OBMC); s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER); s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN); +#if FF_API_MPEGVIDEO_GLOBAL_OPTS s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC); +#endif s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT); if(avctx->rc_max_rate && !avctx->rc_buffer_size){ diff --git a/libavcodec/options.c b/libavcodec/options.c index 9f7a899a75..19a4133a78 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -407,7 +407,9 @@ static const AVOption options[]={ {"partb8x8", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_B8X8 }, INT_MIN, INT_MAX, V|E, "partitions"}, {"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), FF_OPT_TYPE_INT, {.dbl = 6 }, 0, INT_MAX, V|E}, {"mv0_threshold", NULL, OFFSET(mv0_threshold), FF_OPT_TYPE_INT, {.dbl = 256 }, 0, INT_MAX, V|E}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_VLC }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, {.dbl = 40 }, 1, INT_MAX, V|E}, {"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, {.dbl = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E}, {"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 889e945082..928513f002 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -86,5 +86,8 @@ #ifndef FF_API_X264_GLOBAL_OPTS #define FF_API_X264_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_MPEGVIDEO_GLOBAL_OPTS +#define FF_API_MPEGVIDEO_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 2c5e1efc093084f1cb4e55b8c06c267801828965 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 08:34:05 +0200 Subject: [PATCH 16/31] mpeg12enc: add drop_frame_timecode private option. Deprecate CODEC_FLAG2_DROP_FRAME_TIMECODE --- libavcodec/avcodec.h | 2 ++ libavcodec/mpeg12enc.c | 12 +++++++++--- libavcodec/mpegvideo.h | 1 + libavcodec/options.c | 2 ++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 408438e62f..5791911a2f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -620,7 +620,9 @@ typedef struct RcOverride{ #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. #endif #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. +#endif #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index eca57d0df7..dd433215f3 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -142,6 +142,11 @@ static av_cold int encode_init(AVCodecContext *avctx) if(MPV_encode_init(avctx) < 0) return -1; +#if FF_API_MPEGVIDEO_GLOBAL_OPTS + if (avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) + s->drop_frame_timecode = 1; +#endif + if(find_frame_rate_index(s) < 0){ if(s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){ av_log(avctx, AV_LOG_ERROR, "MPEG1/2 does not support %d/%d fps\n", avctx->time_base.den, avctx->time_base.num); @@ -174,7 +179,7 @@ static av_cold int encode_init(AVCodecContext *avctx) } } - if((avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) && s->frame_rate_index != 4){ + if (s->drop_frame_timecode && s->frame_rate_index != 4) { av_log(avctx, AV_LOG_ERROR, "Drop frame time code only allowed with 1001/30000 fps\n"); return -1; } @@ -285,14 +290,14 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) } put_header(s, GOP_START_CODE); - put_bits(&s->pb, 1, !!(s->avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE)); /* drop frame flag */ + put_bits(&s->pb, 1, s->drop_frame_timecode); /* drop frame flag */ /* time code : we must convert from the real frame rate to a fake mpeg frame rate in case of low frame rate */ fps = (framerate.num + framerate.den/2)/ framerate.den; time_code = s->current_picture_ptr->f.coded_picture_number + s->avctx->timecode_frame_start; s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number; - if (s->avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) { + if (s->drop_frame_timecode) { /* only works for NTSC 29.97 */ int d = time_code / 17982; int m = time_code % 17982; @@ -931,6 +936,7 @@ static void mpeg1_encode_block(MpegEncContext *s, #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM static const AVOption options[] = { { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, { NULL }, }; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 0790b075f0..34069c69bb 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -644,6 +644,7 @@ typedef struct MpegEncContext { int interlaced_dct; int first_slice; int first_field; ///< is 1 for the first field of a field picture 0 otherwise + int drop_frame_timecode; ///< timecode is in drop frame format. /* RTP specific */ int rtp_mode; diff --git a/libavcodec/options.c b/libavcodec/options.c index 19a4133a78..5231cb4c53 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -421,7 +421,9 @@ static const AVOption options[]={ {"max_partition_order", "deprecated, use flac-specific options", OFFSET(max_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, #endif {"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT64, {.dbl = 0 }, 0, INT64_MAX, V|E}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NON_LINEAR_QUANT }, INT_MIN, INT_MAX, V|E, "flags2"}, #if FF_API_REQUEST_CHANNELS {"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D}, From 88262ca87df1054209ef6db255b521e412fd78fc Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 09:57:36 +0200 Subject: [PATCH 17/31] mpeg2enc: add 'non_linear_quant' private option Deprecate CODEC_FLAG2_NON_LINEAR_QUANT --- libavcodec/avcodec.h | 2 ++ libavcodec/mpeg12enc.c | 15 ++++++++++++--- libavcodec/mpegvideo_enc.c | 4 +++- libavcodec/options.c | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 5791911a2f..f8a8006c89 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -625,7 +625,9 @@ typedef struct RcOverride{ #endif #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. +#endif #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. diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index dd433215f3..30afa2eb46 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -934,9 +934,18 @@ static void mpeg1_encode_block(MpegEncContext *s, #define OFFSET(x) offsetof(MpegEncContext, x) #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM -static const AVOption options[] = { - { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, +#define COMMON_OPTS\ + { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },\ { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, + +static const AVOption mpeg1_options[] = { + COMMON_OPTS + { NULL }, +}; + +static const AVOption mpeg2_options[] = { + COMMON_OPTS + { "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; @@ -944,7 +953,7 @@ static const AVOption options[] = { static const AVClass mpeg## x ##_class = {\ .class_name = "mpeg" #x "video encoder",\ .item_name = av_default_item_name,\ - .option = options,\ + .option = mpeg## x ##_options,\ .version = LIBAVUTIL_VERSION_INT,\ }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 42fd6609c9..1f8f9f49d6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -338,8 +338,8 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN); #if FF_API_MPEGVIDEO_GLOBAL_OPTS s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC); -#endif s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT); +#endif if(avctx->rc_max_rate && !avctx->rc_buffer_size){ av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n"); @@ -463,10 +463,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) } if(s->q_scale_type == 1){ +#if FF_API_MPEGVIDEO_GLOBAL_OPTS if(s->codec_id != CODEC_ID_MPEG2VIDEO){ av_log(avctx, AV_LOG_ERROR, "non linear quant is only available for mpeg2\n"); return -1; } +#endif if(avctx->qmax > 12){ av_log(avctx, AV_LOG_ERROR, "non linear quant only supports qmax <= 12 currently\n"); return -1; diff --git a/libavcodec/options.c b/libavcodec/options.c index 5231cb4c53..b9918819b1 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -423,8 +423,8 @@ static const AVOption options[]={ {"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT64, {.dbl = 0 }, 0, INT64_MAX, V|E}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"}, -#endif {"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NON_LINEAR_QUANT }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif #if FF_API_REQUEST_CHANNELS {"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D}, #endif From a7cec3a09407f7cf494d84549665d242ad31fc4e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:09:09 +0200 Subject: [PATCH 18/31] libmp3lame: add 'reservoir' private option. Deprecate CODEC_FLAG2_BIT_RESERVOIR --- libavcodec/avcodec.h | 2 ++ libavcodec/libmp3lame.c | 23 ++++++++++++++++++++++- libavcodec/options.c | 2 ++ libavcodec/version.h | 3 +++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index f8a8006c89..64226835c2 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -628,7 +628,9 @@ typedef struct RcOverride{ #if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. #endif +#if FF_API_LAME_GLOBAL_OPTS #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible +#endif #define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) #define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. #if FF_API_X264_GLOBAL_OPTS diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 2eeb97d827..b46ce42fb0 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -25,16 +25,20 @@ */ #include "libavutil/intreadwrite.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "mpegaudio.h" #include #define BUFFER_SIZE (7200 + 2*MPA_FRAME_SIZE + MPA_FRAME_SIZE/4) typedef struct Mp3AudioContext { + AVClass *class; lame_global_flags *gfp; int stereo; uint8_t buffer[BUFFER_SIZE]; int buffer_index; + int reservoir; } Mp3AudioContext; static av_cold int MP3lame_encode_init(AVCodecContext *avctx) @@ -64,7 +68,10 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx) lame_set_VBR_quality(s->gfp, avctx->global_quality/(float)FF_QP2LAMBDA); } lame_set_bWriteVbrTag(s->gfp,0); - lame_set_disable_reservoir(s->gfp, avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR ? 0 : 1); +#if FF_API_LAME_GLOBAL_OPTIONS + s->reservoir = avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR; +#endif + lame_set_disable_reservoir(s->gfp, !s->reservoir); if (lame_init_params(s->gfp) < 0) goto err_close; @@ -213,6 +220,19 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx) return 0; } +#define OFFSET(x) offsetof(Mp3AudioContext, x) +#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "reservoir", "Use bit reservoir.", OFFSET(reservoir), FF_OPT_TYPE_INT, { 1 }, 0, 1, AE }, + { NULL }, +}; + +static const AVClass libmp3lame_class = { + .class_name = "libmp3lame encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; AVCodec ff_libmp3lame_encoder = { .name = "libmp3lame", @@ -226,4 +246,5 @@ AVCodec ff_libmp3lame_encoder = { .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .supported_samplerates= sSampleRates, .long_name= NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"), + .priv_class = &libmp3lame_class, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index b9918819b1..1344a89c6a 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -431,7 +431,9 @@ static const AVOption options[]={ #if FF_API_DRC_SCALE {"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 0.0, 1.0, A|D}, #endif +#if FF_API_LAME_GLOBAL_OPTS {"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"}, +#endif {"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E, "flags2"}, {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 928513f002..0de224bda4 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -89,5 +89,8 @@ #ifndef FF_API_MPEGVIDEO_GLOBAL_OPTS #define FF_API_MPEGVIDEO_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_LAME_GLOBAL_OPTS +#define FF_API_LAME_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 38934f19fe624270fabf32a411d84f1fee3e0aae Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 19/31] libx264: add 'psy' private option. Deprecate CODEC_FLAG2_PSY --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 7 +++++-- libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 64226835c2..b0317d5a2e 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -632,8 +632,8 @@ typedef struct RcOverride{ #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible #endif #define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) -#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. #if FF_API_X264_GLOBAL_OPTS +#define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. #define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. #define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. #endif diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index e653de45ab..2ea6614028 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -47,6 +47,7 @@ typedef struct X264Context { int aq_mode; float aq_strength; char *psy_rd; + int psy; int rc_lookahead; int weightp; int weightb; @@ -243,8 +244,6 @@ 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.analyse.b_psy = avctx->flags2 & CODEC_FLAG2_PSY; - x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; @@ -331,6 +330,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT; x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; + x4->params.analyse.b_psy = avctx->flags2 & CODEC_FLAG2_PSY; #endif if (x4->aq_mode >= 0) @@ -341,6 +341,8 @@ static av_cold int X264_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Error parsing option 'psy-rd' with value '%s'.\n", x4->psy_rd); return AVERROR(EINVAL); } + if (x4->psy >= 0) + x4->params.analyse.b_psy = x4->psy; if (x4->rc_lookahead >= 0) x4->params.rc.i_lookahead = x4->rc_lookahead; if (x4->weightp >= 0) @@ -440,6 +442,7 @@ static const AVOption options[] = { { "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 : 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 }, diff --git a/libavcodec/options.c b/libavcodec/options.c index 1344a89c6a..e7e79831d8 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -446,8 +446,8 @@ static const AVOption options[]={ {"colorspace", NULL, OFFSET(colorspace), FF_OPT_TYPE_INT, {.dbl = AVCOL_SPC_UNSPECIFIED }, 1, AVCOL_SPC_NB-1, V|E|D}, {"color_range", NULL, OFFSET(color_range), FF_OPT_TYPE_INT, {.dbl = AVCOL_RANGE_UNSPECIFIED }, 0, AVCOL_RANGE_NB-1, V|E|D}, {"chroma_sample_location", NULL, OFFSET(chroma_sample_location), FF_OPT_TYPE_INT, {.dbl = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, V|E|D}, -{"psy", "use psycho visual optimization", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_PSY }, INT_MIN, INT_MAX, V|E, "flags2"}, #if FF_API_X264_GLOBAL_OPTS +{"psy", "use psycho visual optimization", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_PSY }, INT_MIN, INT_MAX, V|E, "flags2"}, {"psy_rd", "specify psycho visual strength", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, {"psy_trellis", "specify psycho visual trellis", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, V|E}, {"aq_mode", "specify aq method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, INT_MAX, V|E}, From 0dc5e12f1e16d22aca861d42de9c4fd400df46ae Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 20/31] libx264: add 'mbtree' private option. Deprecate CODEC_FLAG2_MBTREE --- libavcodec/avcodec.h | 2 +- libavcodec/libx264.c | 6 +++++- libavcodec/options.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index b0317d5a2e..f59b850c35 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -631,8 +631,8 @@ typedef struct RcOverride{ #if FF_API_LAME_GLOBAL_OPTS #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible #endif -#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) #if FF_API_X264_GLOBAL_OPTS +#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. #define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 2ea6614028..8614ec5cd3 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -58,6 +58,7 @@ typedef struct X264Context { int dct8x8; int fast_pskip; int aud; + int mbtree; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -304,7 +305,6 @@ static av_cold int X264_init(AVCodecContext *avctx) (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; } - x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); x4->params.rc.f_pb_factor = avctx->b_quant_factor; x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; @@ -331,6 +331,7 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP; x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD; x4->params.analyse.b_psy = avctx->flags2 & CODEC_FLAG2_PSY; + x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); #endif if (x4->aq_mode >= 0) @@ -364,6 +365,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.b_fast_pskip = x4->fast_pskip; if (x4->aud >= 0) x4->params.b_aud = x4->aud; + if (x4->mbtree >= 0) + x4->params.rc.b_mb_tree = x4->mbtree; if (x4->fastfirstpass) x264_param_apply_fastfirstpass(&x4->params); @@ -460,6 +463,7 @@ static const AVOption options[] = { { "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}, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index e7e79831d8..4ad86e6c15 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -434,7 +434,9 @@ static const AVOption options[]={ #if FF_API_LAME_GLOBAL_OPTS {"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"}, #endif +#if FF_API_X264_GLOBAL_OPTS {"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E, "flags2"}, +#endif {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"}, {"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|D, "request_channel_layout"}, From 0cc06b9e23bc798b1af3302d095db23f000a97e6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 21/31] snow: add 'memc_only' private option. Deprecate CODEC_FLAG2_MEMC_ONLY --- libavcodec/avcodec.h | 2 ++ libavcodec/snow.c | 22 ++++++++++++++++++++-- libavcodec/version.h | 3 +++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index f59b850c35..2059fd7f9b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -619,7 +619,9 @@ typedef struct RcOverride{ #if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. #endif +#if FF_API_SNOW_GLOBAL_OPTS #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). +#endif #if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. #endif diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 2af5d234d7..974b7c350d 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -19,6 +19,8 @@ */ #include "libavutil/intmath.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "dsputil.h" #include "dwt.h" @@ -199,7 +201,7 @@ typedef struct Plane{ }Plane; typedef struct SnowContext{ - + AVClass *class; AVCodecContext *avctx; RangeCoder c; DSPContext dsp; @@ -252,6 +254,7 @@ typedef struct SnowContext{ int me_cache[ME_CACHE_SIZE]; int me_cache_generation; slice_buffer sb; + int memc_only; MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX) @@ -3518,7 +3521,7 @@ redo_frame: int x, y; // int bits= put_bits_count(&s->c.pb); - if(!(avctx->flags2 & CODEC_FLAG2_MEMC_ONLY)){ + if (!s->memc_only) { //FIXME optimize if(pict->data[plane_index]) //FIXME gray hack for(y=0; y ref, P frame -> ME+MC).", OFFSET(memc_only), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { NULL }, +}; + +static const AVClass snowenc_class = { + .class_name = "snow encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_snow_encoder = { .name = "snow", .type = AVMEDIA_TYPE_VIDEO, @@ -3685,5 +3702,6 @@ AVCodec ff_snow_encoder = { .encode = encode_frame, .close = encode_end, .long_name = NULL_IF_CONFIG_SMALL("Snow"), + .priv_class = &snowenc_class, }; #endif diff --git a/libavcodec/version.h b/libavcodec/version.h index 0de224bda4..7abd993b98 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -92,5 +92,8 @@ #ifndef FF_API_LAME_GLOBAL_OPTS #define FF_API_LAME_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_SNOW_GLOBAL_OPTS +#define FF_API_SNOW_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 4623420d84e97d141c20078cfa09c7568f693bd5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 22/31] mpeg4enc: add 'data_partitioning' private option. Deprecate CODEC_FLAG_PART --- libavcodec/avcodec.h | 2 ++ libavcodec/mpeg4videoenc.c | 17 +++++++++++++++++ libavcodec/mpegvideo_enc.c | 7 ++++++- libavcodec/options.c | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2059fd7f9b..6cee81e460 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -570,7 +570,9 @@ typedef struct RcOverride{ #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC. #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. +#endif /** * The parent program guarantees that the input for B-frames containing * streams is not written to for at least s->max_b_frames+1 frames, if diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 900903779c..ad3e604df0 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/log.h" +#include "libavutil/opt.h" #include "mpegvideo.h" #include "h263.h" #include "mpeg4video.h" @@ -1274,6 +1276,20 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) put_bits(&s->pb, 1, 0); /* no HEC */ } +#define OFFSET(x) offsetof(MpegEncContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { NULL }, +}; + +static const AVClass mpeg4enc_class = { + .class_name = "MPEG4 encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_mpeg4_encoder = { .name = "mpeg4", .type = AVMEDIA_TYPE_VIDEO, @@ -1285,4 +1301,5 @@ AVCodec ff_mpeg4_encoder = { .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), + .priv_class = &mpeg4enc_class, }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 1f8f9f49d6..47f431c1a9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -305,7 +305,10 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->luma_elim_threshold = avctx->luma_elim_threshold; s->chroma_elim_threshold= avctx->chroma_elim_threshold; s->strict_std_compliance= avctx->strict_std_compliance; - s->data_partitioning= avctx->flags & CODEC_FLAG_PART; +#if FF_API_MPEGVIDEO_GLOBAL_OPTS + if (avctx->flags & CODEC_FLAG_PART) + s->data_partitioning = 1; +#endif s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; s->mpeg_quant= avctx->mpeg_quant; s->rtp_mode= !!avctx->rtp_payload_size; @@ -402,10 +405,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) return -1; } +#if FF_API_MPEGVIDEO_GLOBAL_OPTS if(s->data_partitioning && s->codec_id != CODEC_ID_MPEG4){ av_log(avctx, AV_LOG_ERROR, "data partitioning not supported by codec\n"); return -1; } +#endif if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){ av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n"); diff --git a/libavcodec/options.c b/libavcodec/options.c index 4ad86e6c15..7828dc9473 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -81,7 +81,9 @@ static const AVOption options[]={ {"qscale", "use fixed qscale", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, {"gmc", "use gmc", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GMC }, INT_MIN, INT_MAX, V|E, "flags"}, {"mv0", "always try a mb with mv=<0,0>", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_MV0 }, INT_MIN, INT_MAX, V|E, "flags"}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"part", "use data partitioning", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PART }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"input_preserved", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"}, {"pass1", "use internal 2pass ratecontrol in first pass mode", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, {"pass2", "use internal 2pass ratecontrol in second pass mode", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, From 1f0c7020a1f08a7cbec2d629759ca33ea92bd89d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 23/31] mjpegdec: add 'extern_huff' private option. Deprecate CODEC_FLAG_EXTERN_HUFF --- libavcodec/avcodec.h | 2 ++ libavcodec/mjpegdec.c | 20 ++++++++++++++++++++ libavcodec/mjpegdec.h | 5 +++++ libavcodec/options.c | 2 ++ libavcodec/version.h | 3 +++ 5 files changed, 32 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 6cee81e460..f65c14d9f8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -581,7 +581,9 @@ typedef struct RcOverride{ #define CODEC_FLAG_INPUT_PRESERVED 0x0100 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. +#if FF_API_MJPEG_GLOBAL_OPTS #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). +#endif #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index b9db777fe1..168cc0bece 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -34,6 +34,7 @@ #include #include "libavutil/imgutils.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "dsputil.h" #include "mjpeg.h" @@ -96,7 +97,11 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) build_basic_mjpeg_vlc(s); +#if FF_API_MJPEG_GLOBAL_OPTS if (avctx->flags & CODEC_FLAG_EXTERN_HUFF) + s->extern_huff = 1; +#endif + if (s->extern_huff) { av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n"); init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8); @@ -1597,6 +1602,20 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx) return 0; } +#define OFFSET(x) offsetof(MJpegDecodeContext, x) +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] = { + { "extern_huff", "Use external huffman table.", OFFSET(extern_huff), FF_OPT_TYPE_INT, { 0 }, 0, 1, VD }, + { NULL }, +}; + +static const AVClass mjpegdec_class = { + .class_name = "MJPEG decoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_mjpeg_decoder = { .name = "mjpeg", .type = AVMEDIA_TYPE_VIDEO, @@ -1608,6 +1627,7 @@ AVCodec ff_mjpeg_decoder = { .capabilities = CODEC_CAP_DR1, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"), + .priv_class = &mjpegdec_class, }; AVCodec ff_thp_decoder = { diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h index 52c256ee2f..bfa987d3c5 100644 --- a/libavcodec/mjpegdec.h +++ b/libavcodec/mjpegdec.h @@ -29,6 +29,8 @@ #ifndef AVCODEC_MJPEGDEC_H #define AVCODEC_MJPEGDEC_H +#include "libavutil/log.h" + #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" @@ -36,6 +38,7 @@ #define MAX_COMPONENTS 4 typedef struct MJpegDecodeContext { + AVClass *class; AVCodecContext *avctx; GetBitContext gb; @@ -106,6 +109,8 @@ typedef struct MJpegDecodeContext { uint16_t (*ljpeg_buffer)[4]; unsigned int ljpeg_buffer_size; + + int extern_huff; } MJpegDecodeContext; int ff_mjpeg_decode_init(AVCodecContext *avctx); diff --git a/libavcodec/options.c b/libavcodec/options.c index 7828dc9473..843064fcf5 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -87,7 +87,9 @@ static const AVOption options[]={ {"input_preserved", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"}, {"pass1", "use internal 2pass ratecontrol in first pass mode", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, {"pass2", "use internal 2pass ratecontrol in second pass mode", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, +#if FF_API_MJPEG_GLOBAL_OPTS {"extern_huff", "use external huffman table (for mjpeg)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_EXTERN_HUFF }, INT_MIN, INT_MAX, 0, "flags"}, +#endif {"gray", "only decode/encode grayscale", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, {"emu_edge", "don't draw edges", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_EMU_EDGE }, INT_MIN, INT_MAX, 0, "flags"}, {"psnr", "error[?] variables will be set during encoding", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 7abd993b98..d4c358e182 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -95,5 +95,8 @@ #ifndef FF_API_SNOW_GLOBAL_OPTS #define FF_API_SNOW_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_MJPEG_GLOBAL_OPTS +#define FF_API_MJPEG_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 0e5d37309f54f4377ec1f1a7ca41ea06d4ade923 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 24/31] mpeg12enc/mpeg4videoenc: add 'alternate_scan' private option. Deprecate CODEC_FLAG_ALT_SCAN --- libavcodec/avcodec.h | 2 ++ libavcodec/mpeg12enc.c | 1 + libavcodec/mpeg4videoenc.c | 1 + libavcodec/mpegvideo_enc.c | 2 +- libavcodec/options.c | 2 ++ 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index f65c14d9f8..ce862b66c0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -592,7 +592,9 @@ typedef struct RcOverride{ #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. +#endif #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). /* Fx : Flag for h263+ extra options */ diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 30afa2eb46..a612501c90 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -946,6 +946,7 @@ static const AVOption mpeg1_options[] = { static const AVOption mpeg2_options[] = { COMMON_OPTS { "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index ad3e604df0..b86d505b79 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1280,6 +1280,7 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 47f431c1a9..042b91d6bc 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -338,8 +338,8 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->obmc= !!(s->flags & CODEC_FLAG_OBMC); s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER); - s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN); #if FF_API_MPEGVIDEO_GLOBAL_OPTS + s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN); s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC); s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT); #endif diff --git a/libavcodec/options.c b/libavcodec/options.c index 843064fcf5..74ff07c07a 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -97,7 +97,9 @@ static const AVOption options[]={ {"naq", "normalize adaptive quantization", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_NORMALIZE_AQP }, INT_MIN, INT_MAX, V|E, "flags"}, {"ildct", "use interlaced dct", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"}, {"low_delay", "force low delay", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"alt", "enable alternate scantable (mpeg2/mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_ALT_SCAN }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"global_header", "place global headers in extradata instead of every keyframe", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"}, {"bitexact", "use only bitexact stuff (except (i)dct)", 0, FF_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, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"}, From 9bb2d1a3f0ea3595fafad32d6ee1261506f57bb4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 25/31] h263p encoder: add 'umv' private option. Deprecate CODEC_FLAG_H263P_UMV --- libavcodec/avcodec.h | 2 ++ libavcodec/mpegvideo_enc.c | 20 +++++++++++++++++++- libavcodec/options.c | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ce862b66c0..bc01f4559c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -599,7 +599,9 @@ typedef struct RcOverride{ #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). /* Fx : Flag for h263+ extra options */ #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector +#endif #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_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 042b91d6bc..98e015fb24 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -29,6 +29,7 @@ #include "libavutil/intmath.h" #include "libavutil/mathematics.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" @@ -605,7 +606,10 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->out_format = FMT_H263; s->h263_plus = 1; /* Fx */ - s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0; +#if FF_API_MPEGVIDEO_GLOBAL_OPTS + if (avctx->flags & CODEC_FLAG_H263P_UMV) + s->umvplus = 1; +#endif s->h263_aic= (avctx->flags & CODEC_FLAG_AC_PRED) ? 1:0; s->modified_quant= s->h263_aic; s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0; @@ -3790,6 +3794,19 @@ AVCodec ff_h263_encoder = { .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"), }; +#define OFFSET(x) offsetof(MpegEncContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { NULL }, +}; +static const AVClass h263p_class = { + .class_name = "H.263p encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_h263p_encoder = { .name = "h263p", .type = AVMEDIA_TYPE_VIDEO, @@ -3801,6 +3818,7 @@ AVCodec ff_h263p_encoder = { .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"), + .priv_class = &h263p_class, }; AVCodec ff_msmpeg4v2_encoder = { diff --git a/libavcodec/options.c b/libavcodec/options.c index 74ff07c07a..23ff7e7f16 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -103,7 +103,9 @@ static const AVOption options[]={ {"global_header", "place global headers in extradata instead of every keyframe", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"}, {"bitexact", "use only bitexact stuff (except (i)dct)", 0, FF_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, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"umv", "use unlimited motion vectors", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_UMV }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"cbp", "use rate distortion optimization for cbp", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, {"qprd", "use rate distortion optimization for qp selection", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, {"aiv", "h263 alternative inter vlc", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_AIV }, INT_MIN, INT_MAX, V|E, "flags"}, From e3922d1110772baee10def844367f961c8c728d5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 26/31] h263p encoder: add 'aiv' private option. Deprecate CODEC_FLAG_H263P_AIV --- libavcodec/avcodec.h | 2 ++ libavcodec/mpegvideo_enc.c | 4 +++- libavcodec/options.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index bc01f4559c..993ed785e8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -604,7 +604,9 @@ typedef struct RcOverride{ #endif #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. +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC +#endif #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 98e015fb24..447431dcf4 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -609,10 +609,11 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) #if FF_API_MPEGVIDEO_GLOBAL_OPTS if (avctx->flags & CODEC_FLAG_H263P_UMV) s->umvplus = 1; + if (avctx->flags & CODEC_FLAG_H263P_AIV) + s->alt_inter_vlc = 1; #endif s->h263_aic= (avctx->flags & CODEC_FLAG_AC_PRED) ? 1:0; s->modified_quant= s->h263_aic; - s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0; s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0; s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0; s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus; @@ -3798,6 +3799,7 @@ AVCodec ff_h263_encoder = { #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; static const AVClass h263p_class = { diff --git a/libavcodec/options.c b/libavcodec/options.c index 23ff7e7f16..fb1fb17f9a 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -108,7 +108,9 @@ static const AVOption options[]={ #endif {"cbp", "use rate distortion optimization for cbp", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, {"qprd", "use rate distortion optimization for qp selection", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"aiv", "h263 alternative inter vlc", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_AIV }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_SLICE_STRUCT }, INT_MIN, INT_MAX, V|E, "flags"}, {"ilme", "interlaced motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, {"scan_offset", "will reserve space for svcd scan offset user data", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_SVCD_SCAN_OFFSET }, INT_MIN, INT_MAX, V|E, "flags"}, From 0d904de89ded7502c7a18a12e27c3e6dff5d1fdf Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 27/31] h263/p encoder: add 'obmc' private option. Deprecate CODEC_FLAG_OBMC --- libavcodec/avcodec.h | 2 +- libavcodec/mpegvideo_enc.c | 28 +++++++++++++++++++++------- libavcodec/options.c | 2 ++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 993ed785e8..c22c98f590 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -606,8 +606,8 @@ typedef struct RcOverride{ #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. #if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC -#endif #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC +#endif #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 447431dcf4..9623bb8265 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -337,12 +337,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) || (s->flags&CODEC_FLAG_QP_RD)) && !s->fixed_qscale; - s->obmc= !!(s->flags & CODEC_FLAG_OBMC); s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER); #if FF_API_MPEGVIDEO_GLOBAL_OPTS s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN); s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC); s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT); + s->obmc= !!(s->flags & CODEC_FLAG_OBMC); #endif if(avctx->rc_max_rate && !avctx->rc_buffer_size){ @@ -396,10 +396,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) return -1; } +#if FF_API_MPEGVIDEO_GLOBAL_OPTS if(s->obmc && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){ av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n"); return -1; } +#endif if(s->quarter_sample && s->codec_id != CODEC_ID_MPEG4){ av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); @@ -598,7 +600,6 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) return -1; } s->out_format = FMT_H263; - s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0; avctx->delay=0; s->low_delay=1; break; @@ -614,7 +615,6 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) #endif s->h263_aic= (avctx->flags & CODEC_FLAG_AC_PRED) ? 1:0; s->modified_quant= s->h263_aic; - s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0; s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0; s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus; s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0; @@ -3783,6 +3783,20 @@ int dct_quantize_c(MpegEncContext *s, return last_non_zero; } +#define OFFSET(x) offsetof(MpegEncContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption h263_options[] = { + { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { NULL }, +}; + +static const AVClass h263_class = { + .class_name = "H.263 encoder", + .item_name = av_default_item_name, + .option = h263_options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_h263_encoder = { .name = "h263", .type = AVMEDIA_TYPE_VIDEO, @@ -3793,19 +3807,19 @@ AVCodec ff_h263_encoder = { .close = MPV_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"), + .priv_class = &h263_class, }; -#define OFFSET(x) offsetof(MpegEncContext, x) -#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM -static const AVOption options[] = { +static const AVOption h263p_options[] = { { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; static const AVClass h263p_class = { .class_name = "H.263p encoder", .item_name = av_default_item_name, - .option = options, + .option = h263p_options, .version = LIBAVUTIL_VERSION_INT, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index fb1fb17f9a..8ac3d959fe 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -75,7 +75,9 @@ static const AVOption options[]={ {"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E}, {"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"}, {"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_OBMC }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"qpel", "use 1/4 pel motion compensation", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"}, {"loop", "use loop filter", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"}, {"qscale", "use fixed qscale", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, From 4bcee8e7f826b79206da660cd66ad91e497d7184 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 28/31] h263/p encoder: add 'structured_slices' private option. Deprecate CODEC_FLAG_H263P_SLICE_STRUCT --- libavcodec/avcodec.h | 2 ++ libavcodec/mpegvideo_enc.c | 5 ++++- libavcodec/options.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c22c98f590..950e32f238 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -609,7 +609,9 @@ typedef struct RcOverride{ #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC #endif #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 +#endif #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. #define CODEC_FLAG_CLOSED_GOP 0x80000000 diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 9623bb8265..809ede1d9a 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -612,12 +612,13 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) s->umvplus = 1; if (avctx->flags & CODEC_FLAG_H263P_AIV) s->alt_inter_vlc = 1; + if (avctx->flags & CODEC_FLAG_H263P_SLICE_STRUCT) + s->h263_slice_structured = 1; #endif s->h263_aic= (avctx->flags & CODEC_FLAG_AC_PRED) ? 1:0; s->modified_quant= s->h263_aic; s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0; s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus; - s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0; /* /Fx */ /* These are just to be sure */ @@ -3787,6 +3788,7 @@ int dct_quantize_c(MpegEncContext *s, #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption h263_options[] = { { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "structured_slices","Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, { NULL }, }; @@ -3814,6 +3816,7 @@ static const AVOption h263p_options[] = { { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, { NULL }, }; static const AVClass h263p_class = { diff --git a/libavcodec/options.c b/libavcodec/options.c index 8ac3d959fe..5035d9f32f 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -112,8 +112,8 @@ static const AVOption options[]={ {"qprd", "use rate distortion optimization for qp selection", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS {"aiv", "h263 alternative inter vlc", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_AIV }, INT_MIN, INT_MAX, V|E, "flags"}, -#endif {"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_SLICE_STRUCT }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"ilme", "interlaced motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, {"scan_offset", "will reserve space for svcd scan offset user data", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_SVCD_SCAN_OFFSET }, INT_MIN, INT_MAX, V|E, "flags"}, {"cgop", "closed gop", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"}, From aed790070486b1b01b48106310d9d0ca1730e459 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 10:16:14 +0200 Subject: [PATCH 29/31] mpeg12: add 'scan_offset' private option. Deprecate CODEC_FLAG_SVCD_SCAN_OFFSET --- libavcodec/avcodec.h | 2 ++ libavcodec/mpeg12enc.c | 7 +++++-- libavcodec/mpegvideo.h | 1 + libavcodec/options.c | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 950e32f238..16f0b8a561 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -613,7 +613,9 @@ typedef struct RcOverride{ #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 #endif #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation +#if FF_API_MPEGVIDEO_GLOBAL_OPTS #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. +#endif #define CODEC_FLAG_CLOSED_GOP 0x80000000 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index a612501c90..79c46beef9 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -145,6 +145,8 @@ static av_cold int encode_init(AVCodecContext *avctx) #if FF_API_MPEGVIDEO_GLOBAL_OPTS if (avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) s->drop_frame_timecode = 1; + if (avctx->flags & CODEC_FLAG_SVCD_SCAN_OFFSET) + s->scan_offset = 1; #endif if(find_frame_rate_index(s) < 0){ @@ -420,7 +422,7 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) put_bits(&s->pb, 1, s->progressive_frame); put_bits(&s->pb, 1, 0); //composite_display_flag } - if(s->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){ + if (s->scan_offset) { int i; put_header(s, USER_START_CODE); @@ -936,7 +938,8 @@ static void mpeg1_encode_block(MpegEncContext *s, #define VE AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM #define COMMON_OPTS\ { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },\ - { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, + { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, \ + { "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, static const AVOption mpeg1_options[] = { COMMON_OPTS diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 34069c69bb..923d46c884 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -645,6 +645,7 @@ typedef struct MpegEncContext { int first_slice; int first_field; ///< is 1 for the first field of a field picture 0 otherwise int drop_frame_timecode; ///< timecode is in drop frame format. + int scan_offset; ///< reserve space for SVCD scan offset user data. /* RTP specific */ int rtp_mode; diff --git a/libavcodec/options.c b/libavcodec/options.c index 5035d9f32f..a715dfafcb 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -115,7 +115,9 @@ static const AVOption options[]={ {"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_SLICE_STRUCT }, INT_MIN, INT_MAX, V|E, "flags"}, #endif {"ilme", "interlaced motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, +#if FF_API_MPEGVIDEO_GLOBAL_OPTS {"scan_offset", "will reserve space for svcd scan offset user data", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_SVCD_SCAN_OFFSET }, INT_MIN, INT_MAX, V|E, "flags"}, +#endif {"cgop", "closed gop", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"}, {"fast", "allow non spec compliant speedup tricks", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"}, {"sgop", "strictly enforce gop size", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"}, From f013cb81182a7030018183c32f8e7224496b6069 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 27 Aug 2011 13:33:10 +0200 Subject: [PATCH 30/31] lavc: cosmetics, group deprecated codec flags --- libavcodec/avcodec.h | 72 +++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 16f0b8a561..73a68b9740 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -570,9 +570,6 @@ typedef struct RcOverride{ #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC. #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. -#endif /** * The parent program guarantees that the input for B-frames containing * streams is not written to for at least s->max_b_frames+1 frames, if @@ -581,9 +578,6 @@ typedef struct RcOverride{ #define CODEC_FLAG_INPUT_PRESERVED 0x0100 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. -#if FF_API_MJPEG_GLOBAL_OPTS -#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). -#endif #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. @@ -592,35 +586,41 @@ typedef struct RcOverride{ #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. -#endif #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). /* Fx : Flag for h263+ extra options */ #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector -#endif #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. -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC -#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC -#endif #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 -#endif #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. -#endif #define CODEC_FLAG_CLOSED_GOP 0x80000000 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. #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. +#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping +#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. +/** + * @defgroup deprecated_flags Deprecated codec flags + * Use corresponding private codec options instead. + * @{ + */ +#if FF_API_MPEGVIDEO_GLOBAL_OPTS +#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC +#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC +#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. +#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. +#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector +#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 +#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. +#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. +#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. +#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. +#endif +#if FF_API_MJPEG_GLOBAL_OPTS +#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). +#endif #if FF_API_X264_GLOBAL_OPTS #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames @@ -629,30 +629,20 @@ typedef struct RcOverride{ #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization -#endif -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. -#endif -#if FF_API_SNOW_GLOBAL_OPTS -#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). -#endif -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. -#endif -#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping -#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. -#if FF_API_MPEGVIDEO_GLOBAL_OPTS -#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. -#endif -#if FF_API_LAME_GLOBAL_OPTS -#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible -#endif -#if FF_API_X264_GLOBAL_OPTS #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. #define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. #endif +#if FF_API_SNOW_GLOBAL_OPTS +#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). +#endif +#if FF_API_LAME_GLOBAL_OPTS +#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible +#endif +/** + * @} + */ /* Unsupported options : * Syntax Arithmetic coding (SAC) From 5d06f15235c2fa1b6ed2c5af3bc0e3750df4291c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 31 Aug 2011 14:04:02 +0200 Subject: [PATCH 31/31] libx264: set default thread count to 0 (auto) --- libavcodec/libx264.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 8614ec5cd3..bff29d892c 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -476,6 +476,7 @@ static const AVClass class = { static const AVCodecDefault x264_defaults[] = { { "b", "0" }, + { "threads", "0" }, { NULL }, };