aboutsummaryrefslogtreecommitdiffstats
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
parent29b673bdcfe1cd37de40b1714bfbcc03817cef7e (diff)
downloadffmpeg-eaffbd9ac4d975f1c6330c17af27fadf0bc3d0c3.tar.gz
avcodec/magicyuv: add 14bit rgb(a) support
-rw-r--r--libavcodec/magicyuv.c26
-rw-r--r--libavformat/isom_tags.c2
-rw-r--r--libavformat/riff.c2
3 files changed, 25 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 {
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index 4738171a9c..4e0727bb45 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -260,6 +260,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
{ AV_CODEC_ID_MAGICYUV, MKTAG('M', '8', 'Y', 'A') },
{ AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'A') },
{ AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'G') },
+ { AV_CODEC_ID_MAGICYUV, MKTAG('M', '4', 'R', 'A') },
+ { AV_CODEC_ID_MAGICYUV, MKTAG('M', '4', 'R', 'G') },
{ AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '0') },
{ AV_CODEC_ID_SHEERVIDEO, MKTAG('S', 'h', 'r', '1') },
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 97708df6e3..51d23b290e 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -463,6 +463,8 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ AV_CODEC_ID_MAGICYUV, MKTAG('M', '0', 'Y', '4') },
{ AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'A') },
{ AV_CODEC_ID_MAGICYUV, MKTAG('M', '2', 'R', 'G') },
+ { AV_CODEC_ID_MAGICYUV, MKTAG('M', '4', 'R', 'A') },
+ { AV_CODEC_ID_MAGICYUV, MKTAG('M', '4', 'R', 'G') },
{ AV_CODEC_ID_YLC, MKTAG('Y', 'L', 'C', '0') },
{ AV_CODEC_ID_SPEEDHQ, MKTAG('S', 'H', 'Q', '0') },
{ AV_CODEC_ID_SPEEDHQ, MKTAG('S', 'H', 'Q', '1') },