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

ramiro subversion at mplayerhq.hu
Mon Sep 1 01:51:38 CEST 2008


Author: ramiro
Date: Mon Sep  1 01:51:38 2008
New Revision: 3696

Log:
There's no need to have 1 billion *_size variables that are only used once
each.


Modified:
   mlp/mlpenc.c

Modified: mlp/mlpenc.c
==============================================================================
--- mlp/mlpenc.c	(original)
+++ mlp/mlpenc.c	Mon Sep  1 01:51:38 2008
@@ -458,14 +458,9 @@ static int mlp_sample_rate(int sample_ra
 static av_cold int mlp_encode_init(AVCodecContext *avctx)
 {
     MLPEncodeContext *ctx = avctx->priv_data;
-    unsigned int major_scratch_buffer_size;
-    unsigned int lossless_check_data_size;
-    unsigned int lpc_sample_buffer_size;
-    unsigned int decoding_params_size;
-    unsigned int channel_params_size;
-    unsigned int frame_size_size;
     unsigned int substr, index;
     unsigned int sum = 0;
+    unsigned int size;
 
     if (avctx->strict_std_compliance > -1 /* inofficial */) {
         av_log(avctx, AV_LOG_ERROR, "The bitstream generated by this encoder "
@@ -526,27 +521,27 @@ static av_cold int mlp_encode_init(AVCod
 
     /* TODO Let user pass parameters for LPC filter. */
 
-    lpc_sample_buffer_size = avctx->frame_size
+    size = avctx->frame_size
                            * ctx->max_restart_interval * sizeof(int32_t);
 
-    ctx->lpc_sample_buffer = av_malloc(lpc_sample_buffer_size);
+    ctx->lpc_sample_buffer = av_malloc(size);
     if (!ctx->lpc_sample_buffer) {
         av_log(avctx, AV_LOG_ERROR,
                "Not enough memory for buffering samples.\n");
         return -1;
     }
 
-    major_scratch_buffer_size = ctx->one_sample_buffer_size
+    size = ctx->one_sample_buffer_size
                             * ctx->max_restart_interval * sizeof(int32_t);
 
-    ctx->major_scratch_buffer = av_malloc(major_scratch_buffer_size);
+    ctx->major_scratch_buffer = av_malloc(size);
     if (!ctx->major_scratch_buffer) {
         av_log(avctx, AV_LOG_ERROR,
                "Not enough memory for buffering samples.\n");
         return -1;
     }
 
-    ctx->major_inout_buffer = av_malloc(major_scratch_buffer_size);
+    ctx->major_inout_buffer = av_malloc(size);
     if (!ctx->major_inout_buffer) {
         av_log(avctx, AV_LOG_ERROR,
                "Not enough memory for buffering samples.\n");
@@ -563,17 +558,17 @@ static av_cold int mlp_encode_init(AVCod
     ctx->mlp_channels3  = get_channels3_code(avctx->channels);
     ctx->num_substreams = 1;
 
-    frame_size_size = sizeof(unsigned int)
+    size = sizeof(unsigned int)
                     * ctx->max_restart_interval;
 
-    ctx->frame_size = av_malloc(frame_size_size);
+    ctx->frame_size = av_malloc(size);
     if (!ctx->frame_size)
         return -1;
 
-    lossless_check_data_size = sizeof(int32_t) * ctx->num_substreams
+    size = sizeof(int32_t) * ctx->num_substreams
                              * ctx->max_restart_interval;
 
-    ctx->lossless_check_data = av_malloc(lossless_check_data_size);
+    ctx->lossless_check_data = av_malloc(size);
     if (!ctx->lossless_check_data)
         return -1;
 
@@ -583,18 +578,18 @@ static av_cold int mlp_encode_init(AVCod
         sum += ctx->seq_size[index];
     }
     ctx->sequence_size = sum;
-    channel_params_size = ctx->restart_intervals * ctx->sequence_size
+    size = ctx->restart_intervals * ctx->sequence_size
                         * ctx->avctx->channels * sizeof(ChannelParams);
-    ctx->channel_params = av_malloc(channel_params_size);
+    ctx->channel_params = av_malloc(size);
     if (!ctx->channel_params) {
         av_log(avctx, AV_LOG_ERROR,
                "Not enough memory for analysis context.\n");
         return -1;
     }
 
-    decoding_params_size = ctx->restart_intervals * ctx->sequence_size
+    size = ctx->restart_intervals * ctx->sequence_size
                          * ctx->num_substreams * sizeof(DecodingParams);
-    ctx->decoding_params = av_malloc(decoding_params_size);
+    ctx->decoding_params = av_malloc(size);
     if (!ctx->decoding_params) {
         av_log(avctx, AV_LOG_ERROR,
                "Not enough memory for analysis context.\n");



More information about the FFmpeg-soc mailing list