History

lavc: move some flac-specific options to its private context.

Anton Khirnov committed 15 years ago

Commit 188dea11 parent bc976959 files · +141 −60Browse files

Unified · Split

9 files
  1. doc/APIchanges +6 −0
  2. libavcodec/alacenc.c +2 −2
  3. libavcodec/avcodec.h +25 −10
  4. libavcodec/flacenc.c +72 −30
  5. libavcodec/lpc.c +6 −6
  6. libavcodec/lpc.h +14 −3
  7. libavcodec/options.c +10 −6
  8. libavcodec/ra144enc.c +2 −2
  9. libavcodec/version.h +4 −1
doc/APIchanges+6−0
@@ -13,6 +13,12 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-05-10 - xxxxxxx - lavc 53.3.0 - avcodec.h
17+ Deprecate AVLPCType and the following fields in
18+ AVCodecContext: lpc_coeff_precision, prediction_order_method,
19+ min_partition_order, max_partition_order, lpc_type, lpc_passes.
20+ Corresponding FLAC encoder options should be used instead.
21+
1622 2011-04-XX - bebe72f - lavu 51.1.0 - avutil.h
1723 Add AVPictureType enum and av_get_picture_type_char(), deprecate
1824 FF_*_TYPE defines and av_get_pict_type_char() defined in
libavcodec/alacenc.c+2−2
@@ -146,7 +146,7 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch) · 145 unmodified lines
146146 s->min_prediction_order,
147147 s->max_prediction_order,
148148 ALAC_MAX_LPC_PRECISION, coefs, shift,
149− AV_LPC_TYPE_LEVINSON, 0,
149+ FF_LPC_TYPE_LEVINSON, 0,
150150 ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
151151
152152 s->lpc[ch].lpc_order = opt_order;
@@ -457,7 +457,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 304 unmodified lines
457457
458458 s->avctx = avctx;
459459 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,
460− AV_LPC_TYPE_LEVINSON);
460+ FF_LPC_TYPE_LEVINSON);
461461
462462 return ret;
463463 }
libavcodec/avcodec.h+25−10
@@ -514,10 +514,11 @@ enum AVChromaLocation{ · 513 unmodified lines
514514 AVCHROMA_LOC_NB , ///< Not part of ABI
515515 };
516516
517+#if FF_API_FLAC_GLOBAL_OPTS
517518 /**
518519 * LPC analysis type
519520 */
520−enum AVLPCType {
521+attribute_deprecated enum AVLPCType {
521522 AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
522523 AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
523524 AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
@@ -525,6 +526,7 @@ enum AVLPCType { · 1 unmodified line
525526 AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
526527 AV_LPC_TYPE_NB , ///< Not part of ABI
527528 };
529+#endif
528530
529531 enum AVAudioServiceType {
530532 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
@@ -2472,42 +2474,53 @@ typedef struct AVCodecContext { · 1941 unmodified lines
24722474 #define FF_COMPRESSION_DEFAULT -1
24732475
24742476 /**
2475− * LPC coefficient precision - used by FLAC encoder
24762477 * - encoding: Set by user.
24772478 * - decoding: unused
24782479 */
2479− int lpc_coeff_precision;
2480+ int min_prediction_order;
24802481
24812482 /**
24822483 * - encoding: Set by user.
24832484 * - decoding: unused
24842485 */
2485− int min_prediction_order;
2486+ int max_prediction_order;
24862487
2488+#if FF_API_FLAC_GLOBAL_OPTS
24872489 /**
2490+ * @defgroup flac_opts FLAC options
2491+ * @deprecated Use FLAC encoder private options instead.
2492+ * @{
2493+ */
2494+
2495+ /**
2496+ * LPC coefficient precision - used by FLAC encoder
24882497 * - encoding: Set by user.
24892498 * - decoding: unused
24902499 */
2491− int max_prediction_order;
2500+ attribute_deprecated int lpc_coeff_precision;
24922501
24932502 /**
24942503 * search method for selecting prediction order
24952504 * - encoding: Set by user.
24962505 * - decoding: unused
24972506 */
2498− int prediction_order_method;
2507+ attribute_deprecated int prediction_order_method;
24992508
25002509 /**
25012510 * - encoding: Set by user.
25022511 * - decoding: unused
25032512 */
2504− int min_partition_order;
2513+ attribute_deprecated int min_partition_order;
25052514
25062515 /**
25072516 * - encoding: Set by user.
25082517 * - decoding: unused
25092518 */
2510− int max_partition_order;
2519+ attribute_deprecated int max_partition_order;
2520+ /**
2521+ * @}
2522+ */
2523+#endif
25112524
25122525 /**
25132526 * GOP timecode frame start number, in non drop frame format
@@ -2725,19 +2738,21 @@ typedef struct AVCodecContext { · 211 unmodified lines
27252738
27262739 int log_level_offset;
27272740
2741+#if FF_API_FLAC_GLOBAL_OPTS
27282742 /**
27292743 * Determines which LPC analysis algorithm to use.
27302744 * - encoding: Set by user
27312745 * - decoding: unused
27322746 */
2733− enum AVLPCType lpc_type;
2747+ attribute_deprecated enum AVLPCType lpc_type;
27342748
27352749 /**
27362750 * Number of passes to use for Cholesky factorization during LPC analysis
27372751 * - encoding: Set by user
27382752 * - decoding: unused
27392753 */
2740− int lpc_passes;
2754+ attribute_deprecated int lpc_passes;
2755+#endif
27412756
27422757 /**
27432758 * Number of slices.
libavcodec/flacenc.c+72−30
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/crc.h"
2323 #include "libavutil/md5.h"
24+#include "libavutil/opt.h"
2425 #include "avcodec.h"
2526 #include "get_bits.h"
2627 #include "golomb.h"
@@ -43,7 +44,7 @@ · 16 unmodified lines
4344 typedef struct CompressionOptions {
4445 int compression_level;
4546 int block_time_ms;
46− enum AVLPCType lpc_type;
47+ enum FFLPCType lpc_type;
4748 int lpc_passes;
4849 int lpc_coeff_precision;
4950 int min_prediction_order;
@@ -80,6 +81,7 @@ typedef struct FlacFrame { · 30 unmodified lines
8081 } FlacFrame;
8182
8283 typedef struct FlacEncodeContext {
84+ AVClass *class;
8385 PutBitContext pb;
8486 int channels;
8587 int samplerate;
@@ -156,16 +158,16 @@ static av_cold void dprint_compression_options(FlacEncodeContext *s) · 70 unmodified lines
156158 av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);
157159
158160 switch (opt->lpc_type) {
159− case AV_LPC_TYPE_NONE:
161+ case FF_LPC_TYPE_NONE:
160162 av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n");
161163 break;
162− case AV_LPC_TYPE_FIXED:
164+ case FF_LPC_TYPE_FIXED:
163165 av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n");
164166 break;
165− case AV_LPC_TYPE_LEVINSON:
167+ case FF_LPC_TYPE_LEVINSON:
166168 av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n");
167169 break;
168− case AV_LPC_TYPE_CHOLESKY:
170+ case FF_LPC_TYPE_CHOLESKY:
169171 av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n",
170172 opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");
171173 break;
@@ -266,32 +268,42 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 94 unmodified lines
266268
267269 s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level];
268270
269− s->options.lpc_type = ((int[]){ AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED,
270− AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
271− AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
272− AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
273− AV_LPC_TYPE_LEVINSON})[level];
271+ if (s->options.lpc_type == FF_LPC_TYPE_DEFAULT)
272+ s->options.lpc_type = ((int[]){ FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED,
273+ FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
274+ FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
275+ FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
276+ FF_LPC_TYPE_LEVINSON})[level];
274277
275278 s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level];
276279 s->options.max_prediction_order = ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level];
277280
278− s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
279− ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
280− ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
281− ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
282− ORDER_METHOD_SEARCH})[level];
281+ if (s->options.prediction_order_method < 0)
282+ s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
283+ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
284+ ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
285+ ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
286+ ORDER_METHOD_SEARCH})[level];
283287
284− s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];
285− s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];
288+ if (s->options.min_partition_order > s->options.max_partition_order) {
289+ av_log(avctx, AV_LOG_ERROR, "invalid partition orders: min=%d max=%d\n",
290+ s->options.min_partition_order, s->options.max_partition_order);
291+ return AVERROR(EINVAL);
292+ }
293+ if (s->options.min_partition_order < 0)
294+ s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];
295+ if (s->options.max_partition_order < 0)
296+ s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];
286297
287298 /* set compression option overrides from AVCodecContext */
288− if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) {
289− if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) {
299+#if FF_API_FLAC_GLOBAL_OPTS
300+ if (avctx->lpc_type > FF_LPC_TYPE_DEFAULT) {
301+ if (avctx->lpc_type > FF_LPC_TYPE_CHOLESKY) {
290302 av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);
291303 return -1;
292304 }
293305 s->options.lpc_type = avctx->lpc_type;
294− if (s->options.lpc_type == AV_LPC_TYPE_CHOLESKY) {
306+ if (s->options.lpc_type == FF_LPC_TYPE_CHOLESKY) {
295307 if (avctx->lpc_passes < 0) {
296308 // default number of passes for Cholesky
297309 s->options.lpc_passes = 2;
@@ -304,11 +316,12 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 6 unmodified lines
304316 }
305317 }
306318 }
319+#endif
307320
308− if (s->options.lpc_type == AV_LPC_TYPE_NONE) {
321+ if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
309322 s->options.min_prediction_order = 0;
310323 } else if (avctx->min_prediction_order >= 0) {
311− if (s->options.lpc_type == AV_LPC_TYPE_FIXED) {
324+ if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
312325 if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
313326 av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
314327 avctx->min_prediction_order);
@@ -322,10 +335,10 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
322335 }
323336 s->options.min_prediction_order = avctx->min_prediction_order;
324337 }
325− if (s->options.lpc_type == AV_LPC_TYPE_NONE) {
338+ if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
326339 s->options.max_prediction_order = 0;
327340 } else if (avctx->max_prediction_order >= 0) {
328− if (s->options.lpc_type == AV_LPC_TYPE_FIXED) {
341+ if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
329342 if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
330343 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
331344 avctx->max_prediction_order);
@@ -345,6 +358,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 13 unmodified lines
345358 return -1;
346359 }
347360
361+#if FF_API_FLAC_GLOBAL_OPTS
348362 if (avctx->prediction_order_method >= 0) {
349363 if (avctx->prediction_order_method > ORDER_METHOD_LOG) {
350364 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) · 24 unmodified lines
375389 s->options.min_partition_order, s->options.max_partition_order);
376390 return -1;
377391 }
392+#endif
378393
379394 if (avctx->frame_size > 0) {
380395 if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||
@@ -388,6 +403,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
388403 }
389404 s->max_blocksize = s->avctx->frame_size;
390405
406+#if FF_API_FLAC_GLOBAL_OPTS
391407 /* set LPC precision */
392408 if (avctx->lpc_coeff_precision > 0) {
393409 if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
@@ -396,10 +412,8 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 2 unmodified lines
396412 return -1;
397413 }
398414 s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;
399− } else {
400− /* default LPC precision */
401− s->options.lpc_coeff_precision = 15;
402415 }
416+#endif
403417
404418 /* set maximum encoded frame size in verbatim mode */
405419 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) · 20 unmodified lines
426440 return AVERROR(ENOMEM);
427441
428442 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,
429− s->options.max_prediction_order, AV_LPC_TYPE_LEVINSON);
443+ s->options.max_prediction_order, FF_LPC_TYPE_LEVINSON);
430444
431445 dprint_compression_options(s);
432446
@@ -867,8 +881,8 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch) · 434 unmodified lines
867881
868882 /* FIXED */
869883 sub->type = FLAC_SUBFRAME_FIXED;
870− if (s->options.lpc_type == AV_LPC_TYPE_NONE ||
871− s->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) {
884+ if (s->options.lpc_type == FF_LPC_TYPE_NONE ||
885+ s->options.lpc_type == FF_LPC_TYPE_FIXED || n <= max_order) {
872886 uint32_t bits[MAX_FIXED_ORDER+1];
873887 if (max_order > MAX_FIXED_ORDER)
874888 max_order = MAX_FIXED_ORDER;
@@ -1314,6 +1328,33 @@ static av_cold int flac_encode_close(AVCodecContext *avctx) · 439 unmodified lines
13141328 return 0;
13151329 }
13161330
1331+#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
1332+static const AVOption options[] = {
1333+{ "lpc_coeff_precision", "LPC coefficient precision", offsetof(FlacEncodeContext, options.lpc_coeff_precision), FF_OPT_TYPE_INT, 15, 0, MAX_LPC_PRECISION, FLAGS },
1334+{ "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" },
1335+{ "none", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_NONE, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1336+{ "fixed", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_FIXED, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1337+{ "levinson", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1338+{ "cholesky", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1339+{ "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 },
1340+{ "min_partition_order", NULL, offsetof(FlacEncodeContext, options.min_partition_order), FF_OPT_TYPE_INT, -1, -1, MAX_PARTITION_ORDER, FLAGS },
1341+{ "max_partition_order", NULL, offsetof(FlacEncodeContext, options.max_partition_order), FF_OPT_TYPE_INT, -1, -1, MAX_PARTITION_ORDER, FLAGS },
1342+{ "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" },
1343+{ "estimation", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_EST, INT_MIN, INT_MAX, FLAGS, "predm" },
1344+{ "2level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_2LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
1345+{ "4level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_4LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
1346+{ "8level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_8LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
1347+{ "search", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_SEARCH, INT_MIN, INT_MAX, FLAGS, "predm" },
1348+{ "log", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_LOG, INT_MIN, INT_MAX, FLAGS, "predm" },
1349+{ NULL },
1350+};
1351+
1352+static const AVClass flac_encoder_class = {
1353+ "FLAC encoder",
1354+ av_default_item_name,
1355+ options,
1356+ LIBAVUTIL_VERSION_INT,
1357+};
13171358
13181359 AVCodec ff_flac_encoder = {
13191360 "flac",
@@ -1327,4 +1368,5 @@ AVCodec ff_flac_encoder = { · 7 unmodified lines
13271368 .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
13281369 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
13291370 .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
1371+ .priv_class = &flac_encoder_class,
13301372 };
libavcodec/lpc.c+6−6
@@ -158,7 +158,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 157 unmodified lines
158158 const int32_t *samples, int blocksize, int min_order,
159159 int max_order, int precision,
160160 int32_t coefs[][MAX_LPC_ORDER], int *shift,
161− enum AVLPCType lpc_type, int lpc_passes,
161+ enum FFLPCType lpc_type, int lpc_passes,
162162 int omethod, int max_shift, int zero_shift)
163163 {
164164 double autoc[MAX_LPC_ORDER+1];
@@ -168,7 +168,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 3 unmodified lines
168168 int opt_order;
169169
170170 assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&
171− lpc_type > AV_LPC_TYPE_FIXED);
171+ lpc_type > FF_LPC_TYPE_FIXED);
172172
173173 /* reinit LPC context if parameters have changed */
174174 if (blocksize != s->blocksize || max_order != s->max_order ||
@@ -177,7 +177,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 2 unmodified lines
177177 ff_lpc_init(s, blocksize, max_order, lpc_type);
178178 }
179179
180− if (lpc_type == AV_LPC_TYPE_LEVINSON) {
180+ if (lpc_type == FF_LPC_TYPE_LEVINSON) {
181181 double *windowed_samples = s->windowed_samples + max_order;
182182
183183 s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
@@ -188,7 +188,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 4 unmodified lines
188188
189189 for(i=0; i<max_order; i++)
190190 ref[i] = fabs(lpc[i][i]);
191− } else if (lpc_type == AV_LPC_TYPE_CHOLESKY) {
191+ } else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
192192 LLSModel m[2];
193193 double var[MAX_LPC_ORDER+1], av_uninit(weight);
194194
@@ -241,13 +241,13 @@ int ff_lpc_calc_coefs(LPCContext *s, · 46 unmodified lines
241241 }
242242
243243 av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
244− enum AVLPCType lpc_type)
244+ enum FFLPCType lpc_type)
245245 {
246246 s->blocksize = blocksize;
247247 s->max_order = max_order;
248248 s->lpc_type = lpc_type;
249249
250− if (lpc_type == AV_LPC_TYPE_LEVINSON) {
250+ if (lpc_type == FF_LPC_TYPE_LEVINSON) {
251251 s->windowed_samples = av_mallocz((blocksize + max_order + 2) *
252252 sizeof(*s->windowed_samples));
253253 if (!s->windowed_samples)
libavcodec/lpc.h+14−3
@@ -35,11 +35,22 @@ · 34 unmodified lines
3535 #define MIN_LPC_ORDER 1
3636 #define MAX_LPC_ORDER 32
3737
38+/**
39+ * LPC analysis type
40+ */
41+enum FFLPCType {
42+ FF_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
43+ FF_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
44+ FF_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
45+ FF_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion
46+ FF_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
47+ FF_LPC_TYPE_NB , ///< Not part of ABI
48+};
3849
3950 typedef struct LPCContext {
4051 int blocksize;
4152 int max_order;
42− enum AVLPCType lpc_type;
53+ enum FFLPCType lpc_type;
4354 double *windowed_samples;
4455
4556 /**
@@ -77,14 +88,14 @@ int ff_lpc_calc_coefs(LPCContext *s, · 31 unmodified lines
7788 const int32_t *samples, int blocksize, int min_order,
7889 int max_order, int precision,
7990 int32_t coefs[][MAX_LPC_ORDER], int *shift,
80− enum AVLPCType lpc_type, int lpc_passes,
91+ enum FFLPCType lpc_type, int lpc_passes,
8192 int omethod, int max_shift, int zero_shift);
8293
8394 /**
8495 * Initialize LPCContext.
8596 */
8697 int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
87− enum AVLPCType lpc_type);
98+ enum FFLPCType lpc_type);
8899 void ff_lpc_init_x86(LPCContext *s);
89100
90101 /**
libavcodec/options.c+10−6
@@ -380,12 +380,14 @@ static const AVOption options[]={ · 379 unmodified lines
380380 {"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},
381381 {"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E},
382382 {"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, FF_COMPRESSION_DEFAULT, INT_MIN, INT_MAX, V|A|E},
383−{"lpc_coeff_precision", "LPC coefficient precision (FLAC)", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
384383 {"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
385384 {"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
386−{"prediction_order_method", "search method for selecting prediction order", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
387−{"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
388−{"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
385+#if FF_API_FLAC_GLOBAL_OPTS
386+{"lpc_coeff_precision", "deprecated, use flac-specific options", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
387+{"prediction_order_method", "deprecated, use flac-specific options", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
388+{"min_partition_order", "deprecated, use flac-specific options", OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
389+{"max_partition_order", "deprecated, use flac-specific options", OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
390+#endif
389391 {"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},
390392 {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
391393 {"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[]={ · 24 unmodified lines
416418 {"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"},
417419 {"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},
418420 {"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX },
419−{"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},
421+#if FF_API_FLAC_GLOBAL_OPTS
422+{"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},
420423 {"none", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_NONE, INT_MIN, INT_MAX, A|E, "lpc_type"},
421424 {"fixed", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_FIXED, INT_MIN, INT_MAX, A|E, "lpc_type"},
422425 {"levinson", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, A|E, "lpc_type"},
423426 {"cholesky", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, A|E, "lpc_type"},
424−{"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},
427+{"lpc_passes", "deprecated, use flac-specific options", OFFSET(lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
428+#endif
425429 {"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
426430 {"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"},
427431 {"slice", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_SLICE, INT_MIN, INT_MAX, V|E|D, "thread_type"},
libavcodec/ra144enc.c+2−2
@@ -54,7 +54,7 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx) · 53 unmodified lines
5454 ractx->lpc_coef[1] = ractx->lpc_tables[1];
5555 ractx->avctx = avctx;
5656 ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
57− AV_LPC_TYPE_LEVINSON);
57+ FF_LPC_TYPE_LEVINSON);
5858 return ret;
5959 }
6060
@@ -461,7 +461,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 400 unmodified lines
461461 32)];
462462
463463 ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
464− LPC_ORDER, 16, lpc_coefs, shift, AV_LPC_TYPE_LEVINSON,
464+ LPC_ORDER, 16, lpc_coefs, shift, FF_LPC_TYPE_LEVINSON,
465465 0, ORDER_METHOD_EST, 12, 0);
466466 for (i = 0; i < LPC_ORDER; i++)
467467 block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
libavcodec/version.h+4−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121 #define AVCODEC_VERSION_H
2222
2323 #define LIBAVCODEC_VERSION_MAJOR 53
24−#define LIBAVCODEC_VERSION_MINOR 2
24+#define LIBAVCODEC_VERSION_MINOR 3
2525 #define LIBAVCODEC_VERSION_MICRO 0
2626
2727 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -62,5 +62,8 @@ · 34 unmodified lines
6262 #ifndef FF_API_OLD_FF_PICT_TYPES
6363 #define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
6464 #endif
65+#ifndef FF_API_FLAC_GLOBAL_OPTS
66+#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
67+#endif
6568
6669 #endif /* AVCODEC_VERSION_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t