X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fdds.c;h=91e0c242265797d18b168aa748d7f5c79966ca45;hb=e328178da90f44690e0076f4dbfd16da9175f441;hp=0e9d9b94f9426e8e97f04bbdcda336a79a170035;hpb=9a9fb710bcf4657e030467cfe2556cb0e2c01afc;p=ffmpeg diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 0e9d9b94f94..91e0c242265 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -45,7 +45,6 @@ enum DDSPostProc { DDS_ALPHA_EXP, DDS_NORMAL_MAP, DDS_RAW_YCOCG, - DDS_SWAP_ALPHA, DDS_SWIZZLE_A2XY, DDS_SWIZZLE_RBXG, DDS_SWIZZLE_RGXB, @@ -241,6 +240,10 @@ static int parse_pixel_format(AVCodecContext *avctx) ctx->paletted = 1; avctx->pix_fmt = AV_PIX_FMT_PAL8; break; + case MKTAG('G', '1', ' ', ' '): + ctx->compressed = 0; + avctx->pix_fmt = AV_PIX_FMT_MONOBLACK; + break; case MKTAG('D', 'X', '1', '0'): /* DirectX 10 extra header */ dxgi = bytestream2_get_le32(gbc); @@ -352,6 +355,8 @@ static int parse_pixel_format(AVCodecContext *avctx) /* 8 bpp */ if (bpp == 8 && r == 0xff && g == 0 && b == 0 && a == 0) avctx->pix_fmt = AV_PIX_FMT_GRAY8; + else if (bpp == 8 && r == 0 && g == 0 && b == 0 && a == 0xff) + avctx->pix_fmt = AV_PIX_FMT_GRAY8; /* 16 bpp */ else if (bpp == 16 && r == 0xff && g == 0 && b == 0 && a == 0xff00) avctx->pix_fmt = AV_PIX_FMT_YA8; @@ -390,8 +395,6 @@ static int parse_pixel_format(AVCodecContext *avctx) ctx->postproc = DDS_NORMAL_MAP; else if (ycocg_classic && !ctx->compressed) ctx->postproc = DDS_RAW_YCOCG; - else if (avctx->pix_fmt == AV_PIX_FMT_YA8) - ctx->postproc = DDS_SWAP_ALPHA; /* ATI/NVidia variants sometimes add swizzling in bpp. */ switch (bpp) { @@ -538,15 +541,6 @@ static void run_postproc(AVCodecContext *avctx, AVFrame *frame) src[3] = a; } break; - case DDS_SWAP_ALPHA: - /* Alpha and Luma are stored swapped. */ - av_log(avctx, AV_LOG_DEBUG, "Post-processing swapped Luma/Alpha.\n"); - - for (i = 0; i < frame->linesize[0] * frame->height; i += 2) { - uint8_t *src = frame->data[0] + i; - FFSWAP(uint8_t, src[0], src[1]); - } - break; case DDS_SWIZZLE_A2XY: /* Swap R and G, often used to restore a standard RGTC2. */ av_log(avctx, AV_LOG_DEBUG, "Post-processing A2XY swizzle.\n"); @@ -699,9 +693,7 @@ static int dds_decode(AVCodecContext *avctx, void *data, } /* Run any post processing here if needed. */ - if (avctx->pix_fmt == AV_PIX_FMT_BGRA || - avctx->pix_fmt == AV_PIX_FMT_RGBA || - avctx->pix_fmt == AV_PIX_FMT_YA8) + if (ctx->postproc != DDS_NONE) run_postproc(avctx, frame); /* Frame is ready to be output. */