Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
| ... | ... |
@@ -50,6 +50,8 @@ typedef struct EightBpsContext {
|
| 50 | 50 |
|
| 51 | 51 |
unsigned char planes; |
| 52 | 52 |
unsigned char planemap[4]; |
| 53 |
+ |
|
| 54 |
+ uint32_t pal[256]; |
|
| 53 | 55 |
} EightBpsContext; |
| 54 | 56 |
|
| 55 | 57 |
|
| ... | ... |
@@ -129,13 +131,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 129 | 129 |
} |
| 130 | 130 |
} |
| 131 | 131 |
|
| 132 |
- if (avctx->palctrl) {
|
|
| 133 |
- memcpy (c->pic.data[1], avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 134 |
- if (avctx->palctrl->palette_changed) {
|
|
| 132 |
+ if (avctx->bits_per_coded_sample <= 8) {
|
|
| 133 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, |
|
| 134 |
+ AV_PKT_DATA_PALETTE, |
|
| 135 |
+ NULL); |
|
| 136 |
+ if (pal) {
|
|
| 135 | 137 |
c->pic.palette_has_changed = 1; |
| 136 |
- avctx->palctrl->palette_changed = 0; |
|
| 137 |
- } else |
|
| 138 |
- c->pic.palette_has_changed = 0; |
|
| 138 |
+ memcpy(c->pal, pal, AVPALETTE_SIZE); |
|
| 139 |
+ } |
|
| 140 |
+ |
|
| 141 |
+ memcpy (c->pic.data[1], c->pal, AVPALETTE_SIZE); |
|
| 139 | 142 |
} |
| 140 | 143 |
|
| 141 | 144 |
*data_size = sizeof(AVFrame); |
| ... | ... |
@@ -164,10 +169,6 @@ static av_cold int decode_init(AVCodecContext *avctx) |
| 164 | 164 |
avctx->pix_fmt = PIX_FMT_PAL8; |
| 165 | 165 |
c->planes = 1; |
| 166 | 166 |
c->planemap[0] = 0; // 1st plane is palette indexes |
| 167 |
- if (avctx->palctrl == NULL) {
|
|
| 168 |
- av_log(avctx, AV_LOG_ERROR, "Error: PAL8 format but no palette from demuxer.\n"); |
|
| 169 |
- return -1; |
|
| 170 |
- } |
|
| 171 | 167 |
break; |
| 172 | 168 |
case 24: |
| 173 | 169 |
avctx->pix_fmt = avctx->get_format(avctx, pixfmt_rgb24); |
| ... | ... |
@@ -67,6 +67,7 @@ typedef struct CinepakContext {
|
| 67 | 67 |
|
| 68 | 68 |
int sega_film_skip_bytes; |
| 69 | 69 |
|
| 70 |
+ uint32_t pal[256]; |
|
| 70 | 71 |
} CinepakContext; |
| 71 | 72 |
|
| 72 | 73 |
static void cinepak_decode_codebook (cvid_codebook *codebook, |
| ... | ... |
@@ -395,7 +396,7 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx) |
| 395 | 395 |
s->sega_film_skip_bytes = -1; /* uninitialized state */ |
| 396 | 396 |
|
| 397 | 397 |
// check for paletted data |
| 398 |
- if ((avctx->palctrl == NULL) || (avctx->bits_per_coded_sample == 40)) {
|
|
| 398 |
+ if (avctx->bits_per_coded_sample != 8) {
|
|
| 399 | 399 |
s->palette_video = 0; |
| 400 | 400 |
avctx->pix_fmt = PIX_FMT_YUV420P; |
| 401 | 401 |
} else {
|
| ... | ... |
@@ -427,17 +428,19 @@ static int cinepak_decode_frame(AVCodecContext *avctx, |
| 427 | 427 |
return -1; |
| 428 | 428 |
} |
| 429 | 429 |
|
| 430 |
- cinepak_decode(s); |
|
| 431 |
- |
|
| 432 | 430 |
if (s->palette_video) {
|
| 433 |
- memcpy (s->frame.data[1], avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 434 |
- if (avctx->palctrl->palette_changed) {
|
|
| 431 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 432 |
+ if (pal) {
|
|
| 435 | 433 |
s->frame.palette_has_changed = 1; |
| 436 |
- avctx->palctrl->palette_changed = 0; |
|
| 437 |
- } else |
|
| 438 |
- s->frame.palette_has_changed = 0; |
|
| 434 |
+ memcpy(s->pal, pal, AVPALETTE_SIZE); |
|
| 435 |
+ } |
|
| 439 | 436 |
} |
| 440 | 437 |
|
| 438 |
+ cinepak_decode(s); |
|
| 439 |
+ |
|
| 440 |
+ if (s->palette_video) |
|
| 441 |
+ memcpy (s->frame.data[1], s->pal, AVPALETTE_SIZE); |
|
| 442 |
+ |
|
| 441 | 443 |
*data_size = sizeof(AVFrame); |
| 442 | 444 |
*(AVFrame*)data = s->frame; |
| 443 | 445 |
|
| ... | ... |
@@ -72,6 +72,7 @@ typedef struct IdcinContext {
|
| 72 | 72 |
hnode huff_nodes[256][HUF_TOKENS*2]; |
| 73 | 73 |
int num_huff_nodes[256]; |
| 74 | 74 |
|
| 75 |
+ uint32_t pal[256]; |
|
| 75 | 76 |
} IdcinContext; |
| 76 | 77 |
|
| 77 | 78 |
/* |
| ... | ... |
@@ -213,7 +214,7 @@ static int idcin_decode_frame(AVCodecContext *avctx, |
| 213 | 213 |
const uint8_t *buf = avpkt->data; |
| 214 | 214 |
int buf_size = avpkt->size; |
| 215 | 215 |
IdcinContext *s = avctx->priv_data; |
| 216 |
- AVPaletteControl *palette_control = avctx->palctrl; |
|
| 216 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 217 | 217 |
|
| 218 | 218 |
s->buf = buf; |
| 219 | 219 |
s->size = buf_size; |
| ... | ... |
@@ -228,13 +229,12 @@ static int idcin_decode_frame(AVCodecContext *avctx, |
| 228 | 228 |
|
| 229 | 229 |
idcin_decode_vlcs(s); |
| 230 | 230 |
|
| 231 |
- /* make the palette available on the way out */ |
|
| 232 |
- memcpy(s->frame.data[1], palette_control->palette, PALETTE_COUNT * 4); |
|
| 233 |
- /* If palette changed inform application*/ |
|
| 234 |
- if (palette_control->palette_changed) {
|
|
| 235 |
- palette_control->palette_changed = 0; |
|
| 231 |
+ if (pal) {
|
|
| 236 | 232 |
s->frame.palette_has_changed = 1; |
| 233 |
+ memcpy(s->pal, pal, AVPALETTE_SIZE); |
|
| 237 | 234 |
} |
| 235 |
+ /* make the palette available on the way out */ |
|
| 236 |
+ memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); |
|
| 238 | 237 |
|
| 239 | 238 |
*data_size = sizeof(AVFrame); |
| 240 | 239 |
*(AVFrame*)data = s->frame; |
| ... | ... |
@@ -77,6 +77,7 @@ typedef struct IpvideoContext {
|
| 77 | 77 |
int stride; |
| 78 | 78 |
int upper_motion_limit_offset; |
| 79 | 79 |
|
| 80 |
+ uint32_t pal[256]; |
|
| 80 | 81 |
} IpvideoContext; |
| 81 | 82 |
|
| 82 | 83 |
#define CHECK_STREAM_PTR(stream_ptr, stream_end, n) \ |
| ... | ... |
@@ -969,7 +970,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s) |
| 969 | 969 |
|
| 970 | 970 |
if (!s->is_16bpp) {
|
| 971 | 971 |
/* this is PAL8, so make the palette available */ |
| 972 |
- memcpy(s->current_frame.data[1], s->avctx->palctrl->palette, PALETTE_COUNT * 4); |
|
| 972 |
+ memcpy(s->current_frame.data[1], s->pal, AVPALETTE_SIZE); |
|
| 973 | 973 |
|
| 974 | 974 |
s->stride = s->current_frame.linesize[0]; |
| 975 | 975 |
s->stream_ptr = s->buf + 14; /* data starts 14 bytes in */ |
| ... | ... |
@@ -1023,10 +1024,6 @@ static av_cold int ipvideo_decode_init(AVCodecContext *avctx) |
| 1023 | 1023 |
|
| 1024 | 1024 |
s->is_16bpp = avctx->bits_per_coded_sample == 16; |
| 1025 | 1025 |
avctx->pix_fmt = s->is_16bpp ? PIX_FMT_RGB555 : PIX_FMT_PAL8; |
| 1026 |
- if (!s->is_16bpp && s->avctx->palctrl == NULL) {
|
|
| 1027 |
- av_log(avctx, AV_LOG_ERROR, " Interplay video: palette expected.\n"); |
|
| 1028 |
- return -1; |
|
| 1029 |
- } |
|
| 1030 | 1026 |
|
| 1031 | 1027 |
dsputil_init(&s->dsp, avctx); |
| 1032 | 1028 |
|
| ... | ... |
@@ -1046,7 +1043,6 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, |
| 1046 | 1046 |
const uint8_t *buf = avpkt->data; |
| 1047 | 1047 |
int buf_size = avpkt->size; |
| 1048 | 1048 |
IpvideoContext *s = avctx->priv_data; |
| 1049 |
- AVPaletteControl *palette_control = avctx->palctrl; |
|
| 1050 | 1049 |
|
| 1051 | 1050 |
/* compressed buffer needs to be large enough to at least hold an entire |
| 1052 | 1051 |
* decoding map */ |
| ... | ... |
@@ -1063,13 +1059,16 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, |
| 1063 | 1063 |
return -1; |
| 1064 | 1064 |
} |
| 1065 | 1065 |
|
| 1066 |
- ipvideo_decode_opcodes(s); |
|
| 1067 |
- |
|
| 1068 |
- if (!s->is_16bpp && palette_control->palette_changed) {
|
|
| 1069 |
- palette_control->palette_changed = 0; |
|
| 1070 |
- s->current_frame.palette_has_changed = 1; |
|
| 1066 |
+ if (!s->is_16bpp) {
|
|
| 1067 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 1068 |
+ if (pal) {
|
|
| 1069 |
+ s->current_frame.palette_has_changed = 1; |
|
| 1070 |
+ memcpy(s->pal, pal, AVPALETTE_SIZE); |
|
| 1071 |
+ } |
|
| 1071 | 1072 |
} |
| 1072 | 1073 |
|
| 1074 |
+ ipvideo_decode_opcodes(s); |
|
| 1075 |
+ |
|
| 1073 | 1076 |
*data_size = sizeof(AVFrame); |
| 1074 | 1077 |
*(AVFrame*)data = s->current_frame; |
| 1075 | 1078 |
|
| ... | ... |
@@ -233,6 +233,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa |
| 233 | 233 |
int i; |
| 234 | 234 |
int header; |
| 235 | 235 |
int blocksize; |
| 236 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 236 | 237 |
|
| 237 | 238 |
if (ctx->pic.data[0]) |
| 238 | 239 |
avctx->release_buffer(avctx, &ctx->pic); |
| ... | ... |
@@ -264,13 +265,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa |
| 264 | 264 |
ctx->pic.pict_type = FF_P_TYPE; |
| 265 | 265 |
} |
| 266 | 266 |
|
| 267 |
- /* if palette has been changed, copy it from palctrl */ |
|
| 268 |
- if (ctx->avctx->palctrl && ctx->avctx->palctrl->palette_changed) {
|
|
| 269 |
- memcpy(ctx->pal, ctx->avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 270 |
- ctx->setpal = 1; |
|
| 271 |
- ctx->avctx->palctrl->palette_changed = 0; |
|
| 272 |
- } |
|
| 273 |
- |
|
| 274 | 267 |
if (header & KMVC_PALETTE) {
|
| 275 | 268 |
ctx->pic.palette_has_changed = 1; |
| 276 | 269 |
// palette starts from index 1 and has 127 entries |
| ... | ... |
@@ -279,6 +273,11 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa |
| 279 | 279 |
} |
| 280 | 280 |
} |
| 281 | 281 |
|
| 282 |
+ if (pal) {
|
|
| 283 |
+ ctx->pic.palette_has_changed = 1; |
|
| 284 |
+ memcpy(ctx->pal, pal, AVPALETTE_SIZE); |
|
| 285 |
+ } |
|
| 286 |
+ |
|
| 282 | 287 |
if (ctx->setpal) {
|
| 283 | 288 |
ctx->setpal = 0; |
| 284 | 289 |
ctx->pic.palette_has_changed = 1; |
| ... | ... |
@@ -374,9 +373,6 @@ static av_cold int decode_init(AVCodecContext * avctx) |
| 374 | 374 |
src += 4; |
| 375 | 375 |
} |
| 376 | 376 |
c->setpal = 1; |
| 377 |
- if (c->avctx->palctrl) {
|
|
| 378 |
- c->avctx->palctrl->palette_changed = 0; |
|
| 379 |
- } |
|
| 380 | 377 |
} |
| 381 | 378 |
|
| 382 | 379 |
avctx->pix_fmt = PIX_FMT_PAL8; |
| ... | ... |
@@ -26,9 +26,6 @@ |
| 26 | 26 |
* http://www.pcisys.net/~melanson/codecs/ |
| 27 | 27 |
* |
| 28 | 28 |
* The MS RLE decoder outputs PAL8 colorspace data. |
| 29 |
- * |
|
| 30 |
- * Note that this decoder expects the palette colors from the end of the |
|
| 31 |
- * BITMAPINFO header passed through palctrl. |
|
| 32 | 29 |
*/ |
| 33 | 30 |
|
| 34 | 31 |
#include <stdio.h> |
| ... | ... |
@@ -46,6 +43,7 @@ typedef struct MsrleContext {
|
| 46 | 46 |
const unsigned char *buf; |
| 47 | 47 |
int size; |
| 48 | 48 |
|
| 49 |
+ uint32_t pal[256]; |
|
| 49 | 50 |
} MsrleContext; |
| 50 | 51 |
|
| 51 | 52 |
static av_cold int msrle_decode_init(AVCodecContext *avctx) |
| ... | ... |
@@ -91,13 +89,16 @@ static int msrle_decode_frame(AVCodecContext *avctx, |
| 91 | 91 |
return -1; |
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 |
- if (s->avctx->palctrl) {
|
|
| 95 |
- /* make the palette available */ |
|
| 96 |
- memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 97 |
- if (s->avctx->palctrl->palette_changed) {
|
|
| 94 |
+ if (avctx->bits_per_coded_sample <= 8) {
|
|
| 95 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 96 |
+ |
|
| 97 |
+ if (pal) {
|
|
| 98 | 98 |
s->frame.palette_has_changed = 1; |
| 99 |
- s->avctx->palctrl->palette_changed = 0; |
|
| 99 |
+ memcpy(s->pal, pal, AVPALETTE_SIZE); |
|
| 100 | 100 |
} |
| 101 |
+ |
|
| 102 |
+ /* make the palette available */ |
|
| 103 |
+ memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); |
|
| 101 | 104 |
} |
| 102 | 105 |
|
| 103 | 106 |
/* FIXME how to correctly detect RLE ??? */ |
| ... | ... |
@@ -25,9 +25,6 @@ |
| 25 | 25 |
* For more information about the MS Video-1 format, visit: |
| 26 | 26 |
* http://www.pcisys.net/~melanson/codecs/ |
| 27 | 27 |
* |
| 28 |
- * This decoder outputs either PAL8 or RGB555 data, depending on the |
|
| 29 |
- * whether a RGB palette was passed through palctrl; |
|
| 30 |
- * if it's present, then the data is PAL8; RGB555 otherwise. |
|
| 31 | 28 |
*/ |
| 32 | 29 |
|
| 33 | 30 |
#include <stdio.h> |
| ... | ... |
@@ -55,6 +52,7 @@ typedef struct Msvideo1Context {
|
| 55 | 55 |
|
| 56 | 56 |
int mode_8bit; /* if it's not 8-bit, it's 16-bit */ |
| 57 | 57 |
|
| 58 |
+ uint32_t pal[256]; |
|
| 58 | 59 |
} Msvideo1Context; |
| 59 | 60 |
|
| 60 | 61 |
static av_cold int msvideo1_decode_init(AVCodecContext *avctx) |
| ... | ... |
@@ -64,7 +62,7 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx) |
| 64 | 64 |
s->avctx = avctx; |
| 65 | 65 |
|
| 66 | 66 |
/* figure out the colorspace based on the presence of a palette */ |
| 67 |
- if (s->avctx->palctrl) {
|
|
| 67 |
+ if (s->avctx->bits_per_coded_sample == 8) {
|
|
| 68 | 68 |
s->mode_8bit = 1; |
| 69 | 69 |
avctx->pix_fmt = PIX_FMT_PAL8; |
| 70 | 70 |
} else {
|
| ... | ... |
@@ -173,13 +171,8 @@ static void msvideo1_decode_8bit(Msvideo1Context *s) |
| 173 | 173 |
} |
| 174 | 174 |
|
| 175 | 175 |
/* make the palette available on the way out */ |
| 176 |
- if (s->avctx->pix_fmt == PIX_FMT_PAL8) {
|
|
| 177 |
- memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 178 |
- if (s->avctx->palctrl->palette_changed) {
|
|
| 179 |
- s->frame.palette_has_changed = 1; |
|
| 180 |
- s->avctx->palctrl->palette_changed = 0; |
|
| 181 |
- } |
|
| 182 |
- } |
|
| 176 |
+ if (s->avctx->pix_fmt == PIX_FMT_PAL8) |
|
| 177 |
+ memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); |
|
| 183 | 178 |
} |
| 184 | 179 |
|
| 185 | 180 |
static void msvideo1_decode_16bit(Msvideo1Context *s) |
| ... | ... |
@@ -309,6 +302,15 @@ static int msvideo1_decode_frame(AVCodecContext *avctx, |
| 309 | 309 |
return -1; |
| 310 | 310 |
} |
| 311 | 311 |
|
| 312 |
+ if (s->mode_8bit) {
|
|
| 313 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 314 |
+ |
|
| 315 |
+ if (pal) {
|
|
| 316 |
+ memcpy(s->pal, pal, AVPALETTE_SIZE); |
|
| 317 |
+ s->frame.palette_has_changed = 1; |
|
| 318 |
+ } |
|
| 319 |
+ } |
|
| 320 |
+ |
|
| 312 | 321 |
if (s->mode_8bit) |
| 313 | 322 |
msvideo1_decode_8bit(s); |
| 314 | 323 |
else |
| ... | ... |
@@ -30,6 +30,7 @@ typedef struct QpegContext{
|
| 30 | 30 |
AVCodecContext *avctx; |
| 31 | 31 |
AVFrame pic; |
| 32 | 32 |
uint8_t *refdata; |
| 33 |
+ uint32_t pal[256]; |
|
| 33 | 34 |
} QpegContext; |
| 34 | 35 |
|
| 35 | 36 |
static void qpeg_decode_intra(const uint8_t *src, uint8_t *dst, int size, |
| ... | ... |
@@ -256,6 +257,7 @@ static int decode_frame(AVCodecContext *avctx, |
| 256 | 256 |
AVFrame * const p= (AVFrame*)&a->pic; |
| 257 | 257 |
uint8_t* outdata; |
| 258 | 258 |
int delta; |
| 259 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 259 | 260 |
|
| 260 | 261 |
if(p->data[0]) |
| 261 | 262 |
avctx->release_buffer(avctx, p); |
| ... | ... |
@@ -274,11 +276,11 @@ static int decode_frame(AVCodecContext *avctx, |
| 274 | 274 |
} |
| 275 | 275 |
|
| 276 | 276 |
/* make the palette available on the way out */ |
| 277 |
- memcpy(a->pic.data[1], a->avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 278 |
- if (a->avctx->palctrl->palette_changed) {
|
|
| 277 |
+ if (pal) {
|
|
| 279 | 278 |
a->pic.palette_has_changed = 1; |
| 280 |
- a->avctx->palctrl->palette_changed = 0; |
|
| 279 |
+ memcpy(a->pal, pal, AVPALETTE_SIZE); |
|
| 281 | 280 |
} |
| 281 |
+ memcpy(a->pic.data[1], a->pal, AVPALETTE_SIZE); |
|
| 282 | 282 |
|
| 283 | 283 |
*data_size = sizeof(AVFrame); |
| 284 | 284 |
*(AVFrame*)data = a->pic; |
| ... | ... |
@@ -289,10 +291,6 @@ static int decode_frame(AVCodecContext *avctx, |
| 289 | 289 |
static av_cold int decode_init(AVCodecContext *avctx){
|
| 290 | 290 |
QpegContext * const a = avctx->priv_data; |
| 291 | 291 |
|
| 292 |
- if (!avctx->palctrl) {
|
|
| 293 |
- av_log(avctx, AV_LOG_FATAL, "Missing required palette via palctrl\n"); |
|
| 294 |
- return -1; |
|
| 295 |
- } |
|
| 296 | 292 |
a->avctx = avctx; |
| 297 | 293 |
avctx->pix_fmt= PIX_FMT_PAL8; |
| 298 | 294 |
a->refdata = av_malloc(avctx->width * avctx->height); |
| ... | ... |
@@ -46,6 +46,7 @@ typedef struct QtrleContext {
|
| 46 | 46 |
const unsigned char *buf; |
| 47 | 47 |
int size; |
| 48 | 48 |
|
| 49 |
+ uint32_t pal[256]; |
|
| 49 | 50 |
} QtrleContext; |
| 50 | 51 |
|
| 51 | 52 |
#define CHECK_STREAM_PTR(n) \ |
| ... | ... |
@@ -511,12 +512,15 @@ static int qtrle_decode_frame(AVCodecContext *avctx, |
| 511 | 511 |
} |
| 512 | 512 |
|
| 513 | 513 |
if(has_palette) {
|
| 514 |
- /* make the palette available on the way out */ |
|
| 515 |
- memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 516 |
- if (s->avctx->palctrl->palette_changed) {
|
|
| 514 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 515 |
+ |
|
| 516 |
+ if (pal) {
|
|
| 517 | 517 |
s->frame.palette_has_changed = 1; |
| 518 |
- s->avctx->palctrl->palette_changed = 0; |
|
| 518 |
+ memcpy(s->pal, pal, AVPALETTE_SIZE); |
|
| 519 | 519 |
} |
| 520 |
+ |
|
| 521 |
+ /* make the palette available on the way out */ |
|
| 522 |
+ memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); |
|
| 520 | 523 |
} |
| 521 | 524 |
|
| 522 | 525 |
done: |
| ... | ... |
@@ -158,9 +158,13 @@ static int raw_decode(AVCodecContext *avctx, |
| 158 | 158 |
(av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PAL))){
|
| 159 | 159 |
frame->data[1]= context->palette; |
| 160 | 160 |
} |
| 161 |
- if (avctx->palctrl && avctx->palctrl->palette_changed) {
|
|
| 162 |
- memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 163 |
- avctx->palctrl->palette_changed = 0; |
|
| 161 |
+ if (avctx->pix_fmt == PIX_FMT_PAL8) {
|
|
| 162 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 163 |
+ |
|
| 164 |
+ if (pal) {
|
|
| 165 |
+ memcpy(frame->data[1], pal, AVPALETTE_SIZE); |
|
| 166 |
+ frame->palette_has_changed = 1; |
|
| 167 |
+ } |
|
| 164 | 168 |
} |
| 165 | 169 |
if(avctx->pix_fmt==PIX_FMT_BGR24 && ((frame->linesize[0]+3)&~3)*avctx->height <= buf_size) |
| 166 | 170 |
frame->linesize[0] = (frame->linesize[0]+3)&~3; |
| ... | ... |
@@ -54,6 +54,7 @@ typedef struct SmcContext {
|
| 54 | 54 |
unsigned char color_quads[COLORS_PER_TABLE * CQUAD]; |
| 55 | 55 |
unsigned char color_octets[COLORS_PER_TABLE * COCTET]; |
| 56 | 56 |
|
| 57 |
+ uint32_t pal[256]; |
|
| 57 | 58 |
} SmcContext; |
| 58 | 59 |
|
| 59 | 60 |
#define GET_BLOCK_COUNT() \ |
| ... | ... |
@@ -110,11 +111,7 @@ static void smc_decode_stream(SmcContext *s) |
| 110 | 110 |
int color_octet_index = 0; |
| 111 | 111 |
|
| 112 | 112 |
/* make the palette available */ |
| 113 |
- memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 114 |
- if (s->avctx->palctrl->palette_changed) {
|
|
| 115 |
- s->frame.palette_has_changed = 1; |
|
| 116 |
- s->avctx->palctrl->palette_changed = 0; |
|
| 117 |
- } |
|
| 113 |
+ memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); |
|
| 118 | 114 |
|
| 119 | 115 |
chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF; |
| 120 | 116 |
stream_ptr += 4; |
| ... | ... |
@@ -440,6 +437,7 @@ static int smc_decode_frame(AVCodecContext *avctx, |
| 440 | 440 |
const uint8_t *buf = avpkt->data; |
| 441 | 441 |
int buf_size = avpkt->size; |
| 442 | 442 |
SmcContext *s = avctx->priv_data; |
| 443 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 443 | 444 |
|
| 444 | 445 |
s->buf = buf; |
| 445 | 446 |
s->size = buf_size; |
| ... | ... |
@@ -452,6 +450,11 @@ static int smc_decode_frame(AVCodecContext *avctx, |
| 452 | 452 |
return -1; |
| 453 | 453 |
} |
| 454 | 454 |
|
| 455 |
+ if (pal) {
|
|
| 456 |
+ s->frame.palette_has_changed = 1; |
|
| 457 |
+ memcpy(s->pal, pal, AVPALETTE_SIZE); |
|
| 458 |
+ } |
|
| 459 |
+ |
|
| 455 | 460 |
smc_decode_stream(s); |
| 456 | 461 |
|
| 457 | 462 |
*data_size = sizeof(AVFrame); |
| ... | ... |
@@ -171,13 +171,6 @@ static int decode_frame(AVCodecContext *avctx, |
| 171 | 171 |
stride = -p->linesize[0]; |
| 172 | 172 |
} |
| 173 | 173 |
|
| 174 |
- if(avctx->pix_fmt == PIX_FMT_PAL8 && avctx->palctrl){
|
|
| 175 |
- memcpy(p->data[1], avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 176 |
- if(avctx->palctrl->palette_changed){
|
|
| 177 |
- p->palette_has_changed = 1; |
|
| 178 |
- avctx->palctrl->palette_changed = 0; |
|
| 179 |
- } |
|
| 180 |
- } |
|
| 181 | 174 |
if(colors){
|
| 182 | 175 |
size_t pal_size; |
| 183 | 176 |
if((colors + first_clr) > 256){
|
| ... | ... |
@@ -60,6 +60,8 @@ typedef struct TsccContext {
|
| 60 | 60 |
unsigned char* decomp_buf; |
| 61 | 61 |
int height; |
| 62 | 62 |
z_stream zstream; |
| 63 |
+ |
|
| 64 |
+ uint32_t pal[256]; |
|
| 63 | 65 |
} CamtasiaContext; |
| 64 | 66 |
|
| 65 | 67 |
/* |
| ... | ... |
@@ -111,11 +113,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 111 | 111 |
|
| 112 | 112 |
/* make the palette available on the way out */ |
| 113 | 113 |
if (c->avctx->pix_fmt == PIX_FMT_PAL8) {
|
| 114 |
- memcpy(c->pic.data[1], c->avctx->palctrl->palette, AVPALETTE_SIZE); |
|
| 115 |
- if (c->avctx->palctrl->palette_changed) {
|
|
| 114 |
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
|
| 115 |
+ |
|
| 116 |
+ if (pal) {
|
|
| 116 | 117 |
c->pic.palette_has_changed = 1; |
| 117 |
- c->avctx->palctrl->palette_changed = 0; |
|
| 118 |
+ memcpy(c->pal, pal, AVPALETTE_SIZE); |
|
| 118 | 119 |
} |
| 120 |
+ memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE); |
|
| 119 | 121 |
} |
| 120 | 122 |
|
| 121 | 123 |
*data_size = sizeof(AVFrame); |
| ... | ... |
@@ -365,15 +365,14 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) |
| 365 | 365 |
/* This is true for all paletted codecs implemented in ffmpeg */ |
| 366 | 366 |
if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
|
| 367 | 367 |
int av_unused i; |
| 368 |
- st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); |
|
| 369 | 368 |
#if HAVE_BIGENDIAN |
| 370 | 369 |
for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) |
| 371 |
- st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); |
|
| 370 |
+ asf_st->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); |
|
| 372 | 371 |
#else |
| 373 |
- memcpy(st->codec->palctrl->palette, st->codec->extradata, |
|
| 374 |
- FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); |
|
| 372 |
+ memcpy(asf_st->palette, st->codec->extradata, |
|
| 373 |
+ FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); |
|
| 375 | 374 |
#endif |
| 376 |
- st->codec->palctrl->palette_changed = 1; |
|
| 375 |
+ asf_st->palette_changed = 1; |
|
| 377 | 376 |
} |
| 378 | 377 |
|
| 379 | 378 |
st->codec->codec_tag = tag1; |
| ... | ... |
@@ -966,6 +965,17 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk |
| 966 | 966 |
asf_st->pkt.stream_index = asf->stream_index; |
| 967 | 967 |
asf_st->pkt.pos = |
| 968 | 968 |
asf_st->packet_pos= asf->packet_pos; |
| 969 |
+ if (asf_st->pkt.data && asf_st->palette_changed) {
|
|
| 970 |
+ uint8_t *pal; |
|
| 971 |
+ pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, |
|
| 972 |
+ AVPALETTE_SIZE); |
|
| 973 |
+ if (!pal) {
|
|
| 974 |
+ av_log(s, AV_LOG_ERROR, "Cannot append palette to packet\n"); |
|
| 975 |
+ } else {
|
|
| 976 |
+ memcpy(pal, asf_st->palette, AVPALETTE_SIZE); |
|
| 977 |
+ asf_st->palette_changed = 0; |
|
| 978 |
+ } |
|
| 979 |
+ } |
|
| 969 | 980 |
//printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
|
| 970 | 981 |
//asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & AV_PKT_FLAG_KEY, |
| 971 | 982 |
//s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO, asf->packet_obj_size); |
| ... | ... |
@@ -1127,7 +1137,6 @@ static int asf_read_close(AVFormatContext *s) |
| 1127 | 1127 |
asf_reset_header(s); |
| 1128 | 1128 |
for(i=0;i<s->nb_streams;i++) {
|
| 1129 | 1129 |
AVStream *st = s->streams[i]; |
| 1130 |
- av_free(st->codec->palctrl); |
|
| 1131 | 1130 |
} |
| 1132 | 1131 |
return 0; |
| 1133 | 1132 |
} |
| ... | ... |
@@ -590,15 +590,14 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 590 | 590 |
/* This code assumes that extradata contains only palette. */ |
| 591 | 591 |
/* This is true for all paletted codecs implemented in FFmpeg. */ |
| 592 | 592 |
if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
|
| 593 |
- st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); |
|
| 594 | 593 |
#if HAVE_BIGENDIAN |
| 595 | 594 |
for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) |
| 596 |
- st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); |
|
| 595 |
+ ast->pal[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); |
|
| 597 | 596 |
#else |
| 598 |
- memcpy(st->codec->palctrl->palette, st->codec->extradata, |
|
| 597 |
+ memcpy(ast->pal, st->codec->extradata, |
|
| 599 | 598 |
FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); |
| 600 | 599 |
#endif |
| 601 |
- st->codec->palctrl->palette_changed = 1; |
|
| 600 |
+ ast->has_pal = 1; |
|
| 602 | 601 |
} |
| 603 | 602 |
|
| 604 | 603 |
print_tag("video", tag1, 0);
|
| ... | ... |
@@ -932,14 +931,14 @@ resync: |
| 932 | 932 |
return err; |
| 933 | 933 |
|
| 934 | 934 |
if(ast->has_pal && pkt->data && pkt->size<(unsigned)INT_MAX/2){
|
| 935 |
- void *ptr= av_realloc(pkt->data, pkt->size + 4*256 + FF_INPUT_BUFFER_PADDING_SIZE); |
|
| 936 |
- if(ptr){
|
|
| 937 |
- ast->has_pal=0; |
|
| 938 |
- pkt->size += 4*256; |
|
| 939 |
- pkt->data= ptr; |
|
| 940 |
- memcpy(pkt->data + pkt->size - 4*256, ast->pal, 4*256); |
|
| 941 |
- }else |
|
| 942 |
- av_log(s, AV_LOG_ERROR, "Failed to append palette\n"); |
|
| 935 |
+ uint8_t *pal; |
|
| 936 |
+ pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); |
|
| 937 |
+ if(!pal){
|
|
| 938 |
+ av_log(s, AV_LOG_ERROR, "Failed to allocate data for palette\n"); |
|
| 939 |
+ }else{
|
|
| 940 |
+ memcpy(pal, ast->pal, AVPALETTE_SIZE); |
|
| 941 |
+ ast->has_pal = 0; |
|
| 942 |
+ } |
|
| 943 | 943 |
} |
| 944 | 944 |
|
| 945 | 945 |
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
|
| ... | ... |
@@ -1340,7 +1339,6 @@ static int avi_read_close(AVFormatContext *s) |
| 1340 | 1340 |
for(i=0;i<s->nb_streams;i++) {
|
| 1341 | 1341 |
AVStream *st = s->streams[i]; |
| 1342 | 1342 |
AVIStream *ast = st->priv_data; |
| 1343 |
- av_free(st->codec->palctrl); |
|
| 1344 | 1343 |
if (ast) {
|
| 1345 | 1344 |
if (ast->sub_ctx) {
|
| 1346 | 1345 |
av_freep(&ast->sub_ctx->pb); |
| ... | ... |
@@ -86,8 +86,6 @@ typedef struct IdcinDemuxContext {
|
| 86 | 86 |
int audio_present; |
| 87 | 87 |
|
| 88 | 88 |
int64_t pts; |
| 89 |
- |
|
| 90 |
- AVPaletteControl palctrl; |
|
| 91 | 89 |
} IdcinDemuxContext; |
| 92 | 90 |
|
| 93 | 91 |
static int idcin_probe(AVProbeData *p) |
| ... | ... |
@@ -172,8 +170,6 @@ static int idcin_read_header(AVFormatContext *s, |
| 172 | 172 |
if (avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) != |
| 173 | 173 |
HUFFMAN_TABLE_SIZE) |
| 174 | 174 |
return AVERROR(EIO); |
| 175 |
- /* save a reference in order to transport the palette */ |
|
| 176 |
- st->codec->palctrl = &idcin->palctrl; |
|
| 177 | 175 |
|
| 178 | 176 |
/* if sample rate is 0, assume no audio */ |
| 179 | 177 |
if (sample_rate) {
|
| ... | ... |
@@ -226,6 +222,7 @@ static int idcin_read_packet(AVFormatContext *s, |
| 226 | 226 |
int palette_scale; |
| 227 | 227 |
unsigned char r, g, b; |
| 228 | 228 |
unsigned char palette_buffer[768]; |
| 229 |
+ uint32_t palette[256]; |
|
| 229 | 230 |
|
| 230 | 231 |
if (s->pb->eof_reached) |
| 231 | 232 |
return AVERROR(EIO); |
| ... | ... |
@@ -236,7 +233,6 @@ static int idcin_read_packet(AVFormatContext *s, |
| 236 | 236 |
return AVERROR(EIO); |
| 237 | 237 |
} else if (command == 1) {
|
| 238 | 238 |
/* trigger a palette change */ |
| 239 |
- idcin->palctrl.palette_changed = 1; |
|
| 240 | 239 |
if (avio_read(pb, palette_buffer, 768) != 768) |
| 241 | 240 |
return AVERROR(EIO); |
| 242 | 241 |
/* scale the palette as necessary */ |
| ... | ... |
@@ -251,7 +247,7 @@ static int idcin_read_packet(AVFormatContext *s, |
| 251 | 251 |
r = palette_buffer[i * 3 ] << palette_scale; |
| 252 | 252 |
g = palette_buffer[i * 3 + 1] << palette_scale; |
| 253 | 253 |
b = palette_buffer[i * 3 + 2] << palette_scale; |
| 254 |
- idcin->palctrl.palette[i] = (r << 16) | (g << 8) | (b); |
|
| 254 |
+ palette[i] = (r << 16) | (g << 8) | (b); |
|
| 255 | 255 |
} |
| 256 | 256 |
} |
| 257 | 257 |
|
| ... | ... |
@@ -262,6 +258,15 @@ static int idcin_read_packet(AVFormatContext *s, |
| 262 | 262 |
ret= av_get_packet(pb, pkt, chunk_size); |
| 263 | 263 |
if (ret < 0) |
| 264 | 264 |
return ret; |
| 265 |
+ if (command == 1) {
|
|
| 266 |
+ uint8_t *pal; |
|
| 267 |
+ |
|
| 268 |
+ pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, |
|
| 269 |
+ AVPALETTE_SIZE); |
|
| 270 |
+ if (ret < 0) |
|
| 271 |
+ return ret; |
|
| 272 |
+ memcpy(pal, palette, AVPALETTE_SIZE); |
|
| 273 |
+ } |
|
| 265 | 274 |
pkt->stream_index = idcin->video_stream_index; |
| 266 | 275 |
pkt->pts = idcin->pts; |
| 267 | 276 |
} else {
|
| ... | ... |
@@ -97,6 +97,8 @@ typedef struct IPMVEContext {
|
| 97 | 97 |
unsigned int video_width; |
| 98 | 98 |
unsigned int video_height; |
| 99 | 99 |
int64_t video_pts; |
| 100 |
+ uint32_t palette[256]; |
|
| 101 |
+ int has_palette; |
|
| 100 | 102 |
|
| 101 | 103 |
unsigned int audio_bits; |
| 102 | 104 |
unsigned int audio_channels; |
| ... | ... |
@@ -116,8 +118,6 @@ typedef struct IPMVEContext {
|
| 116 | 116 |
|
| 117 | 117 |
int64_t next_chunk_offset; |
| 118 | 118 |
|
| 119 |
- AVPaletteControl palette_control; |
|
| 120 |
- |
|
| 121 | 119 |
} IPMVEContext; |
| 122 | 120 |
|
| 123 | 121 |
static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, |
| ... | ... |
@@ -162,6 +162,17 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, |
| 162 | 162 |
if (av_new_packet(pkt, s->decode_map_chunk_size + s->video_chunk_size)) |
| 163 | 163 |
return CHUNK_NOMEM; |
| 164 | 164 |
|
| 165 |
+ if (s->has_palette) {
|
|
| 166 |
+ uint8_t *pal; |
|
| 167 |
+ |
|
| 168 |
+ pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, |
|
| 169 |
+ AVPALETTE_SIZE); |
|
| 170 |
+ if (pal) {
|
|
| 171 |
+ memcpy(pal, s->palette, AVPALETTE_SIZE); |
|
| 172 |
+ s->has_palette = 0; |
|
| 173 |
+ } |
|
| 174 |
+ } |
|
| 175 |
+ |
|
| 165 | 176 |
pkt->pos= s->decode_map_chunk_offset; |
| 166 | 177 |
avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET); |
| 167 | 178 |
s->decode_map_chunk_offset = 0; |
| ... | ... |
@@ -456,10 +467,9 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, |
| 456 | 456 |
r = scratch[j++] * 4; |
| 457 | 457 |
g = scratch[j++] * 4; |
| 458 | 458 |
b = scratch[j++] * 4; |
| 459 |
- s->palette_control.palette[i] = (r << 16) | (g << 8) | (b); |
|
| 459 |
+ s->palette[i] = (r << 16) | (g << 8) | (b); |
|
| 460 | 460 |
} |
| 461 |
- /* indicate a palette change */ |
|
| 462 |
- s->palette_control.palette_changed = 1; |
|
| 461 |
+ s->has_palette = 1; |
|
| 463 | 462 |
break; |
| 464 | 463 |
|
| 465 | 464 |
case OPCODE_SET_PALETTE_COMPRESSED: |
| ... | ... |
@@ -573,9 +583,6 @@ static int ipmovie_read_header(AVFormatContext *s, |
| 573 | 573 |
st->codec->height = ipmovie->video_height; |
| 574 | 574 |
st->codec->bits_per_coded_sample = ipmovie->video_bpp; |
| 575 | 575 |
|
| 576 |
- /* palette considerations */ |
|
| 577 |
- st->codec->palctrl = &ipmovie->palette_control; |
|
| 578 |
- |
|
| 579 | 576 |
if (ipmovie->audio_type) {
|
| 580 | 577 |
st = av_new_stream(s, 0); |
| 581 | 578 |
if (!st) |
| ... | ... |
@@ -123,6 +123,8 @@ typedef struct MOVStreamContext {
|
| 123 | 123 |
int width; ///< tkhd width |
| 124 | 124 |
int height; ///< tkhd height |
| 125 | 125 |
int dts_shift; ///< dts shift when ctts is negative |
| 126 |
+ uint32_t palette[256]; |
|
| 127 |
+ int has_palette; |
|
| 126 | 128 |
} MOVStreamContext; |
| 127 | 129 |
|
| 128 | 130 |
typedef struct MOVContext {
|
| ... | ... |
@@ -1027,7 +1027,6 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) |
| 1027 | 1027 |
unsigned int color_start, color_count, color_end; |
| 1028 | 1028 |
unsigned char r, g, b; |
| 1029 | 1029 |
|
| 1030 |
- st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl)); |
|
| 1031 | 1030 |
if (color_greyscale) {
|
| 1032 | 1031 |
int color_index, color_dec; |
| 1033 | 1032 |
/* compute the greyscale palette */ |
| ... | ... |
@@ -1037,7 +1036,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) |
| 1037 | 1037 |
color_dec = 256 / (color_count - 1); |
| 1038 | 1038 |
for (j = 0; j < color_count; j++) {
|
| 1039 | 1039 |
r = g = b = color_index; |
| 1040 |
- st->codec->palctrl->palette[j] = |
|
| 1040 |
+ sc->palette[j] = |
|
| 1041 | 1041 |
(r << 16) | (g << 8) | (b); |
| 1042 | 1042 |
color_index -= color_dec; |
| 1043 | 1043 |
if (color_index < 0) |
| ... | ... |
@@ -1058,7 +1057,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) |
| 1058 | 1058 |
r = color_table[j * 3 + 0]; |
| 1059 | 1059 |
g = color_table[j * 3 + 1]; |
| 1060 | 1060 |
b = color_table[j * 3 + 2]; |
| 1061 |
- st->codec->palctrl->palette[j] = |
|
| 1061 |
+ sc->palette[j] = |
|
| 1062 | 1062 |
(r << 16) | (g << 8) | (b); |
| 1063 | 1063 |
} |
| 1064 | 1064 |
} else {
|
| ... | ... |
@@ -1080,12 +1079,12 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) |
| 1080 | 1080 |
avio_r8(pb); |
| 1081 | 1081 |
b = avio_r8(pb); |
| 1082 | 1082 |
avio_r8(pb); |
| 1083 |
- st->codec->palctrl->palette[j] = |
|
| 1083 |
+ sc->palette[j] = |
|
| 1084 | 1084 |
(r << 16) | (g << 8) | (b); |
| 1085 | 1085 |
} |
| 1086 | 1086 |
} |
| 1087 | 1087 |
} |
| 1088 |
- st->codec->palctrl->palette_changed = 1; |
|
| 1088 |
+ sc->has_palette = 1; |
|
| 1089 | 1089 |
} |
| 1090 | 1090 |
} else if(st->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
|
| 1091 | 1091 |
int bits_per_sample, flags; |
| ... | ... |
@@ -2433,6 +2432,17 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 2433 | 2433 |
ret = av_get_packet(sc->pb, pkt, sample->size); |
| 2434 | 2434 |
if (ret < 0) |
| 2435 | 2435 |
return ret; |
| 2436 |
+ if (sc->has_palette) {
|
|
| 2437 |
+ uint8_t *pal; |
|
| 2438 |
+ |
|
| 2439 |
+ pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); |
|
| 2440 |
+ if (!pal) {
|
|
| 2441 |
+ av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n"); |
|
| 2442 |
+ } else {
|
|
| 2443 |
+ memcpy(pal, sc->palette, AVPALETTE_SIZE); |
|
| 2444 |
+ sc->has_palette = 0; |
|
| 2445 |
+ } |
|
| 2446 |
+ } |
|
| 2436 | 2447 |
#if CONFIG_DV_DEMUXER |
| 2437 | 2448 |
if (mov->dv_demux && sc->dv_audio_container) {
|
| 2438 | 2449 |
dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size); |