diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2011-04-09 15:49:51 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2011-04-15 18:02:05 +0200 |
commit | 2d8591c27e2dc582a7020e2580e16278dbfbddff (patch) | |
tree | 5e251cc6e974c0b9e2c99b3f6e622b4983e4941a /libavformat/asfdec.c | |
parent | 4de339e219908ff44cbb1d823edeeead3b8facda (diff) | |
download | ffmpeg-2d8591c27e2dc582a7020e2580e16278dbfbddff.tar.gz |
make containers pass palette change in AVPacket
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavformat/asfdec.c')
-rw-r--r-- | libavformat/asfdec.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 30828ad6ff..36e9efad75 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -365,15 +365,14 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) /* This is true for all paletted codecs implemented in ffmpeg */ if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) { int av_unused i; - st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #if HAVE_BIGENDIAN for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) - st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); + asf_st->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); #else - memcpy(st->codec->palctrl->palette, st->codec->extradata, - FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); + memcpy(asf_st->palette, st->codec->extradata, + FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif - st->codec->palctrl->palette_changed = 1; + asf_st->palette_changed = 1; } st->codec->codec_tag = tag1; @@ -966,6 +965,17 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk asf_st->pkt.stream_index = asf->stream_index; asf_st->pkt.pos = asf_st->packet_pos= asf->packet_pos; + if (asf_st->pkt.data && asf_st->palette_changed) { + uint8_t *pal; + pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, + AVPALETTE_SIZE); + if (!pal) { + av_log(s, AV_LOG_ERROR, "Cannot append palette to packet\n"); + } else { + memcpy(pal, asf_st->palette, AVPALETTE_SIZE); + asf_st->palette_changed = 0; + } + } //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & AV_PKT_FLAG_KEY, //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) asf_reset_header(s); for(i=0;i<s->nb_streams;i++) { AVStream *st = s->streams[i]; - av_free(st->codec->palctrl); } return 0; } |