Ticket #6045: patchpsd32.diff

File patchpsd32.diff, 3.0 KB (added by Carl Eugen Hoyos, 10 years ago)
  • libavcodec/psd.c

    diff --git a/libavcodec/psd.c b/libavcodec/psd.c
    index 7587ed9..e48b379 100644
    a b static int decode_frame(AVCodecContext *avctx, void *data,  
    332332        if (s->channel_count == 3) {
    333333            if (s->channel_depth == 8) {
    334334                avctx->pix_fmt = AV_PIX_FMT_GBRP;
    335             } else if (s->channel_depth == 16) {
     335            } else if (s->channel_depth == 16 || s->channel_depth == 32) {
    336336                avctx->pix_fmt = AV_PIX_FMT_GBRP16BE;
    337337            } else {
    338338                avpriv_report_missing_feature(avctx, "channel depth %d for rgb", s->channel_depth);
    … … static int decode_frame(AVCodecContext *avctx, void *data,  
    341341        } else if (s->channel_count == 4) {
    342342            if (s->channel_depth == 8) {
    343343                avctx->pix_fmt = AV_PIX_FMT_GBRAP;
    344             } else if (s->channel_depth == 16) {
     344            } else if (s->channel_depth == 16 || s->channel_depth == 32) {
    345345                avctx->pix_fmt = AV_PIX_FMT_GBRAP16BE;
    346346            } else {
    347347                avpriv_report_missing_feature(avctx, "channel depth %d for rgb", s->channel_depth);
    … … static int decode_frame(AVCodecContext *avctx, void *data,  
    356356        if (s->channel_count == 1) {
    357357            if (s->channel_depth == 8) {
    358358                avctx->pix_fmt = AV_PIX_FMT_GRAY8;
    359             } else if (s->channel_depth == 16) {
     359            } else if (s->channel_depth == 16 || s->channel_depth == 32) {
    360360                avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
    361361            } else {
    362362                avpriv_report_missing_feature(avctx, "channel depth %d for grayscale", s->channel_depth);
    … … static int decode_frame(AVCodecContext *avctx, void *data,  
    380380        avpriv_report_missing_feature(avctx, "color mode %d", s->color_mode);
    381381        return AVERROR_PATCHWELCOME;
    382382    }
     383    if (s->channel_depth == 32)
     384        av_log(avctx, AV_LOG_WARNING, "truncating 32bit channel_depth to 16bit\n");
    383385
    384386    if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
    385387        return ret;
    … … static int decode_frame(AVCodecContext *avctx, void *data,  
    420422                }
    421423            }
    422424        }
     425    } else if (s->channel_depth == 32) {
     426        if (avctx->pix_fmt == AV_PIX_FMT_GRAY16BE)
     427            eq_channel[0] = 0;
     428        for (c = 0; c < s->channel_count; c++) {
     429            plane_number = eq_channel[c];
     430            ptr = picture->data[plane_number];/* get the right plane */
     431            for (y = 0; y < s->height; y++) {
     432                for (x = 0; x < s->width; x++) {
     433//                    AV_WB16(ptr + 2 * x, AV_RB32(&ptr_data[4 * x]) >> 16);
     434uint32_t v = AV_RB32(&ptr_data[4 * x]);
     435v >>= 11;
     436AV_WB16(ptr + 2 * x, v);
     437                }
     438                ptr += picture->linesize[plane_number];
     439                ptr_data += s->width * s->pixel_size;
     440            }
     441        }
    423442    } else {/* Planar */
    424443        if (s->channel_count == 1)/* gray 8 or gray 16be */
    425444            eq_channel[0] = 0;/* assign first channel, to first plane */