Browse code

adxenc: use a loop to encode each channel

Justin Ruggles authored on 2011/12/20 00:18:09
Showing 1 changed files
... ...
@@ -128,6 +128,7 @@ static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame,
128 128
     ADXContext *c          = avctx->priv_data;
129 129
     const int16_t *samples = data;
130 130
     uint8_t *dst           = frame;
131
+    int ch;
131 132
 
132 133
     if (!c->header_parsed) {
133 134
         int hdrsize = adx_encode_header(avctx, dst, buf_size);
... ...
@@ -135,13 +136,9 @@ static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame,
135 135
         c->header_parsed = 1;
136 136
     }
137 137
 
138
-    if (avctx->channels == 1) {
139
-            adx_encode(c, dst, samples, c->prev, avctx->channels);
140
-            dst     += 18;
141
-    } else {
142
-            adx_encode(c, dst,      samples,     c->prev,     avctx->channels);
143
-            adx_encode(c, dst + 18, samples + 1, c->prev + 1, avctx->channels);
144
-            dst     += 18*2;
138
+    for (ch = 0; ch < avctx->channels; ch++) {
139
+        adx_encode(c, dst, samples + ch, &c->prev[ch], avctx->channels);
140
+        dst += 18;
145 141
     }
146 142
     return dst - frame;
147 143
 }