]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/liba52.c
write actual min and max frame size to FLAC header. update regression test checksum.
[ffmpeg] / libavcodec / liba52.c
index 81dcf6aef0f83393cd40b8bd9097f166be6aaaaa..ec0a252b5fe3839c7148bbda0325ca7b4f5f537a 100644 (file)
@@ -77,7 +77,7 @@ static void* dlsymm(void* handle, const char* symbol)
 }
 #endif
 
-static int a52_decode_init(AVCodecContext *avctx)
+static av_cold int a52_decode_init(AVCodecContext *avctx)
 {
     AC3DecodeState *s = avctx->priv_data;
 
@@ -119,6 +119,7 @@ static int a52_decode_init(AVCodecContext *avctx)
         avctx->channels = avctx->request_channels;
     }
 
+    avctx->sample_fmt = SAMPLE_FMT_S16;
     return 0;
 }
 
@@ -160,50 +161,50 @@ static int a52_decode_frame(AVCodecContext *avctx,
         return -1;
     }
     len = s->a52_syncinfo(buf, &s->flags, &sample_rate, &bit_rate);
-                if (len == 0) {
-                    av_log(avctx, AV_LOG_ERROR, "Error decoding frame, no sync byte at begin\n");
-                    return -1;
-                }
+    if (len == 0) {
+        av_log(avctx, AV_LOG_ERROR, "Error decoding frame, no sync byte at begin\n");
+        return -1;
+    }
     if (buf_size < len) {
         av_log(avctx, AV_LOG_ERROR, "Error decoding frame, not enough bytes\n");
         return -1;
     }
-                    /* update codec info */
-                    avctx->sample_rate = sample_rate;
-                    s->channels = ac3_channels[s->flags & 7];
-                    if (s->flags & A52_LFE)
-                        s->channels++;
-                    if (avctx->request_channels > 0 &&
-                            avctx->request_channels <= 2 &&
-                            avctx->request_channels < s->channels) {
-                        avctx->channels = avctx->request_channels;
-                    } else {
-                        avctx->channels = s->channels;
-                    }
-                    avctx->bit_rate = bit_rate;
-            flags = s->flags;
-            if (avctx->channels == 1)
-                flags = A52_MONO;
-            else if (avctx->channels == 2)
-                flags = A52_STEREO;
-            else
-                flags |= A52_ADJUST_LEVEL;
-            level = 1;
-            if (s->a52_frame(s->state, buf, &flags, &level, 384)) {
-            fail:
-                av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
-                return -1;
-            }
-            for (i = 0; i < 6; i++) {
-                if (s->a52_block(s->state))
-                    goto fail;
-                float_to_int(s->samples, out_samples + i * 256 * avctx->channels, avctx->channels);
-            }
-            *data_size = 6 * avctx->channels * 256 * sizeof(int16_t);
+    /* update codec info */
+    avctx->sample_rate = sample_rate;
+    s->channels = ac3_channels[s->flags & 7];
+    if (s->flags & A52_LFE)
+            s->channels++;
+    if (avctx->request_channels > 0 &&
+        avctx->request_channels <= 2 &&
+        avctx->request_channels < s->channels) {
+        avctx->channels = avctx->request_channels;
+    } else {
+        avctx->channels = s->channels;
+    }
+    avctx->bit_rate = bit_rate;
+    flags = s->flags;
+    if (avctx->channels == 1)
+        flags = A52_MONO;
+    else if (avctx->channels == 2)
+        flags = A52_STEREO;
+    else
+        flags |= A52_ADJUST_LEVEL;
+    level = 1;
+    if (s->a52_frame(s->state, buf, &flags, &level, 384)) {
+    fail:
+        av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
+        return -1;
+    }
+    for (i = 0; i < 6; i++) {
+        if (s->a52_block(s->state))
+            goto fail;
+        float_to_int(s->samples, out_samples + i * 256 * avctx->channels, avctx->channels);
+    }
+    *data_size = 6 * avctx->channels * 256 * sizeof(int16_t);
     return len;
 }
 
-static int a52_decode_end(AVCodecContext *avctx)
+static av_cold int a52_decode_end(AVCodecContext *avctx)
 {
     AC3DecodeState *s = avctx->priv_data;
     s->a52_free(s->state);
@@ -222,4 +223,5 @@ AVCodec liba52_decoder = {
     NULL,
     a52_decode_end,
     a52_decode_frame,
+    .long_name = NULL_IF_CONFIG_SMALL("liba52 ATSC A/52 / AC-3"),
 };