[FFmpeg-soc] [soc]: r3689 - mlp/mlpenc.c

ramiro subversion at mplayerhq.hu
Sun Aug 31 22:11:17 CEST 2008


Author: ramiro
Date: Sun Aug 31 22:11:15 2008
New Revision: 3689

Log:
Rework the way parameter buffers are used and always analyze up to
max_restart_interval access units.


Modified:
   mlp/mlpenc.c

Modified: mlp/mlpenc.c
==============================================================================
--- mlp/mlpenc.c	(original)
+++ mlp/mlpenc.c	Sun Aug 31 22:11:15 2008
@@ -123,6 +123,7 @@ typedef struct {
 
     unsigned int    max_restart_interval;   ///< Max interval of access units in between two major frames.
     unsigned int    min_restart_interval;   ///< Min interval of access units in between two major frames.
+    unsigned int    restart_intervals;      ///< Number of possible major frame sizes.
 
     uint16_t        timestamp;              ///< Timestamp of current access unit.
 
@@ -132,6 +133,8 @@ typedef struct {
     uint8_t         mlp_channels3;  /**< TODO unknown channel-related field
                                      *   These values are correct for mono and stereo. */
 
+    unsigned int    seq_size  [MAJOR_HEADER_INTERVAL];
+
     ChannelParams   channel_params[MAJOR_HEADER_INTERVAL][MAJOR_HEADER_INTERVAL][MAJOR_HEADER_INTERVAL+1][MAX_CHANNELS];
 
     BestOffset      best_offset[MAJOR_HEADER_INTERVAL+1][MAX_CHANNELS][NUM_CODEBOOKS];
@@ -452,7 +455,7 @@ static av_cold int mlp_encode_init(AVCod
     unsigned int lossless_check_data_size;
     unsigned int lpc_sample_buffer_size;
     unsigned int frame_size_size;
-    unsigned int substr;
+    unsigned int substr, index;
 
     if (avctx->strict_std_compliance > -1 /* inofficial */) {
         av_log(avctx, AV_LOG_ERROR, "The bitstream generated by this encoder "
@@ -509,6 +512,7 @@ static av_cold int mlp_encode_init(AVCod
         if (!ctx->min_restart_interval)
             ctx->min_restart_interval = 1;
     }
+    ctx->restart_intervals = ctx->max_restart_interval / ctx->min_restart_interval;
 
     /* TODO Let user pass parameters for LPC filter. */
 
@@ -563,6 +567,10 @@ static av_cold int mlp_encode_init(AVCod
     if (!ctx->lossless_check_data)
         return -1;
 
+    for (index = 0; index < ctx->restart_intervals; index++) {
+        ctx->seq_size  [index] = ((index + 1) * ctx->min_restart_interval) + 1;
+    }
+
     for (substr = 0; substr < ctx->num_substreams; substr++) {
         RestartHeader  *rh = &ctx->restart_header [substr];
 
@@ -2011,8 +2019,8 @@ static void set_major_params(MLPEncodeCo
     unsigned int index;
     unsigned int substr;
 
-    memcpy(ctx->major_channel_params, ctx->channel_params[MAJOR_HEADER_INTERVAL-1][MAJOR_HEADER_INTERVAL-1], sizeof(ctx->major_channel_params));
-    memcpy(ctx->major_decoding_params, ctx->decoding_params[MAJOR_HEADER_INTERVAL-1][MAJOR_HEADER_INTERVAL-1], sizeof(ctx->major_decoding_params));
+    memcpy(ctx->major_channel_params, ctx->channel_params[ctx->restart_intervals-1][MAJOR_HEADER_INTERVAL-1], sizeof(ctx->major_channel_params));
+    memcpy(ctx->major_decoding_params, ctx->decoding_params[ctx->restart_intervals-1][MAJOR_HEADER_INTERVAL-1], sizeof(ctx->major_decoding_params));
 
     for (substr = 0; substr < ctx->num_substreams; substr++) {
 
@@ -2022,8 +2030,8 @@ static void set_major_params(MLPEncodeCo
         ctx->prev_channel_params = restart_channel_params;
 
         for (index = 0; index < MAJOR_HEADER_INTERVAL + 1; index++) {
-                ctx->cur_decoding_params = &ctx->decoding_params[MAJOR_HEADER_INTERVAL-1][MAJOR_HEADER_INTERVAL-1][index][substr];
-                ctx->cur_channel_params = ctx->channel_params[MAJOR_HEADER_INTERVAL-1][MAJOR_HEADER_INTERVAL-1][index];
+                ctx->cur_decoding_params = &ctx->decoding_params[ctx->restart_intervals-1][MAJOR_HEADER_INTERVAL-1][index][substr];
+                ctx->cur_channel_params = ctx->channel_params[ctx->restart_intervals-1][MAJOR_HEADER_INTERVAL-1][index];
 
                 ctx->major_params_changed[index][substr] = compare_decoding_params(ctx);
 
@@ -2176,9 +2184,9 @@ input_and_return:
     if (!restart_frame) {
     int seq_index;
 
-    for (seq_index  = ctx->frame_index;
-         seq_index  > 0;
-         seq_index -= ctx->min_restart_interval) {
+    for (seq_index = 0;
+         seq_index < ctx->restart_intervals && (seq_index * ctx->min_restart_interval) <= ctx->avctx->frame_number;
+         seq_index++) {
         unsigned int number_of_samples = 0;
         unsigned int index;
 
@@ -2186,8 +2194,9 @@ input_and_return:
         ctx->inout_buffer = ctx->major_inout_buffer;
         ctx->seq_index = seq_index;
 
-        ctx->starting_frame_index = ctx->frame_index - seq_index;
-        ctx->number_of_frames = seq_index + 1;
+        ctx->starting_frame_index = (ctx->avctx->frame_number - (ctx->avctx->frame_number % ctx->min_restart_interval)
+                                  - (seq_index * ctx->min_restart_interval)) % ctx->max_restart_interval;
+        ctx->number_of_frames = ctx->seq_size[seq_index] - 1;
 
         for (index = 0; index < ctx->number_of_frames; index++) {
             number_of_samples += ctx->frame_size[(ctx->starting_frame_index + index) % ctx->max_restart_interval];



More information about the FFmpeg-soc mailing list