Merge commit '243df1351d2d928caa084a5704ed783f0b83f072'
* commit '243df1351d2d928caa084a5704ed783f0b83f072':
  lavc: Move {min,max}_prediction_order to codec private options
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
			
			
This commit is contained in:
		@@ -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,8 @@ typedef struct AlacLPCContext {
 | 
			
		||||
} AlacLPCContext;
 | 
			
		||||
 | 
			
		||||
typedef struct AlacEncodeContext {
 | 
			
		||||
    const AVClass *class;
 | 
			
		||||
    AVCodecContext *avctx;
 | 
			
		||||
    int frame_size;                     /**< current frame size               */
 | 
			
		||||
    int verbatim;                       /**< current frame verbatim mode flag */
 | 
			
		||||
    int compression_level;
 | 
			
		||||
@@ -73,7 +77,6 @@ typedef struct AlacEncodeContext {
 | 
			
		||||
    RiceContext rc;
 | 
			
		||||
    AlacLPCContext lpc[2];
 | 
			
		||||
    LPCContext lpc_ctx;
 | 
			
		||||
    AVCodecContext *avctx;
 | 
			
		||||
} AlacEncodeContext;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -556,7 +559,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) {
 | 
			
		||||
@@ -569,7 +573,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) {
 | 
			
		||||
@@ -581,6 +584,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,
 | 
			
		||||
@@ -644,12 +649,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,
 | 
			
		||||
 
 | 
			
		||||
@@ -2621,19 +2621,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;
 | 
			
		||||
 
 | 
			
		||||
@@ -335,9 +335,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,
 | 
			
		||||
@@ -353,9 +353,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,
 | 
			
		||||
@@ -371,6 +369,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);
 | 
			
		||||
@@ -1464,6 +1482,9 @@ static const AVOption options[] = {
 | 
			
		||||
{ "mid_side",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_MID_SIDE    }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
 | 
			
		||||
{ "exact_rice_parameters", "Calculate rice parameters exactly", offsetof(FlacEncodeContext, options.exact_rice_parameters), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
 | 
			
		||||
{ "multi_dim_quant",       "Multi-dimensional quantization",    offsetof(FlacEncodeContext, options.multi_dim_quant),       AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
 | 
			
		||||
{ "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 },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -430,9 +430,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 = -1 }, -1, 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},
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user