]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rscc.c
lavf/segment: fix writing separate header with auto BSF
[ffmpeg] / libavcodec / rscc.c
index fe0df2eec1d6fd151ed5251744bc753671f2cf47..7f280a9a973b816bec5883d349e1fc9b144fb70c 100644 (file)
@@ -31,7 +31,7 @@
  * and it can be deflated or not. Similarly, pixel data comes after the header
  * and a variable size value, and it can be deflated or just raw.
  *
- * Supports: BGRA, BGR24, RGB555, RGB8
+ * Supports: BGRA, BGR24, RGB555, PAL8
  */
 
 #include <stdint.h>
@@ -58,6 +58,7 @@ typedef struct RsccContext {
     Tile *tiles;
     unsigned int tiles_size;
     int component_size;
+    uint32_t pal[AVPALETTE_COUNT];
 
     /* zlib interaction */
     uint8_t *inflated_buf;
@@ -89,8 +90,8 @@ static av_cold int rscc_init(AVCodecContext *avctx)
         ctx->component_size = avctx->bits_per_coded_sample / 8;
         switch (avctx->bits_per_coded_sample) {
         case 8:
-            avpriv_report_missing_feature(avctx, "8 bits per pixel");
-            return AVERROR_PATCHWELCOME;
+            avctx->pix_fmt = AV_PIX_FMT_PAL8;
+            break;
         case 16:
             avctx->pix_fmt = AV_PIX_FMT_RGB555LE;
             break;
@@ -98,7 +99,7 @@ static av_cold int rscc_init(AVCodecContext *avctx)
             avctx->pix_fmt = AV_PIX_FMT_BGR24;
             break;
         case 32:
-            avctx->pix_fmt = AV_PIX_FMT_BGRA;
+            avctx->pix_fmt = AV_PIX_FMT_BGR0;
             break;
         default:
             av_log(avctx, AV_LOG_ERROR, "Invalid bits per pixel value (%d)\n",
@@ -308,6 +309,16 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
     } else {
         frame->pict_type = AV_PICTURE_TYPE_P;
     }
+    if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
+        const uint8_t *pal = av_packet_get_side_data(avpkt,
+                                                     AV_PKT_DATA_PALETTE,
+                                                     NULL);
+        if (pal) {
+            frame->palette_has_changed = 1;
+            memcpy(ctx->pal, pal, AVPALETTE_SIZE);
+        }
+        memcpy (frame->data[1], ctx->pal, AVPALETTE_SIZE);
+    }
     *got_frame = 1;
 
 end: