diff options
Diffstat (limited to 'src/demuxers')
-rw-r--r-- | src/demuxers/asfheader.c | 9 | ||||
-rw-r--r-- | src/demuxers/demux_4xm.c | 2 | ||||
-rw-r--r-- | src/demuxers/demux_avi.c | 10 | ||||
-rw-r--r-- | src/demuxers/demux_film.c | 8 | ||||
-rw-r--r-- | src/demuxers/demux_iff.c | 6 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_pes.c | 5 | ||||
-rw-r--r-- | src/demuxers/demux_ogg.c | 63 | ||||
-rw-r--r-- | src/demuxers/demux_qt.c | 1 | ||||
-rw-r--r-- | src/demuxers/demux_real.c | 2 | ||||
-rw-r--r-- | src/demuxers/demux_realaudio.c | 2 | ||||
-rw-r--r-- | src/demuxers/demux_slave.c | 6 | ||||
-rw-r--r-- | src/demuxers/demux_str.c | 4 | ||||
-rw-r--r-- | src/demuxers/demux_ts.c | 6 | ||||
-rw-r--r-- | src/demuxers/demux_wav.c | 2 | ||||
-rw-r--r-- | src/demuxers/demux_wc3movie.c | 2 |
15 files changed, 55 insertions, 73 deletions
diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c index f95c68e41..5db25d07f 100644 --- a/src/demuxers/asfheader.c +++ b/src/demuxers/asfheader.c @@ -581,10 +581,9 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_ if (buffer_len < 10)
return 0;
- content = malloc(sizeof(asf_content_t));
+ content = calloc(1, sizeof(asf_content_t));
if (!content)
return 0;
- memset(content, 0, sizeof(asf_content_t));
asf_reader_init(&reader, buffer, buffer_len);
asf_reader_get_16(&reader, &title_length);
@@ -617,10 +616,9 @@ 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));
+ asf_header = calloc(1, 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) {
@@ -703,10 +701,9 @@ 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));
+ asf_header->pub.content = calloc(1, sizeof(asf_content_t));
if (!asf_header->pub.content)
goto exit_error;
- memset(asf_header->pub.content, 0, sizeof(asf_content_t));
}
return &asf_header->pub;
diff --git a/src/demuxers/demux_4xm.c b/src/demuxers/demux_4xm.c index a5fcd6568..c264e4421 100644 --- a/src/demuxers/demux_4xm.c +++ b/src/demuxers/demux_4xm.c @@ -158,7 +158,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) { /* read the whole header */ header_size = _X_LE_32(&preview[4]) - 4; - header = xine_xmalloc(header_size); + header = malloc(header_size); if (!header || fourxm->input->read(fourxm->input, header, header_size) != header_size) { free(header); return 0; diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 01efe0e53..37f74ddb1 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -790,7 +790,7 @@ static avi_t *AVI_init(demux_avi_t *this) { if(strncasecmp(data,"hdrl",4) == 0) { hdrl_len = n; - hdrl_data = (unsigned char *) xine_xmalloc(n); + hdrl_data = (unsigned char *) malloc(n); if(hdrl_data==0) ERR_EXIT(AVI_ERR_NO_MEM); if (this->input->read(this->input, hdrl_data,n) != n ) @@ -812,9 +812,8 @@ static avi_t *AVI_init(demux_avi_t *this) { break if this is not the case */ AVI->n_idx = AVI->max_idx = n / 16; - if (AVI->idx) - free(AVI->idx); /* On the off chance there are multiple index chunks */ - AVI->idx = (unsigned char((*)[16])) xine_xmalloc(n); + free(AVI->idx); /* On the off chance there are multiple index chunks */ + AVI->idx = (unsigned char((*)[16])) malloc(n); if (AVI->idx == 0) ERR_EXIT(AVI_ERR_NO_MEM); @@ -882,7 +881,6 @@ static avi_t *AVI_init(demux_avi_t *this) { this->AVI_errno = AVI_ERR_NO_MEM; return 0; } - memset((void *)a,0,sizeof(avi_audio_t)); AVI->audio[AVI->n_audio] = a; a->audio_strn = num_stream; @@ -922,7 +920,7 @@ static avi_t *AVI_init(demux_avi_t *this) { if(lasttag == 1) { /* lprintf ("size : %d\n",sizeof(AVI->bih)); */ AVI->bih = (xine_bmiheader *) - xine_xmalloc((n < sizeof(xine_bmiheader)) ? sizeof(xine_bmiheader) : n); + malloc((n < sizeof(xine_bmiheader)) ? sizeof(xine_bmiheader) : n); if(AVI->bih == NULL) { this->AVI_errno = AVI_ERR_NO_MEM; return 0; diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c index 7abbf7134..27986d9e1 100644 --- a/src/demuxers/demux_film.c +++ b/src/demuxers/demux_film.c @@ -151,7 +151,7 @@ static int open_film_file(demux_film_t *film) { /* header size = header size - 16-byte FILM signature */ film_header_size = _X_BE_32(&scratch[4]) - 16; - film_header = xine_xmalloc(film_header_size); + film_header = malloc(film_header_size); if (!film_header) return 0; strncpy(film->version, &scratch[8], 4); @@ -331,10 +331,8 @@ static int open_film_file(demux_film_t *film) { /* allocate enough space in the interleave preload buffer for the * first chunk (which will be more than enough for successive chunks) */ if (film->audio_type) { - if (film->interleave_buffer) - free(film->interleave_buffer); - film->interleave_buffer = - xine_xmalloc(film->sample_table[0].sample_size); + free(film->interleave_buffer); + film->interleave_buffer = calloc(1, film->sample_table[0].sample_size); if (!film->interleave_buffer) goto film_abort; } diff --git a/src/demuxers/demux_iff.c b/src/demuxers/demux_iff.c index d43eebf22..1785e86d7 100644 --- a/src/demuxers/demux_iff.c +++ b/src/demuxers/demux_iff.c @@ -399,7 +399,7 @@ static int read_iff_chunk(demux_iff_t *this) { case IFF_CMAP_CHUNK: /* every color contains red, green and blue componente using 8Bit */ this->cmap_num = junk_size / PIC_SIZE_OF_COLOR_REGISTER; - this->cmap = (ColorRegister *)xine_xmalloc(junk_size); + this->cmap = (ColorRegister *)malloc(junk_size); this->video_send_palette = 1; if (!this->cmap || this->input->read(this->input, (char *)this->cmap, junk_size) != junk_size) return 0; @@ -711,14 +711,14 @@ static int demux_iff_send_chunk(demux_plugin_t *this_gen) { if (this->audio_interleave_buffer_size > 0) { this->audio_interleave_buffer = - xine_xmalloc(this->audio_interleave_buffer_size); + calloc(1, this->audio_interleave_buffer_size); if (!this->audio_interleave_buffer) return this->status = DEMUX_FINISHED; } if (this->audio_read_buffer_size > 0) { this->audio_read_buffer = - xine_xmalloc(this->audio_read_buffer_size); + calloc(1, this->audio_read_buffer_size); if (!this->audio_read_buffer) return this->status = DEMUX_FINISHED; } diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index 477a071a4..32dd2cb51 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.c @@ -274,7 +274,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) while ((p[2] != 1) || p[0] || p[1]) { /* resync code */ - for(n=0;n<5;n++) p[n]=p[n+1]; + memmove(p, p+1, 5); i = read_data(this, p+5, (off_t) 1); if (i != 1) { this->status = DEMUX_FINISHED; @@ -306,8 +306,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) p = buf->mem; /* copy local buffer to fifo element. */ - for (n = 0; n < sizeof (buf6); n++) - p[ n ] = buf6[ n ]; + memcpy(p, buf6, sizeof(buf6)); if (preview_mode) buf->decoder_flags = BUF_FLAG_PREVIEW; diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index c8c39c991..16e6c40d9 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -304,10 +304,10 @@ static void send_ogg_packet (demux_ogg_t *this, buf_element_t *buf; int done=0,todo=op->bytes; - int op_size = sizeof(ogg_packet); + const size_t op_size = sizeof(ogg_packet); while (done<todo) { - int offset=0; + size_t offset=0; buf = fifo->buffer_pool_alloc (fifo); buf->decoder_flags = decoder_flags; if (done==0) { @@ -531,34 +531,34 @@ static void update_chapter_display (demux_ogg_t *this, int stream_num, ogg_packe chapter--; if (chapter != this->chapter_info->current_chapter){ - xine_event_t uevent; - xine_ui_data_t data; - int title_len; - char *title; + xine_ui_data_t data = { + .str = { 0, }, + .str_len = 0 + }; + xine_event_t uevent = { + .type = XINE_EVENT_UI_SET_TITLE, + .stream = this->stream, + .data = &data, + .data_length = sizeof(data) + }; this->chapter_info->current_chapter = chapter; - if (chapter >= 0) { - char t_title[256]; + if (chapter >= 0) { if (this->title) { - snprintf(t_title, sizeof (t_title), "%s / %s", this->title, this->chapter_info->entries[chapter].name); + data.str_len = snprintf(data.str, sizeof(data.str), "%s / %s", this->title, this->chapter_info->entries[chapter].name); } else { - snprintf(t_title, sizeof (t_title), "%s", this->chapter_info->entries[chapter].name); + strncpy(data.str, this->chapter_info->entries[chapter].name, sizeof(data.str)-1); } - title = t_title; } else { - title = this->title; + strncpy(data.str, this->title, sizeof(data.str)); } - _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, title); - lprintf("new TITLE: %s\n", title); - - uevent.type = XINE_EVENT_UI_SET_TITLE; - uevent.stream = this->stream; - uevent.data = &data; - uevent.data_length = sizeof(data); - title_len = strlen(title) + 1; - memcpy(data.str, title, title_len); - data.str_len = title_len; + if ( data.str_len == 0 ) + data.str_len = strlen(data.str); + + _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, data.str); + lprintf("new TITLE: %s\n", data.str); + xine_event_send(this->stream, &uevent); } } @@ -1267,8 +1267,8 @@ static void decode_annodex_header (demux_ogg_t *this, const int stream_num, ogg_ static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) { int64_t granule_rate_n, granule_rate_d; uint32_t secondary_headers; - char content_type[1024]; - int content_type_length; + const char *content_type = ""; + size_t content_type_length = 0; lprintf("AnxData stream detected\n"); @@ -1280,11 +1280,16 @@ static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_ lprintf("granule_rate %" PRId64 "/%" PRId64 ", %d secondary headers\n", granule_rate_n, granule_rate_d, secondary_headers); - /* read "Content-Tyoe" MIME header */ - sscanf(&op->packet[28], "Content-Type: %1023s\r\n", content_type); - content_type_length = strlen(content_type); + /* read "Content-Type" MIME header */ + const char *startline = &op->packet[28]; + const char *endline; + if ( strcmp(&op->packet[28], "Content-Type: ") == 0 && + (endline = strstr(startline, "\r\n")) ) { + content_type = startline + sizeof("Content-Type: "); + content_type_length = startline - endline; + } - lprintf("Content-Type: %s (length:%d)\n", content_type, content_type_length); + lprintf("Content-Type: %s (length:%td)\n", content_type, content_type_length); /* how many header packets in the AnxData stream? */ this->si[stream_num]->headers = secondary_headers + 1; @@ -2027,7 +2032,6 @@ static demux_plugin_t *anx_open_plugin (demux_class_t *class_gen, */ this = calloc(1, sizeof(demux_ogg_t)); - memset (this, 0, sizeof(demux_ogg_t)); this->stream = stream; this->input = input; @@ -2073,7 +2077,6 @@ static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen, */ this = calloc(1, sizeof(demux_ogg_t)); - memset (this, 0, sizeof(demux_ogg_t)); this->stream = stream; this->input = input; diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c index 525160dd2..e51344798 100644 --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.c @@ -1736,7 +1736,6 @@ static qt_error build_frame_table(qt_trak *trak, media_id_counts = calloc(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++) { diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index ad5daf5ea..48bf24969 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -440,7 +440,7 @@ static void real_parse_headers (demux_real_t *this) { case CONT_TAG: chunk_size -= PREAMBLE_SIZE; - chunk_buffer = xine_xmalloc(chunk_size); + chunk_buffer = malloc(chunk_size); if (this->input->read(this->input, chunk_buffer, chunk_size) != chunk_size) { free (chunk_buffer); diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c index e34fe0857..bc132adae 100644 --- a/src/demuxers/demux_realaudio.c +++ b/src/demuxers/demux_realaudio.c @@ -110,7 +110,7 @@ static int open_ra_file(demux_ra_t *this) { } /* allocate for and read header data */ - this->header = xine_xmalloc(this->header_size); + this->header = malloc(this->header_size); if (!this->header || _x_demux_read_header(this->input, this->header, this->header_size) != this->header_size) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: unable to read header\n"); diff --git a/src/demuxers/demux_slave.c b/src/demuxers/demux_slave.c index c2d427d8c..28a89a973 100644 --- a/src/demuxers/demux_slave.c +++ b/src/demuxers/demux_slave.c @@ -186,10 +186,8 @@ static int demux_slave_next (demux_slave_t *this) { buf->decoder_flags = decoder_flags; /* set decoder info */ - for( i = 0; i < BUF_NUM_DEC_INFO; i++ ) { - buf->decoder_info[i] = this->decoder_info[i]; - buf->decoder_info_ptr[i] = this->decoder_info_ptr[i]; - } + memcpy(buf->decoder_info, this->decoder_info, sizeof(this->decoder_info)); + memcpy(buf->decoder_info_ptr, this->decoder_info_ptr, sizeof(this->decoder_info)); memset(this->decoder_info, 0, sizeof(this->decoder_info)); memset(this->decoder_info_ptr, 0, sizeof(this->decoder_info_ptr)); diff --git a/src/demuxers/demux_str.c b/src/demuxers/demux_str.c index 97e025504..1e750f183 100644 --- a/src/demuxers/demux_str.c +++ b/src/demuxers/demux_str.c @@ -188,9 +188,7 @@ static int open_str_file(demux_str_t *this) { unsigned char check_bytes[STR_CHECK_BYTES]; int local_offset, sector, channel; - for (channel = 0; channel < STR_MAX_CHANNELS; channel++) { - this->channel_type[channel] = 0; - } + memset(this->channel_type, 0, sizeof(this->channel_type)); this->input->seek(this->input, 0, SEEK_SET); if (this->input->read(this->input, check_bytes, STR_CHECK_BYTES) != diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index c3b1c2bad..6d854e4c3 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -2278,12 +2278,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this->status = DEMUX_FINISHED; -#ifdef TS_READ_STATS - for (i=0; i<=NPKT_PER_READ; i++) { - this->rstat[i] = 0; - } -#endif - /* DVBSUB */ this->spu_pid = INVALID_PID; this->spu_langs_count = 0; diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c index b8d3a8229..4a1cc78ec 100644 --- a/src/demuxers/demux_wav.c +++ b/src/demuxers/demux_wav.c @@ -126,7 +126,7 @@ static int open_wav_file(demux_wav_t *this) { return 0; this->input->seek(this->input, wave_pos, SEEK_SET); - this->wave = xine_xmalloc( this->wave_size ); + this->wave = malloc( this->wave_size ); if (!this->wave || this->input->read(this->input, (void *)this->wave, this->wave_size) != this->wave_size) { diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c index dab0d2619..64ae431fb 100644 --- a/src/demuxers/demux_wc3movie.c +++ b/src/demuxers/demux_wc3movie.c @@ -380,8 +380,6 @@ static int open_mve_file(demux_mve_t *this) { /* allocate space for the shot offset index and set offsets to 0 */ this->shot_offsets = calloc(this->number_of_shots, sizeof(off_t)); this->current_shot = 0; - for (i = 0; i < this->number_of_shots; i++) - this->shot_offsets[i] = 0; /* skip the SOND chunk */ this->input->seek(this->input, 12, SEEK_CUR); |