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
 | 
					 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "libavutil/opt.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "avcodec.h"
 | 
					#include "avcodec.h"
 | 
				
			||||||
#include "put_bits.h"
 | 
					#include "put_bits.h"
 | 
				
			||||||
#include "internal.h"
 | 
					#include "internal.h"
 | 
				
			||||||
@@ -57,6 +59,8 @@ typedef struct AlacLPCContext {
 | 
				
			|||||||
} AlacLPCContext;
 | 
					} AlacLPCContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct AlacEncodeContext {
 | 
					typedef struct AlacEncodeContext {
 | 
				
			||||||
 | 
					    const AVClass *class;
 | 
				
			||||||
 | 
					    AVCodecContext *avctx;
 | 
				
			||||||
    int frame_size;                     /**< current frame size               */
 | 
					    int frame_size;                     /**< current frame size               */
 | 
				
			||||||
    int verbatim;                       /**< current frame verbatim mode flag */
 | 
					    int verbatim;                       /**< current frame verbatim mode flag */
 | 
				
			||||||
    int compression_level;
 | 
					    int compression_level;
 | 
				
			||||||
@@ -73,7 +77,6 @@ typedef struct AlacEncodeContext {
 | 
				
			|||||||
    RiceContext rc;
 | 
					    RiceContext rc;
 | 
				
			||||||
    AlacLPCContext lpc[2];
 | 
					    AlacLPCContext lpc[2];
 | 
				
			||||||
    LPCContext lpc_ctx;
 | 
					    LPCContext lpc_ctx;
 | 
				
			||||||
    AVCodecContext *avctx;
 | 
					 | 
				
			||||||
} AlacEncodeContext;
 | 
					} AlacEncodeContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -556,7 +559,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
 | 
				
			|||||||
        AV_WB8(alac_extradata+20, s->rc.k_modifier);
 | 
					        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 >= 0) {
 | 
				
			||||||
        if (avctx->min_prediction_order < MIN_LPC_ORDER ||
 | 
					        if (avctx->min_prediction_order < MIN_LPC_ORDER ||
 | 
				
			||||||
           avctx->min_prediction_order > ALAC_MAX_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->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 >= 0) {
 | 
				
			||||||
        if (avctx->max_prediction_order < MIN_LPC_ORDER ||
 | 
					        if (avctx->max_prediction_order < MIN_LPC_ORDER ||
 | 
				
			||||||
            avctx->max_prediction_order > ALAC_MAX_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;
 | 
					        s->max_prediction_order = avctx->max_prediction_order;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					FF_ENABLE_DEPRECATION_WARNINGS
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (s->max_prediction_order < s->min_prediction_order) {
 | 
					    if (s->max_prediction_order < s->min_prediction_order) {
 | 
				
			||||||
        av_log(avctx, AV_LOG_ERROR,
 | 
					        av_log(avctx, AV_LOG_ERROR,
 | 
				
			||||||
@@ -644,12 +649,29 @@ static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 | 
				
			|||||||
    return 0;
 | 
					    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 = {
 | 
					AVCodec ff_alac_encoder = {
 | 
				
			||||||
    .name           = "alac",
 | 
					    .name           = "alac",
 | 
				
			||||||
    .long_name      = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
 | 
					    .long_name      = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
 | 
				
			||||||
    .type           = AVMEDIA_TYPE_AUDIO,
 | 
					    .type           = AVMEDIA_TYPE_AUDIO,
 | 
				
			||||||
    .id             = AV_CODEC_ID_ALAC,
 | 
					    .id             = AV_CODEC_ID_ALAC,
 | 
				
			||||||
    .priv_data_size = sizeof(AlacEncodeContext),
 | 
					    .priv_data_size = sizeof(AlacEncodeContext),
 | 
				
			||||||
 | 
					    .priv_class     = &alacenc_class,
 | 
				
			||||||
    .init           = alac_encode_init,
 | 
					    .init           = alac_encode_init,
 | 
				
			||||||
    .encode2        = alac_encode_frame,
 | 
					    .encode2        = alac_encode_frame,
 | 
				
			||||||
    .close          = alac_encode_close,
 | 
					    .close          = alac_encode_close,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2621,19 +2621,15 @@ typedef struct AVCodecContext {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    int trellis;
 | 
					    int trellis;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					#if FF_API_PRIVATE_OPT
 | 
				
			||||||
     * - encoding: Set by user.
 | 
					    /** @deprecated use encoder private options instead */
 | 
				
			||||||
     * - decoding: unused
 | 
					    attribute_deprecated
 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    int min_prediction_order;
 | 
					    int min_prediction_order;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /** @deprecated use encoder private options instead */
 | 
				
			||||||
     * - encoding: Set by user.
 | 
					    attribute_deprecated
 | 
				
			||||||
     * - decoding: unused
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    int max_prediction_order;
 | 
					    int max_prediction_order;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if FF_API_PRIVATE_OPT
 | 
					 | 
				
			||||||
    /** @deprecated use encoder private options instead */
 | 
					    /** @deprecated use encoder private options instead */
 | 
				
			||||||
    attribute_deprecated
 | 
					    attribute_deprecated
 | 
				
			||||||
    int64_t timecode_frame_start;
 | 
					    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)
 | 
					    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];
 | 
					        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) {
 | 
					#if FF_API_PRIVATE_OPT
 | 
				
			||||||
        s->options.min_prediction_order = 0;
 | 
					FF_DISABLE_DEPRECATION_WARNINGS
 | 
				
			||||||
    } else if (avctx->min_prediction_order >= 0) {
 | 
					    if (avctx->min_prediction_order >= 0) {
 | 
				
			||||||
        if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
 | 
					        if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
 | 
				
			||||||
            if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
 | 
					            if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
 | 
				
			||||||
                av_log(avctx, AV_LOG_WARNING,
 | 
					                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;
 | 
					        s->options.min_prediction_order = avctx->min_prediction_order;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
 | 
					    if (avctx->max_prediction_order >= 0) {
 | 
				
			||||||
        s->options.max_prediction_order = 0;
 | 
					 | 
				
			||||||
    } else if (avctx->max_prediction_order >= 0) {
 | 
					 | 
				
			||||||
        if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
 | 
					        if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
 | 
				
			||||||
            if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
 | 
					            if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
 | 
				
			||||||
                av_log(avctx, AV_LOG_WARNING,
 | 
					                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;
 | 
					        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) {
 | 
					    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",
 | 
					        av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n",
 | 
				
			||||||
               s->options.min_prediction_order, s->options.max_prediction_order);
 | 
					               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" },
 | 
					{ "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 },
 | 
					{ "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 },
 | 
					{ "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 },
 | 
					{ 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},
 | 
					{"b_sensitivity", "adjust sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, V|E},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
 | 
					{"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},
 | 
					{"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},
 | 
					{"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},
 | 
					{"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
 | 
					#endif
 | 
				
			||||||
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
 | 
					{"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