diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c
index 3e1cea6..c9d1f98 100644
|
a
|
b
|
static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
| 90 | 90 | |
| 91 | 91 | switch (depth) { |
| 92 | 92 | case 1: |
| 93 | | avctx->pix_fmt = PIX_FMT_MONOWHITE; |
| | 93 | avctx->pix_fmt = maplength ? PIX_FMT_PAL8 : PIX_FMT_MONOWHITE; |
| 94 | 94 | break; |
| 95 | 95 | case 8: |
| 96 | 96 | avctx->pix_fmt = PIX_FMT_PAL8; |
| … |
… |
static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
| 118 | 118 | if (buf_end - buf < maplength) |
| 119 | 119 | return AVERROR_INVALIDDATA; |
| 120 | 120 | |
| 121 | | if (depth != 8 && maplength) { |
| | 121 | if (avctx->pix_fmt != PIX_FMT_PAL8 && maplength) { |
| 122 | 122 | av_log(avctx, AV_LOG_WARNING, "useless colormap found or file is corrupted, trying to recover\n"); |
| 123 | 123 | |
| 124 | | } else if (depth == 8) { |
| | 124 | } else if (avctx->pix_fmt == PIX_FMT_PAL8) { |
| 125 | 125 | unsigned int len = maplength / 3; |
| 126 | 126 | |
| 127 | 127 | if (!maplength) { |
| … |
… |
static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
|
| 182 | 182 | buf += alen; |
| 183 | 183 | } |
| 184 | 184 | } |
| | 185 | if (avctx->pix_fmt == PIX_FMT_PAL8 && depth == 1) { |
| | 186 | ptr = p->data[0]; |
| | 187 | for (y=0; y<h; y++) { |
| | 188 | x = w + 7 >> 3; |
| | 189 | do { |
| | 190 | ptr[8*x+7] = ptr[x] & 1; |
| | 191 | ptr[8*x+6] = ptr[x] >> 1 & 1; |
| | 192 | ptr[8*x+5] = ptr[x] >> 2 & 1; |
| | 193 | ptr[8*x+4] = ptr[x] >> 3 & 1; |
| | 194 | ptr[8*x+3] = ptr[x] >> 4 & 1; |
| | 195 | ptr[8*x+2] = ptr[x] >> 5 & 1; |
| | 196 | ptr[8*x+1] = ptr[x] >> 6 & 1; |
| | 197 | ptr[8*x] = ptr[x] >> 7; |
| | 198 | } while (x--); |
| | 199 | ptr += stride; |
| | 200 | } |
| | 201 | } |
| 185 | 202 | |
| 186 | 203 | *picture = s->picture; |
| 187 | 204 | *data_size = sizeof(AVFrame); |
| … |
… |
AVCodec ff_sunrast_decoder = {
|
| 206 | 223 | .init = sunrast_init, |
| 207 | 224 | .close = sunrast_end, |
| 208 | 225 | .decode = sunrast_decode_frame, |
| 209 | | .capabilities = CODEC_CAP_DR1, |
| | 226 | // .capabilities = CODEC_CAP_DR1, |
| 210 | 227 | .long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"), |
| 211 | 228 | }; |