mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
lavc: move some flac-specific options to its private context.
This commit is contained in:
parent
bc97695af8
commit
188dea1dbf
@ -13,6 +13,12 @@ libavutil: 2011-04-18
|
||||
|
||||
API changes, most recent first:
|
||||
|
||||
2011-05-10 - xxxxxxx - lavc 53.3.0 - avcodec.h
|
||||
Deprecate AVLPCType and the following fields in
|
||||
AVCodecContext: lpc_coeff_precision, prediction_order_method,
|
||||
min_partition_order, max_partition_order, lpc_type, lpc_passes.
|
||||
Corresponding FLAC encoder options should be used instead.
|
||||
|
||||
2011-04-XX - bebe72f - lavu 51.1.0 - avutil.h
|
||||
Add AVPictureType enum and av_get_picture_type_char(), deprecate
|
||||
FF_*_TYPE defines and av_get_pict_type_char() defined in
|
||||
|
@ -146,7 +146,7 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch)
|
||||
s->min_prediction_order,
|
||||
s->max_prediction_order,
|
||||
ALAC_MAX_LPC_PRECISION, coefs, shift,
|
||||
AV_LPC_TYPE_LEVINSON, 0,
|
||||
FF_LPC_TYPE_LEVINSON, 0,
|
||||
ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
|
||||
|
||||
s->lpc[ch].lpc_order = opt_order;
|
||||
@ -457,7 +457,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
|
||||
|
||||
s->avctx = avctx;
|
||||
ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,
|
||||
AV_LPC_TYPE_LEVINSON);
|
||||
FF_LPC_TYPE_LEVINSON);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -514,10 +514,11 @@ enum AVChromaLocation{
|
||||
AVCHROMA_LOC_NB , ///< Not part of ABI
|
||||
};
|
||||
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
/**
|
||||
* LPC analysis type
|
||||
*/
|
||||
enum AVLPCType {
|
||||
attribute_deprecated enum AVLPCType {
|
||||
AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
|
||||
AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
|
||||
AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
|
||||
@ -525,6 +526,7 @@ enum AVLPCType {
|
||||
AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
|
||||
AV_LPC_TYPE_NB , ///< Not part of ABI
|
||||
};
|
||||
#endif
|
||||
|
||||
enum AVAudioServiceType {
|
||||
AV_AUDIO_SERVICE_TYPE_MAIN = 0,
|
||||
@ -2471,13 +2473,6 @@ typedef struct AVCodecContext {
|
||||
int compression_level;
|
||||
#define FF_COMPRESSION_DEFAULT -1
|
||||
|
||||
/**
|
||||
* LPC coefficient precision - used by FLAC encoder
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
int lpc_coeff_precision;
|
||||
|
||||
/**
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
@ -2490,24 +2485,42 @@ typedef struct AVCodecContext {
|
||||
*/
|
||||
int max_prediction_order;
|
||||
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
/**
|
||||
* @defgroup flac_opts FLAC options
|
||||
* @deprecated Use FLAC encoder private options instead.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* LPC coefficient precision - used by FLAC encoder
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
attribute_deprecated int lpc_coeff_precision;
|
||||
|
||||
/**
|
||||
* search method for selecting prediction order
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
int prediction_order_method;
|
||||
attribute_deprecated int prediction_order_method;
|
||||
|
||||
/**
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
int min_partition_order;
|
||||
attribute_deprecated int min_partition_order;
|
||||
|
||||
/**
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
int max_partition_order;
|
||||
attribute_deprecated int max_partition_order;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GOP timecode frame start number, in non drop frame format
|
||||
@ -2725,19 +2738,21 @@ typedef struct AVCodecContext {
|
||||
|
||||
int log_level_offset;
|
||||
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
/**
|
||||
* Determines which LPC analysis algorithm to use.
|
||||
* - encoding: Set by user
|
||||
* - decoding: unused
|
||||
*/
|
||||
enum AVLPCType lpc_type;
|
||||
attribute_deprecated enum AVLPCType lpc_type;
|
||||
|
||||
/**
|
||||
* Number of passes to use for Cholesky factorization during LPC analysis
|
||||
* - encoding: Set by user
|
||||
* - decoding: unused
|
||||
*/
|
||||
int lpc_passes;
|
||||
attribute_deprecated int lpc_passes;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Number of slices.
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "libavutil/crc.h"
|
||||
#include "libavutil/md5.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "golomb.h"
|
||||
@ -43,7 +44,7 @@
|
||||
typedef struct CompressionOptions {
|
||||
int compression_level;
|
||||
int block_time_ms;
|
||||
enum AVLPCType lpc_type;
|
||||
enum FFLPCType lpc_type;
|
||||
int lpc_passes;
|
||||
int lpc_coeff_precision;
|
||||
int min_prediction_order;
|
||||
@ -80,6 +81,7 @@ typedef struct FlacFrame {
|
||||
} FlacFrame;
|
||||
|
||||
typedef struct FlacEncodeContext {
|
||||
AVClass *class;
|
||||
PutBitContext pb;
|
||||
int channels;
|
||||
int samplerate;
|
||||
@ -156,16 +158,16 @@ static av_cold void dprint_compression_options(FlacEncodeContext *s)
|
||||
av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);
|
||||
|
||||
switch (opt->lpc_type) {
|
||||
case AV_LPC_TYPE_NONE:
|
||||
case FF_LPC_TYPE_NONE:
|
||||
av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n");
|
||||
break;
|
||||
case AV_LPC_TYPE_FIXED:
|
||||
case FF_LPC_TYPE_FIXED:
|
||||
av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n");
|
||||
break;
|
||||
case AV_LPC_TYPE_LEVINSON:
|
||||
case FF_LPC_TYPE_LEVINSON:
|
||||
av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n");
|
||||
break;
|
||||
case AV_LPC_TYPE_CHOLESKY:
|
||||
case FF_LPC_TYPE_CHOLESKY:
|
||||
av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n",
|
||||
opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");
|
||||
break;
|
||||
@ -266,32 +268,42 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
|
||||
s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level];
|
||||
|
||||
s->options.lpc_type = ((int[]){ AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED,
|
||||
AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
|
||||
AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
|
||||
AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
|
||||
AV_LPC_TYPE_LEVINSON})[level];
|
||||
if (s->options.lpc_type == FF_LPC_TYPE_DEFAULT)
|
||||
s->options.lpc_type = ((int[]){ FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED,
|
||||
FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
|
||||
FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
|
||||
FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
|
||||
FF_LPC_TYPE_LEVINSON})[level];
|
||||
|
||||
s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level];
|
||||
s->options.max_prediction_order = ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level];
|
||||
|
||||
s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
|
||||
ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
|
||||
ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
|
||||
ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
|
||||
ORDER_METHOD_SEARCH})[level];
|
||||
if (s->options.prediction_order_method < 0)
|
||||
s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
|
||||
ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
|
||||
ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
|
||||
ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
|
||||
ORDER_METHOD_SEARCH})[level];
|
||||
|
||||
s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];
|
||||
s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];
|
||||
if (s->options.min_partition_order > s->options.max_partition_order) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid partition orders: min=%d max=%d\n",
|
||||
s->options.min_partition_order, s->options.max_partition_order);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (s->options.min_partition_order < 0)
|
||||
s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];
|
||||
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];
|
||||
|
||||
/* set compression option overrides from AVCodecContext */
|
||||
if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) {
|
||||
if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) {
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
if (avctx->lpc_type > FF_LPC_TYPE_DEFAULT) {
|
||||
if (avctx->lpc_type > FF_LPC_TYPE_CHOLESKY) {
|
||||
av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);
|
||||
return -1;
|
||||
}
|
||||
s->options.lpc_type = avctx->lpc_type;
|
||||
if (s->options.lpc_type == AV_LPC_TYPE_CHOLESKY) {
|
||||
if (s->options.lpc_type == FF_LPC_TYPE_CHOLESKY) {
|
||||
if (avctx->lpc_passes < 0) {
|
||||
// default number of passes for Cholesky
|
||||
s->options.lpc_passes = 2;
|
||||
@ -304,11 +316,12 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (s->options.lpc_type == AV_LPC_TYPE_NONE) {
|
||||
if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
|
||||
s->options.min_prediction_order = 0;
|
||||
} else if (avctx->min_prediction_order >= 0) {
|
||||
if (s->options.lpc_type == AV_LPC_TYPE_FIXED) {
|
||||
if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
|
||||
if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
|
||||
avctx->min_prediction_order);
|
||||
@ -322,10 +335,10 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
}
|
||||
s->options.min_prediction_order = avctx->min_prediction_order;
|
||||
}
|
||||
if (s->options.lpc_type == AV_LPC_TYPE_NONE) {
|
||||
if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
|
||||
s->options.max_prediction_order = 0;
|
||||
} else if (avctx->max_prediction_order >= 0) {
|
||||
if (s->options.lpc_type == AV_LPC_TYPE_FIXED) {
|
||||
if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
|
||||
if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
|
||||
avctx->max_prediction_order);
|
||||
@ -345,6 +358,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
if (avctx->prediction_order_method >= 0) {
|
||||
if (avctx->prediction_order_method > ORDER_METHOD_LOG) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid prediction order method: %d\n",
|
||||
@ -375,6 +389,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
s->options.min_partition_order, s->options.max_partition_order);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (avctx->frame_size > 0) {
|
||||
if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||
|
||||
@ -388,6 +403,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
}
|
||||
s->max_blocksize = s->avctx->frame_size;
|
||||
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
/* set LPC precision */
|
||||
if (avctx->lpc_coeff_precision > 0) {
|
||||
if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
|
||||
@ -396,10 +412,8 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;
|
||||
} else {
|
||||
/* default LPC precision */
|
||||
s->options.lpc_coeff_precision = 15;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* set maximum encoded frame size in verbatim mode */
|
||||
s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size,
|
||||
@ -426,7 +440,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,
|
||||
s->options.max_prediction_order, AV_LPC_TYPE_LEVINSON);
|
||||
s->options.max_prediction_order, FF_LPC_TYPE_LEVINSON);
|
||||
|
||||
dprint_compression_options(s);
|
||||
|
||||
@ -867,8 +881,8 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
|
||||
|
||||
/* FIXED */
|
||||
sub->type = FLAC_SUBFRAME_FIXED;
|
||||
if (s->options.lpc_type == AV_LPC_TYPE_NONE ||
|
||||
s->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) {
|
||||
if (s->options.lpc_type == FF_LPC_TYPE_NONE ||
|
||||
s->options.lpc_type == FF_LPC_TYPE_FIXED || n <= max_order) {
|
||||
uint32_t bits[MAX_FIXED_ORDER+1];
|
||||
if (max_order > MAX_FIXED_ORDER)
|
||||
max_order = MAX_FIXED_ORDER;
|
||||
@ -1314,6 +1328,33 @@ static av_cold int flac_encode_close(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
|
||||
static const AVOption options[] = {
|
||||
{ "lpc_coeff_precision", "LPC coefficient precision", offsetof(FlacEncodeContext, options.lpc_coeff_precision), FF_OPT_TYPE_INT, 15, 0, MAX_LPC_PRECISION, FLAGS },
|
||||
{ "lpc_type", "LPC algorithm", offsetof(FlacEncodeContext, options.lpc_type), FF_OPT_TYPE_INT, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_NB-1, FLAGS, "lpc_type" },
|
||||
{ "none", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_NONE, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
|
||||
{ "fixed", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_FIXED, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
|
||||
{ "levinson", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
|
||||
{ "cholesky", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
|
||||
{ "lpc_passes", "Number of passes to use for Cholesky factorization during LPC analysis", offsetof(FlacEncodeContext, options.lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, FLAGS },
|
||||
{ "min_partition_order", NULL, offsetof(FlacEncodeContext, options.min_partition_order), FF_OPT_TYPE_INT, -1, -1, MAX_PARTITION_ORDER, FLAGS },
|
||||
{ "max_partition_order", NULL, offsetof(FlacEncodeContext, options.max_partition_order), FF_OPT_TYPE_INT, -1, -1, MAX_PARTITION_ORDER, FLAGS },
|
||||
{ "prediction_order_method", "Search method for selecting prediction order", offsetof(FlacEncodeContext, options.prediction_order_method), FF_OPT_TYPE_INT, -1, -1, ORDER_METHOD_LOG, FLAGS, "predm" },
|
||||
{ "estimation", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_EST, INT_MIN, INT_MAX, FLAGS, "predm" },
|
||||
{ "2level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_2LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
|
||||
{ "4level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_4LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
|
||||
{ "8level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_8LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
|
||||
{ "search", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_SEARCH, INT_MIN, INT_MAX, FLAGS, "predm" },
|
||||
{ "log", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_LOG, INT_MIN, INT_MAX, FLAGS, "predm" },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const AVClass flac_encoder_class = {
|
||||
"FLAC encoder",
|
||||
av_default_item_name,
|
||||
options,
|
||||
LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
AVCodec ff_flac_encoder = {
|
||||
"flac",
|
||||
@ -1327,4 +1368,5 @@ AVCodec ff_flac_encoder = {
|
||||
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
|
||||
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
|
||||
.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
|
||||
.priv_class = &flac_encoder_class,
|
||||
};
|
||||
|
@ -158,7 +158,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
const int32_t *samples, int blocksize, int min_order,
|
||||
int max_order, int precision,
|
||||
int32_t coefs[][MAX_LPC_ORDER], int *shift,
|
||||
enum AVLPCType lpc_type, int lpc_passes,
|
||||
enum FFLPCType lpc_type, int lpc_passes,
|
||||
int omethod, int max_shift, int zero_shift)
|
||||
{
|
||||
double autoc[MAX_LPC_ORDER+1];
|
||||
@ -168,7 +168,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
int opt_order;
|
||||
|
||||
assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&
|
||||
lpc_type > AV_LPC_TYPE_FIXED);
|
||||
lpc_type > FF_LPC_TYPE_FIXED);
|
||||
|
||||
/* reinit LPC context if parameters have changed */
|
||||
if (blocksize != s->blocksize || max_order != s->max_order ||
|
||||
@ -177,7 +177,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
ff_lpc_init(s, blocksize, max_order, lpc_type);
|
||||
}
|
||||
|
||||
if (lpc_type == AV_LPC_TYPE_LEVINSON) {
|
||||
if (lpc_type == FF_LPC_TYPE_LEVINSON) {
|
||||
double *windowed_samples = s->windowed_samples + max_order;
|
||||
|
||||
s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
|
||||
@ -188,7 +188,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
|
||||
for(i=0; i<max_order; i++)
|
||||
ref[i] = fabs(lpc[i][i]);
|
||||
} else if (lpc_type == AV_LPC_TYPE_CHOLESKY) {
|
||||
} else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
|
||||
LLSModel m[2];
|
||||
double var[MAX_LPC_ORDER+1], av_uninit(weight);
|
||||
|
||||
@ -241,13 +241,13 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
}
|
||||
|
||||
av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
|
||||
enum AVLPCType lpc_type)
|
||||
enum FFLPCType lpc_type)
|
||||
{
|
||||
s->blocksize = blocksize;
|
||||
s->max_order = max_order;
|
||||
s->lpc_type = lpc_type;
|
||||
|
||||
if (lpc_type == AV_LPC_TYPE_LEVINSON) {
|
||||
if (lpc_type == FF_LPC_TYPE_LEVINSON) {
|
||||
s->windowed_samples = av_mallocz((blocksize + max_order + 2) *
|
||||
sizeof(*s->windowed_samples));
|
||||
if (!s->windowed_samples)
|
||||
|
@ -35,11 +35,22 @@
|
||||
#define MIN_LPC_ORDER 1
|
||||
#define MAX_LPC_ORDER 32
|
||||
|
||||
/**
|
||||
* LPC analysis type
|
||||
*/
|
||||
enum FFLPCType {
|
||||
FF_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
|
||||
FF_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
|
||||
FF_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
|
||||
FF_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion
|
||||
FF_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
|
||||
FF_LPC_TYPE_NB , ///< Not part of ABI
|
||||
};
|
||||
|
||||
typedef struct LPCContext {
|
||||
int blocksize;
|
||||
int max_order;
|
||||
enum AVLPCType lpc_type;
|
||||
enum FFLPCType lpc_type;
|
||||
double *windowed_samples;
|
||||
|
||||
/**
|
||||
@ -77,14 +88,14 @@ int ff_lpc_calc_coefs(LPCContext *s,
|
||||
const int32_t *samples, int blocksize, int min_order,
|
||||
int max_order, int precision,
|
||||
int32_t coefs[][MAX_LPC_ORDER], int *shift,
|
||||
enum AVLPCType lpc_type, int lpc_passes,
|
||||
enum FFLPCType lpc_type, int lpc_passes,
|
||||
int omethod, int max_shift, int zero_shift);
|
||||
|
||||
/**
|
||||
* Initialize LPCContext.
|
||||
*/
|
||||
int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
|
||||
enum AVLPCType lpc_type);
|
||||
enum FFLPCType lpc_type);
|
||||
void ff_lpc_init_x86(LPCContext *s);
|
||||
|
||||
/**
|
||||
|
@ -380,12 +380,14 @@ static const AVOption options[]={
|
||||
{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},
|
||||
{"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E},
|
||||
{"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, FF_COMPRESSION_DEFAULT, INT_MIN, INT_MAX, V|A|E},
|
||||
{"lpc_coeff_precision", "LPC coefficient precision (FLAC)", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
|
||||
{"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
{"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
{"prediction_order_method", "search method for selecting prediction order", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
{"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
{"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
{"lpc_coeff_precision", "deprecated, use flac-specific options", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
|
||||
{"prediction_order_method", "deprecated, use flac-specific options", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
{"min_partition_order", "deprecated, use flac-specific options", OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
{"max_partition_order", "deprecated, use flac-specific options", OFFSET(max_partition_order), FF_OPT_TYPE_INT, -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, 0, 0, INT64_MAX, V|E},
|
||||
{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
|
||||
{"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"},
|
||||
@ -416,12 +418,14 @@ static const AVOption options[]={
|
||||
{"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_REFRESH, INT_MIN, INT_MAX, V|E, "flags2"},
|
||||
{"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E},
|
||||
{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX },
|
||||
{"lpc_type", "specify LPC algorithm", OFFSET(lpc_type), FF_OPT_TYPE_INT, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E},
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
{"lpc_type", "deprecated, use flac-specific options", OFFSET(lpc_type), FF_OPT_TYPE_INT, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E},
|
||||
{"none", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_NONE, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
||||
{"fixed", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_FIXED, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
||||
{"levinson", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
||||
{"cholesky", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
||||
{"lpc_passes", "number of passes to use for Cholesky factorization during LPC analysis", OFFSET(lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
{"lpc_passes", "deprecated, use flac-specific options", OFFSET(lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
|
||||
#endif
|
||||
{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
|
||||
{"thread_type", "select multithreading type", OFFSET(thread_type), FF_OPT_TYPE_INT, FF_THREAD_SLICE|FF_THREAD_FRAME, 0, INT_MAX, V|E|D, "thread_type"},
|
||||
{"slice", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_SLICE, INT_MIN, INT_MAX, V|E|D, "thread_type"},
|
||||
|
@ -54,7 +54,7 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx)
|
||||
ractx->lpc_coef[1] = ractx->lpc_tables[1];
|
||||
ractx->avctx = avctx;
|
||||
ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
|
||||
AV_LPC_TYPE_LEVINSON);
|
||||
FF_LPC_TYPE_LEVINSON);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame,
|
||||
32)];
|
||||
|
||||
ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
|
||||
LPC_ORDER, 16, lpc_coefs, shift, AV_LPC_TYPE_LEVINSON,
|
||||
LPC_ORDER, 16, lpc_coefs, shift, FF_LPC_TYPE_LEVINSON,
|
||||
0, ORDER_METHOD_EST, 12, 0);
|
||||
for (i = 0; i < LPC_ORDER; i++)
|
||||
block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define AVCODEC_VERSION_H
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 53
|
||||
#define LIBAVCODEC_VERSION_MINOR 2
|
||||
#define LIBAVCODEC_VERSION_MINOR 3
|
||||
#define LIBAVCODEC_VERSION_MICRO 0
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
@ -62,5 +62,8 @@
|
||||
#ifndef FF_API_OLD_FF_PICT_TYPES
|
||||
#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_FLAC_GLOBAL_OPTS
|
||||
#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_VERSION_H */
|
||||
|
Loading…
Reference in New Issue
Block a user