summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-07-04 15:49:21 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-07-04 15:49:21 +0200
commita5fea58eeaff30d4bb4464c619af9d49faf425ae (patch)
tree31d992820fa071f22d851c11f8faf07bef2b0f7f
parente658d8485c47059959ea8b1b2b0342b7d017d5d3 (diff)
downloadxine-lib-a5fea58eeaff30d4bb4464c619af9d49faf425ae.tar.gz
xine-lib-a5fea58eeaff30d4bb4464c619af9d49faf425ae.tar.bz2
Improve header processing and misc cleanups.
When processing the header, read the whole 12-bytes block at once, then use _x_is_fourcc() to check for the signatures, and only then try to find the size. --HG-- extra : transplant_source : %B8%90%00%DAJ%7F%3F%E4%00%05%07z%3D%C5%02%03v%A8%B4C
-rw-r--r--src/demuxers/demux_eawve.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/demuxers/demux_eawve.c b/src/demuxers/demux_eawve.c
index 58ce4520f..7a21635cb 100644
--- a/src/demuxers/demux_eawve.c
+++ b/src/demuxers/demux_eawve.c
@@ -78,16 +78,16 @@ typedef struct {
*/
static uint32_t read_arbitary(input_plugin_t *input){
- uint8_t size, byte;
- int i;
- uint32_t word;
+ uint8_t size;
if (input->read(input, (void*)&size, 1) != 1) {
return 0;
}
- word = 0;
+ uint32_t word = 0;
+ int i;
for (i=0;i<size;i++) {
+ uint8_t byte;
if (input->read(input, (void*)&byte, 1) != 1) {
return 0;
}
@@ -104,33 +104,25 @@ static uint32_t read_arbitary(input_plugin_t *input){
*/
static int process_header(demux_eawve_t *this){
- int inHeader;
- uint32_t blockid, size;
+ uint8_t header[12];
if (this->input->get_current_pos(this->input) != 0)
this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, (void*)&blockid, 4) != 4) {
- return 0;
- }
- if (be2me_32(blockid) != FOURCC_TAG('S', 'C', 'H', 'l')) {
+ if (this->input->read(this->input, header, sizeof(header)) != sizeof(header))
return 0;
- }
- if (this->input->read(this->input, (void*)&size, 4) != 4) {
+ if (!_x_is_fourcc(&header[0], "SCHl"))
return 0;
- }
- size = le2me_32(size);
- if (this->input->read(this->input, (void*)&blockid, 4) != 4) {
- return 0;
- }
- if (be2me_32(blockid) != FOURCC_TAG('P', 'T', '\0', '\0')) {
+ if (!_x_is_fourcc(&header[8], "PT\0\0")) {
lprintf("PT header missing\n");
return 0;
}
- inHeader = 1;
+ const uint32_t size = _X_LE_32(&header[4]);
+
+ int inHeader = 1;
while (inHeader) {
int inSubheader;
uint8_t byte;