History

avformat/cdxl: add support for custom 24bit pal8 formats

Also stop discarding half of audio samples and use planar pcm s8.

Paul B Mahol committed 5 years ago

Commit e8189511 parent e6254d53 files · +37 −22Browse files

Showing the changes to libavcodec (1 of 3 files). Show all

Unified · Split

libavcodec/cdxl.c+20−9
@@ -43,6 +43,7 @@ · 42 unmodified lines
4343 typedef struct CDXLVideoContext {
4444 AVCodecContext *avctx;
4545 int bpp;
46+ int type;
4647 int format;
4748 int padded_bits;
4849 const uint8_t *palette;
@@ -65,14 +66,19 @@ static av_cold int cdxl_decode_init(AVCodecContext *avctx) · 16 unmodified lines
6566
6667 static void import_palette(CDXLVideoContext *c, uint32_t *new_palette)
6768 {
68− int i;
69−
70− for (i = 0; i < c->palette_size / 2; i++) {
71− unsigned rgb = AV_RB16(&c->palette[i * 2]);
72− unsigned r = ((rgb >> 8) & 0xF) * 0x11;
73− unsigned g = ((rgb >> 4) & 0xF) * 0x11;
74− unsigned b = (rgb & 0xF) * 0x11;
75− AV_WN32(&new_palette[i], (0xFFU << 24) | (r << 16) | (g << 8) | b);
69+ if (c->type == 1) {
70+ for (int i = 0; i < c->palette_size / 2; i++) {
71+ unsigned rgb = AV_RB16(&c->palette[i * 2]);
72+ unsigned r = ((rgb >> 8) & 0xF) * 0x11;
73+ unsigned g = ((rgb >> 4) & 0xF) * 0x11;
74+ unsigned b = (rgb & 0xF) * 0x11;
75+ AV_WN32(&new_palette[i], (0xFFU << 24) | (r << 16) | (g << 8) | b);
76+ }
77+ } else {
78+ for (int i = 0; i < c->palette_size / 3; i++) {
79+ unsigned rgb = AV_RB24(&c->palette[i * 3]);
80+ AV_WN32(&new_palette[i], (0xFFU << 24) | rgb);
81+ }
7682 }
7783 }
7884
@@ -246,6 +252,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, · 167 unmodified lines
246252
247253 if (buf_size < 32)
248254 return AVERROR_INVALIDDATA;
255+ c->type = buf[0];
249256 encoding = buf[1] & 7;
250257 c->format = buf[1] & 0xE0;
251258 w = AV_RB16(&buf[14]);
@@ -256,7 +263,11 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines
256263 c->video = c->palette + c->palette_size;
257264 c->video_size = buf_size - c->palette_size - 32;
258265
259− if (c->palette_size > 512)
266+ if (c->type > 1)
267+ return AVERROR_INVALIDDATA;
268+ if (c->type == 1 && c->palette_size > 512)
269+ return AVERROR_INVALIDDATA;
270+ if (c->type == 0 && c->palette_size > 768)
260271 return AVERROR_INVALIDDATA;
261272 if (buf_size < c->palette_size + 32)
262273 return AVERROR_INVALIDDATA;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t