Mercurial > libavformat.hg
comparison mov.c @ 4719:5dd75af88ade libavformat
allocate palette in codec directly
author | bcoudurier |
---|---|
date | Sun, 15 Mar 2009 09:44:57 +0000 |
parents | 7bf091a4b6d9 |
children | b39c3e7a6622 |
comparison
equal
deleted
inserted
replaced
4718:7bf091a4b6d9 | 4719:5dd75af88ade |
---|---|
752 (color_depth == 8)) { | 752 (color_depth == 8)) { |
753 /* for palette traversal */ | 753 /* for palette traversal */ |
754 unsigned int color_start, color_count, color_end; | 754 unsigned int color_start, color_count, color_end; |
755 unsigned char r, g, b; | 755 unsigned char r, g, b; |
756 | 756 |
757 st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl)); | |
757 if (color_greyscale) { | 758 if (color_greyscale) { |
758 int color_index, color_dec; | 759 int color_index, color_dec; |
759 /* compute the greyscale palette */ | 760 /* compute the greyscale palette */ |
760 st->codec->bits_per_coded_sample = color_depth; | 761 st->codec->bits_per_coded_sample = color_depth; |
761 color_count = 1 << color_depth; | 762 color_count = 1 << color_depth; |
762 color_index = 255; | 763 color_index = 255; |
763 color_dec = 256 / (color_count - 1); | 764 color_dec = 256 / (color_count - 1); |
764 for (j = 0; j < color_count; j++) { | 765 for (j = 0; j < color_count; j++) { |
765 r = g = b = color_index; | 766 r = g = b = color_index; |
766 c->palette_control.palette[j] = | 767 st->codec->palctrl->palette[j] = |
767 (r << 16) | (g << 8) | (b); | 768 (r << 16) | (g << 8) | (b); |
768 color_index -= color_dec; | 769 color_index -= color_dec; |
769 if (color_index < 0) | 770 if (color_index < 0) |
770 color_index = 0; | 771 color_index = 0; |
771 } | 772 } |
782 | 783 |
783 for (j = 0; j < color_count; j++) { | 784 for (j = 0; j < color_count; j++) { |
784 r = color_table[j * 4 + 0]; | 785 r = color_table[j * 4 + 0]; |
785 g = color_table[j * 4 + 1]; | 786 g = color_table[j * 4 + 1]; |
786 b = color_table[j * 4 + 2]; | 787 b = color_table[j * 4 + 2]; |
787 c->palette_control.palette[j] = | 788 st->codec->palctrl->palette[j] = |
788 (r << 16) | (g << 8) | (b); | 789 (r << 16) | (g << 8) | (b); |
789 } | 790 } |
790 } else { | 791 } else { |
791 /* load the palette from the file */ | 792 /* load the palette from the file */ |
792 color_start = get_be32(pb); | 793 color_start = get_be32(pb); |
804 get_byte(pb); | 805 get_byte(pb); |
805 g = get_byte(pb); | 806 g = get_byte(pb); |
806 get_byte(pb); | 807 get_byte(pb); |
807 b = get_byte(pb); | 808 b = get_byte(pb); |
808 get_byte(pb); | 809 get_byte(pb); |
809 c->palette_control.palette[j] = | 810 st->codec->palctrl->palette[j] = |
810 (r << 16) | (g << 8) | (b); | 811 (r << 16) | (g << 8) | (b); |
811 } | 812 } |
812 } | 813 } |
813 } | 814 } |
814 st->codec->palctrl = &c->palette_control; | |
815 st->codec->palctrl->palette_changed = 1; | 815 st->codec->palctrl->palette_changed = 1; |
816 } else | 816 } |
817 st->codec->palctrl = NULL; | |
818 } else if(st->codec->codec_type==CODEC_TYPE_AUDIO) { | 817 } else if(st->codec->codec_type==CODEC_TYPE_AUDIO) { |
819 int bits_per_sample, flags; | 818 int bits_per_sample, flags; |
820 uint16_t version = get_be16(pb); | 819 uint16_t version = get_be16(pb); |
821 | 820 |
822 st->codec->codec_id = id; | 821 st->codec->codec_id = id; |
1998 { | 1997 { |
1999 MOVContext *mov = s->priv_data; | 1998 MOVContext *mov = s->priv_data; |
2000 int i, j; | 1999 int i, j; |
2001 | 2000 |
2002 for (i = 0; i < s->nb_streams; i++) { | 2001 for (i = 0; i < s->nb_streams; i++) { |
2003 MOVStreamContext *sc = s->streams[i]->priv_data; | 2002 AVStream *st = s->streams[i]; |
2003 MOVStreamContext *sc = st->priv_data; | |
2004 | 2004 |
2005 av_freep(&sc->ctts_data); | 2005 av_freep(&sc->ctts_data); |
2006 for (j = 0; j < sc->drefs_count; j++) | 2006 for (j = 0; j < sc->drefs_count; j++) |
2007 av_freep(&sc->drefs[j].path); | 2007 av_freep(&sc->drefs[j].path); |
2008 av_freep(&sc->drefs); | 2008 av_freep(&sc->drefs); |
2009 if (sc->pb && sc->pb != s->pb) | 2009 if (sc->pb && sc->pb != s->pb) |
2010 url_fclose(sc->pb); | 2010 url_fclose(sc->pb); |
2011 | |
2012 av_freep(&st->codec->palctrl); | |
2011 } | 2013 } |
2012 | 2014 |
2013 if (mov->dv_demux) { | 2015 if (mov->dv_demux) { |
2014 for(i = 0; i < mov->dv_fctx->nb_streams; i++) { | 2016 for(i = 0; i < mov->dv_fctx->nb_streams; i++) { |
2015 av_freep(&mov->dv_fctx->streams[i]->codec); | 2017 av_freep(&mov->dv_fctx->streams[i]->codec); |