diff options
-rw-r--r-- | libavcodec/alacenc.c | 27 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 14 | ||||
-rw-r--r-- | libavcodec/flacenc.c | 33 | ||||
-rw-r--r-- | libavcodec/options_table.h | 2 |
4 files changed, 57 insertions, 19 deletions
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 8a94f81..4857338 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/opt.h" + #include "avcodec.h" #include "put_bits.h" #include "internal.h" @@ -57,6 +59,7 @@ typedef struct AlacLPCContext { } AlacLPCContext; typedef struct AlacEncodeContext { + AVCodecContext *avctx; int frame_size; /**< current frame size */ int verbatim; /**< current frame verbatim mode flag */ int compression_level; @@ -73,7 +76,6 @@ typedef struct AlacEncodeContext { RiceContext rc; AlacLPCContext lpc[2]; LPCContext lpc_ctx; - AVCodecContext *avctx; } AlacEncodeContext; @@ -544,7 +546,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) AV_WB8(alac_extradata+20, s->rc.k_modifier); } - s->min_prediction_order = DEFAULT_MIN_PRED_ORDER; +#if FF_API_PRIVATE_OPT +FF_DISABLE_DEPRECATION_WARNINGS if (avctx->min_prediction_order >= 0) { if (avctx->min_prediction_order < MIN_LPC_ORDER || avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) { @@ -557,7 +560,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) s->min_prediction_order = avctx->min_prediction_order; } - s->max_prediction_order = DEFAULT_MAX_PRED_ORDER; if (avctx->max_prediction_order >= 0) { if (avctx->max_prediction_order < MIN_LPC_ORDER || avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) { @@ -569,6 +571,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) s->max_prediction_order = avctx->max_prediction_order; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (s->max_prediction_order < s->min_prediction_order) { av_log(avctx, AV_LOG_ERROR, @@ -634,12 +638,29 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return 0; } +#define OFFSET(x) offsetof(AlacEncodeContext, x) +#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, { .i64 = DEFAULT_MIN_PRED_ORDER }, MIN_LPC_ORDER, ALAC_MAX_LPC_ORDER, AE }, + { "max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, { .i64 = DEFAULT_MAX_PRED_ORDER }, MIN_LPC_ORDER, ALAC_MAX_LPC_ORDER, AE }, + + { NULL }, +}; + +static const AVClass alacenc_class = { + .class_name = "alacenc", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_alac_encoder = { .name = "alac", .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ALAC, .priv_data_size = sizeof(AlacEncodeContext), + .priv_class = &alacenc_class, .init = alac_encode_init, .encode2 = alac_encode_frame, .close = alac_encode_close, diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index de367de..e997129 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2386,19 +2386,15 @@ typedef struct AVCodecContext { */ int trellis; - /** - * - encoding: Set by user. - * - decoding: unused - */ +#if FF_API_PRIVATE_OPT + /** @deprecated use encoder private options instead */ + attribute_deprecated int min_prediction_order; - /** - * - encoding: Set by user. - * - decoding: unused - */ + /** @deprecated use encoder private options instead */ + attribute_deprecated int max_prediction_order; -#if FF_API_PRIVATE_OPT /** @deprecated use encoder private options instead */ attribute_deprecated int64_t timecode_frame_start; diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 7349f44..e25e867 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -325,9 +325,9 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) if (s->options.max_partition_order < 0) s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level]; - if (s->options.lpc_type == FF_LPC_TYPE_NONE) { - s->options.min_prediction_order = 0; - } else if (avctx->min_prediction_order >= 0) { +#if FF_API_PRIVATE_OPT +FF_DISABLE_DEPRECATION_WARNINGS + if (avctx->min_prediction_order >= 0) { if (s->options.lpc_type == FF_LPC_TYPE_FIXED) { if (avctx->min_prediction_order > MAX_FIXED_ORDER) { av_log(avctx, AV_LOG_WARNING, @@ -343,9 +343,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) } s->options.min_prediction_order = avctx->min_prediction_order; } - if (s->options.lpc_type == FF_LPC_TYPE_NONE) { - s->options.max_prediction_order = 0; - } else if (avctx->max_prediction_order >= 0) { + if (avctx->max_prediction_order >= 0) { if (s->options.lpc_type == FF_LPC_TYPE_FIXED) { if (avctx->max_prediction_order > MAX_FIXED_ORDER) { av_log(avctx, AV_LOG_WARNING, @@ -361,6 +359,26 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) } s->options.max_prediction_order = avctx->max_prediction_order; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (s->options.lpc_type == FF_LPC_TYPE_NONE) { + s->options.min_prediction_order = 0; + s->options.max_prediction_order = 0; + } else if (s->options.lpc_type == FF_LPC_TYPE_FIXED) { + if (s->options.min_prediction_order > MAX_FIXED_ORDER) { + av_log(avctx, AV_LOG_WARNING, + "invalid min prediction order %d, clamped to %d\n", + s->options.min_prediction_order, MAX_FIXED_ORDER); + s->options.min_prediction_order = MAX_FIXED_ORDER; + } + if (s->options.max_prediction_order > MAX_FIXED_ORDER) { + av_log(avctx, AV_LOG_WARNING, + "invalid max prediction order %d, clamped to %d\n", + s->options.max_prediction_order, MAX_FIXED_ORDER); + s->options.max_prediction_order = MAX_FIXED_ORDER; + } + } + if (s->options.max_prediction_order < s->options.min_prediction_order) { av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n", s->options.min_prediction_order, s->options.max_prediction_order); @@ -1332,6 +1350,9 @@ static const AVOption options[] = { { "left_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_LEFT_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" }, { "right_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_RIGHT_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" }, { "mid_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_MID_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" }, +{ "min_prediction_order", NULL, offsetof(FlacEncodeContext, options.min_prediction_order), AV_OPT_TYPE_INT, { .i64 = 0 }, MIN_LPC_ORDER, MAX_LPC_ORDER, FLAGS }, +{ "max_prediction_order", NULL, offsetof(FlacEncodeContext, options.max_prediction_order), AV_OPT_TYPE_INT, { .i64 = 0 }, MIN_LPC_ORDER, MAX_LPC_ORDER, FLAGS }, + { NULL }, }; diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 570a66e..b93a72d 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -410,9 +410,9 @@ static const AVOption avcodec_options[] = { {"b_sensitivity", "adjust sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, V|E}, #endif {"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E}, +#if FF_API_PRIVATE_OPT {"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E}, {"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E}, -#if FF_API_PRIVATE_OPT {"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, V|E}, #endif {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, |