use tell() to obtain data chunk offset

This commit is contained in:
nu774 2013-10-30 14:27:28 +09:00
parent d533c8e002
commit 3de0e22dcc
3 changed files with 3 additions and 8 deletions

View File

@ -193,12 +193,10 @@ int caf_parse(caf_reader_t *reader, int64_t *data_length)
} else if (fcc == M4AF_FOURCC('d','a','t','a')) { } else if (fcc == M4AF_FOURCC('d','a','t','a')) {
TRY_IO(pcm_skip(&reader->io, 4)); /* mEditCount */ TRY_IO(pcm_skip(&reader->io, 4)); /* mEditCount */
*data_length = (chunk_size == ~0ULL) ? chunk_size : chunk_size - 4; *data_length = (chunk_size == ~0ULL) ? chunk_size : chunk_size - 4;
reader->data_offset += 12; reader->data_offset = pcm_tell(&reader->io);
break; break;
} else } else
TRY_IO(pcm_skip(&reader->io, chunk_size)); TRY_IO(pcm_skip(&reader->io, chunk_size));
reader->data_offset += (chunk_size + 8);
} }
ENSURE(reader->sample_format.channels_per_frame); ENSURE(reader->sample_format.channels_per_frame);
ENSURE(fcc == M4AF_FOURCC('d','a','t','a')); ENSURE(fcc == M4AF_FOURCC('d','a','t','a'));

View File

@ -675,7 +675,7 @@ int parse_raw_spec(const char *spec, pcm_sample_description_t *desc)
static pcm_io_vtbl_t pcm_io_vtbl = { static pcm_io_vtbl_t pcm_io_vtbl = {
read_callback, seek_callback, tell_callback read_callback, seek_callback, tell_callback
}; };
static pcm_io_vtbl_t pcm_io_vtbl_noseek = { read_callback, 0, 0 }; static pcm_io_vtbl_t pcm_io_vtbl_noseek = { read_callback, 0, tell_callback };
static static
pcm_reader_t *open_input(aacenc_param_ex_t *params) pcm_reader_t *open_input(aacenc_param_ex_t *params)

View File

@ -93,7 +93,6 @@ int riff_ds64(wav_reader_t *reader, int64_t *length)
TRY_IO(pcm_scanl(&reader->io, "QQQL", TRY_IO(pcm_scanl(&reader->io, "QQQL",
&riff_size, length, &sample_count, &table_size) != 4); &riff_size, length, &sample_count, &table_size) != 4);
TRY_IO(pcm_skip(&reader->io, (chunk_size - 27) & ~1)); TRY_IO(pcm_skip(&reader->io, (chunk_size - 27) & ~1));
reader->data_offset += (chunk_size + 9) & ~1;
FAIL: FAIL:
return -1; return -1;
} }
@ -163,7 +162,6 @@ int wav_parse(wav_reader_t *reader, int64_t *data_length)
container == RIFF_FOURCC('R','F','6','4')); container == RIFF_FOURCC('R','F','6','4'));
TRY_IO(pcm_read32le(&reader->io, &fcc)); TRY_IO(pcm_read32le(&reader->io, &fcc));
ENSURE(fcc == RIFF_FOURCC('W','A','V','E')); ENSURE(fcc == RIFF_FOURCC('W','A','V','E'));
reader->data_offset = 12;
if (container == RIFF_FOURCC('R','F','6','4')) if (container == RIFF_FOURCC('R','F','6','4'))
riff_ds64(reader, data_length); riff_ds64(reader, data_length);
@ -174,12 +172,11 @@ int wav_parse(wav_reader_t *reader, int64_t *data_length)
} else if (fcc == RIFF_FOURCC('d','a','t','a')) { } else if (fcc == RIFF_FOURCC('d','a','t','a')) {
if (container == RIFF_FOURCC('R','I','F','F')) if (container == RIFF_FOURCC('R','I','F','F'))
*data_length = chunk_size; *data_length = chunk_size;
reader->data_offset += 8; reader->data_offset = pcm_tell(&reader->io);
break; break;
} else { } else {
TRY_IO(pcm_skip(&reader->io, (chunk_size + 1) & ~1)); TRY_IO(pcm_skip(&reader->io, (chunk_size + 1) & ~1));
} }
reader->data_offset += (chunk_size + 9) & ~1;
} }
if (fcc == RIFF_FOURCC('d','a','t','a')) if (fcc == RIFF_FOURCC('d','a','t','a'))
return 0; return 0;