Unified · Split
| @@ -13,6 +13,12 @@ libavutil: 2011-04-18 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 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 | + | |
| 16 | 22 | 2011-04-XX - bebe72f - lavu 51.1.0 - avutil.h |
| 17 | 23 | Add AVPictureType enum and av_get_picture_type_char(), deprecate |
| 18 | 24 | FF_*_TYPE defines and av_get_pict_type_char() defined in |
| @@ -146,7 +146,7 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch) · 145 unmodified lines | ||
| 146 | 146 | s->min_prediction_order, |
| 147 | 147 | s->max_prediction_order, |
| 148 | 148 | ALAC_MAX_LPC_PRECISION, coefs, shift, |
| 149 | − AV_LPC_TYPE_LEVINSON, 0, | |
| 149 | + FF_LPC_TYPE_LEVINSON, 0, | |
| 150 | 150 | ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1); |
| 151 | 151 | |
| 152 | 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 | 458 | s->avctx = avctx; |
| 459 | 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 | 462 | return ret; |
| 463 | 463 | } |
| @@ -514,10 +514,11 @@ enum AVChromaLocation{ · 513 unmodified lines | ||
| 514 | 514 | AVCHROMA_LOC_NB , ///< Not part of ABI |
| 515 | 515 | }; |
| 516 | 516 | |
| 517 | +#if FF_API_FLAC_GLOBAL_OPTS | |
| 517 | 518 | /** |
| 518 | 519 | * LPC analysis type |
| 519 | 520 | */ |
| 520 | −enum AVLPCType { | |
| 521 | +attribute_deprecated enum AVLPCType { | |
| 521 | 522 | AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type |
| 522 | 523 | AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients |
| 523 | 524 | AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients |
| @@ -525,6 +526,7 @@ enum AVLPCType { · 1 unmodified line | ||
| 525 | 526 | AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization |
| 526 | 527 | AV_LPC_TYPE_NB , ///< Not part of ABI |
| 527 | 528 | }; |
| 529 | +#endif | |
| 528 | 530 | |
| 529 | 531 | enum AVAudioServiceType { |
| 530 | 532 | AV_AUDIO_SERVICE_TYPE_MAIN = 0, |
| @@ -2472,42 +2474,53 @@ typedef struct AVCodecContext { · 1941 unmodified lines | ||
| 2472 | 2474 | #define FF_COMPRESSION_DEFAULT -1 |
| 2473 | 2475 | |
| 2474 | 2476 | /** |
| 2475 | − * LPC coefficient precision - used by FLAC encoder | |
| 2476 | 2477 | * - encoding: Set by user. |
| 2477 | 2478 | * - decoding: unused |
| 2478 | 2479 | */ |
| 2479 | − int lpc_coeff_precision; | |
| 2480 | + int min_prediction_order; | |
| 2480 | 2481 | |
| 2481 | 2482 | /** |
| 2482 | 2483 | * - encoding: Set by user. |
| 2483 | 2484 | * - 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 | 2497 | * - encoding: Set by user. |
| 2489 | 2498 | * - decoding: unused |
| 2490 | 2499 | */ |
| 2491 | − int max_prediction_order; | |
| 2500 | + attribute_deprecated int lpc_coeff_precision; | |
| 2492 | 2501 | |
| 2493 | 2502 | /** |
| 2494 | 2503 | * search method for selecting prediction order |
| 2495 | 2504 | * - encoding: Set by user. |
| 2496 | 2505 | * - decoding: unused |
| 2497 | 2506 | */ |
| 2498 | − int prediction_order_method; | |
| 2507 | + attribute_deprecated int prediction_order_method; | |
| 2499 | 2508 | |
| 2500 | 2509 | /** |
| 2501 | 2510 | * - encoding: Set by user. |
| 2502 | 2511 | * - decoding: unused |
| 2503 | 2512 | */ |
| 2504 | − int min_partition_order; | |
| 2513 | + attribute_deprecated int min_partition_order; | |
| 2505 | 2514 | |
| 2506 | 2515 | /** |
| 2507 | 2516 | * - encoding: Set by user. |
| 2508 | 2517 | * - 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 | 2526 | * GOP timecode frame start number, in non drop frame format |
| @@ -2725,19 +2738,21 @@ typedef struct AVCodecContext { · 211 unmodified lines | ||
| 2725 | 2738 | |
| 2726 | 2739 | int log_level_offset; |
| 2727 | 2740 | |
| 2741 | +#if FF_API_FLAC_GLOBAL_OPTS | |
| 2728 | 2742 | /** |
| 2729 | 2743 | * Determines which LPC analysis algorithm to use. |
| 2730 | 2744 | * - encoding: Set by user |
| 2731 | 2745 | * - decoding: unused |
| 2732 | 2746 | */ |
| 2733 | − enum AVLPCType lpc_type; | |
| 2747 | + attribute_deprecated enum AVLPCType lpc_type; | |
| 2734 | 2748 | |
| 2735 | 2749 | /** |
| 2736 | 2750 | * Number of passes to use for Cholesky factorization during LPC analysis |
| 2737 | 2751 | * - encoding: Set by user |
| 2738 | 2752 | * - decoding: unused |
| 2739 | 2753 | */ |
| 2740 | − int lpc_passes; | |
| 2754 | + attribute_deprecated int lpc_passes; | |
| 2755 | +#endif | |
| 2741 | 2756 | |
| 2742 | 2757 | /** |
| 2743 | 2758 | * Number of slices. |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | #include "libavutil/crc.h" |
| 23 | 23 | #include "libavutil/md5.h" |
| 24 | +#include "libavutil/opt.h" | |
| 24 | 25 | #include "avcodec.h" |
| 25 | 26 | #include "get_bits.h" |
| 26 | 27 | #include "golomb.h" |
| @@ -43,7 +44,7 @@ · 16 unmodified lines | ||
| 43 | 44 | typedef struct CompressionOptions { |
| 44 | 45 | int compression_level; |
| 45 | 46 | int block_time_ms; |
| 46 | − enum AVLPCType lpc_type; | |
| 47 | + enum FFLPCType lpc_type; | |
| 47 | 48 | int lpc_passes; |
| 48 | 49 | int lpc_coeff_precision; |
| 49 | 50 | int min_prediction_order; |
| @@ -80,6 +81,7 @@ typedef struct FlacFrame { · 30 unmodified lines | ||
| 80 | 81 | } FlacFrame; |
| 81 | 82 | |
| 82 | 83 | typedef struct FlacEncodeContext { |
| 84 | + AVClass *class; | |
| 83 | 85 | PutBitContext pb; |
| 84 | 86 | int channels; |
| 85 | 87 | int samplerate; |
| @@ -156,16 +158,16 @@ static av_cold void dprint_compression_options(FlacEncodeContext *s) · 70 unmodified lines | ||
| 156 | 158 | av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level); |
| 157 | 159 | |
| 158 | 160 | switch (opt->lpc_type) { |
| 159 | − case AV_LPC_TYPE_NONE: | |
| 161 | + case FF_LPC_TYPE_NONE: | |
| 160 | 162 | av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n"); |
| 161 | 163 | break; |
| 162 | − case AV_LPC_TYPE_FIXED: | |
| 164 | + case FF_LPC_TYPE_FIXED: | |
| 163 | 165 | av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n"); |
| 164 | 166 | break; |
| 165 | − case AV_LPC_TYPE_LEVINSON: | |
| 167 | + case FF_LPC_TYPE_LEVINSON: | |
| 166 | 168 | av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n"); |
| 167 | 169 | break; |
| 168 | − case AV_LPC_TYPE_CHOLESKY: | |
| 170 | + case FF_LPC_TYPE_CHOLESKY: | |
| 169 | 171 | av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n", |
| 170 | 172 | opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es"); |
| 171 | 173 | break; |
| @@ -266,32 +268,42 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 94 unmodified lines | ||
| 266 | 268 | |
| 267 | 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, | |
| 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]; | |
| 274 | 277 | |
| 275 | 278 | s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level]; |
| 276 | 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, | |
| 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]; | |
| 283 | 287 | |
| 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]; | |
| 286 | 297 | |
| 287 | 298 | /* 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) { | |
| 290 | 302 | av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type); |
| 291 | 303 | return -1; |
| 292 | 304 | } |
| 293 | 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 | 307 | if (avctx->lpc_passes < 0) { |
| 296 | 308 | // default number of passes for Cholesky |
| 297 | 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 | 322 | s->options.min_prediction_order = 0; |
| 310 | 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 | 325 | if (avctx->min_prediction_order > MAX_FIXED_ORDER) { |
| 313 | 326 | av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", |
| 314 | 327 | avctx->min_prediction_order); |
| @@ -322,10 +335,10 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines | ||
| 322 | 335 | } |
| 323 | 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 | 339 | s->options.max_prediction_order = 0; |
| 327 | 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 | 342 | if (avctx->max_prediction_order > MAX_FIXED_ORDER) { |
| 330 | 343 | av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", |
| 331 | 344 | avctx->max_prediction_order); |
| @@ -345,6 +358,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 13 unmodified lines | ||
| 345 | 358 | return -1; |
| 346 | 359 | } |
| 347 | 360 | |
| 361 | +#if FF_API_FLAC_GLOBAL_OPTS | |
| 348 | 362 | if (avctx->prediction_order_method >= 0) { |
| 349 | 363 | if (avctx->prediction_order_method > ORDER_METHOD_LOG) { |
| 350 | 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 | 389 | s->options.min_partition_order, s->options.max_partition_order); |
| 376 | 390 | return -1; |
| 377 | 391 | } |
| 392 | +#endif | |
| 378 | 393 | |
| 379 | 394 | if (avctx->frame_size > 0) { |
| 380 | 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 | 404 | s->max_blocksize = s->avctx->frame_size; |
| 390 | 405 | |
| 406 | +#if FF_API_FLAC_GLOBAL_OPTS | |
| 391 | 407 | /* set LPC precision */ |
| 392 | 408 | if (avctx->lpc_coeff_precision > 0) { |
| 393 | 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 | 412 | return -1; |
| 397 | 413 | } |
| 398 | 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 | 418 | /* set maximum encoded frame size in verbatim mode */ |
| 405 | 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 | 440 | return AVERROR(ENOMEM); |
| 427 | 441 | |
| 428 | 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 | 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 | 882 | /* FIXED */ |
| 869 | 883 | 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) { | |
| 872 | 886 | uint32_t bits[MAX_FIXED_ORDER+1]; |
| 873 | 887 | if (max_order > MAX_FIXED_ORDER) |
| 874 | 888 | max_order = MAX_FIXED_ORDER; |
| @@ -1314,6 +1328,33 @@ static av_cold int flac_encode_close(AVCodecContext *avctx) · 439 unmodified lines | ||
| 1314 | 1328 | return 0; |
| 1315 | 1329 | } |
| 1316 | 1330 | |
| 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 | +}; | |
| 1317 | 1358 | |
| 1318 | 1359 | AVCodec ff_flac_encoder = { |
| 1319 | 1360 | "flac", |
| @@ -1327,4 +1368,5 @@ AVCodec ff_flac_encoder = { · 7 unmodified lines | ||
| 1327 | 1368 | .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, |
| 1328 | 1369 | .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, |
| 1329 | 1370 | .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), |
| 1371 | + .priv_class = &flac_encoder_class, | |
| 1330 | 1372 | }; |
| @@ -158,7 +158,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 157 unmodified lines | ||
| 158 | 158 | const int32_t *samples, int blocksize, int min_order, |
| 159 | 159 | int max_order, int precision, |
| 160 | 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 | 162 | int omethod, int max_shift, int zero_shift) |
| 163 | 163 | { |
| 164 | 164 | double autoc[MAX_LPC_ORDER+1]; |
| @@ -168,7 +168,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 3 unmodified lines | ||
| 168 | 168 | int opt_order; |
| 169 | 169 | |
| 170 | 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 | 173 | /* reinit LPC context if parameters have changed */ |
| 174 | 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 | 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 | 181 | double *windowed_samples = s->windowed_samples + max_order; |
| 182 | 182 | |
| 183 | 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 | 189 | for(i=0; i<max_order; i++) |
| 190 | 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 | 192 | LLSModel m[2]; |
| 193 | 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 | |
| 243 | 243 | av_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 | 246 | s->blocksize = blocksize; |
| 247 | 247 | s->max_order = max_order; |
| 248 | 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 | 251 | s->windowed_samples = av_mallocz((blocksize + max_order + 2) * |
| 252 | 252 | sizeof(*s->windowed_samples)); |
| 253 | 253 | if (!s->windowed_samples) |
| @@ -35,11 +35,22 @@ · 34 unmodified lines | ||
| 35 | 35 | #define MIN_LPC_ORDER 1 |
| 36 | 36 | #define MAX_LPC_ORDER 32 |
| 37 | 37 | |
| 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 | +}; | |
| 38 | 49 | |
| 39 | 50 | typedef struct LPCContext { |
| 40 | 51 | int blocksize; |
| 41 | 52 | int max_order; |
| 42 | − enum AVLPCType lpc_type; | |
| 53 | + enum FFLPCType lpc_type; | |
| 43 | 54 | double *windowed_samples; |
| 44 | 55 | |
| 45 | 56 | /** |
| @@ -77,14 +88,14 @@ int ff_lpc_calc_coefs(LPCContext *s, · 31 unmodified lines | ||
| 77 | 88 | const int32_t *samples, int blocksize, int min_order, |
| 78 | 89 | int max_order, int precision, |
| 79 | 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 | 92 | int omethod, int max_shift, int zero_shift); |
| 82 | 93 | |
| 83 | 94 | /** |
| 84 | 95 | * Initialize LPCContext. |
| 85 | 96 | */ |
| 86 | 97 | int ff_lpc_init(LPCContext *s, int blocksize, int max_order, |
| 87 | − enum AVLPCType lpc_type); | |
| 98 | + enum FFLPCType lpc_type); | |
| 88 | 99 | void ff_lpc_init_x86(LPCContext *s); |
| 89 | 100 | |
| 90 | 101 | /** |
| @@ -380,12 +380,14 @@ static const AVOption options[]={ · 379 unmodified lines | ||
| 380 | 380 | {"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"}, |
| 381 | 381 | {"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E}, |
| 382 | 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 | 383 | {"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, |
| 385 | 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}, | |
| 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 | |
| 389 | 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 | 392 | {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"}, |
| 391 | 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 | 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 | 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 | 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 | 423 | {"none", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_NONE, INT_MIN, INT_MAX, A|E, "lpc_type"}, |
| 421 | 424 | {"fixed", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_FIXED, INT_MIN, INT_MAX, A|E, "lpc_type"}, |
| 422 | 425 | {"levinson", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, A|E, "lpc_type"}, |
| 423 | 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 | 429 | {"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E}, |
| 426 | 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 | 431 | {"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) · 53 unmodified lines | ||
| 54 | 54 | ractx->lpc_coef[1] = ractx->lpc_tables[1]; |
| 55 | 55 | ractx->avctx = avctx; |
| 56 | 56 | ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER, |
| 57 | − AV_LPC_TYPE_LEVINSON); | |
| 57 | + FF_LPC_TYPE_LEVINSON); | |
| 58 | 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 | 461 | 32)]; |
| 462 | 462 | |
| 463 | 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 | 465 | 0, ORDER_METHOD_EST, 12, 0); |
| 466 | 466 | for (i = 0; i < LPC_ORDER; i++) |
| 467 | 467 | block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] << |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #define AVCODEC_VERSION_H |
| 22 | 22 | |
| 23 | 23 | #define LIBAVCODEC_VERSION_MAJOR 53 |
| 24 | −#define LIBAVCODEC_VERSION_MINOR 2 | |
| 24 | +#define LIBAVCODEC_VERSION_MINOR 3 | |
| 25 | 25 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 26 | 26 | |
| 27 | 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| @@ -62,5 +62,8 @@ · 34 unmodified lines | ||
| 62 | 62 | #ifndef FF_API_OLD_FF_PICT_TYPES |
| 63 | 63 | #define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54) |
| 64 | 64 | #endif |
| 65 | +#ifndef FF_API_FLAC_GLOBAL_OPTS | |
| 66 | +#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) | |
| 67 | +#endif | |
| 65 | 68 | |
| 66 | 69 | #endif /* AVCODEC_VERSION_H */ |