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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162011-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
162011-04-XX - bebe72f - lavu 51.1.0 - avutil.h222011-04-XX - bebe72f - lavu 51.1.0 - avutil.h
17 Add AVPictureType enum and av_get_picture_type_char(), deprecate23 Add AVPictureType enum and av_get_picture_type_char(), deprecate
18 FF_*_TYPE defines and av_get_pict_type_char() defined in24 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
146 s->min_prediction_order,146 s->min_prediction_order,
147 s->max_prediction_order,147 s->max_prediction_order,
148 ALAC_MAX_LPC_PRECISION, coefs, shift,148 ALAC_MAX_LPC_PRECISION, coefs, shift,
149 AV_LPC_TYPE_LEVINSON, 0,149 FF_LPC_TYPE_LEVINSON, 0,
150 ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);150 ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
151 151
152 s->lpc[ch].lpc_order = opt_order;152 s->lpc[ch].lpc_order = opt_order;
@@ -457,7 +457,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 304 unmodified lines
457 457
458 s->avctx = avctx;458 s->avctx = avctx;
459 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,459 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,
460 AV_LPC_TYPE_LEVINSON);460 FF_LPC_TYPE_LEVINSON);
461 461
462 return ret;462 return ret;
463}463}
libavcodec/avcodec.h+25−10
@@ -514,10 +514,11 @@ enum AVChromaLocation{ · 513 unmodified lines
514 AVCHROMA_LOC_NB , ///< Not part of ABI514 AVCHROMA_LOC_NB , ///< Not part of ABI
515};515};
516 516
517#if FF_API_FLAC_GLOBAL_OPTS
517/**518/**
518 * LPC analysis type519 * LPC analysis type
519 */520 */
520enum AVLPCType {521attribute_deprecated enum AVLPCType {
521 AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type522 AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
522 AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients523 AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
523 AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients524 AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
@@ -525,6 +526,7 @@ enum AVLPCType { · 1 unmodified line
525 AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization526 AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
526 AV_LPC_TYPE_NB , ///< Not part of ABI527 AV_LPC_TYPE_NB , ///< Not part of ABI
527};528};
529#endif
528 530
529enum AVAudioServiceType {531enum AVAudioServiceType {
530 AV_AUDIO_SERVICE_TYPE_MAIN = 0,532 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
@@ -2472,42 +2474,53 @@ typedef struct AVCodecContext { · 1941 unmodified lines
2472#define FF_COMPRESSION_DEFAULT -12474#define FF_COMPRESSION_DEFAULT -1
2473 2475
2474 /**2476 /**
2475 * LPC coefficient precision - used by FLAC encoder
2476 * - encoding: Set by user.2477 * - encoding: Set by user.
2477 * - decoding: unused2478 * - decoding: unused
2478 */2479 */
2479 int lpc_coeff_precision;2480 int min_prediction_order;
2480 2481
2481 /**2482 /**
2482 * - encoding: Set by user.2483 * - encoding: Set by user.
2483 * - decoding: unused2484 * - decoding: unused
2484 */2485 */
2485 int min_prediction_order;2486 int max_prediction_order;
2486 2487
2488#if FF_API_FLAC_GLOBAL_OPTS
2487 /**2489 /**
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
2488 * - encoding: Set by user.2497 * - encoding: Set by user.
2489 * - decoding: unused2498 * - decoding: unused
2490 */2499 */
2491 int max_prediction_order;2500 attribute_deprecated int lpc_coeff_precision;
2492 2501
2493 /**2502 /**
2494 * search method for selecting prediction order2503 * search method for selecting prediction order
2495 * - encoding: Set by user.2504 * - encoding: Set by user.
2496 * - decoding: unused2505 * - decoding: unused
2497 */2506 */
2498 int prediction_order_method;2507 attribute_deprecated int prediction_order_method;
2499 2508
2500 /**2509 /**
2501 * - encoding: Set by user.2510 * - encoding: Set by user.
2502 * - decoding: unused2511 * - decoding: unused
2503 */2512 */
2504 int min_partition_order;2513 attribute_deprecated int min_partition_order;
2505 2514
2506 /**2515 /**
2507 * - encoding: Set by user.2516 * - encoding: Set by user.
2508 * - decoding: unused2517 * - decoding: unused
2509 */2518 */
2510 int max_partition_order;2519 attribute_deprecated int max_partition_order;
2520 /**
2521 * @}
2522 */
2523#endif
2511 2524
2512 /**2525 /**
2513 * GOP timecode frame start number, in non drop frame format2526 * GOP timecode frame start number, in non drop frame format
@@ -2725,19 +2738,21 @@ typedef struct AVCodecContext { · 211 unmodified lines
2725 2738
2726 int log_level_offset;2739 int log_level_offset;
2727 2740
2741#if FF_API_FLAC_GLOBAL_OPTS
2728 /**2742 /**
2729 * Determines which LPC analysis algorithm to use.2743 * Determines which LPC analysis algorithm to use.
2730 * - encoding: Set by user2744 * - encoding: Set by user
2731 * - decoding: unused2745 * - decoding: unused
2732 */2746 */
2733 enum AVLPCType lpc_type;2747 attribute_deprecated enum AVLPCType lpc_type;
2734 2748
2735 /**2749 /**
2736 * Number of passes to use for Cholesky factorization during LPC analysis2750 * Number of passes to use for Cholesky factorization during LPC analysis
2737 * - encoding: Set by user2751 * - encoding: Set by user
2738 * - decoding: unused2752 * - decoding: unused
2739 */2753 */
2740 int lpc_passes;2754 attribute_deprecated int lpc_passes;
2755#endif
2741 2756
2742 /**2757 /**
2743 * Number of slices.2758 * Number of slices.
libavcodec/flacenc.c+72−30
@@ -21,6 +21,7 @@ · 20 unmodified lines
21 21
22#include "libavutil/crc.h"22#include "libavutil/crc.h"
23#include "libavutil/md5.h"23#include "libavutil/md5.h"
24#include "libavutil/opt.h"
24#include "avcodec.h"25#include "avcodec.h"
25#include "get_bits.h"26#include "get_bits.h"
26#include "golomb.h"27#include "golomb.h"
@@ -43,7 +44,7 @@ · 16 unmodified lines
43typedef struct CompressionOptions {44typedef struct CompressionOptions {
44 int compression_level;45 int compression_level;
45 int block_time_ms;46 int block_time_ms;
46 enum AVLPCType lpc_type;47 enum FFLPCType lpc_type;
47 int lpc_passes;48 int lpc_passes;
48 int lpc_coeff_precision;49 int lpc_coeff_precision;
49 int min_prediction_order;50 int min_prediction_order;
@@ -80,6 +81,7 @@ typedef struct FlacFrame { · 30 unmodified lines
80} FlacFrame;81} FlacFrame;
81 82
82typedef struct FlacEncodeContext {83typedef struct FlacEncodeContext {
84 AVClass *class;
83 PutBitContext pb;85 PutBitContext pb;
84 int channels;86 int channels;
85 int samplerate;87 int samplerate;
@@ -156,16 +158,16 @@ static av_cold void dprint_compression_options(FlacEncodeContext *s) · 70 unmodified lines
156 av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);158 av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);
157 159
158 switch (opt->lpc_type) {160 switch (opt->lpc_type) {
159 case AV_LPC_TYPE_NONE:161 case FF_LPC_TYPE_NONE:
160 av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n");162 av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n");
161 break;163 break;
162 case AV_LPC_TYPE_FIXED:164 case FF_LPC_TYPE_FIXED:
163 av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n");165 av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n");
164 break;166 break;
165 case AV_LPC_TYPE_LEVINSON:167 case FF_LPC_TYPE_LEVINSON:
166 av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n");168 av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n");
167 break;169 break;
168 case AV_LPC_TYPE_CHOLESKY:170 case FF_LPC_TYPE_CHOLESKY:
169 av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n",171 av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n",
170 opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");172 opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");
171 break;173 break;
@@ -266,32 +268,42 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 94 unmodified lines
266 268
267 s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level];269 s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level];
268 270
269 s->options.lpc_type = ((int[]){ AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED,271 if (s->options.lpc_type == FF_LPC_TYPE_DEFAULT)
270 AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,272 s->options.lpc_type = ((int[]){ FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED,
271 AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,273 FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
272 AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,274 FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
273 AV_LPC_TYPE_LEVINSON})[level];275 FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
276 FF_LPC_TYPE_LEVINSON})[level];
274 277
275 s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level];278 s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level];
276 s->options.max_prediction_order = ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level];279 s->options.max_prediction_order = ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level];
277 280
278 s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,281 if (s->options.prediction_order_method < 0)
279 ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,282 s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
280 ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,283 ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
281 ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,284 ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
282 ORDER_METHOD_SEARCH})[level];285 ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
286 ORDER_METHOD_SEARCH})[level];
283 287
284 s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];288 if (s->options.min_partition_order > s->options.max_partition_order) {
285 s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];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];
286 297
287 /* set compression option overrides from AVCodecContext */298 /* set compression option overrides from AVCodecContext */
288 if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) {299#if FF_API_FLAC_GLOBAL_OPTS
289 if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) {300 if (avctx->lpc_type > FF_LPC_TYPE_DEFAULT) {
301 if (avctx->lpc_type > FF_LPC_TYPE_CHOLESKY) {
290 av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);302 av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);
291 return -1;303 return -1;
292 }304 }
293 s->options.lpc_type = avctx->lpc_type;305 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) {
295 if (avctx->lpc_passes < 0) {307 if (avctx->lpc_passes < 0) {
296 // default number of passes for Cholesky308 // default number of passes for Cholesky
297 s->options.lpc_passes = 2;309 s->options.lpc_passes = 2;
@@ -304,11 +316,12 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 6 unmodified lines
304 }316 }
305 }317 }
306 }318 }
319#endif
307 320
308 if (s->options.lpc_type == AV_LPC_TYPE_NONE) {321 if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
309 s->options.min_prediction_order = 0;322 s->options.min_prediction_order = 0;
310 } else if (avctx->min_prediction_order >= 0) {323 } 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) {
312 if (avctx->min_prediction_order > MAX_FIXED_ORDER) {325 if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
313 av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",326 av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
314 avctx->min_prediction_order);327 avctx->min_prediction_order);
@@ -322,10 +335,10 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
322 }335 }
323 s->options.min_prediction_order = avctx->min_prediction_order;336 s->options.min_prediction_order = avctx->min_prediction_order;
324 }337 }
325 if (s->options.lpc_type == AV_LPC_TYPE_NONE) {338 if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
326 s->options.max_prediction_order = 0;339 s->options.max_prediction_order = 0;
327 } else if (avctx->max_prediction_order >= 0) {340 } 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) {
329 if (avctx->max_prediction_order > MAX_FIXED_ORDER) {342 if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
330 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",343 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
331 avctx->max_prediction_order);344 avctx->max_prediction_order);
@@ -345,6 +358,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 13 unmodified lines
345 return -1;358 return -1;
346 }359 }
347 360
361#if FF_API_FLAC_GLOBAL_OPTS
348 if (avctx->prediction_order_method >= 0) {362 if (avctx->prediction_order_method >= 0) {
349 if (avctx->prediction_order_method > ORDER_METHOD_LOG) {363 if (avctx->prediction_order_method > ORDER_METHOD_LOG) {
350 av_log(avctx, AV_LOG_ERROR, "invalid prediction order method: %d\n",364 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
375 s->options.min_partition_order, s->options.max_partition_order);389 s->options.min_partition_order, s->options.max_partition_order);
376 return -1;390 return -1;
377 }391 }
392#endif
378 393
379 if (avctx->frame_size > 0) {394 if (avctx->frame_size > 0) {
380 if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||395 if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||
@@ -388,6 +403,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
388 }403 }
389 s->max_blocksize = s->avctx->frame_size;404 s->max_blocksize = s->avctx->frame_size;
390 405
406#if FF_API_FLAC_GLOBAL_OPTS
391 /* set LPC precision */407 /* set LPC precision */
392 if (avctx->lpc_coeff_precision > 0) {408 if (avctx->lpc_coeff_precision > 0) {
393 if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {409 if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
@@ -396,10 +412,8 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 2 unmodified lines
396 return -1;412 return -1;
397 }413 }
398 s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;414 s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;
399 } else {
400 /* default LPC precision */
401 s->options.lpc_coeff_precision = 15;
402 }415 }
416#endif
403 417
404 /* set maximum encoded frame size in verbatim mode */418 /* set maximum encoded frame size in verbatim mode */
405 s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size,419 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
426 return AVERROR(ENOMEM);440 return AVERROR(ENOMEM);
427 441
428 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,442 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);
430 444
431 dprint_compression_options(s);445 dprint_compression_options(s);
432 446
@@ -867,8 +881,8 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch) · 434 unmodified lines
867 881
868 /* FIXED */882 /* FIXED */
869 sub->type = FLAC_SUBFRAME_FIXED;883 sub->type = FLAC_SUBFRAME_FIXED;
870 if (s->options.lpc_type == AV_LPC_TYPE_NONE ||884 if (s->options.lpc_type == FF_LPC_TYPE_NONE ||
871 s->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) {885 s->options.lpc_type == FF_LPC_TYPE_FIXED || n <= max_order) {
872 uint32_t bits[MAX_FIXED_ORDER+1];886 uint32_t bits[MAX_FIXED_ORDER+1];
873 if (max_order > MAX_FIXED_ORDER)887 if (max_order > MAX_FIXED_ORDER)
874 max_order = MAX_FIXED_ORDER;888 max_order = MAX_FIXED_ORDER;
@@ -1314,6 +1328,33 @@ static av_cold int flac_encode_close(AVCodecContext *avctx) · 439 unmodified lines
1314 return 0;1328 return 0;
1315}1329}
1316 1330
1331#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
1332static 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
1352static const AVClass flac_encoder_class = {
1353 "FLAC encoder",
1354 av_default_item_name,
1355 options,
1356 LIBAVUTIL_VERSION_INT,
1357};
1317 1358
1318AVCodec ff_flac_encoder = {1359AVCodec ff_flac_encoder = {
1319 "flac",1360 "flac",
@@ -1327,4 +1368,5 @@ AVCodec ff_flac_encoder = { · 7 unmodified lines
1327 .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,1368 .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
1328 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},1369 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
1329 .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),1370 .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
1371 .priv_class = &flac_encoder_class,
1330};1372};
libavcodec/lpc.c+6−6
@@ -158,7 +158,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 157 unmodified lines
158 const int32_t *samples, int blocksize, int min_order,158 const int32_t *samples, int blocksize, int min_order,
159 int max_order, int precision,159 int max_order, int precision,
160 int32_t coefs[][MAX_LPC_ORDER], int *shift,160 int32_t coefs[][MAX_LPC_ORDER], int *shift,
161 enum AVLPCType lpc_type, int lpc_passes,161 enum FFLPCType lpc_type, int lpc_passes,
162 int omethod, int max_shift, int zero_shift)162 int omethod, int max_shift, int zero_shift)
163{163{
164 double autoc[MAX_LPC_ORDER+1];164 double autoc[MAX_LPC_ORDER+1];
@@ -168,7 +168,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 3 unmodified lines
168 int opt_order;168 int opt_order;
169 169
170 assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&170 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);
172 172
173 /* reinit LPC context if parameters have changed */173 /* reinit LPC context if parameters have changed */
174 if (blocksize != s->blocksize || max_order != s->max_order ||174 if (blocksize != s->blocksize || max_order != s->max_order ||
@@ -177,7 +177,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 2 unmodified lines
177 ff_lpc_init(s, blocksize, max_order, lpc_type);177 ff_lpc_init(s, blocksize, max_order, lpc_type);
178 }178 }
179 179
180 if (lpc_type == AV_LPC_TYPE_LEVINSON) {180 if (lpc_type == FF_LPC_TYPE_LEVINSON) {
181 double *windowed_samples = s->windowed_samples + max_order;181 double *windowed_samples = s->windowed_samples + max_order;
182 182
183 s->lpc_apply_welch_window(samples, blocksize, windowed_samples);183 s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
@@ -188,7 +188,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 4 unmodified lines
188 188
189 for(i=0; i<max_order; i++)189 for(i=0; i<max_order; i++)
190 ref[i] = fabs(lpc[i][i]);190 ref[i] = fabs(lpc[i][i]);
191 } else if (lpc_type == AV_LPC_TYPE_CHOLESKY) {191 } else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
192 LLSModel m[2];192 LLSModel m[2];
193 double var[MAX_LPC_ORDER+1], av_uninit(weight);193 double var[MAX_LPC_ORDER+1], av_uninit(weight);
194 194
@@ -241,13 +241,13 @@ int ff_lpc_calc_coefs(LPCContext *s, · 46 unmodified lines
241}241}
242 242
243av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,243av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
244 enum AVLPCType lpc_type)244 enum FFLPCType lpc_type)
245{245{
246 s->blocksize = blocksize;246 s->blocksize = blocksize;
247 s->max_order = max_order;247 s->max_order = max_order;
248 s->lpc_type = lpc_type;248 s->lpc_type = lpc_type;
249 249
250 if (lpc_type == AV_LPC_TYPE_LEVINSON) {250 if (lpc_type == FF_LPC_TYPE_LEVINSON) {
251 s->windowed_samples = av_mallocz((blocksize + max_order + 2) *251 s->windowed_samples = av_mallocz((blocksize + max_order + 2) *
252 sizeof(*s->windowed_samples));252 sizeof(*s->windowed_samples));
253 if (!s->windowed_samples)253 if (!s->windowed_samples)
libavcodec/lpc.h+14−3
@@ -35,11 +35,22 @@ · 34 unmodified lines
35#define MIN_LPC_ORDER 135#define MIN_LPC_ORDER 1
36#define MAX_LPC_ORDER 3236#define MAX_LPC_ORDER 32
37 37
38/**
39 * LPC analysis type
40 */
41enum 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};
38 49
39typedef struct LPCContext {50typedef struct LPCContext {
40 int blocksize;51 int blocksize;
41 int max_order;52 int max_order;
42 enum AVLPCType lpc_type;53 enum FFLPCType lpc_type;
43 double *windowed_samples;54 double *windowed_samples;
44 55
45 /**56 /**
@@ -77,14 +88,14 @@ int ff_lpc_calc_coefs(LPCContext *s, · 31 unmodified lines
77 const int32_t *samples, int blocksize, int min_order,88 const int32_t *samples, int blocksize, int min_order,
78 int max_order, int precision,89 int max_order, int precision,
79 int32_t coefs[][MAX_LPC_ORDER], int *shift,90 int32_t coefs[][MAX_LPC_ORDER], int *shift,
80 enum AVLPCType lpc_type, int lpc_passes,91 enum FFLPCType lpc_type, int lpc_passes,
81 int omethod, int max_shift, int zero_shift);92 int omethod, int max_shift, int zero_shift);
82 93
83/**94/**
84 * Initialize LPCContext.95 * Initialize LPCContext.
85 */96 */
86int ff_lpc_init(LPCContext *s, int blocksize, int max_order,97int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
87 enum AVLPCType lpc_type);98 enum FFLPCType lpc_type);
88void ff_lpc_init_x86(LPCContext *s);99void ff_lpc_init_x86(LPCContext *s);
89 100
90/**101/**
libavcodec/options.c+10−6
@@ -380,12 +380,14 @@ static const AVOption options[]={ · 379 unmodified lines
380{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},380{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},
381{"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E},381{"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E},
382{"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, FF_COMPRESSION_DEFAULT, INT_MIN, INT_MAX, V|A|E},382{"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},
384{"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},383{"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
385{"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},384{"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},385#if FF_API_FLAC_GLOBAL_OPTS
387{"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},386{"lpc_coeff_precision", "deprecated, use flac-specific options", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
388{"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, 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
389{"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},391{"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},
390{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},392{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
391{"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"},393{"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
416{"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"},418{"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"},
417{"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},419{"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},
418{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX },420{"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},
420{"none", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_NONE, INT_MIN, INT_MAX, A|E, "lpc_type"},423{"none", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_NONE, INT_MIN, INT_MAX, A|E, "lpc_type"},
421{"fixed", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_FIXED, INT_MIN, INT_MAX, A|E, "lpc_type"},424{"fixed", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_FIXED, INT_MIN, INT_MAX, A|E, "lpc_type"},
422{"levinson", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, A|E, "lpc_type"},425{"levinson", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, A|E, "lpc_type"},
423{"cholesky", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, A|E, "lpc_type"},426{"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
425{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},429{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
426{"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"},430{"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"},
427{"slice", NULL, 0, FF_OPT_TYPE_CONST, FF_THREAD_SLICE, INT_MIN, INT_MAX, V|E|D, "thread_type"},431{"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
54 ractx->lpc_coef[1] = ractx->lpc_tables[1];54 ractx->lpc_coef[1] = ractx->lpc_tables[1];
55 ractx->avctx = avctx;55 ractx->avctx = avctx;
56 ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,56 ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
57 AV_LPC_TYPE_LEVINSON);57 FF_LPC_TYPE_LEVINSON);
58 return ret;58 return ret;
59}59}
60 60
@@ -461,7 +461,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 400 unmodified lines
461 32)];461 32)];
462 462
463 ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,463 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,
465 0, ORDER_METHOD_EST, 12, 0);465 0, ORDER_METHOD_EST, 12, 0);
466 for (i = 0; i < LPC_ORDER; i++)466 for (i = 0; i < LPC_ORDER; i++)
467 block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<467 block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
libavcodec/version.h+4−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
21#define AVCODEC_VERSION_H21#define AVCODEC_VERSION_H
22 22
23#define LIBAVCODEC_VERSION_MAJOR 5323#define LIBAVCODEC_VERSION_MAJOR 53
24#define LIBAVCODEC_VERSION_MINOR 224#define LIBAVCODEC_VERSION_MINOR 3
25#define LIBAVCODEC_VERSION_MICRO 025#define LIBAVCODEC_VERSION_MICRO 0
26 26
27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -62,5 +62,8 @@ · 34 unmodified lines
62#ifndef FF_API_OLD_FF_PICT_TYPES62#ifndef FF_API_OLD_FF_PICT_TYPES
63#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)63#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
64#endif64#endif
65#ifndef FF_API_FLAC_GLOBAL_OPTS
66#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
67#endif
65 68
66#endif /* AVCODEC_VERSION_H */69#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