aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/electronicarts.c
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2007-10-18 21:55:51 +0000
committerAurelien Jacobs <aurel@gnuage.org>2007-10-18 21:55:51 +0000
commit215eb1028d155cae2184673ab36cddd101b1390b (patch)
tree76b23d5f1e9fec0c260709472e46ad159fa27359 /libavformat/electronicarts.c
parentd51bd73ce649820279aa5ac959291507f6b98cce (diff)
downloadffmpeg-215eb1028d155cae2184673ab36cddd101b1390b.tar.gz
move audio header parsing in its own function
Originally committed as revision 10786 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/electronicarts.c')
-rw-r--r--libavformat/electronicarts.c66
1 files changed, 40 insertions, 26 deletions
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index c96d8cc67d..9c20290d5b 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -71,37 +71,15 @@ static uint32_t read_arbitary(ByteIOContext *pb) {
}
/*
- * 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 @@ static int process_ea_header(AVFormatContext *s) {
}
}
+ 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);