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 | typedef struct CDXLVideoContext { | 43 | typedef struct CDXLVideoContext { |
| 44 | AVCodecContext *avctx; | 44 | AVCodecContext *avctx; |
| 45 | int bpp; | 45 | int bpp; |
| 46 | int type; | ||
| 46 | int format; | 47 | int format; |
| 47 | int padded_bits; | 48 | int padded_bits; |
| 48 | const uint8_t *palette; | 49 | const uint8_t *palette; |
| @@ -65,14 +66,19 @@ static av_cold int cdxl_decode_init(AVCodecContext *avctx) · 16 unmodified lines | |||
| 65 | 66 | ||
| 66 | static void import_palette(CDXLVideoContext *c, uint32_t *new_palette) | 67 | static void import_palette(CDXLVideoContext *c, uint32_t *new_palette) |
| 67 | { | 68 | { |
| 68 | int i; | 69 | if (c->type == 1) { |
| 69 | 70 | for (int i = 0; i < c->palette_size / 2; i++) { | |
| 70 | for (i = 0; i < c->palette_size / 2; i++) { | 71 | unsigned rgb = AV_RB16(&c->palette[i * 2]); |
| 71 | unsigned rgb = AV_RB16(&c->palette[i * 2]); | 72 | unsigned r = ((rgb >> 8) & 0xF) * 0x11; |
| 72 | unsigned r = ((rgb >> 8) & 0xF) * 0x11; | 73 | unsigned g = ((rgb >> 4) & 0xF) * 0x11; |
| 73 | unsigned g = ((rgb >> 4) & 0xF) * 0x11; | 74 | unsigned b = (rgb & 0xF) * 0x11; |
| 74 | unsigned b = (rgb & 0xF) * 0x11; | 75 | AV_WN32(&new_palette[i], (0xFFU << 24) | (r << 16) | (g << 8) | b); |
| 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 | if (buf_size < 32) | 253 | if (buf_size < 32) |
| 248 | return AVERROR_INVALIDDATA; | 254 | return AVERROR_INVALIDDATA; |
| 255 | c->type = buf[0]; | ||
| 249 | encoding = buf[1] & 7; | 256 | encoding = buf[1] & 7; |
| 250 | c->format = buf[1] & 0xE0; | 257 | c->format = buf[1] & 0xE0; |
| 251 | w = AV_RB16(&buf[14]); | 258 | w = AV_RB16(&buf[14]); |
| @@ -256,7 +263,11 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data, · 4 unmodified lines | |||
| 256 | c->video = c->palette + c->palette_size; | 263 | c->video = c->palette + c->palette_size; |
| 257 | c->video_size = buf_size - c->palette_size - 32; | 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 | return AVERROR_INVALIDDATA; | 271 | return AVERROR_INVALIDDATA; |
| 261 | if (buf_size < c->palette_size + 32) | 272 | if (buf_size < c->palette_size + 32) |
| 262 | return AVERROR_INVALIDDATA; | 273 | return AVERROR_INVALIDDATA; |