]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pnm.c
pnmdec: always output native pixel format
[ffmpeg] / libavcodec / pnm.c
index 308457bbe9473c0731c6253a802b749ce4c060e4..63b77cd8076e9ce4bc4066bf5850ba6c5d452e68 100644 (file)
@@ -116,10 +116,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
         if (depth == 1) {
             if (maxval == 1) {
                 avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
-            } else if (maxval == 255) {
+            } else if (maxval < 256) {
                 avctx->pix_fmt = AV_PIX_FMT_GRAY8;
             } else {
-                avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
+                avctx->pix_fmt = AV_PIX_FMT_GRAY16;
             }
         } else if (depth == 2) {
             if (maxval == 255)
@@ -128,13 +128,13 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
             if (maxval < 256) {
                 avctx->pix_fmt = AV_PIX_FMT_RGB24;
             } else {
-                avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
+                avctx->pix_fmt = AV_PIX_FMT_RGB48;
             }
         } else if (depth == 4) {
             if (maxval < 256) {
                 avctx->pix_fmt = AV_PIX_FMT_RGBA;
             } else {
-                avctx->pix_fmt = AV_PIX_FMT_RGBA64BE;
+                avctx->pix_fmt = AV_PIX_FMT_RGBA64;
             }
         } else {
             return AVERROR_INVALIDDATA;
@@ -162,14 +162,14 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
         }
         if (s->maxval >= 256) {
             if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
-                avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
+                avctx->pix_fmt = AV_PIX_FMT_GRAY16;
             } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
-                avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
+                avctx->pix_fmt = AV_PIX_FMT_RGB48;
             } else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P && s->maxval < 65536) {
                 if (s->maxval < 512)
-                    avctx->pix_fmt = AV_PIX_FMT_YUV420P9BE;
+                    avctx->pix_fmt = AV_PIX_FMT_YUV420P9;
                 else if (s->maxval < 1024)
-                    avctx->pix_fmt = AV_PIX_FMT_YUV420P10BE;
+                    avctx->pix_fmt = AV_PIX_FMT_YUV420P10;
                 else
                     avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
             } else {
@@ -192,13 +192,3 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
     }
     return 0;
 }
-
-av_cold int ff_pnm_init(AVCodecContext *avctx)
-{
-    PNMContext *s = avctx->priv_data;
-
-    avcodec_get_frame_defaults(&s->picture);
-    avctx->coded_frame = &s->picture;
-
-    return 0;
-}