]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/8bps.c
libxvid: Use proper context in av_log() calls
[ffmpeg] / libavcodec / 8bps.c
index ad1266f6b5cf5f3ce6ad80bd41fd99d190de0ea9..7ba2b318e3766f3f61dbd0e044bf2602c61423bb 100644 (file)
@@ -28,7 +28,6 @@
  * Supports: PAL8 (RGB 8bpp, paletted)
  *         : BGR24 (RGB 24bpp) (can also output it as RGB32)
  *         : RGB32 (RGB 32bpp, 4th plane is probably alpha and it's ignored)
- *
  */
 
 #include <stdio.h>
@@ -159,7 +158,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         c->planemap[0] = 0; // 1st plane is palette indexes
         break;
     case 24:
-        avctx->pix_fmt = avctx->get_format(avctx, pixfmt_rgb24);
+        avctx->pix_fmt = ff_get_format(avctx, pixfmt_rgb24);
         c->planes      = 3;
         c->planemap[0] = 2; // 1st plane is red
         c->planemap[1] = 1; // 2nd plane is green
@@ -168,17 +167,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
     case 32:
         avctx->pix_fmt = AV_PIX_FMT_RGB32;
         c->planes      = 4;
-#if HAVE_BIGENDIAN
-        c->planemap[0] = 1; // 1st plane is red
-        c->planemap[1] = 2; // 2nd plane is green
-        c->planemap[2] = 3; // 3rd plane is blue
-        c->planemap[3] = 0; // 4th plane is alpha???
-#else
-        c->planemap[0] = 2; // 1st plane is red
-        c->planemap[1] = 1; // 2nd plane is green
-        c->planemap[2] = 0; // 3rd plane is blue
-        c->planemap[3] = 3; // 4th plane is alpha???
-#endif
+        /* handle planemap setup later for decoding rgb24 data as rbg32 */
         break;
     default:
         av_log(avctx, AV_LOG_ERROR, "Error: Unsupported color depth: %u.\n",
@@ -186,16 +175,22 @@ static av_cold int decode_init(AVCodecContext *avctx)
         return AVERROR_INVALIDDATA;
     }
 
+    if (avctx->pix_fmt == AV_PIX_FMT_RGB32) {
+        c->planemap[0] = HAVE_BIGENDIAN ? 1 : 2; // 1st plane is red
+        c->planemap[1] = HAVE_BIGENDIAN ? 2 : 1; // 2nd plane is green
+        c->planemap[2] = HAVE_BIGENDIAN ? 3 : 0; // 3rd plane is blue
+        c->planemap[3] = HAVE_BIGENDIAN ? 0 : 3; // 4th plane is alpha???
+    }
     return 0;
 }
 
 AVCodec ff_eightbps_decoder = {
     .name           = "8bps",
+    .long_name      = NULL_IF_CONFIG_SMALL("QuickTime 8BPS video"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_8BPS,
     .priv_data_size = sizeof(EightBpsContext),
     .init           = decode_init,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
-    .long_name      = NULL_IF_CONFIG_SMALL("QuickTime 8BPS video"),
+    .capabilities   = AV_CODEC_CAP_DR1,
 };