Also stop discarding half of audio samples and use planar pcm s8.
Showing the changes to libavcodec (1 of 3 files). Show all
Unified · Split
| @@ -43,6 +43,7 @@ · 42 unmodified lines | ||
| 43 | 43 | typedef struct CDXLVideoContext { |
| 44 | 44 | AVCodecContext *avctx; |
| 45 | 45 | int bpp; |
| 46 | + int type; | |
| 46 | 47 | int format; |
| 47 | 48 | int padded_bits; |
| 48 | 49 | const uint8_t *palette; |
| @@ -65,14 +66,19 @@ static av_cold int cdxl_decode_init(AVCodecContext *avctx) · 16 unmodified lines | ||
| 65 | 66 | |
| 66 | 67 | static void import_palette(CDXLVideoContext *c, uint32_t *new_palette) |
| 67 | 68 | { |
| 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 | + } | |
| 76 | 82 | } |
| 77 | 83 | } |
| 78 | 84 | |
| @@ -246,6 +252,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, · 167 unmodified lines | ||
| 246 | 252 | |
| 247 | 253 | if (buf_size < 32) |
| 248 | 254 | return AVERROR_INVALIDDATA; |
| 255 | + c->type = buf[0]; | |
| 249 | 256 | encoding = buf[1] & 7; |
| 250 | 257 | c->format = buf[1] & 0xE0; |
| 251 | 258 | w = AV_RB16(&buf[14]); |
| @@ -256,7 +263,11 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines | ||
| 256 | 263 | c->video = c->palette + c->palette_size; |
| 257 | 264 | c->video_size = buf_size - c->palette_size - 32; |
| 258 | 265 | |
| 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) | |
| 260 | 271 | return AVERROR_INVALIDDATA; |
| 261 | 272 | if (buf_size < c->palette_size + 32) |
| 262 | 273 | return AVERROR_INVALIDDATA; |