History

avcodec/mlpenc: export max_interval option

Paul B Mahol committed 3 years ago

Commit 78fa1cf1 parent ee9fb281 file · +12 −12Browse files

Unified · Split

libavcodec/mlpenc.c+12−12
@@ -38,7 +38,8 @@ · 37 unmodified lines
3838 #include "mlp.h"
3939 #include "lpc.h"
4040
41−#define MAJOR_HEADER_INTERVAL 16
41+#define MIN_HEADER_INTERVAL 8
42+#define MAX_HEADER_INTERVAL 128
4243
4344 #define MLP_MIN_LPC_ORDER 1
4445 #define MLP_MAX_LPC_ORDER 8
@@ -124,6 +125,8 @@ typedef struct MLPEncodeContext { · 79 unmodified lines
124125 AVClass *class;
125126 AVCodecContext *avctx;
126127
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.
127130 int lpc_type;
128131 int lpc_passes;
129132 int prediction_order;
@@ -165,8 +168,6 @@ typedef struct MLPEncodeContext { · 35 unmodified lines
165168
166169 unsigned int one_sample_buffer_size; ///< Number of samples*channel for one access unit.
167170
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.
170171 unsigned int restart_intervals; ///< Number of possible major frame sizes.
171172
172173 uint16_t output_timing; ///< Timestamp of current access unit.
@@ -182,9 +183,9 @@ typedef struct MLPEncodeContext { · 9 unmodified lines
182183 uint8_t ch8_presentation_mod; ///< channel modifier for TrueHD stream 2
183184 RestartHeader restart_header;
184185
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];
188189
189190 unsigned int major_cur_subblock_index;
190191 unsigned int major_filter_state_subblock;
@@ -555,10 +556,8 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) · 364 unmodified lines
555556 ctx->num_channels = avctx->ch_layout.nb_channels + 2; /* +2 noise channels */
556557 ctx->one_sample_buffer_size = avctx->frame_size
557558 * ctx->num_channels;
558− /* TODO Let user pass major header interval as parameter. */
559− ctx->max_restart_interval = MAJOR_HEADER_INTERVAL;
560559
561− ctx->min_restart_interval = MAJOR_HEADER_INTERVAL;
560+ ctx->min_restart_interval = ctx->max_restart_interval;
562561 ctx->restart_intervals = ctx->max_restart_interval / ctx->min_restart_interval;
563562
564563 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
643642 /* FIXME: this works for 1 and 2 channels, but check for more */
644643 rh->max_matrix_channel = rh->max_channel;
645644
646− ctx->number_of_samples = avctx->frame_size * MAJOR_HEADER_INTERVAL;
645+ ctx->number_of_samples = avctx->frame_size * ctx->max_restart_interval;
647646
648647 if ((ret = ff_lpc_init(&ctx->lpc_ctx, ctx->number_of_samples,
649648 MLP_MAX_LPC_ORDER, ctx->lpc_type)) < 0)
@@ -1800,7 +1799,7 @@ static void rematrix_channels(MLPEncodeContext *ctx) · 1150 unmodified lines
18001799 ****************************************************************************/
18011800
18021801 typedef struct PathCounter {
1803− char path[MAJOR_HEADER_INTERVAL + 2];
1802+ char path[MAX_HEADER_INTERVAL + 2];
18041803 int cur_idx;
18051804 uint32_t bitcount;
18061805 } PathCounter;
@@ -1948,7 +1947,7 @@ static void set_major_params(MLPEncodeContext *ctx) · 141 unmodified lines
19481947 ctx->prev_decoding_params = restart_decoding_params;
19491948 ctx->prev_channel_params = restart_channel_params;
19501949
1951− for (unsigned int index = 0; index < MAJOR_HEADER_INTERVAL + 1; index++) {
1950+ for (unsigned int index = 0; index < MAX_HEADER_INTERVAL + 1; index++) {
19521951 ctx->cur_decoding_params = &ctx->b[index].major_decoding_params;
19531952 ctx->cur_channel_params = ctx->b[index].major_channel_params;
19541953
@@ -2160,6 +2159,7 @@ static av_cold int mlp_encode_close(AVCodecContext *avctx) · 205 unmodified lines
21602159 #define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
21612160 #define OFFSET(x) offsetof(MLPEncodeContext, x)
21622161 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 },
21632163 { "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" },
21642164 { "levinson", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_LEVINSON }, 0, 0, FLAGS, "lpc_type" },
21652165 { "cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_CHOLESKY }, 0, 0, FLAGS, "lpc_type" },

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