]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bfi.c
mpegaudiodec: fix short_start calculation
[ffmpeg] / libavcodec / bfi.c
index 542ba5421c879f6abcfd82a9b290764d873c6d4b..8355850183f6ffd5b456d197978eee9b292159a1 100644 (file)
@@ -39,8 +39,8 @@ typedef struct BFIContext {
 static av_cold int bfi_decode_init(AVCodecContext *avctx)
 {
     BFIContext *bfi = avctx->priv_data;
-    avctx->pix_fmt = PIX_FMT_PAL8;
-    bfi->dst = av_mallocz(avctx->width * avctx->height);
+    avctx->pix_fmt  = PIX_FMT_PAL8;
+    bfi->dst        = av_mallocz(avctx->width * avctx->height);
     return 0;
 }
 
@@ -48,9 +48,9 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
                             int *data_size, AVPacket *avpkt)
 {
     GetByteContext g;
-    int buf_size = avpkt->size;
+    int buf_size    = avpkt->size;
     BFIContext *bfi = avctx->priv_data;
-    uint8_t *dst = bfi->dst;
+    uint8_t *dst    = bfi->dst;
     uint8_t *src, *dst_offset, colour1, colour2;
     uint8_t *frame_end = bfi->dst + avctx->width * avctx->height;
     uint32_t *pal;
@@ -82,9 +82,8 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
             int shift = 16;
             *pal = 0;
             for (j = 0; j < 3; j++, shift -= 8)
-                *pal +=
-                    ((avctx->extradata[i * 3 + j] << 2) |
-                    (avctx->extradata[i * 3 + j] >> 4)) << shift;
+                *pal += ((avctx->extradata[i * 3 + j] << 2) |
+                         (avctx->extradata[i * 3 + j] >> 4)) << shift;
             pal++;
         }
         bfi->frame.palette_has_changed = 1;
@@ -107,7 +106,7 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
             return -1;
         }
 
-        /* Get length and offset(if required) */
+        /* Get length and offset (if required) */
         if (length == 0) {
             if (code == 1) {
                 length = bytestream2_get_byte(&g);
@@ -127,8 +126,7 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
             break;
 
         switch (code) {
-
-        case 0:                //Normal Chain
+        case 0:                // normal chain
             if (length >= bytestream2_get_bytes_left(&g)) {
                 av_log(avctx, AV_LOG_ERROR, "Frame larger than buffer.\n");
                 return -1;
@@ -136,21 +134,18 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
             bytestream2_get_buffer(&g, dst, length);
             dst += length;
             break;
-
-        case 1:                //Back Chain
+        case 1:                // back chain
             dst_offset = dst - offset;
-            length *= 4;        //Convert dwords to bytes.
+            length    *= 4;     // Convert dwords to bytes.
             if (dst_offset < bfi->dst)
                 break;
             while (length--)
                 *dst++ = *dst_offset++;
             break;
-
-        case 2:                //Skip Chain
+        case 2:                // skip chain
             dst += length;
             break;
-
-        case 3:                //Fill Chain
+        case 3:                // fill chain
             colour1 = bytestream2_get_byte(&g);
             colour2 = bytestream2_get_byte(&g);
             while (length--) {
@@ -158,7 +153,6 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
                 *dst++ = colour2;
             }
             break;
-
         }
     }
 
@@ -169,12 +163,12 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
         src += avctx->width;
         dst += bfi->frame.linesize[0];
     }
-    *data_size = sizeof(AVFrame);
+    *data_size       = sizeof(AVFrame);
     *(AVFrame *)data = bfi->frame;
     return buf_size;
 }
 
-static av_cold int bfi_decode_close(AVCodecContext * avctx)
+static av_cold int bfi_decode_close(AVCodecContext *avctx)
 {
     BFIContext *bfi = avctx->priv_data;
     if (bfi->frame.data[0])
@@ -184,13 +178,13 @@ static av_cold int bfi_decode_close(AVCodecContext * avctx)
 }
 
 AVCodec ff_bfi_decoder = {
-    .name = "bfi",
-    .type = AVMEDIA_TYPE_VIDEO,
-    .id CODEC_ID_BFI,
+    .name           = "bfi",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_BFI,
     .priv_data_size = sizeof(BFIContext),
-    .init = bfi_decode_init,
-    .close = bfi_decode_close,
-    .decode = bfi_decode_frame,
-    .capabilities = CODEC_CAP_DR1,
-    .long_name = NULL_IF_CONFIG_SMALL("Brute Force & Ignorance"),
+    .init           = bfi_decode_init,
+    .close          = bfi_decode_close,
+    .decode         = bfi_decode_frame,
+    .capabilities   = CODEC_CAP_DR1,
+    .long_name      = NULL_IF_CONFIG_SMALL("Brute Force & Ignorance"),
 };