cosmetics: sample_to_chunk -> stsc

Originally committed as revision 17054 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Baptiste Coudurier 16 years ago
parent a234e38d6e
commit 04e06cfa20
  1. 36
      libavformat/mov.c

@ -113,8 +113,8 @@ typedef struct MOVStreamContext {
MOVStts *stts_data; MOVStts *stts_data;
unsigned int ctts_count; unsigned int ctts_count;
MOVStts *ctts_data; MOVStts *ctts_data;
unsigned int sample_to_chunk_sz; unsigned int stsc_count;
MOVStsc *sample_to_chunk; MOVStsc *stsc_data;
int ctts_index; int ctts_index;
int ctts_sample; int ctts_sample;
unsigned int sample_size; unsigned int sample_size;
@ -1067,19 +1067,19 @@ static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
entries = get_be32(pb); entries = get_be32(pb);
if(entries >= UINT_MAX / sizeof(*sc->sample_to_chunk)) if(entries >= UINT_MAX / sizeof(*sc->stsc_data))
return -1; return -1;
dprintf(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries); dprintf(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
sc->sample_to_chunk_sz = entries; sc->stsc_count = entries;
sc->sample_to_chunk = av_malloc(entries * sizeof(*sc->sample_to_chunk)); sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));
if (!sc->sample_to_chunk) if (!sc->stsc_data)
return -1; return -1;
for(i=0; i<entries; i++) { for(i=0; i<entries; i++) {
sc->sample_to_chunk[i].first = get_be32(pb); sc->stsc_data[i].first = get_be32(pb);
sc->sample_to_chunk[i].count = get_be32(pb); sc->stsc_data[i].count = get_be32(pb);
sc->sample_to_chunk[i].id = get_be32(pb); sc->stsc_data[i].id = get_be32(pb);
} }
return 0; return 0;
} }
@ -1249,10 +1249,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
st->nb_frames = sc->sample_count; st->nb_frames = sc->sample_count;
for (i = 0; i < sc->chunk_count; i++) { for (i = 0; i < sc->chunk_count; i++) {
current_offset = sc->chunk_offsets[i]; current_offset = sc->chunk_offsets[i];
if (stsc_index + 1 < sc->sample_to_chunk_sz && if (stsc_index + 1 < sc->stsc_count &&
i + 1 == sc->sample_to_chunk[stsc_index + 1].first) i + 1 == sc->stsc_data[stsc_index + 1].first)
stsc_index++; stsc_index++;
for (j = 0; j < sc->sample_to_chunk[stsc_index].count; j++) { for (j = 0; j < sc->stsc_data[stsc_index].count; j++) {
if (current_sample >= sc->sample_count) { if (current_sample >= sc->sample_count) {
av_log(mov->fc, AV_LOG_ERROR, "wrong sample count\n"); av_log(mov->fc, AV_LOG_ERROR, "wrong sample count\n");
goto out; goto out;
@ -1265,7 +1265,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
} }
sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample]; sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample];
if(sc->pseudo_stream_id == -1 || if(sc->pseudo_stream_id == -1 ||
sc->sample_to_chunk[stsc_index].id - 1 == sc->pseudo_stream_id) { sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) {
av_add_index_entry(st, current_offset, current_dts, sample_size, distance, av_add_index_entry(st, current_offset, current_dts, sample_size, distance,
keyframe ? AVINDEX_KEYFRAME : 0); keyframe ? AVINDEX_KEYFRAME : 0);
dprintf(mov->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", " dprintf(mov->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
@ -1289,10 +1289,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
unsigned int frames = 1; unsigned int frames = 1;
for (i = 0; i < sc->chunk_count; i++) { for (i = 0; i < sc->chunk_count; i++) {
current_offset = sc->chunk_offsets[i]; current_offset = sc->chunk_offsets[i];
if (stsc_index + 1 < sc->sample_to_chunk_sz && if (stsc_index + 1 < sc->stsc_count &&
i + 1 == sc->sample_to_chunk[stsc_index + 1].first) i + 1 == sc->stsc_data[stsc_index + 1].first)
stsc_index++; stsc_index++;
chunk_samples = sc->sample_to_chunk[stsc_index].count; chunk_samples = sc->stsc_data[stsc_index].count;
/* get chunk size, beware of alaw/ulaw/mace */ /* get chunk size, beware of alaw/ulaw/mace */
if (sc->samples_per_frame > 0 && if (sc->samples_per_frame > 0 &&
(chunk_samples * sc->bytes_per_frame % sc->samples_per_frame == 0)) { (chunk_samples * sc->bytes_per_frame % sc->samples_per_frame == 0)) {
@ -1355,7 +1355,7 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
return ret; return ret;
/* sanity checks */ /* sanity checks */
if(sc->chunk_count && (!sc->stts_count || !sc->sample_to_chunk_sz || if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
(!sc->sample_size && !sc->sample_count))){ (!sc->sample_size && !sc->sample_count))){
av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
st->index); st->index);
@ -1403,7 +1403,7 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
/* Do not need those anymore. */ /* Do not need those anymore. */
av_freep(&sc->chunk_offsets); av_freep(&sc->chunk_offsets);
av_freep(&sc->sample_to_chunk); av_freep(&sc->stsc_data);
av_freep(&sc->sample_sizes); av_freep(&sc->sample_sizes);
av_freep(&sc->keyframes); av_freep(&sc->keyframes);
av_freep(&sc->stts_data); av_freep(&sc->stts_data);

Loading…
Cancel
Save