aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-01-31 04:10:02 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-31 04:36:53 +0100
commit6ffac5d33d334f847150356293ecb6f9eaf69e15 (patch)
tree27e6ea59bce5a7d74cca88be2c8c804ad66cd3a3 /libavcodec
parent77864be44a0daeae846d7395b3cb682a22ce99a9 (diff)
downloadffmpeg-6ffac5d33d334f847150356293ecb6f9eaf69e15.tar.gz
avcodec/rawdec: Switch to monowhite if there is no palette & bpp=1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/rawdec.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 3536943adf..93cbedfed8 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -112,6 +112,9 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
avctx->pix_fmt == AV_PIX_FMT_YUYV422)
context->is_yuv2 = 1;
+ if (avctx->pix_fmt == AV_PIX_FMT_PAL8 && avctx->bits_per_coded_sample == 1)
+ avctx->pix_fmt = AV_PIX_FMT_NONE;
+
return 0;
}
@@ -152,7 +155,7 @@ MKSCALE16(scale16le, AV_RL16, AV_WL16)
static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ const AVPixFmtDescriptor *desc;
RawVideoContext *context = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
@@ -173,6 +176,20 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
av_log(avctx, AV_LOG_ERROR, "Packet too small (%d) height (%d)\n", avpkt->size, avctx->height);
return AVERROR_INVALIDDATA;
}
+ if (avctx->pix_fmt == AV_PIX_FMT_NONE &&
+ avctx->bits_per_coded_sample == 1 &&
+ avctx->frame_number == 0 &&
+ context->palette &&
+ AV_RB64(context->palette->data) == 0xFFFFFFFF00000000
+ ) {
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
+ if (!pal) {
+ avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
+ } else
+ avctx->pix_fmt = AV_PIX_FMT_PAL8;
+ }
+
+ desc = av_pix_fmt_desc_get(avctx->pix_fmt);
if ((avctx->bits_per_coded_sample == 8 || avctx->bits_per_coded_sample == 4
|| avctx->bits_per_coded_sample == 2 || avctx->bits_per_coded_sample == 1) &&