aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/magicyuv.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-09-27 15:41:01 +0200
committerPaul B Mahol <onemda@gmail.com>2023-09-28 19:37:58 +0200
commiteaffbd9ac4d975f1c6330c17af27fadf0bc3d0c3 (patch)
treed1db853d191686e39527c231954638c7e127b59d /libavcodec/magicyuv.c
parent29b673bdcfe1cd37de40b1714bfbcc03817cef7e (diff)
downloadffmpeg-eaffbd9ac4d975f1c6330c17af27fadf0bc3d0c3.tar.gz
avcodec/magicyuv: add 14bit rgb(a) support
Diffstat (limited to 'libavcodec/magicyuv.c')
-rw-r--r--libavcodec/magicyuv.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index 539da54c2f..3573db0f0a 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -73,12 +73,16 @@ typedef struct MagicYUVContext {
int (*magy_decode_slice)(AVCodecContext *avctx, void *tdata,
int j, int threadnr);
LLVidDSPContext llviddsp;
+ HuffEntry he[1 << 14];
+ uint8_t len[1 << 14];
} MagicYUVContext;
-static int huff_build(const uint8_t len[], uint16_t codes_pos[33],
+static int huff_build(AVCodecContext *avctx,
+ const uint8_t len[], uint16_t codes_pos[33],
VLC *vlc, VLC_MULTI *multi, int nb_elems, void *logctx)
{
- HuffEntry he[4096];
+ MagicYUVContext *s = avctx->priv_data;
+ HuffEntry *he = s->he;
for (int i = 31; i > 0; i--)
codes_pos[i] += codes_pos[i + 1];
@@ -381,7 +385,7 @@ static int build_huffman(AVCodecContext *avctx, const uint8_t *table,
{
MagicYUVContext *s = avctx->priv_data;
GetByteContext gb;
- uint8_t len[4096];
+ uint8_t *len = s->len;
uint16_t length_count[33] = { 0 };
int i = 0, j = 0, k;
@@ -409,7 +413,7 @@ static int build_huffman(AVCodecContext *avctx, const uint8_t *table,
if (j == max) {
j = 0;
- if (huff_build(len, length_count, &s->vlc[i], &s->multi[i], max, avctx)) {
+ if (huff_build(avctx, len, length_count, &s->vlc[i], &s->multi[i], max, avctx)) {
av_log(avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n");
return AVERROR_INVALIDDATA;
}
@@ -526,6 +530,16 @@ static int magy_decode_frame(AVCodecContext *avctx, AVFrame *p,
s->decorrelate = 1;
s->bps = 12;
break;
+ case 0x71:
+ avctx->pix_fmt = AV_PIX_FMT_GBRP14;
+ s->decorrelate = 1;
+ s->bps = 14;
+ break;
+ case 0x72:
+ avctx->pix_fmt = AV_PIX_FMT_GBRAP14;
+ s->decorrelate = 1;
+ s->bps = 14;
+ break;
case 0x73:
avctx->pix_fmt = AV_PIX_FMT_GRAY10;
s->bps = 10;
@@ -653,7 +667,9 @@ static int magy_decode_frame(AVCodecContext *avctx, AVFrame *p,
avctx->pix_fmt == AV_PIX_FMT_GBRP10 ||
avctx->pix_fmt == AV_PIX_FMT_GBRAP10||
avctx->pix_fmt == AV_PIX_FMT_GBRAP12||
- avctx->pix_fmt == AV_PIX_FMT_GBRP12) {
+ avctx->pix_fmt == AV_PIX_FMT_GBRAP14||
+ avctx->pix_fmt == AV_PIX_FMT_GBRP12||
+ avctx->pix_fmt == AV_PIX_FMT_GBRP14) {
FFSWAP(uint8_t*, p->data[0], p->data[1]);
FFSWAP(int, p->linesize[0], p->linesize[1]);
} else {