[FFmpeg-soc] [soc]: r3592 - mlp/mlpenc.c
ramiro
subversion at mplayerhq.hu
Sun Aug 24 20:26:59 CEST 2008
Author: ramiro
Date: Sun Aug 24 20:26:59 2008
New Revision: 3592
Log:
Split analyze_sample_buffer() out of mlp_encode_frame().
Modified:
mlp/mlpenc.c
Modified: mlp/mlpenc.c
==============================================================================
--- mlp/mlpenc.c (original)
+++ mlp/mlpenc.c Sun Aug 24 20:26:59 2008
@@ -1688,12 +1688,58 @@ static void set_major_params(MLPEncodeCo
memcpy(ctx->major_params_changed, ctx->params_changed[0], sizeof(ctx->major_params_changed));
}
+static void analyze_sample_buffer(MLPEncodeContext *ctx)
+{
+ unsigned int index, subblock;
+ unsigned int substr;
+
+ for (substr = 0; substr < ctx->num_substreams; substr++) {
+ unsigned int num_subblocks = 1;
+
+ ctx->cur_restart_header = &ctx->restart_header[substr];
+
+ ctx->prev_decoding_params = &ctx->restart_decoding_params[substr];
+ ctx->prev_channel_params = ctx->restart_channel_params;
+
+ for (subblock = 0; subblock < MAX_SUBBLOCKS; subblock++)
+ for (index = 0; index < ctx->number_of_frames; index++) {
+ DecodingParams *dp = &ctx->decoding_params[ctx->frame_index][index][subblock][substr];
+ dp->blocksize = ctx->frame_size[index];
+ }
+ ctx->decoding_params[ctx->frame_index][0][0][substr].blocksize = 8;
+ ctx->decoding_params[ctx->frame_index][0][1][substr].blocksize = ctx->frame_size[ctx->frame_index] - 8;
+
+ ctx->cur_decoding_params = &ctx->decoding_params[ctx->frame_index][0][1][substr];
+ ctx->cur_channel_params = ctx->channel_params[ctx->frame_index][0][1];
+
+ lossless_matrix_coeffs (ctx);
+ rematrix_channels (ctx);
+ determine_quant_step_size(ctx);
+ determine_filters (ctx);
+
+ copy_restart_frame_params(ctx, substr);
+
+ for (index = 0; index < ctx->number_of_frames; index++) {
+ for (subblock = 0; subblock <= num_subblocks; subblock++) {
+ ctx->cur_decoding_params = &ctx->decoding_params[ctx->frame_index][index][subblock][substr];
+ ctx->cur_channel_params = ctx->channel_params[ctx->frame_index][index][subblock];
+ determine_bits(ctx);
+ ctx->sample_buffer += ctx->cur_decoding_params->blocksize * ctx->num_channels;
+ if (subblock)
+ num_subblocks = 0;
+ ctx->params_changed[ctx->frame_index][index][subblock][substr] = compare_decoding_params(ctx);
+ ctx->prev_decoding_params = ctx->cur_decoding_params;
+ ctx->prev_channel_params = ctx->cur_channel_params;
+ }
+ }
+ }
+}
+
static int mlp_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size,
void *data)
{
MLPEncodeContext *ctx = avctx->priv_data;
unsigned int bytes_written = 0;
- unsigned int substr;
int restart_frame;
ctx->frame_index = avctx->frame_number % ctx->major_header_interval;
@@ -1776,46 +1822,7 @@ input_and_return:
input_to_sample_buffer(ctx);
- for (substr = 0; substr < ctx->num_substreams; substr++) {
- unsigned int num_subblocks = 1;
-
- ctx->cur_restart_header = &ctx->restart_header[substr];
-
- ctx->prev_decoding_params = &ctx->restart_decoding_params[substr];
- ctx->prev_channel_params = ctx->restart_channel_params;
-
- for (subblock = 0; subblock < MAX_SUBBLOCKS; subblock++)
- for (index = 0; index < ctx->number_of_frames; index++) {
- DecodingParams *dp = &ctx->decoding_params[ctx->frame_index][index][subblock][substr];
- dp->blocksize = ctx->frame_size[index];
- }
- ctx->decoding_params[ctx->frame_index][0][0][substr].blocksize = 8;
- ctx->decoding_params[ctx->frame_index][0][1][substr].blocksize = ctx->frame_size[ctx->frame_index] - 8;
-
- ctx->cur_decoding_params = &ctx->decoding_params[ctx->frame_index][0][1][substr];
- ctx->cur_channel_params = ctx->channel_params[ctx->frame_index][0][1];
-
- lossless_matrix_coeffs (ctx);
- rematrix_channels (ctx);
- determine_quant_step_size(ctx);
- determine_filters (ctx);
-
- copy_restart_frame_params(ctx, substr);
-
- for (index = 0; index < ctx->number_of_frames; index++) {
- for (subblock = 0; subblock <= num_subblocks; subblock++) {
- ctx->cur_decoding_params = &ctx->decoding_params[ctx->frame_index][index][subblock][substr];
- ctx->cur_channel_params = ctx->channel_params[ctx->frame_index][index][subblock];
- determine_bits(ctx);
- ctx->sample_buffer += ctx->cur_decoding_params->blocksize * ctx->num_channels;
- if (subblock)
- num_subblocks = 0;
- ctx->params_changed[ctx->frame_index][index][subblock][substr] = compare_decoding_params(ctx);
- ctx->prev_decoding_params = ctx->cur_decoding_params;
- ctx->prev_channel_params = ctx->cur_channel_params;
- }
- }
- }
+ analyze_sample_buffer(ctx);
}
return bytes_written;
More information about the FFmpeg-soc
mailing list