]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/tiertexseqv.c
matroskadec: remove some unused ebml funcs
[ffmpeg] / libavcodec / tiertexseqv.c
index 85d585ea8f11122e29d353c7c724b0ab38078e8e..3ff353555d3175e96a82d77b6f82d17ae5807259 100644 (file)
 typedef struct SeqVideoContext {
     AVCodecContext *avctx;
     AVFrame frame;
-    unsigned int palette[256];
-    unsigned char block[8 * 8];
 } SeqVideoContext;
 
 
-static unsigned char *seq_unpack_rle_block(unsigned char *src, unsigned char *dst, int dst_size)
+static const unsigned char *seq_unpack_rle_block(const unsigned char *src, unsigned char *dst, int dst_size)
 {
     int i, len, sz;
     GetBitContext gb;
@@ -67,27 +65,28 @@ static unsigned char *seq_unpack_rle_block(unsigned char *src, unsigned char *ds
     return src;
 }
 
-static unsigned char *seq_decode_op1(SeqVideoContext *seq, unsigned char *src, unsigned char *dst)
+static const unsigned char *seq_decode_op1(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
 {
-    unsigned char *color_table;
+    const unsigned char *color_table;
     int b, i, len, bits;
     GetBitContext gb;
+    unsigned char block[8 * 8];
 
     len = *src++;
     if (len & 0x80) {
         switch (len & 3) {
         case 1:
-            src = seq_unpack_rle_block(src, seq->block, sizeof(seq->block));
+            src = seq_unpack_rle_block(src, block, sizeof(block));
             for (b = 0; b < 8; b++) {
-                memcpy(dst, &seq->block[b * 8], 8);
+                memcpy(dst, &block[b * 8], 8);
                 dst += seq->frame.linesize[0];
             }
             break;
         case 2:
-            src = seq_unpack_rle_block(src, seq->block, sizeof(seq->block));
+            src = seq_unpack_rle_block(src, block, sizeof(block));
             for (i = 0; i < 8; i++) {
                 for (b = 0; b < 8; b++)
-                    dst[b * seq->frame.linesize[0]] = seq->block[i * 8 + b];
+                    dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
                 ++dst;
             }
             break;
@@ -107,7 +106,7 @@ static unsigned char *seq_decode_op1(SeqVideoContext *seq, unsigned char *src, u
     return src;
 }
 
-static unsigned char *seq_decode_op2(SeqVideoContext *seq, unsigned char *src, unsigned char *dst)
+static const unsigned char *seq_decode_op2(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
 {
     int i;
 
@@ -120,7 +119,7 @@ static unsigned char *seq_decode_op2(SeqVideoContext *seq, unsigned char *src, u
     return src;
 }
 
-static unsigned char *seq_decode_op3(SeqVideoContext *seq, unsigned char *src, unsigned char *dst)
+static const unsigned char *seq_decode_op3(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst)
 {
     int pos, offset;
 
@@ -133,22 +132,23 @@ static unsigned char *seq_decode_op3(SeqVideoContext *seq, unsigned char *src, u
     return src;
 }
 
-static void seqvideo_decode(SeqVideoContext *seq, unsigned char *data, int data_size)
+static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size)
 {
     GetBitContext gb;
     int flags, i, j, x, y, op;
     unsigned char c[3];
     unsigned char *dst;
+    uint32_t *palette;
 
     flags = *data++;
 
     if (flags & 1) {
+        palette = (uint32_t *)seq->frame.data[1];
         for (i = 0; i < 256; i++) {
             for (j = 0; j < 3; j++, data++)
                 c[j] = (*data << 2) | (*data >> 4);
-            seq->palette[i] = (c[0] << 16) | (c[1] << 8) | c[2];
+            palette[i] = AV_RB24(c);
         }
-        memcpy(seq->frame.data[1], seq->palette, sizeof(seq->palette));
         seq->frame.palette_has_changed = 1;
     }
 
@@ -173,7 +173,7 @@ static void seqvideo_decode(SeqVideoContext *seq, unsigned char *data, int data_
     }
 }
 
-static int seqvideo_decode_init(AVCodecContext *avctx)
+static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
 {
     SeqVideoContext *seq = avctx->priv_data;
 
@@ -187,7 +187,7 @@ static int seqvideo_decode_init(AVCodecContext *avctx)
 
 static int seqvideo_decode_frame(AVCodecContext *avctx,
                                  void *data, int *data_size,
-                                 uint8_t *buf, int buf_size)
+                                 const uint8_t *buf, int buf_size)
 {
 
     SeqVideoContext *seq = avctx->priv_data;
@@ -207,7 +207,7 @@ static int seqvideo_decode_frame(AVCodecContext *avctx,
     return buf_size;
 }
 
-static int seqvideo_decode_end(AVCodecContext *avctx)
+static av_cold int seqvideo_decode_end(AVCodecContext *avctx)
 {
     SeqVideoContext *seq = avctx->priv_data;
 
@@ -227,4 +227,5 @@ AVCodec tiertexseqvideo_decoder = {
     seqvideo_decode_end,
     seqvideo_decode_frame,
     CODEC_CAP_DR1,
+    .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ video"),
 };