]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/psd.c
Merge commit '4fb311c804098d78e5ce5f527f9a9c37536d3a08'
[ffmpeg] / libavcodec / psd.c
index a4830c654fa20de1db87ef935249fab4e8ae2529..66f2ec28d7d59e2b358ddbfcd3f222ca7b492ac2 100644 (file)
@@ -316,9 +316,18 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 
     s->pixel_size = s->channel_depth >> 3;/* in byte */
     s->line_size = s->width * s->pixel_size;
-    s->uncompressed_size = s->line_size * s->height * s->channel_count;
 
     switch (s->color_mode) {
+    case PSD_BITMAP:
+        if (s->channel_depth != 1 || s->channel_count != 1) {
+            av_log(s->avctx, AV_LOG_ERROR,
+                    "Invalid bitmap file (channel_depth %d, channel_count %d)\n",
+                    s->channel_depth, s->channel_count);
+            return AVERROR_INVALIDDATA;
+        }
+        s->line_size = s->width + 7 >> 3;
+        avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
+        break;
     case PSD_INDEXED:
         if (s->channel_depth != 8 || s->channel_count != 1) {
             av_log(s->avctx, AV_LOG_ERROR,
@@ -353,7 +362,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
         }
         break;
     case PSD_DUOTONE:
-        av_log(avctx, AV_LOG_WARNING, "ignoring unknwon duotone specification.\n");
+        av_log(avctx, AV_LOG_WARNING, "ignoring unknown duotone specification.\n");
     case PSD_GRAYSCALE:
         if (s->channel_count == 1) {
             if (s->channel_depth == 8) {
@@ -383,6 +392,8 @@ static int decode_frame(AVCodecContext *avctx, void *data,
         return AVERROR_PATCHWELCOME;
     }
 
+    s->uncompressed_size = s->line_size * s->height * s->channel_count;
+
     if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
         return ret;
 
@@ -430,9 +441,9 @@ static int decode_frame(AVCodecContext *avctx, void *data,
             plane_number = eq_channel[c];
             ptr = picture->data[plane_number];/* get the right plane */
             for (y = 0; y < s->height; y++) {
-                memcpy(ptr, ptr_data, s->width * s->pixel_size);
+                memcpy(ptr, ptr_data, s->line_size);
                 ptr += picture->linesize[plane_number];
-                ptr_data += s->width * s->pixel_size;
+                ptr_data += s->line_size;
             }
         }
     }