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
38#include "mlp.h"38#include "mlp.h"
39#include "lpc.h"39#include "lpc.h"
40 40
41#define MAJOR_HEADER_INTERVAL 1641#define MIN_HEADER_INTERVAL 8
42#define MAX_HEADER_INTERVAL 128
42 43
43#define MLP_MIN_LPC_ORDER 144#define MLP_MIN_LPC_ORDER 1
44#define MLP_MAX_LPC_ORDER 845#define MLP_MAX_LPC_ORDER 8
@@ -124,6 +125,8 @@ typedef struct MLPEncodeContext { · 79 unmodified lines
124 AVClass *class;125 AVClass *class;
125 AVCodecContext *avctx;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 int lpc_type;130 int lpc_type;
128 int lpc_passes;131 int lpc_passes;
129 int prediction_order;132 int prediction_order;
@@ -165,8 +168,6 @@ typedef struct MLPEncodeContext { · 35 unmodified lines
165 168
166 unsigned int one_sample_buffer_size; ///< Number of samples*channel for one access unit.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 unsigned int restart_intervals; ///< Number of possible major frame sizes.171 unsigned int restart_intervals; ///< Number of possible major frame sizes.
171 172
172 uint16_t output_timing; ///< Timestamp of current access unit.173 uint16_t output_timing; ///< Timestamp of current access unit.
@@ -182,9 +183,9 @@ typedef struct MLPEncodeContext { · 9 unmodified lines
182 uint8_t ch8_presentation_mod; ///< channel modifier for TrueHD stream 2183 uint8_t ch8_presentation_mod; ///< channel modifier for TrueHD stream 2
183 RestartHeader restart_header;184 RestartHeader restart_header;
184 185
185 MLPBlock b[MAJOR_HEADER_INTERVAL + 1];186 MLPBlock b[MAX_HEADER_INTERVAL + 1];
186 int32_t lpc_sample_buffer[MAJOR_HEADER_INTERVAL * MAX_BLOCKSIZE];187 int32_t lpc_sample_buffer[MAX_HEADER_INTERVAL * MAX_BLOCKSIZE];
187 int32_t filter_state_buffer[NUM_FILTERS][MAX_BLOCKSIZE * MAJOR_HEADER_INTERVAL];188 int32_t filter_state_buffer[NUM_FILTERS][MAX_BLOCKSIZE * MAX_HEADER_INTERVAL];
188 189
189 unsigned int major_cur_subblock_index;190 unsigned int major_cur_subblock_index;
190 unsigned int major_filter_state_subblock;191 unsigned int major_filter_state_subblock;
@@ -555,10 +556,8 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) · 364 unmodified lines
555 ctx->num_channels = avctx->ch_layout.nb_channels + 2; /* +2 noise channels */556 ctx->num_channels = avctx->ch_layout.nb_channels + 2; /* +2 noise channels */
556 ctx->one_sample_buffer_size = avctx->frame_size557 ctx->one_sample_buffer_size = avctx->frame_size
557 * ctx->num_channels;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 ctx->restart_intervals = ctx->max_restart_interval / ctx->min_restart_interval;561 ctx->restart_intervals = ctx->max_restart_interval / ctx->min_restart_interval;
563 562
564 size = ctx->one_sample_buffer_size * ctx->max_restart_interval;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 /* FIXME: this works for 1 and 2 channels, but check for more */642 /* FIXME: this works for 1 and 2 channels, but check for more */
644 rh->max_matrix_channel = rh->max_channel;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 if ((ret = ff_lpc_init(&ctx->lpc_ctx, ctx->number_of_samples,647 if ((ret = ff_lpc_init(&ctx->lpc_ctx, ctx->number_of_samples,
649 MLP_MAX_LPC_ORDER, ctx->lpc_type)) < 0)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
1802typedef struct PathCounter {1801typedef struct PathCounter {
1803 char path[MAJOR_HEADER_INTERVAL + 2];1802 char path[MAX_HEADER_INTERVAL + 2];
1804 int cur_idx;1803 int cur_idx;
1805 uint32_t bitcount;1804 uint32_t bitcount;
1806} PathCounter;1805} PathCounter;
@@ -1948,7 +1947,7 @@ static void set_major_params(MLPEncodeContext *ctx) · 141 unmodified lines
1948 ctx->prev_decoding_params = restart_decoding_params;1947 ctx->prev_decoding_params = restart_decoding_params;
1949 ctx->prev_channel_params = restart_channel_params;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 ctx->cur_decoding_params = &ctx->b[index].major_decoding_params;1951 ctx->cur_decoding_params = &ctx->b[index].major_decoding_params;
1953 ctx->cur_channel_params = ctx->b[index].major_channel_params;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#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM2159#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
2161#define OFFSET(x) offsetof(MLPEncodeContext, x)2160#define OFFSET(x) offsetof(MLPEncodeContext, x)
2162static const AVOption mlp_options[] = {2161static 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{ "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" },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{ "levinson", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_LEVINSON }, 0, 0, FLAGS, "lpc_type" },2164{ "levinson", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_LEVINSON }, 0, 0, FLAGS, "lpc_type" },
2165{ "cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_CHOLESKY }, 0, 0, FLAGS, "lpc_type" },2165{ "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