summaryrefslogtreecommitdiff
path: root/src/demuxers
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers')
-rw-r--r--src/demuxers/asfheader.c52
-rw-r--r--src/demuxers/demux_asf.c5
-rw-r--r--src/demuxers/demux_flv.c29
-rw-r--r--src/demuxers/demux_matroska.c5
-rw-r--r--src/demuxers/demux_mpeg_block.c36
-rw-r--r--src/demuxers/demux_mpeg_pes.c2
-rw-r--r--src/demuxers/demux_qt.c97
-rw-r--r--src/demuxers/demux_real.c15
-rw-r--r--src/demuxers/ebml.c47
-rw-r--r--src/demuxers/group_audio.c2
-rw-r--r--src/demuxers/id3.c30
11 files changed, 123 insertions, 197 deletions
diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c
index 26a61d8fd..23692574e 100644
--- a/src/demuxers/asfheader.c
+++ b/src/demuxers/asfheader.c
@@ -63,7 +63,6 @@ struct asf_header_internal_s {
/* private part */
int number_count;
uint16_t numbers[ASF_MAX_NUM_STREAMS];
- iconv_t iconv_cd;
uint8_t *bitrate_pointers[ASF_MAX_NUM_STREAMS];
};
@@ -130,8 +129,7 @@ static uint8_t *asf_reader_get_bytes(asf_reader_t *reader, size_t size) {
if ((reader->size - reader->pos) < size)
return NULL;
- buffer = malloc(size);
- if (!buffer)
+ if (! (buffer = malloc(size)) )
return NULL;
memcpy(buffer, reader->buffer + reader->pos, size);
reader->pos += size;
@@ -241,8 +239,7 @@ static int asf_header_parse_file_properties(asf_header_t *header, uint8_t *buffe
return 0;
}
- asf_file = malloc(sizeof(asf_file_t));
- if (!asf_file) {
+ if (! (asf_file = malloc(sizeof(asf_file_t))) ) {
lprintf("cannot allocate asf_file_struct\n");
return 0;
}
@@ -296,8 +293,7 @@ static int asf_header_parse_stream_properties(asf_header_t *header, uint8_t *buf
if (buffer_len < 54)
goto exit_error;
- asf_stream = malloc(sizeof(asf_stream_t));
- if (!asf_stream)
+ if (! (asf_stream = malloc(sizeof(asf_stream_t))) )
goto exit_error;
asf_reader_init(&reader, buffer, buffer_len);
@@ -363,8 +359,7 @@ static int asf_header_parse_stream_extended_properties(asf_header_t *header, uin
if (buffer_len < 64)
return 0;
- asf_stream_extension = malloc(sizeof(asf_stream_extension_t));
- if (!asf_stream_extension)
+ if (! (asf_stream_extension = malloc(sizeof(asf_stream_extension_t))) )
return 0;
asf_reader_init(&reader, buffer, buffer_len);
@@ -577,14 +572,16 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_
asf_reader_t reader;
asf_content_t *content;
uint16_t title_length, author_length, copyright_length, description_length, rating_length;
+ iconv_t iconv_cd;
if (buffer_len < 10)
return 0;
- content = malloc(sizeof(asf_content_t));
- if (!content)
+ if (! (content = calloc(1, sizeof(asf_content_t))) )
+ return 0;
+
+ if ( (iconv_cd = iconv_open("UTF-8", "UCS-2LE")) == (iconv_t)-1 )
return 0;
- memset(content, 0, sizeof(asf_content_t));
asf_reader_init(&reader, buffer, buffer_len);
asf_reader_get_16(&reader, &title_length);
@@ -593,13 +590,15 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_
asf_reader_get_16(&reader, &description_length);
asf_reader_get_16(&reader, &rating_length);
- content->title = asf_reader_get_string(&reader, title_length, header->iconv_cd);
- content->author = asf_reader_get_string(&reader, author_length, header->iconv_cd);
- content->copyright = asf_reader_get_string(&reader, copyright_length, header->iconv_cd);
- content->description = asf_reader_get_string(&reader, description_length, header->iconv_cd);
- content->rating = asf_reader_get_string(&reader, rating_length, header->iconv_cd);
+ content->title = asf_reader_get_string(&reader, title_length, iconv_cd);
+ content->author = asf_reader_get_string(&reader, author_length, iconv_cd);
+ content->copyright = asf_reader_get_string(&reader, copyright_length, iconv_cd);
+ content->description = asf_reader_get_string(&reader, description_length, iconv_cd);
+ content->rating = asf_reader_get_string(&reader, rating_length, iconv_cd);
header->pub.content = content;
+
+ iconv_close(iconv_cd);
return 1;
}
@@ -611,24 +610,14 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
uint32_t object_count;
uint16_t junk;
- asf_header = malloc(sizeof(asf_header_internal_t));
- if (!asf_header)
- return NULL;
- memset(asf_header, 0, sizeof(asf_header_internal_t));
-
lprintf("parsing_asf_header\n");
if (buffer_len < 6) {
printf("invalid buffer size\n");
- free(asf_header);
return NULL;
}
- asf_header->iconv_cd = iconv_open ("UTF-8", "UCS-2LE");
- if (asf_header->iconv_cd == (iconv_t)-1) {
- printf("iconv open error\n");
- free(asf_header);
+ if (! (asf_header = calloc(1, sizeof(asf_header_internal_t))) )
return NULL;
- }
asf_reader_init(&reader, buffer, buffer_len);
asf_reader_get_32(&reader, &object_count);
@@ -697,10 +686,8 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
}
if (!asf_header->pub.content) {
lprintf("no content object present\n");
- asf_header->pub.content = malloc(sizeof(asf_content_t));
- if (!asf_header->pub.content)
+ if (! (asf_header->pub.content = calloc(1, sizeof(asf_content_t))) )
goto exit_error;
- memset(asf_header->pub.content, 0, sizeof(asf_content_t));
}
return &asf_header->pub;
@@ -766,9 +753,6 @@ void asf_header_delete (asf_header_t *header_pub) {
asf_header_delete_stream_extended_properties(header->pub.stream_extensions[i]);
}
- if (header->iconv_cd != (iconv_t)-1)
- iconv_close (header->iconv_cd);
-
free(header);
}
diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c
index 889299beb..f5091035b 100644
--- a/src/demuxers/demux_asf.c
+++ b/src/demuxers/demux_asf.c
@@ -612,14 +612,14 @@ static int demux_asf_send_headers_common (demux_asf_t *this) {
}
static void asf_reorder(demux_asf_t *this, uint8_t *src, int len){
- uint8_t *dst = malloc(len);
+ uint8_t dst[len];
uint8_t *s2 = src;
int i = 0, x, y;
while(len-i >= this->reorder_h * this->reorder_w*this->reorder_b){
for(x = 0; x < this->reorder_w; x++)
for(y = 0; y < this->reorder_h; y++){
- memcpy(dst + i, s2 + (y * this->reorder_w+x) * this->reorder_b,
+ memcpy(&dst[i], s2 + (y * this->reorder_w+x) * this->reorder_b,
this->reorder_b);
i += this->reorder_b;
}
@@ -627,7 +627,6 @@ static void asf_reorder(demux_asf_t *this, uint8_t *src, int len){
}
xine_fast_memcpy(src,dst,i);
- free(dst);
}
/* redefine abs as macro to handle 64-bit diffs.
diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c
index f0b29532b..7f9dec5fe 100644
--- a/src/demuxers/demux_flv.c
+++ b/src/demuxers/demux_flv.c
@@ -870,6 +870,30 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
+static const char *get_description (demux_class_t *this_gen) {
+ return "Flash Video file demux plugin";
+}
+
+static const char *get_identifier (demux_class_t *this_gen) {
+ return "FLV";
+}
+
+static const char *get_extensions (demux_class_t *this_gen) {
+ return "flv";
+}
+
+static const char *get_mimetypes (demux_class_t *this_gen) {
+ return "video/x-flv: flv: Flash video;"
+ "video/flv: flv: Flash video;"
+ "application/x-flash-video: flv: Flash video;";
+}
+
+static void class_dispose (demux_class_t *this_gen) {
+ demux_flv_class_t *this = (demux_flv_class_t *) this_gen;
+
+ free (this);
+}
+
static void *init_plugin (xine_t *xine, void *data) {
demux_flv_class_t *this;
@@ -878,7 +902,9 @@ static void *init_plugin (xine_t *xine, void *data) {
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Flash Video file demux plugin");
this->demux_class.identifier = "FLV";
- this->demux_class.mimetypes = "video/x-flv: flv: Flash video;";
+ this->demux_class.mimetypes = "video/x-flv: flv: Flash video;"
+ "video/flv: flv: Flash video;"
+ "application/x-flash-video: flv: Flash video;";
this->demux_class.extensions = "flv";
this->demux_class.dispose = default_demux_class_dispose;
@@ -897,3 +923,4 @@ const plugin_info_t xine_plugin_info[] EXPORTED = {
{ PLUGIN_DEMUX, 27, "flashvideo", XINE_VERSION_CODE, &demux_info_flv, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
+
diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c
index f8166173a..16cf87978 100644
--- a/src/demuxers/demux_matroska.c
+++ b/src/demuxers/demux_matroska.c
@@ -1749,10 +1749,7 @@ static int parse_tags(demux_matroska_t *this) {
static void alloc_block_data (demux_matroska_t *this, int len) {
/* memory management */
if (this->block_data_size < len) {
- if (this->block_data)
- this->block_data = realloc(this->block_data, len);
- else
- this->block_data = malloc(len);
+ this->block_data = realloc(this->block_data, len);
this->block_data_size = len;
}
}
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index e6ae7df8d..3b6aa24bc 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -1454,39 +1454,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_MRL: {
- char *ending;
-
- const char *const mrl = input->get_mrl (input);
-
- if(!strncmp(mrl, "vcd:", 4)) {
- this->blocksize = 2324;
- demux_mpeg_block_accept_input (this, input);
- } else if(!strncmp(mrl, "dvd:", 4) || !strncmp(mrl, "pvr:", 4)) {
- this->blocksize = 2048;
- demux_mpeg_block_accept_input (this, input);
- } else {
- ending = strrchr(mrl, '.');
-
- if (!ending) {
- av_free (this->scratch);
- free (this);
- return NULL;
- }
- if ( (!strncasecmp (ending, ".vob", 4)) ||
- (!strncmp((ending + 3), "mpeg2", 5)) ||
- (!strncmp((ending + 3), "mpeg1", 5)) ) {
- this->blocksize = 2048;
- demux_mpeg_block_accept_input(this, input);
- } else {
- av_free (this->scratch);
- free (this);
- return NULL;
- }
- }
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT: {
this->blocksize = input->get_blocksize(input);
@@ -1527,7 +1495,7 @@ static void *init_plugin (xine_t *xine, void *data) {
this->demux_class.description = N_("DVD/VOB demux plugin");
this->demux_class.identifier = "MPEG_BLOCK";
this->demux_class.mimetypes = NULL;
- this->demux_class.extensions = "vob";
+ this->demux_class.extensions = "vob vcd:/ dvd:/ pvr:/";
this->demux_class.dispose = default_demux_class_dispose;
return this;
diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c
index 64fe764a4..f1a36a235 100644
--- a/src/demuxers/demux_mpeg_pes.c
+++ b/src/demuxers/demux_mpeg_pes.c
@@ -1756,7 +1756,7 @@ static void *init_plugin (xine_t *xine, void *data) {
this->demux_class.description = N_("mpeg pes demux plugin");
this->demux_class.identifier = "MPEG_PES";
this->demux_class.mimetypes = NULL;
- this->demux_class.extensions = "pes";
+ this->demux_class.extensions = "pes vdr:/ netvdr:/";
this->demux_class.dispose = default_demux_class_dispose;
return this;
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c
index b46cbc593..8fb554de2 100644
--- a/src/demuxers/demux_qt.c
+++ b/src/demuxers/demux_qt.c
@@ -651,8 +651,7 @@ static void free_qt_info(qt_info *info) {
for (j = 0; j < info->traks[i].stsd_atoms_count; j++) {
if (info->traks[i].type == MEDIA_AUDIO) {
free(info->traks[i].stsd_atoms[j].audio.properties_atom);
- if (info->traks[i].stsd_atoms[j].audio.wave)
- free(info->traks[i].stsd_atoms[j].audio.wave);
+ free(info->traks[i].stsd_atoms[j].audio.wave);
} else if (info->traks[i].type == MEDIA_VIDEO)
free(info->traks[i].stsd_atoms[j].video.properties_atom);
}
@@ -686,34 +685,28 @@ static int is_qt_file(input_plugin_t *qt_file) {
off_t moov_atom_offset = -1;
int64_t moov_atom_size = -1;
int i;
- unsigned char atom_preamble[ATOM_PREAMBLE_SIZE];
- unsigned char preview[MAX_PREVIEW_SIZE];
int len;
/* if the input is non-seekable, be much more stringent about qualifying
* a QT file: In this case, the moov must be the first atom in the file */
if ((qt_file->get_capabilities(qt_file) & INPUT_CAP_SEEKABLE) == 0) {
- memset (&preview, 0, MAX_PREVIEW_SIZE);
+ unsigned char preview[MAX_PREVIEW_SIZE] = { 0, };
len = qt_file->get_optional_data(qt_file, preview, INPUT_OPTIONAL_DATA_PREVIEW);
if (_X_BE_32(&preview[4]) == MOOV_ATOM)
return 1;
else {
- if (_X_BE_32(&preview[4]) == FTYP_ATOM) {
- /* show some lenience if the first atom is 'ftyp'; the second atom
- * could be 'moov' */
- moov_atom_size = _X_BE_32(&preview[0]);
- /* compute the size of the current atom plus the preamble of the
- * next atom; if the size is within the range on the preview buffer
- * then the next atom's preamble is in the preview buffer */
- i = moov_atom_size + ATOM_PREAMBLE_SIZE;
- if (i >= MAX_PREVIEW_SIZE)
- return 0;
- if (_X_BE_32(&preview[i - 4]) == MOOV_ATOM)
- return 1;
- else
- return 0;
- } else
- return 0;
+ if (_X_BE_32(&preview[4]) != FTYP_ATOM)
+ return 0;
+
+ /* show some lenience if the first atom is 'ftyp'; the second atom
+ * could be 'moov'
+ * compute the size of the current atom plus the preamble of the
+ * next atom; if the size is within the range on the preview buffer
+ * then the next atom's preamble is in the preview buffer */
+ uint64_t ftyp_atom_size = _X_BE_32(&preview[0]) + ATOM_PREAMBLE_SIZE;
+ if (ftyp_atom_size >= MAX_PREVIEW_SIZE)
+ return 0;
+ return _X_BE_32(&preview[ftyp_atom_size - 4]) == MOOV_ATOM;
}
}
@@ -721,6 +714,7 @@ static int is_qt_file(input_plugin_t *qt_file) {
if (moov_atom_offset == -1) {
return 0;
} else {
+ unsigned char atom_preamble[ATOM_PREAMBLE_SIZE];
/* check that the next atom in the chunk contains alphanumeric
* characters in the atom type field; if not, disqualify the file
* as a QT file */
@@ -807,31 +801,33 @@ static void parse_meta_atom(qt_info *info, unsigned char *meta_atom) {
const uint8_t *const sub_atom = &meta_atom[j];
const qt_atom sub_atom_code = _X_BE_32(&sub_atom[4]);
const uint32_t sub_atom_size = _X_BE_32(&sub_atom[0]);
+ char *const data_atom = parse_data_atom(&sub_atom[8]);
switch(sub_atom_code) {
case ART_ATOM:
- info->artist = parse_data_atom(&sub_atom[8]);
+ info->artist = data_atom;
break;
case NAM_ATOM:
- info->name = parse_data_atom(&sub_atom[8]);
+ info->name = data_atom;
break;
case ALB_ATOM:
- info->album = parse_data_atom(&sub_atom[8]);
+ info->album = data_atom;
break;
case GEN_ATOM:
- info->genre = parse_data_atom(&sub_atom[8]);
+ info->genre = data_atom;
break;
case CMT_ATOM:
- info->comment = parse_data_atom(&sub_atom[8]);
+ info->comment = data_atom;
break;
case WRT_ATOM:
- info->composer = parse_data_atom(&sub_atom[8]);
+ info->composer = data_atom;
break;
case DAY_ATOM:
- info->year = parse_data_atom(&sub_atom[8]);
+ info->year = data_atom;
break;
default:
debug_meta_load("unknown atom %08x in ilst\n", sub_atom_code);
+ free(data_atom);
}
j += sub_atom_size;
@@ -1008,18 +1004,17 @@ static qt_error parse_trak_atom (qt_trak *trak,
const uint32_t current_stsd_atom_size = _X_BE_32(&trak_atom[atom_pos - 4]);
- /* for palette traversal */
- int color_depth;
- int color_flag;
- int color_start;
- int color_count;
- int color_end;
- int color_index;
- int color_dec;
- int color_greyscale;
- const unsigned char *color_table;
-
if (trak->type == MEDIA_VIDEO) {
+ /* for palette traversal */
+ int color_depth;
+ int color_flag;
+ int color_start;
+ int color_count;
+ int color_end;
+ int color_index;
+ int color_dec;
+ int color_greyscale;
+ const unsigned char *color_table;
trak->stsd_atoms[k].video.media_id = k + 1;
trak->stsd_atoms[k].video.properties_offset = properties_offset;
@@ -1464,8 +1459,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
debug_atom_load(" qt stco atom (32-bit chunk offset atom): %d chunk offsets\n",
trak->chunk_offset_count);
- trak->chunk_offset_table = (int64_t *)malloc(
- trak->chunk_offset_count * sizeof(int64_t));
+ trak->chunk_offset_table = calloc(trak->chunk_offset_count, sizeof(int64_t));
if (!trak->chunk_offset_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1492,8 +1486,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
debug_atom_load(" qt co64 atom (64-bit chunk offset atom): %d chunk offsets\n",
trak->chunk_offset_count);
- trak->chunk_offset_table = (int64_t *)malloc(
- trak->chunk_offset_count * sizeof(int64_t));
+ trak->chunk_offset_table = calloc(trak->chunk_offset_count, sizeof(int64_t));
if (!trak->chunk_offset_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1523,8 +1516,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
debug_atom_load(" qt stsc atom (sample-to-chunk atom): %d entries\n",
trak->sample_to_chunk_count);
- trak->sample_to_chunk_table = (sample_to_chunk_table_t *)malloc(
- trak->sample_to_chunk_count * sizeof(sample_to_chunk_table_t));
+ trak->sample_to_chunk_table = calloc(trak->sample_to_chunk_count, sizeof(sample_to_chunk_table_t));
if (!trak->sample_to_chunk_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1558,8 +1550,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
debug_atom_load(" qt stts atom (time-to-sample atom): %d entries\n",
trak->time_to_sample_count);
- trak->time_to_sample_table = (time_to_sample_table_t *)malloc(
- (trak->time_to_sample_count+1) * sizeof(time_to_sample_table_t));
+ trak->time_to_sample_table = calloc(trak->time_to_sample_count+1, sizeof(time_to_sample_table_t));
if (!trak->time_to_sample_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1752,8 +1743,7 @@ static qt_error build_frame_table(qt_trak *trak,
/* in this case, the total number of frames is equal to the number of
* entries in the sample size table */
trak->frame_count = trak->sample_size_count;
- trak->frames = (qt_frame *)malloc(
- trak->frame_count * sizeof(qt_frame));
+ trak->frames = calloc(trak->frame_count, sizeof(qt_frame));
if (!trak->frames)
return QT_NO_MEMORY;
trak->current_frame = 0;
@@ -1765,10 +1755,9 @@ static qt_error build_frame_table(qt_trak *trak,
pts_index_countdown =
trak->time_to_sample_table[pts_index].count;
- media_id_counts = xine_xmalloc(trak->stsd_atoms_count * sizeof(int));
+ media_id_counts = xine_xcalloc(trak->stsd_atoms_count, sizeof(int));
if (!media_id_counts)
return QT_NO_MEMORY;
- memset(media_id_counts, 0, trak->stsd_atoms_count * sizeof(int));
/* iterate through each start chunk in the stsc table */
for (i = 0; i < trak->sample_to_chunk_count; i++) {
@@ -1903,8 +1892,7 @@ static qt_error build_frame_table(qt_trak *trak,
/* in this case, the total number of frames is equal to the number of
* chunks */
trak->frame_count = trak->chunk_offset_count;
- trak->frames = (qt_frame *)malloc(
- trak->frame_count * sizeof(qt_frame));
+ trak->frames = calloc(trak->frame_count, sizeof(qt_frame));
if (!trak->frames)
return QT_NO_MEMORY;
@@ -2146,7 +2134,6 @@ static qt_error open_qt_file(qt_info *info, input_plugin_t *input,
unsigned char *moov_atom = NULL;
off_t moov_atom_offset = -1;
int64_t moov_atom_size = -1;
- unsigned char preview[MAX_PREVIEW_SIZE];
/* zlib stuff */
z_stream z_state;
@@ -2169,7 +2156,7 @@ static qt_error open_qt_file(qt_info *info, input_plugin_t *input,
if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE))
find_moov_atom(input, &moov_atom_offset, &moov_atom_size);
else {
- memset (&preview, 0, MAX_PREVIEW_SIZE);
+ unsigned char preview[MAX_PREVIEW_SIZE] = { 0, };
input->get_optional_data(input, preview, INPUT_OPTIONAL_DATA_PREVIEW);
if (_X_BE_32(&preview[4]) != MOOV_ATOM) {
/* special case if there is an ftyp atom first */
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index 761296ac4..962030083 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -232,7 +232,7 @@ static void real_parse_index(demux_real_t *this) {
if(index && entries) {
/* Allocate memory for index */
- *index = xine_xmalloc(entries * sizeof(real_index_entry_t));
+ *index = xine_xcalloc(entries, sizeof(real_index_entry_t));
/* Read index */
for(i = 0; i < entries; i++) {
@@ -275,17 +275,17 @@ static mdpr_t *real_parse_mdpr(const char *data) {
mdpr->duration=_X_BE_32(&data[28]);
mdpr->stream_name_size=data[32];
- mdpr->stream_name=malloc(sizeof(char)*(mdpr->stream_name_size+1));
+ mdpr->stream_name=calloc(mdpr->stream_name_size+1, sizeof(char));
memcpy(mdpr->stream_name, &data[33], mdpr->stream_name_size);
mdpr->stream_name[(int)mdpr->stream_name_size]=0;
mdpr->mime_type_size=data[33+mdpr->stream_name_size];
- mdpr->mime_type=malloc(sizeof(char)*(mdpr->mime_type_size+1));
+ mdpr->mime_type=calloc(mdpr->mime_type_size+1, sizeof(char));
memcpy(mdpr->mime_type, &data[34+mdpr->stream_name_size], mdpr->mime_type_size);
mdpr->mime_type[(int)mdpr->mime_type_size]=0;
mdpr->type_specific_len=_X_BE_32(&data[34+mdpr->stream_name_size+mdpr->mime_type_size]);
- mdpr->type_specific_data=malloc(sizeof(char)*(mdpr->type_specific_len));
+ mdpr->type_specific_data=calloc(mdpr->type_specific_len, sizeof(char));
memcpy(mdpr->type_specific_data,
&data[38+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
@@ -820,8 +820,8 @@ static int demux_real_parse_references( demux_real_t *this) {
if( !strncmp(&buf[i],"-->",3) )
comment = 0;
- if( (!strncmp(&buf[i],"pnm://",6) || !strncmp(&buf[i],"rtsp://",7)) &&
- !comment ) {
+ if( (!strncmp(&buf[i],"pnm://",6) || !strncmp(&buf[i],"rtsp://",7) ||
+ !strncmp(&buf[i],"http://",7)) && !comment ) {
for(j=i; buf[j] && buf[j] != '"' && !isspace(buf[j]); j++ )
;
buf[j]='\0';
@@ -1529,7 +1529,8 @@ static int real_check_stream_type(uint8_t *buf, int len)
return 1;
buf[len] = '\0';
- if( strstr(buf,"pnm://") || strstr(buf,"rtsp://") || strstr(buf,"<smil>") )
+ if( strstr(buf,"pnm://") || strstr(buf,"rtsp://") || strstr(buf,"<smil>") ||
+ strstr(buf,"http://") )
return 2;
return 0;
diff --git a/src/demuxers/ebml.c b/src/demuxers/ebml.c
index 218046cf5..d5f7bb9b5 100644
--- a/src/demuxers/ebml.c
+++ b/src/demuxers/ebml.c
@@ -41,20 +41,10 @@
ebml_parser_t *new_ebml_parser (xine_t *xine, input_plugin_t *input) {
ebml_parser_t *ebml;
- ebml = malloc(sizeof(ebml_parser_t));
+ ebml = xine_xmalloc(sizeof(ebml_parser_t));
ebml->xine = xine;
ebml->input = input;
- ebml->version = 0;
- ebml->read_version = 0;
- ebml->max_id_len = 0;
- ebml->max_size_len = 0;
- ebml->doctype = NULL;
- ebml->doctype_version = 0;
- ebml->doctype_read_version = 0;
-
- ebml->level = 0;
-
return ebml;
}
@@ -325,34 +315,31 @@ int ebml_read_date (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *date) {
int ebml_read_master (ebml_parser_t *ebml, ebml_elem_t *elem) {
ebml_elem_t *top_elem;
- if (ebml->level >= 0) {
- top_elem = &ebml->elem_stack[ebml->level];
- top_elem->start = elem->start;
- top_elem->len = elem->len;
- top_elem->id = elem->id;
-
- ebml->level++;
- lprintf("id: 0x%x, len: %" PRIu64 ", level: %d\n", elem->id, elem->len, ebml->level);
- if (ebml->level >= EBML_STACK_SIZE) {
- xprintf(ebml->xine, XINE_VERBOSITY_LOG,
- "ebml: max level exceeded\n");
- return 0;
- }
- return 1;
- } else {
+ if (ebml->level < 0) {
xprintf(ebml->xine, XINE_VERBOSITY_LOG,
"ebml: invalid current level\n");
return 0;
}
-}
-int ebml_read_binary(ebml_parser_t *ebml, ebml_elem_t *elem, void *binary) {
- if (!ebml_read_elem_data(ebml, binary, elem->len))
+ top_elem = &ebml->elem_stack[ebml->level];
+ top_elem->start = elem->start;
+ top_elem->len = elem->len;
+ top_elem->id = elem->id;
+
+ ebml->level++;
+ lprintf("id: 0x%x, len: %" PRIu64 ", level: %d\n", elem->id, elem->len, ebml->level);
+ if (ebml->level >= EBML_STACK_SIZE) {
+ xprintf(ebml->xine, XINE_VERBOSITY_LOG,
+ "ebml: max level exceeded\n");
return 0;
-
+ }
return 1;
}
+int ebml_read_binary(ebml_parser_t *ebml, ebml_elem_t *elem, void *binary) {
+ return !!ebml_read_elem_data(ebml, binary, elem->len);
+}
+
int ebml_check_header(ebml_parser_t *ebml) {
uint32_t next_level;
ebml_elem_t master;
diff --git a/src/demuxers/group_audio.c b/src/demuxers/group_audio.c
index 78bf4012b..d3832c36d 100644
--- a/src/demuxers/group_audio.c
+++ b/src/demuxers/group_audio.c
@@ -42,7 +42,7 @@ static const demuxer_info_t demux_info_ac3 = {
};
static const demuxer_info_t demux_info_aud = {
- 10 /* priority */
+ -2 /* priority */
};
static const demuxer_info_t demux_info_aiff = {
diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c
index 4149c0512..ceb66014f 100644
--- a/src/demuxers/id3.c
+++ b/src/demuxers/id3.c
@@ -273,15 +273,9 @@ static int id3v22_parse_frame_header(input_plugin_t *input,
static int id3v22_interp_frame(input_plugin_t *input,
xine_stream_t *stream,
id3v22_frame_header_t *frame_header) {
- char *buf;
+ char buf[frame_header->size + 1];
int enc;
- buf = malloc(frame_header->size + 1);
- if (buf == NULL) {
- lprintf("malloc error");
- return 0;
- }
-
if (input->read (input, buf, frame_header->size) == frame_header->size) {
buf[frame_header->size] = 0;
enc = buf[0];
@@ -327,11 +321,9 @@ static int id3v22_interp_frame(input_plugin_t *input,
lprintf("unhandled frame\n");
}
- free(buf);
return 1;
} else {
lprintf("read error\n");
- free(buf);
return 0;
}
}
@@ -467,15 +459,9 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input,
static int id3v23_interp_frame(input_plugin_t *input,
xine_stream_t *stream,
id3v23_frame_header_t *frame_header) {
- char *buf;
+ char buf[frame_header->size + 1];
int enc;
- buf = malloc(frame_header->size + 1);
- if (buf == NULL) {
- lprintf("malloc error");
- return 0;
- }
-
if (input->read (input, buf, frame_header->size) == frame_header->size) {
buf[frame_header->size] = 0;
enc = buf[0];
@@ -521,11 +507,9 @@ static int id3v23_interp_frame(input_plugin_t *input,
lprintf("unhandled frame\n");
}
- free(buf);
return 1;
} else {
lprintf("read error\n");
- free(buf);
return 0;
}
}
@@ -716,15 +700,9 @@ static int id3v24_parse_ext_header(input_plugin_t *input,
static int id3v24_interp_frame(input_plugin_t *input,
xine_stream_t *stream,
id3v24_frame_header_t *frame_header) {
- char *buf;
+ char buf[frame_header->size + 1];
int enc;
- buf = malloc(frame_header->size + 1);
- if (buf == NULL) {
- lprintf("malloc error");
- return 0;
- }
-
if (input->read (input, buf, frame_header->size) == frame_header->size) {
buf[frame_header->size] = 0;
enc = buf[0];
@@ -772,11 +750,9 @@ static int id3v24_interp_frame(input_plugin_t *input,
lprintf("unhandled frame\n");
}
- free(buf);
return 1;
} else {
lprintf("read error\n");
- free(buf);
return 0;
}
}