diff options
Diffstat (limited to 'src')
40 files changed, 593 insertions, 719 deletions
diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c index 4074ff776..8559c6ece 100644 --- a/src/combined/ffmpeg/ff_audio_decoder.c +++ b/src/combined/ffmpeg/ff_audio_decoder.c @@ -107,6 +107,8 @@ static const ff_codec_t ff_audio_lookup[] = { {BUF_AUDIO_SMACKER, CODEC_ID_SMACKAUDIO, "Smacker (ffmpeg)"}, {BUF_AUDIO_FLVADPCM, CODEC_ID_ADPCM_SWF, "Flash ADPCM (ffmpeg)"}, {BUF_AUDIO_WAVPACK, CODEC_ID_WAVPACK, "WavPack (ffmpeg)"}, + {BUF_AUDIO_AMR_NB, CODEC_ID_AMR_NB, "AMR narrow band (ffmpeg)"}, + {BUF_AUDIO_AMR_WB, CODEC_ID_AMR_WB, "AMR wide band (ffmpeg)"}, }; @@ -519,7 +521,8 @@ static const uint32_t supported_audio_types[] = { BUF_AUDIO_SMACKER, BUF_AUDIO_FLVADPCM, BUF_AUDIO_WAVPACK, - + BUF_AUDIO_AMR_NB, + BUF_AUDIO_AMR_WB, 0 }; diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c index 02fcdce40..8afbde890 100644 --- a/src/combined/ffmpeg/ff_video_decoder.c +++ b/src/combined/ffmpeg/ff_video_decoder.c @@ -320,6 +320,7 @@ static const ff_codec_t ff_video_lookup[] = { {BUF_VIDEO_CAVS, CODEC_ID_CAVS, "Chinese AVS (ffmpeg)"}, {BUF_VIDEO_VMNC, CODEC_ID_VMNC, "VMware Screen Codec (ffmpeg)"}, {BUF_VIDEO_THEORA_RAW, CODEC_ID_THEORA, "Theora (ffmpeg)"}, + {BUF_VIDEO_SNOW, CODEC_ID_SNOW, "Snow (ffmpeg)"}, }; static const char *const skip_loop_filter_enum_names[] = { @@ -1731,6 +1732,7 @@ static const uint32_t supported_video_types[] = { BUF_VIDEO_FLASHSV, BUF_VIDEO_CAVS, BUF_VIDEO_VMNC, + BUF_VIDEO_SNOW, BUF_VIDEO_THEORA_RAW, 0 }; diff --git a/src/combined/nsf_demuxer.c b/src/combined/nsf_demuxer.c index ee05f0f90..8ee816c99 100644 --- a/src/combined/nsf_demuxer.c +++ b/src/combined/nsf_demuxer.c @@ -98,7 +98,7 @@ static int open_nsf_file(demux_nsf_t *this) { return 0; /* check for the signature */ - if ( memcmp(header, "NESM\x1A", 5) != 0 ) + if (memcmp(header, "NESM\x1A", 5) != 0) return 0; this->total_songs = header[6]; diff --git a/src/demuxers/demux_4xm.c b/src/demuxers/demux_4xm.c index f8977d8c8..62146cffc 100644 --- a/src/demuxers/demux_4xm.c +++ b/src/demuxers/demux_4xm.c @@ -125,25 +125,15 @@ static float get_le_float(unsigned char *buffer) * This function is called from the _open() function of this demuxer. * It returns 1 if 4xm file was opened successfully. */ static int open_fourxm_file(demux_fourxm_t *fourxm) { - unsigned char preview[12]; - int header_size; - unsigned char *header; - int i; - unsigned int fourcc_tag; - unsigned int size; - unsigned int current_track; - unsigned int audio_type; - unsigned int total_frames; - float fps; /* the file signature will be in the first 12 bytes */ if (_x_demux_read_header(fourxm->input, preview, 12) != 12) return 0; /* check for the signature tags */ - if ((_X_LE_32(&preview[0]) != RIFF_TAG) || - (_X_LE_32(&preview[8]) != _4XMV_TAG)) + if (!_x_is_fourcc(&preview[0], "RIFF") || + !_x_is_fourcc(&preview[8], "4XMV")) return 0; /* file is qualified; skip over the header bytes in the stream */ @@ -152,13 +142,13 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) { /* fetch the LIST-HEAD header */ if (fourxm->input->read(fourxm->input, preview, 12) != 12) return 0; - if ((_X_LE_32(&preview[0]) != LIST_TAG) || - (_X_LE_32(&preview[8]) != HEAD_TAG)) + if (!_x_is_fourcc(&preview[0], "LIST") || + !_x_is_fourcc(&preview[8], "HEAD") ) return 0; /* read the whole header */ - header_size = _X_LE_32(&preview[4]) - 4; - header = malloc(header_size); + const uint32_t header_size = _X_LE_32(&preview[4]) - 4; + uint8_t *const header = malloc(header_size); if (!header || fourxm->input->read(fourxm->input, header, header_size) != header_size) { free(header); return 0; @@ -171,12 +161,13 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) { fourxm->video_pts_inc = 0; /* take the lazy approach and search for any and all vtrk and strk chunks */ + int i; for (i = 0; i < header_size - 8; i++) { - fourcc_tag = _X_LE_32(&header[i]); - size = _X_LE_32(&header[i + 4]); + const uint32_t fourcc_tag = _X_LE_32(&header[i]); + const uint32_t size = _X_LE_32(&header[i + 4]); if (fourcc_tag == std__TAG) { - fps = get_le_float(&header[i + 12]); + const float fps = get_le_float(&header[i + 12]); fourxm->video_pts_inc = (int64_t)(90000.0 / fps); } else if (fourcc_tag == vtrk_TAG) { /* check that there is enough data */ @@ -184,7 +175,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) { free(header); return 0; } - total_frames = _X_LE_32(&header[i + 24]); + const uint32_t total_frames = _X_LE_32(&header[i + 24]); fourxm->duration_in_ms = total_frames; fourxm->duration_in_ms *= fourxm->video_pts_inc; fourxm->duration_in_ms /= 90000; @@ -198,7 +189,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) { free(header); return 0; } - current_track = _X_LE_32(&header[i + 8]); + const uint32_t current_track = _X_LE_32(&header[i + 8]); if (current_track + 1 > fourxm->track_count) { fourxm->track_count = current_track + 1; fourxm->tracks = realloc(fourxm->tracks, @@ -212,7 +203,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) { fourxm->tracks[current_track].channels = _X_LE_32(&header[i + 36]); fourxm->tracks[current_track].sample_rate = _X_LE_32(&header[i + 40]); fourxm->tracks[current_track].bits = _X_LE_32(&header[i + 44]); - audio_type = _X_LE_32(&header[i + 12]); + const uint32_t audio_type = _X_LE_32(&header[i + 12]); if (audio_type == 0) fourxm->tracks[current_track].audio_type = BUF_AUDIO_LPCM_LE; else if (audio_type == 1) @@ -239,20 +230,18 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) { demux_fourxm_t *this = (demux_fourxm_t *) this_gen; buf_element_t *buf = NULL; - unsigned int fourcc_tag; - unsigned int size; - unsigned char header[8]; unsigned int remaining_bytes; unsigned int current_track; /* read the next header */ + uint8_t header[8]; if (this->input->read(this->input, header, 8) != 8) { this->status = DEMUX_FINISHED; return this->status; } - fourcc_tag = _X_LE_32(&header[0]); - size = _X_LE_32(&header[4]); + const uint32_t fourcc_tag = _X_LE_32(&header[0]); + const uint32_t size = _X_LE_32(&header[4]); switch (fourcc_tag) { diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c index e6467ecd9..4076cc2e0 100644 --- a/src/demuxers/demux_aac.c +++ b/src/demuxers/demux_aac.c @@ -91,7 +91,7 @@ static int open_aac_file(demux_aac_t *this) { return 0; /* Check for an ADIF header - should be at the start of the file */ - if ( signature == ME_FOURCC('A', 'D', 'I', 'F') ) { + if (_x_is_fourcc(peak, "AIDF")) { lprintf("found ADIF header\n"); return 1; } @@ -128,9 +128,7 @@ static int open_aac_file(demux_aac_t *this) { if ((frame_size > 0) && (data_start+frame_size < MAX_PREVIEW_SIZE-1) && /* first 28 bits must be identical */ - (peak[data_start ] ==peak[data_start+frame_size ]) && - (peak[data_start+1] ==peak[data_start+frame_size+1]) && - (peak[data_start+2] ==peak[data_start+frame_size+2]) && + memcmp(&peak[data_start], &peak[data_start+frame_size], 4) == 0 && (peak[data_start+3]>>4==peak[data_start+frame_size+3]>>4)) { lprintf("found second ADTS header\n"); diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c index 601f5c865..8d0dc452c 100644 --- a/src/demuxers/demux_ac3.c +++ b/src/demuxers/demux_ac3.c @@ -37,6 +37,9 @@ #ifdef HAVE_ALLOCA_H #include <alloca.h> #endif +#ifdef HAVE_MALLOC_H +#include <malloc.h> +#endif #define LOG_MODULE "demux_ac3" #define LOG_VERBOSE diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c index 8e3b63643..fb60ee294 100644 --- a/src/demuxers/demux_aiff.c +++ b/src/demuxers/demux_aiff.c @@ -115,8 +115,8 @@ static int open_aiff_file(demux_aiff_t *this) { return 0; /* check the signature */ - if ((_X_BE_32(&signature[0]) != FORM_TAG) || - (_X_BE_32(&signature[8]) != AIFF_TAG)) + if( !_x_is_fourcc(&signature[0], "FORM") || + !_x_is_fourcc(&signature[8], "AIFF") ) return 0; /* file is qualified; skip over the header bytes in the stream */ diff --git a/src/demuxers/demux_aud.c b/src/demuxers/demux_aud.c index 5be209125..afb1e44ef 100644 --- a/src/demuxers/demux_aud.c +++ b/src/demuxers/demux_aud.c @@ -143,7 +143,7 @@ static int demux_aud_send_chunk(demux_plugin_t *this_gen) { } /* validate the chunk */ - if (_X_LE_32(&chunk_preamble[4]) != 0x0000DEAF) { + if (!_x_is_fourcc(&chunk_preamble[4], "\xAF\xDE\x00\x00")) { this->status = DEMUX_FINISHED; return this->status; } diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c index b69ba3859..a7d7bce9a 100644 --- a/src/demuxers/demux_dts.c +++ b/src/demuxers/demux_dts.c @@ -33,6 +33,9 @@ #ifdef HAVE_ALLOCA_H #include <alloca.h> #endif +#ifdef HAVE_MALLOC_H +#include <malloc.h> +#endif #define LOG_MODULE "demux_dts" #define LOG_VERBOSE diff --git a/src/demuxers/demux_eawve.c b/src/demuxers/demux_eawve.c index bf45f432a..ea3348e61 100644 --- a/src/demuxers/demux_eawve.c +++ b/src/demuxers/demux_eawve.c @@ -78,16 +78,16 @@ typedef struct { */ static uint32_t read_arbitary(input_plugin_t *input){ - uint8_t size, byte; - int i; - uint32_t word; + uint8_t size; if (input->read(input, (void*)&size, 1) != 1) { return 0; } - word = 0; + uint32_t word = 0; + int i; for (i=0;i<size;i++) { + uint8_t byte; if (input->read(input, (void*)&byte, 1) != 1) { return 0; } @@ -104,33 +104,25 @@ static uint32_t read_arbitary(input_plugin_t *input){ */ static int process_header(demux_eawve_t *this){ - int inHeader; - uint32_t blockid, size; + uint8_t header[12]; if (this->input->get_current_pos(this->input) != 0) this->input->seek(this->input, 0, SEEK_SET); - if (this->input->read(this->input, (void*)&blockid, 4) != 4) { - return 0; - } - if (be2me_32(blockid) != FOURCC_TAG('S', 'C', 'H', 'l')) { + if (this->input->read(this->input, header, sizeof(header)) != sizeof(header)) return 0; - } - if (this->input->read(this->input, (void*)&size, 4) != 4) { + if (!_x_is_fourcc(&header[0], "SCHl")) return 0; - } - size = le2me_32(size); - if (this->input->read(this->input, (void*)&blockid, 4) != 4) { - return 0; - } - if (be2me_32(blockid) != FOURCC_TAG('P', 'T', '\0', '\0')) { + if (!_x_is_fourcc(&header[8], "PT\0\0")) { lprintf("PT header missing\n"); return 0; } - inHeader = 1; + const uint32_t size = _X_LE_32(&header[4]); + + int inHeader = 1; while (inHeader) { int inSubheader; uint8_t byte; diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c index 32cf161a0..5699dbe12 100644 --- a/src/demuxers/demux_film.c +++ b/src/demuxers/demux_film.c @@ -141,9 +141,9 @@ static int open_film_file(demux_film_t *film) { return 0; /* FILM signature correct? */ - if (memcmp(scratch, "FILM", 4)) { + if (!_x_is_fourcc(scratch, "FILM")) return 0; - } + llprintf(DEBUG_FILM_LOAD, "found 'FILM' signature\n"); /* file is qualified; skip over the header bytes in the stream */ diff --git a/src/demuxers/demux_mpc.c b/src/demuxers/demux_mpc.c index e11d85ee4..b5516bad5 100644 --- a/src/demuxers/demux_mpc.c +++ b/src/demuxers/demux_mpc.c @@ -47,6 +47,7 @@ #include <xine/buffer.h> #include "bswap.h" #include "group_audio.h" +#include "id3.h" /* Note that the header is actually 25 bytes long, so we'd only read 28 * (because of byte swapping we have to round up to nearest multiple of 4) @@ -89,17 +90,13 @@ static int open_mpc_file(demux_mpc_t *this) { /* TODO: non-seeking version */ if (INPUT_IS_SEEKABLE(this->input)) { /* Check for id3v2 tag */ - if ((this->header[0] == 'I') || - (this->header[1] == 'D') || - (this->header[2] == '3')) { + if (id3v2_istag(this->header)) { lprintf("found id3v2 header\n"); /* Read tag size */ - id3v2_size = (this->header[6] << 21) + - (this->header[7] << 14) + - (this->header[8] << 7) + - this->header[9] + 10; + + id3v2_size = _X_BE_32_synchsafe(&this->header[6]) + 10; /* Add footer size if one is present */ if (this->header[5] & 0x10) @@ -118,9 +115,7 @@ static int open_mpc_file(demux_mpc_t *this) { } /* Validate signature - We only support SV 7.x at the moment */ - if ((this->header[0] != 'M') || - (this->header[1] != 'P') || - (this->header[2] != '+') || + if ( memcmp(this->header, "MP+", 3) != 0 || ((this->header[3]&0x0f) != 0x07)) return 0; diff --git a/src/demuxers/demux_nsv.c b/src/demuxers/demux_nsv.c index 9c3b85e86..3c67cbf78 100644 --- a/src/demuxers/demux_nsv.c +++ b/src/demuxers/demux_nsv.c @@ -50,7 +50,6 @@ #define FOURCC_TAG BE_FOURCC #define NSVf_TAG FOURCC_TAG('N', 'S', 'V', 'f') #define NSVs_TAG FOURCC_TAG('N', 'S', 'V', 's') -#define NONE_TAG FOURCC_TAG('N', 'O', 'N', 'E') #define BEEF 0xEFBE @@ -256,17 +255,11 @@ static int open_nsv_file(demux_nsv_t *this) { return 0; /* check for a 'NSV' signature */ - if ((preview[0] != 'N') || - (preview[1] != 'S') || - (preview[2] != 'V')) - { - if ((preview[0] != 'Z') || - (preview[1] != 0) || - (preview[2] != '9')) - return 0; + if ( memcmp(preview, "Z\09", 3) == 0) { this->is_ultravox = preview[3]; this->ultravox_first = 1; - } + } else if ( memcmp(preview, "NSV", 3) != 0 ) + return 0; lprintf("NSV file detected, ultravox=%d\n", this->is_ultravox); @@ -302,7 +295,7 @@ static int open_nsv_file(demux_nsv_t *this) { return 0; this->video_fourcc = _X_ME_32(&preview[4]); - if (_X_BE_32(&preview[4]) == NONE_TAG) + if (_x_is_fourcc(&preview[4], "NONE")) this->video_type = 0; else { @@ -312,7 +305,7 @@ static int open_nsv_file(demux_nsv_t *this) { } this->audio_fourcc = _X_ME_32(&preview[8]); - if (_X_BE_32(&preview[8]) == NONE_TAG) + if (_x_is_fourcc(&preview[8], "NONE")) this->audio_type = 0; else { diff --git a/src/demuxers/demux_rawdv.c b/src/demuxers/demux_rawdv.c index da83a625c..bffd4c9c0 100644 --- a/src/demuxers/demux_rawdv.c +++ b/src/demuxers/demux_rawdv.c @@ -368,8 +368,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str } /* DIF (DV) movie file */ - if (!((buf[0] == 0x1f) && (buf[1] == 0x07) && (buf[2] == 00) && - (buf[4] ^ 0x01))) { + if (memcmp(buf, "\x1F\x07\x00", 3) != 0 || !(buf[4] ^ 0x01)) { free (this); return NULL; } diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index b7f2fc569..105dc60a5 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -58,12 +58,10 @@ #include "real_common.h" #define FOURCC_TAG BE_FOURCC -#define RMF_TAG FOURCC_TAG('.', 'R', 'M', 'F') #define PROP_TAG FOURCC_TAG('P', 'R', 'O', 'P') #define MDPR_TAG FOURCC_TAG('M', 'D', 'P', 'R') #define CONT_TAG FOURCC_TAG('C', 'O', 'N', 'T') #define DATA_TAG FOURCC_TAG('D', 'A', 'T', 'A') -#define INDX_TAG FOURCC_TAG('I', 'N', 'D', 'X') #define RA_TAG FOURCC_TAG('.', 'r', 'a', 0xfd) #define VIDO_TAG FOURCC_TAG('V', 'I', 'D', 'O') @@ -183,8 +181,6 @@ 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; - unsigned int entries, stream_num; - real_index_entry_t **index; while(next_index_chunk) { lprintf("reading index chunk at %"PRIX64"\n", next_index_chunk); @@ -200,70 +196,68 @@ static void real_parse_index(demux_real_t *this) { } /* Check chunk is actually an index chunk */ - if(_X_BE_32(&index_chunk_header[0]) == INDX_TAG) { - unsigned short version; + if(!_x_is_fourcc(&index_chunk_header[0], "INDX")) { + lprintf("expected index chunk found chunk type: %.4s\n", &index_chunk_header[0]); + break; + } - /* Check version */ - version = _X_BE_16(&index_chunk_header[8]); - if(version != 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_real: unknown object version in INDX: 0x%04x\n", version); - break; - } + /* Check version */ + const uint16_t version = _X_BE_16(&index_chunk_header[8]); + if(version != 0) { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_real: unknown object version in INDX: 0x%04x\n", version); + break; + } - /* Read data from header */ - entries = _X_BE_32(&index_chunk_header[10]); - stream_num = _X_BE_16(&index_chunk_header[14]); - next_index_chunk = _X_BE_32(&index_chunk_header[16]); - - /* Find which stream this index is for */ - index = NULL; - for(i = 0; i < this->num_video_streams; i++) { - if(stream_num == this->video_streams[i].mdpr->stream_number) { - index = &this->video_streams[i].index; - this->video_streams[i].index_entries = entries; - lprintf("found index chunk for video stream with num %d\n", stream_num); - break; - } + /* Read data from header */ + const uint32_t entries = _X_BE_32(&index_chunk_header[10]); + const uint16_t stream_num = _X_BE_16(&index_chunk_header[14]); + next_index_chunk = _X_BE_32(&index_chunk_header[16]); + + /* Find which stream this index is for */ + real_index_entry_t **index = NULL; + for(i = 0; i < this->num_video_streams; i++) { + if(stream_num == this->video_streams[i].mdpr->stream_number) { + index = &this->video_streams[i].index; + this->video_streams[i].index_entries = entries; + lprintf("found index chunk for video stream with num %d\n", stream_num); + break; } + } - if(!index) { - for(i = 0; i < this->num_audio_streams; i++) { - if(stream_num == this->audio_streams[i].mdpr->stream_number) { - index = &this->audio_streams[i].index; - this->audio_streams[i].index_entries = entries; - lprintf("found index chunk for audio stream with num %d\n", stream_num); - break; - } - } + if(!index) { + for(i = 0; i < this->num_audio_streams; i++) { + if(stream_num == this->audio_streams[i].mdpr->stream_number) { + index = &this->audio_streams[i].index; + this->audio_streams[i].index_entries = entries; + lprintf("found index chunk for audio stream with num %d\n", stream_num); + break; + } } + } - if(index && entries) - /* Allocate memory for index */ - *index = calloc(entries, sizeof(real_index_entry_t)); + 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++) { - if(this->input->read(this->input, index_record, INDEX_RECORD_SIZE) - != INDEX_RECORD_SIZE) { - lprintf("index record not read\n"); - free(*index); - *index = NULL; - break; - } - - (*index)[i].timestamp = _X_BE_32(&index_record[2]); - (*index)[i].offset = _X_BE_32(&index_record[6]); - (*index)[i].packetno = _X_BE_32(&index_record[10]); - } - } else { - lprintf("unused index chunk with %d entries for stream num %d\n", - entries, stream_num); + if(index && entries && *index) { + /* Read index */ + for(i = 0; i < entries; i++) { + if(this->input->read(this->input, index_record, INDEX_RECORD_SIZE) + != INDEX_RECORD_SIZE) { + lprintf("index record not read\n"); + free(*index); + *index = NULL; + break; + } + + (*index)[i].timestamp = _X_BE_32(&index_record[2]); + (*index)[i].offset = _X_BE_32(&index_record[6]); + (*index)[i].packetno = _X_BE_32(&index_record[10]); } } else { - lprintf("expected index chunk found chunk type: %.4s\n", &index_chunk_header[0]); - break; + lprintf("unused index chunk with %d entries for stream num %d\n", + entries, stream_num); } } @@ -319,17 +313,12 @@ static void real_free_mdpr (mdpr_t *mdpr) { static void real_parse_audio_specific_data (demux_real_t *this, real_stream_t * stream, - uint8_t * data, int len) + uint8_t * data) { - int coded_frame_size; - int codec_data_length; - int coded_frame_size2; - int subpacket_size; - - coded_frame_size = _X_BE_32 (data+24); - codec_data_length = _X_BE_16 (data+40); - coded_frame_size2 = _X_BE_16 (data+42); - subpacket_size = _X_BE_16 (data+44); + const uint32_t coded_frame_size = _X_BE_32 (data+24); + 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; @@ -359,15 +348,15 @@ static void real_parse_audio_specific_data (demux_real_t *this, "demux_real: error, i don't handle buf type 0x%08x\n", stream->buf_type); } - if (stream->sps) { - stream->frame_size = stream->w / stream->sps * stream->h * stream->sps; - stream->frame_buffer = xine_xmalloc (stream->frame_size); - stream->frame_num_bytes = 0; - } else { - stream->frame_size = stream->w * stream->h; - stream->frame_buffer = xine_xmalloc (stream->frame_size); - stream->frame_num_bytes = 0; - } + /* + * when stream->sps is set it used to do this: + * stream->frame_size = stream->w / stream->sps * stream->h * stream->sps; + * but it looks pointless? the compiler will probably optimise it away, I suppose? + */ + stream->frame_size = stream->w * stream->h; + + stream->frame_buffer = calloc(stream->frame_size, 1); + stream->frame_num_bytes = 0; stream->sub_packet_cnt = 0; xprintf (this->stream->xine, XINE_VERBOSITY_LOG, @@ -381,37 +370,35 @@ static void real_parse_headers (demux_real_t *this) { char preamble[PREAMBLE_SIZE]; unsigned int chunk_type = 0; unsigned int chunk_size; - unsigned short version; - unsigned char *chunk_buffer; - int field_size; - int stream_ptr; - unsigned char data_chunk_header[DATA_CHUNK_HEADER_SIZE]; - unsigned char signature[REAL_SIGNATURE_SIZE]; - - this->data_start = 0; - this->data_size = 0; - this->num_video_streams = 0; - this->num_audio_streams = 0; if (INPUT_IS_SEEKABLE(this->input)) this->input->seek (this->input, 0, SEEK_SET); - if (this->input->read(this->input, signature, REAL_SIGNATURE_SIZE) != - REAL_SIGNATURE_SIZE) { + { + 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); + return; + } - lprintf ("signature not read\n"); - this->status = DEMUX_FINISHED; - return; + /* skip to the start of the first chunk and start traversing */ + chunk_size = _X_BE_32(&signature[4]); } - if (_X_BE_32(signature) != RMF_TAG) { - this->status = DEMUX_FINISHED; - lprintf ("signature not found '%.4s'\n", signature); - return; - } + this->data_start = 0; + this->data_size = 0; + this->num_video_streams = 0; + this->num_audio_streams = 0; - /* skip to the start of the first chunk and start traversing */ - chunk_size = _X_BE_32(&signature[4]); this->input->seek(this->input, chunk_size-8, SEEK_CUR); /* iterate through chunks and gather information until the first DATA @@ -432,189 +419,181 @@ static void real_parse_headers (demux_real_t *this) { case PROP_TAG: case MDPR_TAG: case CONT_TAG: - - chunk_size -= PREAMBLE_SIZE; - chunk_buffer = malloc(chunk_size); - if (this->input->read(this->input, chunk_buffer, chunk_size) != - chunk_size) { - free (chunk_buffer); - this->status = DEMUX_FINISHED; - return; - } + { + chunk_size -= PREAMBLE_SIZE; + uint8_t *const chunk_buffer = malloc(chunk_size); + if (this->input->read(this->input, chunk_buffer, chunk_size) != + chunk_size) { + free (chunk_buffer); + this->status = DEMUX_FINISHED; + return; + } - version = _X_BE_16(&chunk_buffer[0]); + uint16_t version = _X_BE_16(&chunk_buffer[0]); - if (chunk_type == PROP_TAG) { + 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); - free(chunk_buffer); - this->status = DEMUX_FINISHED; - return; - } + if(version != 0) { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demuxe_real: unknown object version in PROP: 0x%04x\n", version); + free(chunk_buffer); + this->status = DEMUX_FINISHED; + return; + } - this->duration = _X_BE_32(&chunk_buffer[22]); - this->index_start = _X_BE_32(&chunk_buffer[30]); - this->data_start = _X_BE_32(&chunk_buffer[34]); - this->avg_bitrate = _X_BE_32(&chunk_buffer[6]); + this->duration = _X_BE_32(&chunk_buffer[22]); + this->index_start = _X_BE_32(&chunk_buffer[30]); + this->data_start = _X_BE_32(&chunk_buffer[34]); + this->avg_bitrate = _X_BE_32(&chunk_buffer[6]); - lprintf("PROP: duration: %d ms\n", this->duration); - lprintf("PROP: index start: %"PRIX64"\n", this->index_start); - lprintf("PROP: data start: %"PRIX64"\n", this->data_start); - lprintf("PROP: average bit rate: %"PRId64"\n", this->avg_bitrate); + lprintf("PROP: duration: %d ms\n", this->duration); + lprintf("PROP: index start: %"PRIX64"\n", this->index_start); + lprintf("PROP: data start: %"PRIX64"\n", this->data_start); + lprintf("PROP: average bit rate: %"PRId64"\n", this->avg_bitrate); - if (this->avg_bitrate<1) - this->avg_bitrate = 1; + if (this->avg_bitrate<1) + this->avg_bitrate = 1; - _x_stream_info_set(this->stream, XINE_STREAM_INFO_BITRATE, + _x_stream_info_set(this->stream, XINE_STREAM_INFO_BITRATE, this->avg_bitrate); - } else if (chunk_type == MDPR_TAG) { - - mdpr_t *mdpr; - uint32_t fourcc; - - if (version != 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_real: unknown object version in MDPR: 0x%04x\n", version); - free(chunk_buffer); - continue; - } + } else if (chunk_type == MDPR_TAG) { + if (version != 0) { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_real: unknown object version in MDPR: 0x%04x\n", version); + free(chunk_buffer); + continue; + } - mdpr = real_parse_mdpr (chunk_buffer); - - lprintf ("parsing type specific data...\n"); - if(!strcmp(mdpr->mime_type, "audio/X-MP3-draft-00")) { - lprintf ("mpeg layer 3 audio detected...\n"); - - fourcc = ME_FOURCC('a', 'd', 'u', 0x55); - this->audio_streams[this->num_audio_streams].fourcc = fourcc; - this->audio_streams[this->num_audio_streams].buf_type = _x_formattag_to_buf_audio(fourcc); - this->audio_streams[this->num_audio_streams].index = NULL; - this->audio_streams[this->num_audio_streams].mdpr = mdpr; - this->num_audio_streams++; - } else if(_X_BE_32(mdpr->type_specific_data) == RA_TAG) { - int version, len; - - if(this->num_audio_streams == MAX_AUDIO_STREAMS) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_real: maximum number of audio stream exceeded\n"); - goto unknown; - } + mdpr_t *const mdpr = real_parse_mdpr (chunk_buffer); + + lprintf ("parsing type specific data...\n"); + if(!strcmp(mdpr->mime_type, "audio/X-MP3-draft-00")) { + lprintf ("mpeg layer 3 audio detected...\n"); + + static const uint32_t fourcc = ME_FOURCC('a', 'd', 'u', 0x55); + this->audio_streams[this->num_audio_streams].fourcc = fourcc; + this->audio_streams[this->num_audio_streams].buf_type = _x_formattag_to_buf_audio(fourcc); + this->audio_streams[this->num_audio_streams].index = NULL; + this->audio_streams[this->num_audio_streams].mdpr = mdpr; + this->num_audio_streams++; + } else if(_X_BE_32(mdpr->type_specific_data) == RA_TAG) { + if(this->num_audio_streams == MAX_AUDIO_STREAMS) { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_real: maximum number of audio stream exceeded\n"); + goto unknown; + } - version = _X_BE_16(mdpr->type_specific_data + 4); + const uint16_t version = _X_BE_16(mdpr->type_specific_data + 4); - lprintf("audio version %d detected\n", version); + lprintf("audio version %d detected\n", version); - switch(version) { + char *fourcc_ptr = NULL; + switch(version) { case 3: /* 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 */ - fourcc = _X_ME_32(mdpr->type_specific_data + mdpr->type_specific_len - 5); + fourcc_ptr = mdpr->type_specific_data + mdpr->type_specific_len - 5; break; - case 4: - len = *(mdpr->type_specific_data + 56); - fourcc = _X_ME_32(mdpr->type_specific_data + 58 + len); + case 4: { + const uint8_t len = *(mdpr->type_specific_data + 56); + fourcc_ptr = mdpr->type_specific_data + 58 + len; + } break; case 5: - fourcc = _X_ME_32(mdpr->type_specific_data + 66); + fourcc_ptr = mdpr->type_specific_data + 66; break; default: lprintf("unsupported audio header version %d\n", version); goto unknown; - } + } + + lprintf("fourcc = %.4s\n", fourcc_ptr); - lprintf("fourcc = %.4s\n", (char *) &fourcc); + const uint32_t fourcc = _X_ME_32(fourcc_ptr); - this->audio_streams[this->num_audio_streams].fourcc = fourcc; - this->audio_streams[this->num_audio_streams].buf_type = _x_formattag_to_buf_audio(fourcc); - this->audio_streams[this->num_audio_streams].index = NULL; - this->audio_streams[this->num_audio_streams].mdpr = mdpr; + this->audio_streams[this->num_audio_streams].fourcc = fourcc; + this->audio_streams[this->num_audio_streams].buf_type = _x_formattag_to_buf_audio(fourcc); + this->audio_streams[this->num_audio_streams].index = NULL; + this->audio_streams[this->num_audio_streams].mdpr = mdpr; - real_parse_audio_specific_data (this, - &this->audio_streams[this->num_audio_streams], - mdpr->type_specific_data, - mdpr->type_specific_len); - this->num_audio_streams++; + if (!this->audio_streams[this->num_audio_streams].buf_type) + _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, fourcc); - if (!this->audio_streams[this->num_audio_streams].buf_type) - _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, fourcc); + real_parse_audio_specific_data (this, + &this->audio_streams[this->num_audio_streams], + mdpr->type_specific_data); + this->num_audio_streams++; - } else if(_X_BE_32(mdpr->type_specific_data + 4) == VIDO_TAG) { + } else if(_X_BE_32(mdpr->type_specific_data + 4) == VIDO_TAG) { - if(this->num_video_streams == MAX_VIDEO_STREAMS) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_real: maximum number of video stream exceeded\n"); - goto unknown; - } + if(this->num_video_streams == MAX_VIDEO_STREAMS) { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_real: maximum number of video stream exceeded\n"); + goto unknown; + } - lprintf ("video detected\n"); - fourcc = _X_ME_32(mdpr->type_specific_data + 8); - lprintf("fourcc = %.4s\n", (char *) &fourcc); + lprintf ("video detected\n"); + const uint32_t fourcc = _X_ME_32(mdpr->type_specific_data + 8); + lprintf("fourcc = %.4s\n", (char *) &fourcc); - this->video_streams[this->num_video_streams].fourcc = fourcc; - this->video_streams[this->num_video_streams].buf_type = _x_fourcc_to_buf_video(fourcc); - this->video_streams[this->num_video_streams].format = _X_BE_32(mdpr->type_specific_data + 30); - this->video_streams[this->num_video_streams].index = NULL; - this->video_streams[this->num_video_streams].mdpr = mdpr; + this->video_streams[this->num_video_streams].fourcc = fourcc; + this->video_streams[this->num_video_streams].buf_type = _x_fourcc_to_buf_video(fourcc); + this->video_streams[this->num_video_streams].format = _X_BE_32(mdpr->type_specific_data + 30); + this->video_streams[this->num_video_streams].index = NULL; + this->video_streams[this->num_video_streams].mdpr = mdpr; - this->num_video_streams++; + this->num_video_streams++; - if (!this->video_streams[this->num_video_streams].buf_type) - _x_report_video_fourcc (this->stream->xine, LOG_MODULE, fourcc); + if (!this->video_streams[this->num_video_streams].buf_type) + _x_report_video_fourcc (this->stream->xine, LOG_MODULE, fourcc); - } else { - lprintf("unrecognised type specific data\n"); + } else { + lprintf("unrecognised type specific data\n"); -unknown: - real_free_mdpr(mdpr); - } + unknown: + real_free_mdpr(mdpr); + } - } else if (chunk_type == CONT_TAG) { + } else if (chunk_type == CONT_TAG) { - if(version != 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_real: unknown object version in CONT: 0x%04x\n", version); - free(chunk_buffer); - continue; - } + if(version != 0) { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_real: unknown object version in CONT: 0x%04x\n", version); + free(chunk_buffer); + continue; + } - stream_ptr = 2; - - /* load the title string */ - field_size = _X_BE_16(&chunk_buffer[stream_ptr]); - stream_ptr += 2; - _x_meta_info_n_set(this->stream, XINE_META_INFO_TITLE, - &chunk_buffer[stream_ptr], field_size); - stream_ptr += field_size; - - /* load the author string */ - field_size = _X_BE_16(&chunk_buffer[stream_ptr]); - stream_ptr += 2; - _x_meta_info_n_set(this->stream, XINE_META_INFO_ARTIST, - &chunk_buffer[stream_ptr], field_size); - stream_ptr += field_size; - - /* load the copyright string as the year */ - field_size = _X_BE_16(&chunk_buffer[stream_ptr]); - stream_ptr += 2; - _x_meta_info_n_set(this->stream, XINE_META_INFO_YEAR, - &chunk_buffer[stream_ptr], field_size); - stream_ptr += field_size; - - /* load the comment string */ - field_size = _X_BE_16(&chunk_buffer[stream_ptr]); - stream_ptr += 2; - _x_meta_info_n_set(this->stream, XINE_META_INFO_COMMENT, - &chunk_buffer[stream_ptr], field_size); - stream_ptr += field_size; - } + int stream_ptr = 2; +#define SET_METADATA_STRING(type) \ + do { \ + const uint16_t field_size = _X_BE_16(&chunk_buffer[stream_ptr]); \ + stream_ptr += 2; \ + _x_meta_info_n_set(this->stream, type, \ + &chunk_buffer[stream_ptr], field_size); \ + stream_ptr += field_size; \ + } while(0) + + /* load the title string */ + SET_METADATA_STRING(XINE_META_INFO_TITLE); + + /* load the author string */ + SET_METADATA_STRING(XINE_META_INFO_ARTIST); + + /* load the copyright string as the year */ + SET_METADATA_STRING(XINE_META_INFO_YEAR); + + /* load the comment string */ + SET_METADATA_STRING(XINE_META_INFO_COMMENT); + } - free(chunk_buffer); + free(chunk_buffer); + } break; - case DATA_TAG: + case DATA_TAG: { + uint8_t data_chunk_header[DATA_CHUNK_HEADER_SIZE]; + if (this->input->read(this->input, data_chunk_header, DATA_CHUNK_HEADER_SIZE) != DATA_CHUNK_HEADER_SIZE) { this->status = DEMUX_FINISHED; @@ -622,7 +601,7 @@ unknown: } /* check version */ - version = _X_BE_16(&data_chunk_header[0]); + const uint16_t version = _X_BE_16(&data_chunk_header[0]); if(version != 0) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: unknown object version in DATA: 0x%04x\n", version); @@ -633,7 +612,8 @@ unknown: this->current_data_chunk_packet_count = _X_BE_32(&data_chunk_header[2]); this->next_data_chunk_offset = _X_BE_32(&data_chunk_header[6]); this->data_chunk_size = chunk_size; - break; + } + break; default: /* this should not occur, but in case it does, skip the chunk */ @@ -649,16 +629,9 @@ unknown: real_parse_index(this); /* Simple stream selection case - 0/1 audio/video streams */ - if(this->num_video_streams == 1) - this->video_stream = &this->video_streams[0]; - else - this->video_stream = NULL; + 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; - if(this->num_audio_streams == 1) - this->audio_stream = &this->audio_streams[0]; - else - this->audio_stream = 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,15 +671,13 @@ unknown: while((offset < len) && ((!this->video_stream && (this->num_video_streams > 0)) || (!this->audio_stream && (this->num_audio_streams > 0)))) { - uint32_t id; - int i, stream; + int i; /* Check for end of the data chunk */ - if(((id = _X_BE_32(&search_buffer[offset])) == DATA_TAG) || - (id == INDX_TAG)) - break; + if (_x_is_fourcc(&search_buffer[offset], "INDX") || _x_is_fourcc(&search_buffer[offset], "DATA")) + break; - stream = _X_BE_16(&search_buffer[offset + 4]); + const int stream = _X_BE_16(&search_buffer[offset + 4]); for(i = 0; !this->video_stream && (i < this->num_video_streams); i++) { if(stream == this->video_streams[i].mdpr->stream_number) { @@ -740,14 +711,12 @@ unknown: /* Send headers and set meta info */ if(this->video_stream) { - buf_element_t *buf; - /* Check for recognised codec*/ if(!this->video_stream->buf_type) this->video_stream->buf_type = BUF_VIDEO_UNKNOWN; /* Send header */ - buf = this->video_fifo->buffer_pool_alloc(this->video_fifo); + 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, @@ -780,10 +749,9 @@ unknown: /* Send headers */ if(this->audio_fifo) { - mdpr_t *mdpr = this->audio_stream->mdpr; - buf_element_t *buf; + mdpr_t *const mdpr = this->audio_stream->mdpr; - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf_element_t *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; @@ -793,7 +761,7 @@ unknown: * 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) { - int version = _X_BE_16(mdpr->type_specific_data + 4); + const uint16_t version = _X_BE_16(mdpr->type_specific_data + 4); if(version != 5) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, @@ -954,9 +922,7 @@ static int demux_real_parse_references( demux_real_t *this) { #define PTS_VIDEO 1 static void check_newpts (demux_real_t *this, int64_t pts, int video, int preview) { - int64_t diff; - - diff = pts - this->last_pts[video]; + const int64_t diff = pts - this->last_pts[video]; lprintf ("check_newpts %"PRId64"\n", pts); if (!preview && pts && @@ -1062,19 +1028,14 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { demux_real_t *this = (demux_real_t *) this_gen; char header[DATA_PACKET_HEADER_SIZE]; - int stream, size, keyframe, input_time = 0; - unsigned short version; - uint32_t id, timestamp; - int64_t pts; - off_t offset, input_length = 0; + int keyframe, input_time = 0; int normpos = 0; - read_next_packet: if(this->reference_mode) return demux_real_parse_references(this); /* load a header from wherever the stream happens to be pointing */ - if ( (size=this->input->read(this->input, header, DATA_PACKET_HEADER_SIZE)) != + if ( this->input->read(this->input, header, DATA_PACKET_HEADER_SIZE) != DATA_PACKET_HEADER_SIZE) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, @@ -1085,15 +1046,14 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { } /* Check to see if we've gone past the end of the data chunk */ - if(((id = _X_BE_32(&header[0])) == DATA_TAG) || - (id == INDX_TAG)) { + if (_x_is_fourcc(&header[0], "INDX") || _x_is_fourcc(&header[0], "DATA")) { lprintf("finished reading data chunk\n"); this->status = DEMUX_FINISHED; return this->status; } /* check version */ - version = _X_BE_16(&header[0]); + const uint16_t version = _X_BE_16(&header[0]); if(version > 1) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: unknown object version in data packet: 0x%04x\n", version); @@ -1102,11 +1062,11 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { } /* read the packet information */ - stream = _X_BE_16(&header[4]); - offset = this->input->get_current_pos(this->input); - size = _X_BE_16(&header[2]) - DATA_PACKET_HEADER_SIZE; - timestamp= _X_BE_32(&header[6]); - pts = (int64_t) timestamp * 90; + const uint16_t stream = _X_BE_16(&header[4]); + const off_t offset = 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) @@ -1121,11 +1081,9 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { if (this->video_stream && (stream == this->video_stream->mdpr->stream_number)) { - int vpkg_header, vpkg_length, vpkg_offset; int vpkg_seqnum = -1; int vpkg_subseq = 0; buf_element_t *buf; - int n, fragment_size; uint32_t decoder_flags; lprintf ("video chunk detected.\n"); @@ -1140,21 +1098,20 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { * bit 6: 1=short header (only one block?) */ - vpkg_header = stream_read_char (this); size--; + const int vpkg_header = stream_read_char (this); size--; lprintf ("vpkg_hdr: %02x (size=%d)\n", vpkg_header, size); + int vpkg_length, vpkg_offset; if (0x40==(vpkg_header&0xc0)) { /* * seems to be a very short header * 2 bytes, purpose of the second byte yet unknown */ - int bummer; - - bummer = stream_read_char (this); size--; + const int bummer = stream_read_char (this); lprintf ("bummer == %02X\n",bummer); vpkg_offset = 0; - vpkg_length = size; + vpkg_length = --size; } else { @@ -1215,9 +1172,8 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { input_time = (int)((int64_t) this->input->get_current_pos(this->input) * 8 * 1000 / this->avg_bitrate); - if(this->data_start && this->data_chunk_size) - input_length = this->data_start + 18 + this->data_chunk_size; - if( input_length ) + 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); @@ -1262,13 +1218,17 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { * calc size of fragment */ - if ((vpkg_header & 0xc0) == 0x080) + int fragment_size; + switch(vpkg_header & 0xc0) { + case 0x80: fragment_size = vpkg_offset; - else { - if (0x00 == (vpkg_header&0xc0)) - fragment_size = size; - else - fragment_size = vpkg_length; + break; + case 0x00: + fragment_size = size; + break; + default: + fragment_size = vpkg_length; + break; } lprintf ("fragment size is %d\n", fragment_size); @@ -1276,14 +1236,11 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { * read fragment_size bytes of data */ - n = fragment_size; + int n = fragment_size; while(n) { buf = this->video_fifo->buffer_pool_alloc(this->video_fifo); - if(n>buf->max_size) - buf->size = buf->max_size; - else - buf->size = n; + buf->size = MIN(n, buf->max_size); buf->decoder_flags = decoder_flags; decoder_flags &= ~BUF_FLAG_FRAME_START; @@ -1367,12 +1324,9 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { input_time = (int)((int64_t) this->input->get_current_pos(this->input) * 8 * 1000 / this->avg_bitrate); - if(this->data_start && this->data_chunk_size) - input_length = this->data_start + 18 + this->data_chunk_size; - else - input_length = 0; + const off_t input_length = this->data_start + 18 + this->data_chunk_size; - if( input_length ) + if( input_length > 18 ) normpos = (int)((double) this->input->get_current_pos(this->input) * 65535 / input_length); check_newpts (this, pts, PTS_AUDIO, 0); @@ -1380,13 +1334,14 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { /* 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, frames, *sizes; + int i; /* Upper 4 bits of second byte is frame count */ - frames = (stream_read_word(this) & 0xf0) >> 4; + const int frames = (stream_read_word(this) & 0xf0) >> 4; /* 2 bytes per frame size */ - sizes = calloc(frames, sizeof(int)); + int sizes[frames]; + for(i = 0; i < frames; i++) sizes[i] = stream_read_word(this); @@ -1398,15 +1353,12 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read AAC frame\n"); - free(sizes); this->status = DEMUX_FINISHED; return this->status; } pts = 0; /* Only set pts on first frame */ } - - free(sizes); } else if (this->audio_stream->buf_type == BUF_AUDIO_COOK || this->audio_stream->buf_type == BUF_AUDIO_ATRK || this->audio_stream->buf_type == BUF_AUDIO_28_8 || @@ -1497,18 +1449,10 @@ discard: /* check if it's time to reload */ if (!this->current_data_chunk_packet_count && this->next_data_chunk_offset) { - char preamble[PREAMBLE_SIZE]; unsigned char data_chunk_header[DATA_CHUNK_HEADER_SIZE]; /* seek to the next DATA chunk offset */ - this->input->seek(this->input, this->next_data_chunk_offset, SEEK_SET); - - /* load the DATA chunk preamble */ - if (this->input->read(this->input, preamble, PREAMBLE_SIZE) != - PREAMBLE_SIZE) { - this->status = DEMUX_FINISHED; - return this->status; - } + this->input->seek(this->input, this->next_data_chunk_offset + PREAMBLE_SIZE, SEEK_SET); /* load the rest of the DATA chunk header */ if (this->input->read(this->input, data_chunk_header, @@ -1657,7 +1601,6 @@ static void demux_real_dispose (demux_plugin_t *this_gen) { } free(this->fragment_tab); - free(this); } @@ -1684,21 +1627,27 @@ static int demux_real_get_optional_data(demux_plugin_t *this_gen, } /* help function to discover stream type. returns: + * -1 if couldn't read * 0 if not known. * 1 if normal stream. * 2 if reference stream. */ -static int real_check_stream_type(uint8_t *buf, int len) +static int real_check_stream_type(input_plugin_t *input) { - if ((buf[0] == 0x2e) - && (buf[1] == 'R') - && (buf[2] == 'M') - && (buf[3] == 'F')) + uint8_t buf[1024]; + off_t len = _x_demux_read_header(input, buf, sizeof(buf)); + + if ( len < 4 ) + return -1; + + if ( memcmp(buf, "\x2eRMF", 4) == 0 ) return 1; - buf[len] = '\0'; - if( strstr(buf,"pnm://") || strstr(buf,"rtsp://") || strstr(buf,"<smil>") || - !strncmp(buf,"http://",7) ) +#define my_strnstr(haystack, haystacklen, needle) \ + memmem(haystack, haystacklen, needle, sizeof(needle)) + + if( my_strnstr(buf, len, "pnm://") || my_strnstr(buf, len, "rtsp://") || + my_strnstr(buf, len, "<smil>") || !strncmp(buf, "http://", MIN(7, len)) ) return 2; return 0; @@ -1707,26 +1656,20 @@ static int real_check_stream_type(uint8_t *buf, int len) static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *stream, input_plugin_t *input) { - demux_real_t *this; - uint8_t buf[1024+1]; - int len, stream_type=0; - - switch (stream->content_detection_method) { - - case METHOD_BY_CONTENT:{ + /* discover stream type */ + const int stream_type = real_check_stream_type(input); - if (! (len = _x_demux_read_header(input, buf, 1024)) ) - return NULL; + if ( stream_type < 0 ) + return NULL; - lprintf ("read 4 bytes: %02x %02x %02x %02x\n", - buf[0], buf[1], buf[2], buf[3]); + switch (stream->content_detection_method) { - if (!(stream_type = real_check_stream_type(buf,len))) + case METHOD_BY_CONTENT: + if ( stream_type < 1 ) return NULL; - } - - lprintf ("by content accepted.\n"); - break; + + lprintf ("by content accepted.\n"); + break; case METHOD_BY_MRL: case METHOD_EXPLICIT: @@ -1736,17 +1679,11 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str return NULL; } - - this = calloc(1, sizeof(demux_real_t)); + demux_real_t *this = calloc(1, sizeof(demux_real_t)); this->stream = stream; this->input = input; - /* discover stream type */ - if(!stream_type) - if ( (len = _x_demux_read_header(this->input, buf, 1024)) ) - stream_type = real_check_stream_type(buf,len); - if(stream_type == 2){ this->reference_mode = 1; lprintf("reference stream detected\n"); @@ -1768,9 +1705,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str } static void *init_class (xine_t *xine, void *data) { - demux_real_class_t *this; - - this = calloc(1, sizeof(demux_real_class_t)); + demux_real_class_t *const this = calloc(1, sizeof(demux_real_class_t)); this->demux_class.open_plugin = open_plugin; this->demux_class.description = N_("RealMedia file demux plugin"); diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c index 81d4da274..1040d42bc 100644 --- a/src/demuxers/demux_realaudio.c +++ b/src/demuxers/demux_realaudio.c @@ -64,7 +64,9 @@ typedef struct { off_t data_start; off_t data_size; - int sps, cfs, w, h; + uint32_t cfs; + uint16_t w, h; + int frame_len; int frame_size; uint8_t *frame_buffer; @@ -77,27 +79,22 @@ typedef struct { } demux_ra_class_t; /* Map flavour to bytes per second */ -static int sipr_fl2bps[4] = {813, 1062, 625, 2000}; // 6.5, 8.5, 5, 16 kbit per second +static const int sipr_fl2bps[4] = {813, 1062, 625, 2000}; // 6.5, 8.5, 5, 16 kbit per second /* returns 1 if the RealAudio file was opened successfully, 0 otherwise */ static int open_ra_file(demux_ra_t *this) { - unsigned char file_header[RA_FILE_HEADER_PREV_SIZE], len; - unsigned short version; - off_t offset; - + uint8_t file_header[RA_FILE_HEADER_PREV_SIZE]; /* check the signature */ if (_x_demux_read_header(this->input, file_header, RA_FILE_HEADER_PREV_SIZE) != RA_FILE_HEADER_PREV_SIZE) return 0; - if ((file_header[0] != '.') || - (file_header[1] != 'r') || - (file_header[2] != 'a')) + if ( memcmp(file_header, ".ra", 3) != 0 ) return 0; /* read version */ - version = _X_BE_16(&file_header[0x04]); + const uint16_t version = _X_BE_16(&file_header[0x04]); /* read header size according to version */ if (version == 3) @@ -118,6 +115,7 @@ static int open_ra_file(demux_ra_t *this) { 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]); @@ -147,31 +145,37 @@ static int open_ra_file(demux_ra_t *this) { } /* Read title */ - len = this->header[offset]; - if(len && ((offset+len+2) < this->header_size)) { - _x_meta_info_n_set(this->stream, XINE_META_INFO_TITLE, - &this->header[offset+1], len); - offset += len+1; - } else - offset++; + { + const uint8_t len = this->header[offset]; + if(len && ((offset+len+2) < this->header_size)) { + _x_meta_info_n_set(this->stream, XINE_META_INFO_TITLE, + &this->header[offset+1], len); + offset += len+1; + } else + offset++; + } /* Author */ - len = this->header[offset]; - if(len && ((offset+len+1) < this->header_size)) { - _x_meta_info_n_set(this->stream, XINE_META_INFO_ARTIST, - &this->header[offset+1], len); - offset += len+1; - } else - offset++; + { + const uint8_t len = this->header[offset]; + if(len && ((offset+len+1) < this->header_size)) { + _x_meta_info_n_set(this->stream, XINE_META_INFO_ARTIST, + &this->header[offset+1], len); + offset += len+1; + } else + offset++; + } /* Copyright/Date */ - len = this->header[offset]; - if(len && ((offset+len) <= this->header_size)) { - _x_meta_info_n_set(this->stream, XINE_META_INFO_YEAR, - &this->header[offset+1], len); - offset += len+1; - } else - offset++; + { + const uint8_t len = this->header[offset]; + if(len && ((offset+len) <= this->header_size)) { + _x_meta_info_n_set(this->stream, XINE_META_INFO_YEAR, + &this->header[offset+1], len); + offset += len+1; + } else + offset++; + } /* Fourcc for version 3 comes after meta info */ if(version == 3) { @@ -193,17 +197,16 @@ static int open_ra_file(demux_ra_t *this) { this->audio_type = _x_formattag_to_buf_audio(this->fourcc); if (version == 4) { - this->sps = _X_BE_16 (this->header+44); + const uint16_t sps = _X_BE_16 (this->header+44) ? : 1; this->w = _X_BE_16 (this->header+42); this->h = _X_BE_16 (this->header+40); this->cfs = _X_BE_32 (this->header+24); - if (this->sps) { - this->frame_size = this->sps * this->h * this->sps; - this->frame_buffer = xine_xmalloc (this->frame_size); - } else { - this->frame_size = this->w * this->h; - this->frame_buffer = xine_xmalloc (this->frame_size); - } + + this->frame_len = this->w * this->h; + this->frame_size = this->frame_len * sps; + + this->frame_buffer = calloc(this->frame_size, 1); + _x_assert(this->frame_buffer != NULL); if (this->audio_type == BUF_AUDIO_28_8 || this->audio_type == BUF_AUDIO_SIPRO) this->block_align = this->cfs; @@ -227,7 +230,6 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) { demux_ra_t *this = (demux_ra_t *) this_gen; off_t current_normpos = 0; - int64_t current_pts; /* just load data chunks from wherever the stream happens to be * pointing; issue a DEMUX_FINISHED status if EOF is reached */ @@ -235,7 +237,7 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) { current_normpos = (int)( (double) (this->input->get_current_pos (this->input) - this->data_start) * 65535 / this->data_size ); - current_pts = 0; /* let the engine sort out the pts for now */ + const int64_t current_pts = 0; /* let the engine sort out the pts for now */ if (this->seek_flag) { _x_demux_control_newpts(this->stream, current_pts, BUF_FLAG_SEEK); @@ -243,26 +245,21 @@ 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) { - uint8_t * buffer; - - buffer = this->frame_buffer; if (this->audio_type == BUF_AUDIO_SIPRO) { - int len = this->h * this->w; - if(this->input->read(this->input, this->frame_buffer, len) < len) { + if(this->input->read(this->input, this->frame_buffer, this->frame_len) < this->frame_len) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: failed to read audio chunk\n"); this->status = DEMUX_FINISHED; return this->status; } - demux_real_sipro_swap (this->frame_buffer, len * 2 / 96); + demux_real_sipro_swap (this->frame_buffer, this->frame_len * 2 / 96); } else { int x, y; - int pos; for (y = 0; y < this->h; y++) for (x = 0; x < this->h / 2; x++) { - pos = x * 2 * this->w + y * this->cfs; + 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, @@ -275,7 +272,7 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) { } _x_demux_send_data(this->audio_fifo, - 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, @@ -310,10 +307,7 @@ static void demux_ra_send_headers(demux_plugin_t *this_gen) { buf->type = this->audio_type; buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_FRAME_END; - if(this->header_size > buf->max_size) - buf->size = buf->max_size; - else - buf->size = this->header_size; + buf->size = MIN(this->header_size, buf->max_size); memcpy(buf->content, this->header, buf->size); diff --git a/src/demuxers/demux_roq.c b/src/demuxers/demux_roq.c index 028f3bcaf..c98650eb2 100644 --- a/src/demuxers/demux_roq.c +++ b/src/demuxers/demux_roq.c @@ -47,7 +47,6 @@ #include "bswap.h" #include "group_games.h" -#define RoQ_MAGIC_NUMBER 0x1084 #define RoQ_CHUNK_PREAMBLE_SIZE 8 #define RoQ_AUDIO_SAMPLE_RATE 22050 @@ -93,8 +92,9 @@ static int open_roq_file(demux_roq_t *this) { return 0; /* check for the RoQ magic numbers */ - if ((_X_LE_16(&preamble[0]) != RoQ_MAGIC_NUMBER) || - (_X_LE_32(&preamble[2]) != 0xFFFFFFFF)) + 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); diff --git a/src/demuxers/demux_smjpeg.c b/src/demuxers/demux_smjpeg.c index 1c7d7a28e..04462919d 100644 --- a/src/demuxers/demux_smjpeg.c +++ b/src/demuxers/demux_smjpeg.c @@ -55,7 +55,6 @@ #define vidD_TAG FOURCC_TAG('v', 'i', 'd', 'D') #define APCM_TAG FOURCC_TAG('A', 'P', 'C', 'M') -#define SMJPEG_SIGNATURE_SIZE 8 /* 16 is the max size of a header chunk (the video header) */ #define SMJPEG_VIDEO_HEADER_SIZE 16 #define SMJPEG_AUDIO_HEADER_SIZE 12 @@ -98,23 +97,18 @@ static int open_smjpeg_file(demux_smjpeg_t *this) { unsigned char header_chunk[SMJPEG_HEADER_CHUNK_MAX_SIZE]; unsigned int audio_codec = 0; - if (_x_demux_read_header(this->input, signature, SMJPEG_SIGNATURE_SIZE) != - SMJPEG_SIGNATURE_SIZE) + static const uint8_t SMJPEG_SIGNATURE[8] = + { 0x00, 0x0A, 'S', 'M', 'J', 'P', 'E', 'G' }; + + if (_x_demux_read_header(this->input, signature, sizeof(SMJPEG_SIGNATURE)) != + sizeof(SMJPEG_SIGNATURE)) return 0; - /* check for the SMJPEG signature */ - if ((signature[0] != 0x00) || - (signature[1] != 0x0A) || - (signature[2] != 'S') || - (signature[3] != 'M') || - (signature[4] != 'J') || - (signature[5] != 'P') || - (signature[6] != 'E') || - (signature[7] != 'G')) + if (memcmp(signature, SMJPEG_SIGNATURE, sizeof(SMJPEG_SIGNATURE)) != 0) return 0; /* file is qualified; jump over the header + version to the duration */ - this->input->seek(this->input, SMJPEG_SIGNATURE_SIZE + 4, SEEK_SET); + this->input->seek(this->input, sizeof(SMJPEG_SIGNATURE) + 4, SEEK_SET); if (this->input->read(this->input, header_chunk, 4) != 4) return 0; this->duration = _X_BE_32(&header_chunk[0]); diff --git a/src/demuxers/demux_snd.c b/src/demuxers/demux_snd.c index 17a783bef..445300f80 100644 --- a/src/demuxers/demux_snd.c +++ b/src/demuxers/demux_snd.c @@ -42,8 +42,6 @@ #define SND_HEADER_SIZE 24 #define PCM_BLOCK_ALIGN 1024 -/* this is the big-endian hex value '.snd' */ -#define snd_TAG 0x2E736E64 typedef struct { demux_plugin_t demux_plugin; @@ -83,7 +81,7 @@ static int open_snd_file(demux_snd_t *this) { return 0; /* check the signature */ - if (_X_BE_32(&header[0]) != snd_TAG) + if ( !_x_is_fourcc(&header[0], ".snd") ) return 0; /* file is qualified; skip over the header bytes in the stream */ diff --git a/src/demuxers/demux_str.c b/src/demuxers/demux_str.c index aec526eb6..ca1acd6e7 100644 --- a/src/demuxers/demux_str.c +++ b/src/demuxers/demux_str.c @@ -139,20 +139,16 @@ #define CD_RAW_SECTOR_SIZE 2352 +static const uint8_t STR_MAGIC = + { 0x60, 0x01, 0x01, 0x80 }; #define STR_MAX_CHANNELS 32 -#define STR_MAGIC (0x80010160) - #define CDXA_TYPE_MASK 0x0E #define CDXA_TYPE_DATA 0x08 #define CDXA_TYPE_AUDIO 0x04 #define CDXA_TYPE_VIDEO 0x02 #define CDXA_SUBMODE_EOF 0x80 /* set if EOF */ -#define FOURCC_TAG BE_FOURCC -#define RIFF_TAG FOURCC_TAG('R', 'I', 'F', 'F') -#define CDXA_TAG FOURCC_TAG('C', 'D', 'X', 'A') - /* FIXME */ #define FRAME_DURATION 45000 @@ -198,8 +194,8 @@ static int open_str_file(demux_str_t *this) { } /* check for STR with a RIFF header */ - if ((_X_BE_32(&check_bytes[0]) == RIFF_TAG) && - (_X_BE_32(&check_bytes[8]) == CDXA_TAG)) + if ( _x_is_fourcc(&check_bytes[0], "RIFF") && + _x_is_fourcc(&check_bytes[8], "CDXA") ) local_offset = 0x2C; else local_offset = 0; @@ -216,16 +212,20 @@ static int open_str_file(demux_str_t *this) { check_bytes[local_offset + 0x13]); /* check for 12-byte sync marker */ - if ((_X_BE_32(&check_bytes[local_offset + 0]) != 0x00FFFFFF) || - (_X_BE_32(&check_bytes[local_offset + 4]) != 0xFFFFFFFF) || - (_X_BE_32(&check_bytes[local_offset + 8]) != 0xFFFFFF00)) { + static const uint8_t sync_marker[12] = + { 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0xFF, 0xFF, 0X00 + }; + if ( memcmp(&check_bytes[local_offset], + sync_marker, sizeof(sync_marker)) != 0 ) { lprintf("sector %d sync error\n", sector); return 0; } /* the 32 bits starting at 0x10 and at 0x14 should be the same */ - if (_X_BE_32(&check_bytes[local_offset + 0x10]) != - _X_BE_32(&check_bytes[local_offset + 0x14])) { + if (memcmp(&check_bytes[local_offset + 0x10], + &check_bytes[local_offset + 0x14], 4) != 0) { lprintf("sector %d control bits copy error\n", sector); return 0; } @@ -244,7 +244,7 @@ static int open_str_file(demux_str_t *this) { case CDXA_TYPE_VIDEO: /* first time we have seen video/data in this channel? */ if ((!(this->channel_type[channel] & CDXA_TYPE_DATA)) && - (_X_LE_32(&check_bytes[local_offset + 0x18]) == STR_MAGIC)) { + (_x_is_fourcc(&check_bytes[local_offset + 0x18], STR_MAGIC))) { /* mark this channel as having video data */ this->channel_type[channel] |= CDXA_TYPE_VIDEO; @@ -345,7 +345,7 @@ static int demux_str_send_chunk(demux_plugin_t *this_gen) { case CDXA_TYPE_DATA: /* video chunk */ - if (_X_LE_32(§or[0x18]) != STR_MAGIC || + if (!_x_is_fourcc(§or[0x18], STR_MAGIC) || channel != this->default_video_channel) { return 0; } diff --git a/src/demuxers/demux_tta.c b/src/demuxers/demux_tta.c index 07b2096e2..4d22481c8 100644 --- a/src/demuxers/demux_tta.c +++ b/src/demuxers/demux_tta.c @@ -71,7 +71,7 @@ static int open_tta_file(demux_tta_t *this) { if (_x_demux_read_header(this->input, &peek, 4) != 4) return 0; - if ( peek != ME_FOURCC('T', 'T', 'A', '1') ) + if ( !_x_is_fourcc(&peek, "TTA1") ) return 0; if ( this->input->read(this->input, this->header.buffer, sizeof(this->header)) != sizeof(this->header) ) diff --git a/src/demuxers/demux_voc.c b/src/demuxers/demux_voc.c index 6312c568c..6a958570e 100644 --- a/src/demuxers/demux_voc.c +++ b/src/demuxers/demux_voc.c @@ -85,7 +85,7 @@ static int open_voc_file(demux_voc_t *this) { return 0; /* check the signature */ - if (memcmp(header, VOC_SIGNATURE, strlen(VOC_SIGNATURE)) != 0) + if (memcmp(header, VOC_SIGNATURE, sizeof(VOC_SIGNATURE)-1) != 0) return 0; /* file is qualified */ @@ -106,7 +106,7 @@ static int open_voc_file(demux_voc_t *this) { } /* assemble 24-bit, little endian length */ - this->data_size = preamble[1] | (preamble[2] << 8) | (preamble[3] << 16); + this->data_size = _X_LE_24(&preamble[1]); /* get the next 2 bytes (re-use preamble bytes) */ if (this->input->read(this->input, preamble, 2) != 2) diff --git a/src/demuxers/demux_vqa.c b/src/demuxers/demux_vqa.c index 05331d39d..3f4ec3e66 100644 --- a/src/demuxers/demux_vqa.c +++ b/src/demuxers/demux_vqa.c @@ -96,8 +96,8 @@ static int open_vqa_file(demux_vqa_t *this) { return 0; /* check for the VQA signatures */ - if ((_X_BE_32(&scratch[0]) != FORM_TAG) || - (_X_BE_32(&scratch[8]) != WVQA_TAG)) + if (!_x_is_fourcc(&scratch[0], "FORM") || + !_x_is_fourcc(&scratch[8], "WVQA") ) return 0; /* file is qualified; skip to the start of the VQA header */ diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c index 11c9d4bf9..f9cf9b16c 100644 --- a/src/demuxers/demux_wc3movie.c +++ b/src/demuxers/demux_wc3movie.c @@ -357,9 +357,9 @@ static int open_mve_file(demux_mve_t *this) { if (_x_demux_read_header(this->input, header, WC3_HEADER_SIZE) != WC3_HEADER_SIZE) return 0; - if ((_X_BE_32(&header[0]) != FORM_TAG) || - (_X_BE_32(&header[8]) != MOVE_TAG) || - (_X_BE_32(&header[12]) != PC_TAG)) + if ( !_x_is_fourcc(&header[0], "FORM") || + !_x_is_fourcc(&header[8], "MOVE") || + !_x_is_fourcc(&header[12], "_PC_") ) return 0; /* file is qualified */ @@ -402,8 +402,8 @@ static int open_mve_file(demux_mve_t *this) { return 0; } - if ((_X_BE_32(&preamble[0]) != PALT_TAG) || - (_X_BE_32(&preamble[4]) != PALETTE_CHUNK_SIZE)) { + if ( !_x_is_fourcc(&preamble[0], "PALT") || + (_X_BE_32(&preamble[4]) != PALETTE_CHUNK_SIZE)) { xine_log(this->stream->xine, XINE_LOG_MSG, _("demux_wc3movie: There was a problem while loading palette chunks\n")); free (this->palettes); diff --git a/src/demuxers/demux_yuv4mpeg2.c b/src/demuxers/demux_yuv4mpeg2.c index 69b1a8baa..e7625f602 100644 --- a/src/demuxers/demux_yuv4mpeg2.c +++ b/src/demuxers/demux_yuv4mpeg2.c @@ -197,21 +197,13 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { this->frame_pts_inc = (90000 * this->fps_d) / this->fps_n; /* finally, look for the first frame */ - while ((header_ptr - header) < (Y4M_HEADER_BYTES - 4)) { - if((header_ptr[0] == 'F') && - (header_ptr[1] == 'R') && - (header_ptr[2] == 'A') && - (header_ptr[3] == 'M') && - (header_ptr[4] == 'E')) { - this->data_start = header_ptr - header; - break; - } else - header_ptr++; - } - + char *data_start_ptr = memmem(header_ptr, Y4M_HEADER_BYTES, "FRAME", 5); + /* make sure the first frame was found */ - if(!this->data_start) + if ( !data_start_ptr ) return 0; + + this->data_start = data_start_ptr - header; /* compute size of all frames */ if (INPUT_IS_SEEKABLE(this->input)) { @@ -228,29 +220,26 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { static int demux_yuv4mpeg2_send_chunk(demux_plugin_t *this_gen) { demux_yuv4mpeg2_t *this = (demux_yuv4mpeg2_t *) this_gen; - buf_element_t *buf = NULL; - unsigned char preamble[Y4M_FRAME_SIGNATURE_SIZE]; - int bytes_remaining; - off_t current_file_pos; - int64_t pts; - /* validate that this is an actual frame boundary */ - if (this->input->read(this->input, preamble, Y4M_FRAME_SIGNATURE_SIZE) != - Y4M_FRAME_SIGNATURE_SIZE) { - this->status = DEMUX_FINISHED; - return this->status; - } - if (memcmp(preamble, Y4M_FRAME_SIGNATURE, Y4M_FRAME_SIGNATURE_SIZE) != - 0) { - this->status = DEMUX_FINISHED; - return this->status; + { + uint8_t preamble[Y4M_FRAME_SIGNATURE_SIZE]; + if (this->input->read(this->input, preamble, Y4M_FRAME_SIGNATURE_SIZE) != + Y4M_FRAME_SIGNATURE_SIZE) { + this->status = DEMUX_FINISHED; + return this->status; + } + if (memcmp(preamble, Y4M_FRAME_SIGNATURE, Y4M_FRAME_SIGNATURE_SIZE) != + 0) { + this->status = DEMUX_FINISHED; + return this->status; + } } /* load and dispatch the raw frame */ - bytes_remaining = this->frame_size; - current_file_pos = + int bytes_remaining = this->frame_size; + off_t current_file_pos = this->input->get_current_pos(this->input) - this->data_start; - pts = current_file_pos; + int64_t pts = current_file_pos; pts /= (this->frame_size + Y4M_FRAME_SIGNATURE_SIZE); pts *= this->frame_pts_inc; @@ -261,17 +250,14 @@ static int demux_yuv4mpeg2_send_chunk(demux_plugin_t *this_gen) { } while(bytes_remaining) { - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf_element_t *buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_VIDEO_I420; if( this->data_size ) buf->extra_info->input_normpos = (int)((double) current_file_pos * 65535 / this->data_size); buf->extra_info->input_time = pts / 90; buf->pts = pts; - if (bytes_remaining > buf->max_size) - buf->size = buf->max_size; - else - buf->size = bytes_remaining; + buf->size = MIN(bytes_remaining, buf->max_size); bytes_remaining -= buf->size; if (this->input->read(this->input, buf->content, buf->size) != @@ -291,7 +277,6 @@ static int demux_yuv4mpeg2_send_chunk(demux_plugin_t *this_gen) { static void demux_yuv4mpeg2_send_headers(demux_plugin_t *this_gen) { demux_yuv4mpeg2_t *this = (demux_yuv4mpeg2_t *) this_gen; - buf_element_t *buf; this->video_fifo = this->stream->video_fifo; this->audio_fifo = this->stream->audio_fifo; @@ -310,7 +295,7 @@ static void demux_yuv4mpeg2_send_headers(demux_plugin_t *this_gen) { _x_demux_control_start(this->stream); /* send init info to decoders */ - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf_element_t *buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); 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 */ @@ -394,10 +379,7 @@ static int demux_yuv4mpeg2_get_optional_data(demux_plugin_t *this_gen, static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *stream, input_plugin_t *input) { - - demux_yuv4mpeg2_t *this; - - this = calloc(1, sizeof(demux_yuv4mpeg2_t)); + demux_yuv4mpeg2_t *this = calloc(1, sizeof(demux_yuv4mpeg2_t)); this->stream = stream; this->input = input; diff --git a/src/demuxers/demux_yuv_frames.c b/src/demuxers/demux_yuv_frames.c index d960e8d4c..454541f06 100644 --- a/src/demuxers/demux_yuv_frames.c +++ b/src/demuxers/demux_yuv_frames.c @@ -70,8 +70,6 @@ static int demux_yuv_frames_get_status (demux_plugin_t *this_gen) { } static int switch_buf(demux_yuv_frames_t *this , buf_element_t *buf){ - int result = 0; - if (!buf) return 0; @@ -88,8 +86,7 @@ static int switch_buf(demux_yuv_frames_t *this , buf_element_t *buf){ case BUF_VIDEO_I420: case BUF_VIDEO_YUY2: this->video_fifo->put(this->video_fifo, buf); - result = 1; /* 1, we still should read audio */ - break; + return 1; /* 1, we still should read audio */ case BUF_AUDIO_LPCM_LE: if (!_x_stream_info_get(this->stream, XINE_STREAM_INFO_HAS_VIDEO)) _x_demux_control_newpts(this->stream, buf->pts, 0); @@ -100,7 +97,7 @@ static int switch_buf(demux_yuv_frames_t *this , buf_element_t *buf){ buf->free_buffer(buf); } - return result; + return 0; } static int demux_yuv_frames_send_chunk (demux_plugin_t *this_gen){ diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index df3a58aea..1d4665273 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -47,6 +47,7 @@ # include <sys/ioctl.h> #else /* for WIN32 */ +# include <windef.h> # include <winioctl.h> #endif diff --git a/src/post/deinterlace/Makefile.am b/src/post/deinterlace/Makefile.am index 1a90b72bf..498a9a59f 100644 --- a/src/post/deinterlace/Makefile.am +++ b/src/post/deinterlace/Makefile.am @@ -9,7 +9,7 @@ xinepost_LTLIBRARIES = xineplug_post_tvtime.la xineplug_post_tvtime_la_SOURCES = xine_plugin.c \ deinterlace.c pulldown.c speedy.c tvtime.c -xineplug_post_tvtime_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) \ +xineplug_post_tvtime_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(PTHREAD_LIBS) \ $(top_builddir)/src/post/deinterlace/plugins/libdeinterlaceplugins.la noinst_HEADERS = deinterlace.h pulldown.h speedtools.h speedy.h tvtime.h diff --git a/src/spu_dec/cmml_decoder.c b/src/spu_dec/cmml_decoder.c index 4dea5645f..da59ed8ae 100644 --- a/src/spu_dec/cmml_decoder.c +++ b/src/spu_dec/cmml_decoder.c @@ -94,8 +94,7 @@ static void update_font_size (spucmml_decoder_t *this) { { 16, 20, 24, 32 }, /* SUBTITLE_SIZE_LARGE */ }; - const int *vec = sizes[this->subtitle_size]; - int y; + const int *const vec = sizes[this->subtitle_size]; if( this->cached_width >= 512 ) this->font_size = vec[3]; @@ -108,7 +107,7 @@ static void update_font_size (spucmml_decoder_t *this) { this->line_height = this->font_size + 10; - y = this->cached_height - (SUB_MAX_TEXT * this->line_height) - 5; + int y = this->cached_height - (SUB_MAX_TEXT * this->line_height) - 5; if(((y - this->vertical_offset) >= 0) && ((y - this->vertical_offset) <= this->cached_height)) y -= this->vertical_offset; @@ -137,83 +136,80 @@ static void update_font_size (spucmml_decoder_t *this) { } static int get_width(spucmml_decoder_t *this, char* text) { - size_t i=0; - int width=0,w,dummy; - char letter[2]={0, 0}; + int width=0; + + while (1) + switch (*text) { + case '\0': + llprintf(LOG_WIDTH, "get_width returning width of %d\n", width); + return width; - while (i<=strlen(text)) { - switch (text[i]) { case '<': - if (!strncmp("<b>", text+i, 3)) { + if (!strncmp("<b>", text, 3)) { /*Do somethink to enable BOLD typeface*/ - i=i+3; + text += 3; break; - } else if (!strncmp("</b>", text+i, 3)) { + } else if (!strncmp("</b>", text, 3)) { /*Do somethink to disable BOLD typeface*/ - i=i+4; + text += 4; break; - } else if (!strncmp("<i>", text+i, 3)) { + } else if (!strncmp("<i>", text, 3)) { /*Do somethink to enable italics typeface*/ - i=i+3; + text += 3; break; - } else if (!strncmp("</i>", text+i, 3)) { + } else if (!strncmp("</i>", text, 3)) { /*Do somethink to disable italics typeface*/ - i=i+4; + text += 4; break; - } else if (!strncmp("<font>", text+i, 3)) { + } else if (!strncmp("<font>", text, 3)) { /*Do somethink to disable typing fixme - no teststreams*/ - i=i+6; + text += 6; break; - } else if (!strncmp("</font>", text+i, 3)) { + } else if (!strncmp("</font>", text, 3)) { /*Do somethink to enable typing fixme - no teststreams*/ - i=i+7; + text += 7; break; } default: - letter[0]=text[i]; - this->stream->osd_renderer->get_text_size(this->osd, letter, &w, &dummy); - width=width+w; - i++; + { + int w, dummy; + const char letter[2] = { *text, '\0' }; + this->stream->osd_renderer->get_text_size(this->osd, letter, &w, &dummy); + width += w; + text++; + } } - } - - llprintf(LOG_WIDTH, "get_width returning width of %d\n", width); - - return width; } static void render_line(spucmml_decoder_t *this, int x, int y, char* text) { - size_t i=0; - int w,dummy; - char letter[2]={0,0}; + while (*text != '\0') { + int w, dummy; + const char letter[2] = { *text, '\0' }; - while (i<=strlen(text)) { - letter[0]=text[i]; this->stream->osd_renderer->render_text(this->osd, x, y, letter, OSD_TEXT1); this->stream->osd_renderer->get_text_size(this->osd, letter, &w, &dummy); - x=x+w; - i++; + x += w; + text++; } } static void draw_subtitle(spucmml_decoder_t *this, int64_t sub_start) { - int line, y; - int font_size; - this->stream->osd_renderer->filled_rect (this->osd, 0, 0, this->cached_width-1, this->line_height * SUB_MAX_TEXT - 1, 0); - y = (SUB_MAX_TEXT - this->lines) * this->line_height; - font_size = this->font_size; + const int y = (SUB_MAX_TEXT - this->lines) * this->line_height; + int font_size = this->font_size; this->stream->osd_renderer->set_encoding(this->osd, this->class->src_encoding); + int line; + for (line=0; line<this->lines; line++) { - int w,x; + int x; while(1) { - w=get_width( this, this->text[line]); + const int w = get_width( this, this->text[line]); x = (this->cached_width - w) / 2; if( w > this->cached_width && font_size > 16 ) { @@ -242,14 +238,13 @@ static void draw_subtitle(spucmml_decoder_t *this, int64_t sub_start) { static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { spucmml_decoder_t *this = (spucmml_decoder_t *) this_gen; - char *str; xml_node_t *packet_xml_root; char * anchor_text = NULL; lprintf("CMML packet seen\n"); - str = (char *) buf->content; + char *str = (char *) buf->content; /* parse the CMML */ @@ -440,11 +435,8 @@ static void update_osd_font(void *this_gen, xine_cfg_entry_t *entry) } static spu_decoder_t *spucmml_class_open_plugin (spu_decoder_class_t *class_gen, xine_stream_t *stream) { - spucmml_class_t *class = (spucmml_class_t *)class_gen; - spucmml_decoder_t *this ; - - this = (spucmml_decoder_t *) calloc(1, sizeof(spucmml_decoder_t)); + spucmml_decoder_t *this = (spucmml_decoder_t *) calloc(1, sizeof(spucmml_decoder_t)); this->spu_decoder.decode_data = spudec_decode_data; this->spu_decoder.reset = spudec_reset; @@ -454,7 +446,7 @@ static spu_decoder_t *spucmml_class_open_plugin (spu_decoder_class_t *class_gen, this->spu_decoder.set_button = NULL; this->spu_decoder.dispose = spudec_dispose; - this->class = class; + this->class = class_gen; this->stream = stream; this->event_queue = xine_event_new_queue (this->stream); @@ -493,10 +485,7 @@ static void update_src_encoding(void *this_gen, xine_cfg_entry_t *entry) } static void *init_spu_decoder_plugin (xine_t *xine, void *data) { - - spucmml_class_t *this ; - - this = (spucmml_class_t *) calloc(1, sizeof(spucmml_class_t)); + spucmml_class_t *this = (spucmml_class_t *) calloc(1, sizeof(spucmml_class_t)); this->class.open_plugin = spucmml_class_open_plugin; this->class.identifier = "spucmml"; diff --git a/src/spu_dec/spu_decoder.c b/src/spu_dec/spu_decoder.c index a2c0a8827..b77c5b493 100644 --- a/src/spu_dec/spu_decoder.c +++ b/src/spu_dec/spu_decoder.c @@ -69,11 +69,9 @@ static const clut_t default_clut[] = { }; static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { - uint32_t stream_id; - spudec_seq_t *cur_seq; spudec_decoder_t *this = (spudec_decoder_t *) this_gen; - stream_id = buf->type & 0x1f ; - cur_seq = &this->spudec_stream_state[stream_id].ra_seq; + const uint8_t stream_id = buf->type & 0x1f ; + spudec_seq_t *cur_seq = &this->spudec_stream_state[stream_id].ra_seq; #ifdef LOG_DEBUG printf("libspudec:got buffer type = %x\n", buf->type); @@ -178,7 +176,6 @@ static void spudec_discontinuity (spu_decoder_t *this_gen) { static void spudec_dispose (spu_decoder_t *this_gen) { spudec_decoder_t *this = (spudec_decoder_t *) this_gen; - int i; video_overlay_manager_t *ovl_manager = this->stream->video_out->get_overlay_manager (this->stream->video_out); if( this->menu_handle >= 0 ) @@ -186,6 +183,7 @@ static void spudec_dispose (spu_decoder_t *this_gen) { this->menu_handle); this->menu_handle = -1; + int i; for (i=0; i < MAX_STREAMS; i++) { if( this->spudec_stream_state[i].overlay_handle >= 0 ) ovl_manager->free_handle(ovl_manager, @@ -226,11 +224,9 @@ static void spudec_set_button (spu_decoder_t *this_gen, int32_t button, int32_t * when video_overlay does menus */ video_overlay_manager_t *ovl_manager; - video_overlay_event_t *overlay_event = NULL; - vo_overlay_t *overlay = NULL; - overlay_event = calloc(1, sizeof(video_overlay_event_t)); + video_overlay_event_t *overlay_event = calloc(1, sizeof(video_overlay_event_t)); + vo_overlay_t *overlay = calloc(1, sizeof(vo_overlay_t)); - overlay = calloc(1, sizeof(vo_overlay_t)); /* FIXME: Watch out for threads. We should really put a lock on this * because events is a different thread than decode_data */ @@ -314,7 +310,6 @@ static void spudec_set_button (spu_decoder_t *this_gen, int32_t button, int32_t static spu_decoder_t *open_plugin (spu_decoder_class_t *class_gen, xine_stream_t *stream) { spudec_decoder_t *this ; - int i; this = (spudec_decoder_t *) calloc(1, sizeof (spudec_decoder_t)); @@ -338,6 +333,8 @@ static spu_decoder_t *open_plugin (spu_decoder_class_t *class_gen, xine_stream_t this->ovl_caps = stream->video_out->get_capabilities(stream->video_out); this->output_open = 0; this->last_event_vpts = 0; + + int i; for (i=0; i < MAX_STREAMS; i++) { this->spudec_stream_state[i].ra_seq.complete = 1; this->spudec_stream_state[i].overlay_handle = -1; diff --git a/src/spu_dec/sputext_decoder.c b/src/spu_dec/sputext_decoder.c index 615910275..e86ee76e3 100644 --- a/src/spu_dec/sputext_decoder.c +++ b/src/spu_dec/sputext_decoder.c @@ -185,7 +185,7 @@ static inline char *get_font (sputext_class_t *class) } static void update_font_size (sputext_decoder_t *this, int force_update) { - static int sizes[SUBTITLE_SIZE_NUM] = { 16, 20, 24, 32, 48, 64 }; + static const int sizes[SUBTITLE_SIZE_NUM] = { 16, 20, 24, 32, 48, 64 }; if ((this->subtitle_size != this->class->subtitle_size) || (this->vertical_offset != this->class->vertical_offset) || @@ -214,11 +214,9 @@ static void update_font_size (sputext_decoder_t *this, int force_update) { } static void update_output_size (sputext_decoder_t *this) { - int unscaled; - - unscaled = this->class->use_unscaled && - (this->stream->video_out->get_capabilities(this->stream->video_out) & - VO_CAP_UNSCALED_OVERLAY); + const int unscaled = this->class->use_unscaled && + (this->stream->video_out->get_capabilities(this->stream->video_out) & + VO_CAP_UNSCALED_OVERLAY); if( unscaled != this->unscaled ) { this->unscaled = unscaled; @@ -330,13 +328,8 @@ static int parse_utf8_size(const void *buf) static int ogm_render_line_internal(sputext_decoder_t *this, int x, int y, const char *text, int render) { - int i = 0, w, value; - char* end; - char letter[5]={0, 0, 0, 0, 0}; - const char *encoding = this->buf_encoding ? this->buf_encoding - : this->class->src_encoding; - int shift, isutf8 = !strcmp(encoding, "utf-8"); - size_t length = strlen (text); + const size_t length = strlen (text); + size_t i = 0; while (i <= length) { @@ -380,6 +373,7 @@ static int ogm_render_line_internal(sputext_decoder_t *this, int x, int y, const if (text[i] == '{') { if (!strncmp("{\\", text+i, 2)) { + int value; if (sscanf(text+i, "{\\b%d}", &value) == 1) { if (render) { @@ -396,7 +390,7 @@ static int ogm_render_line_internal(sputext_decoder_t *this, int x, int y, const this->current_osd_text = OSD_TEXT1; } } - end = strstr(text+i+2, "}"); + char *const end = strstr(text+i+2, "}"); if (end) { i=end-text+1; continue; @@ -404,15 +398,20 @@ static int ogm_render_line_internal(sputext_decoder_t *this, int x, int y, const } } - shift = isutf8 ? parse_utf8_size (&text[i]) : 1; + char letter[5]; + const char *const encoding = this->buf_encoding ? : this->class->src_encoding; + const int isutf8 = !strcmp(encoding, "utf-8"); + const size_t shift = isutf8 ? parse_utf8_size (&text[i]) : 1; memcpy(letter,&text[i],shift); letter[shift]=0; if (render) this->renderer->render_text(this->osd, x, y, letter, this->current_osd_text); - this->renderer->get_text_size(this->osd, letter, &w, &value); - x=x+w; - i+=shift; + + int w, dummy; + this->renderer->get_text_size(this->osd, letter, &w, &dummy); + x += w; + i += shift; } return x; @@ -548,15 +547,9 @@ static int is_cjk_encoding(const char *enc) { static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t sub_end ) { - int line, y; - int font_size; - char *font; - const char *encoding = (this->buf_encoding)?this->buf_encoding: - this->class->src_encoding; + int y; int sub_x, sub_y, max_width; int alignment; - int rebuild_all; - _x_assert(this->renderer != NULL); if ( ! this->renderer ) @@ -566,21 +559,20 @@ static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t su update_font_size(this, 0); - font = get_font (this->class); + const char *const font = get_font (this->class); if( strcmp(this->font, font) ) { strncpy(this->font, font, FILENAME_MAX); this->font[FILENAME_MAX - 1] = '\0'; this->renderer->set_font (this->osd, font, this->font_size); } - font_size = this->font_size; - if (this->buf_encoding) - this->renderer->set_encoding(this->osd, this->buf_encoding); - else - this->renderer->set_encoding(this->osd, this->class->src_encoding); + int font_size = this->font_size; + const char *const encoding = this->buf_encoding ? : this->class->src_encoding; + this->renderer->set_encoding(this->osd, encoding); - rebuild_all = 0; + int rebuild_all = 0; + int line; for (line = 0; line < this->lines; line++) { int line_width = ogm_get_width(this, this->text[line]); @@ -638,30 +630,27 @@ static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t su /* regenerate all the lines to find something that better fits */ if (rebuild_all) { - int line, line_width; - char *stream, *current_cut, *best_cut; - char buf[SUB_BUFSIZE * SUB_MAX_TEXT]; + char buf[SUB_BUFSIZE * SUB_MAX_TEXT] = { 0, }; - buf[0] = 0; + int line; for(line = 0; line < this->lines; line++) { - size_t len = strlen(buf); - if (len) { + const size_t len = strlen(buf); + if (len) buf[len] = ' '; - len++; - } - strncpy(buf + len, this->text[line], SUB_BUFSIZE); - *(buf + len + SUB_BUFSIZE) = 0; + + strncat(buf, this->text[line], SUB_BUFSIZE-len-1); } - stream = buf; + char *stream = buf; this->lines = 0; + char *current_cut, *best_cut; do { if (this->lines + 1 < SUB_MAX_TEXT) { /* find the longest sequence witch fit */ - line_width = 0; + int line_width = 0; current_cut = stream; best_cut = NULL; while (line_width < max_width) { diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am index 9c498ff84..e32f2d2f4 100644 --- a/src/xine-engine/Makefile.am +++ b/src/xine-engine/Makefile.am @@ -2,8 +2,8 @@ include $(top_srcdir)/misc/Makefile.common include $(top_srcdir)/lib/Makefile.common AM_CFLAGS = $(DEFAULT_OCFLAGS) $(X_CFLAGS) $(FT2_CFLAGS) $(FONTCONFIG_CFLAGS) \ - $(AVUTIL_CFLAGS) $(PTHREAD_CFLAGS) $(VISIBILITY_FLAG) -AM_CPPFLAGS = $(XDG_BASEDIR_CPPFLAGS) $(ZLIB_CPPFLAGS) $(PTHREAD_CFLAGS) -DXINE_LIBRARY_COMPILE + $(AVUTIL_CFLAGS) $(VISIBILITY_FLAG) +AM_CPPFLAGS = $(XDG_BASEDIR_CPPFLAGS) $(ZLIB_CPPFLAGS) -DXINE_LIBRARY_COMPILE XINEUTILS_LIB = $(top_builddir)/src/xine-utils/libxineutils.la diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index 15b5ff952..7601e5d7f 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -781,6 +781,14 @@ static const video_db_t video_db[] = { BUF_VIDEO_VMNC, "VMware Screen Codec" }, +{ + { + ME_FOURCC('S','N','O','W'), + 0 + }, + BUF_VIDEO_SNOW, + "Snow" +}, { { 0 }, 0, "last entry" } }; @@ -1142,11 +1150,32 @@ static const audio_db_t audio_db[] = { }, { { - 0 + ME_FOURCC('W', 'V', 'P', 'K'), }, BUF_AUDIO_WAVPACK, "Wavpack" }, +{ + { + ME_FOURCC('s', 'a', 'm', 'r'), + }, + BUF_AUDIO_AMR_NB, + "AMR narrow band" +}, +{ + { + ME_FOURCC('s', 'a', 'w', 'b'), + }, + BUF_AUDIO_AMR_WB, + "AMR wide band" +}, +{ + { + ME_FOURCC('T', 'T', 'A', '1'), + }, + BUF_AUDIO_TTA, + "True Audio Lossless" +}, { { 0 }, 0, "last entry" } }; diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 2ff9f494f..7f0497e78 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -602,7 +602,7 @@ static void collect_plugins(xine_t *this, char *path){ #if defined(__hpux) if(!strstr(str, ".sl") #elif defined(__CYGWIN__) || defined(WIN32) - if(!strstr(str, ".dll") + if(!strstr(str, ".dll") || strstr(str, ".dll.a") #else if(!strstr(str, ".so") #endif diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index f0fe25e29..a789b50d4 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -239,7 +239,7 @@ static osd_object_t *XINE_MALLOC osd_new_object (osd_renderer_t *this, int width osd->width = width; osd->height = height; - osd->area = xine_xmalloc( width * height ); + osd->area = calloc(width, height); osd->x1 = width; osd->y1 = height; diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c index 3315e2aa3..4c485035b 100644 --- a/src/xine-engine/post.c +++ b/src/xine-engine/post.c @@ -30,13 +30,10 @@ void _x_post_init(post_plugin_t *post, int num_audio_inputs, int num_video_inputs) { - int audio_inputs_size = (num_audio_inputs + 1) * sizeof(xine_audio_port_t *); - int video_inputs_size = (num_video_inputs + 1) * sizeof(xine_video_port_t *); - post->input = xine_list_new(); post->output = xine_list_new(); - post->xine_post.audio_input = (xine_audio_port_t **)xine_xmalloc(audio_inputs_size); - post->xine_post.video_input = (xine_video_port_t **)xine_xmalloc(video_inputs_size); + post->xine_post.audio_input = calloc(num_audio_inputs + 1, sizeof(xine_audio_port_t *)); + post->xine_post.video_input = calloc(num_video_inputs + 1, sizeof(xine_video_port_t *)); } diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 07da930fb..217272a97 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.c @@ -730,6 +730,8 @@ uint32_t xine_get_stream_info (xine_stream_t *stream, int info) { case XINE_STREAM_INFO_IGNORE_AUDIO: case XINE_STREAM_INFO_IGNORE_SPU: case XINE_STREAM_INFO_VIDEO_HAS_STILL: + case XINE_STREAM_INFO_SKIPPED_FRAMES: + case XINE_STREAM_INFO_DISCARDED_FRAMES: case XINE_STREAM_INFO_VIDEO_AFD: case XINE_STREAM_INFO_DVD_TITLE_NUMBER: case XINE_STREAM_INFO_DVD_TITLE_COUNT: diff --git a/src/xine-utils/Makefile.am b/src/xine-utils/Makefile.am index 2088d0cae..9dd7f64d6 100644 --- a/src/xine-utils/Makefile.am +++ b/src/xine-utils/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/misc/Makefile.common AM_CFLAGS = $(DEFAULT_OCFLAGS) $(X_CFLAGS) $(VISIBILITY_FLAG) -AM_CPPFLAGS = $(PTHREAD_CFLAGS) -DXINE_LIBRARY_COMPILE +AM_CPPFLAGS = -DXINE_LIBRARY_COMPILE EXTRA_DIST = ppcasm_string.S ppc_asm.tmpl diff --git a/src/xine-utils/color.c b/src/xine-utils/color.c index dc2c7e5e5..fac998ad3 100644 --- a/src/xine-utils/color.c +++ b/src/xine-utils/color.c @@ -159,18 +159,14 @@ void (*yuy2_to_yv12) * and height passed to it. The width must be divisible by 2. */ void init_yuv_planes(yuv_planes_t *yuv_planes, int width, int height) { - - int plane_size; - memset (yuv_planes, 0, sizeof (yuv_planes)); yuv_planes->row_width = width; yuv_planes->row_count = height; - plane_size = yuv_planes->row_width * yuv_planes->row_count; - yuv_planes->y = xine_xmalloc(plane_size); - yuv_planes->u = xine_xmalloc(plane_size); - yuv_planes->v = xine_xmalloc(plane_size); + yuv_planes->y = calloc(width, height); + yuv_planes->u = calloc(width, height); + yuv_planes->v = calloc(width, height); } /* diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index 8b01bd52b..8a9774b3d 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -415,11 +415,8 @@ const char *xine_get_pluginroot(void) { static char pluginroot[1024] = {0, }; if (!pluginroot[0]) { - char *sep, *sep2; - strcpy (pluginroot, xine_get_plugindir ()); - sep = strrchr (pluginroot, '/'); - sep2 = strrchr (pluginroot, '\\'); - *(sep < sep2 ? sep : sep2) = 0; + xine_get_rootdir(pluginroot, sizeof(pluginroot) - strlen(XINE_REL_PLUGINROOT) - 1); + strcat(pluginroot, XINE_DIRECTORY_SEPARATOR_STRING XINE_REL_PLUGINROOT); } return pluginroot; |