comparison asf.c @ 297:85d558a18134 libavformat

Make avi and asf demuxer export palette in palctrl
author rtognimp
date Sun, 02 Nov 2003 21:55:38 +0000
parents a313e1080322
children 6ee1b02f9b2a
comparison
equal deleted inserted replaced
296:252946de6d3f 297:85d558a18134
906 if (size > 40) { 906 if (size > 40) {
907 st->codec.extradata_size = size - 40; 907 st->codec.extradata_size = size - 40;
908 st->codec.extradata = av_mallocz(st->codec.extradata_size); 908 st->codec.extradata = av_mallocz(st->codec.extradata_size);
909 get_buffer(pb, st->codec.extradata, st->codec.extradata_size); 909 get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
910 } 910 }
911
912 /* Extract palette from extradata if bpp <= 8 */
913 /* This code assumes that extradata contains only palette */
914 /* This is true for all paletted codecs implemented in ffmpeg */
915 if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) {
916 st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl));
917 #ifdef WORDS_BIGENDIAN
918 for (i = 0; i < FFMIN(st->codec.extradata_size / 4, 256); i++)
919 st->codec.palctrl->palette[i] = bswap_32(st->codec.extradata)[i * 4]);
920 #else
921 memcpy(st->codec.palctrl->palette, st->codec.extradata,
922 FFMIN(st->codec.extradata_size, AVPALETTE_SIZE));
923 #endif
924 st->codec.palctrl->palette_changed = 1;
925 }
926
911 st->codec.codec_tag = tag1; 927 st->codec.codec_tag = tag1;
912 st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); 928 st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
913 } 929 }
914 pos2 = url_ftell(pb); 930 pos2 = url_ftell(pb);
915 url_fskip(pb, gsize - (pos2 - pos1 + 24)); 931 url_fskip(pb, gsize - (pos2 - pos1 + 24));
1224 1240
1225 for(i=0;i<s->nb_streams;i++) { 1241 for(i=0;i<s->nb_streams;i++) {
1226 AVStream *st = s->streams[i]; 1242 AVStream *st = s->streams[i];
1227 av_free(st->priv_data); 1243 av_free(st->priv_data);
1228 av_free(st->codec.extradata); 1244 av_free(st->codec.extradata);
1245 av_free(st->codec.palctrl);
1229 } 1246 }
1230 return 0; 1247 return 0;
1231 } 1248 }
1232 1249
1233 static int asf_read_seek(AVFormatContext *s, int64_t pts) 1250 static int asf_read_seek(AVFormatContext *s, int64_t pts)