Unified · Split
| @@ -38,7 +38,8 @@ · 37 unmodified lines | ||
| 38 | 38 | #include "mlp.h" |
| 39 | 39 | #include "lpc.h" |
| 40 | 40 | |
| 41 | −#define MAJOR_HEADER_INTERVAL 16 | |
| 41 | +#define MIN_HEADER_INTERVAL 8 | |
| 42 | +#define MAX_HEADER_INTERVAL 128 | |
| 42 | 43 | |
| 43 | 44 | #define MLP_MIN_LPC_ORDER 1 |
| 44 | 45 | #define MLP_MAX_LPC_ORDER 8 |
| @@ -124,6 +125,8 @@ typedef struct MLPEncodeContext { · 79 unmodified lines | ||
| 124 | 125 | AVClass *class; |
| 125 | 126 | AVCodecContext *avctx; |
| 126 | 127 | |
| 128 | + int max_restart_interval; ///< Max interval of access units in between two major frames. | |
| 129 | + int min_restart_interval; ///< Min interval of access units in between two major frames. | |
| 127 | 130 | int lpc_type; |
| 128 | 131 | int lpc_passes; |
| 129 | 132 | int prediction_order; |
| @@ -165,8 +168,6 @@ typedef struct MLPEncodeContext { · 35 unmodified lines | ||
| 165 | 168 | |
| 166 | 169 | unsigned int one_sample_buffer_size; ///< Number of samples*channel for one access unit. |
| 167 | 170 | |
| 168 | − unsigned int max_restart_interval; ///< Max interval of access units in between two major frames. | |
| 169 | − unsigned int min_restart_interval; ///< Min interval of access units in between two major frames. | |
| 170 | 171 | unsigned int restart_intervals; ///< Number of possible major frame sizes. |
| 171 | 172 | |
| 172 | 173 | uint16_t output_timing; ///< Timestamp of current access unit. |
| @@ -182,9 +183,9 @@ typedef struct MLPEncodeContext { · 9 unmodified lines | ||
| 182 | 183 | uint8_t ch8_presentation_mod; ///< channel modifier for TrueHD stream 2 |
| 183 | 184 | RestartHeader restart_header; |
| 184 | 185 | |
| 185 | − MLPBlock b[MAJOR_HEADER_INTERVAL + 1]; | |
| 186 | − int32_t lpc_sample_buffer[MAJOR_HEADER_INTERVAL * MAX_BLOCKSIZE]; | |
| 187 | − int32_t filter_state_buffer[NUM_FILTERS][MAX_BLOCKSIZE * MAJOR_HEADER_INTERVAL]; | |
| 186 | + MLPBlock b[MAX_HEADER_INTERVAL + 1]; | |
| 187 | + int32_t lpc_sample_buffer[MAX_HEADER_INTERVAL * MAX_BLOCKSIZE]; | |
| 188 | + int32_t filter_state_buffer[NUM_FILTERS][MAX_BLOCKSIZE * MAX_HEADER_INTERVAL]; | |
| 188 | 189 | |
| 189 | 190 | unsigned int major_cur_subblock_index; |
| 190 | 191 | unsigned int major_filter_state_subblock; |
| @@ -555,10 +556,8 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) · 364 unmodified lines | ||
| 555 | 556 | ctx->num_channels = avctx->ch_layout.nb_channels + 2; /* +2 noise channels */ |
| 556 | 557 | ctx->one_sample_buffer_size = avctx->frame_size |
| 557 | 558 | * ctx->num_channels; |
| 558 | − /* TODO Let user pass major header interval as parameter. */ | |
| 559 | − ctx->max_restart_interval = MAJOR_HEADER_INTERVAL; | |
| 560 | 559 | |
| 561 | − ctx->min_restart_interval = MAJOR_HEADER_INTERVAL; | |
| 560 | + ctx->min_restart_interval = ctx->max_restart_interval; | |
| 562 | 561 | ctx->restart_intervals = ctx->max_restart_interval / ctx->min_restart_interval; |
| 563 | 562 | |
| 564 | 563 | size = ctx->one_sample_buffer_size * ctx->max_restart_interval; |
| @@ -643,7 +642,7 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) · 78 unmodified lines | ||
| 643 | 642 | /* FIXME: this works for 1 and 2 channels, but check for more */ |
| 644 | 643 | rh->max_matrix_channel = rh->max_channel; |
| 645 | 644 | |
| 646 | − ctx->number_of_samples = avctx->frame_size * MAJOR_HEADER_INTERVAL; | |
| 645 | + ctx->number_of_samples = avctx->frame_size * ctx->max_restart_interval; | |
| 647 | 646 | |
| 648 | 647 | if ((ret = ff_lpc_init(&ctx->lpc_ctx, ctx->number_of_samples, |
| 649 | 648 | MLP_MAX_LPC_ORDER, ctx->lpc_type)) < 0) |
| @@ -1800,7 +1799,7 @@ static void rematrix_channels(MLPEncodeContext *ctx) · 1150 unmodified lines | ||
| 1800 | 1799 | ****************************************************************************/ |
| 1801 | 1800 | |
| 1802 | 1801 | typedef struct PathCounter { |
| 1803 | − char path[MAJOR_HEADER_INTERVAL + 2]; | |
| 1802 | + char path[MAX_HEADER_INTERVAL + 2]; | |
| 1804 | 1803 | int cur_idx; |
| 1805 | 1804 | uint32_t bitcount; |
| 1806 | 1805 | } PathCounter; |
| @@ -1948,7 +1947,7 @@ static void set_major_params(MLPEncodeContext *ctx) · 141 unmodified lines | ||
| 1948 | 1947 | ctx->prev_decoding_params = restart_decoding_params; |
| 1949 | 1948 | ctx->prev_channel_params = restart_channel_params; |
| 1950 | 1949 | |
| 1951 | − for (unsigned int index = 0; index < MAJOR_HEADER_INTERVAL + 1; index++) { | |
| 1950 | + for (unsigned int index = 0; index < MAX_HEADER_INTERVAL + 1; index++) { | |
| 1952 | 1951 | ctx->cur_decoding_params = &ctx->b[index].major_decoding_params; |
| 1953 | 1952 | ctx->cur_channel_params = ctx->b[index].major_channel_params; |
| 1954 | 1953 | |
| @@ -2160,6 +2159,7 @@ static av_cold int mlp_encode_close(AVCodecContext *avctx) · 205 unmodified lines | ||
| 2160 | 2159 | #define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM |
| 2161 | 2160 | #define OFFSET(x) offsetof(MLPEncodeContext, x) |
| 2162 | 2161 | static const AVOption mlp_options[] = { |
| 2162 | +{ "max_interval", "Max number of frames between each new header", OFFSET(max_restart_interval), AV_OPT_TYPE_INT, {.i64 = 16 }, MIN_HEADER_INTERVAL, MAX_HEADER_INTERVAL, FLAGS }, | |
| 2163 | 2163 | { "lpc_type", "LPC algorithm", OFFSET(lpc_type), AV_OPT_TYPE_INT, {.i64 = FF_LPC_TYPE_LEVINSON }, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_CHOLESKY, FLAGS, "lpc_type" }, |
| 2164 | 2164 | { "levinson", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_LEVINSON }, 0, 0, FLAGS, "lpc_type" }, |
| 2165 | 2165 | { "cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_CHOLESKY }, 0, 0, FLAGS, "lpc_type" }, |