changeset 4479:f1057be02298 libavcodec

cosmetics: don't needlessly open new blocks
author mru
date Mon, 05 Feb 2007 19:55:15 +0000
parents ca8c6efd00d3
children 3a31e2fc1b9b
files dtsdec.c
diffstat 1 files changed, 40 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/dtsdec.c	Mon Feb 05 19:35:36 2007 +0000
+++ b/dtsdec.c	Mon Feb 05 19:55:15 2007 +0000
@@ -208,10 +208,15 @@
     int bit_rate;
     int len;
     dts_state_t *state = avctx->priv_data;
+    level_t level;
+    sample_t bias;
+    int i;
 
     *data_size = 0;
 
     while(1) {
+        int length;
+
         len = end - start;
         if(!len)
             break;
@@ -225,60 +230,50 @@
         if(bufpos != buf + HEADER_SIZE)
             break;
 
-        {
-            int length;
+        length = dts_syncinfo(state, buf, &flags, &sample_rate, &bit_rate,
+                              &frame_length);
+        if(!length) {
+            av_log(NULL, AV_LOG_INFO, "skip\n");
+            for(bufptr = buf; bufptr < buf + HEADER_SIZE - 1; bufptr++)
+                bufptr[0] = bufptr[1];
+            continue;
+        }
+        bufpos = buf + length;
+    }
 
-            length =
-                dts_syncinfo(state, buf, &flags, &sample_rate, &bit_rate,
-                             &frame_length);
-            if(!length) {
-                av_log(NULL, AV_LOG_INFO, "skip\n");
-                for(bufptr = buf; bufptr < buf + HEADER_SIZE - 1; bufptr++)
-                    bufptr[0] = bufptr[1];
-                continue;
-            }
-            bufpos = buf + length;
-        }
+    flags = 2;              /* ???????????? */
+    level = CONVERT_LEVEL;
+    bias = CONVERT_BIAS;
+
+    flags |= DTS_ADJUST_LEVEL;
+    if(dts_frame(state, buf, &flags, &level, bias)) {
+        av_log(avctx, AV_LOG_ERROR, "dts_frame() failed\n");
+        goto end;
     }
 
-    {
-        level_t level;
-        sample_t bias;
-        int i;
+    avctx->sample_rate = sample_rate;
+    avctx->channels = channels_multi(flags);
+    avctx->bit_rate = bit_rate;
 
-        flags = 2;              /* ???????????? */
-        level = CONVERT_LEVEL;
-        bias = CONVERT_BIAS;
+    for(i = 0; i < dts_blocks_num(state); i++) {
+        int chans;
 
-        flags |= DTS_ADJUST_LEVEL;
-        if(dts_frame(state, buf, &flags, &level, bias))
-            goto error;
-        avctx->sample_rate = sample_rate;
-        avctx->channels = channels_multi(flags);
-        avctx->bit_rate = bit_rate;
-        for(i = 0; i < dts_blocks_num(state); i++) {
-            if(dts_block(state))
-                goto error;
-            {
-                int chans;
+        if(dts_block(state)) {
+            av_log(avctx, AV_LOG_ERROR, "dts_block() failed\n");
+            goto end;
+        }
 
-                chans = channels_multi(flags);
-                convert2s16_multi(dts_samples(state), out_samples,
-                                  flags & (DTS_CHANNEL_MASK | DTS_LFE));
+        chans = channels_multi(flags);
+        convert2s16_multi(dts_samples(state), out_samples,
+                          flags & (DTS_CHANNEL_MASK | DTS_LFE));
 
-                out_samples += 256 * chans;
-                *data_size += 256 * sizeof(int16_t) * chans;
-            }
-        }
-        bufptr = buf;
-        bufpos = buf + HEADER_SIZE;
-        return start - buff;
-      error:
-        av_log(NULL, AV_LOG_ERROR, "error\n");
-        bufptr = buf;
-        bufpos = buf + HEADER_SIZE;
+        out_samples += 256 * chans;
+        *data_size += 256 * sizeof(int16_t) * chans;
     }
 
+end:
+    bufptr = buf;
+    bufpos = buf + HEADER_SIZE;
     return start - buff;
 }