]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/sunrast.c
lavc: move SANE_NB_CHANNELS to internal.h and use it in the PCM decoders
[ffmpeg] / libavcodec / sunrast.c
index fef17b4054f42299ca66ed48708e70434d56ca6e..a10f44964817947d1558f5e8324c8723be7accb3 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
@@ -77,7 +78,11 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
         av_log(avctx, AV_LOG_ERROR, "invalid image size\n");
         return AVERROR_INVALIDDATA;
     }
-    if (maptype & ~1) {
+    if (maptype == RMT_RAW) {
+        av_log_ask_for_sample(avctx, "unsupported colormap type\n");
+        return AVERROR_PATCHWELCOME;
+    }
+    if (maptype > RMT_RAW) {
         av_log(avctx, AV_LOG_ERROR, "invalid colormap type\n");
         return AVERROR_INVALIDDATA;
     }
@@ -85,13 +90,13 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
 
     switch (depth) {
         case 1:
-            avctx->pix_fmt = PIX_FMT_MONOWHITE;
+            avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
             break;
         case 8:
-            avctx->pix_fmt = maplength ? PIX_FMT_PAL8 : PIX_FMT_GRAY8;
+            avctx->pix_fmt = maplength ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_GRAY8;
             break;
         case 24:
-            avctx->pix_fmt = (type == RT_FORMAT_RGB) ? PIX_FMT_RGB24 : PIX_FMT_BGR24;
+            avctx->pix_fmt = (type == RT_FORMAT_RGB) ? AV_PIX_FMT_RGB24 : AV_PIX_FMT_BGR24;
             break;
         default:
             av_log(avctx, AV_LOG_ERROR, "invalid depth\n");
@@ -192,11 +197,11 @@ static av_cold int sunrast_end(AVCodecContext *avctx) {
 AVCodec ff_sunrast_decoder = {
     .name           = "sunrast",
     .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = CODEC_ID_SUNRAST,
+    .id             = AV_CODEC_ID_SUNRAST,
     .priv_data_size = sizeof(SUNRASTContext),
     .init           = sunrast_init,
     .close          = sunrast_end,
     .decode         = sunrast_decode_frame,
     .capabilities   = CODEC_CAP_DR1,
-    .long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"),
+    .long_name      = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"),
 };