]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bethsoftvideo.c
x86: ff_get_cpu_flags_x86(): Avoid a pointless variable indirection
[ffmpeg] / libavcodec / bethsoftvideo.c
index fa0457cc660a9cb9d6a254de75be50e44c3e6206..3900f7512c03a41d196a28ff2133b731d3b1ece4 100644 (file)
@@ -59,7 +59,7 @@ static int set_palette(BethsoftvidContext *ctx)
         palette[a] = bytestream2_get_be24u(&ctx->g) * 4;
     }
     ctx->frame.palette_has_changed = 1;
-    return 256*3;
+    return 0;
 }
 
 static int bethsoftvid_decode_frame(AVCodecContext *avctx,
@@ -71,14 +71,23 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
     uint8_t * dst;
     uint8_t * frame_end;
     int remaining = avctx->width;          // number of bytes remaining on a line
-    const int wrap_to_next_line = vid->frame.linesize[0] - avctx->width;
-    int code;
+    int wrap_to_next_line;
+    int code, ret;
     int yoffset;
 
     if (avctx->reget_buffer(avctx, &vid->frame)) {
         av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
         return -1;
     }
+    wrap_to_next_line = vid->frame.linesize[0] - avctx->width;
+
+    if (avpkt->side_data_elems > 0 &&
+        avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) {
+        bytestream2_init(&vid->g, avpkt->side_data[0].data,
+                         avpkt->side_data[0].size);
+        if ((ret = set_palette(vid)) < 0)
+            return ret;
+    }
 
     bytestream2_init(&vid->g, avpkt->data, avpkt->size);
     dst = vid->frame.data[0];
@@ -86,7 +95,12 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
 
     switch(block_type = bytestream2_get_byte(&vid->g)){
         case PALETTE_BLOCK: {
-            return set_palette(vid);
+            *data_size = 0;
+            if ((ret = set_palette(vid)) < 0) {
+                av_log(avctx, AV_LOG_ERROR, "error reading palette\n");
+                return ret;
+            }
+            return bytestream2_tell(&vid->g);
         }
         case VIDEO_YOFF_P_FRAME:
             yoffset = bytestream2_get_le16(&vid->g);
@@ -137,13 +151,13 @@ static av_cold int bethsoftvid_decode_end(AVCodecContext *avctx)
 }
 
 AVCodec ff_bethsoftvid_decoder = {
-    .name = "bethsoftvid",
-    .type = AVMEDIA_TYPE_VIDEO,
-    .id CODEC_ID_BETHSOFTVID,
+    .name           = "bethsoftvid",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_BETHSOFTVID,
     .priv_data_size = sizeof(BethsoftvidContext),
-    .init = bethsoftvid_decode_init,
-    .close = bethsoftvid_decode_end,
-    .decode = bethsoftvid_decode_frame,
-    .capabilities = CODEC_CAP_DR1,
-    .long_name = NULL_IF_CONFIG_SMALL("Bethesda VID video"),
+    .init           = bethsoftvid_decode_init,
+    .close          = bethsoftvid_decode_end,
+    .decode         = bethsoftvid_decode_frame,
+    .capabilities   = CODEC_CAP_DR1,
+    .long_name      = NULL_IF_CONFIG_SMALL("Bethesda VID video"),
 };