Commit bedf2328 authored by bcoudurier's avatar bcoudurier

allocate palette in codec directly

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17976 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent fdb00712
...@@ -126,7 +126,6 @@ typedef struct MOVContext { ...@@ -126,7 +126,6 @@ typedef struct MOVContext {
int64_t duration; /* duration of the longest track */ int64_t duration; /* duration of the longest track */
int found_moov; /* when both 'moov' and 'mdat' sections has been found */ int found_moov; /* when both 'moov' and 'mdat' sections has been found */
int found_mdat; /* we suppose we have enough data to read the file */ int found_mdat; /* we suppose we have enough data to read the file */
AVPaletteControl palette_control;
DVDemuxContext *dv_demux; DVDemuxContext *dv_demux;
AVFormatContext *dv_fctx; AVFormatContext *dv_fctx;
int isom; /* 1 if file is ISO Media (mp4/3gp) */ int isom; /* 1 if file is ISO Media (mp4/3gp) */
......
...@@ -754,6 +754,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -754,6 +754,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
unsigned int color_start, color_count, color_end; unsigned int color_start, color_count, color_end;
unsigned char r, g, b; unsigned char r, g, b;
st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl));
if (color_greyscale) { if (color_greyscale) {
int color_index, color_dec; int color_index, color_dec;
/* compute the greyscale palette */ /* compute the greyscale palette */
...@@ -763,7 +764,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -763,7 +764,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
color_dec = 256 / (color_count - 1); color_dec = 256 / (color_count - 1);
for (j = 0; j < color_count; j++) { for (j = 0; j < color_count; j++) {
r = g = b = color_index; r = g = b = color_index;
c->palette_control.palette[j] = st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b); (r << 16) | (g << 8) | (b);
color_index -= color_dec; color_index -= color_dec;
if (color_index < 0) if (color_index < 0)
...@@ -784,7 +785,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -784,7 +785,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
r = color_table[j * 4 + 0]; r = color_table[j * 4 + 0];
g = color_table[j * 4 + 1]; g = color_table[j * 4 + 1];
b = color_table[j * 4 + 2]; b = color_table[j * 4 + 2];
c->palette_control.palette[j] = st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b); (r << 16) | (g << 8) | (b);
} }
} else { } else {
...@@ -806,15 +807,13 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) ...@@ -806,15 +807,13 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
get_byte(pb); get_byte(pb);
b = get_byte(pb); b = get_byte(pb);
get_byte(pb); get_byte(pb);
c->palette_control.palette[j] = st->codec->palctrl->palette[j] =
(r << 16) | (g << 8) | (b); (r << 16) | (g << 8) | (b);
} }
} }
} }
st->codec->palctrl = &c->palette_control;
st->codec->palctrl->palette_changed = 1; st->codec->palctrl->palette_changed = 1;
} else }
st->codec->palctrl = NULL;
} else if(st->codec->codec_type==CODEC_TYPE_AUDIO) { } else if(st->codec->codec_type==CODEC_TYPE_AUDIO) {
int bits_per_sample, flags; int bits_per_sample, flags;
uint16_t version = get_be16(pb); uint16_t version = get_be16(pb);
...@@ -2000,7 +1999,8 @@ static int mov_read_close(AVFormatContext *s) ...@@ -2000,7 +1999,8 @@ static int mov_read_close(AVFormatContext *s)
int i, j; int i, j;
for (i = 0; i < s->nb_streams; i++) { for (i = 0; i < s->nb_streams; i++) {
MOVStreamContext *sc = s->streams[i]->priv_data; AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
av_freep(&sc->ctts_data); av_freep(&sc->ctts_data);
for (j = 0; j < sc->drefs_count; j++) for (j = 0; j < sc->drefs_count; j++)
...@@ -2008,6 +2008,8 @@ static int mov_read_close(AVFormatContext *s) ...@@ -2008,6 +2008,8 @@ static int mov_read_close(AVFormatContext *s)
av_freep(&sc->drefs); av_freep(&sc->drefs);
if (sc->pb && sc->pb != s->pb) if (sc->pb && sc->pb != s->pb)
url_fclose(sc->pb); url_fclose(sc->pb);
av_freep(&st->codec->palctrl);
} }
if (mov->dv_demux) { if (mov->dv_demux) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment