diff options
Diffstat (limited to 'src/demuxers')
62 files changed, 1319 insertions, 1319 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am index 4c2aac019..bcf812e03 100644 --- a/src/demuxers/Makefile.am +++ b/src/demuxers/Makefile.am @@ -9,7 +9,7 @@ ogg_module = xineplug_dmx_ogg.la endif if BUILD_ASF -asf_module = xineplug_dmx_asf.la +asf_module = xineplug_dmx_asf.la endif if BUILD_NOSEFART @@ -49,7 +49,7 @@ xineplug_LTLIBRARIES = $(ogg_module) $(asf_module) $(mng_module) $(image_module) xineplug_dmx_nsv.la \ xineplug_dmx_matroska.la \ xineplug_dmx_iff.la \ - xineplug_dmx_flv.la + xineplug_dmx_flv.la xineplug_dmx_ogg_la_SOURCES = demux_ogg.c xineplug_dmx_ogg_la_LIBADD = $(XINE_LIB) $(VORBIS_LIBS) $(SPEEX_LIBS) $(THEORA_LIBS) $(OGG_LIBS) $(LTLIBINTL) diff --git a/src/demuxers/demux.h b/src/demuxers/demux.h index 81907cfcf..a824730ea 100644 --- a/src/demuxers/demux.h +++ b/src/demuxers/demux.h @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -63,7 +63,7 @@ struct demux_class_s { */ const char* (*get_identifier) (demux_class_t *this); - + /* * return MIME types supported for this plugin */ @@ -73,7 +73,7 @@ struct demux_class_s { /* * return ' ' seperated list of file extensions this * demuxer is likely to handle - * (will be used to filter media files in + * (will be used to filter media files in * file selection dialogs) */ @@ -100,7 +100,7 @@ struct demux_plugin_s { void (*send_headers) (demux_plugin_t *this); /* - * ask demux to seek + * ask demux to seek * * for seekable streams, a start position can be specified * @@ -118,11 +118,11 @@ struct demux_plugin_s { * starting the demuxer) */ - int (*seek) (demux_plugin_t *this, + int (*seek) (demux_plugin_t *this, off_t start_pos, int start_time, int playing ); /* - * send a chunk of data down to decoder fifos + * send a chunk of data down to decoder fifos * * the meaning of "chunk" is specific to every demux, usually * it involves parsing one unit of data from stream. @@ -132,15 +132,15 @@ struct demux_plugin_s { */ int (*send_chunk) (demux_plugin_t *this); - + /* - * free resources + * free resources */ void (*dispose) (demux_plugin_t *this) ; /* - * returns DEMUX_OK or DEMUX_FINISHED + * returns DEMUX_OK or DEMUX_FINISHED */ int (*get_status) (demux_plugin_t *this) ; @@ -157,12 +157,12 @@ struct demux_plugin_s { */ uint32_t (*get_capabilities) (demux_plugin_t *this); - + /* * request optional data from input plugin. */ int (*get_optional_data) (demux_plugin_t *this, void *data, int data_type); - + /* * "backwards" link to plugin class */ @@ -181,8 +181,8 @@ struct demux_plugin_s { /* * DEMUX_CAP_AUDIOLANG: * DEMUX_CAP_SPULANG: - * demux plugin knows something about audio/spu languages, - * e.g. knows that audio stream #0 is english, + * demux plugin knows something about audio/spu languages, + * e.g. knows that audio stream #0 is english, * audio stream #1 is german, ... Same bits as INPUT * capabilities . */ diff --git a/src/demuxers/demux_4xm.c b/src/demuxers/demux_4xm.c index 397a271b8..a58cf0f22 100644 --- a/src/demuxers/demux_4xm.c +++ b/src/demuxers/demux_4xm.c @@ -256,7 +256,7 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_VIDEO_4XM; if( this->filesize ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->filesize ); buf->extra_info->input_time = this->video_pts / 90; buf->pts = this->video_pts; @@ -271,7 +271,7 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_VIDEO_4XM; if( this->filesize ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->filesize ); buf->extra_info->input_time = this->video_pts / 90; buf->pts = this->video_pts; @@ -320,7 +320,7 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = this->tracks[current_track].audio_type; if( this->filesize ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->filesize ); /* let the engine sort it out */ buf->extra_info->input_time = 0; @@ -354,7 +354,7 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) { break; default: - lprintf("bad chunk: %c%c%c%c (%02X%02X%02X%02X)\n", + lprintf("bad chunk: %c%c%c%c (%02X%02X%02X%02X)\n", header[0], header[1], header[2], header[3], header[0], header[1], header[2], header[3]); this->status = DEMUX_FINISHED; diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c index 68a684ffa..6615f4f61 100644 --- a/src/demuxers/demux_aac.c +++ b/src/demuxers/demux_aac.c @@ -108,7 +108,7 @@ static int open_aac_file(demux_aac_t *this) { if ( this->input->read(this->input, peak, MAX_PREVIEW_SIZE) != MAX_PREVIEW_SIZE ) return 0; this->input->seek(this->input, 0, SEEK_SET); - } else if (_x_demux_read_header(this->input, peak, MAX_PREVIEW_SIZE) != + } else if (_x_demux_read_header(this->input, peak, MAX_PREVIEW_SIZE) != MAX_PREVIEW_SIZE) return 0; @@ -177,7 +177,7 @@ static int demux_aac_send_chunk(demux_plugin_t *this_gen) { buf->free_buffer(buf); this->status = DEMUX_FINISHED; return this->status; - } else + } else buf->size = bytes_read; /* each buffer stands on its own */ diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c index 711bb0b45..f13144254 100644 --- a/src/demuxers/demux_ac3.c +++ b/src/demuxers/demux_ac3.c @@ -307,7 +307,7 @@ static int demux_ac3_send_chunk (demux_plugin_t *this_gen) { } } else { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->size = this->input->read(this->input, buf->content, + buf->size = this->input->read(this->input, buf->content, this->frame_size); } @@ -319,7 +319,7 @@ static int demux_ac3_send_chunk (demux_plugin_t *this_gen) { buf->type = this->buf_type; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) current_stream_pos * + buf->extra_info->input_normpos = (int)( (double) current_stream_pos * 65535 / this->input->get_length (this->input) ); buf->extra_info->input_time = audio_pts / 90; buf->pts = audio_pts; diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c index 273992f64..ee45963a5 100644 --- a/src/demuxers/demux_aiff.c +++ b/src/demuxers/demux_aiff.c @@ -139,7 +139,7 @@ static int open_aiff_file(demux_aiff_t *this) { } chunk_type = _X_BE_32(&preamble[0]); chunk_size = _X_BE_32(&preamble[4]); - + if (chunk_type == COMM_TAG) { unsigned char buffer[100]; @@ -174,7 +174,7 @@ static int open_aiff_file(demux_aiff_t *this) { (this->audio_bits / 8); this->running_time = (this->audio_frames / this->audio_sample_rate) * 1000; - /* we should send only complete frames to decoder, as it + /* we should send only complete frames to decoder, as it * doesn't handle underconsumption yet */ this->audio_block_align = PCM_BLOCK_ALIGN - PCM_BLOCK_ALIGN % (this->audio_bits / 8 * this->audio_channels); @@ -210,7 +210,7 @@ static int demux_aiff_send_chunk (demux_plugin_t *this_gen) { /* just load data chunks from wherever the stream happens to be * pointing; issue a DEMUX_FINISHED status if EOF is reached */ remaining_sample_bytes = this->audio_block_align; - current_file_pos = + current_file_pos = this->input->get_current_pos(this->input) - this->data_start; current_pts = current_file_pos; @@ -258,7 +258,7 @@ static int demux_aiff_send_chunk (demux_plugin_t *this_gen) { this->audio_fifo->put (this->audio_fifo, buf); } - + return this->status; } diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 6c9ea631c..e2da05c75 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -88,13 +88,13 @@ typedef struct { int skip; int resync; int first_seq; - + int payload_size; /* palette handling */ int palette_count; palette_entry_t palette[256]; - + } asf_demux_stream_t; typedef struct demux_asf_s { @@ -109,13 +109,13 @@ typedef struct demux_asf_s { int64_t keyframe_ts; int keyframe_found; - + int seqno; uint32_t packet_size; uint8_t packet_len_flags; uint32_t data_size; uint64_t packet_count; - + asf_demux_stream_t streams[MAX_NUM_STREAMS]; int video_stream; int audio_stream; @@ -145,7 +145,7 @@ typedef struct demux_asf_s { int reorder_b; int buf_flag_seek; - + /* first packet position */ int64_t first_packet_pos; @@ -267,7 +267,7 @@ static int get_guid (demux_asf_t *this) { for(i = 0; i < 8; i++) { g.Data4[i] = get_byte(this); } - + return get_guid_id(this, &g); } @@ -306,7 +306,7 @@ static void asf_send_audio_header (demux_asf_t *this, int stream) { this->status = DEMUX_FINISHED; return; } - + memcpy (buf->content, wavex, asf_stream->private_data_length); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, wavex->wFormatTag); @@ -347,10 +347,10 @@ static void asf_send_video_header (demux_asf_t *this, int stream) { this->status = DEMUX_FINISHED; return; } - + buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAMERATE| BUF_FLAG_FRAME_END; - + buf->decoder_info[0] = 0; if (this->asf_header->aspect_ratios[stream].x && this->asf_header->aspect_ratios[stream].y) @@ -369,7 +369,7 @@ static void asf_send_video_header (demux_asf_t *this, int stream) { /* send off the palette, if there is one */ if (demux_stream->palette_count) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "demux_asf: stream %d, palette : %d entries\n", stream, demux_stream->palette_count); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->decoder_flags = BUF_FLAG_SPECIAL|BUF_FLAG_HEADER; @@ -390,7 +390,7 @@ static int asf_read_header (demux_asf_t *this) { asf_header_len = get_le64(this); if (asf_header_len > 4 * 1024 * 1024) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: asf_read_header: overly-large header? (%"PRIu64" bytes)\n", asf_header_len); return 0; @@ -425,13 +425,13 @@ static int asf_read_header (demux_asf_t *this) { this->packet_size = this->asf_header->file->packet_size; this->packet_count = this->asf_header->file->data_packet_count; - + /* compute stream duration */ - this->length = (this->asf_header->file->send_duration - + this->length = (this->asf_header->file->send_duration - this->asf_header->file->preroll) / 10000; if (this->length < 0) this->length = 0; - + /* compute average byterate (needed for seeking) */ if (this->asf_header->file->max_bitrate) this->rate = this->asf_header->file->max_bitrate >> 3; @@ -473,14 +473,14 @@ static int asf_read_header (demux_asf_t *this) { this->reorder_w = (asf_stream->error_correction_data[2]<<8)|asf_stream->error_correction_data[1]; this->reorder_b = (asf_stream->error_correction_data[4]<<8)|asf_stream->error_correction_data[3]; this->reorder_w /= this->reorder_b; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: audio conceal interleave detected (%d x %d x %d)\n", this->reorder_w, this->reorder_h, this->reorder_b ); } else { this->reorder_b = this->reorder_h = this->reorder_w = 1; } - - + + demux_stream->buf_type = _x_formattag_to_buf_audio ( ((xine_waveformatex *)asf_stream->private_data)->wFormatTag ); if ( !demux_stream->buf_type ) { @@ -489,9 +489,9 @@ static int asf_read_header (demux_asf_t *this) { ((xine_waveformatex *)asf_stream->private_data)->wFormatTag); demux_stream->buf_type = BUF_AUDIO_UNKNOWN; } - + _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC, _x_buf_audio_name(demux_stream->buf_type)); - + this->streams[i].fifo = this->audio_fifo; this->streams[i].frag_offset = 0; this->streams[i].seq = 0; @@ -501,12 +501,12 @@ static int asf_read_header (demux_asf_t *this) { this->streams[i].defrag = 1; } else this->streams[i].defrag = 0; - + lprintf ("found an audio stream id=%d \n", asf_stream->stream_number); break; - + case GUID_ASF_VIDEO_MEDIA: - { + { /* video private data * 11 bytes : header * 40 bytes : bmiheader @@ -515,38 +515,38 @@ static int asf_read_header (demux_asf_t *this) { uint32_t width, height; uint16_t bmiheader_size; xine_bmiheader *bmiheader; - + width = _X_LE_32(asf_stream->private_data); height = _X_LE_32(asf_stream->private_data + 4); /* there is one unknown byte between height and the bmiheader size */ bmiheader_size = _X_LE_16(asf_stream->private_data + 9); - + /* FIXME: bmiheader_size must be >= sizeof(xine_bmiheader) */ - + bmiheader = (xine_bmiheader *) (asf_stream->private_data + 11); _x_bmiheader_le2me(bmiheader); - + /* FIXME: check if (bmi_header_size == bmiheader->biSize) ? */ demux_stream->buf_type = _x_fourcc_to_buf_video(bmiheader->biCompression); if( !demux_stream->buf_type ) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: unknown video format %.4s\n", (char*)&(bmiheader->biCompression)); - + demux_stream->buf_type = BUF_VIDEO_UNKNOWN; } - + _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, _x_buf_video_name(demux_stream->buf_type)); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, width); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, height); - + this->streams[i].fifo = this->video_fifo; this->streams[i].frag_offset = 0; this->streams[i].defrag = 0; - + /* load the palette, if there is one */ demux_stream->palette_count = bmiheader->biClrUsed; - + lprintf ("palette_count: %d\n", demux_stream->palette_count); if (demux_stream->palette_count > 256) { lprintf ("number of colours exceeded 256 (%d)", demux_stream->palette_count); @@ -555,10 +555,10 @@ static int asf_read_header (demux_asf_t *this) { if ((asf_stream->private_data_length - sizeof(xine_bmiheader) - 11) >= (demux_stream->palette_count * 4)) { int j; uint8_t *palette; - + /* according to msdn the palette is located here : */ palette = (uint8_t *)bmiheader + bmiheader->biSize; - + /* load the palette */ for (j = 0; j < demux_stream->palette_count; j++) { demux_stream->palette[j].b = *(palette + j * 4 + 0); @@ -567,7 +567,7 @@ static int asf_read_header (demux_asf_t *this) { } } else { int j; - + /* generate a greyscale palette */ demux_stream->palette_count = 256; for (j = 0; j < demux_stream->palette_count; j++) { @@ -576,7 +576,7 @@ static int asf_read_header (demux_asf_t *this) { demux_stream->palette[j].b = j; } } - + lprintf ("found a video stream id=%d, buf_type=%08x \n", this->asf_header->streams[i]->stream_number, this->streams[i].buf_type); } @@ -746,7 +746,7 @@ static void asf_send_buffer_nodefrag (demux_asf_t *this, asf_demux_stream_t *str lprintf ("data: %d %d %d %d\n", buf->content[0], buf->content[1], buf->content[2], buf->content[3]); if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->extra_info->input_time = timestamp; @@ -832,46 +832,46 @@ static void asf_send_buffer_defrag (demux_asf_t *this, asf_demux_stream_t *strea if (package_done) { int bufsize; uint8_t *p; - + lprintf("packet done: offset=%d, payload=%d\n", stream->frag_offset, stream->payload_size); if (stream->fifo == this->audio_fifo && this->reorder_h > 1 && this->reorder_w > 1 ) { asf_reorder(this,stream->buffer,stream->frag_offset); } - + p = stream->buffer; while( stream->frag_offset ) { if ( stream->frag_offset < stream->fifo->buffer_pool_buf_size ) bufsize = stream->frag_offset; else bufsize = stream->fifo->buffer_pool_buf_size; - + buf = stream->fifo->buffer_pool_alloc (stream->fifo); xine_fast_memcpy (buf->content, p, bufsize); - + if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->extra_info->input_time = stream->timestamp; - + /* send the same pts for the entire frame */ buf->pts = stream->timestamp * 90; - + buf->type = stream->buf_type; buf->size = bufsize; - + lprintf ("buffer type %08x %8d bytes, %8lld pts\n", buf->type, buf->size, buf->pts); - + stream->frag_offset -= bufsize; p+=bufsize; - + if ((buf->type & BUF_MAJOR_MASK) == BUF_VIDEO_BASE) check_newpts (this, buf->pts, PTS_VIDEO, !stream->frag_offset); else check_newpts (this, buf->pts, PTS_AUDIO, !stream->frag_offset); - + /* test if whole packet read */ if ( !stream->frag_offset ) buf->decoder_flags |= BUF_FLAG_FRAME_END; @@ -888,9 +888,9 @@ static int asf_parse_packet_align(demux_asf_t *this) { uint32_t mod; uint64_t packet_num; - + current_pos = this->input->get_current_pos (this->input); - + /* seek to the beginning of the next packet */ mod = (current_pos - this->first_packet_pos) % this->packet_size; this->packet_size_left = mod ? this->packet_size - mod : 0; @@ -904,7 +904,7 @@ static int asf_parse_packet_align(demux_asf_t *this) { } } this->packet_size_left = 0; - + /* check packet_count */ packet_num = (packet_pos - this->first_packet_pos) / this->packet_size; lprintf("packet_num=%"PRId64", packet_count=%"PRId64"\n", packet_num, this->packet_count); @@ -925,7 +925,7 @@ static int asf_parse_packet_align(demux_asf_t *this) { } } } - + return 0; } @@ -951,7 +951,7 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { ecd_opaque = (ecd_flags >> 4) & 0x1; ecd_len_type = (ecd_flags >> 5) & 0x3; ecd_present = (ecd_flags >> 7) & 0x1; - + /* skip ecd */ if (ecd_present && !ecd_opaque && !ecd_len_type) { int read_size; @@ -965,7 +965,7 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { } else { GUID *guid = (GUID *)buf; - + /* check if it's a new stream */ buf[0] = ecd_flags; if (this->input->read (this->input, buf + 1, 15) != 15) { @@ -982,7 +982,7 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { if (demux_asf_send_headers_common(this)) return 1; } else { - + /* skip invalid packet */ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: skip invalid packet: %2X\n", ecd_flags); this->input->seek (this->input, this->packet_size - *p_hdr_size, SEEK_CUR); @@ -991,7 +991,7 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) { } } } while (invalid_packet); - + return 0; } @@ -1060,7 +1060,7 @@ static int asf_parse_packet_payload_header(demux_asf_t *this, uint32_t p_hdr_siz xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: invalid padsize: %d\n", this->packet_padsize); return 1; } - + /* Multiple frames */ if (this->packet_len_flags & 0x01) { this->frame_flag = get_byte(this); p_hdr_size += 1; @@ -1097,7 +1097,7 @@ static int asf_parse_packet_payload_common(demux_asf_t *this, *stream = NULL; lprintf ("got raw_id=%d, stream_id=%d\n", raw_id, stream_id); - + for (i = 0; i < this->asf_header->stream_count; i++) { lprintf ("stream_number = %d\n", this->asf_header->streams[i]->stream_number); if ((this->asf_header->streams[i]->stream_number == stream_id) && @@ -1107,7 +1107,7 @@ static int asf_parse_packet_payload_common(demux_asf_t *this, break; } } - + switch ((this->packet_prop_flags >> 4) & 3){ case 1: seq = get_byte(this); s_hdr_size += 1; @@ -1264,10 +1264,10 @@ static int asf_parse_packet_compressed_payload(demux_asf_t *this, stream->resync = 0; stream->skip = 0; } - + if (!stream->skip) { lprintf ("sending buffer of type %08x\n", stream->buf_type); - + if (stream->defrag) asf_send_buffer_defrag (this, stream, 0, *timestamp, object_length); else @@ -1439,15 +1439,15 @@ static int demux_asf_parse_http_references( demux_asf_t *this) { if (!end) goto failure; *end = '\0'; } - + /* replace http by mmsh */ if (!strncmp(href, "http", 4)) { memcpy(href, "mmsh", 4); } - + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: http ref: %s\n", href); _x_demux_send_mrl_reference (this->stream, 0, href, NULL, 0, 0); - + if (free_href) free(href); } @@ -1631,13 +1631,13 @@ static int demux_asf_parse_asx_references( demux_asf_t *this) { else if (!strcasecmp (asx_ref->name, "STARTTIME")) { - if (start_time == (uint32_t)-1) + if (start_time == (uint32_t)-1) start_time = asx_get_time_value (asx_ref); } else if (!strcasecmp (asx_ref->name, "DURATION")) { - if (duration == (uint32_t)-1) + if (duration == (uint32_t)-1) duration = asx_get_time_value (asx_ref); } @@ -1690,7 +1690,7 @@ static int demux_asf_send_chunk (demux_plugin_t *this_gen) { uint32_t rlen = 0; uint8_t raw_id = 0; int64_t ts = 0; - + switch (this->mode) { case ASF_MODE_ASX_REF: return demux_asf_parse_asx_references(this); @@ -1707,9 +1707,9 @@ static int demux_asf_send_chunk (demux_plugin_t *this_gen) { return this->status; default: - { + { int header_size = 0; - + if (asf_parse_packet_align(this)) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: asf_parse_packet_align failed\n"); this->status = DEMUX_FINISHED; @@ -1725,7 +1725,7 @@ static int demux_asf_send_chunk (demux_plugin_t *this_gen) { this->status = DEMUX_FINISHED; return this->status; } - + for (this->frame = 0; this->frame < (this->nb_frames & 0x3f); this->frame++) { raw_id = get_byte(this); this->packet_size_left -= 1; @@ -1750,7 +1750,7 @@ static void demux_asf_dispose (demux_plugin_t *this_gen) { if (this->asf_header) { int i; - + for (i=0; i<this->asf_header->stream_count; i++) { asf_demux_stream_t *asf_stream; @@ -1763,7 +1763,7 @@ static void demux_asf_dispose (demux_plugin_t *this_gen) { asf_header_delete (this->asf_header); } - + free (this); } @@ -1823,11 +1823,11 @@ static int demux_asf_seek (demux_plugin_t *this_gen, start_pos, start_time); this->status = DEMUX_OK; - + if (this->mode != ASF_MODE_NORMAL) { return this->status; } - + /* * seek to start position */ @@ -1841,7 +1841,7 @@ static int demux_asf_seek (demux_plugin_t *this_gen, this->last_pts[PTS_AUDIO] = 0; this->keyframe_ts = 0; this->keyframe_found = 0; - + /* engine sync stuff */ this->send_newpts = 1; this->buf_flag_seek = 1; @@ -1849,11 +1849,11 @@ static int demux_asf_seek (demux_plugin_t *this_gen, if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) { _x_demux_flush_engine(this->stream); - + start_time /= 1000; start_pos = (off_t) ( (double) start_pos / 65535 * this->input->get_length (this->input) ); - + if ( (!start_pos) && (start_time)) start_pos = start_time * this->rate; @@ -1914,7 +1914,7 @@ static int demux_asf_seek (demux_plugin_t *this_gen, this->status = DEMUX_FINISHED; return this->status; } - + for (this->frame = 0; this->frame < (this->nb_frames & 0x3f); this->frame++) { raw_id = get_byte(this); this->packet_size_left -= 1; @@ -1923,7 +1923,7 @@ static int demux_asf_seek (demux_plugin_t *this_gen, stream_id = raw_id & 0x7f; if (asf_parse_packet_payload_common(this, raw_id, &stream, &frag_offset, &rlen)) break; - + if (rlen == 1) { if (asf_parse_packet_compressed_payload(this, stream, raw_id, frag_offset, &ts)) break; @@ -1931,7 +1931,7 @@ static int demux_asf_seek (demux_plugin_t *this_gen, if (asf_parse_packet_payload(this, stream, raw_id, frag_offset, rlen, &ts)) break; } - + if (state == 0) { if (this->keyframe_found) { if (this->audio_stream == -1) { @@ -1981,12 +1981,12 @@ static int demux_asf_seek (demux_plugin_t *this_gen, this->streams[this->audio_stream].resync = 1; this->streams[this->audio_stream].skip = 1; } - } else if (!playing && this->input->seek_time != NULL) { + } else if (!playing && this->input->seek_time != NULL) { if (start_pos && !start_time) start_time = this->length * start_pos / 65535; - + this->input->seek_time (this->input, start_time, SEEK_SET); - + this->keyframe_ts = 0; this->keyframe_found = 0; /* means next keyframe */ if (this->video_stream >= 0) { @@ -2011,7 +2011,7 @@ static int demux_asf_seek (demux_plugin_t *this_gen, } } return this->status; - + error: this->status = DEMUX_FINISHED; return this->status; @@ -2140,7 +2140,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this->demux_plugin.demux_class = class_gen; this->status = DEMUX_FINISHED; - + return &this->demux_plugin; } @@ -2201,7 +2201,7 @@ static void *init_class (xine_t *xine, void *data) { static const demuxer_info_t demux_info_asf = { 10 /* priority */ }; - + const plugin_info_t xine_plugin_info[] EXPORTED = { /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "asf", XINE_VERSION_CODE, &demux_info_asf, init_class }, diff --git a/src/demuxers/demux_aud.c b/src/demuxers/demux_aud.c index 7730de1fa..caaa4e91a 100644 --- a/src/demuxers/demux_aud.c +++ b/src/demuxers/demux_aud.c @@ -105,7 +105,7 @@ remove this case for the time being since this audio type is not supported anyway. if (header[11] == 1) this->audio_type = BUF_AUDIO_WESTWOOD; - else + else #endif if (header[11] == 99) this->audio_type = BUF_AUDIO_VQA_IMA; diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 0ab3448bb..100828bd2 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -7,12 +7,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -134,7 +134,7 @@ typedef struct _avistdindex_chunk { uint32_t dwReserved3; /* must be 0 */ avistdindex_entry *aIndex; } avistdindex_chunk; - + /* Base Index Form 'indx' */ typedef struct _avisuperindex_chunk { @@ -150,7 +150,7 @@ typedef struct _avisuperindex_chunk { avisuperindex_entry *aIndex; /* where are the ix## chunks */ avistdindex_chunk **stdindex; /* the ix## chunks itself (array) */ } avisuperindex_chunk; - + /* These next three are the video and audio structures that can grow * during the playback of a streaming file. */ @@ -473,7 +473,7 @@ static int start_pos_stopper(demux_avi_t *this, void *data) { maxframe--; } return -1; -} +} /* Use this one to ensure that a video frame with the given timestamp * is in the index. */ @@ -600,11 +600,11 @@ static int idx_grow(demux_avi_t *this, int (*stopper)(demux_avi_t *, void *), } } else { int i; - + /* Audio chunk */ for(i = 0; i < this->avi->n_audio; ++i) { avi_audio_t *audio = this->avi->audio[i]; - + if ((data[0] == audio->audio_tag[0]) && (data[1] == audio->audio_tag[1])) { off_t pos = chunk_pos + AVI_HEADER_SIZE; @@ -617,7 +617,7 @@ static int idx_grow(demux_avi_t *this, int (*stopper)(demux_avi_t *, void *), } else { audio->block_no += 1; } - + if (audio_index_append(this->avi, i, pos, chunk_len, audio->audio_tot, audio->block_no) == -1) { /* As above. */ @@ -711,10 +711,10 @@ do { \ static void reset_idx(demux_avi_t *this, avi_t *AVI) { int n; - + this->idx_grow.nexttagoffset = AVI->movi_start; this->has_index = 0; - + AVI->video_idx.video_frames = 0; for(n = 0; n < AVI->n_audio; n++) { AVI->audio[n]->audio_idx.audio_chunks = 0; @@ -778,14 +778,14 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { n = _X_LE_32(data + 4); n = PAD_EVEN(n); next_chunk = this->idx_grow.nexttagoffset + 8 + n; - + lprintf("chunk: %c%c%c%c, size: %" PRId64 "\n", data[0], data[1], data[2], data[3], (int64_t)n); - + if (n >= 4 && strncasecmp(data,"LIST",4) == 0) { if( this->input->read(this->input, data,4) != 4 ) ERR_EXIT(AVI_ERR_READ); n -= 4; - + lprintf(" chunk: %c%c%c%c\n", data[0], data[1], data[2], data[3]); @@ -799,7 +799,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { ERR_EXIT(AVI_ERR_READ); } else if(strncasecmp(data,"movi",4) == 0) { - + AVI->movi_start = this->input->get_current_pos(this->input); AVI->movi_end = AVI->movi_start + n - 1; @@ -877,7 +877,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { lasttag = 1; /* vids */ lprintf("dwScale=%d, dwRate=%d, dwInitialFrames=%d, dwStart=%d, num_stream=%d\n", AVI->dwScale, AVI->dwRate, AVI->dwInitialFrames, AVI->dwStart, num_stream); - + } else if (strncasecmp (hdrl_data+i,"auds",4) ==0 /* && ! auds_strh_seen*/) { if(AVI->n_audio < MAX_AUDIO_STREAMS) { avi_audio_t *a = (avi_audio_t *) calloc(1, sizeof(avi_audio_t)); @@ -892,10 +892,10 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { a->dwScale = _X_LE_32(hdrl_data + i + 20); a->dwRate = _X_LE_32(hdrl_data + i + 24); a->dwStart = _X_LE_32(hdrl_data + i + 28); - + lprintf("dwScale=%d, dwRate=%d, dwInitialFrames=%d, dwStart=%d, num_stream=%d\n", a->dwScale, a->dwRate, a->dwInitialFrames, a->dwStart, num_stream); - + a->dwSampleSize = _X_LE_32(hdrl_data + i + 44); a->audio_tot = 0; auds_strh_seen = 1; @@ -909,14 +909,14 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { lasttag = 0; } num_stream++; - + } else if(strncasecmp(hdrl_data+i,"dmlh",4) == 0) { AVI->total_frames = _X_LE_32(hdrl_data+i+8); #ifdef DEBUG_ODML lprintf( "AVI: real number of frames %d\n", AVI->total_frames); #endif i += 8; - + } else if(strncasecmp(hdrl_data + i, "strf", 4) == 0) { i += 4; strf_size = _X_LE_32(hdrl_data + i); @@ -973,7 +973,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { } else if(lasttag == 2) { xine_waveformatex *wavex; - + wavex = (xine_waveformatex *)malloc(n); if (!wavex) { this->AVI_errno = AVI_ERR_NO_MEM; @@ -1175,7 +1175,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { } lprintf("idx_type=%d, AVI->n_idx=%d\n", idx_type, AVI->n_idx); - + if (idx_type != 0 && !AVI->is_opendml) { /* Now generate the video index and audio index arrays from the * idx1 record. */ @@ -1232,7 +1232,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "demux_avi: This is an OpenDML stream\n"); nvi = 0; - for(audtr=0; audtr<AVI->n_audio; ++audtr) nai[audtr] = 0; + for(audtr=0; audtr<AVI->n_audio; ++audtr) nai[audtr] = 0; /* ************************ */ /* VIDEO */ @@ -1300,7 +1300,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { "demux_avi: Warning: the video super index is NULL\n"); } - + /* ************************ */ /* AUDIO */ /* ************************ */ @@ -1344,7 +1344,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { /* skip header */ en += hdrl_len; nai[audtr] += nrEntries; - + while (k < nai[audtr]) { off_t pos; @@ -1352,7 +1352,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { pos = offset + _X_LE_32(en); en += 4; len = odml_len(en); en += 4; - + /* VBR streams (hack from mplayer) */ if (audio->wavex && audio->wavex->nBlockAlign) { audio->block_no += (len + audio->wavex->nBlockAlign - 1) / @@ -1394,7 +1394,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { this->idx_grow.nexttagoffset = AVI->movi_start; this->has_index = 0; } - + /* Reposition the file */ if (!this->streaming) this->input->seek(this->input, AVI->movi_start, SEEK_SET); @@ -1480,7 +1480,7 @@ static int AVI_read_video(demux_avi_t *this, avi_t *AVI, char *vidbuf, nr = 0; /* total number of bytes read */ left = vie->len - AVI->video_posb; - + while ((bytes > 0) && (left > 0)) { if (bytes < left) todo = bytes; @@ -1522,7 +1522,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { int audio_sent = 0; lprintf("begin\n"); - + /* Try to grow the index, in case more of the avi file has shown up * since we last checked. If it's still too small, well then we're at * the end of the stream. */ @@ -1531,7 +1531,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { lprintf("end of stream\n"); } } - + for (i = 0; i < this->avi->n_audio; i++) { avi_audio_t *audio = this->avi->audio[i]; @@ -1542,7 +1542,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { } } } - + video_pts = get_video_pts (this, this->avi->video_posf); for (i=0; i < this->avi->n_audio; i++) { @@ -1568,7 +1568,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { /* read audio */ buf->pts = audio_pts; - + buf->size = AVI_read_audio (this, audio, buf->mem, buf->max_size, &buf->decoder_flags); buf->decoder_flags |= decoder_flags; @@ -1580,12 +1580,12 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { buf->type = audio->audio_type | i; buf->extra_info->input_time = audio_pts / 90; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); - + check_newpts (this, buf->pts, PTS_AUDIO); this->audio_fifo->put (this->audio_fifo, buf); - + audio_sent++; } } else @@ -1595,7 +1595,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { if (audio_sent == 0) { do_read_video = 1; } - + if (do_read_video) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); @@ -1611,12 +1611,12 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { if (this->has_index && this->avi->video_idx.video_frames > 2) { /* use video_frames-2 instead of video_frames-1 to fix problems with weird non-interleaved streams */ - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->avi->video_idx.vindex[this->avi->video_idx.video_frames - 2].pos); } else { if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); } buf->extra_info->frame_number = this->avi->video_posf; @@ -1631,7 +1631,7 @@ static int demux_avi_next (demux_avi_t *this, int decoder_flags) { lprintf ("adding buf %d to video fifo, decoder_info[0]: %d\n", buf, buf->decoder_info[0]); */ - + check_newpts (this, buf->pts, PTS_VIDEO); this->video_fifo->put (this->video_fifo, buf); video_sent++; @@ -1752,7 +1752,7 @@ static int demux_avi_next_streaming (demux_avi_t *this, int decoder_flags) { } buf->extra_info->input_time = audio_pts / 90; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->type = audio->audio_type | audio_stream; @@ -1783,7 +1783,7 @@ static int demux_avi_next_streaming (demux_avi_t *this, int decoder_flags) { /* read video */ buf->pts = video_pts; lprintf("video pts: %" PRId64 "\n", video_pts); - + if (left > this->video_fifo->buffer_pool_buf_size) { buf->size = this->video_fifo->buffer_pool_buf_size; buf->decoder_flags = 0; @@ -1838,7 +1838,7 @@ static int demux_avi_send_chunk (demux_plugin_t *this_gen) { this->seek_request = 0; demux_avi_seek_internal(this); } - + if (!demux_avi_next (this, 0)) { this->status = DEMUX_FINISHED; } @@ -1918,7 +1918,7 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { this->avi->bih->biCompression = this->avi->compressor; this->avi->video_type = BUF_VIDEO_XVID; } - + _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, !this->no_audio); _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, _x_buf_video_name(this->avi->video_type)); @@ -1936,7 +1936,7 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { _x_demux_control_start (this->stream); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - + if (this->avi->bih->biSize > buf->max_size) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "demux_avi: private video decoder data length (%d) is greater than fifo buffer length (%d)\n", @@ -1945,9 +1945,9 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { this->status = DEMUX_FINISHED; return; } - + /* wait, before sending out the video header, one more special case hack: - * if the video type is RGB, indicate that it is upside down with a + * if the video type is RGB, indicate that it is upside down with a * negative height */ if (this->avi->video_type == BUF_VIDEO_RGB) { this->avi->bih->biHeight = -this->avi->bih->biHeight; @@ -1958,7 +1958,7 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { buf->decoder_info[0] = this->video_step; memcpy (buf->content, this->avi->bih, this->avi->bih->biSize); buf->size = this->avi->bih->biSize; - + if (this->avi->video_type) { this->avi->compressor = this->avi->bih->biCompression; } else { @@ -2006,7 +2006,7 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { buf->size = todo; } todo -= buf->size; - + buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER; if (todo == 0) buf->decoder_flags |= BUF_FLAG_FRAME_END; @@ -2023,7 +2023,7 @@ static void demux_avi_send_headers (demux_plugin_t *this_gen) { } if(this->avi->n_audio == 1) - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, this->avi->audio[0]->wavex->wFormatTag); } @@ -2073,7 +2073,7 @@ static int demux_avi_seek_internal (demux_avi_t *this) { int64_t audio_pts; off_t start_pos = this->seek_start_pos; int start_time = this->seek_start_time; - + start_pos = (off_t) ( (double) start_pos / 65535 * this->input->get_length (this->input) ); @@ -2108,12 +2108,12 @@ static int demux_avi_seek_internal (demux_avi_t *this) { video_pts = start_time * 90; idx_grow(this, start_time_stopper, &video_pts); } - + if (start_pos || start_time) max_pos = this->avi->video_idx.video_frames - 1; else max_pos=0; - + cur_pos = this->avi->video_posf; if (max_pos < 0) { this->status = DEMUX_FINISHED; @@ -2141,7 +2141,7 @@ static int demux_avi_seek_internal (demux_avi_t *this) { } } } - + while (vie && !(vie->flags & AVIIF_KEYFRAME) && cur_pos) { this->avi->video_posf = --cur_pos; vie = video_cur_index_entry(this); @@ -2164,7 +2164,7 @@ static int demux_avi_seek_internal (demux_avi_t *this) { if (!this->no_audio && this->status == DEMUX_OK) { audio_index_entry_t *aie; int i; - + for(i = 0; i < this->avi->n_audio; i++) { max_pos = this->avi->audio[i]->audio_idx.audio_chunks - 1; min_pos = 0; diff --git a/src/demuxers/demux_cdda.c b/src/demuxers/demux_cdda.c index d48bb2a51..6aee5042e 100644 --- a/src/demuxers/demux_cdda.c +++ b/src/demuxers/demux_cdda.c @@ -84,7 +84,7 @@ static int demux_cdda_send_chunk (demux_plugin_t *this_gen) { buf->type = BUF_AUDIO_LPCM_LE; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->pts = this->input->get_current_pos(this->input); buf->pts *= 90000; diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c index ed1f16d33..0c73877e9 100644 --- a/src/demuxers/demux_dts.c +++ b/src/demuxers/demux_dts.c @@ -160,7 +160,7 @@ static int open_dts_file(demux_dts_t *this) { break; } /* 14 bits and little endian bitstream */ - else if ((syncword == 0xff1f00e8) && + else if ((syncword == 0xff1f00e8) && ((peak[i] & 0xf0) == 0xf0) && (peak[i+1] == 0x07)) { dts_version = 3; break; @@ -218,8 +218,8 @@ static int open_dts_file(demux_dts_t *this) { { case 0: /* BE16 */ case 1: /* LE16 */ - this->frame_size = fsize * 8 / 16 * 2; - break; + this->frame_size = fsize * 8 / 16 * 2; + break; case 2: /* BE14 */ case 3: /* LE14 */ this->frame_size = fsize * 8 / 14 * 2; @@ -250,7 +250,7 @@ static int demux_dts_send_chunk (demux_plugin_t *this_gen) { int frame_number; uint32_t blocksize; - current_stream_pos = this->input->get_current_pos(this->input) - + current_stream_pos = this->input->get_current_pos(this->input) - this->data_start; frame_number = current_stream_pos / this->frame_size; @@ -274,7 +274,7 @@ static int demux_dts_send_chunk (demux_plugin_t *this_gen) { } } else { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->size = this->input->read(this->input, buf->content, + buf->size = this->input->read(this->input, buf->content, this->frame_size); } @@ -286,7 +286,7 @@ static int demux_dts_send_chunk (demux_plugin_t *this_gen) { buf->type = BUF_AUDIO_DTS; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) current_stream_pos * + buf->extra_info->input_normpos = (int)( (double) current_stream_pos * 65535 / (this->input->get_length(this->input) - this->data_start) ); buf->extra_info->input_time = audio_pts / 90; buf->pts = audio_pts; @@ -360,7 +360,7 @@ static int demux_dts_seek (demux_plugin_t *this_gen, if (start_time) { int length = demux_dts_get_stream_length (this_gen); if (length != 0) { - start_pos = start_time * + start_pos = start_time * (this->input->get_length(this->input) - this->data_start) / length; } } diff --git a/src/demuxers/demux_eawve.c b/src/demuxers/demux_eawve.c index 7a21635cb..2e393847c 100644 --- a/src/demuxers/demux_eawve.c +++ b/src/demuxers/demux_eawve.c @@ -213,7 +213,7 @@ static int demux_eawve_send_chunk(demux_eawve_t *this){ buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo); buf->type = BUF_AUDIO_EA_ADPCM; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->extra_info->input_time = (int)((int64_t)this->sample_counter * 1000 / 22050); buf->pts = this->sample_counter; diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c index a66befe01..d38fe3c62 100644 --- a/src/demuxers/demux_elem.c +++ b/src/demuxers/demux_elem.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -46,7 +46,7 @@ #define NUM_PREVIEW_BUFFERS 50 #define SCRATCH_SIZE 256 -typedef struct { +typedef struct { demux_plugin_t demux_plugin; xine_stream_t *stream; @@ -83,7 +83,7 @@ static int demux_mpeg_elem_next (demux_mpeg_elem_t *this, int preview_mode) { buf->content = buf->mem; buf->pts = 0; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->type = BUF_VIDEO_MPEG; @@ -91,7 +91,7 @@ static int demux_mpeg_elem_next (demux_mpeg_elem_t *this, int preview_mode) { buf->decoder_flags = BUF_FLAG_PREVIEW; this->video_fifo->put(this->video_fifo, buf); - + return 1; } @@ -304,7 +304,7 @@ static const demuxer_info_t demux_info_elem = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "elem", XINE_VERSION_CODE, &demux_info_elem, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c index dcd57f76c..a8bd0b288 100644 --- a/src/demuxers/demux_film.c +++ b/src/demuxers/demux_film.c @@ -163,7 +163,7 @@ static int open_film_file(demux_film_t *film) { film->version[3]); /* load the rest of the FILM header */ - if (film->input->read(film->input, film_header, film_header_size) != + if (film->input->read(film->input, film_header, film_header_size) != film_header_size) { free (film->interleave_buffer); free (film->sample_table); @@ -202,7 +202,7 @@ static int open_film_file(demux_film_t *film) { if( !film->video_type ) film->video_type = BUF_VIDEO_UNKNOWN; - + /* fetch the audio information if the chunk size checks out */ if (chunk_size == 32) { film->audio_channels = film_header[21]; @@ -388,7 +388,7 @@ static int demux_film_send_chunk(demux_plugin_t *this_gen) { } /* check if we're only sending audio samples until the next keyframe */ - if ((this->waiting_for_keyframe) && + if ((this->waiting_for_keyframe) && (!this->sample_table[i].audio)) { if (this->sample_table[i].keyframe) { this->waiting_for_keyframe = 0; @@ -428,7 +428,7 @@ static int demux_film_send_chunk(demux_plugin_t *this_gen) { /* set the frame duration */ buf->decoder_flags |= BUF_FLAG_FRAMERATE; buf->decoder_info[0] = this->sample_table[i].duration; - + if (remaining_sample_bytes > buf->max_size) buf->size = buf->max_size; else @@ -443,11 +443,11 @@ static int demux_film_send_chunk(demux_plugin_t *this_gen) { } /* skip over the extra non-spec CVID bytes */ - this->input->seek(this->input, + this->input->seek(this->input, this->sample_table[i].sample_size - cvid_chunk_size, SEEK_CUR); /* load the rest of the chunk */ - if (this->input->read(this->input, buf->content + 10, + if (this->input->read(this->input, buf->content + 10, buf->size - 10) != buf->size - 10) { buf->free_buffer(buf); this->status = DEMUX_FINISHED; @@ -499,7 +499,7 @@ static int demux_film_send_chunk(demux_plugin_t *this_gen) { /* set the frame duration */ buf->decoder_flags |= BUF_FLAG_FRAMERATE; buf->decoder_info[0] = this->sample_table[i].duration; - + if (remaining_sample_bytes > buf->max_size) buf->size = buf->max_size; else @@ -627,8 +627,8 @@ static int demux_film_send_chunk(demux_plugin_t *this_gen) { buf->content[j] = this->interleave_buffer[k]; buf->content[j + 1] = this->interleave_buffer[k + 1]; } - for (j = 2, - k = interleave_index + this->sample_table[i].sample_size / 2; + for (j = 2, + k = interleave_index + this->sample_table[i].sample_size / 2; j < buf->size; j += 4, k += 2) { buf->content[j] = this->interleave_buffer[k]; buf->content[j + 1] = this->interleave_buffer[k + 1]; @@ -638,8 +638,8 @@ static int demux_film_send_chunk(demux_plugin_t *this_gen) { for (j = 0, k = interleave_index; j < buf->size; j += 2, k += 1) { buf->content[j] = this->interleave_buffer[k] += 0x80; } - for (j = 1, - k = interleave_index + this->sample_table[i].sample_size / 2; + for (j = 1, + k = interleave_index + this->sample_table[i].sample_size / 2; j < buf->size; j += 2, k += 1) { buf->content[j] = this->interleave_buffer[k] += 0x80; } @@ -654,7 +654,7 @@ static int demux_film_send_chunk(demux_plugin_t *this_gen) { this->audio_fifo->put(this->audio_fifo, buf); } } - + return this->status; } @@ -737,13 +737,13 @@ static int demux_film_seek (demux_plugin_t *this_gen, off_t start_pos, int start this->waiting_for_keyframe = 0; this->last_sample = 0; } - + /* if input is non-seekable, do not proceed with the rest of this * seek function */ if (!INPUT_IS_SEEKABLE(this->input)) return this->status; - /* perform a binary search on the sample table, testing the offset + /* perform a binary search on the sample table, testing the offset * boundaries first */ if (start_pos) { if (start_pos <= 0) @@ -760,7 +760,7 @@ static int demux_film_seek (demux_plugin_t *this_gen, off_t start_pos, int start while (!found) { middle = (left + right) / 2; if ((start_pos >= this->sample_table[middle].sample_offset) && - (start_pos <= this->sample_table[middle].sample_offset + + (start_pos <= this->sample_table[middle].sample_offset + this->sample_table[middle].sample_size)) { found = 1; } else if (start_pos < this->sample_table[middle].sample_offset) { @@ -817,7 +817,7 @@ static int demux_film_seek (demux_plugin_t *this_gen, off_t start_pos, int start } this->current_sample = best_index; - + return this->status; } diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c index c4132b767..885e440a1 100644 --- a/src/demuxers/demux_flac.c +++ b/src/demuxers/demux_flac.c @@ -119,7 +119,7 @@ static int open_flac_file(demux_flac_t *flac) { * will always be 1 metadata block */ do { - if (flac->input->read(flac->input, preamble, FLAC_SIGNATURE_SIZE) != + if (flac->input->read(flac->input, preamble, FLAC_SIGNATURE_SIZE) != FLAC_SIGNATURE_SIZE) return 0; @@ -133,11 +133,11 @@ static int open_flac_file(demux_flac_t *flac) { case 0: lprintf ("STREAMINFO metadata\n"); if (block_length != FLAC_STREAMINFO_SIZE) { - lprintf ("expected STREAMINFO chunk of %d bytes\n", + lprintf ("expected STREAMINFO chunk of %d bytes\n", FLAC_STREAMINFO_SIZE); return 0; } - if (flac->input->read(flac->input, + if (flac->input->read(flac->input, flac->streaminfo + sizeof(xine_waveformatex), FLAC_STREAMINFO_SIZE) != FLAC_STREAMINFO_SIZE) return 0; @@ -146,8 +146,8 @@ static int open_flac_file(demux_flac_t *flac) { flac->bits_per_sample = ((flac->sample_rate >> 4) & 0x1F) + 1; flac->sample_rate >>= 12; flac->total_samples = _X_BE_64(&streaminfo[10]) & UINT64_C(0x0FFFFFFFFF); /* 36 bits */ - lprintf ("%d Hz, %d bits, %d channels, %"PRId64" total samples\n", - flac->sample_rate, flac->bits_per_sample, + lprintf ("%d Hz, %d bits, %d channels, %"PRId64" total samples\n", + flac->sample_rate, flac->bits_per_sample, flac->channels, flac->total_samples); break; @@ -178,7 +178,7 @@ static int open_flac_file(demux_flac_t *flac) { lprintf (" %d: sample %"PRId64", ", i, flac->seekpoints[i].sample_number); flac->seekpoints[i].offset = _X_BE_64(&buffer[8]); flac->seekpoints[i].size = _X_BE_16(&buffer[16]); - lprintf ("@ 0x%"PRIX64", size = %d bytes, ", + lprintf ("@ 0x%"PRIX64", size = %d bytes, ", flac->seekpoints[i].offset, flac->seekpoints[i].size); flac->seekpoints[i].pts = flac->seekpoints[i].sample_number; flac->seekpoints[i].pts *= 90000; @@ -187,7 +187,7 @@ static int open_flac_file(demux_flac_t *flac) { } break; - /* VORBIS_COMMENT + /* VORBIS_COMMENT * * For a description of the format please have a look at * http://www.xiph.org/vorbis/doc/v-comment.html */ @@ -229,7 +229,7 @@ static int open_flac_file(demux_flac_t *flac) { lprintf ("comment[%02d] = %s\n", cn, comment); - if ((strncasecmp ("TITLE=", comment, 6) == 0) + if ((strncasecmp ("TITLE=", comment, 6) == 0) && (length - 6 > 0)) { _x_meta_info_set_utf8 (flac->stream, XINE_META_INFO_TITLE, comment + 6); } else if ((strncasecmp ("ARTIST=", comment, 7) == 0) @@ -397,7 +397,7 @@ static int demux_flac_seek (demux_plugin_t *this_gen, int seekpoint_index = 0; int64_t start_pts; unsigned char buf[4]; - + start_pos = (off_t) ( (double) start_pos / 65535 * this->data_size ); @@ -458,9 +458,9 @@ static int demux_flac_seek (demux_plugin_t *this_gen, } _x_demux_flush_engine(this->stream); - this->input->seek(this->input, this->seekpoints[seekpoint_index].offset, + this->input->seek(this->input, this->seekpoints[seekpoint_index].offset, SEEK_SET); - _x_demux_control_newpts(this->stream, + _x_demux_control_newpts(this->stream, this->seekpoints[seekpoint_index].pts, BUF_FLAG_SEEK); } diff --git a/src/demuxers/demux_fli.c b/src/demuxers/demux_fli.c index 12ae81609..7735671b9 100644 --- a/src/demuxers/demux_fli.c +++ b/src/demuxers/demux_fli.c @@ -112,7 +112,7 @@ static int open_fli_file(demux_fli_t *this) { this->speed = _X_LE_32(&this->fli_header[16]); if (this->magic_number == FLI_FILE_MAGIC_1) { - /* + /* * in this case, the speed (n) is number of 1/70s ticks between frames: * * xine pts n * frame # @@ -123,7 +123,7 @@ static int open_fli_file(demux_fli_t *this) { */ this->frame_pts_inc = this->speed * 1285.7; } else if (this->magic_number == FLI_FILE_MAGIC_2) { - /* + /* * in this case, the speed (n) is number of milliseconds between frames: * * xine pts n * frame # diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c index d3da20136..813f33086 100644 --- a/src/demuxers/demux_flv.c +++ b/src/demuxers/demux_flv.c @@ -20,7 +20,7 @@ /* * Flash Video (.flv) File Demuxer - * by Mike Melanson (melanson@pcisys.net) and + * by Mike Melanson (melanson@pcisys.net) and * Claudio Ciccani (klan@users.sf.net) * * For more information on the FLV file format, visit: @@ -67,28 +67,28 @@ typedef struct { unsigned char flags; off_t start; /* in bytes */ off_t size; /* in bytes */ - + unsigned char got_video_header; unsigned char got_audio_header; - + unsigned int length; /* in ms */ int width; int height; int duration; int videocodec; - + int samplerate; int samplesize; int stereo; int audiocodec; - + off_t filesize; - + flv_index_entry_t *index; unsigned int num_indices; - + unsigned int cur_pts; - + int64_t last_pts[2]; int send_newpts; int buf_flag_seek; @@ -178,7 +178,7 @@ static int open_flv_file(demux_flv_t *this) { if ((buffer[0] != 'F') || (buffer[1] != 'L') || (buffer[2] != 'V')) return 0; - + if (buffer[3] != 0x01) { xprintf(this->xine, XINE_VERBOSITY_LOG, _("unsupported FLV version (%d).\n"), buffer[3]); @@ -194,10 +194,10 @@ static int open_flv_file(demux_flv_t *this) { this->start = _X_BE_32(&buffer[5]); this->size = this->input->get_length(this->input); - + this->input->seek(this->input, this->start, SEEK_SET); - - lprintf(" qualified FLV file, repositioned @ offset 0x%" PRIxMAX "\n", + + lprintf(" qualified FLV file, repositioned @ offset 0x%" PRIxMAX "\n", (intmax_t)this->start); return 1; @@ -209,19 +209,19 @@ static int open_flv_file(demux_flv_t *this) { _tmp.d;\ })\ -static int parse_flv_var(demux_flv_t *this, +static int parse_flv_var(demux_flv_t *this, unsigned char *buf, int size, char *key, int keylen) { unsigned char *tmp = buf; unsigned char *end = buf + size; char *str; unsigned char type; unsigned int len, num; - + if (size < 1) return 0; - + type = *tmp++; - + switch (type) { case FLV_DATA_TYPE_NUMBER: lprintf(" got number (%f)\n", BE_F64(tmp)); @@ -366,7 +366,7 @@ static int parse_flv_var(demux_flv_t *this, lprintf(" got type %d\n", type); break; } - + return (tmp - buf); } @@ -375,7 +375,7 @@ static void parse_flv_script(demux_flv_t *this, int size) { unsigned char *tmp = buf; unsigned char *end = buf + size; int len; - + if (!buf || this->input->read(this->input, buf, size ) != size) { this->status = DEMUX_FINISHED; free(buf); @@ -388,7 +388,7 @@ static void parse_flv_script(demux_flv_t *this, int size) { break; tmp += len; } - + free(buf); } @@ -401,7 +401,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { unsigned int buf_type = 0; unsigned int buf_flags = 0; unsigned int pts; - + while (1) { lprintf (" reading FLV tag...\n"); this->input->seek(this->input, 4, SEEK_CUR); @@ -413,7 +413,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { tag_type = buffer[0]; remaining_bytes = _X_BE_24(&buffer[1]); pts = _X_BE_24(&buffer[4]) | (buffer[7] << 24); - + lprintf(" tag_type = 0x%02X, 0x%X bytes, pts %u\n", tag_type, remaining_bytes, pts/90); @@ -422,10 +422,10 @@ static int read_flv_packet(demux_flv_t *this, int preview) { lprintf(" got audio tag..\n"); if (this->input->read(this->input, buffer, 1) != 1) { this->status = DEMUX_FINISHED; - return this->status; + return this->status; } remaining_bytes--; - + this->audiocodec = buffer[0] >> 4; /* override */ switch (this->audiocodec) { case FLV_SOUND_FORMAT_PCM_BE: @@ -458,7 +458,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { buf_type = BUF_AUDIO_UNKNOWN; break; } - + fifo = this->audio_fifo; if (preview && !this->got_audio_header) { /* send init info to audio decoder */ @@ -474,7 +474,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { this->got_audio_header = 1; } break; - + case FLV_TAG_TYPE_VIDEO: lprintf(" got video tag..\n"); if (this->input->read(this->input, buffer, 1) != 1) { @@ -482,7 +482,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { return this->status; } remaining_bytes--; - + switch ((buffer[0] >> 4)) { case 0x01: buf_flags = BUF_FLAG_KEYFRAME; @@ -494,7 +494,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { default: break; } - + this->videocodec = buffer[0] & 0x0F; /* override */ switch (this->videocodec) { case FLV_VIDEO_FORMAT_FLV1: @@ -523,12 +523,12 @@ static int read_flv_packet(demux_flv_t *this, int preview) { buf_type = BUF_VIDEO_UNKNOWN; break; } - + fifo = this->video_fifo; if (preview && !this->got_video_header) { xine_bmiheader *bih; /* send init info to video decoder; send the bitmapinfo header to the decoder - * primarily as a formality since there is no real data inside */ + * primarily as a formality since there is no real data inside */ buf = fifo->buffer_pool_alloc(fifo); buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER | BUF_FLAG_FRAMERATE | BUF_FLAG_FRAME_END; @@ -566,7 +566,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { this->got_video_header = 1; } break; - + case FLV_TAG_TYPE_SCRIPT: lprintf(" got script tag...\n"); if (preview) { @@ -612,7 +612,7 @@ static int read_flv_packet(demux_flv_t *this, int preview) { this->got_audio_header = 1; lprintf(" got audio header from metadata...\n"); } - + if (!this->got_video_header && this->videocodec && this->videocodec != FLV_VIDEO_FORMAT_H264) { xine_bmiheader *bih; buf = this->video_fifo->buffer_pool_alloc(this->video_fifo); @@ -647,34 +647,34 @@ static int read_flv_packet(demux_flv_t *this, int preview) { this->got_video_header = 1; lprintf(" got video header from metadata...\n"); } - + return this->status; } /* no preview */ - this->input->seek(this->input, remaining_bytes, SEEK_CUR); + this->input->seek(this->input, remaining_bytes, SEEK_CUR); continue; - + default: lprintf(" skipping packet...\n"); this->input->seek(this->input, remaining_bytes, SEEK_CUR); continue; } - + while (remaining_bytes) { buf = fifo->buffer_pool_alloc(fifo); buf->type = buf_type; - + buf->extra_info->input_time = pts; if (this->input->get_length(this->input)) { - buf->extra_info->input_normpos = + buf->extra_info->input_normpos = (int)((double)this->input->get_current_pos(this->input) * 65535.0 / this->size); } - + if ((buf_type == BUF_VIDEO_H264 || buf_type == BUF_AUDIO_AAC) && buffer[0] == 0) { /* AVC/AAC sequence header */ buf->pts = 0; buf->size = 0; - + buf->decoder_flags = BUF_FLAG_SPECIAL | BUF_FLAG_HEADER; if (preview) buf->decoder_flags |= BUF_FLAG_PREVIEW; @@ -682,13 +682,13 @@ static int read_flv_packet(demux_flv_t *this, int preview) { buf->decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG; buf->decoder_info[2] = MIN(remaining_bytes, buf->max_size); buf->decoder_info_ptr[2] = buf->mem; - + if (this->input->read(this->input, buf->mem, buf->decoder_info[2]) != buf->decoder_info[2]) { buf->free_buffer(buf); this->status = DEMUX_FINISHED; break; } - + if (remaining_bytes > buf->max_size) { xprintf(this->xine, XINE_VERBOSITY_LOG, _("sequence header too big (%u bytes)!\n"), remaining_bytes); @@ -722,11 +722,11 @@ static int read_flv_packet(demux_flv_t *this, int preview) { fifo->put(fifo, buf); } - + this->cur_pts = pts; break; } - + return this->status; } @@ -737,32 +737,32 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { int next_tag = 0; int do_rewind = (seek_pts < this->cur_pts); int i; - - lprintf(" seeking %s to %d...\n", + + lprintf(" seeking %s to %d...\n", do_rewind ? "backward" : "forward", seek_pts); - + if (seek_pos == 0 && seek_pts == 0) { this->input->seek(this->input, this->start, SEEK_SET); this->cur_pts = 0; return; } - + if (this->index) { if (do_rewind) { for (i = this->num_indices-1; i > 0; i--) { if (this->index[i-1].pts < seek_pts) break; } - } + } else { for (i = 0; i < (this->num_indices-1); i++) { if (this->index[i+1].pts > seek_pts) break; } } - + if (this->index[i].offset >= this->start+4) { - lprintf(" seeking to index entry %d (pts:%u, offset:%u).\n", + lprintf(" seeking to index entry %d (pts:%u, offset:%u).\n", i, this->index[i].pts, this->index[i].offset); this->input->seek(this->input, this->index[i].offset-4, SEEK_SET); @@ -771,16 +771,16 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { } else if (seek_pos && this->videocodec && abs(seek_pts-this->cur_pts) > 300000) { off_t pos, size; - + pos = this->input->get_current_pos(this->input); size = this->filesize ? : this->input->get_length(this->input); this->input->seek(this->input, (uint64_t)size * seek_pos / 65535, SEEK_SET); lprintf(" resyncing...\n"); - + /* resync */ for (i = 0; i < 200000; i++) { uint8_t buf[4]; - + if (this->input->read(this->input, buf, 1) < 1) { this->status = DEMUX_FINISHED; return; @@ -801,30 +801,30 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { this->input->seek(this->input, -11, SEEK_CUR); } } - + lprintf(" ...resync failed!\n"); this->input->seek(this->input, pos, SEEK_SET); - } - else if (seek_pts) { + } + else if (seek_pts) { while (do_rewind ? (seek_pts < this->cur_pts) : (seek_pts > this->cur_pts)) { unsigned char tag_type; int data_size; int ptag_size; - + if (next_tag) this->input->seek(this->input, next_tag, SEEK_CUR); - + len = this->input->read(this->input, buffer, 16); if (len != 16) { len = (len < 0) ? 0 : len; break; } - + ptag_size = _X_BE_32(&buffer[0]); tag_type = buffer[4]; data_size = _X_BE_24(&buffer[5]); pts = _X_BE_24(&buffer[8]) | (buffer[11] << 24); - + if (do_rewind) { if (!ptag_size) break; /* beginning of movie */ @@ -833,7 +833,7 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { else { next_tag = data_size - 1; } - + if (this->flags & FLV_FLAG_HAS_VIDEO) { /* sync to video key frame */ if (tag_type != FLV_TAG_TYPE_VIDEO || (buffer[15] >> 4) != 0x01) @@ -842,10 +842,10 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { } this->cur_pts = pts; } - + /* seek back to the beginning of the tag */ this->input->seek(this->input, -len, SEEK_CUR); - + lprintf( " seeked to %d.\n", pts); } } @@ -853,7 +853,7 @@ static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) { static int demux_flv_send_chunk(demux_plugin_t *this_gen) { demux_flv_t *this = (demux_flv_t *) this_gen; - + return read_flv_packet(this, 0); } @@ -865,11 +865,11 @@ static void demux_flv_send_headers(demux_plugin_t *this_gen) { this->audio_fifo = this->stream->audio_fifo; this->status = DEMUX_OK; - + this->buf_flag_seek = 1; /* load stream information */ - _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, + _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, (this->flags & FLV_FLAG_HAS_VIDEO) ? 1 : 0); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, (this->flags & FLV_FLAG_HAS_AUDIO) ? 1 : 0); @@ -898,7 +898,7 @@ static int demux_flv_seek (demux_plugin_t *this_gen, if (INPUT_IS_SEEKABLE(this->input)) { if (start_pos && !start_time) { - if (this->length) + if (this->length) start_time = (int64_t) this->length * start_pos / 65535; else if (this->index) start_time = this->index[(int)(start_pos * (this->num_indices-1) / 65535)].pts; @@ -906,13 +906,13 @@ static int demux_flv_seek (demux_plugin_t *this_gen, if (!this->length || start_time < this->length) { seek_flv_file(this, start_pos, start_time); - + if (playing) { this->buf_flag_seek = 1; _x_demux_flush_engine(this->stream); } } - } + } return this->status; } diff --git a/src/demuxers/demux_idcin.c b/src/demuxers/demux_idcin.c index d44f03ab3..46d4c284b 100644 --- a/src/demuxers/demux_idcin.c +++ b/src/demuxers/demux_idcin.c @@ -328,7 +328,7 @@ static int open_idcin_file(demux_idcin_t *this) { this->input->seek(this->input, IDCIN_HEADER_SIZE, SEEK_SET); /* read the Huffman table */ - if (this->input->read(this->input, huffman_table, HUFFMAN_TABLE_SIZE) != + if (this->input->read(this->input, huffman_table, HUFFMAN_TABLE_SIZE) != HUFFMAN_TABLE_SIZE) return 0; @@ -347,7 +347,7 @@ static int open_idcin_file(demux_idcin_t *this) { _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS, this->wave.wBitsPerSample); - this->filesize = this->input->get_length(this->input) - + this->filesize = this->input->get_length(this->input) - IDCIN_HEADER_SIZE - HUFFMAN_TABLE_SIZE; return 1; @@ -433,7 +433,7 @@ static int demux_idcin_seek (demux_plugin_t *this_gen, off_t start_pos, int star this->status = DEMUX_OK; /* reposition stream past the Huffman tables */ - this->input->seek(this->input, IDCIN_HEADER_SIZE + HUFFMAN_TABLE_SIZE, + this->input->seek(this->input, IDCIN_HEADER_SIZE + HUFFMAN_TABLE_SIZE, SEEK_SET); this->pts_counter = 0; diff --git a/src/demuxers/demux_image.c b/src/demuxers/demux_image.c index feaf3ceaa..08136edba 100644 --- a/src/demuxers/demux_image.c +++ b/src/demuxers/demux_image.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2003-2005 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -82,7 +82,7 @@ static int demux_image_next (demux_plugin_t *this_gen, int preview) { } else { this->status = DEMUX_OK; } - + if (preview) buf->decoder_flags = BUF_FLAG_PREVIEW; @@ -211,7 +211,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this->demux_plugin.get_capabilities = demux_image_get_capabilities; this->demux_plugin.get_optional_data = demux_image_get_optional_data; this->demux_plugin.demux_class = class_gen; - + this->status = DEMUX_FINISHED; this->buf_type = buf_type; @@ -226,7 +226,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, static const char *get_description (demux_class_t *this_gen) { return "image demux plugin"; } - + static const char *get_identifier (demux_class_t *this_gen) { return "imagedmx"; } diff --git a/src/demuxers/demux_ipmovie.c b/src/demuxers/demux_ipmovie.c index 4ef877988..5b4e12ef8 100644 --- a/src/demuxers/demux_ipmovie.c +++ b/src/demuxers/demux_ipmovie.c @@ -183,7 +183,7 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) { while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) { /* read the next chunk, wherever the file happens to be pointing */ - if (this->input->read(this->input, opcode_preamble, + if (this->input->read(this->input, opcode_preamble, OPCODE_PREAMBLE_SIZE) != OPCODE_PREAMBLE_SIZE) { chunk_type = CHUNK_BAD; break; @@ -221,7 +221,7 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) { chunk_type = CHUNK_BAD; break; } - if (this->input->read(this->input, scratch, opcode_size) != + if (this->input->read(this->input, scratch, opcode_size) != opcode_size) { chunk_type = CHUNK_BAD; break; @@ -239,7 +239,7 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) { chunk_type = CHUNK_BAD; break; } - if (this->input->read(this->input, scratch, opcode_size) != + if (this->input->read(this->input, scratch, opcode_size) != opcode_size) { chunk_type = CHUNK_BAD; break; @@ -275,7 +275,7 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) { chunk_type = CHUNK_BAD; break; } - if (this->input->read(this->input, scratch, opcode_size) != + if (this->input->read(this->input, scratch, opcode_size) != opcode_size) { chunk_type = CHUNK_BAD; break; @@ -336,23 +336,23 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) { buf->extra_info->input_normpos = (int)( (double) current_file_pos * 65535 / this->data_size); buf->extra_info->input_time = audio_pts / 90; buf->pts = audio_pts; - + if (opcode_size > buf->max_size) buf->size = buf->max_size; else buf->size = opcode_size; opcode_size -= buf->size; - + if (this->input->read(this->input, buf->content, buf->size) != buf->size) { buf->free_buffer(buf); chunk_type = CHUNK_BAD; break; } - + if (!opcode_size) buf->decoder_flags |= BUF_FLAG_FRAME_END; - + this->audio_fifo->put (this->audio_fifo, buf); } }else{ @@ -377,7 +377,7 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) { case OPCODE_SET_PALETTE: lprintf("set palette\n"); - /* check for the logical maximum palette size + /* check for the logical maximum palette size * (3 * 256 + 4 bytes) */ if (opcode_size > 0x304) { lprintf("set_palette opcode too large\n"); diff --git a/src/demuxers/demux_matroska-chapters.c b/src/demuxers/demux_matroska-chapters.c index aad8fe46d..4bfafe0da 100644 --- a/src/demuxers/demux_matroska-chapters.c +++ b/src/demuxers/demux_matroska-chapters.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2009 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index 9d224c62c..94f47db44 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -59,7 +59,7 @@ static void check_newpts (demux_matroska_t *this, int64_t pts, if ((track->track_type == MATROSKA_TRACK_VIDEO) || (track->track_type == MATROSKA_TRACK_AUDIO)) { - + diff = pts - track->last_pts; if (pts && (this->send_newpts || (track->last_pts && abs(diff)>WRAP_THRESHOLD)) ) { @@ -410,9 +410,9 @@ static int parse_content_encodings (demux_matroska_t *this, matroska_track_t *tr static void init_codec_video(demux_matroska_t *this, matroska_track_t *track) { buf_element_t *buf; - + buf = track->fifo->buffer_pool_alloc (track->fifo); - + if (track->codec_private_len > buf->max_size) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "demux_matroska: private decoder data length (%d) is greater than fifo buffer length (%" PRId32 ")\n", @@ -429,20 +429,20 @@ static void init_codec_video(demux_matroska_t *this, matroska_track_t *track) { xine_fast_memcpy (buf->content, track->codec_private, buf->size); else buf->content = NULL; - + if(track->default_duration) { buf->decoder_flags |= BUF_FLAG_FRAMERATE; - buf->decoder_info[0] = (int64_t)track->default_duration * + buf->decoder_info[0] = (int64_t)track->default_duration * (int64_t)90 / (int64_t)1000000; } - - if(track->video_track && track->video_track->display_width && + + if(track->video_track && track->video_track->display_width && track->video_track->display_height) { buf->decoder_flags |= BUF_FLAG_ASPECT; buf->decoder_info[1] = track->video_track->display_width; buf->decoder_info[2] = track->video_track->display_height; } - + track->fifo->put (track->fifo, buf); } @@ -460,7 +460,7 @@ static void init_codec_audio(demux_matroska_t *this, matroska_track_t *track) { return; } buf->size = track->codec_private_len; - + /* default param */ buf->decoder_info[0] = 0; buf->decoder_info[1] = 44100; @@ -492,9 +492,9 @@ static void init_codec_audio(demux_matroska_t *this, matroska_track_t *track) { static void init_codec_real(demux_matroska_t *this, matroska_track_t * track) { buf_element_t *buf; - + buf = track->fifo->buffer_pool_alloc (track->fifo); - + if (track->codec_private_len > buf->max_size) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "demux_matroska: private decoder data length (%d) is greater than fifo buffer length (%" PRId32 ")\n", @@ -502,30 +502,30 @@ static void init_codec_real(demux_matroska_t *this, matroska_track_t * track) { buf->free_buffer(buf); return; } - + buf->size = track->codec_private_len; buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_FRAME_END; buf->type = track->buf_type; buf->pts = 0; - + if (buf->size) xine_fast_memcpy (buf->content, track->codec_private, buf->size); else buf->content = NULL; - + if(track->default_duration) { buf->decoder_flags |= BUF_FLAG_FRAMERATE; - buf->decoder_info[0] = (int64_t)track->default_duration * + buf->decoder_info[0] = (int64_t)track->default_duration * (int64_t)90 / (int64_t)1000000; } - - if(track->video_track && track->video_track->display_width && + + if(track->video_track && track->video_track->display_width && track->video_track->display_height) { buf->decoder_flags |= BUF_FLAG_ASPECT; buf->decoder_info[1] = track->video_track->display_width; buf->decoder_info[2] = track->video_track->display_height; } - + track->fifo->put (track->fifo, buf); } @@ -551,7 +551,7 @@ static void init_codec_xiph(demux_matroska_t *this, matroska_track_t *track) { data = track->codec_private + 3; for (i = 0; i < 3; i++) { buf = track->fifo->buffer_pool_alloc (track->fifo); - + if (frame[i] > buf->max_size) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "demux_matroska: private decoder data length (%d) is greater than fifo buffer length (%" PRId32 ")\n", @@ -560,7 +560,7 @@ static void init_codec_xiph(demux_matroska_t *this, matroska_track_t *track) { return; } buf->size = frame[i]; - + buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_FRAME_START | BUF_FLAG_FRAME_END; buf->type = track->buf_type; buf->pts = 0; @@ -849,7 +849,7 @@ static void handle_realvideo (demux_plugin_t *this_gen, matroska_track_t *track, buf->decoder_info[1] = BUF_SPECIAL_RV_CHUNK_TABLE; buf->decoder_info[2] = chunks; buf->decoder_info_ptr[2] = buf->content; - + buf->size = 0; buf->type = track->buf_type; @@ -916,7 +916,7 @@ static void handle_sub_ssa (demux_plugin_t *this_gen, matroska_track_t *track, } } } - + last_char = *data; data++; data_len--; } @@ -927,11 +927,11 @@ static void handle_sub_ssa (demux_plugin_t *this_gen, matroska_track_t *track, buf->size = dest - (char *)buf->content; buf->extra_info->input_normpos = input_normpos; buf->extra_info->input_time = input_time; - + track->fifo->put(track->fifo, buf); } else { buf->free_buffer(buf); - } + } } static void handle_sub_utf8 (demux_plugin_t *this_gen, matroska_track_t *track, @@ -946,7 +946,7 @@ static void handle_sub_utf8 (demux_plugin_t *this_gen, matroska_track_t *track, buf = track->fifo->buffer_pool_alloc(track->fifo); buf->size = data_len + 9; /* 2 uint32_t + '\0' */ - + if (buf->max_size >= buf->size) { buf->decoder_flags = decoder_flags; @@ -955,7 +955,7 @@ static void handle_sub_utf8 (demux_plugin_t *this_gen, matroska_track_t *track, buf->decoder_info[1] = BUF_SPECIAL_CHARSET_ENCODING; buf->decoder_info_ptr[2] = "utf-8"; buf->decoder_info[2] = strlen(buf->decoder_info_ptr[2]); - + val = (uint32_t *)buf->content; *val++ = data_pts / 90; /* start time */ *val++ = (data_pts + data_duration) / 90; /* end time */ @@ -1020,7 +1020,7 @@ static void handle_vobsub (demux_plugin_t *this_gen, matroska_track_t *track, (int)track->track_num, result); free(dest); inflateEnd(&zstream); - + if (result == Z_DATA_ERROR && track->compress_algo == MATROSKA_COMPRESS_UNKNOWN) { track->compress_algo = MATROSKA_COMPRESS_NONE; data_len = old_data_len; @@ -1033,11 +1033,11 @@ static void handle_vobsub (demux_plugin_t *this_gen, matroska_track_t *track, zstream.avail_out += 4000; } while ((zstream.avail_out == 4000) && (zstream.avail_in != 0) && (result != Z_STREAM_END)); - + if (track->compress_algo != MATROSKA_COMPRESS_NONE) { data_len = zstream.total_out; inflateEnd(&zstream); - + data = dest; track->compress_algo = MATROSKA_COMPRESS_ZLIB; lprintf("VobSub: decompression for track %d from %d to %d\n", @@ -1098,7 +1098,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { } break; - case MATROSKA_ID_TR_TYPE: + case MATROSKA_ID_TR_TYPE: { uint64_t num; lprintf("TrackType\n"); @@ -1200,7 +1200,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { } break; - case MATROSKA_ID_TR_UID: + case MATROSKA_ID_TR_UID: { uint64_t val; @@ -1470,10 +1470,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { static int parse_tracks(demux_matroska_t *this) { ebml_parser_t *ebml = this->ebml; int next_level = 2; - + while (next_level == 2) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -1515,10 +1515,10 @@ static int parse_cue_trackposition(demux_matroska_t *this, int *track_num, int64_t *pos) { ebml_parser_t *ebml = this->ebml; int next_level = 4; - + while (next_level == 4) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -1555,10 +1555,10 @@ static int parse_cue_point(demux_matroska_t *this) { int next_level = 3; int64_t timecode = -1, pos = -1; int track_num = -1; - + while (next_level == 3) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -1623,10 +1623,10 @@ static int parse_cue_point(demux_matroska_t *this) { static int parse_cues(demux_matroska_t *this) { ebml_parser_t *ebml = this->ebml; int next_level = 2; - + while (next_level == 2) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -1652,10 +1652,10 @@ static int parse_cues(demux_matroska_t *this) { static int parse_attachments(demux_matroska_t *this) { ebml_parser_t *ebml = this->ebml; int next_level = 2; - + while (next_level == 2) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -1674,10 +1674,10 @@ static int parse_attachments(demux_matroska_t *this) { static int parse_tags(demux_matroska_t *this) { ebml_parser_t *ebml = this->ebml; int next_level = 2; - + while (next_level == 2) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -1716,7 +1716,7 @@ static int parse_ebml_uint(demux_matroska_t *this, uint8_t *data, uint64_t *num) } if (size > 8) { off_t pos = this->input->get_current_pos(this->input); - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "demux_matroska: Invalid Track Number at position %" PRIdMAX "\n", (intmax_t)pos); return 0; @@ -1745,7 +1745,7 @@ static int parse_ebml_sint(demux_matroska_t *this, uint8_t *data, int64_t *num) *num = -1; else *num = unum - ((1 << ((7 * size) - 1)) - 1); - + return size; } @@ -1815,7 +1815,7 @@ static int parse_block (demux_matroska_t *this, size_t block_size, flags = *data; data += 1; - + lprintf("track_num: %" PRIu64 ", timecode_diff: %d, flags: 0x%x\n", track_num, timecode_diff, flags); gap = flags & 1; @@ -1922,7 +1922,7 @@ static int parse_block (demux_matroska_t *this, size_t block_size, int frame_size; lprintf("fixed size lacing\n"); - + frame_size = block_size_left / (lace_num + 1); for (i = 0; i < lace_num; i++) { frame[i] = frame_size; @@ -2024,10 +2024,10 @@ static int parse_simpleblock(demux_matroska_t *this, size_t block_len, uint64_t file_len = this->input->get_length(this->input); if( file_len ) normpos = (int) ( (double) block_pos * 65535 / file_len ); - + if (!read_block_data(this, block_len)) return 0; - + has_block = 1; /* we have the duration, we can parse the block now */ if (!parse_block(this, block_len, cluster_timecode, block_duration, @@ -2258,10 +2258,10 @@ static int parse_seek_entry(demux_matroska_t *this) { int has_position = 0; uint64_t id = 0; uint64_t pos; - + while (next_level == 3) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -2285,26 +2285,26 @@ static int parse_seek_entry(demux_matroska_t *this) { } next_level = ebml_get_next_level(ebml, &elem); } - + /* do not parse clusters */ if (id == MATROSKA_ID_CLUSTER) { lprintf("skip cluster\n"); return 1; } - - /* parse the referenced element */ + + /* parse the referenced element */ if (has_id && has_position) { off_t current_pos, seek_pos; - + seek_pos = this->segment.start + pos; - + if ((seek_pos > 0) && (seek_pos < this->input->get_length(this->input))) { ebml_parser_t ebml_bak; /* backup current state */ current_pos = this->input->get_current_pos(this->input); memcpy(&ebml_bak, this->ebml, sizeof(ebml_parser_t)); /* FIXME */ - + /* seek and parse the top_level element */ this->ebml->level = 1; if (this->input->seek(this->input, seek_pos, SEEK_SET) < 0) { @@ -2343,7 +2343,7 @@ static int parse_seekhead(demux_matroska_t *this) { while (next_level == 2) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -2381,18 +2381,18 @@ static int parse_top_level_head(demux_matroska_t *this, int *next_level) { int ret_value = 1; off_t current_pos; - + current_pos = this->input->get_current_pos(this->input); lprintf("current_pos: %" PRIdMAX "\n", (intmax_t)current_pos); - + if (!ebml_read_elem_head(ebml, &elem)) return 0; - + if (!find_top_level_entry(this, current_pos)) { if (!add_top_level_entry(this, current_pos)) return 0; - + switch (elem.id) { case MATROSKA_ID_SEEKHEAD: lprintf("SeekHead\n"); @@ -2459,7 +2459,7 @@ static int parse_top_level_head(demux_matroska_t *this, int *next_level) { if (!ebml_skip(ebml, &elem)) return 0; } - + if (next_level) *next_level = ebml_get_next_level(ebml, &elem); @@ -2546,12 +2546,12 @@ static int parse_segment(demux_matroska_t *this) { if (this->segment.id == MATROSKA_ID_SEGMENT) { int res; int next_level; - + lprintf("Segment detected\n"); if (!ebml_read_master (ebml, &this->segment)) return 0; - + res = 1; next_level = 1; /* stop the loop on the first cluster */ @@ -2603,14 +2603,14 @@ static void demux_matroska_send_headers (demux_plugin_t *this_gen) { _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, (this->num_video_tracks != 0)); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, (this->num_audio_tracks != 0)); - + /* * send preview buffers */ /* enter in the segment */ ebml_read_master (this->ebml, &this->segment); - + /* seek back to the beginning of the segment */ next_level = 1; if (this->input->seek(this->input, this->segment.start, SEEK_SET) < 0) { @@ -2620,7 +2620,7 @@ static void demux_matroska_send_headers (demux_plugin_t *this_gen) { this->status = DEMUX_FINISHED; return; } - + this->preview_sent = 0; this->preview_mode = 1; @@ -2706,7 +2706,7 @@ static int demux_matroska_seek (demux_plugin_t *this_gen, matroska_index_t *index; matroska_track_t *track; int i, entry; - + start_pos = (off_t) ( (double) start_pos / 65535 * this->input->get_length (this->input) ); @@ -2762,10 +2762,10 @@ static int demux_matroska_seek (demux_plugin_t *this_gen, index->track_num, start_pos ? "pos" : "time", start_pos ? (intmax_t)start_pos : (intmax_t)start_time, index->track_num, index->timecode[entry], (intmax_t)index->pos[entry]); - + if (this->input->seek(this->input, index->pos[entry], SEEK_SET) < 0) this->status = DEMUX_FINISHED; - + /* we always seek to the ebml level 1 */ this->ebml->level = 1; @@ -2779,7 +2779,7 @@ static int demux_matroska_seek (demux_plugin_t *this_gen, static void demux_matroska_dispose (demux_plugin_t *this_gen) { - + demux_matroska_t *this = (demux_matroska_t *) this_gen; int i; @@ -2861,7 +2861,7 @@ static int demux_matroska_get_optional_data (demux_plugin_t *this_gen, if ((channel >= 0) && (channel < this->num_sub_tracks)) { for (track_num = 0; track_num < this->num_tracks; track_num++) { matroska_track_t *track = this->tracks[track_num]; - + if ((track->buf_type & 0xFF00001F) == (BUF_SPU_BASE + channel)) { if (track->language) { strncpy (str, track->language, XINE_LANG_MAX); @@ -2877,13 +2877,13 @@ static int demux_matroska_get_optional_data (demux_plugin_t *this_gen, } } return DEMUX_OPTIONAL_UNSUPPORTED; - + case DEMUX_OPTIONAL_DATA_AUDIOLANG: lprintf ("DEMUX_OPTIONAL_DATA_AUDIOLANG channel = %d\n",channel); if ((channel >= 0) && (channel < this->num_audio_tracks)) { for (track_num = 0; track_num < this->num_tracks; track_num++) { matroska_track_t *track = this->tracks[track_num]; - + if ((track->buf_type & 0xFF00001F) == (BUF_AUDIO_BASE + channel)) { if (track->language) { strncpy (str, track->language, XINE_LANG_MAX); diff --git a/src/demuxers/demux_matroska.h b/src/demuxers/demux_matroska.h index a62aba498..e1611f397 100644 --- a/src/demuxers/demux_matroska.h +++ b/src/demuxers/demux_matroska.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -55,7 +55,7 @@ typedef struct { off_t *pos; uint64_t *timecode; int num_entries; - + } matroska_index_t; typedef struct { @@ -110,10 +110,10 @@ typedef struct { matroska_track_t *audio_track; /* to remove */ matroska_track_t *sub_track; /* to remove */ uint64_t last_timecode; - + int send_newpts; int buf_flag_seek; - + /* seekhead parsing */ int top_level_list_size; int top_level_list_max_size; diff --git a/src/demuxers/demux_mng.c b/src/demuxers/demux_mng.c index d0d83ff80..2fccd0b9e 100644 --- a/src/demuxers/demux_mng.c +++ b/src/demuxers/demux_mng.c @@ -181,7 +181,7 @@ static int demux_mng_send_chunk(demux_mng_t *this){ buf->decoder_flags = BUF_FLAG_FRAMERATE; buf->decoder_info[0] = 90 * this->timer_count; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->extra_info->input_time = this->tick_count; buf->pts = 90 * this->tick_count; diff --git a/src/demuxers/demux_mod.c b/src/demuxers/demux_mod.c index de3e29ca8..0439be7ee 100644 --- a/src/demuxers/demux_mod.c +++ b/src/demuxers/demux_mod.c @@ -74,16 +74,16 @@ typedef struct { char *artist; char *copyright; size_t filesize; - + char *buffer; int64_t current_pts; - + ModPlug_Settings settings; ModPlugFile *mpfile; int mod_length; int seek_flag; /* this is set when a seek just occurred */ - + } demux_mod_t; typedef struct { @@ -131,7 +131,7 @@ static int probe_mod_file(demux_mod_t *this) { static int open_mod_file(demux_mod_t *this) { int total_read; off_t input_length; - + /* Get size and create buffer */ input_length = this->input->get_length(this->input); /* Avoid potential issues with signed variables and e.g. read() returning -1 */ @@ -139,7 +139,7 @@ static int open_mod_file(demux_mod_t *this) { xine_log(this->stream->xine, XINE_LOG_PLUGIN, "modplug - size overflow\n"); return 0; } - this->filesize = input_length; + this->filesize = input_length; this->buffer = (char *)malloc(this->filesize); if(!this->buffer) { xine_log(this->stream->xine, XINE_LOG_PLUGIN, "modplug - allocation failure\n"); @@ -148,23 +148,23 @@ static int open_mod_file(demux_mod_t *this) { /* Seek to beginning */ this->input->seek(this->input, 0, SEEK_SET); - + /* Read data */ total_read = this->input->read(this->input, this->buffer, this->filesize); - + if(total_read != this->filesize) { xine_log(this->stream->xine, XINE_LOG_PLUGIN, "modplug - filesize error\n"); free(this->buffer); return 0; } - + this->mpfile = ModPlug_Load(this->buffer, this->filesize); if (this->mpfile==NULL) { xine_log(this->stream->xine, XINE_LOG_PLUGIN, "modplug - load error\n"); free(this->buffer); return 0; } - + /* Set up modplug engine */ ModPlug_GetSettings(&this->settings); this->settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; /* RESAMP */ @@ -172,15 +172,15 @@ static int open_mod_file(demux_mod_t *this) { this->settings.mBits = MOD_BITS; this->settings.mFrequency = MOD_SAMPLERATE; ModPlug_SetSettings(&this->settings); - + this->title = strdup(ModPlug_GetName(this->mpfile)); this->artist = strdup(""); this->copyright = strdup(""); - + this->mod_length = ModPlug_GetLength(this->mpfile); if (this->mod_length < 1) this->mod_length = 1; /* avoids -ve & div-by-0 */ - + return 1; } @@ -201,20 +201,20 @@ static int demux_mod_send_chunk(demux_plugin_t *this_gen) { buf->size = mlen; buf->pts = this->current_pts; buf->extra_info->input_time = buf->pts / 90; - + buf->extra_info->input_normpos = buf->extra_info->input_time * 65535 / this->mod_length; buf->decoder_flags = BUF_FLAG_FRAME_END; - + if (this->seek_flag) { _x_demux_control_newpts(this->stream, buf->pts, BUF_FLAG_SEEK); this->seek_flag = 0; } this->audio_fifo->put (this->audio_fifo, buf); - + this->current_pts += 90000 * mlen / OUT_BYTES_PER_SECOND; } - + return this->status; } @@ -260,9 +260,9 @@ static int demux_mod_seek (demux_plugin_t *this_gen, demux_mod_t *this = (demux_mod_t *) this_gen; int64_t seek_millis; - + if (start_pos) { - seek_millis = this->mod_length; + seek_millis = this->mod_length; seek_millis *= start_pos; seek_millis /= 65535; } else { @@ -272,14 +272,14 @@ static int demux_mod_seek (demux_plugin_t *this_gen, _x_demux_flush_engine(this->stream); ModPlug_Seek(this->mpfile, seek_millis); this->current_pts = seek_millis * 90; - + this->seek_flag = 1; return this->status; } static void demux_mod_dispose (demux_plugin_t *this_gen) { demux_mod_t *this = (demux_mod_t *) this_gen; - + ModPlug_Unload(this->mpfile); free(this->buffer); free(this->title); @@ -335,7 +335,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->status = DEMUX_FINISHED; xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "TEST mod decode\n"); - + switch (stream->content_detection_method) { case METHOD_EXPLICIT: diff --git a/src/demuxers/demux_mpc.c b/src/demuxers/demux_mpc.c index 220e1b8b6..04b25eeb5 100644 --- a/src/demuxers/demux_mpc.c +++ b/src/demuxers/demux_mpc.c @@ -24,7 +24,7 @@ * APE tag reading * Seeking?? */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -66,7 +66,7 @@ typedef struct { unsigned int frames; double samplerate; unsigned int length; - + unsigned int current_frame; unsigned int next_frame_bits; } demux_mpc_t; @@ -82,7 +82,7 @@ typedef struct { static int open_mpc_file(demux_mpc_t *this) { unsigned int first_frame_size; unsigned int id3v2_size = 0; - + /* Read the file header */ if (_x_demux_read_header(this->input, this->header, HEADER_SIZE) != HEADER_SIZE) return 0; @@ -91,39 +91,39 @@ static int open_mpc_file(demux_mpc_t *this) { if (INPUT_IS_SEEKABLE(this->input)) { /* Check for id3v2 tag */ if (id3v2_istag(this->header)) { - + lprintf("found id3v2 header\n"); - + /* Read tag size */ - + id3v2_size = _X_BE_32_synchsafe(&this->header[6]) + 10; - + /* Add footer size if one is present */ if (this->header[5] & 0x10) id3v2_size += 10; - + lprintf("id3v2 size: %u\n", id3v2_size); - + /* Seek past tag */ if (this->input->seek(this->input, id3v2_size, SEEK_SET) < 0) return 0; - + /* Read musepack header */ if (this->input->read(this->input, this->header, HEADER_SIZE) != HEADER_SIZE) return 0; } } - + /* Validate signature - We only support SV 7.x at the moment */ if ( memcmp(this->header, "MP+", 3) != 0 || ((this->header[3]&0x0f) != 0x07)) return 0; - + /* Get frame count */ this->current_frame = 0; this->frames = _X_LE_32(&this->header[4]); lprintf("number of frames: %u\n", this->frames); - + /* Get sample rate */ switch ((_X_LE_32(&this->header[8]) >> 16) & 0x3) { case 0: @@ -142,7 +142,7 @@ static int open_mpc_file(demux_mpc_t *this) { break; } lprintf("samplerate: %f kHz\n", this->samplerate); - + /* Calculate stream length */ this->length = (int) ((double) this->frames * 1152 / this->samplerate); lprintf("stream length: %d ms\n", this->length); @@ -151,14 +151,14 @@ static int open_mpc_file(demux_mpc_t *this) { first_frame_size = (_X_LE_32(&this->header[24]) >> 4) & 0xFFFFF; this->next_frame_bits = first_frame_size - 4; lprintf("first frame size: %u\n", first_frame_size); - + /* Move input to start of data (to nearest multiple of 4) */ this->input->seek(this->input, 28+id3v2_size, SEEK_SET); - + /* Set stream info */ _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, _X_ME_32(this->header)); - + return 1; } @@ -168,30 +168,30 @@ static int demux_mpc_send_chunk(demux_plugin_t *this_gen) { off_t bytes_read; buf_element_t *buf = NULL; - + /* Check if we've finished */ if (this->current_frame++ == this->frames) { lprintf("all frames read\n"); this->status = DEMUX_FINISHED; - return this->status; + return this->status; } lprintf("current frame: %u\n", this->current_frame); - - /* Get a buffer */ + + /* Get a buffer */ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_MPC; buf->pts = 0; buf->extra_info->total_time = this->length; - + /* Set normalised position */ - buf->extra_info->input_normpos = - (int) ((double) this->input->get_current_pos(this->input) * 65535 / + buf->extra_info->input_normpos = + (int) ((double) this->input->get_current_pos(this->input) * 65535 / this->input->get_length(this->input)); - + /* Set time based on there being 1152 audio frames per frame */ - buf->extra_info->input_time = + buf->extra_info->input_time = (int) ((double) this->current_frame * 1152 / this->samplerate); - + /* Calculate the number of bits that need to be read to finish reading * the current frame and read the size of the next frame. This number * has to be rounded up to the nearest 4 bytes on account of the @@ -204,35 +204,35 @@ static int demux_mpc_send_chunk(demux_plugin_t *this_gen) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("demux_mpc: frame too big for buffer")); this->status = DEMUX_FINISHED; - return this->status; + return this->status; } - + /* Read data */ bytes_read = this->input->read(this->input, buf->content, bytes_to_read); if(bytes_read <= 0) { buf->free_buffer(buf); this->status = DEMUX_FINISHED; return this->status; - } else + } else buf->size = bytes_read; - + /* Read the size of the next frame */ if (this->current_frame < this->frames) { - /* The number of bits of the next frame we've read */ + /* The number of bits of the next frame we've read */ extra_bits_read = bits_to_read - (this->next_frame_bits+20); - + if(extra_bits_read <= 12) next_frame_size = (_X_LE_32(&buf->content[bytes_to_read-4]) >> extra_bits_read) & 0xFFFFF; else next_frame_size = ((_X_LE_32(&buf->content[bytes_to_read-8]) << (32-extra_bits_read)) | (_X_LE_32(&buf->content[bytes_to_read-4]) >> extra_bits_read)) & 0xFFFFF; - + lprintf("next frame size: %u\n", next_frame_size); - + /* The number of bits of the next frame still to read */ - this->next_frame_bits = next_frame_size - extra_bits_read; + this->next_frame_bits = next_frame_size - extra_bits_read; } - + /* Each buffer contains at least one frame */ buf->decoder_flags |= BUF_FLAG_FRAME_END; @@ -255,14 +255,14 @@ static void demux_mpc_send_headers(demux_plugin_t *this_gen) { /* Send header to decoder */ if (this->audio_fifo) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - + buf->type = BUF_AUDIO_MPC; buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_FRAME_END; buf->decoder_info[0] = this->input->get_length(this->input); buf->decoder_info[1] = 0; buf->decoder_info[2] = 0; buf->decoder_info[3] = 0; - + /* Copy the header */ buf->size = HEADER_SIZE; memcpy(buf->content, this->header, buf->size); @@ -351,12 +351,12 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str case METHOD_BY_CONTENT: case METHOD_EXPLICIT: - + if (!open_mpc_file(this)) { free (this); return NULL; } - + break; default: diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c index 85b62f48e..dbaae108d 100644 --- a/src/demuxers/demux_mpeg.c +++ b/src/demuxers/demux_mpeg.c @@ -170,7 +170,7 @@ static void find_mdat_atom(input_plugin_t *input, off_t *mdat_offset, } else atom_size -= ATOM_PREAMBLE_SIZE; - + input->seek(input, atom_size, SEEK_CUR); } } @@ -310,13 +310,13 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) buf->type = BUF_SPU_SVCD + spu_id; buf->pts = pts; - /* There is a bug in WinSubMux doesn't redo PACK headers in + /* There is a bug in WinSubMux doesn't redo PACK headers in the private stream 1. This might cause the below to mess up. if( !preview_mode ) check_newpts( this, this->pts, PTS_VIDEO ); */ this->video_fifo->put (this->video_fifo, buf); - lprintf ("SPU SVCD PACK (pts: %"PRId64", spu id: %d) put on FIFO\n", + lprintf ("SPU SVCD PACK (pts: %"PRId64", spu id: %d) put on FIFO\n", buf->pts, spu_id); return; @@ -368,10 +368,10 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) buf->decoder_flags = BUF_FLAG_PREVIEW; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = - (int)( ((int64_t)this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = + (int)( ((int64_t)this->input->get_current_pos (this->input) * 65535) / this->input->get_length (this->input) ); - + if (this->rate) buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) * 1000 / (this->rate * 50)); @@ -405,8 +405,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) buf->decoder_flags |= BUF_FLAG_PREVIEW; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = - (int)( ((int64_t)this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = + (int)( ((int64_t)this->input->get_current_pos (this->input) * 65535) / this->input->get_length (this->input) ); if (this->rate) buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) @@ -449,7 +449,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) this->input->read (this->input, this->dummy_space, header_len); - for (i = len; i > 0; i -= (this->audio_fifo) + for (i = len; i > 0; i -= (this->audio_fifo) ? this->audio_fifo->buffer_pool_buf_size : this->video_fifo->buffer_pool_buf_size) { if(this->audio_fifo) { buf = this->input->read_block (this->input, this->audio_fifo, @@ -469,8 +469,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) buf->decoder_flags = BUF_FLAG_PREVIEW; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = - (int)( ((int64_t)this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = + (int)( ((int64_t)this->input->get_current_pos (this->input) * 65535) / this->input->get_length (this->input) ); if (this->rate) buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) @@ -505,18 +505,18 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) header_len -= 5 ; } - + if ((flags & 0x40) == 0x40) { - + w = read_bytes(this, 1); dts = (int64_t)(w & 0x0e) << 29 ; w = read_bytes(this, 2); dts |= (w & 0xFFFE) << 14; w = read_bytes(this, 2); dts |= (w & 0xFFFE) >> 1; - + header_len -= 5 ; - } + } /* read rest of header */ this->input->read (this->input, this->dummy_space, header_len); @@ -542,8 +542,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) buf->decoder_flags = BUF_FLAG_PREVIEW; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = - (int)( ((int64_t)this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = + (int)( ((int64_t)this->input->get_current_pos (this->input) * 65535) / this->input->get_length (this->input) ); if (this->rate) buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) @@ -554,7 +554,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr) } else { - for (i = len; i > 0; i -= 10000) + for (i = len; i > 0; i -= 10000) this->input->read (this->input, this->dummy_space, (i > 10000) ? 10000 : i); } @@ -622,7 +622,7 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr) pts |= (w & 0xFFFE) << 14; w = read_bytes(this, 2); len -= 2; - + pts |= (w & 0xFFFE) >> 1; w = read_bytes(this, 1); len -= 1; @@ -649,11 +649,11 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr) lprintf("use scr\n"); pts = scr; } - + if ((stream_id & 0xe0) == 0xc0) { int track = stream_id & 0x1f; - for (i = len; i > 0; i -= (this->audio_fifo) + for (i = len; i > 0; i -= (this->audio_fifo) ? this->audio_fifo->buffer_pool_buf_size : this->video_fifo->buffer_pool_buf_size) { if(this->audio_fifo) { buf = this->input->read_block (this->input, this->audio_fifo, @@ -673,8 +673,8 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr) buf->decoder_flags = BUF_FLAG_PREVIEW; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = - (int)( ((int64_t)this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = + (int)( ((int64_t)this->input->get_current_pos (this->input) * 65535) / this->input->get_length (this->input) ); if (this->rate) buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) @@ -708,8 +708,8 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr) buf->decoder_flags = BUF_FLAG_PREVIEW; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = - (int)( ((int64_t)this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = + (int)( ((int64_t)this->input->get_current_pos (this->input) * 65535) / this->input->get_length (this->input) ); if (this->rate) buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) @@ -720,12 +720,12 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr) } else if (stream_id == 0xbd) { - for (i = len; i > 0; i -= 10000) + for (i = len; i > 0; i -= 10000) this->input->read (this->input, this->dummy_space, (i > 10000) ? 10000 : i); } else { - for (i = len; i > 0; i -= 10000) + for (i = len; i > 0; i -= 10000) this->input->read (this->input, this->dummy_space, (i > 10000) ? 10000 : i); } } @@ -978,40 +978,40 @@ static void demux_mpeg_send_headers (demux_plugin_t *this_gen) { demux_mpeg_t *this = (demux_mpeg_t *) this_gen; uint32_t w; int num_buffers = NUM_PREVIEW_BUFFERS; - + this->video_fifo = this->stream->video_fifo; this->audio_fifo = this->stream->audio_fifo; this->rate = 0; /* fixme */ this->last_pts[0] = 0; this->last_pts[1] = 0; - + _x_demux_control_start(this->stream); /* * send preview buffers for stream/meta_info */ - + _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); this->preview_mode = 1; - + this->input->seek (this->input, 4, SEEK_SET); - + this->status = DEMUX_OK ; - + do { w = parse_pack_preview (this, &num_buffers); - + if (w != 0x000001ba) demux_mpeg_resync (this, w); - + num_buffers --; - + } while ( (this->status == DEMUX_OK) && (num_buffers > 0)); - + this->status = DEMUX_OK ; _x_stream_info_set(this->stream, XINE_STREAM_INFO_BITRATE, this->rate * 50 * 8); @@ -1155,7 +1155,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str /* go through the same MPEG detection song and dance */ if (input->read(input, buf, 4) == 4) { - if (!buf[0] && !buf[1] && (buf[2] == 0x01) + if (!buf[0] && !buf[1] && (buf[2] == 0x01) && (buf[3] == 0xba)) /* if so, take it */ break; } @@ -1163,7 +1163,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str free (this); return NULL; } - + /* reset position for next check */ if (input->seek(input, 0, SEEK_SET) != 0) { free (this); @@ -1174,7 +1174,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str fourcc_tag = _X_BE_32(&buf[0]); if (fourcc_tag == RIFF_TAG) { uint8_t large_buf[1024]; - + if (input->read(input, large_buf, 12) != 12) { free(this); return NULL; @@ -1193,7 +1193,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str * MPEG video marker. No, it's not a very efficient approach, but * if execution has reached this special case, this is currently * the best chance for detecting the file automatically. Also, - * be extra lazy and do not bother skipping over the data + * be extra lazy and do not bother skipping over the data * header. */ for (i = 0; i < RIFF_CHECK_KILOBYTES && !ok; i++) { if (input->read(input, large_buf, 1024) != 1024) @@ -1282,7 +1282,7 @@ static const demuxer_info_t demux_info_mpeg = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "mpeg", XINE_VERSION_CODE, &demux_info_mpeg, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index 55eb0ce81..aa5294e8b 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2006 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -20,7 +20,7 @@ * demultiplexer for mpeg 1/2 program streams * used with fixed blocksize devices (like dvd/vcd) */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -44,7 +44,7 @@ #define NUM_PREVIEW_BUFFERS 250 #define DISC_TRESHOLD 90000 -#define WRAP_THRESHOLD 120000 +#define WRAP_THRESHOLD 120000 #define PTS_AUDIO 0 #define PTS_VIDEO 1 @@ -56,14 +56,14 @@ typedef struct demux_mpeg_block_s { demux_plugin_t demux_plugin; - xine_stream_t *stream; + xine_stream_t *stream; fifo_buffer_t *audio_fifo; fifo_buffer_t *video_fifo; input_plugin_t *input; int status; - + int blocksize; int rate; @@ -123,30 +123,30 @@ static int32_t parse_program_stream_pack_header(demux_mpeg_block_t *this, uint8_ /* OK, i think demux_mpeg_block discontinuity handling demands some explanation: - + - The preferred discontinuity handling/detection for DVD is based on NAV packets information. Most of the time it will provide us very accurate and reliable information. - + - Has been shown that sometimes a DVD discontinuity may happen before a new NAV packet arrives (seeking?). To avoid sending wrong PTS to decoders we _used_ to check for SCR discontinuities. Unfortunately some VCDs have very broken SCR values causing false triggering. - + - To fix the above problem (also note that VCDs don't have NAV packets) we fallback to the same PTS-based wrap detection as used in demux_mpeg. The only trick is to not send discontinuity information if NAV packets have already done the job. - + [Miguel 02-05-2002] */ static void check_newpts( demux_mpeg_block_t *this, int64_t pts, int video ) { int64_t diff; - + diff = pts - this->last_pts[video]; - + if( pts && (this->send_newpts || (this->last_pts[video] && abs(diff)>WRAP_THRESHOLD) ) ) { /* check if pts is outside nav pts range. any stream without nav must enter here. */ @@ -164,10 +164,10 @@ static void check_newpts( demux_mpeg_block_t *this, int64_t pts, int video ) } else { lprintf("no wrap detected\n" ); } - + this->last_pts[1-video] = 0; } - + if( pts ) this->last_pts[video] = pts; } @@ -220,9 +220,9 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m buf->decoder_flags = BUF_FLAG_PREVIEW; else buf->decoder_flags = 0; - + if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); while(p < (buf->content + this->blocksize)) { @@ -435,7 +435,7 @@ static int32_t parse_program_stream_pack_header(demux_mpeg_block_t *this, uint8_ return 12; } else { /* mpeg2 */ - + int num_stuffing_bytes; /* system_clock_reference */ @@ -499,7 +499,7 @@ static int32_t parse_private_stream_2(demux_mpeg_block_t *this, uint8_t *p, buf_ * the NAV packet for a much more accurate timing */ if (buf->extra_info->input_time) { int64_t cell_time, frames; - + cell_time = (p[7+0x18] >> 4 ) * 10 * 60 * 60 * 1000; cell_time += (p[7+0x18] & 0x0f) * 60 * 60 * 1000; cell_time += (p[7+0x19] >> 4 ) * 10 * 60 * 1000; @@ -508,7 +508,7 @@ static int32_t parse_private_stream_2(demux_mpeg_block_t *this, uint8_t *p, buf_ cell_time += (p[7+0x1a] & 0x0f) * 1000; frames = ((p[7+0x1b] & 0x30) >> 4) * 10; frames += ((p[7+0x1b] & 0x0f) ) ; - + if (p[7+0x1b] & 0x80) cell_time += (frames * 1000)/25; else @@ -518,7 +518,7 @@ static int32_t parse_private_stream_2(demux_mpeg_block_t *this, uint8_t *p, buf_ this->last_cell_pos = this->input->get_current_pos (this->input); this->last_begin_time = buf->extra_info->input_time; } - + lprintf ("NAV packet, start pts = %"PRId64", end_pts = %"PRId64"\n", start_pts, end_pts); @@ -569,14 +569,14 @@ static int32_t parse_pes_for_pts(demux_mpeg_block_t *this, uint8_t *p, buf_eleme } if (this->rate && !buf->extra_info->input_time) - buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) + buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) * 1000 / (this->rate * 50)); if (this->mpeg1) { header_len = 6; p += 6; /* packet_len -= 6; */ while ((p[0] & 0x80) == 0x80) { - p++; + p++; header_len++; this->packet_len--; /* printf ("stuffing\n");*/ @@ -589,9 +589,9 @@ static int32_t parse_pes_for_pts(demux_mpeg_block_t *this, uint8_t *p, buf_eleme this->packet_len -= 2; } - this->pts = 0; + this->pts = 0; this->dts = 0; - + if ((p[0] & 0xf0) == 0x20) { this->pts = (int64_t)(p[ 0] & 0x0E) << 29 ; this->pts |= p[ 1] << 22 ; @@ -608,19 +608,19 @@ static int32_t parse_pes_for_pts(demux_mpeg_block_t *this, uint8_t *p, buf_eleme this->pts |= (p[ 2] & 0xFE) << 14 ; this->pts |= p[ 3] << 7 ; this->pts |= (p[ 4] & 0xFE) >> 1 ; - + this->dts = (int64_t)(p[ 5] & 0x0E) << 29 ; this->dts |= p[ 6] << 22 ; this->dts |= (p[ 7] & 0xFE) << 14 ; this->dts |= p[ 8] << 7 ; this->dts |= (p[ 9] & 0xFE) >> 1 ; - + p += 10; header_len += 10; this->packet_len -= 10; return header_len; } else { - p++; + p++; header_len++; this->packet_len--; return header_len; @@ -664,13 +664,13 @@ static int32_t parse_pes_for_pts(demux_mpeg_block_t *this, uint8_t *p, buf_eleme this->pts = 0; if (p[7] & 0x40) { /* dts avail */ - + this->dts = (int64_t)(p[14] & 0x0E) << 29 ; this->dts |= p[15] << 22 ; this->dts |= (p[16] & 0xFE) << 14 ; this->dts |= p[17] << 7 ; this->dts |= (p[18] & 0xFE) >> 1 ; - + } else this->dts = 0; @@ -699,16 +699,16 @@ static int32_t parse_private_stream_1(demux_mpeg_block_t *this, uint8_t *p, buf_ buf->content = p+1; buf->size = this->packet_len-1; - + buf->type = BUF_SPU_DVD + spu_id; buf->decoder_flags |= BUF_FLAG_SPECIAL; buf->decoder_info[1] = BUF_SPECIAL_SPU_DVD_SUBTYPE; buf->decoder_info[2] = SPU_DVD_SUBTYPE_PACKAGE; buf->pts = this->pts; - - this->video_fifo->put (this->video_fifo, buf); + + this->video_fifo->put (this->video_fifo, buf); lprintf ("SPU PACK put on fifo\n"); - + return -1; } @@ -724,9 +724,9 @@ static int32_t parse_private_stream_1(demux_mpeg_block_t *this, uint8_t *p, buf_ if( !preview_mode ) check_newpts( this, this->pts, PTS_VIDEO ); */ - this->video_fifo->put (this->video_fifo, buf); + this->video_fifo->put (this->video_fifo, buf); lprintf ("SPU SVCD PACK (%"PRId64", %d) put on fifo\n", this->pts, spu_id); - + return -1; } @@ -741,29 +741,29 @@ static int32_t parse_private_stream_1(demux_mpeg_block_t *this, uint8_t *p, buf_ /* this is probably wrong: if( !preview_mode ) check_newpts( this, this->pts, PTS_VIDEO ); - */ - this->video_fifo->put (this->video_fifo, buf); + */ + this->video_fifo->put (this->video_fifo, buf); lprintf ("SPU CVD PACK (%"PRId64", %d) put on fifo\n", this->pts, spu_id); - + return -1; } if ((p[0]&0xF0) == 0x80) { - + track = p[0] & 0x0F; /* hack : ac3 track */ - /* Number of frame headers + /* Number of frame headers * * Describes the number of a52 frame headers that start in this pack (One pack per DVD sector). * * Likely values: 1 or 2. */ buf->decoder_info[1] = p[1]; - /* First access unit pointer. + /* First access unit pointer. * * Describes the byte offset within this pack to the beginning of the first A52 frame header. * The PTS from this pack applies to the beginning of the first A52 frame that starts in this pack. - * Any bytes before this offset should be considered to belong to the previous A52 frame. + * Any bytes before this offset should be considered to belong to the previous A52 frame. * and therefore be tagged with a PTS value derived from the previous pack. * * Likely values: Anything from 1 to the size of an A52 frame. @@ -864,7 +864,7 @@ static int32_t parse_private_stream_1(demux_mpeg_block_t *this, uint8_t *p, buf_ buf->free_buffer(buf); return -1; } - + } else if ((p[0]&0xf0) == 0xa0) { int pcm_offset; @@ -911,7 +911,7 @@ static int32_t parse_private_stream_1(demux_mpeg_block_t *this, uint8_t *p, buf_ buf->decoder_flags |= BUF_FLAG_SPECIAL; buf->decoder_info[1] = BUF_SPECIAL_LPCM_CONFIG; buf->decoder_info[2] = p[5]; - + pcm_offset = 7; buf->content = p+pcm_offset; @@ -930,7 +930,7 @@ static int32_t parse_private_stream_1(demux_mpeg_block_t *this, uint8_t *p, buf_ buf->free_buffer(buf); return -1; } - + } /* Some new streams have been encountered. 1) DVD+RW disc recorded with a Philips DVD recorder: - new unknown sub-stream id of 0xff @@ -1003,10 +1003,10 @@ static int demux_mpeg_block_send_chunk (demux_plugin_t *this_gen) { } #ifdef ESTIMATE_RATE_FIXED -/*! - Estimate bitrate by looking inside the MPEG file for presentation - time stamps (PTS) and computing how far apart these are - in bytes and in time. +/*! + Estimate bitrate by looking inside the MPEG file for presentation + time stamps (PTS) and computing how far apart these are + in bytes and in time. On failure return 0. @@ -1037,23 +1037,23 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { int rate=0; /* The return rate value */ int stream_id; - /* We can't estimate by sampling if we don't thave the ability to + /* We can't estimate by sampling if we don't thave the ability to randomly access the and more importantly reset after accessessing. */ if (!(this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE)) return 0; mpeg_length= this->input->get_length (this->input); - step = TRUNC((mpeg_length/MAX_SAMPLES), blocksize); + step = TRUNC((mpeg_length/MAX_SAMPLES), blocksize); if (step <= 0) step = blocksize; /* avoid endless loop for tiny files */ pos = step; /* At this point "pos", and "step" are a multiple of blocksize and they should continue to be so throughout. */ - + this->input->seek (this->input, pos, SEEK_SET); - while ( (buf = this->input->read_block (this->input, this->video_fifo, blocksize)) + while ( (buf = this->input->read_block (this->input, this->video_fifo, blocksize)) && count < MAX_SAMPLES && reads++ < MAX_READS ) { p = buf->content; /* len = this->mnBlocksize; */ @@ -1062,9 +1062,9 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { is_mpeg1 = (p[4] & 0x40) == 0; - if (is_mpeg1) + if (is_mpeg1) p += 12; - else + else p += 14 + (p[0xD] & 0x07); } @@ -1081,7 +1081,7 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { } stream_id = p[3]; - pts = 0; + pts = 0; if ((stream_id < 0xbc) || ((stream_id & 0xf0) != 0xe0)) { pos += (off_t) blocksize; @@ -1111,18 +1111,18 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { pts |= (p[ 2] & 0xFE) << 14 ; pts |= p[ 3] << 7 ; pts |= (p[ 4] & 0xFE) >> 1 ; - } + } } } else { /* mpeg 2 */ - + if (p[7] & 0x80) { /* pts avail */ - + pts = (int64_t)(p[ 9] & 0x0E) << 29 ; pts |= p[10] << 22 ; pts |= (p[11] & 0xFE) << 14 ; pts |= p[12] << 7 ; pts |= (p[13] & 0xFE) >> 1 ; - + } else pts = 0; } @@ -1132,16 +1132,16 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { if ( (pos>last_pos) && (pts>last_pts) ) { int cur_rate; - + cur_rate = ((pos - last_pos)*90000) / ((pts - last_pts) * 50); - + rate = (count * rate + cur_rate) / (count+1); count ++; - + /* - printf ("demux_mpeg_block: stream_id %02x, pos: %"PRId64", pts: %d, cur_rate = %d, overall rate : %d\n", - stream_id, pos, pts, cur_rate, rate); + printf ("demux_mpeg_block: stream_id %02x, pos: %"PRId64", pts: %d, cur_rate = %d, overall rate : %d\n", + stream_id, pos, pts, cur_rate, rate); */ } @@ -1165,14 +1165,14 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { lprintf("est_rate=%d\n",rate); return rate; - + } #endif /*ESTIMATE_RATE_FIXED*/ static void demux_mpeg_block_dispose (demux_plugin_t *this_gen) { demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; - + free (this); } @@ -1182,7 +1182,7 @@ static int demux_mpeg_block_get_status (demux_plugin_t *this_gen) { return this->status; } -static int demux_mpeg_detect_blocksize(demux_mpeg_block_t *this, +static int demux_mpeg_detect_blocksize(demux_mpeg_block_t *this, input_plugin_t *input) { uint8_t scratch[4]; @@ -1196,10 +1196,10 @@ static int demux_mpeg_detect_blocksize(demux_mpeg_block_t *this, input->seek(input, 2324, SEEK_SET); if (input->read(input, scratch, 4) != 4) return 0; - if (scratch[0] || scratch[1] - || (scratch[2] != 0x01) || (scratch[3] != 0xba)) + if (scratch[0] || scratch[1] + || (scratch[2] != 0x01) || (scratch[3] != 0xba)) return 0; - + return 2324; } else return 2048; @@ -1219,34 +1219,34 @@ static void demux_mpeg_block_send_headers (demux_plugin_t *this_gen) { if (!this->blocksize) return; } - - /* + + /* * send start buffer */ - + _x_demux_control_start(this->stream); - + #ifdef USE_ILL_ADVISED_ESTIMATE_RATE_INITIALLY - if (!this->rate) + if (!this->rate) this->rate = demux_mpeg_block_estimate_rate (this); -#else +#else /* Set to Use rate given in by stream initially. */ - this->rate = 0; + this->rate = 0; #endif - + if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) { - + int num_buffers = NUM_PREVIEW_BUFFERS; - + this->input->seek (this->input, 0, SEEK_SET); - + this->status = DEMUX_OK ; while ( (num_buffers>0) && (this->status == DEMUX_OK) ) { - + demux_mpeg_block_parse_pack(this, 1); num_buffers --; } - } + } /* else FIXME: implement preview generation from PREVIEW data */ this->status = DEMUX_OK; @@ -1265,19 +1265,19 @@ static int demux_mpeg_block_seek (demux_plugin_t *this_gen, this->input->get_length (this->input) ); if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) { - + if (start_pos) { start_pos /= (off_t) this->blocksize; start_pos *= (off_t) this->blocksize; - + this->input->seek (this->input, start_pos, SEEK_SET); } else if (start_time) { - + if( this->input->seek_time ) { this->input->seek_time (this->input, start_time, SEEK_SET); } else { start_time /= 1000; - + if (this->last_cell_time) { start_pos = start_time - (this->last_cell_time + this->last_begin_time)/1000; start_pos *= this->rate; @@ -1290,20 +1290,20 @@ static int demux_mpeg_block_seek (demux_plugin_t *this_gen, } start_pos /= (off_t) this->blocksize; start_pos *= (off_t) this->blocksize; - + this->input->seek (this->input, start_pos, SEEK_SET); } } else this->input->seek (this->input, 0, SEEK_SET); } - + /* * now start demuxing */ this->last_cell_time = 0; this->send_newpts = 1; if( !playing ) { - + this->buf_flag_seek = 0; this->nav_last_end_pts = this->nav_last_start_pts = 0; this->status = DEMUX_OK ; @@ -1314,7 +1314,7 @@ static int demux_mpeg_block_seek (demux_plugin_t *this_gen, this->nav_last_end_pts = this->nav_last_start_pts = 0; _x_demux_flush_engine(this->stream); } - + return this->status; } @@ -1332,7 +1332,7 @@ static void demux_mpeg_block_accept_input (demux_mpeg_block_t *this, lprintf ("mrl %s is new\n", this->cur_mrl); - } + } else { lprintf ("mrl %s is known, bitrate: %d\n", this->cur_mrl, this->rate * 50 * 8); @@ -1346,7 +1346,7 @@ static int demux_mpeg_block_get_stream_length (demux_plugin_t *this_gen) { * find input plugin */ - if (this->rate) + if (this->rate) return (int)((int64_t) 1000 * this->input->get_length (this->input) / (this->rate * 50)); else @@ -1371,7 +1371,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this = calloc(1, sizeof(demux_mpeg_block_t)); this->stream = stream; this->input = input; - + this->demux_plugin.send_headers = demux_mpeg_block_send_headers; this->demux_plugin.send_chunk = demux_mpeg_block_send_chunk; this->demux_plugin.seek = demux_mpeg_block_seek; @@ -1386,9 +1386,9 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str lprintf ("open_plugin:detection_method=%d\n", stream->content_detection_method); - + switch (stream->content_detection_method) { - + case METHOD_BY_CONTENT: { /* use demux_mpeg for non-block devices */ @@ -1551,7 +1551,7 @@ static const demuxer_info_t demux_info_mpeg_block = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "mpeg_block", XINE_VERSION_CODE, &demux_info_mpeg_block, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index 9715e1254..0fe97fb93 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -24,7 +24,7 @@ * (c) 2003 James Courtier-Dutton James@superbug.demon.co.uk * This code might also decode normal MPG files. */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -48,7 +48,7 @@ #define NUM_PREVIEW_BUFFERS 250 #define DISC_TRESHOLD 90000 -#define WRAP_THRESHOLD 270000 +#define WRAP_THRESHOLD 270000 #define PTS_AUDIO 0 #define PTS_VIDEO 1 @@ -60,14 +60,14 @@ typedef struct demux_mpeg_pes_s { demux_plugin_t demux_plugin; - xine_stream_t *stream; + xine_stream_t *stream; fifo_buffer_t *audio_fifo; fifo_buffer_t *video_fifo; input_plugin_t *input; int status; - + int rate; char cur_mrl[256]; @@ -91,7 +91,7 @@ typedef struct demux_mpeg_pes_s { uint8_t mpeg1:1; uint8_t wait_for_program_stream_pack_header:1; uint8_t mpeg12_h264_detected:2; - + int last_begin_time; int64_t last_cell_time; off_t last_cell_pos; @@ -202,7 +202,7 @@ static int detect_pts_discontinuity( demux_mpeg_pes_t *this, int64_t pts, int vi /* no discontinuity detected */ return 0; } - + static void check_newpts( demux_mpeg_pes_t *this, int64_t pts, int video ) { if( pts && (this->send_newpts || detect_pts_discontinuity(this, pts, video) ) ) { @@ -226,7 +226,7 @@ static void check_newpts( demux_mpeg_pes_t *this, int64_t pts, int video ) /* clear pts on the other track to avoid detecting the same discontinuity again */ this->last_pts[1-video] = 0; } - + if( pts ) this->last_pts[video] = pts; } @@ -258,7 +258,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) int32_t result; off_t i; uint8_t buf6[ 6 ]; - + this->scr = 0; this->preview_mode = preview_mode; @@ -280,9 +280,9 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) return; } } - + /* FIXME: buf must be allocated from somewhere before calling here. */ - + /* these streams should be allocated on the audio_fifo, if available. */ if ((0xC0 <= p[ 3 ] && p[ 3 ] <= 0xDF) /* audio_stream */ || 0xBD == p[ 3 ]) /* private_sream_1 */ @@ -301,19 +301,19 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) return; } } - + p = buf->mem; /* copy local buffer to fifo element. */ memcpy(p, buf6, sizeof(buf6)); - + if (preview_mode) buf->decoder_flags = BUF_FLAG_PREVIEW; else buf->decoder_flags = 0; - + if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); this->stream_id = p[3]; @@ -412,7 +412,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("xine-lib:demux_mpeg_pes: Unrecognised stream_id 0x%02x. " "Please report this to xine developers.\n"), this->stream_id); - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: packet_len=%d\n", this->packet_len); buf->free_buffer (buf); return; @@ -435,11 +435,11 @@ static int32_t parse_padding_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elem { /* Handle Jumbo frames from VDR. */ int i; - + int size = buf->max_size; if ((todo - done) < size) size = todo - done; - + i = read_data(this, buf->mem, (off_t)size); if (i != size) break; @@ -456,98 +456,98 @@ static int32_t parse_padding_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elem static int32_t parse_program_stream_map(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x.\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_ecm_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_emm_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_dsmcc_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_iec_13522_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_h222_typeA_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_h222_typeB_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_h222_typeC_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_h222_typeD_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_h222_typeE_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_IEC14496_SL_packetized_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_IEC14496_FlexMux_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_program_stream_directory(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; } static int32_t parse_ancillary_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf) { /* FIXME: Implement */ - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "xine-lib:demux_mpeg_pes: Unhandled stream_id 0x%02x\n", this->stream_id); buf->free_buffer (buf); return -1; @@ -588,7 +588,7 @@ static int32_t parse_program_stream_pack_header(demux_mpeg_pes_t *this, uint8_t return 12; } else { /* mpeg2 */ - + int num_stuffing_bytes; /* system_clock_reference */ @@ -662,7 +662,7 @@ static int32_t parse_private_stream_2(demux_mpeg_pes_t *this, uint8_t *p, buf_el * the NAV packet for a much more accurate timing */ if (buf->extra_info->input_time) { int64_t cell_time, frames; - + cell_time = (p[7+0x18] >> 4 ) * 10 * 60 * 60 * 1000; cell_time += (p[7+0x18] & 0x0f) * 60 * 60 * 1000; cell_time += (p[7+0x19] >> 4 ) * 10 * 60 * 1000; @@ -671,7 +671,7 @@ static int32_t parse_private_stream_2(demux_mpeg_pes_t *this, uint8_t *p, buf_el cell_time += (p[7+0x1a] & 0x0f) * 1000; frames = ((p[7+0x1b] & 0x30) >> 4) * 10; frames += ((p[7+0x1b] & 0x0f) ) ; - + if (p[7+0x1b] & 0x80) cell_time += (frames * 1000)/25; else @@ -681,7 +681,7 @@ static int32_t parse_private_stream_2(demux_mpeg_pes_t *this, uint8_t *p, buf_el this->last_cell_pos = this->input->get_current_pos (this->input); this->last_begin_time = buf->extra_info->input_time; } - + lprintf ("NAV packet, start pts = %"PRId64", end_pts = %"PRId64"\n", start_pts, end_pts); @@ -731,7 +731,7 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element } if (this->rate && !buf->extra_info->input_time) - buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) + buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) * 1000 / (this->rate * 50)); /* FIXME: This was determined by comparing a single MPEG1 and a single MPEG2 stream */ @@ -746,7 +746,7 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element p += 6; /* packet_len -= 6; */ while ((p[0] & 0x80) == 0x80) { - p++; + p++; header_len++; this->packet_len--; /* printf ("stuffing\n");*/ @@ -759,9 +759,9 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element this->packet_len -= 2; } - this->pts = 0; + this->pts = 0; this->dts = 0; - + if ((p[0] & 0xf0) == 0x20) { this->pts = (int64_t) (p[ 0] & 0x0E) << 29 ; this->pts |= (int64_t) p[ 1] << 22 ; @@ -778,19 +778,19 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element this->pts |= (int64_t) (p[ 2] & 0xFE) << 14 ; this->pts |= (int64_t) p[ 3] << 7 ; this->pts |= (int64_t) (p[ 4] & 0xFE) >> 1 ; - + this->dts = (int64_t) (p[ 5] & 0x0E) << 29 ; this->dts |= (int64_t) p[ 6] << 22 ; this->dts |= (int64_t) (p[ 7] & 0xFE) << 14 ; this->dts |= (int64_t) p[ 8] << 7 ; this->dts |= (int64_t) (p[ 9] & 0xFE) >> 1 ; - + p += 10; header_len += 10; this->packet_len -= 10; return header_len; } else { - p++; + p++; header_len++; this->packet_len--; return header_len; @@ -834,13 +834,13 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element this->pts = 0; if (p[7] & 0x40) { /* dts avail */ - + this->dts = (int64_t) (p[14] & 0x0E) << 29 ; this->dts |= (int64_t) p[15] << 22 ; this->dts |= (int64_t) (p[16] & 0xFE) << 14 ; this->dts |= (int64_t) p[17] << 7 ; this->dts |= (int64_t) (p[18] & 0xFE) >> 1 ; - + } else this->dts = 0; @@ -869,16 +869,16 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el buf->content = p+1; buf->size = this->packet_len-1; - + buf->type = BUF_SPU_DVD + spu_id; buf->decoder_flags |= BUF_FLAG_SPECIAL; buf->decoder_info[1] = BUF_SPECIAL_SPU_DVD_SUBTYPE; buf->decoder_info[2] = SPU_DVD_SUBTYPE_PACKAGE; buf->pts = this->pts; - - this->video_fifo->put (this->video_fifo, buf); + + this->video_fifo->put (this->video_fifo, buf); lprintf ("SPU PACK put on fifo\n"); - + return this->packet_len + result; } @@ -894,9 +894,9 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el if( !preview_mode ) check_newpts( this, this->pts, PTS_VIDEO ); */ - this->video_fifo->put (this->video_fifo, buf); + this->video_fifo->put (this->video_fifo, buf); lprintf ("SPU SVCD PACK (%"PRId64", %d) put on fifo\n", this->pts, spu_id); - + return this->packet_len + result; } @@ -911,15 +911,15 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el /* this is probably wrong: if( !preview_mode ) check_newpts( this, this->pts, PTS_VIDEO ); - */ - this->video_fifo->put (this->video_fifo, buf); + */ + this->video_fifo->put (this->video_fifo, buf); lprintf ("SPU CVD PACK (%"PRId64", %d) put on fifo\n", this->pts, spu_id); - + return this->packet_len + result; } if ((p[0]&0xF0) == 0x80) { - + track = p[0] & 0x0F; /* hack : ac3 track */ buf->decoder_info[1] = p[1]; /* Number of frame headers */ buf->decoder_info[2] = p[2] << 8 | p[3]; /* First access unit pointer */ @@ -943,7 +943,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el buf->free_buffer(buf); } return this->packet_len + result; - + } else if ((p[0]&0xf0) == 0xa0) { int pcm_offset; @@ -983,7 +983,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el switch ((p[5]>>6) & 3) { case 3: /* illegal, use 16-bits? */ default: - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "illegal lpcm sample format (%d), assume 16-bit samples\n", (p[5]>>6) & 3 ); case 0: bits_per_sample = 16; break; @@ -996,7 +996,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el buf->decoder_flags |= BUF_FLAG_SPECIAL; buf->decoder_info[1] = BUF_SPECIAL_LPCM_CONFIG; buf->decoder_info[2] = p[5]; - + pcm_offset = 7; buf->content = p+pcm_offset; @@ -1020,7 +1020,7 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el int size; /* - * A52/AC3 streams in some DVB-S recordings made with VDR. + * A52/AC3 streams in some DVB-S recordings made with VDR. * It is broadcast by a german tv-station called PRO7. * PRO7 uses dolby 5.1 (A52 5.1) in some of the movies they broadcast, * (and they would switch it to stereo-sound(A52 2.0) during commercials.) @@ -1073,18 +1073,18 @@ static int32_t parse_private_stream_1(demux_mpeg_pes_t *this, uint8_t *p, buf_el lprintf ("A52 PACK put on fifo\n"); } else { buf->free_buffer(buf); - } + } } return this->packet_len + result; } - + /* Some new streams have been encountered. 1) DVD+RW disc recorded with a Philips DVD recorder: - new unknown sub-stream id of 0xff */ - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("demux_mpeg_pes:Unrecognised private stream 1 0x%02x. Please report this to xine developers.\n"), p[0]); buf->free_buffer(buf); return this->packet_len + result; @@ -1166,7 +1166,7 @@ static int32_t parse_video_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elemen if (this->mpeg12_h264_detected > 2) { int nal_type_code = -1; if (payload_size >= 4 && p[2] == 0x01 && p[1] == 0x00 && p[0] == 0x00) - nal_type_code = p[3] & 0x1f; + nal_type_code = p[3] & 0x1f; if (nal_type_code == 9) { /* access unit delimiter */ buf_element_t *b = this->video_fifo->buffer_pool_alloc (this->video_fifo); b->content = b->mem; @@ -1275,10 +1275,10 @@ static int demux_mpeg_pes_send_chunk (demux_plugin_t *this_gen) { } #ifdef ESTIMATE_RATE_FIXED -/*! - Estimate bitrate by looking inside the MPEG file for presentation - time stamps (PTS) and computing how far apart these are - in bytes and in time. +/*! + Estimate bitrate by looking inside the MPEG file for presentation + time stamps (PTS) and computing how far apart these are + in bytes and in time. On failure return 0. @@ -1308,23 +1308,23 @@ static int demux_mpeg_pes_estimate_rate (demux_mpeg_pes_t *this) { int rate=0; /* The return rate value */ int stream_id; - /* We can't estimate by sampling if we don't thave the ability to + /* We can't estimate by sampling if we don't thave the ability to randomly access the and more importantly reset after accessessing. */ if (!(this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE)) return 0; mpeg_length= this->input->get_length (this->input); - step = TRUNC((mpeg_length/MAX_SAMPLES), 2048); + step = TRUNC((mpeg_length/MAX_SAMPLES), 2048); if (step <= 0) step = 2048; /* avoid endless loop for tiny files */ pos = step; /* At this point "pos", and "step" are a multiple of blocksize and they should continue to be so throughout. */ - + this->input->seek (this->input, pos, SEEK_SET); - while ( (buf = this->input->read_block (this->input, this->video_fifo, 2048)) + while ( (buf = this->input->read_block (this->input, this->video_fifo, 2048)) && count < MAX_SAMPLES && reads++ < MAX_READS ) { p = buf->content; /* len = this->mnBlocksize; */ @@ -1333,9 +1333,9 @@ static int demux_mpeg_pes_estimate_rate (demux_mpeg_pes_t *this) { is_mpeg1 = (p[4] & 0x40) == 0; - if (is_mpeg1) + if (is_mpeg1) p += 12; - else + else p += 14 + (p[0xD] & 0x07); } @@ -1345,14 +1345,14 @@ static int demux_mpeg_pes_estimate_rate (demux_mpeg_pes_t *this) { /* we should now have a PES packet here */ if (p[0] || p[1] || (p[2] != 1)) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_mpeg_pes: error %02x %02x %02x (should be 0x000001) \n", p[0], p[1], p[2]); buf->free_buffer (buf); return rate; } stream_id = p[3]; - pts = 0; + pts = 0; if ((stream_id < 0xbc) || ((stream_id & 0xf0) != 0xe0)) { pos += (off_t) 2048; @@ -1381,18 +1381,18 @@ static int demux_mpeg_pes_estimate_rate (demux_mpeg_pes_t *this) { pts |= (p[ 2] & 0xFE) << 14 ; pts |= p[ 3] << 7 ; pts |= (p[ 4] & 0xFE) >> 1 ; - } + } } } else { /* mpeg 2 */ - + if (p[7] & 0x80) { /* pts avail */ - + pts = (int64_t)(p[ 9] & 0x0E) << 29 ; pts |= p[10] << 22 ; pts |= (p[11] & 0xFE) << 14 ; pts |= p[12] << 7 ; pts |= (p[13] & 0xFE) >> 1 ; - + } else pts = 0; } @@ -1402,16 +1402,16 @@ static int demux_mpeg_pes_estimate_rate (demux_mpeg_pes_t *this) { if ( (pos>last_pos) && (pts>last_pts) ) { int cur_rate; - + cur_rate = ((pos - last_pos)*90000) / ((pts - last_pts) * 50); - + rate = (count * rate + cur_rate) / (count+1); count ++; - + /* - printf ("demux_mpeg_pes: stream_id %02x, pos: %"PRId64", pts: %d, cur_rate = %d, overall rate : %d\n", - stream_id, pos, pts, cur_rate, rate); + printf ("demux_mpeg_pes: stream_id %02x, pos: %"PRId64", pts: %d, cur_rate = %d, overall rate : %d\n", + stream_id, pos, pts, cur_rate, rate); */ } @@ -1431,14 +1431,14 @@ static int demux_mpeg_pes_estimate_rate (demux_mpeg_pes_t *this) { lprintf("est_rate=%d\n",rate); return rate; - + } #endif /*ESTIMATE_RATE_FIXED*/ static void demux_mpeg_pes_dispose (demux_plugin_t *this_gen) { demux_mpeg_pes_t *this = (demux_mpeg_pes_t *) this_gen; - + free (this->scratch_base); free (this); } @@ -1456,35 +1456,35 @@ static void demux_mpeg_pes_send_headers (demux_plugin_t *this_gen) { this->video_fifo = this->stream->video_fifo; this->audio_fifo = this->stream->audio_fifo; - /* + /* * send start buffer */ - + _x_demux_control_start(this->stream); - + #ifdef USE_ILL_ADVISED_ESTIMATE_RATE_INITIALLY - if (!this->rate) + if (!this->rate) this->rate = demux_mpeg_pes_estimate_rate (this); -#else +#else /* Set to Use rate given in by stream initially. */ - this->rate = 0; + this->rate = 0; #endif - + if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) { - + int num_buffers = NUM_PREVIEW_BUFFERS; - + this->input->seek (this->input, 0, SEEK_SET); - + this->status = DEMUX_OK ; while ( (num_buffers>0) && (this->status == DEMUX_OK) ) { - + demux_mpeg_pes_parse_pack(this, 1); num_buffers --; } - } + } else if((this->input->get_capabilities(this->input) & INPUT_CAP_PREVIEW) != 0) { - + this->preview_size = this->input->get_optional_data(this->input, &this->preview_data, INPUT_OPTIONAL_DATA_PREVIEW); this->preview_done = 0; @@ -1512,14 +1512,14 @@ static int demux_mpeg_pes_seek (demux_plugin_t *this_gen, this->input->get_length (this->input) ); if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) { - + if (start_pos) { start_pos /= (off_t) 2048; start_pos *= (off_t) 2048; - + this->input->seek (this->input, start_pos, SEEK_SET); } else if (start_time) { - + if (this->last_cell_time) { start_pos = start_time - (this->last_cell_time + this->last_begin_time)/1000; start_pos *= this->rate; @@ -1532,19 +1532,19 @@ static int demux_mpeg_pes_seek (demux_plugin_t *this_gen, } start_pos /= (off_t) 2048; start_pos *= (off_t) 2048; - + this->input->seek (this->input, start_pos, SEEK_SET); } else this->input->seek (this->input, 0, SEEK_SET); } - + /* * now start demuxing */ this->last_cell_time = 0; this->send_newpts = 1; if( !playing ) { - + this->buf_flag_seek = 0; this->nav_last_end_pts = this->nav_last_start_pts = 0; this->status = DEMUX_OK ; @@ -1557,7 +1557,7 @@ static int demux_mpeg_pes_seek (demux_plugin_t *this_gen, this->mpeg12_h264_detected = 0; _x_demux_flush_engine(this->stream); } - + return this->status; } @@ -1575,7 +1575,7 @@ static void demux_mpeg_pes_accept_input (demux_mpeg_pes_t *this, lprintf ("mrl %s is new\n", this->cur_mrl); - } + } else { lprintf ("mrl %s is known, bitrate: %d\n", this->cur_mrl, this->rate * 50 * 8); @@ -1589,7 +1589,7 @@ static int demux_mpeg_pes_get_stream_length (demux_plugin_t *this_gen) { * find input plugin */ - if (this->rate) + if (this->rate) return (int)((int64_t) 1000 * this->input->get_length (this->input) / (this->rate * 50)); else @@ -1614,7 +1614,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this = calloc(1, sizeof(demux_mpeg_pes_t)); this->stream = stream; this->input = input; - + this->demux_plugin.send_headers = demux_mpeg_pes_send_headers; this->demux_plugin.send_chunk = demux_mpeg_pes_send_chunk; this->demux_plugin.seek = demux_mpeg_pes_seek; @@ -1637,9 +1637,9 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str lprintf ("open_plugin:detection_method=%d\n", stream->content_detection_method); - + switch (stream->content_detection_method) { - + case METHOD_BY_CONTENT: { /* use demux_mpeg_block for block devices */ @@ -1806,7 +1806,7 @@ static const demuxer_info_t demux_info_mpeg_pes = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "mpeg_pes", XINE_VERSION_CODE, &demux_info_mpeg_pes, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index a87de5f97..6205f9a08 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2007 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -98,7 +98,7 @@ typedef struct { uint32_t stream_size; uint8_t toc[XING_TOC_LENGTH]; uint32_t vbr_scale; - + /* Lame extension */ uint16_t start_delay; uint16_t end_delay; @@ -289,7 +289,7 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con return 0; } #endif - + { const uint16_t samples = mp3_samples[frame->version_idx][frame->layer - 1]; frame->bitrate = mp3_bitrates[frame->version_idx][frame->layer - 1][frame_header.bitrate_idx] * 1000; @@ -339,21 +339,21 @@ static xing_header_t *XINE_MALLOC parse_xing_header(mpg_audio_frame_t *frame, else ptr += (9 + 4); } - + if (ptr >= (buf + bufsize - 4)) goto exit_error; lprintf("checking %08X\n", *ptr); - + if (_X_BE_32(ptr) == XING_TAG) { int has_frames_flag = 0; int has_bytes_flag = 0; - + xing = calloc(1, sizeof(xing_header_t)); if (!xing) goto exit_error; - + lprintf("found Xing header\n"); ptr += 4; - + if (ptr >= (buf + bufsize - 4)) goto exit_error; xing->flags = _X_BE_32(ptr); ptr += 4; @@ -369,7 +369,7 @@ static xing_header_t *XINE_MALLOC parse_xing_header(mpg_audio_frame_t *frame, lprintf("stream size: %d\n", xing->stream_size); has_bytes_flag = 1; } - + /* check if it's a useful Xing header */ if (!has_frames_flag || !has_bytes_flag) { lprintf("Stupid Xing tag, cannot do anything with it !\n"); @@ -427,7 +427,7 @@ static xing_header_t *XINE_MALLOC parse_xing_header(mpg_audio_frame_t *frame, lprintf("Xing header not found\n"); } return xing; - + exit_error: lprintf("Xing header parse error\n"); free(xing); @@ -450,13 +450,13 @@ static vbri_header_t *XINE_MALLOC parse_vbri_header(mpg_audio_frame_t *frame, return NULL; ptr += (32 + 4); - + if ((ptr + 4) >= (buf + bufsize)) return 0; lprintf("Checking %08X\n", *ptr); if (_X_BE_32(ptr) == VBRI_TAG) { lprintf("found Vbri header\n"); ptr += 4; - + if ((ptr + 22) >= (buf + bufsize)) return 0; vbri->version = _X_BE_16(ptr); ptr += 2; vbri->delai = _X_BE_16(ptr); ptr += 2; @@ -699,7 +699,7 @@ static int sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen, int *version, static int read_frame_header(demux_mpgaudio_t *this, uint8_t *header_buf, int bytes) { off_t len; int i; - + for (i = 0; i < (4 - bytes); i++) { header_buf[i] = header_buf[i + bytes]; } @@ -958,7 +958,7 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) { this->br = ((uint64_t)vbri->stream_size * 8 * 1000) / this->stream_length; } } - + /* Set to default if Vbr header is incomplete or not present */ if (!this->br) { /* assume CBR */ @@ -1152,7 +1152,7 @@ static uint32_t demux_mpgaudio_get_capabilities(demux_plugin_t *this_gen) { static int demux_mpgaudio_get_optional_data(demux_plugin_t *this_gen, void *data, int data_type) { return DEMUX_OPTIONAL_UNSUPPORTED; -} +} static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *stream, input_plugin_t *input) { @@ -1174,18 +1174,18 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str case METHOD_BY_EXTENSION: { const char *const mrl = input->get_mrl(input); const char *const extensions = class_gen->get_extensions (class_gen); - + lprintf ("stage by extension %s\n", mrl); - + if (!_x_demux_check_extension (mrl, extensions)) return NULL; - + } break; case METHOD_EXPLICIT: break; - + default: return NULL; } @@ -1229,7 +1229,7 @@ static const char *get_identifier (demux_class_t *this_gen) { static const char *get_extensions (demux_class_t *this_gen) { demux_mpgaudio_class_t *this = (demux_mpgaudio_class_t *) this_gen; - + if( _x_decoder_available(this->xine, BUF_AUDIO_MPEG) ) return "mp3 mp2 mpa mpega"; else @@ -1262,9 +1262,9 @@ static void class_dispose (demux_class_t *this_gen) { } void *demux_mpgaudio_init_class (xine_t *xine, void *data) { - + demux_mpgaudio_class_t *this; - + this = calloc(1, sizeof(demux_mpgaudio_class_t)); this->xine = xine; diff --git a/src/demuxers/demux_nsf.c b/src/demuxers/demux_nsf.c index 926ea97e1..40aeae9da 100644 --- a/src/demuxers/demux_nsf.c +++ b/src/demuxers/demux_nsf.c @@ -22,7 +22,7 @@ * NSF File "Demuxer" by Mike Melanson (melanson@pcisys.net) * This is really just a loader for NES Music File Format (extension NSF) * which loads an entire NSF file and passes it over to the NSF audio - * decoder. + * decoder. * * After the file is sent over, the demuxer controls the playback by * sending empty buffers with incrementing pts values. @@ -166,7 +166,7 @@ static int demux_nsf_send_chunk(demux_plugin_t *this_gen) { buf->decoder_info[1] = 0; buf->type = BUF_AUDIO_NSF; - if(this->total_songs) + if(this->total_songs) buf->extra_info->input_normpos = (this->current_song - 1) * 65535 / this->total_songs; buf->extra_info->input_time = this->current_pts / 90; buf->pts = this->current_pts; diff --git a/src/demuxers/demux_nsv.c b/src/demuxers/demux_nsv.c index 42d31ca14..8017d3d3f 100644 --- a/src/demuxers/demux_nsv.c +++ b/src/demuxers/demux_nsv.c @@ -106,17 +106,17 @@ static void nsv_parse_framerate(demux_nsv_t *this, uint8_t framerate) /* 29.97 fps */ this->frame_pts_inc = 3003; break; - + case 3: /* 23.976 fps */ this->frame_pts_inc = 3753; break; - + case 5: /* 14.98 fps */ this->frame_pts_inc = 6006; break; - + default: lprintf("unknown framerate: 0x%02X\n", this->fps); this->frame_pts_inc = 90000; @@ -124,7 +124,7 @@ static void nsv_parse_framerate(demux_nsv_t *this, uint8_t framerate) } } else this->frame_pts_inc = 90000 / this->fps; - + lprintf("frame_pts_inc=%d\n", this->frame_pts_inc); } @@ -138,7 +138,7 @@ static off_t nsv_read(demux_nsv_t *this, uint8_t *buffer, off_t len) { int ultravox_rest; int buffer_pos = 0; - + /* ultravox stuff */ while (len) { ultravox_rest = this->ultravox_size - this->ultravox_pos; @@ -194,7 +194,7 @@ static off_t nsv_seek(demux_nsv_t *this, off_t offset, int origin) { /* ultravox stuff */ if (origin == SEEK_CUR) { uint8_t buffer[1024]; - + while (offset) { if (offset > sizeof(buffer)) { if (nsv_read(this, buffer, sizeof(buffer)) != sizeof(buffer)) @@ -221,7 +221,7 @@ static int nsv_resync(demux_nsv_t *this) { for (i = 0; i < NSV_MAX_RESYNC; i++) { uint8_t byte; - + if (nsv_read(this, &byte, 1) != 1) return NSV_RESYNC_ERROR; @@ -267,11 +267,11 @@ static int open_nsv_file(demux_nsv_t *this) { while (!NSVs_found) { switch (nsv_resync(this)) { - + case NSV_RESYNC_NSVf: { uint32_t chunk_size; - + /* if there is a NSVs tag, load 24 more header bytes; load starting at * offset 4 in buffer to keep header data in line with document */ if (nsv_read(this, &preview[4], 24) != 24) @@ -280,41 +280,41 @@ static int open_nsv_file(demux_nsv_t *this) { lprintf("found NSVf chunk\n"); /* this->data_size = _X_LE_32(&preview[8]);*/ /*lprintf("data_size: %lld\n", this->data_size);*/ - + /* skip the rest of the data */ chunk_size = _X_LE_32(&preview[4]); nsv_seek(this, chunk_size - 28, SEEK_CUR); } break; - + case NSV_RESYNC_NSVs: - - /* fetch the remaining 15 header bytes of the first chunk to get the + + /* fetch the remaining 15 header bytes of the first chunk to get the * relevant information */ if (nsv_read(this, &preview[4], 15) != 15) return 0; - + this->video_fourcc = _X_ME_32(&preview[4]); if (_x_is_fourcc(&preview[4], "NONE")) this->video_type = 0; else this->video_type = _x_fourcc_to_buf_video(this->video_fourcc); - + this->audio_fourcc = _X_ME_32(&preview[8]); if (_x_is_fourcc(&preview[8], "NONE")) this->audio_type = 0; else this->audio_type = _x_formattag_to_buf_audio(this->audio_fourcc); - + this->bih.biSize = sizeof(this->bih); this->bih.biWidth = _X_LE_16(&preview[12]); this->bih.biHeight = _X_LE_16(&preview[14]); this->bih.biCompression = this->video_fourcc; this->video_pts = 0; - + /* may not be true, but set it for the time being */ this->frame_pts_inc = 3003; - + lprintf("video: %c%c%c%c, buffer type %08X, %dx%d\n", preview[4], preview[5], @@ -333,10 +333,10 @@ static int open_nsv_file(demux_nsv_t *this) { nsv_parse_framerate(this, preview[16]); NSVs_found = 1; break; - + case NSV_RESYNC_ERROR: return 0; - + } } @@ -458,27 +458,27 @@ static int demux_nsv_send_chunk(demux_plugin_t *this_gen) { current_file_pos = this->input->get_current_pos(this->input); lprintf("dispatching video & audio chunks...\n"); - + if (this->is_first_chunk) { chunk_type = NSV_RESYNC_BEEF; this->is_first_chunk = 0; } else { chunk_type = nsv_resync(this); } - + switch (chunk_type) { case NSV_RESYNC_NSVf: /* do nothing */ break; - + case NSV_RESYNC_NSVs: /* skip header */ if (nsv_read(this, buffer, 15) != 15) return 0; nsv_parse_framerate(this, buffer[12]); - + /* fall thru */ - + case NSV_RESYNC_BEEF: if (nsv_read(this, buffer, 5) != 5) { this->status = DEMUX_FINISHED; @@ -488,15 +488,15 @@ static int demux_nsv_send_chunk(demux_plugin_t *this_gen) { video_size >>= 4; video_size &= 0xFFFFF; audio_size = _X_LE_16(&buffer[3]); - + nsv_parse_payload(this, video_size, audio_size); break; - + case NSV_RESYNC_ERROR: this->status = DEMUX_FINISHED; break; } - + return this->status; } diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index e3a9b20c4..3fc5ec9e1 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -329,7 +329,7 @@ static void send_ogg_packet (demux_ogg_t *this, buf->pts = pts; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->extra_info->input_time = buf->pts / 90 ; buf->type = this->si[stream_num]->buf_types; @@ -578,10 +578,10 @@ static void send_ogg_buf (demux_ogg_t *this, int normpos = 0; if( this->input->get_length (this->input) ) - normpos = (int)( (double) this->input->get_current_pos (this->input) * + normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); - + hdrlen = (*op->packet & PACKET_LEN_BITS01) >> 6; hdrlen |= (*op->packet & PACKET_LEN_BITS2) << 1; @@ -686,7 +686,7 @@ static void send_ogg_buf (demux_ogg_t *this, check_newpts( this, pts, PTS_VIDEO, decoder_flags ); } else pts = 0; - + llprintf(DEBUG_VIDEO_PACKETS, "videostream %d op-gpos %" PRId64 " hdr-gpos %" PRId64 " pts %" PRId64 " \n", stream_num, @@ -1328,7 +1328,7 @@ static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_ } else { this->si[stream_num]->buf_types = BUF_CONTROL_NOP; } - + } static void decode_cmml_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) { @@ -1603,10 +1603,10 @@ static int demux_ogg_send_chunk (demux_plugin_t *this_gen) { if (ogg_page_eos(&this->og)) { int i; int finished_streams = 0; - + lprintf("end of stream, serialnumber %d\n", cur_serno); this->si[stream_num]->delivered_eos = 1; - + /* check if all logical streams are finished */ for (i = 0; i < this->num_streams; i++) { finished_streams += this->si[i]->delivered_eos; @@ -1628,12 +1628,12 @@ static int demux_ogg_send_chunk (demux_plugin_t *this_gen) { this->unhandled_video_streams = 0; this->num_spu_streams = 0; this->avg_bitrate = 1; - + /* try to read a chained stream */ this->send_newpts = 1; this->last_pts[0] = 0; this->last_pts[1] = 0; - + /* send control buffer to avoid buffer leak */ _x_demux_control_end(this->stream, 0); _x_demux_control_start(this->stream); @@ -1762,7 +1762,7 @@ static int demux_ogg_seek (demux_plugin_t *this_gen, hasn` changed its length, otherwise no seek to "new" data is possible*/ lprintf ("seek to time %d called\n",start_time); - lprintf ("current time is %d\n",current_time); + lprintf ("current time is %d\n",current_time); if (current_time > start_time) { /*seek between beginning and current_pos*/ @@ -1782,7 +1782,7 @@ static int demux_ogg_seek (demux_plugin_t *this_gen, } lprintf ("current_pos is %" PRId64 "\n",current_pos); - lprintf ("new_pos is %" PRId64 "\n",start_pos); + lprintf ("new_pos is %" PRId64 "\n",start_pos); } else { /*seek using avg_bitrate*/ @@ -1801,9 +1801,9 @@ static int demux_ogg_seek (demux_plugin_t *this_gen, ogg_stream_reset(&this->si[i]->oss); } - /*some strange streams have no syncpoint flag set at the beginning*/ - if (start_pos == 0) - this->keyframe_needed = 0; + /*some strange streams have no syncpoint flag set at the beginning*/ + if (start_pos == 0) + this->keyframe_needed = 0; lprintf ("seek to %" PRId64 " called\n",start_pos); @@ -1814,7 +1814,7 @@ static int demux_ogg_seek (demux_plugin_t *this_gen, /* fixme - this would be a nice position to do the following tasks 1. adjust an ogg videostream to a keyframe 2. compare the keyframe_pts with start_time. if the difference is to - high (e.g. larger than max keyframe_intervall, do a new seek or + high (e.g. larger than max keyframe_intervall, do a new seek or continue reading 3. adjust the audiostreams in such a way, that the difference is not to high. @@ -1822,12 +1822,12 @@ static int demux_ogg_seek (demux_plugin_t *this_gen, In short words, do all the cleanups necessary to continue playback without further actions */ - + this->send_newpts = 1; this->status = DEMUX_OK; - + if( !playing ) { - + this->buf_flag_seek = 0; } else { @@ -1844,13 +1844,13 @@ static int demux_ogg_seek (demux_plugin_t *this_gen, _x_demux_flush_engine(this->stream); } - + return this->status; } static int demux_ogg_get_stream_length (demux_plugin_t *this_gen) { - demux_ogg_t *this = (demux_ogg_t *) this_gen; + demux_ogg_t *this = (demux_ogg_t *) this_gen; if (this->time_length==-1){ if (this->avg_bitrate) { @@ -1865,7 +1865,7 @@ static int demux_ogg_get_stream_length (demux_plugin_t *this_gen) { } static uint32_t demux_ogg_get_capabilities(demux_plugin_t *this_gen) { - demux_ogg_t *this = (demux_ogg_t *) this_gen; + demux_ogg_t *this = (demux_ogg_t *) this_gen; int cap_chapter = 0; if (this->chapter_info) @@ -1895,8 +1895,8 @@ static int format_lang_string (demux_ogg_t * this, uint32_t buf_mask, uint32_t b static int demux_ogg_get_optional_data(demux_plugin_t *this_gen, void *data, int data_type) { - - demux_ogg_t *this = (demux_ogg_t *) this_gen; + + demux_ogg_t *this = (demux_ogg_t *) this_gen; char *str=(char *) data; int channel = *((int *)data); @@ -2021,7 +2021,7 @@ static int detect_anx_content (int detection_method, demux_class_t *class_gen, } static demux_plugin_t *anx_open_plugin (demux_class_t *class_gen, - xine_stream_t *stream, + xine_stream_t *stream, input_plugin_t *input) { demux_ogg_t *this; @@ -2050,13 +2050,13 @@ static demux_plugin_t *anx_open_plugin (demux_class_t *class_gen, this->demux_plugin.get_capabilities = demux_ogg_get_capabilities; this->demux_plugin.get_optional_data = demux_ogg_get_optional_data; this->demux_plugin.demux_class = class_gen; - + this->status = DEMUX_FINISHED; #ifdef HAVE_THEORA theora_info_init (&this->t_info); theora_comment_init (&this->t_comment); -#endif +#endif this->chapter_info = 0; this->title = 0; @@ -2066,7 +2066,7 @@ static demux_plugin_t *anx_open_plugin (demux_class_t *class_gen, } static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen, - xine_stream_t *stream, + xine_stream_t *stream, input_plugin_t *input) { demux_ogg_t *this; @@ -2091,13 +2091,13 @@ static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen, this->demux_plugin.get_capabilities = demux_ogg_get_capabilities; this->demux_plugin.get_optional_data = demux_ogg_get_optional_data; this->demux_plugin.demux_class = class_gen; - + this->status = DEMUX_FINISHED; #ifdef HAVE_THEORA theora_info_init (&this->t_info); theora_comment_init (&this->t_comment); -#endif +#endif this->chapter_info = 0; this->title = 0; @@ -2113,7 +2113,7 @@ static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen, static const char *anx_get_description (demux_class_t *this_gen) { return "Annodex demux plugin"; } - + static const char *anx_get_identifier (demux_class_t *this_gen) { return "Annodex"; } @@ -2159,7 +2159,7 @@ static void *anx_init_class (xine_t *xine, void *data) { static const char *ogg_get_description (demux_class_t *this_gen) { return "OGG demux plugin"; } - + static const char *ogg_get_identifier (demux_class_t *this_gen) { return "OGG"; } @@ -2213,7 +2213,7 @@ static const demuxer_info_t demux_info_ogg = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "ogg", XINE_VERSION_CODE, &demux_info_ogg, ogg_init_class }, { PLUGIN_DEMUX, 26, "anx", XINE_VERSION_CODE, &demux_info_anx, anx_init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } diff --git a/src/demuxers/demux_pva.c b/src/demuxers/demux_pva.c index ddd32b63c..e2b61dcf0 100644 --- a/src/demuxers/demux_pva.c +++ b/src/demuxers/demux_pva.c @@ -148,7 +148,7 @@ static int demux_pva_send_chunk(demux_plugin_t *this_gen) { current_file_pos = this->input->get_current_pos(this->input); if (preamble[2] == 1) { - + /* video */ /* load the pts if it is the first thing in the chunk */ @@ -253,7 +253,7 @@ static int demux_pva_send_chunk(demux_plugin_t *this_gen) { buf->pts = pts; if( this->data_size ) - buf->extra_info->input_normpos = (int) ((double) this->input->get_current_pos(this->input) * + buf->extra_info->input_normpos = (int) ((double) this->input->get_current_pos(this->input) * 65535 / this->data_size); this->audio_fifo->put (this->audio_fifo, buf); @@ -302,7 +302,7 @@ static void demux_pva_send_headers(demux_plugin_t *this_gen) { buf->pts = 0; if( this->data_size ) - buf->extra_info->input_normpos = (int) ((double) this->input->get_current_pos(this->input) * + buf->extra_info->input_normpos = (int) ((double) this->input->get_current_pos(this->input) * 65535 / this->data_size); buf->type = BUF_VIDEO_MPEG; @@ -329,7 +329,7 @@ static void demux_pva_send_headers(demux_plugin_t *this_gen) { buf->pts = 0; if( this->data_size ) - buf->extra_info->input_normpos = (int) ((double) this->input->get_current_pos(this->input) * + buf->extra_info->input_normpos = (int) ((double) this->input->get_current_pos(this->input) * 65535 / this->data_size); buf->type = BUF_AUDIO_MPEG; @@ -347,7 +347,7 @@ static int demux_pva_seek (demux_plugin_t *this_gen, unsigned char seek_buffer[SEEK_BUFFER_SIZE]; int found = 0; int i; - + start_pos = (off_t) ( (double) start_pos / 65535 * this->data_size ); diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c index 2039e54d3..8e00d73a4 100644 --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.c @@ -262,10 +262,10 @@ typedef struct { /* flags that indicate how a trak is supposed to be used */ unsigned int flags; - + /* formattag-like field that specifies codec in mp4 files */ unsigned int object_type_id; - + /* decoder data pass information to the decoder */ void *decoder_config; int decoder_config_len; @@ -307,7 +307,7 @@ typedef struct { unsigned int modification_time; unsigned int timescale; /* base clock frequency is Hz */ unsigned int duration; - + int64_t moov_first_offset; int trak_count; @@ -381,7 +381,7 @@ typedef struct { * lazyqt special debugging functions **********************************************************************/ -/* define DEBUG_ATOM_LOAD as 1 to get a verbose parsing of the relevant +/* define DEBUG_ATOM_LOAD as 1 to get a verbose parsing of the relevant * atoms */ #define DEBUG_ATOM_LOAD 0 @@ -403,7 +403,7 @@ typedef struct { /* Define DEBUG_DUMP_MOOV as 1 to dump the raw moov atom to disk. This is * particularly useful in debugging a file with a compressed moov (cmov) - * atom. The atom will be dumped to the filename specified as + * atom. The atom will be dumped to the filename specified as * RAW_MOOV_FILENAME. */ #define DEBUG_DUMP_MOOV 0 #define RAW_MOOV_FILENAME "moovatom.raw" @@ -502,7 +502,7 @@ static void find_moov_atom(input_plugin_t *input, off_t *moov_offset, atom = _X_BE_32(&atom_preamble[4]); /* Special case alert: 'free' atoms sometimes masquerade as 'moov' - * atoms. If this is a free atom, check for 'cmov' or 'mvhd' immediately + * atoms. If this is a free atom, check for 'cmov' or 'mvhd' immediately * following. QT Player can handle it, so xine should too. */ if (atom == FREE_ATOM) { @@ -533,7 +533,7 @@ static void find_moov_atom(input_plugin_t *input, off_t *moov_offset, /* if this atom is not the moov atom, make sure that it is at least one * of the other top-level QT atom. - * However, allow a configurable amount ( currently 1 ) atom be a + * However, allow a configurable amount ( currently 1 ) atom be a * non known atom, in hopes a known atom will be found */ if ((atom != FREE_ATOM) && (atom != JUNK_ATOM) && @@ -712,7 +712,7 @@ static int is_qt_file(input_plugin_t *qt_file) { return 0; } else { /* check that the next atom in the chunk contains alphanumeric - * characters in the atom type field; if not, disqualify the file + * characters in the atom type field; if not, disqualify the file * as a QT file */ qt_file->seek(qt_file, moov_atom_offset + ATOM_PREAMBLE_SIZE, SEEK_SET); if (qt_file->read(qt_file, atom_preamble, ATOM_PREAMBLE_SIZE) != @@ -821,7 +821,7 @@ static void parse_mvhd_atom(qt_info *info, unsigned char *mvhd_atom) { static int mp4_read_descr_len(unsigned char *s, uint32_t *length) { uint8_t b; uint8_t numBytes = 0; - + *length = 0; do { @@ -900,14 +900,14 @@ static qt_error parse_trak_atom (qt_trak *trak, break; } } - + debug_atom_load(" qt: parsing %s trak atom\n", (trak->type == MEDIA_VIDEO) ? "video" : (trak->type == MEDIA_AUDIO) ? "audio" : "other"); /* search for the useful atoms */ for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++) { - current_atom_size = _X_BE_32(&trak_atom[i - 4]); + current_atom_size = _X_BE_32(&trak_atom[i - 4]); current_atom = _X_BE_32(&trak_atom[i]); if (current_atom == TKHD_ATOM) { @@ -947,7 +947,7 @@ static qt_error parse_trak_atom (qt_trak *trak, } else if (current_atom == MDHD_ATOM) { int version; debug_atom_load ("demux_qt: mdhd atom\n"); - + version = trak_atom[i+4]; if ( version > 1 ) continue; /* unsupported, undocumented */ @@ -975,7 +975,7 @@ static qt_error parse_trak_atom (qt_trak *trak, properties_offset = 0x0C; for (k = 0; k < trak->stsd_atoms_count; k++) { - current_stsd_atom_size = _X_BE_32(&trak_atom[atom_pos - 4]); + current_stsd_atom_size = _X_BE_32(&trak_atom[atom_pos - 4]); if (current_stsd_atom_size < 4) { last_error = QT_HEADER_TROUBLE; goto free_trak; @@ -988,7 +988,7 @@ static qt_error parse_trak_atom (qt_trak *trak, /* copy the properties atom */ trak->stsd_atoms[k].video.properties_atom_size = current_stsd_atom_size - 4; - trak->stsd_atoms[k].video.properties_atom = + trak->stsd_atoms[k].video.properties_atom = xine_xmalloc(trak->stsd_atoms[k].video.properties_atom_size); if (!trak->stsd_atoms[k].video.properties_atom) { last_error = QT_NO_MEMORY; @@ -1006,7 +1006,7 @@ static qt_error parse_trak_atom (qt_trak *trak, trak->stsd_atoms[k].video.palette_count = 0; /* fetch video parameters */ - if( _X_BE_16(&trak_atom[atom_pos + 0x1C]) && + if( _X_BE_16(&trak_atom[atom_pos + 0x1C]) && _X_BE_16(&trak_atom[atom_pos + 0x1E]) ) { trak->stsd_atoms[k].video.width = _X_BE_16(&trak_atom[atom_pos + 0x1C]); @@ -1034,9 +1034,9 @@ static qt_error parse_trak_atom (qt_trak *trak, /* compute the greyscale palette */ color_index = 255; - color_dec = 256 / + color_dec = 256 / (trak->stsd_atoms[k].video.palette_count - 1); - for (j = 0; + for (j = 0; j < trak->stsd_atoms[k].video.palette_count; j++) { @@ -1061,7 +1061,7 @@ static qt_error parse_trak_atom (qt_trak *trak, else color_table = qt_default_palette_256; - for (j = 0; + for (j = 0; j < trak->stsd_atoms[k].video.palette_count; j++) { @@ -1088,7 +1088,7 @@ static qt_error parse_trak_atom (qt_trak *trak, color_index = _X_BE_16(&trak_atom[atom_pos + 0x5A + j * 8]); if (color_count & 0x8000) color_index = j; - if (color_index < + if (color_index < trak->stsd_atoms[k].video.palette_count) { trak->stsd_atoms[k].video.palette[color_index].r = trak_atom[atom_pos + 0x5A + j * 8 + 2]; @@ -1131,7 +1131,7 @@ static qt_error parse_trak_atom (qt_trak *trak, /* copy the properties atom */ trak->stsd_atoms[k].audio.properties_atom_size = current_stsd_atom_size - 4; - trak->stsd_atoms[k].audio.properties_atom = + trak->stsd_atoms[k].audio.properties_atom = xine_xmalloc(trak->stsd_atoms[k].audio.properties_atom_size); if (!trak->stsd_atoms[k].audio.properties_atom) { last_error = QT_NO_MEMORY; @@ -1153,12 +1153,12 @@ static qt_error parse_trak_atom (qt_trak *trak, trak->stsd_atoms[k].audio.bits / 8; trak->stsd_atoms[k].audio.samples_per_frame = trak->stsd_atoms[k].audio.channels; - trak->stsd_atoms[k].audio.bytes_per_frame = - trak->stsd_atoms[k].audio.bytes_per_sample * + trak->stsd_atoms[k].audio.bytes_per_frame = + trak->stsd_atoms[k].audio.bytes_per_sample * trak->stsd_atoms[k].audio.samples_per_frame; - trak->stsd_atoms[k].audio.samples_per_packet = + trak->stsd_atoms[k].audio.samples_per_packet = trak->stsd_atoms[k].audio.samples_per_frame; - trak->stsd_atoms[k].audio.bytes_per_packet = + trak->stsd_atoms[k].audio.bytes_per_packet = trak->stsd_atoms[k].audio.bytes_per_sample; /* special case time: A lot of CBR audio codecs stored in the @@ -1166,7 +1166,7 @@ static qt_error parse_trak_atom (qt_trak *trak, if (trak->stsd_atoms[k].audio.codec_fourcc == IMA4_FOURCC) { trak->stsd_atoms[k].audio.samples_per_packet = 64; trak->stsd_atoms[k].audio.bytes_per_packet = 34; - trak->stsd_atoms[k].audio.bytes_per_frame = 34 * + trak->stsd_atoms[k].audio.bytes_per_frame = 34 * trak->stsd_atoms[k].audio.channels; trak->stsd_atoms[k].audio.bytes_per_sample = 2; trak->stsd_atoms[k].audio.samples_per_frame = 64 * @@ -1182,7 +1182,7 @@ static qt_error parse_trak_atom (qt_trak *trak, } else if (trak->stsd_atoms[k].audio.codec_fourcc == MAC6_FOURCC) { trak->stsd_atoms[k].audio.samples_per_packet = 6; trak->stsd_atoms[k].audio.bytes_per_packet = 1; - trak->stsd_atoms[k].audio.bytes_per_frame = 1 * + trak->stsd_atoms[k].audio.bytes_per_frame = 1 * trak->stsd_atoms[k].audio.channels; trak->stsd_atoms[k].audio.bytes_per_sample = 1; trak->stsd_atoms[k].audio.samples_per_frame = 6 * @@ -1190,7 +1190,7 @@ static qt_error parse_trak_atom (qt_trak *trak, } else if (trak->stsd_atoms[k].audio.codec_fourcc == ALAW_FOURCC) { trak->stsd_atoms[k].audio.samples_per_packet = 1; trak->stsd_atoms[k].audio.bytes_per_packet = 1; - trak->stsd_atoms[k].audio.bytes_per_frame = 1 * + trak->stsd_atoms[k].audio.bytes_per_frame = 1 * trak->stsd_atoms[k].audio.channels; trak->stsd_atoms[k].audio.bytes_per_sample = 2; trak->stsd_atoms[k].audio.samples_per_frame = 2 * @@ -1198,7 +1198,7 @@ static qt_error parse_trak_atom (qt_trak *trak, } else if (trak->stsd_atoms[k].audio.codec_fourcc == ULAW_FOURCC) { trak->stsd_atoms[k].audio.samples_per_packet = 1; trak->stsd_atoms[k].audio.bytes_per_packet = 1; - trak->stsd_atoms[k].audio.bytes_per_frame = 1 * + trak->stsd_atoms[k].audio.bytes_per_frame = 1 * trak->stsd_atoms[k].audio.channels; trak->stsd_atoms[k].audio.bytes_per_sample = 2; trak->stsd_atoms[k].audio.samples_per_frame = 2 * @@ -1217,20 +1217,20 @@ static qt_error parse_trak_atom (qt_trak *trak, (trak->stsd_atoms[k].audio.codec_fourcc != RAW_FOURCC)) { if (_X_BE_32(&trak_atom[atom_pos + 0x20])) - trak->stsd_atoms[k].audio.samples_per_packet = + trak->stsd_atoms[k].audio.samples_per_packet = _X_BE_32(&trak_atom[atom_pos + 0x20]); if (_X_BE_32(&trak_atom[atom_pos + 0x24])) - trak->stsd_atoms[k].audio.bytes_per_packet = + trak->stsd_atoms[k].audio.bytes_per_packet = _X_BE_32(&trak_atom[atom_pos + 0x24]); if (_X_BE_32(&trak_atom[atom_pos + 0x28])) - trak->stsd_atoms[k].audio.bytes_per_frame = + trak->stsd_atoms[k].audio.bytes_per_frame = _X_BE_32(&trak_atom[atom_pos + 0x28]); if (_X_BE_32(&trak_atom[atom_pos + 0x2C])) - trak->stsd_atoms[k].audio.bytes_per_sample = + trak->stsd_atoms[k].audio.bytes_per_sample = _X_BE_32(&trak_atom[atom_pos + 0x2C]); if (trak->stsd_atoms[k].audio.bytes_per_packet) trak->stsd_atoms[k].audio.samples_per_frame = - (trak->stsd_atoms[k].audio.bytes_per_frame / + (trak->stsd_atoms[k].audio.bytes_per_frame / trak->stsd_atoms[k].audio.bytes_per_packet) * trak->stsd_atoms[k].audio.samples_per_packet; } @@ -1252,13 +1252,13 @@ static qt_error parse_trak_atom (qt_trak *trak, trak->stsd_atoms[k].audio.vbr = 1; /* further, FFmpeg's ALAC decoder requires 36 out-of-band bytes */ trak->stsd_atoms[k].audio.properties_atom_size = 36; - trak->stsd_atoms[k].audio.properties_atom = + trak->stsd_atoms[k].audio.properties_atom = xine_xmalloc(trak->stsd_atoms[k].audio.properties_atom_size); if (!trak->stsd_atoms[k].audio.properties_atom) { last_error = QT_NO_MEMORY; goto free_trak; } - memcpy(trak->stsd_atoms[k].audio.properties_atom, + memcpy(trak->stsd_atoms[k].audio.properties_atom, &trak_atom[atom_pos + 0x20], trak->stsd_atoms[k].audio.properties_atom_size); } @@ -1274,7 +1274,7 @@ static qt_error parse_trak_atom (qt_trak *trak, (_X_BE_32(&trak_atom[atom_pos + 0x3C]) == FRMA_ATOM) && (_X_ME_32(&trak_atom[atom_pos + 0x48]) == trak->stsd_atoms[k].audio.codec_fourcc)) { int wave_size = _X_BE_32(&trak_atom[atom_pos + 0x44]) - 8; - + if ((wave_size >= sizeof(xine_waveformatex)) && (current_atom_size >= (0x4C + wave_size))) { trak->stsd_atoms[k].audio.wave_size = wave_size; @@ -1331,12 +1331,12 @@ static qt_error parse_trak_atom (qt_trak *trak, } else if (current_atom == ESDS_ATOM) { uint32_t len; - + debug_atom_load(" qt/mpeg-4 esds atom\n"); - if ((trak->type == MEDIA_VIDEO) || + if ((trak->type == MEDIA_VIDEO) || (trak->type == MEDIA_AUDIO)) { - + j = i + 8; if( trak_atom[j++] == 0x03 ) { j += mp4_read_descr_len( &trak_atom[j], &len ); @@ -1368,13 +1368,13 @@ static qt_error parse_trak_atom (qt_trak *trak, } } else if (current_atom == AVCC_ATOM) { - + debug_atom_load(" avcC atom\n"); - + trak->decoder_config_len = current_atom_size - 8; trak->decoder_config = realloc(trak->decoder_config, trak->decoder_config_len); memcpy(trak->decoder_config, &trak_atom[i + 4], trak->decoder_config_len); - + } else if (current_atom == STSZ_ATOM) { /* there should only be one of these atoms */ @@ -1682,9 +1682,9 @@ static qt_error parse_reference_atom (reference_t *ref, /* This is a little support function used to process the edit list when * building a frame table. */ #define MAX_DURATION 0x7FFFFFFFFFFFFFFFLL -static void get_next_edit_list_entry(qt_trak *trak, +static void get_next_edit_list_entry(qt_trak *trak, int *edit_list_index, - unsigned int *edit_list_media_time, + unsigned int *edit_list_media_time, int64_t *edit_list_duration, unsigned int global_timescale) { @@ -1701,9 +1701,9 @@ static void get_next_edit_list_entry(qt_trak *trak, /* otherwise, find an edit list entries whose media time != -1 */ if (trak->edit_list_table[*edit_list_index].media_time != -1) { - *edit_list_media_time = + *edit_list_media_time = trak->edit_list_table[*edit_list_index].media_time; - *edit_list_duration = + *edit_list_duration = trak->edit_list_table[*edit_list_index].track_duration; /* duration is in global timescale units; convert to trak timescale */ @@ -1717,8 +1717,8 @@ static void get_next_edit_list_entry(qt_trak *trak, *edit_list_index = *edit_list_index + 1; } - /* on the way out, check if this is the last edit list entry; if so, - * don't let the duration expire (so set it to an absurdly large value) + /* on the way out, check if this is the last edit list entry; if so, + * don't let the duration expire (so set it to an absurdly large value) */ if (*edit_list_index == trak->edit_list_count) *edit_list_duration = MAX_DURATION; @@ -1753,7 +1753,7 @@ static qt_error build_frame_table(qt_trak *trak, /* AUDIO and OTHER frame types follow the same rules; VIDEO and vbr audio * frame types follow a different set */ - if ((trak->type == MEDIA_VIDEO) || + if ((trak->type == MEDIA_VIDEO) || (trak->properties->audio.vbr)) { /* in this case, the total number of frames is equal to the number of @@ -1803,7 +1803,7 @@ static qt_error build_frame_table(qt_trak *trak, trak->stsd_atoms_count); trak->frames[frame_counter].media_id = 0; } else { - trak->frames[frame_counter].media_id = + trak->frames[frame_counter].media_id = trak->sample_to_chunk_table[i].media_id; media_id_counts[trak->sample_to_chunk_table[i].media_id - 1]++; } @@ -1863,11 +1863,11 @@ static qt_error build_frame_table(qt_trak *trak, debug_edit_list(" %d: (before) pts = %"PRId64"...", i, trak->frames[i].pts); - if (trak->frames[i].pts < edit_list_media_time) + if (trak->frames[i].pts < edit_list_media_time) trak->frames[i].pts = edit_list_pts_counter; else { if (i < trak->frame_count - 1) - frame_duration = + frame_duration = (trak->frames[i + 1].pts - trak->frames[i].pts); debug_edit_list("duration = %"PRId64"...", frame_duration); @@ -1946,7 +1946,7 @@ static qt_error build_frame_table(qt_trak *trak, trak->stsd_atoms_count); trak->frames[j].media_id = 0; } else { - trak->frames[j].media_id = + trak->frames[j].media_id = trak->sample_to_chunk_table[i].media_id; } @@ -2011,10 +2011,10 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom, /* create a new trak structure */ info->trak_count++; - info->traks = (qt_trak *)realloc(info->traks, + info->traks = (qt_trak *)realloc(info->traks, info->trak_count * sizeof(qt_trak)); - info->last_error = parse_trak_atom (&info->traks[info->trak_count - 1], + info->last_error = parse_trak_atom (&info->traks[info->trak_count - 1], &moov_atom[i - 4]); if (info->last_error != QT_OK) { info->trak_count--; @@ -2123,11 +2123,11 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom, /* iterate through 1..n-1 reference entries and decide on the right one */ for (i = 1; i < info->reference_count; i++) { - if (info->references[i].qtim_version > + if (info->references[i].qtim_version > info->references[info->chosen_reference].qtim_version) info->chosen_reference = i; else if ((info->references[i].data_rate <= bandwidth) && - (info->references[i].data_rate > + (info->references[i].data_rate > info->references[info->chosen_reference].data_rate)) info->chosen_reference = i; } @@ -2211,7 +2211,7 @@ static qt_error open_qt_file(qt_info *info, input_plugin_t *input, info->last_error = QT_FILE_READ_ERROR; return info->last_error; } - if (input->read(input, moov_atom, moov_atom_size) != + if (input->read(input, moov_atom, moov_atom_size) != moov_atom_size) { free(moov_atom); info->last_error = QT_FILE_READ_ERROR; @@ -2342,12 +2342,12 @@ static int demux_qt_send_chunk(demux_plugin_t *this_gen) { /* if audio is present, send pts of current audio frame, otherwise * send current video frame pts */ if (audio_trak) - _x_demux_control_newpts(this->stream, - audio_trak->frames[audio_trak->current_frame].pts, + _x_demux_control_newpts(this->stream, + audio_trak->frames[audio_trak->current_frame].pts, BUF_FLAG_SEEK); else - _x_demux_control_newpts(this->stream, - video_trak->frames[video_trak->current_frame].pts, + _x_demux_control_newpts(this->stream, + video_trak->frames[video_trak->current_frame].pts, BUF_FLAG_SEEK); } @@ -2454,7 +2454,7 @@ static int demux_qt_send_chunk(demux_plugin_t *this_gen) { frame_duration); debug_video_demux(" qt: sending off video frame %d from offset 0x%"PRIX64", %d bytes, media id %d, %"PRId64" pts\n", - i, + i, video_trak->frames[i].offset, video_trak->frames[i].size, video_trak->frames[i].media_id, @@ -2512,7 +2512,7 @@ static int demux_qt_send_chunk(demux_plugin_t *this_gen) { SEEK_SET); debug_audio_demux(" qt: sending off audio frame %d from offset 0x%"PRIX64", %d bytes, media id %d, %"PRId64" pts\n", - i, + i, audio_trak->frames[i].offset, audio_trak->frames[i].size, audio_trak->frames[i].media_id, @@ -2531,8 +2531,8 @@ static int demux_qt_send_chunk(demux_plugin_t *this_gen) { * turns around and sends out audio buffers as soon as they are * received. If 2 or more consecutive audio buffers are dispatched to * the audio out unit, the engine will compensate with pops. */ - if ((buf->type == BUF_AUDIO_LPCM_BE) || - (buf->type == BUF_AUDIO_LPCM_LE)) { + if ((buf->type == BUF_AUDIO_LPCM_BE) || + (buf->type == BUF_AUDIO_LPCM_LE)) { if (first_buf) { buf->extra_info->input_time = audio_trak->frames[i].pts / 90; buf->pts = audio_trak->frames[i].pts; @@ -2561,7 +2561,7 @@ static int demux_qt_send_chunk(demux_plugin_t *this_gen) { /* Special case alert: If this is signed, 8-bit data, transform * the data to unsigned. */ - if ((audio_trak->properties->audio.bits == 8) && + if ((audio_trak->properties->audio.bits == 8) && ((audio_trak->properties->audio.codec_fourcc == TWOS_FOURCC) || (audio_trak->properties->audio.codec_fourcc == SOWT_FOURCC))) for (j = 0; j < buf->size; j++) @@ -2630,7 +2630,7 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { this->bih.biBitCount = video_trak->properties->video.depth; this->bih.biCompression = video_trak->properties->video.codec_fourcc; - video_trak->properties->video.codec_buftype = + video_trak->properties->video.codec_buftype = _x_fourcc_to_buf_video(this->bih.biCompression); /* hack: workaround a fourcc clash! 'mpg4' is used by MS and Sorenson @@ -2638,13 +2638,13 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { */ if( video_trak->properties->video.codec_buftype == BUF_VIDEO_MSMPEG4_V1 ) video_trak->properties->video.codec_buftype = BUF_VIDEO_MPEG4; - - if( !video_trak->properties->video.codec_buftype && + + if( !video_trak->properties->video.codec_buftype && video_trak->properties->video.codec_fourcc ) video_trak->properties->video.codec_buftype = BUF_VIDEO_UNKNOWN; _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); - _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, + _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, this->bih.biWidth); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, this->bih.biHeight); @@ -2677,7 +2677,7 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { break; } } else { - audio_trak->properties->audio.codec_buftype = + audio_trak->properties->audio.codec_buftype = _x_formattag_to_buf_audio(audio_trak->properties->audio.codec_fourcc); } @@ -2692,7 +2692,7 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { audio_trak->properties->audio.sample_rate); _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS, audio_trak->properties->audio.bits); - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, audio_trak->properties->audio.codec_fourcc); } else { @@ -2733,17 +2733,17 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { (video_trak->properties->video.codec_buftype)) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END; - + memcpy(buf->content, &this->bih, sizeof(this->bih)); buf->size = sizeof(this->bih); buf->type = video_trak->properties->video.codec_buftype; this->video_fifo->put (this->video_fifo, buf); - + /* send header info to decoder. some mpeg4 streams need this */ if( video_trak->decoder_config ) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = video_trak->properties->video.codec_buftype; - + if (video_trak->properties->video.codec_fourcc == AVC1_FOURCC) { buf->size = 0; buf->decoder_flags = BUF_FLAG_SPECIAL|BUF_FLAG_HEADER; @@ -2787,9 +2787,9 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { /* set the audio bitrate field (only for CBR audio) */ if (!audio_trak->properties->audio.vbr) { - audio_bitrate = + audio_bitrate = audio_trak->properties->audio.sample_rate / - audio_trak->properties->audio.samples_per_frame * + audio_trak->properties->audio.samples_per_frame * audio_trak->properties->audio.bytes_per_frame * audio_trak->properties->audio.channels * 8; @@ -2804,7 +2804,7 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { buf->decoder_info[1] = audio_trak->properties->audio.sample_rate; buf->decoder_info[2] = audio_trak->properties->audio.bits; buf->decoder_info[3] = audio_trak->properties->audio.channels; - + if( audio_trak->properties->audio.wave_size ) { if( audio_trak->properties->audio.wave_size > buf->max_size ) buf->size = buf->max_size; @@ -2815,9 +2815,9 @@ static void demux_qt_send_headers(demux_plugin_t *this_gen) { buf->size = 0; buf->content = NULL; } - + this->audio_fifo->put (this->audio_fifo, buf); - + if( audio_trak->decoder_config ) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = audio_trak->properties->audio.codec_buftype; @@ -2910,7 +2910,7 @@ static int demux_qt_seek (demux_plugin_t *this_gen, qt_trak *video_trak = NULL; qt_trak *audio_trak = NULL; int64_t keyframe_pts; - + start_pos = (off_t) ( (double) start_pos / 65535 * this->data_size ); @@ -3171,7 +3171,7 @@ static const demuxer_info_t demux_info_qt = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "quicktime", XINE_VERSION_CODE, &demux_info_qt, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_rawdv.c b/src/demuxers/demux_rawdv.c index d95fc9125..968542057 100644 --- a/src/demuxers/demux_rawdv.c +++ b/src/demuxers/demux_rawdv.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -89,17 +89,17 @@ static int demux_raw_dv_next (demux_raw_dv_t *this) { /* TODO: duplicate data and send to audio fifo. * however we don't have dvaudio decoder yet. */ - + buf->pts = this->pts; buf->extra_info->input_time = this->pts/90; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->extra_info->frame_number = this->cur_frame; buf->type = BUF_VIDEO_DV; - + this->video_fifo->put(this->video_fifo, buf); - + if (this->audio_fifo) { abuf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); abuf->content = abuf->mem; @@ -213,11 +213,11 @@ static void demux_raw_dv_send_headers (demux_plugin_t *this_gen) { bih->biSizeImage = bih->biWidth*bih->biHeight; this->video_fifo->put(this->video_fifo, buf); - + this->pts = 0; this->cur_frame = 0; this->bytes_left = this->frame_size; - + this->status = DEMUX_OK; _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); @@ -305,18 +305,18 @@ static int demux_raw_dv_seek (demux_plugin_t *this_gen, /* Upcast start_time in case sizeof(off_t) > sizeof(int) */ start_pos = ((off_t) start_time * 90 / this->duration) * this->frame_size; } - - start_pos = start_pos - (start_pos % this->frame_size); + + start_pos = start_pos - (start_pos % this->frame_size); this->input->seek(this->input, start_pos, SEEK_SET); this->cur_frame = start_pos / this->frame_size; this->pts = this->cur_frame * this->duration; this->bytes_left = this->frame_size; - + _x_demux_flush_engine (this->stream); _x_demux_control_newpts (this->stream, this->pts, BUF_FLAG_SEEK); - + this->status = DEMUX_OK; return this->status; } @@ -368,7 +368,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str case METHOD_BY_CONTENT: { uint8_t buf[8]; - + if (_x_demux_read_header(input, buf, 8) != 8) { free (this); return NULL; diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 774c74e2c..340083221 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -26,9 +26,9 @@ * * video packet sub-demuxer ported from mplayer code (www.mplayerhq.hu): * Real parser & demuxer - * + * * (C) Alex Beregszaszi <alex@naxine.org> - * + * * Based on FFmpeg's libav/rm.c. */ @@ -111,10 +111,10 @@ typedef struct { uint32_t fourcc; uint32_t buf_type; uint32_t format; - + real_index_entry_t *index; int index_entries; - + mdpr_t *mdpr; int sps, cfs, w, h; int block_align; @@ -159,7 +159,7 @@ typedef struct { int64_t last_pts[2]; int send_newpts; int buf_flag_seek; - + uint32_t last_ts; uint32_t next_ts; int last_seq; @@ -184,7 +184,7 @@ static void real_parse_index(demux_real_t *this) { unsigned char index_chunk_header[INDEX_CHUNK_HEADER_SIZE]; unsigned char index_record[INDEX_RECORD_SIZE]; int i; - + while(next_index_chunk) { lprintf("reading index chunk at %"PRIX64"\n", next_index_chunk); @@ -242,7 +242,7 @@ static void real_parse_index(demux_real_t *this) { if(index && entries) /* Allocate memory for index */ *index = calloc(entries, sizeof(real_index_entry_t)); - + if(index && entries && *index) { /* Read index */ for(i = 0; i < entries; i++) { @@ -357,7 +357,7 @@ static void real_parse_audio_specific_data (demux_real_t *this, const uint16_t codec_data_length = _X_BE_16 (data+40); const uint16_t coded_frame_size2 = _X_BE_16 (data+42); const uint16_t subpacket_size = _X_BE_16 (data+44); - + stream->sps = subpacket_size; stream->w = coded_frame_size2; stream->h = codec_data_length; @@ -382,7 +382,7 @@ static void real_parse_audio_specific_data (demux_real_t *this, break; default: - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: error, i don't handle buf type 0x%08x\n", stream->buf_type); } @@ -425,12 +425,12 @@ static void real_parse_headers (demux_real_t *this) { uint8_t signature[REAL_SIGNATURE_SIZE]; if (this->input->read(this->input, signature, REAL_SIGNATURE_SIZE) != REAL_SIGNATURE_SIZE) { - + lprintf ("signature not read\n"); this->status = DEMUX_FINISHED; return; } - + if ( !_x_is_fourcc(signature, ".RMF") ) { this->status = DEMUX_FINISHED; lprintf ("signature not found '%.4s'\n", signature); @@ -480,11 +480,11 @@ static void real_parse_headers (demux_real_t *this) { this->status = DEMUX_FINISHED; return; } - + uint16_t version = _X_BE_16(&chunk_buffer[0]); if (chunk_type == PROP_TAG) { - + if(version != 0) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demuxe_real: unknown object version in PROP: 0x%04x\n", version); @@ -516,7 +516,7 @@ static void real_parse_headers (demux_real_t *this) { free(chunk_buffer); continue; } - + mdpr_t *const mdpr = real_parse_mdpr (chunk_buffer, chunk_size); lprintf ("parsing type specific data...\n"); @@ -541,7 +541,7 @@ static void real_parse_headers (demux_real_t *this) { "demux_real: maximum number of audio stream exceeded\n"); goto unknown; } - + const uint16_t version = _X_BE_16(mdpr->type_specific_data + 4); lprintf("audio version %d detected\n", version); @@ -549,7 +549,7 @@ static void real_parse_headers (demux_real_t *this) { char *fourcc_ptr = "\0\0\0"; switch(version) { case 3: - /* Version 3 header stores fourcc after meta info - cheat by reading backwards from the + /* Version 3 header stores fourcc after meta info - cheat by reading backwards from the * end of the header instead of having to parse it all */ if (mdpr->type_specific_len >= 5) fourcc_ptr = mdpr->type_specific_data + mdpr->type_specific_len - 5; @@ -591,7 +591,7 @@ static void real_parse_headers (demux_real_t *this) { "demux_real: maximum number of video stream exceeded\n"); goto unknown; } - + lprintf ("video detected\n"); const uint32_t fourcc = _X_ME_32(mdpr->type_specific_data + 8); lprintf("fourcc = %.4s\n", (char *) &fourcc); @@ -632,7 +632,7 @@ static void real_parse_headers (demux_real_t *this) { /* load the title string */ SET_METADATA_STRING(XINE_META_INFO_TITLE); - + /* load the author string */ SET_METADATA_STRING(XINE_META_INFO_ARTIST); @@ -650,12 +650,12 @@ static void real_parse_headers (demux_real_t *this) { case DATA_TAG: { uint8_t data_chunk_header[DATA_CHUNK_HEADER_SIZE]; - if (this->input->read(this->input, data_chunk_header, + if (this->input->read(this->input, data_chunk_header, DATA_CHUNK_HEADER_SIZE) != DATA_CHUNK_HEADER_SIZE) { this->status = DEMUX_FINISHED; return ; } - + /* check version */ const uint16_t version = _X_BE_16(&data_chunk_header[0]); if(version != 0) { @@ -683,11 +683,11 @@ static void real_parse_headers (demux_real_t *this) { /* Read index tables */ if(INPUT_IS_SEEKABLE(this->input)) real_parse_index(this); - + /* Simple stream selection case - 0/1 audio/video streams */ this->video_stream = (this->num_video_streams == 1) ? &this->video_streams[0] : NULL; this->audio_stream = (this->num_audio_streams == 1) ? &this->audio_streams[0] : NULL; - + /* In the case of multiple audio/video streams select the first streams found in the file */ if((this->num_video_streams > 1) || (this->num_audio_streams > 1)) { @@ -698,23 +698,23 @@ static void real_parse_headers (demux_real_t *this) { /* Get data to search through for stream chunks */ if(INPUT_IS_SEEKABLE(this->input)) { original_pos = this->input->get_current_pos(this->input); - + if((len = this->input->read(this->input, search_buffer, MAX_PREVIEW_SIZE)) <= 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read header\n"); this->status = DEMUX_FINISHED; return; } - + offset = 0; } else if((this->input->get_capabilities(this->input) & INPUT_CAP_PREVIEW) != 0) { if((len = this->input->get_optional_data(this->input, search_buffer, INPUT_OPTIONAL_DATA_PREVIEW)) <= 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read header\n"); this->status = DEMUX_FINISHED; return; } - + /* Preview data starts at the beginning of the file */ offset = this->data_start + 18; } else { @@ -723,16 +723,16 @@ static void real_parse_headers (demux_real_t *this) { this->status = DEMUX_FINISHED; return; } - + while((offset < len) && ((!this->video_stream && (this->num_video_streams > 0)) || (!this->audio_stream && (this->num_audio_streams > 0)))) { int i; - + /* Check for end of the data chunk */ if (_x_is_fourcc(&search_buffer[offset], "INDX") || _x_is_fourcc(&search_buffer[offset], "DATA")) break; - + const int stream = _X_BE_16(&search_buffer[offset + 4]); for(i = 0; !this->video_stream && (i < this->num_video_streams); i++) { @@ -741,7 +741,7 @@ static void real_parse_headers (demux_real_t *this) { lprintf("selecting video stream: %d\n", stream); } } - + for(i = 0; !this->audio_stream && (i < this->num_audio_streams); i++) { if(stream == this->audio_streams[i].mdpr->stream_number) { this->audio_stream = &this->audio_streams[i]; @@ -751,11 +751,11 @@ static void real_parse_headers (demux_real_t *this) { offset += _X_BE_16(&search_buffer[offset + 2]); } - + if(INPUT_IS_SEEKABLE(this->input)) this->input->seek(this->input, original_pos, SEEK_SET); } - + /* Let the user know if we haven't managed to detect what streams to play */ if((!this->video_stream && this->num_video_streams) || (!this->audio_stream && this->num_audio_streams)) { @@ -764,17 +764,17 @@ static void real_parse_headers (demux_real_t *this) { this->status = DEMUX_FINISHED; return; } - + /* Send headers and set meta info */ if(this->video_stream) { /* Check for recognised codec*/ if(!this->video_stream->buf_type) this->video_stream->buf_type = BUF_VIDEO_UNKNOWN; - + /* Send header */ buf_element_t *const buf = this->video_fifo->buffer_pool_alloc(this->video_fifo); buf->content = buf->mem; - + memcpy(buf->content, this->video_stream->mdpr->type_specific_data, this->video_stream->mdpr->type_specific_len); @@ -792,7 +792,7 @@ static void real_parse_headers (demux_real_t *this) { this->video_stream->fourcc); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_BITRATE, this->video_stream->mdpr->avg_bit_rate); - + /* Allocate fragment offset table */ this->fragment_tab = calloc(FRAGMENT_TAB_SIZE, sizeof(uint32_t)); this->fragment_tab_max = FRAGMENT_TAB_SIZE; @@ -802,7 +802,7 @@ static void real_parse_headers (demux_real_t *this) { /* Check for recognised codec */ if(!this->audio_stream->buf_type) this->audio_stream->buf_type = BUF_AUDIO_UNKNOWN; - + /* Send headers */ if(this->audio_fifo) { mdpr_t *const mdpr = this->audio_stream->mdpr; @@ -811,21 +811,21 @@ static void real_parse_headers (demux_real_t *this) { buf->type = this->audio_stream->buf_type; buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_FRAME_END; - + /* For AAC we send two header buffers, the first is a standard audio * header giving bits per sample, sample rate and number of channels. * The second is the codec initialisation data found at the end of * the type specific data for the audio stream */ if(buf->type == BUF_AUDIO_AAC) { const uint16_t version = _X_BE_16(mdpr->type_specific_data + 4); - + if(version != 5) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: unsupported audio header version for AAC: %d\n", version); buf->free_buffer(buf); goto unsupported; } - + buf->decoder_info[1] = _X_BE_16(mdpr->type_specific_data + 54); buf->decoder_info[2] = _X_BE_16(mdpr->type_specific_data + 58); buf->decoder_info[3] = _X_BE_16(mdpr->type_specific_data + 60); @@ -833,18 +833,18 @@ static void real_parse_headers (demux_real_t *this) { buf->decoder_flags |= BUF_FLAG_STDHEADER; buf->content = NULL; buf->size = 0; - + this->audio_fifo->put (this->audio_fifo, buf); - + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - + buf->type = this->audio_stream->buf_type; buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_FRAME_END|BUF_FLAG_SPECIAL; buf->decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG; buf->decoder_info[2] = _X_BE_32(mdpr->type_specific_data + 74) - 1; buf->decoder_info_ptr[2] = buf->content; buf->size = 0; - + memcpy(buf->content, mdpr->type_specific_data + 79, buf->decoder_info[2]); @@ -892,7 +892,7 @@ static int demux_real_parse_references( demux_real_t *this) { lprintf("parsing references\n"); - + /* read file to memory. * warning: dumb code, but hopefuly ok since reference file is small */ do { @@ -911,7 +911,7 @@ static int demux_real_parse_references( demux_real_t *this) { if(buf_used) buf[buf_used] = '\0'; - + lprintf("received %d bytes [%s]\n", buf_used, buf); if (!strncmp(buf,"http://",7)) @@ -945,10 +945,10 @@ static int demux_real_parse_references( demux_real_t *this) { /* rpm files can contain comments which should be skipped */ if( !strncmp(&buf[i],"<!--",4) ) comment = 1; - + if( !strncmp(&buf[i],"-->",3) ) comment = 0; - + if( (!strncmp(&buf[i],"pnm://",6) || !strncmp(&buf[i],"rtsp://",7)) && !comment ) { for(j=i; buf[j] && buf[j] != '"' && !isspace(buf[j]); j++ ) @@ -961,14 +961,14 @@ static int demux_real_parse_references( demux_real_t *this) { i = j; } - } - + } + free(buf); - + this->status = DEMUX_FINISHED; return this->status; } - + /* redefine abs as macro to handle 64-bit diffs. i guess llabs may not be available everywhere */ #define abs(x) ( ((x)<0) ? -(x) : (x) ) @@ -1004,7 +1004,7 @@ static uint32_t real_fix_timestamp (demux_real_t *this, uint8_t *hdr, uint32_t t int pict_type; int seq; uint32_t ts_out; - + switch(this->video_stream->buf_type) { case BUF_VIDEO_RV20: pict_type = (hdr[0] & 0xC0) >> 6; @@ -1019,35 +1019,35 @@ static uint32_t real_fix_timestamp (demux_real_t *this, uint8_t *hdr, uint32_t t seq = ((hdr[1] & 0x07) << 10) + (hdr[2] << 2) + ((hdr[3] & 0xC0) >> 6); break; default: - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_real: can't fix timestamp for buf type 0x%08x\n", + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_real: can't fix timestamp for buf type 0x%08x\n", this->video_stream->buf_type); return ts_in; break; } - + switch (pict_type) { case 0: - case 1: + case 1: /* I frame */ ts_out = this->next_ts; - + this->last_ts = this->next_ts; this->next_ts = ts_in; - + this->last_seq = this->next_seq; this->next_seq = seq; break; case 2: /* P frame */ ts_out = this->next_ts; - + this->last_ts = this->next_ts; if (seq < this->next_seq) this->next_ts += seq + 8192 - this->next_seq; else this->next_ts += seq - this->next_seq; - + this->last_seq = this->next_seq; this->next_seq = seq; break; @@ -1064,8 +1064,8 @@ static uint32_t real_fix_timestamp (demux_real_t *this, uint8_t *hdr, uint32_t t ts_out = 0; break; } - - return ts_out; + + return ts_out; } static int stream_read_char (demux_real_t *this) { @@ -1089,7 +1089,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { if(this->reference_mode) return demux_real_parse_references(this); - + /* load a header from wherever the stream happens to be pointing */ if ( this->input->read(this->input, header, DATA_PACKET_HEADER_SIZE) != DATA_PACKET_HEADER_SIZE) { @@ -1116,14 +1116,14 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { this->status = DEMUX_FINISHED; return this->status; } - + /* read the packet information */ const uint16_t stream = _X_BE_16(&header[4]); const off_t offset __attr_unused = this->input->get_current_pos(this->input); uint16_t size = _X_BE_16(&header[2]) - DATA_PACKET_HEADER_SIZE; const uint32_t timestamp= _X_BE_32(&header[6]); int64_t pts = (int64_t) timestamp * 90; - + /* Data packet header with version 1 contains 1 extra byte */ if(version == 0) keyframe = header[11] & PN_KEYFRAME_FLAG; @@ -1225,22 +1225,22 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { if(this->video_stream->index) input_time = timestamp; else - input_time = (int)((int64_t) this->input->get_current_pos(this->input) + input_time = (int)((int64_t) this->input->get_current_pos(this->input) * 8 * 1000 / this->avg_bitrate); const off_t input_length = this->data_start + 18 + this->data_chunk_size; if( input_length > 18 ) normpos = (int)((double) this->input->get_current_pos(this->input) * 65535 / input_length); - + check_newpts (this, pts, PTS_VIDEO, 0); if (this->fragment_size == 0) { lprintf ("new packet starting\n"); - + /* send fragment offset table */ if(this->fragment_count) { lprintf("sending fragment offset table\n"); - + buf = this->video_fifo->buffer_pool_alloc(this->video_fifo); buf->decoder_flags = BUF_FLAG_SPECIAL | BUF_FLAG_FRAME_END; @@ -1253,18 +1253,18 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { xine_fast_memcpy(buf->decoder_info_ptr[2], this->fragment_tab, this->fragment_count*8); - + this->video_fifo->put(this->video_fifo, buf); - + this->fragment_count = 0; } - + decoder_flags = BUF_FLAG_FRAME_START; } else { lprintf ("continuing packet \n"); decoder_flags = 0; } - + /* add entry to fragment offset table */ this->fragment_tab[2*this->fragment_count] = 1; this->fragment_tab[2*this->fragment_count+1] = this->fragment_size; @@ -1291,30 +1291,30 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { /* * read fragment_size bytes of data */ - + int n = fragment_size; while(n) { buf = this->video_fifo->buffer_pool_alloc(this->video_fifo); - + buf->size = MIN(n, buf->max_size); buf->decoder_flags = decoder_flags; decoder_flags &= ~BUF_FLAG_FRAME_START; - + buf->type = this->video_stream->buf_type; - + if(this->input->read(this->input, buf->content, buf->size) < buf->size) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read video fragment"); buf->free_buffer(buf); this->status = DEMUX_FINISHED; return this->status; } - - /* RV30 and RV40 streams contain some fragments that shouldn't be passed - * to the decoder. The purpose of these fragments is unknown, but - * realplayer doesn't appear to pass them to the decoder either */ - if((n == fragment_size) && + + /* RV30 and RV40 streams contain some fragments that shouldn't be passed + * to the decoder. The purpose of these fragments is unknown, but + * realplayer doesn't appear to pass them to the decoder either */ + if((n == fragment_size) && (((buf->type == BUF_VIDEO_RV30) && (buf->content[0] & 0x20)) || ((buf->type == BUF_VIDEO_RV40) && (buf->content[0] & 0x80)))) { lprintf("ignoring fragment\n"); @@ -1326,12 +1326,12 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { break; } - + /* if the video stream has b-frames fix the timestamps */ if((this->video_stream->format >= 0x20200002) && (buf->decoder_flags & BUF_FLAG_FRAME_START)) pts = (int64_t) real_fix_timestamp(this, buf->content, timestamp) * 90; - + /* this test was moved from ffmpeg video decoder. * fixme: is pts only valid on frame start? */ if( buf->decoder_flags & BUF_FLAG_FRAME_START ) @@ -1339,13 +1339,13 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { else buf->pts = 0; pts = 0; - + buf->extra_info->input_normpos = normpos; buf->extra_info->input_time = input_time; buf->extra_info->total_time = this->duration; - + this->video_fifo->put(this->video_fifo, buf); - + n -= buf->size; } @@ -1370,49 +1370,49 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { goto discard; else this->audio_need_keyframe = 0; - + /* if we have a seekable stream then use the timestamp for the data * packet for more accurate seeking - if not then estimate time using * average bitrate */ if(this->audio_stream->index) input_time = timestamp; else - input_time = (int)((int64_t) this->input->get_current_pos(this->input) - * 8 * 1000 / this->avg_bitrate); - + input_time = (int)((int64_t) this->input->get_current_pos(this->input) + * 8 * 1000 / this->avg_bitrate); + const off_t input_length = this->data_start + 18 + this->data_chunk_size; - + if( input_length > 18 ) normpos = (int)((double) this->input->get_current_pos(this->input) * 65535 / input_length); - + check_newpts (this, pts, PTS_AUDIO, 0); - + /* Each packet of AAC is made up of several AAC frames preceded by a * header defining the size of the frames */ if(this->audio_stream->buf_type == BUF_AUDIO_AAC) { int i; - + /* Upper 4 bits of second byte is frame count */ const int frames = (stream_read_word(this) & 0xf0) >> 4; - + /* 2 bytes per frame size */ int sizes[frames]; for(i = 0; i < frames; i++) sizes[i] = stream_read_word(this); - + for(i = 0; i < frames; i++) { - if(_x_demux_read_send_data(this->audio_fifo, this->input, sizes[i], pts, - this->audio_stream->buf_type, 0, normpos, + if(_x_demux_read_send_data(this->audio_fifo, this->input, sizes[i], pts, + this->audio_stream->buf_type, 0, normpos, input_time, this->duration, 0) < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read AAC frame\n"); this->status = DEMUX_FINISHED; return this->status; } - + pts = 0; /* Only set pts on first frame */ } } else if (this->audio_stream->buf_type == BUF_AUDIO_COOK || @@ -1440,11 +1440,11 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { for (x = 0; x < sph / 2; x++) { pos = x * 2 * w + spc * cfs; if(pos + cfs > fs || this->input->read(this->input, buffer + pos, cfs) < cfs) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read audio chunk\n"); - + this->status = DEMUX_FINISHED; - return this->status; + return this->status; } } break; @@ -1453,22 +1453,22 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { for (x = 0; x < w / sps; x++) { pos = sps * (sph * x + ((sph + 1) / 2) * (spc & 1) + (spc >> 1)); if(pos + sps > fs || this->input->read(this->input, buffer + pos, sps) < sps) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read audio chunk\n"); - + this->status = DEMUX_FINISHED; - return this->status; + return this->status; } } break; case BUF_AUDIO_SIPRO: pos = spc * w; if(pos + w > fs || this->input->read(this->input, buffer + pos, w) < w) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read audio chunk\n"); - + this->status = DEMUX_FINISHED; - return this->status; + return this->status; } if (spc == sph - 1) demux_real_sipro_swap (buffer, sph * w * 2 / 96); @@ -1481,20 +1481,20 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { this->duration, 0); } } else { - if(_x_demux_read_send_data(this->audio_fifo, this->input, size, pts, + if(_x_demux_read_send_data(this->audio_fifo, this->input, size, pts, this->audio_stream->buf_type, 0, normpos, input_time, this->duration, 0) < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read audio chunk\n"); this->status = DEMUX_FINISHED; return this->status; } - + /* FIXME: dp->flags = (flags & 0x2) ? 0x10 : 0; */ } - + } else { /* discard */ @@ -1577,14 +1577,14 @@ static int demux_real_seek (demux_plugin_t *this_gen, demux_real_t *this = (demux_real_t *) this_gen; real_index_entry_t *index, *other_index = NULL; int i = 0, entries; - + lprintf("seek start_pos=%d, start_time=%d, playing=%d\n", (int)start_pos, start_time, playing); if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) && ((this->audio_stream && this->audio_stream->index) || (this->video_stream && this->video_stream->index))) { - + start_pos = (off_t) ( (double) start_pos / 65535 * this->input->get_length (this->input) ); @@ -1632,14 +1632,14 @@ static int demux_real_seek (demux_plugin_t *this_gen, /* RTSP supports only time based seek */ if (start_pos && !start_time) start_time = (int64_t) this->duration * start_pos / 65535; - + this->input->seek_time(this->input, start_time, SEEK_SET); } this->send_newpts = 1; this->old_seqnum = -1; this->fragment_size = 0; - + this->next_ts = 0; this->next_seq = 0; @@ -1656,13 +1656,13 @@ static void demux_real_dispose (demux_plugin_t *this_gen) { real_free_mdpr(this->video_streams[i].mdpr); free(this->video_streams[i].index); } - + for(i = 0; i < this->num_audio_streams; i++) { real_free_mdpr(this->audio_streams[i].mdpr); free(this->audio_streams[i].index); free(this->audio_streams[i].frame_buffer); } - + free(this->fragment_tab); free(this); } @@ -1702,7 +1702,7 @@ static int real_check_stream_type(input_plugin_t *input) if ( len < 4 ) return -1; - + if ( memcmp(buf, "\x2eRMF", 4) == 0 ) return 1; @@ -1730,7 +1730,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str case METHOD_BY_CONTENT: if ( stream_type < 1 ) return NULL; - + lprintf ("by content accepted.\n"); break; @@ -1796,7 +1796,7 @@ static const char *get_mimetypes (demux_class_t *this_gen) { return "audio/x-pn-realaudio: ra, rm, ram: Real Media file;" "audio/x-pn-realaudio-plugin: rpm: Real Media plugin file;" "audio/x-real-audio: ra, rm, ram: Real Media file;" - "application/vnd.rn-realmedia: ra, rm, ram: Real Media file;"; + "application/vnd.rn-realmedia: ra, rm, ram: Real Media file;"; } static void class_dispose (demux_class_t *this_gen) { diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c index 44449667c..3c18f7ec3 100644 --- a/src/demuxers/demux_realaudio.c +++ b/src/demuxers/demux_realaudio.c @@ -63,7 +63,7 @@ typedef struct { off_t data_start; off_t data_size; - + uint32_t cfs; uint16_t w, h; int frame_len; @@ -95,7 +95,7 @@ static int open_ra_file(demux_ra_t *this) { /* read version */ const uint16_t version = _X_BE_16(&file_header[0x04]); - + /* read header size according to version */ if (version == 3) this->header_size = _X_BE_16(&file_header[0x06]) + 8; @@ -105,45 +105,45 @@ static int open_ra_file(demux_ra_t *this) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: unknown version number %d\n", version); return 0; } - + /* allocate for and read header data */ 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"); free(this->header); return 0; } - + off_t offset; /* read header data according to version */ if((version == 3) && (this->header_size >= 32)) { this->data_size = _X_BE_32(&this->header[0x12]); - + this->block_align = 240; - + offset = 0x16; } else if(this->header_size >= 72) { - this->data_size = _X_BE_32(&this->header[0x1C]); - + this->data_size = _X_BE_32(&this->header[0x1C]); + this->block_align = _X_BE_16(&this->header[0x2A]); - + if(this->header[0x3D] == 4) this->fourcc = _X_ME_32(&this->header[0x3E]); else { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: invalid fourcc size %d\n", this->header[0x3D]); free(this->header); return 0; } - + offset = 0x45; } else { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: header too small\n"); free(this->header); return 0; } - + /* Read title */ { const uint8_t len = this->header[offset]; @@ -154,7 +154,7 @@ static int open_ra_file(demux_ra_t *this) { } else offset++; } - + /* Author */ { const uint8_t len = this->header[offset]; @@ -165,7 +165,7 @@ static int open_ra_file(demux_ra_t *this) { } else offset++; } - + /* Copyright/Date */ { const uint8_t len = this->header[offset]; @@ -176,23 +176,23 @@ static int open_ra_file(demux_ra_t *this) { } else offset++; } - + /* Fourcc for version 3 comes after meta info */ if(version == 3) { if (((offset+7) <= this->header_size)) { if(this->header[offset+2] == 4) this->fourcc = _X_ME_32(&this->header[offset+3]); else { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: invalid fourcc size %d\n", this->header[offset+2]); free(this->header); return 0; } } else { - this->fourcc = ME_FOURCC('l', 'p', 'c', 'J'); + this->fourcc = ME_FOURCC('l', 'p', 'c', 'J'); } } - + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, this->fourcc); this->audio_type = _x_formattag_to_buf_audio(this->fourcc); @@ -219,7 +219,7 @@ static int open_ra_file(demux_ra_t *this) { if (this->audio_type == BUF_AUDIO_28_8 || this->audio_type == BUF_AUDIO_SIPRO) this->block_align = this->cfs; } - + /* seek to start of data */ this->data_start = this->header_size; if (this->input->seek(this->input, this->data_start, SEEK_SET) != @@ -242,7 +242,7 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) { /* just load data chunks from wherever the stream happens to be * pointing; issue a DEMUX_FINISHED status if EOF is reached */ if( this->input->get_length (this->input) ) - current_normpos = (int)( (double) (this->input->get_current_pos (this->input) - this->data_start) * + current_normpos = (int)( (double) (this->input->get_current_pos (this->input) - this->data_start) * 65535 / this->data_size ); const int64_t current_pts = 0; /* let the engine sort out the pts for now */ @@ -255,11 +255,11 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) { if (this->audio_type == BUF_AUDIO_28_8 || this->audio_type == BUF_AUDIO_SIPRO) { if (this->audio_type == BUF_AUDIO_SIPRO) { if(this->input->read(this->input, this->frame_buffer, this->frame_len) < this->frame_len) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: failed to read audio chunk\n"); - + this->status = DEMUX_FINISHED; - return this->status; + return this->status; } demux_real_sipro_swap (this->frame_buffer, this->frame_len * 2 / 96); } else { @@ -270,25 +270,25 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) { const int pos = x * 2 * this->w + y * this->cfs; if(this->input->read(this->input, this->frame_buffer + pos, this->cfs) < this->cfs) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: failed to read audio chunk\n"); - + this->status = DEMUX_FINISHED; - return this->status; + return this->status; } } } _x_demux_send_data(this->audio_fifo, - this->frame_buffer, this->frame_size, + this->frame_buffer, this->frame_size, current_pts, this->audio_type, 0, current_normpos, current_pts / 90, 0, 0); - } else if(_x_demux_read_send_data(this->audio_fifo, this->input, this->block_align, - current_pts, this->audio_type, 0, current_normpos, + } else if(_x_demux_read_send_data(this->audio_fifo, this->input, this->block_align, + current_pts, this->audio_type, 0, current_normpos, current_pts / 90, 0, 0) < 0) { - this->status = DEMUX_FINISHED; + this->status = DEMUX_FINISHED; } - + return this->status; } @@ -314,9 +314,9 @@ static void demux_ra_send_headers(demux_plugin_t *this_gen) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = this->audio_type; buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_FRAME_END; - + buf->size = MIN(this->header_size, buf->max_size); - + memcpy(buf->content, this->header, buf->size); this->audio_fifo->put (this->audio_fifo, buf); @@ -364,7 +364,7 @@ static int demux_ra_seek (demux_plugin_t *this_gen, static void demux_ra_dispose (demux_plugin_t *this_gen) { demux_ra_t *this = (demux_ra_t *) this_gen; - + if(this->header) free(this->header); if (this->frame_buffer) @@ -439,7 +439,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str } break; - + default: free (this); return NULL; diff --git a/src/demuxers/demux_roq.c b/src/demuxers/demux_roq.c index df2fb76a5..346d487aa 100644 --- a/src/demuxers/demux_roq.c +++ b/src/demuxers/demux_roq.c @@ -92,11 +92,11 @@ static int open_roq_file(demux_roq_t *this) { return 0; /* check for the RoQ magic numbers */ - static const uint8_t RoQ_MAGIC_STRING[] = + static const uint8_t RoQ_MAGIC_STRING[] = { 0x10, 0x84, 0xFF, 0xFF, 0xFF, 0xFF }; if( memcmp(preamble, RoQ_MAGIC_STRING, sizeof(RoQ_MAGIC_STRING)) != 0 ) return 0; - + this->bih.biSize = sizeof(xine_bmiheader); this->bih.biWidth = this->bih.biHeight = 0; this->wave.nChannels = 0; /* assume no audio at first */ @@ -119,7 +119,7 @@ static int open_roq_file(demux_roq_t *this) { while (i-- > 0) { /* if this read fails, then maybe it's just a really small RoQ file * (even less than 2 seconds) */ - if (this->input->read(this->input, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != + if (this->input->read(this->input, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE) break; chunk_type = _X_LE_16(&preamble[0]); @@ -181,7 +181,7 @@ static int demux_roq_send_chunk(demux_plugin_t *this_gen) { off_t current_file_pos; /* fetch the next preamble */ - if (this->input->read(this->input, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != + if (this->input->read(this->input, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE) { this->status = DEMUX_FINISHED; return this->status; @@ -193,21 +193,21 @@ static int demux_roq_send_chunk(demux_plugin_t *this_gen) { if ((chunk_type == RoQ_SOUND_MONO) || (chunk_type == RoQ_SOUND_STEREO)) { if( this->audio_fifo ) { - + /* do this calculation carefully because I can't trust the * 64-bit numerical manipulation */ audio_pts = this->audio_byte_count; audio_pts *= 90000; audio_pts /= (RoQ_AUDIO_SAMPLE_RATE * this->wave.nChannels); this->audio_byte_count += chunk_size - 8; /* do not count the preamble */ - + current_file_pos = this->input->get_current_pos(this->input); /* send out the preamble */ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_ROQ; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) (current_file_pos - RoQ_CHUNK_PREAMBLE_SIZE) * + buf->extra_info->input_normpos = (int)( (double) (current_file_pos - RoQ_CHUNK_PREAMBLE_SIZE) * 65535 / this->input->get_length (this->input) ); buf->pts = 0; buf->size = RoQ_CHUNK_PREAMBLE_SIZE; @@ -219,7 +219,7 @@ static int demux_roq_send_chunk(demux_plugin_t *this_gen) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_ROQ; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) current_file_pos * + buf->extra_info->input_normpos = (int)( (double) current_file_pos * 65535 / this->input->get_length (this->input) ); buf->pts = audio_pts; @@ -256,7 +256,7 @@ static int demux_roq_send_chunk(demux_plugin_t *this_gen) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_VIDEO_ROQ; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) (current_file_pos - RoQ_CHUNK_PREAMBLE_SIZE) * + buf->extra_info->input_normpos = (int)( (double) (current_file_pos - RoQ_CHUNK_PREAMBLE_SIZE) * 65535 / this->input->get_length (this->input) ); buf->pts = this->video_pts_counter; buf->size = RoQ_CHUNK_PREAMBLE_SIZE; @@ -267,7 +267,7 @@ static int demux_roq_send_chunk(demux_plugin_t *this_gen) { buf = this->video_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_VIDEO_ROQ; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) current_file_pos * + buf->extra_info->input_normpos = (int)( (double) current_file_pos * 65535 / this->input->get_length (this->input) ); buf->pts = this->video_pts_counter; diff --git a/src/demuxers/demux_shn.c b/src/demuxers/demux_shn.c index ccc34b57f..b4f7c764b 100644 --- a/src/demuxers/demux_shn.c +++ b/src/demuxers/demux_shn.c @@ -83,7 +83,7 @@ static int demux_shn_send_chunk(demux_plugin_t *this_gen) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_SHORTEN; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); buf->pts = 0; @@ -92,7 +92,7 @@ static int demux_shn_send_chunk(demux_plugin_t *this_gen) { buf->free_buffer(buf); this->status = DEMUX_FINISHED; return this->status; - } else + } else buf->size = bytes_read; /* each buffer stands on its own */ diff --git a/src/demuxers/demux_slave.c b/src/demuxers/demux_slave.c index abb4d01e5..de530f224 100644 --- a/src/demuxers/demux_slave.c +++ b/src/demuxers/demux_slave.c @@ -2,19 +2,19 @@ * Copyright (C) 2000-2003 the xine project * May 2003 - Miguel Freitas * This plugin was sponsored by 1Control - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -51,7 +51,7 @@ #define CHECK_VPTS_INTERVAL 2*90000 #define NETWORK_PREBUFFER 90000 -typedef struct { +typedef struct { demux_plugin_t demux_plugin; xine_stream_t *stream; @@ -86,7 +86,7 @@ static int demux_slave_next (demux_slave_t *this) { char fifo_name[11]; uint8_t *p, *s; int64_t curvpts; - + /* fill the scratch buffer */ n = this->input->read(this->input, &this->scratch[this->scratch_used], SCRATCH_SIZE - this->scratch_used); @@ -433,7 +433,7 @@ static const demuxer_info_t demux_info_slave = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "slave", XINE_VERSION_CODE, &demux_info_slave, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_smjpeg.c b/src/demuxers/demux_smjpeg.c index aacd55503..04a46fa78 100644 --- a/src/demuxers/demux_smjpeg.c +++ b/src/demuxers/demux_smjpeg.c @@ -112,7 +112,7 @@ static int open_smjpeg_file(demux_smjpeg_t *this) { if (this->input->read(this->input, header_chunk, 4) != 4) return 0; this->duration = _X_BE_32(&header_chunk[0]); - + /* initial state: no video and no audio (until headers found) */ this->video_type = this->audio_type = 0; this->input_length = this->input->get_length (this->input); diff --git a/src/demuxers/demux_snd.c b/src/demuxers/demux_snd.c index b98b66758..66e2bd543 100644 --- a/src/demuxers/demux_snd.c +++ b/src/demuxers/demux_snd.c @@ -110,11 +110,11 @@ static int open_snd_file(demux_snd_t *this) { this->audio_bytes_per_second = this->audio_channels * this->audio_sample_rate; break; - + case 2: this->audio_type = BUF_AUDIO_LPCM_BE; this->audio_bits = 8; - this->audio_frames = this->data_size / + this->audio_frames = this->data_size / (this->audio_channels * this->audio_bits / 8); this->audio_block_align = PCM_BLOCK_ALIGN; this->audio_bytes_per_second = this->audio_channels * @@ -124,7 +124,7 @@ static int open_snd_file(demux_snd_t *this) { case 3: this->audio_type = BUF_AUDIO_LPCM_BE; this->audio_bits = 16; - this->audio_frames = this->data_size / + this->audio_frames = this->data_size / (this->audio_channels * this->audio_bits / 8); this->audio_block_align = PCM_BLOCK_ALIGN; this->audio_bytes_per_second = this->audio_channels * @@ -163,7 +163,7 @@ static int demux_snd_send_chunk(demux_plugin_t *this_gen) { /* just load data chunks from wherever the stream happens to be * pointing; issue a DEMUX_FINISHED status if EOF is reached */ remaining_sample_bytes = this->audio_block_align; - current_file_pos = + current_file_pos = this->input->get_current_pos(this->input) - this->data_start; current_pts = current_file_pos; @@ -205,7 +205,7 @@ static int demux_snd_send_chunk(demux_plugin_t *this_gen) { for (i = 0; i < buf->size; i++) buf->content[i] += 0x80; } - + this->audio_fifo->put (this->audio_fifo, buf); } return this->status; @@ -251,11 +251,11 @@ static int demux_snd_seek (demux_plugin_t *this_gen, off_t start_pos, int start_ demux_snd_t *this = (demux_snd_t *) this_gen; start_pos = (off_t) ( (double) start_pos / 65535 * this->data_size ); - + this->seek_flag = 1; this->status = DEMUX_OK; _x_demux_flush_engine (this->stream); - + /* if input is non-seekable, do not proceed with the rest of this * seek function */ if (!INPUT_IS_SEEKABLE(this->input)) @@ -346,7 +346,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str } } /* falling through is intended */ - + case METHOD_BY_CONTENT: case METHOD_EXPLICIT: @@ -380,7 +380,7 @@ static const char *get_extensions (demux_class_t *this_gen) { static const char *get_mimetypes (demux_class_t *this_gen) { return "audio/basic: snd,au: ULAW (Sun) audio;" "audio/x-basic: snd,au: ULAW (Sun) audio;" - "audio/x-pn-au: snd,au: ULAW (Sun) audio;"; + "audio/x-pn-au: snd,au: ULAW (Sun) audio;"; } diff --git a/src/demuxers/demux_str.c b/src/demuxers/demux_str.c index 442bffadc..d88432817 100644 --- a/src/demuxers/demux_str.c +++ b/src/demuxers/demux_str.c @@ -102,7 +102,7 @@ * - then follows 16-bit RLE data until the EOD * - RLE format: bits 15-10: # of 0s preceding this value (unsigned) * bits 9-0: this value (signed) - * - e.g. 3 bytes (2,10)(0,20)(3,30) -> 0 0 10 20 0 0 0 30 + * - e.g. 3 bytes (2,10)(0,20)(3,30) -> 0 0 10 20 0 0 0 30 * - 16 bits: EOD (0xFE00) * - 16 bits: 0xFE00 end-of-data footer */ @@ -367,7 +367,7 @@ static int demux_str_send_chunk(demux_plugin_t *this_gen) { */ if( this->data_size ) - buf->extra_info->input_normpos = (int)( (double) current_pos * + buf->extra_info->input_normpos = (int)( (double) current_pos * 65535 / this->data_size ); buf->extra_info->input_time = (current_pos*1000)/(CD_RAW_SECTOR_SIZE*75); @@ -405,7 +405,7 @@ static int demux_str_send_chunk(demux_plugin_t *this_gen) { } if( this->data_size ) - buf->extra_info->input_normpos = (int)( (double) current_pos * + buf->extra_info->input_normpos = (int)( (double) current_pos * 65535 / this->data_size ); buf->extra_info->input_time = (current_pos*1000)/(CD_RAW_SECTOR_SIZE*75); @@ -529,7 +529,7 @@ static int demux_str_get_status (demux_plugin_t *this_gen) { static int demux_str_get_stream_length (demux_plugin_t *this_gen) { demux_str_t *this = (demux_str_t *) this_gen; - return (int)((int64_t) this->input->get_length(this->input) + return (int)((int64_t) this->input->get_length(this->input) * 1000 / (CD_RAW_SECTOR_SIZE * 75)); } @@ -575,7 +575,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str mrl = input->get_mrl (input); extensions = class_gen->get_extensions (class_gen); - + if (!_x_demux_check_extension (mrl, extensions)) { free (this); return NULL; diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index d662bb0ed..cedcbb4a1 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -40,7 +40,7 @@ * - demux HDMV/BluRay bitmap subtitles * * 28-Nov-2004 Mike Lampard <mlampard> - * - Added support for PMT sections larger than 1 ts packet + * - Added support for PMT sections larger than 1 ts packet * * 28-Aug-2004 James Courtier-Dutton <jcdutton> * - Improve PAT and PMT handling. Added some FIXME comments. @@ -58,7 +58,7 @@ * - dynamic allocation leaks fixes * * 27-May-2002 Giovanni Baronetti and Mauro Borghi <mauro.borghi@tilab.com> - * - fill buffers before putting them in fifos + * - fill buffers before putting them in fifos * - force PMT reparsing when PMT PID changes * - accept non seekable input plugins -- FIX? * - accept dvb as input plugin @@ -173,7 +173,7 @@ #define PKT_SIZE 188 #define BODY_SIZE (188 - 4) /* more PIDS are needed due "auto-detection". 40 spare media entries */ -#define MAX_PIDS ((BODY_SIZE - 1 - 13) / 4) + 40 +#define MAX_PIDS ((BODY_SIZE - 1 - 13) / 4) + 40 #define MAX_PMTS ((BODY_SIZE - 1 - 13) / 4) + 10 #define SYNC_BYTE 0x47 @@ -283,7 +283,7 @@ typedef struct { int pid; int media_index; } demux_ts_spu_lang; - + /* Audio Channels */ #define MAX_AUDIO_TRACKS 32 @@ -335,10 +335,10 @@ typedef struct { unsigned int pid_count; unsigned int videoPid; unsigned int videoMedia; - + demux_ts_audio_track audio_tracks[MAX_AUDIO_TRACKS]; int audio_tracks_count; - + int send_end_buffers; int64_t last_pts[2]; int send_newpts; @@ -366,7 +366,7 @@ typedef struct { int32_t npkt_read; uint8_t buf[BUF_SIZE]; /* == PKT_SIZE * NPKT_PER_READ */ - + int numPreview; } demux_ts_t; @@ -394,7 +394,7 @@ static void demux_ts_build_crc32_table(demux_ts_t*this) { } } -static uint32_t demux_ts_compute_crc32(demux_ts_t*this, uint8_t *data, +static uint32_t demux_ts_compute_crc32(demux_ts_t*this, uint8_t *data, int32_t length, uint32_t crc32) { int32_t i; @@ -439,7 +439,7 @@ static void check_newpts( demux_ts_t *this, int64_t pts, int video ) The original code worked well when the wrap happend like this: V7 A7 V8 V9 A9 Dv V0 V1 da A1 V2 V3 A3 V4 - + Legend: Vn = video packet with timestamp n An = audio packet with timestamp n @@ -457,16 +457,16 @@ static void check_newpts( demux_ts_t *this, int64_t pts, int video ) a delay of almoust 26.5 hours! The new code gives the following sequences for the above examples: - + V7 A7 V8 V9 A9 Dv V0 V1 A1 V2 V3 A3 V4 V7 V8 A7 V9 Dv V0 Da A9 Dv V1 V2 A1 V3 V4 A3 After proving this code it should be cleaned up to use just a single variable "last_pts". */ - + /* this->last_pts[video] = pts; -*/ +*/ this->last_pts[video] = this->last_pts[1-video] = pts; } } @@ -492,7 +492,7 @@ static void demux_send_special_spu_buf( demux_ts_t *this, uint32_t spu_type, int static void demux_ts_update_spu_channel(demux_ts_t *this) { buf_element_t *buf; - + this->current_spu_channel = this->stream->spu_channel; buf = this->video_fifo->buffer_pool_alloc(this->video_fifo); @@ -501,7 +501,7 @@ static void demux_ts_update_spu_channel(demux_ts_t *this) buf->decoder_flags = BUF_FLAG_SPECIAL; buf->decoder_info[1] = BUF_SPECIAL_SPU_DVB_DESCRIPTOR; buf->size = 0; - + if (this->current_spu_channel >= 0 && this->current_spu_channel < this->spu_langs_count) { @@ -570,7 +570,7 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt, * indicator set. */ if (!pusi) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: demux error! PAT without payload unit start indicator\n"); return; } @@ -580,7 +580,7 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt, */ pkt += pkt[4]; if (pkt - original_pkt > PKT_SIZE) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: demux error! PAT with invalid pointer\n"); return; } @@ -614,13 +614,13 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt, } if (pkt - original_pkt > BODY_SIZE - 1 - 3 - section_length) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: FIXME: (unsupported )PAT spans multiple TS packets\n"); return; } if ((section_number != 0) || (last_section_number != 0)) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: FIXME: (unsupported) PAT consists of multiple (%d) sections\n", last_section_number); return; } @@ -629,11 +629,11 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt, calc_crc32 = demux_ts_compute_crc32 (this, pkt+5, section_length+3-4, 0xffffffff); if (crc32 != calc_crc32) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: demux error! PAT with invalid CRC32: packet_crc32: %.8x calc_crc32: %.8x\n", crc32,calc_crc32); return; - } + } #ifdef TS_PAT_LOG else { printf ("demux_ts: PAT CRC32 ok.\n"); @@ -711,7 +711,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m, /* we should have a PES packet here */ if (p[0] || p[1] || (p[2] != 1)) { - xprintf (xine, XINE_VERBOSITY_DEBUG, + xprintf (xine, XINE_VERBOSITY_DEBUG, "demux_ts: error %02x %02x %02x (should be 0x000001) \n", p[0], p[1], p[2]); return 0 ; } @@ -762,7 +762,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m, /* sometimes corruption on header_len causes segfault in memcpy below */ if (header_len + 9 > pkt_len) { - xprintf (xine, XINE_VERBOSITY_DEBUG, + xprintf (xine, XINE_VERBOSITY_DEBUG, "demux_ts: illegal value for PES_header_data_length (0x%x)\n", header_len); return 0; } @@ -791,7 +791,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m, if (stream_id == 0xbd || stream_id == 0xfd /* HDMV */) { int spu_id; - + lprintf ("audio buf = %02X %02X %02X %02X %02X %02X %02X %02X\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); @@ -801,7 +801,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m, * these "raw" streams may begin with a byte that looks like a stream type. * For audio streams, m->type already contains the stream no. */ - if((m->descriptor_tag == STREAM_AUDIO_AC3) || /* ac3 - raw */ + if((m->descriptor_tag == STREAM_AUDIO_AC3) || /* ac3 - raw */ (p[0] == 0x0B && p[1] == 0x77)) { /* ac3 - syncword */ m->content = p; m->size = packet_len; @@ -893,7 +893,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m, m->content = p; m->size = packet_len; switch (m->descriptor_tag) { - case ISO_11172_AUDIO: + case ISO_11172_AUDIO: case ISO_13818_AUDIO: lprintf ("demux_ts: found MPEG audio track.\n"); m->type |= BUF_AUDIO_MPEG; @@ -942,7 +942,7 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, case (i.e. adaptation field only) when it does not get bumped. */ if (m->counter != INVALID_CC) { if ((m->counter & 0x0f) != cc) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: PID 0x%.4x: unexpected cc %d (expected %d)\n", m->pid, cc, m->counter); } } @@ -972,9 +972,9 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, } m->buf->pts = m->pts; m->buf->decoder_info[0] = 1; - + if( this->input->get_length (this->input) ) - m->buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + m->buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); if (this->rate) m->buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) @@ -992,7 +992,7 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, if (!demux_ts_parse_pes_header(this->stream->xine, m, ts, len, this->stream)) { m->buf->free_buffer(m->buf); m->buf = NULL; - + if (m->corrupted_pes > CORRUPT_PES_THRESHOLD && m->autodetected) { if (this->videoPid == m->pid) { this->videoPid = INVALID_PID; @@ -1000,7 +1000,7 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, } } else { m->corrupted_pes++; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: PID 0x%.4x: corrupted pes encountered\n", m->pid); } } else { @@ -1019,7 +1019,7 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, m->buf->pts = m->pts; m->buf->decoder_info[0] = 1; if( this->input->get_length (this->input) ) - m->buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * + m->buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) * 65535 / this->input->get_length (this->input) ); if (this->rate) m->buf->extra_info->input_time = (int)((int64_t)this->input->get_current_pos (this->input) @@ -1104,7 +1104,7 @@ static void demux_ts_get_reg_desc(demux_ts_t *this, uint32_t *dest, { *dest = (d[2] << 24) | (d[3] << 16) | (d[4] << 8) | d[5]; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: found registration format identifier: 0x%.4x\n", *dest); return; } @@ -1126,7 +1126,7 @@ static inline int ts_payloadsize(unsigned char * tsp) } return 184; } - + /* * NAME demux_ts_parse_pmt @@ -1156,14 +1156,14 @@ static void demux_ts_parse_pmt (demux_ts_t *this, uint32_t crc32; uint32_t calc_crc32; uint32_t coded_length; - unsigned int pid; + unsigned int pid; unsigned char *stream; - unsigned int i; - int count; - char *ptr = NULL; + unsigned int i; + int count; + char *ptr = NULL; unsigned char len; - unsigned int offset=0; - + unsigned int offset=0; + /* * A new section should start with the payload unit start * indicator set. We allocate some mem (max. allowed for a PM section) @@ -1172,7 +1172,7 @@ static void demux_ts_parse_pmt (demux_ts_t *this, if (pusi) { pkt+=pkt[4]; /* pointer to start of section */ offset=1; - + if (this->pmt[program_count] != NULL) free(this->pmt[program_count]); this->pmt[program_count] = (uint8_t *) calloc(4096, sizeof(unsigned char)); this->pmt_write_ptr[program_count] = this->pmt[program_count]; @@ -1216,7 +1216,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num } if ((section_number != 0) || (last_section_number != 0)) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: FIXME (unsupported) PMT consists of multiple (%d) sections\n", last_section_number); return; } @@ -1242,7 +1242,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num len = count-offset; memcpy (this->pmt_write_ptr[program_count], ptr, len); this->pmt_write_ptr[program_count] +=len; - + #ifdef TS_PMT_LOG printf ("ts_demux: wr_ptr: %p, will be %p when finished\n", this->pmt_write_ptr[program_count], @@ -1280,9 +1280,9 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num this->pmt[program_count], section_length+3-4, 0xffffffff); if (crc32 != calc_crc32) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: demux error! PMT with invalid CRC32: packet_crc32: %#.8x calc_crc32: %#.8x\n", - crc32,calc_crc32); + crc32,calc_crc32); return; } else { @@ -1329,7 +1329,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num stream = &this->pmt[program_count][12] + program_info_length; coded_length = 13 + program_info_length; if (coded_length > section_length) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux error! PMT with inconsistent progInfo length\n"); return; } @@ -1346,7 +1346,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num stream_info_length = ((stream[3] << 8) | stream[4]) & 0x0fff; coded_length = 5 + stream_info_length; if (coded_length > section_length) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux error! PMT with inconsistent streamInfo length\n"); return; } @@ -1461,9 +1461,9 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num { int no = this->spu_langs_count; demux_ts_spu_lang *lang = &this->spu_langs[no]; - + this->spu_langs_count++; - + memcpy(lang->desc.lang, &stream[pos], 3); lang->desc.lang[3] = 0; lang->desc.comp_page_id = @@ -1525,7 +1525,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num * then we check the registration format identifier to see if it holds "AC-3" (0x41432d33) and * if is does, we tag this as an audio stream. * FIXME: This will need expanding if we ever see a DTS or other media format here. - */ + */ if ((this->audio_tracks_count < MAX_AUDIO_TRACKS) && (stream[0] >= 0x80) ) { int i, found = 0; for(i = 0; i < this->audio_tracks_count; i++) { @@ -1626,7 +1626,7 @@ static int sync_correct(demux_ts_t*this, uint8_t *buf, int32_t npkt_read) { n + p * this->pkt_size); /* FIXME: when read_length is not as required... we now stop demuxing */ if (read_length != (n + p * this->pkt_size)) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts_tsync_correct: sync found, but read failed\n"); return 0; } @@ -1695,7 +1695,7 @@ static unsigned char * demux_synchronise(demux_ts_t* this) { read_length = this->input->read(this->input, this->buf, this->pkt_size * NPKT_PER_READ); if (read_length < 0 || read_length % this->pkt_size) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: read returned %d bytes (not a multiple of %d!)\n", read_length, this->pkt_size); this->status = DEMUX_FINISHED; @@ -1734,7 +1734,7 @@ static unsigned char * demux_synchronise(demux_ts_t* this) { } -static int64_t demux_ts_adaptation_field_parse(uint8_t *data, +static int64_t demux_ts_adaptation_field_parse(uint8_t *data, uint32_t adaptation_field_length) { uint32_t discontinuity_indicator=0; @@ -1856,7 +1856,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { transport_error_indicator = (originalPkt[1] >> 7) & 0x01; payload_unit_start_indicator = (originalPkt[1] >> 6) & 0x01; transport_priority = (originalPkt[1] >> 5) & 0x01; - pid = ((originalPkt[1] << 8) | + pid = ((originalPkt[1] << 8) | originalPkt[2]) & 0x1fff; transport_scrambling_control = (originalPkt[3] >> 6) & 0x03; adaptation_field_control = (originalPkt[3] >> 4) & 0x03; @@ -1877,7 +1877,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { * Discard packets that are obviously bad. */ if (sync_byte != SYNC_BYTE) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux error! invalid ts sync byte %.2x\n", sync_byte); return; } @@ -1892,7 +1892,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { if (transport_scrambling_control) { if (this->videoPid == pid) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: selected videoPid is scrambled; skipping...\n"); } for (i=0; i < this->scrambled_npids; i++) { @@ -1917,7 +1917,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { */ data_offset += adaptation_field_length + 1; } - + if (! (adaptation_field_control & 0x1)) { return; } @@ -1929,10 +1929,10 @@ static void demux_ts_parse_packet (demux_ts_t*this) { */ program_count=0; if(this->media_num<MAX_PMTS) - while ((this->program_number[program_count] != INVALID_PROGRAM) && - (program_count < MAX_PMTS)) { + while ((this->program_number[program_count] != INVALID_PROGRAM) && + (program_count < MAX_PMTS)) { if (pid == this->pmt_pid[program_count]) { - + #ifdef TS_LOG printf ("demux_ts: PMT prog: 0x%.4x pid: 0x%.4x\n", this->program_number[program_count], @@ -1945,7 +1945,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { } program_count++; } - + if (payload_unit_start_indicator && this->media_num < MAX_PIDS){ int pes_stream_id; if (pid == 0) { @@ -1959,7 +1959,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { #ifdef TS_HEADER_LOG printf("demux_ts:ts_pes_header:stream_id=0x%.2x\n",pes_stream_id); #endif - + if ( (pes_stream_id >= VIDEO_STREAM_S) && (pes_stream_id <= VIDEO_STREAM_E) ) { if ( this->videoPid == INVALID_PID) { int i, found = 0; @@ -1969,7 +1969,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { break; } } - + if (found && (this->media[i].corrupted_pes == 0)) { this->videoPid = pid; this->videoMedia = i; @@ -1979,11 +1979,11 @@ static void demux_ts_parse_packet (demux_ts_t*this) { this->media[this->videoMedia].autodetected = 1; demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, 0x100 + pes_stream_id); } - + if (this->videoPid != INVALID_PID) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: auto-detected video pid 0x%.4x\n", pid); - } + } } } else if ( (pes_stream_id >= AUDIO_STREAM_S) && (pes_stream_id <= AUDIO_STREAM_E) ) { if (this->audio_tracks_count < MAX_AUDIO_TRACKS) { @@ -2010,10 +2010,10 @@ static void demux_ts_parse_packet (demux_ts_t*this) { } } } - + if (data_len > PKT_SIZE) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: demux error! invalid payload size %d\n", data_len); } else { @@ -2087,7 +2087,7 @@ static void demux_ts_event_handler (demux_ts_t *this) { this->last_pmt_crc = 0; _x_demux_control_start (this->stream); break; - + } xine_event_free (event); @@ -2126,7 +2126,7 @@ static void demux_ts_dispose (demux_plugin_t *this_gen) { } } for (i=0; i < MAX_PIDS; i++) { - if (this->media[i].buf != NULL) { + if (this->media[i].buf != NULL) { this->media[i].buf->free_buffer(this->media[i].buf); this->media[i].buf = NULL; } @@ -2163,23 +2163,23 @@ static void demux_ts_send_headers (demux_plugin_t *this_gen) { this->last_pmt_crc = 0; _x_demux_control_start (this->stream); - + this->input->seek (this->input, 0, SEEK_SET); this->send_newpts = 1; - + demux_ts_build_crc32_table (this); - + this->status = DEMUX_OK ; this->send_end_buffers = 1; this->scrambled_npids = 0; - + /* DVBSUB */ this->spu_pid = INVALID_PID; this->spu_langs_count = 0; this->current_spu_channel = -1; - + /* FIXME ? */ _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); @@ -2206,11 +2206,11 @@ static int demux_ts_seek (demux_plugin_t *this_gen, } this->send_newpts = 1; - + for (i=0; i<MAX_PIDS; i++) { demux_ts_media *m = &this->media[i]; - if (m->buf != NULL) + if (m->buf != NULL) m->buf->free_buffer(m->buf); m->buf = NULL; m->counter = INVALID_CC; @@ -2219,7 +2219,7 @@ static int demux_ts_seek (demux_plugin_t *this_gen, } if( !playing ) { - + this->status = DEMUX_OK; this->buf_flag_seek = 0; @@ -2229,7 +2229,7 @@ static int demux_ts_seek (demux_plugin_t *this_gen, _x_demux_flush_engine(this->stream); } - + return this->status; } @@ -2238,7 +2238,7 @@ static int demux_ts_get_stream_length (demux_plugin_t *this_gen) { demux_ts_t*this = (demux_ts_t*)this_gen; if (this->rate) - return (int)((int64_t) this->input->get_length (this->input) + return (int)((int64_t) this->input->get_length (this->input) * 1000 / (this->rate * 50)); else return 0; @@ -2260,7 +2260,7 @@ static int demux_ts_get_optional_data(demux_plugin_t *this_gen, /* be a bit paranoid */ if (this == NULL || this->stream == NULL) return DEMUX_OPTIONAL_UNSUPPORTED; - + switch (data_type) { case DEMUX_OPTIONAL_DATA_AUDIOLANG: @@ -2279,7 +2279,7 @@ static int demux_ts_get_optional_data(demux_plugin_t *this_gen, if (channel>=0 && channel<this->spu_langs_count) { memcpy(str, this->spu_langs[channel].desc.lang, 3); str[3] = 0;} - else + else strcpy(str, "none"); return DEMUX_OPTIONAL_SUCCESS; @@ -2315,10 +2315,10 @@ static int detect_ts(uint8_t *buf, size_t len, int ts_size) return ts_detected; } -static demux_plugin_t *open_plugin (demux_class_t *class_gen, - xine_stream_t *stream, +static demux_plugin_t *open_plugin (demux_class_t *class_gen, + xine_stream_t *stream, input_plugin_t *input) { - + demux_ts_t *this; int i; int hdmv = -1; @@ -2333,9 +2333,9 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, if (detect_ts(buf, sizeof(buf), PKT_SIZE)) hdmv = 0; - else if (detect_ts(buf, sizeof(buf), PKT_SIZE+4)) + else if (detect_ts(buf, sizeof(buf), PKT_SIZE+4)) hdmv = 1; - else + else return NULL; } break; @@ -2398,7 +2398,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this->demux_plugin.get_capabilities = demux_ts_get_capabilities; this->demux_plugin.get_optional_data = demux_ts_get_optional_data; this->demux_plugin.demux_class = class_gen; - + /* * Initialise our specialised data. */ @@ -2423,7 +2423,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this->last_pmt_crc = 0; this->rate = 16000; /* FIXME */ - + this->status = DEMUX_FINISHED; /* DVBSUB */ @@ -2440,7 +2440,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this->pkt_size = PKT_SIZE + this->pkt_offset; this->numPreview=0; - + return &this->demux_plugin; } @@ -2451,7 +2451,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, static const char *get_description (demux_class_t *this_gen) { return "MPEG Transport Stream demuxer"; } - + static const char *get_identifier (demux_class_t *this_gen) { return "MPEG_TS"; } @@ -2472,9 +2472,9 @@ static void class_dispose (demux_class_t *this_gen) { } static void *init_class (xine_t *xine, void *data) { - + demux_ts_class_t *this; - + this = calloc(1, sizeof(demux_ts_class_t)); this->config = xine->config; this->xine = xine; @@ -2498,7 +2498,7 @@ static const demuxer_info_t demux_info_ts = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "mpeg-ts", XINE_VERSION_CODE, &demux_info_ts, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/demuxers/demux_tta.c b/src/demuxers/demux_tta.c index 7853c8182..9edad08bd 100644 --- a/src/demuxers/demux_tta.c +++ b/src/demuxers/demux_tta.c @@ -141,7 +141,7 @@ static int demux_tta_send_chunk(demux_plugin_t *this_gen) { if ( bytes_to_read <= 0 ) buf->decoder_flags |= BUF_FLAG_FRAME_END; - + this->audio_fifo->put(this->audio_fifo, buf); } diff --git a/src/demuxers/demux_vmd.c b/src/demuxers/demux_vmd.c index b81e4575e..6aec12580 100644 --- a/src/demuxers/demux_vmd.c +++ b/src/demuxers/demux_vmd.c @@ -19,7 +19,7 @@ */ /* - * Sierra Video and Music Data (.vmd) File Demuxer + * Sierra Video and Music Data (.vmd) File Demuxer * by Mike Melanson (melanson@pcisys.net) * For more information on the VMD file format, visit: * http://www.pcisys.net/~melanson/codecs/ @@ -109,7 +109,7 @@ static int open_vmd_file(demux_vmd_t *this) { unsigned int total_frames; int64_t current_video_pts = 0; - if (_x_demux_read_header(this->input, vmd_header, VMD_HEADER_SIZE) != + if (_x_demux_read_header(this->input, vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE) return 0; @@ -234,7 +234,7 @@ static int demux_vmd_send_chunk(demux_plugin_t *this_gen) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_VIDEO_VMD; if( this->data_size ) - buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * + buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * 65535 / this->data_size); memcpy(buf->content, frame->frame_record, BYTES_PER_FRAME_RECORD); buf->size = BYTES_PER_FRAME_RECORD; @@ -246,7 +246,7 @@ static int demux_vmd_send_chunk(demux_plugin_t *this_gen) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_VIDEO_VMD; if( this->data_size ) - buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * + buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * 65535 / this->data_size); if (remaining_bytes > buf->max_size) @@ -277,7 +277,7 @@ static int demux_vmd_send_chunk(demux_plugin_t *this_gen) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_VMD; if( this->data_size ) - buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * + buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * 65535 / this->data_size); memcpy(buf->content, frame->frame_record, BYTES_PER_FRAME_RECORD); buf->size = BYTES_PER_FRAME_RECORD; @@ -289,7 +289,7 @@ static int demux_vmd_send_chunk(demux_plugin_t *this_gen) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_VMD; if( this->data_size ) - buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * + buf->extra_info->input_normpos = (int)( (double) (frame->frame_offset - this->data_start) * 65535 / this->data_size); if (remaining_bytes > buf->max_size) diff --git a/src/demuxers/demux_voc.c b/src/demuxers/demux_voc.c index e825f6869..1ddbc1727 100644 --- a/src/demuxers/demux_voc.c +++ b/src/demuxers/demux_voc.c @@ -93,7 +93,7 @@ static int open_voc_file(demux_voc_t *this) { this->input->seek(this->input, first_block_offset, SEEK_SET); /* load the block preamble */ - if (this->input->read(this->input, preamble, BLOCK_PREAMBLE_SIZE) != + if (this->input->read(this->input, preamble, BLOCK_PREAMBLE_SIZE) != BLOCK_PREAMBLE_SIZE) return 0; @@ -142,7 +142,7 @@ static int demux_voc_send_chunk(demux_plugin_t *this_gen) { /* just load data chunks from wherever the stream happens to be * pointing; issue a DEMUX_FINISHED status if EOF is reached */ remaining_sample_bytes = PCM_BLOCK_ALIGN; - current_file_pos = + current_file_pos = this->input->get_current_pos(this->input) - this->data_start; current_pts = current_file_pos; @@ -231,7 +231,7 @@ static int demux_voc_seek (demux_plugin_t *this_gen, off_t start_pos, int start_ start_pos = (off_t) ( (double) start_pos / 65535 * this->data_size ); - + this->seek_flag = 1; this->status = DEMUX_OK; _x_demux_flush_engine (this->stream); diff --git a/src/demuxers/demux_vox.c b/src/demuxers/demux_vox.c index 1b34106ad..ccf9bf877 100644 --- a/src/demuxers/demux_vox.c +++ b/src/demuxers/demux_vox.c @@ -87,7 +87,7 @@ static int demux_vox_send_chunk (demux_plugin_t *this_gen) { buf->size = buf->max_size; if( this->input->get_length (this->input) ) - buf->extra_info->input_normpos = (int)( (double) current_file_pos * + buf->extra_info->input_normpos = (int)( (double) current_file_pos * 65535 / this->input->get_length (this->input) ); buf->extra_info->input_time = audio_pts / 90; buf->pts = audio_pts; @@ -166,7 +166,7 @@ static int demux_vox_get_status (demux_plugin_t *this_gen) { static int demux_vox_get_stream_length (demux_plugin_t *this_gen) { demux_vox_t *this = (demux_vox_t *) this_gen; - return (int)((int64_t)this->input->get_length(this->input) + return (int)((int64_t)this->input->get_length(this->input) * 2 * 1000 / DIALOGIC_SAMPLERATE); } diff --git a/src/demuxers/demux_vqa.c b/src/demuxers/demux_vqa.c index 5fb8273dd..578be14ee 100644 --- a/src/demuxers/demux_vqa.c +++ b/src/demuxers/demux_vqa.c @@ -25,7 +25,7 @@ * * Quick technical note: VQA files begin with a header that includes a * frame index. This ought to be useful for seeking within a VQA file. - * However, seeking is infeasible due to the audio encoding: Each audio + * However, seeking is infeasible due to the audio encoding: Each audio * block needs information from the previous audio block in order to be * decoded, thus making random seeking difficult. */ @@ -108,7 +108,7 @@ static int open_vqa_file(demux_vqa_t *this) { this->filesize = 1; /* load the VQA header */ - if (this->input->read(this->input, vqa_header, VQA_HEADER_SIZE) != + if (this->input->read(this->input, vqa_header, VQA_HEADER_SIZE) != VQA_HEADER_SIZE) return 0; diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c index 7750c3e0e..36cc4eabb 100644 --- a/src/demuxers/demux_wc3movie.c +++ b/src/demuxers/demux_wc3movie.c @@ -177,7 +177,7 @@ static int demux_mve_send_chunk(demux_plugin_t *this_gen) { } } this->current_shot++; - + /* this is the start of a new shot; send a new palette */ if (this->input->read(this->input, preamble, 4) != 4) { this->status = DEMUX_FINISHED; @@ -205,7 +205,7 @@ static int demux_mve_send_chunk(demux_plugin_t *this_gen) { } else if (chunk_tag == AUDI_TAG) { if( this->audio_fifo ) { audio_pts = this->video_pts - WC3_PTS_INC; - + while (chunk_size) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = BUF_AUDIO_LPCM_LE; @@ -213,23 +213,23 @@ static int demux_mve_send_chunk(demux_plugin_t *this_gen) { buf->extra_info->input_normpos = (int)( (double) current_file_pos * 65535 / this->data_size); buf->extra_info->input_time = audio_pts / 90; buf->pts = audio_pts; - + if (chunk_size > buf->max_size) buf->size = buf->max_size; else buf->size = chunk_size; chunk_size -= buf->size; - + if (this->input->read(this->input, buf->content, buf->size) != buf->size) { buf->free_buffer(buf); this->status = DEMUX_FINISHED; break; } - + if (!chunk_size) buf->decoder_flags |= BUF_FLAG_FRAME_END; - + this->audio_fifo->put (this->audio_fifo, buf); } }else{ @@ -293,7 +293,7 @@ static void demux_mve_send_headers(demux_plugin_t *this_gen) { /* load stream information */ _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); - /* this is not strictly correct-- some WC3 MVE files do not contain + /* this is not strictly correct-- some WC3 MVE files do not contain * audio, but I'm too lazy to check if that is the case */ _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, @@ -376,7 +376,7 @@ static int open_mve_file(demux_mve_t *this) { if (this->input->read(this->input, preamble, 4) != 4) return 0; this->number_of_shots = _X_LE_32(&preamble[0]); - + /* 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; @@ -540,13 +540,13 @@ static int demux_mve_seek (demux_plugin_t *this_gen, start_time /= 1000; start_pos = (off_t) ( (double) start_pos / 65535 * this->data_size ); - + this->status = DEMUX_OK; _x_demux_flush_engine(this->stream); this->seek_flag = 1; /* if input is non-seekable, do not proceed with the rest of this - * seek function */ + * seek function */ if (!INPUT_IS_SEEKABLE(this->input)) return this->status; @@ -566,7 +566,7 @@ static int demux_mve_seek (demux_plugin_t *this_gen, chunk_size = (_X_BE_32(&preamble[4]) + 1) & (~1); if (chunk_tag == SHOT_TAG) { - this->shot_offsets[0] = + this->shot_offsets[0] = this->input->get_current_pos(this->input) - PREAMBLE_SIZE; /* skip the four SHOT data bytes (palette index) */ this->input->seek(this->input, 4, SEEK_CUR); @@ -581,7 +581,7 @@ static int demux_mve_seek (demux_plugin_t *this_gen, start_pos += this->data_start; for (i = 0; i < this->number_of_shots - 1; i++) { - /* if the next shot offset has not been recorded, traverse through the + /* if the next shot offset has not been recorded, traverse through the * file until it is found */ if (this->shot_offsets[i + 1] == 0) { off_t current_pos; @@ -607,7 +607,7 @@ static int demux_mve_seek (demux_plugin_t *this_gen, chunk_size = (_X_BE_32(&preamble[4]) + 1) & (~1); if (chunk_tag == SHOT_TAG) { - this->shot_offsets[i + 1] = + this->shot_offsets[i + 1] = this->input->get_current_pos(this->input) - PREAMBLE_SIZE; /* skip the four SHOT data bytes (palette index) */ this->input->seek(this->input, 4, SEEK_CUR); @@ -620,7 +620,7 @@ static int demux_mve_seek (demux_plugin_t *this_gen, /* check if the seek-to offset falls in between this shot offset and * the next one */ - if ((start_pos >= this->shot_offsets[i]) && + if ((start_pos >= this->shot_offsets[i]) && (start_pos < this->shot_offsets[i + 1])) { new_shot = i; diff --git a/src/demuxers/demux_yuv4mpeg2.c b/src/demuxers/demux_yuv4mpeg2.c index 2387fc7a7..aa1a4dff6 100644 --- a/src/demuxers/demux_yuv4mpeg2.c +++ b/src/demuxers/demux_yuv4mpeg2.c @@ -69,7 +69,7 @@ typedef struct { int aspect_d; int progressive; int top_field_first; - + unsigned int frame_pts_inc; unsigned int frame_size; @@ -86,7 +86,7 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { char *header_ptr, *header_endptr, *header_end; this->bih.biWidth = this->bih.biHeight = this->fps_n = this->fps_d = - this->aspect_n = this->aspect_d = this->progressive = + this->aspect_n = this->aspect_d = this->progressive = this->top_field_first = this->data_start = 0; if (_x_demux_read_header(this->input, header, Y4M_HEADER_BYTES) != Y4M_HEADER_BYTES) @@ -98,11 +98,11 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { /* null terminate the read data */ header[Y4M_HEADER_BYTES] = '\0'; - + /* check for stream header terminator */ if ((header_end = strchr(header, '\n')) == NULL) return 0; - + /* read tagged fields in stream header */ header_ptr = &header[Y4M_SIGNATURE_SIZE]; while (header_ptr < header_end) { @@ -111,7 +111,7 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { break; else header_ptr++; - + switch (*header_ptr) { case 'W': /* read the width */ @@ -153,31 +153,31 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { return 0; else header_ptr = header_endptr; - + /* denominator */ this->fps_d = strtol(header_ptr + 1, &header_endptr, 10); if (header_endptr == header_ptr + 1) return 0; else header_ptr = header_endptr; - + break; case 'A': - /* read aspect ratio - stored as a ratio(!) + /* read aspect ratio - stored as a ratio(!) * numerator */ this->aspect_n = strtol(header_ptr + 1, &header_endptr, 10); if ((header_endptr == header_ptr + 1) || (*header_endptr != ':')) return 0; else header_ptr = header_endptr; - + /* denominator */ this->aspect_d = strtol(header_ptr + 1, &header_endptr, 10); if (header_endptr == header_ptr + 1) return 0; else header_ptr = header_endptr; - + break; default: /* skip whatever this is */ @@ -185,7 +185,7 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { header_ptr++; } } - + /* make sure all the data was found */ if (!this->bih.biWidth || !this->bih.biHeight || !this->fps_n || !this->fps_d) return 0; @@ -194,8 +194,8 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { this->frame_size = this->bih.biWidth * this->bih.biHeight * 3 / 2; /* pts difference between frames */ - this->frame_pts_inc = (90000 * this->fps_d) / this->fps_n; - + this->frame_pts_inc = (90000 * this->fps_d) / this->fps_n; + /* finally, look for the first frame */ char *data_start_ptr = memmem(header_ptr, Y4M_HEADER_BYTES, "FRAME", 5); @@ -204,7 +204,7 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { return 0; this->data_start = data_start_ptr - header; - + /* compute size of all frames */ if (INPUT_IS_SEEKABLE(this->input)) { this->data_size = this->input->get_length(this->input) - @@ -271,9 +271,9 @@ static int demux_yuv4mpeg2_send_chunk(demux_plugin_t *this_gen) { buf->decoder_flags |= BUF_FLAG_FRAME_END; this->video_fifo->put(this->video_fifo, buf); } - + return this->status; -} +} static void demux_yuv4mpeg2_send_headers(demux_plugin_t *this_gen) { demux_yuv4mpeg2_t *this = (demux_yuv4mpeg2_t *) this_gen; @@ -299,13 +299,13 @@ static void demux_yuv4mpeg2_send_headers(demux_plugin_t *this_gen) { buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAMERATE| BUF_FLAG_FRAME_END; buf->decoder_info[0] = this->frame_pts_inc; /* initial video step */ - + if(this->aspect_n && this->aspect_d) { buf->decoder_flags |= BUF_FLAG_ASPECT; buf->decoder_info[1] = this->bih.biWidth * this->aspect_n; buf->decoder_info[2] = this->bih.biHeight * this->aspect_d; } - + buf->decoder_info[3] = this->progressive; buf->decoder_info[4] = this->top_field_first; @@ -327,7 +327,7 @@ static int demux_yuv4mpeg2_seek (demux_plugin_t *this_gen, /* YUV4MPEG2 files are essentially constant bit-rate video. Seek along * the calculated frame boundaries. Divide the requested seek offset - * by the frame size integer-wise to obtain the desired frame number + * by the frame size integer-wise to obtain the desired frame number * and then multiply the frame number by the frame size to get the * starting offset. Add the data_start offset to obtain the final * offset. */ @@ -370,7 +370,7 @@ static int demux_yuv4mpeg2_get_status (demux_plugin_t *this_gen) { static int demux_yuv4mpeg2_get_stream_length (demux_plugin_t *this_gen) { demux_yuv4mpeg2_t *this = (demux_yuv4mpeg2_t *) this_gen; - return (int)(((int64_t) this->data_size * 1000 * this->fps_d) / + return (int)(((int64_t) this->data_size * 1000 * this->fps_d) / ((this->frame_size + Y4M_FRAME_SIGNATURE_SIZE) * this->fps_n)); } diff --git a/src/demuxers/demux_yuv_frames.c b/src/demuxers/demux_yuv_frames.c index 089207f58..81dd2b03a 100644 --- a/src/demuxers/demux_yuv_frames.c +++ b/src/demuxers/demux_yuv_frames.c @@ -1,19 +1,19 @@ /* * Copyright (C) 2003-2004 the xine project * Copyright (C) 2003 Jeroen Asselman <j.asselman@itsec-ps.nl> - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -120,27 +120,27 @@ static void demux_yuv_frames_send_headers (demux_plugin_t *this_gen){ this->video_fifo = this->stream->video_fifo; this->audio_fifo = this->stream->audio_fifo; - + _x_demux_control_start(this->stream); if(_x_stream_info_get(this->stream, XINE_STREAM_INFO_HAS_AUDIO)) { buf = this->input->read_block(this->input, this->audio_fifo, 0); - + if (buf) this->audio_fifo->put(this->audio_fifo, buf); else this->status = DEMUX_FINISHED; } - + if(_x_stream_info_get(this->stream, XINE_STREAM_INFO_HAS_VIDEO)) { buf = this->input->read_block(this->input, this->video_fifo, 0); - + if (buf) this->video_fifo->put(this->video_fifo, buf); else this->status = DEMUX_FINISHED; } - + this->status = DEMUX_OK; } diff --git a/src/demuxers/ebml.c b/src/demuxers/ebml.c index 4ce8a549d..75fbfde75 100644 --- a/src/demuxers/ebml.c +++ b/src/demuxers/ebml.c @@ -40,7 +40,7 @@ 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 = xine; ebml->input = input; @@ -52,15 +52,15 @@ ebml_parser_t *new_ebml_parser (xine_t *xine, input_plugin_t *input) { ebml->doctype = NULL; ebml->doctype_version = 0; ebml->doctype_read_version = 0; - + ebml->level = 0; - + return ebml; } void dispose_ebml_parser(ebml_parser_t *ebml) { - free(ebml); + free(ebml); } @@ -132,7 +132,7 @@ static int ebml_read_elem_len(ebml_parser_t *ebml, uint64_t *len) { int ff_bytes; uint64_t value; int i; - + if (ebml->input->read(ebml->input, data, 1) != 1) { off_t pos = ebml->input->get_current_pos(ebml->input); xprintf(ebml->xine, XINE_VERBOSITY_LOG, @@ -162,7 +162,7 @@ static int ebml_read_elem_len(ebml_parser_t *ebml, uint64_t *len) { ff_bytes = 1; else ff_bytes = 0; - + /* read the rest of the len */ if (ebml->input->read(ebml->input, data + 1, size - 1) != (size - 1)) { off_t pos = ebml->input->get_current_pos(ebml->input); @@ -231,7 +231,7 @@ int ebml_read_uint(ebml_parser_t *ebml, ebml_elem_t *elem, uint64_t *num) { "ebml: Invalid integer element size %" PRIu64 "\n", size); return 0; } - + if (!ebml_read_elem_data (ebml, data, size)) return 0; @@ -253,7 +253,7 @@ int ebml_read_sint (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *num) { "ebml: Invalid integer element size %" PRIu64 "\n", size); return 0; } - + if (!ebml_read_elem_data(ebml, data, size)) return 0; @@ -262,7 +262,7 @@ int ebml_read_sint (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *num) { *num = -1; else *num = 0; - + while (size > 0) { *num = (*num << 8) | data[elem->len - size]; size--; @@ -310,7 +310,7 @@ int ebml_read_ascii(ebml_parser_t *ebml, ebml_elem_t *elem, char *str) { if (!ebml_read_elem_data(ebml, str, size)) return 0; - + return 1; } @@ -346,7 +346,7 @@ int ebml_read_master (ebml_parser_t *ebml, ebml_elem_t *elem) { 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) { @@ -378,20 +378,20 @@ int ebml_check_header(ebml_parser_t *ebml) { "ebml: invalid master element\n"); return 0; } - + if (master.id != EBML_ID_EBML) { xprintf(ebml->xine, XINE_VERBOSITY_LOG, "ebml: invalid master element\n"); return 0; } - + if (!ebml_read_master (ebml, &master)) return 0; next_level = 1; while (next_level == 1) { ebml_elem_t elem; - + if (!ebml_read_elem_head(ebml, &elem)) return 0; @@ -405,7 +405,7 @@ int ebml_check_header(ebml_parser_t *ebml) { ebml->version = num; break; } - + case EBML_ID_EBMLREADVERSION: { uint64_t num; diff --git a/src/demuxers/ebml.h b/src/demuxers/ebml.h index 9aa471c0b..6d750a98c 100644 --- a/src/demuxers/ebml.h +++ b/src/demuxers/ebml.h @@ -48,7 +48,7 @@ typedef struct ebml_parser_s { /* xine stuff */ xine_t *xine; input_plugin_t *input; - + /* EBML Parser Stack Management */ ebml_elem_t elem_stack[EBML_STACK_SIZE]; int level; @@ -61,7 +61,7 @@ typedef struct ebml_parser_s { char *doctype; uint64_t doctype_version; uint64_t doctype_read_version; - + } ebml_parser_t; diff --git a/src/demuxers/group_audio.c b/src/demuxers/group_audio.c index 2643a8b80..f405d0292 100644 --- a/src/demuxers/group_audio.c +++ b/src/demuxers/group_audio.c @@ -110,7 +110,7 @@ static const demuxer_info_t demux_info_mod = { #endif const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "aac", XINE_VERSION_CODE, &demux_info_aac, demux_aac_init_plugin }, { PLUGIN_DEMUX, 26, "ac3", XINE_VERSION_CODE, &demux_info_ac3, demux_ac3_init_plugin }, { PLUGIN_DEMUX, 26, "aud", XINE_VERSION_CODE, &demux_info_aud, demux_aud_init_plugin }, diff --git a/src/demuxers/group_audio.h b/src/demuxers/group_audio.h index 424e5c8e0..d2cd91875 100644 --- a/src/demuxers/group_audio.h +++ b/src/demuxers/group_audio.h @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2005 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA diff --git a/src/demuxers/group_games.c b/src/demuxers/group_games.c index ad257c2fb..f08e8477d 100644 --- a/src/demuxers/group_games.c +++ b/src/demuxers/group_games.c @@ -78,7 +78,7 @@ static const demuxer_info_t demux_info_vmd = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_DEMUX, 26, "wve", XINE_VERSION_CODE, &demux_info_eawve, demux_eawve_init_plugin}, { PLUGIN_DEMUX, 26, "idcin", XINE_VERSION_CODE, &demux_info_idcin, demux_idcin_init_plugin }, { PLUGIN_DEMUX, 26, "ipmovie", XINE_VERSION_CODE, &demux_info_ipmovie, demux_ipmovie_init_plugin }, diff --git a/src/demuxers/group_games.h b/src/demuxers/group_games.h index f93d4bb07..ea6b00e75 100644 --- a/src/demuxers/group_games.h +++ b/src/demuxers/group_games.h @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index 070ca2650..15599ffea 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -29,7 +29,7 @@ * * ID3v2 specs: http://www.id3.org/ */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -84,7 +84,7 @@ static const char* const id3_encoding[] = { "UTF-16", /* 0x01 */ "UTF-16BE", /* 0x02 */ "UTF-8"}; /* 0x03 */ - + int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream) { off_t len; @@ -113,7 +113,7 @@ int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream) { if (tag.genre < ID3_GENRE_COUNT) { _x_meta_info_set(stream, XINE_META_INFO_GENRE, id3_genre[tag.genre]); } - + } return 1; } else { @@ -126,12 +126,12 @@ static int id3v2_parse_genre(char* dest, char *src, int len) { int state = 0; char *buf = dest; unsigned int index = 0; - + while (*src) { lprintf("state=%d\n", state); if ((buf - dest) >= len) return 0; - + switch (state) { case 0: /* initial state */ @@ -278,7 +278,7 @@ static int id3v22_interp_frame(input_plugin_t *input, const size_t bufsize = frame_header->size + 2; if ( bufsize < 3 ) /* frames has to be _at least_ 1 byte */ return 0; - + buf = malloc(bufsize); if (buf == NULL) { lprintf("malloc error"); @@ -296,7 +296,7 @@ static int id3v22_interp_frame(input_plugin_t *input, case ( FOURCC_TAG(0, 'T', 'C', 'O') ): { char tmp[1024]; - + if (id3v2_parse_genre(tmp, buf + 1, 1024)) { _x_meta_info_set(stream, XINE_META_INFO_GENRE, tmp); } @@ -352,21 +352,21 @@ static int id3v22_parse_tag(input_plugin_t *input, if (tag_header.flags & ID3V22_ZERO_FLAG) { /* invalid flags */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } if (tag_header.flags & ID3V22_COMPRESS_FLAG) { /* compressed tag: not supported */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": compressed tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } if (tag_header.flags & ID3V22_UNSYNCH_FLAG) { /* unsynchronized tag: not supported */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": unsynchronized tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; @@ -378,11 +378,11 @@ static int id3v22_parse_tag(input_plugin_t *input, if (tag_frame_header.id) { if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v22_interp_frame(input, stream, &tag_frame_header)) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid frame content\n"); } } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; @@ -394,7 +394,7 @@ static int id3v22_parse_tag(input_plugin_t *input, return 1; } } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } @@ -433,9 +433,9 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input, uint8_t buf[14]; if (input->read (input, buf, 4) == 4) { - + frame_ext_header->size = _X_BE_32(&buf[0]); - + if (frame_ext_header->size == 6) { if (input->read (input, buf + 4, 6) == 6) { frame_ext_header->flags = _X_BE_16(buf + 4); @@ -443,7 +443,7 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input, frame_ext_header->crc = 0; } else { return 0; - } + } } else if (frame_ext_header->size == 10) { if (input->read (input, buf + 4, 10) == 10) { @@ -476,7 +476,7 @@ static int id3v23_interp_frame(input_plugin_t *input, const size_t bufsize = frame_header->size + 2; if ( bufsize < 3 ) /* frames has to be _at least_ 1 byte */ return 0; - + buf = malloc(bufsize); if (buf == NULL) { lprintf("malloc error"); @@ -494,7 +494,7 @@ static int id3v23_interp_frame(input_plugin_t *input, case ( FOURCC_TAG('T', 'C', 'O', 'N') ): { char tmp[1024]; - + if (id3v2_parse_genre(tmp, buf + 1, 1024)) { _x_meta_info_set(stream, XINE_META_INFO_GENRE, tmp); } @@ -550,14 +550,14 @@ static int id3v23_parse_tag(input_plugin_t *input, if (tag_header.flags & ID3V23_ZERO_FLAG) { /* invalid flags */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; } if (tag_header.flags & ID3V23_UNSYNCH_FLAG) { /* unsynchronized tag: not supported */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": unsynchronized tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; @@ -576,11 +576,11 @@ static int id3v23_parse_tag(input_plugin_t *input, if (tag_frame_header.id) { if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v23_interp_frame(input, stream, &tag_frame_header)) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid frame content\n"); } } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; @@ -593,7 +593,7 @@ static int id3v23_parse_tag(input_plugin_t *input, return 1; } } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } @@ -610,7 +610,7 @@ static int id3v23_parse_tag(input_plugin_t *input, /* id3v2 "genre" parsing code. what a ugly format ! */ static int id3v24_parse_genre(char* dest, char *src, int len) { unsigned int index = 0; - + dest[0] = '\0'; if (sscanf(src, "%u", &index) == 1) { if (index < ID3_GENRE_COUNT) { @@ -648,7 +648,7 @@ static int id3v24_parse_ext_header(input_plugin_t *input, uint8_t buf[5]; if (input->read (input, buf, 4) == 4) { - + frame_ext_header->size = _X_BE_32(&buf[0]); if (input->read (input, buf, 2) == 2) { @@ -731,7 +731,7 @@ static int id3v24_interp_frame(input_plugin_t *input, const size_t bufsize = frame_header->size + 2; if ( bufsize < 3 ) /* frames has to be _at least_ 1 byte */ return 0; - + buf = malloc(bufsize); if (buf == NULL) { lprintf("malloc error"); @@ -744,14 +744,14 @@ static int id3v24_interp_frame(input_plugin_t *input, enc = buf[0]; if( enc >= ID3_ENCODING_COUNT ) enc = 0; - + lprintf("data: %s\n", buf+1); switch (frame_header->id) { case ( FOURCC_TAG('T', 'C', 'O', 'N') ): { char tmp[1024]; - + if (id3v24_parse_genre(tmp, buf + 1, 1024)) { _x_meta_info_set(stream, XINE_META_INFO_GENRE, tmp); } @@ -808,7 +808,7 @@ static int id3v24_parse_tag(input_plugin_t *input, if (tag_header.flags & ID3V24_ZERO_FLAG) { /* invalid flags */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags); input->seek (input, tag_header.size - pos, SEEK_CUR); return 0; @@ -833,11 +833,11 @@ static int id3v24_parse_tag(input_plugin_t *input, if (tag_frame_header.id) { if ((pos + tag_frame_header.size) <= tag_header.size) { if (!id3v24_interp_frame(input, stream, &tag_frame_header)) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid frame content\n"); } } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; @@ -849,7 +849,7 @@ static int id3v24_parse_tag(input_plugin_t *input, return 1; } } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_frame_header problem\n"); return 0; } @@ -877,7 +877,7 @@ int id3v2_parse_tag(input_plugin_t *input, xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.2 tag\n"); result = id3v22_parse_tag(input, stream, mp3_frame_header); break; - + case 3: xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.3 tag\n"); result = id3v23_parse_tag(input, stream, mp3_frame_header); diff --git a/src/demuxers/matroska.h b/src/demuxers/matroska.h index b32725b3b..0a8226319 100644 --- a/src/demuxers/matroska.h +++ b/src/demuxers/matroska.h @@ -272,7 +272,7 @@ struct matroska_track_s { uint32_t codec_private_len; int default_flag; uint32_t compress_algo; - + uint32_t buf_type; fifo_buffer_t *fifo; diff --git a/src/demuxers/qtpalette.h b/src/demuxers/qtpalette.h index a8a44e916..422b570a9 100644 --- a/src/demuxers/qtpalette.h +++ b/src/demuxers/qtpalette.h @@ -11,7 +11,7 @@ static const unsigned char qt_default_palette_4[4 * 4] = { 0x93, 0x65, 0x5E, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xDF, 0xD0, 0xAB, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }; static const unsigned char qt_default_palette_16[16 * 4] = { @@ -30,7 +30,7 @@ static const unsigned char qt_default_palette_16[16 * 4] = { 0xFF, 0xFB, 0xF9, 0x00, 0xE8, 0xCA, 0xC5, 0x00, 0x8A, 0x7C, 0x77, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00 }; static const unsigned char qt_default_palette_256[256 * 4] = { |