# HG changeset patch # User aurel # Date 1192744551 0 # Node ID 39ede602ff13950cdf7247aca27b37cd3e2f5e37 # Parent d3ad7d3d5f90c3c7de543b905a9fae2e66d7d0a1 move audio header parsing in its own function diff -r d3ad7d3d5f90 -r 39ede602ff13 electronicarts.c --- a/electronicarts.c Thu Oct 18 21:45:53 2007 +0000 +++ b/electronicarts.c Thu Oct 18 21:55:51 2007 +0000 @@ -71,37 +71,15 @@ } /* - * Process EA file header - * Returns 1 if the EA file is valid and successfully opened, 0 otherwise + * Process PT/GSTR sound header + * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx */ -static int process_ea_header(AVFormatContext *s) { +static int process_audio_header_elements(AVFormatContext *s) +{ int inHeader = 1; - uint32_t blockid, size = 0; - int num, den; EaDemuxContext *ea = s->priv_data; ByteIOContext *pb = &s->pb; - blockid = get_le32(pb); - if (blockid == MVhd_TAG) { - size = get_le32(pb); - url_fskip(pb, 16); - den = get_le32(pb); - num = get_le32(pb); - ea->time_base = (AVRational) {num, den}; - url_fskip(pb, size-32); - blockid = get_le32(pb); - } - if (blockid != SCHl_TAG) - return 0; - size += get_le32(pb); - blockid = get_le32(pb); - if (blockid == GSTR_TAG) { - url_fskip(pb, 4); - } else if (blockid != PT00_TAG) { - av_log (s, AV_LOG_ERROR, "PT header missing\n"); - return 0; - } - while (inHeader) { int inSubheader; uint8_t byte; @@ -154,6 +132,42 @@ } } + return 1; +} + +/* + * Process EA file header + * Returns 1 if the EA file is valid and successfully opened, 0 otherwise + */ +static int process_ea_header(AVFormatContext *s) { + uint32_t blockid, size = 0; + int num, den; + EaDemuxContext *ea = s->priv_data; + ByteIOContext *pb = &s->pb; + + blockid = get_le32(pb); + if (blockid == MVhd_TAG) { + size = get_le32(pb); + url_fskip(pb, 16); + den = get_le32(pb); + num = get_le32(pb); + ea->time_base = (AVRational) {num, den}; + url_fskip(pb, size-32); + blockid = get_le32(pb); + } + if (blockid != SCHl_TAG) + return 0; + size += get_le32(pb); + blockid = get_le32(pb); + if (blockid == GSTR_TAG) { + url_fskip(pb, 4); + } else if (blockid != PT00_TAG) { + av_log (s, AV_LOG_ERROR, "PT header missing\n"); + return 0; + } + + process_audio_header_elements(s); + /* skip to the start of the data */ url_fseek(pb, size, SEEK_SET);