diff options
Diffstat (limited to 'libmpdemux')
35 files changed, 32 insertions, 16353 deletions
diff --git a/libmpdemux/aac_hdr.c b/libmpdemux/aac_hdr.c deleted file mode 100644 index 36991e27a2..0000000000 --- a/libmpdemux/aac_hdr.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2005 Nico Sabbi - * - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <stdint.h> -#include "aac_hdr.h" -#include "libavutil/attributes.h" - -/// \param srate (out) sample rate -/// \param num (out) number of audio frames in this ADTS frame -/// \return size of the ADTS frame in bytes -/// aac_parse_frames needs a buffer at least 8 bytes long -int aac_parse_frame(uint8_t *buf, int *srate, int *num) -{ - int i = 0, sr, fl = 0, id av_unused; - static int srates[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 0, 0, 0}; - - if((buf[i] != 0xFF) || ((buf[i+1] & 0xF6) != 0xF0)) - return 0; - - id = (buf[i+1] >> 3) & 0x01; //id=1 mpeg2, 0: mpeg4 - sr = (buf[i+2] >> 2) & 0x0F; - if(sr > 11) - return 0; - *srate = srates[sr]; - - fl = ((buf[i+3] & 0x03) << 11) | (buf[i+4] << 3) | ((buf[i+5] >> 5) & 0x07); - *num = (buf[i+6] & 0x02) + 1; - - return fl; -} diff --git a/libmpdemux/aac_hdr.h b/libmpdemux/aac_hdr.h deleted file mode 100644 index be56368925..0000000000 --- a/libmpdemux/aac_hdr.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPLAYER_AAC_HDR_H -#define MPLAYER_AAC_HDR_H - -#include <stdint.h> - -int aac_parse_frame(uint8_t *buf, int *srate, int *num); - -#endif /* MPLAYER_AAC_HDR_H */ diff --git a/libmpdemux/demux_aac.c b/libmpdemux/demux_aac.c deleted file mode 100644 index 9d37d75cf8..0000000000 --- a/libmpdemux/demux_aac.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "config.h" -#include "mp_msg.h" - -#include "stream/stream.h" -#include "demuxer.h" -#include "parse_es.h" -#include "stheader.h" -#include "aac_hdr.h" -#include "ms_hdr.h" - -typedef struct { - uint8_t *buf; - uint64_t size; /// amount of time of data packets pushed to demuxer->audio (in bytes) - float time; /// amount of time elapsed based upon samples_per_frame/sample_rate (in milliseconds) - float last_pts; /// last pts seen - int bitrate; /// bitrate computed as size/time -} aac_priv_t; - -static int demux_aac_init(demuxer_t *demuxer) -{ - aac_priv_t *priv; - - priv = calloc(1, sizeof(aac_priv_t)); - if(!priv) - return 0; - - priv->buf = malloc(8); - if(!priv->buf) - { - free(priv); - return 0; - } - - demuxer->priv = priv; - return 1; -} - -static void demux_close_aac(demuxer_t *demuxer) -{ - aac_priv_t *priv = (aac_priv_t *) demuxer->priv; - - if(!priv) - return; - - free(priv->buf); - - free(demuxer->priv); - - return; -} - -/// returns DEMUXER_TYPE_AAC if it finds 8 ADTS frames in 32768 bytes, 0 otherwise -static int demux_aac_probe(demuxer_t *demuxer) -{ - int cnt = 0, c, len, srate, num; - off_t init, probed; - aac_priv_t *priv; - - if(! demux_aac_init(demuxer)) - { - mp_msg(MSGT_DEMUX, MSGL_ERR, "COULDN'T INIT aac_demux, exit\n"); - return 0; - } - - priv = (aac_priv_t *) demuxer->priv; - - init = probed = stream_tell(demuxer->stream); - while(probed-init <= 32768 && cnt < 8) - { - c = 0; - while(c != 0xFF) - { - c = stream_read_char(demuxer->stream); - if(c < 0) - goto fail; - } - priv->buf[0] = 0xFF; - if(stream_read(demuxer->stream, &(priv->buf[1]), 7) < 7) - goto fail; - - len = aac_parse_frame(priv->buf, &srate, &num); - if(len > 0) - { - cnt++; - stream_skip(demuxer->stream, len - 8); - } - probed = stream_tell(demuxer->stream); - } - - stream_seek(demuxer->stream, init); - if(cnt < 8) - goto fail; - - mp_msg(MSGT_DEMUX, MSGL_V, "demux_aac_probe, INIT: %"PRIu64", PROBED: %"PRIu64", cnt: %d\n", init, probed, cnt); - return DEMUXER_TYPE_AAC; - -fail: - mp_msg(MSGT_DEMUX, MSGL_V, "demux_aac_probe, failed to detect an AAC stream\n"); - return 0; -} - -static demuxer_t* demux_aac_open(demuxer_t *demuxer) -{ - sh_audio_t *sh; - - sh = new_sh_audio(demuxer, 0); - sh->ds = demuxer->audio; - sh->format = mmioFOURCC('M', 'P', '4', 'A'); - demuxer->audio->id = 0; - demuxer->audio->sh = sh; - - demuxer->filepos = stream_tell(demuxer->stream); - - return demuxer; -} - -static int demux_aac_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) -{ - aac_priv_t *priv = (aac_priv_t *) demuxer->priv; - demux_packet_t *dp; - int c1, c2, len, srate, num; - float tm = 0; - - if(demuxer->stream->eof || (demuxer->movi_end && stream_tell(demuxer->stream) >= demuxer->movi_end)) - return 0; - - while(! demuxer->stream->eof) - { - c1 = c2 = 0; - while(c1 != 0xFF) - { - c1 = stream_read_char(demuxer->stream); - if(c1 < 0) - return 0; - } - c2 = stream_read_char(demuxer->stream); - if(c2 < 0) - return 0; - if((c2 & 0xF6) != 0xF0) - continue; - - priv->buf[0] = (unsigned char) c1; - priv->buf[1] = (unsigned char) c2; - if(stream_read(demuxer->stream, &(priv->buf[2]), 6) < 6) - return 0; - - len = aac_parse_frame(priv->buf, &srate, &num); - if(len > 0) - { - dp = new_demux_packet(len); - if(! dp) - { - mp_msg(MSGT_DEMUX, MSGL_ERR, "fill_buffer, NEW_ADD_PACKET(%d)FAILED\n", len); - return 0; - } - - - memcpy(dp->buffer, priv->buf, 8); - stream_read(demuxer->stream, &(dp->buffer[8]), len-8); - if(srate) - tm = (float) (num * 1024.0/srate); - priv->last_pts += tm; - dp->pts = priv->last_pts; - //fprintf(stderr, "\nPTS: %.3f\n", dp->pts); - ds_add_packet(demuxer->audio, dp); - priv->size += len; - priv->time += tm; - - priv->bitrate = (int) (priv->size / priv->time); - demuxer->filepos = stream_tell(demuxer->stream); - - return len; - } - else - stream_skip(demuxer->stream, -6); - } - - return 0; -} - - -//This is an almost verbatim copy of high_res_mp3_seek(), from demux_audio.c -static void demux_aac_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) -{ - aac_priv_t *priv = (aac_priv_t *) demuxer->priv; - demux_stream_t *d_audio=demuxer->audio; - sh_audio_t *sh_audio=d_audio->sh; - float time; - - ds_free_packs(d_audio); - - time = (flags & SEEK_ABSOLUTE) ? rel_seek_secs - priv->last_pts : rel_seek_secs; - if(time < 0) - { - stream_seek(demuxer->stream, demuxer->movi_start); - time = priv->last_pts + time; - priv->last_pts = 0; - } - - if(time > 0) - { - int len, nf, srate, num; - - nf = time * sh_audio->samplerate/1024; - - while(nf > 0) - { - if(stream_read(demuxer->stream,priv->buf, 8) < 8) - break; - len = aac_parse_frame(priv->buf, &srate, &num); - if(len <= 0) - { - stream_skip(demuxer->stream, -7); - continue; - } - stream_skip(demuxer->stream, len - 8); - priv->last_pts += (float) (num*1024.0/srate); - nf -= num; - } - } -} - - -const demuxer_desc_t demuxer_desc_aac = { - "AAC demuxer", - "aac", - "AAC", - "Nico Sabbi", - "Raw AAC files ", - DEMUXER_TYPE_AAC, - 0, // unsafe autodetect - demux_aac_probe, - demux_aac_fill_buffer, - demux_aac_open, - demux_close_aac, - demux_aac_seek, - NULL -}; diff --git a/libmpdemux/demux_avi.c b/libmpdemux/demux_avi.c index f73648166c..3841cf2736 100644 --- a/libmpdemux/demux_avi.c +++ b/libmpdemux/demux_avi.c @@ -29,7 +29,6 @@ #include "stream/stream.h" #include "demuxer.h" #include "stheader.h" -#include "demux_ogg.h" #include "aviheader.h" extern const demuxer_desc_t demuxer_desc_avi_ni; @@ -862,38 +861,6 @@ static int avi_check_file(demuxer_t *demuxer) } -static demuxer_t* demux_open_hack_avi(demuxer_t *demuxer) -{ - struct MPOpts *opts = demuxer->opts; - sh_audio_t* sh_a; - - demuxer = demux_open_avi(demuxer); - if(!demuxer) return NULL; // failed to open - sh_a = demuxer->audio->sh; - if(demuxer->audio->id != -2 && sh_a) { -#ifdef CONFIG_OGGVORBIS - // support for Ogg-in-AVI: - if(sh_a->format == 0xFFFE) - demuxer = init_avi_with_ogg(demuxer); - else if(sh_a->format == 0x674F) { - stream_t* s; - demuxer_t *od; - s = new_ds_stream(demuxer->audio); - od = new_demuxer(opts, s,DEMUXER_TYPE_OGG,-1,-2,-2,NULL); - if(!demux_ogg_open(od)) { - mp_tmsg( MSGT_DEMUXER,MSGL_ERR,"Unable to open the Ogg demuxer.\n"); - free_stream(s); - demuxer->audio->id = -2; - } else - demuxer = new_demuxers_demuxer(demuxer,od,demuxer); - } -#endif - } - - return demuxer; -} - - const demuxer_desc_t demuxer_desc_avi = { "AVI demuxer", "avi", @@ -904,7 +871,7 @@ const demuxer_desc_t demuxer_desc_avi = { 1, // safe autodetect avi_check_file, demux_avi_fill_buffer, - demux_open_hack_avi, + demux_open_avi, demux_close_avi, demux_seek_avi, demux_avi_control @@ -920,7 +887,7 @@ const demuxer_desc_t demuxer_desc_avi_ni = { 1, // safe autodetect avi_check_file, demux_avi_fill_buffer_ni, - demux_open_hack_avi, + demux_open_avi, demux_close_avi, demux_seek_avi, demux_avi_control @@ -936,7 +903,7 @@ const demuxer_desc_t demuxer_desc_avi_nini = { 1, // safe autodetect avi_check_file, demux_avi_fill_buffer_nini, - demux_open_hack_avi, + demux_open_avi, demux_close_avi, demux_seek_avi, demux_avi_control diff --git a/libmpdemux/demux_film.c b/libmpdemux/demux_film.c deleted file mode 100644 index 713c9ea26e..0000000000 --- a/libmpdemux/demux_film.c +++ /dev/null @@ -1,490 +0,0 @@ -/* - * FILM file parser - * Copyright (C) 2002 Mike Melanson - * - * This demuxer handles FILM (a.k.a. CPK) files commonly found on Sega - * Saturn CD-ROM games. FILM files have also been found on 3DO games. - * - * details of the FILM file format can be found at: - * http://www.pcisys.net/~melanson/codecs/ - * - * This file is part of MPlayer. - * - * MPlayer 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. - * - * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include "config.h" -#include "mp_msg.h" - -#include "stream/stream.h" -#include "demuxer.h" -#include "stheader.h" - -// chunk types found in a FILM file -#define CHUNK_FILM mmioFOURCC('F', 'I', 'L', 'M') -#define CHUNK_FDSC mmioFOURCC('F', 'D', 'S', 'C') -#define CHUNK_STAB mmioFOURCC('S', 'T', 'A', 'B') - -typedef struct film_chunk_t -{ - off_t chunk_offset; - int chunk_size; - unsigned int syncinfo1; - unsigned int syncinfo2; - - float pts; -} film_chunk_t; - -typedef struct film_data_t -{ - unsigned int total_chunks; - unsigned int current_chunk; - film_chunk_t *chunks; - unsigned int chunks_per_second; - unsigned int film_version; -} film_data_t; - -static void demux_seek_film(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) -{ - film_data_t *film_data = (film_data_t *)demuxer->priv; - int new_current_chunk=(flags&SEEK_ABSOLUTE)?0:film_data->current_chunk; - - if(flags&SEEK_FACTOR) - new_current_chunk += rel_seek_secs * film_data->total_chunks; // 0..1 - else - new_current_chunk += rel_seek_secs * film_data->chunks_per_second; // secs - - -mp_msg(MSGT_DECVIDEO, MSGL_INFO,"current, total chunks = %d, %d; seek %5.3f sec, new chunk guess = %d\n", - film_data->current_chunk, film_data->total_chunks, - rel_seek_secs, new_current_chunk); - - // check if the new chunk number is valid - if (new_current_chunk < 0) - new_current_chunk = 0; - if ((unsigned int)new_current_chunk > film_data->total_chunks) - new_current_chunk = film_data->total_chunks - 1; - - while (((film_data->chunks[new_current_chunk].syncinfo1 == 0xFFFFFFFF) || - (film_data->chunks[new_current_chunk].syncinfo1 & 0x80000000)) && - (new_current_chunk > 0)) - new_current_chunk--; - - film_data->current_chunk = new_current_chunk; - -mp_msg(MSGT_DECVIDEO, MSGL_INFO," (flags = %X) actual new chunk = %d (syncinfo1 = %08X)\n", - flags, film_data->current_chunk, film_data->chunks[film_data->current_chunk].syncinfo1); - demuxer->video->pts=film_data->chunks[film_data->current_chunk].pts; - -} - -// return value: -// 0 = EOF or no stream found -// 1 = successfully read a packet -static int demux_film_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) -{ - int i; - unsigned char byte_swap; - int cvid_size; - sh_video_t *sh_video = demuxer->video->sh; - sh_audio_t *sh_audio = demuxer->audio->sh; - film_data_t *film_data = (film_data_t *)demuxer->priv; - film_chunk_t film_chunk; - int length_fix_bytes; - demux_packet_t* dp; - - // see if the end has been reached - if (film_data->current_chunk >= film_data->total_chunks) - return 0; - - film_chunk = film_data->chunks[film_data->current_chunk]; - - // position stream and fetch chunk - stream_seek(demuxer->stream, film_chunk.chunk_offset); - - // load the chunks manually (instead of using ds_read_packet()), since - // they require some adjustment - // (all ones in syncinfo1 indicates an audio chunk) - if (film_chunk.syncinfo1 == 0xFFFFFFFF) - { - if(demuxer->audio->id>=-1){ // audio not disabled - dp = new_demux_packet(film_chunk.chunk_size); - if (stream_read(demuxer->stream, dp->buffer, film_chunk.chunk_size) != - film_chunk.chunk_size) - return 0; - dp->pts = film_chunk.pts; - dp->pos = film_chunk.chunk_offset; - - // adjust the data before queuing it: - // 8-bit: signed -> unsigned - // 16-bit: big-endian -> little-endian - if (sh_audio->wf->wBitsPerSample == 8) - for (i = 0; i < film_chunk.chunk_size; i++) - dp->buffer[i] += 128; - else - for (i = 0; i < film_chunk.chunk_size; i += 2) - { - byte_swap = dp->buffer[i]; - dp->buffer[i] = dp->buffer[i + 1]; - dp->buffer[i + 1] = byte_swap; - } - - /* for SegaSaturn .cpk file, translate audio data if stereo */ - if (sh_audio->wf->nChannels == 2) { - if (sh_audio->wf->wBitsPerSample == 8) { - unsigned char* tmp = dp->buffer; - unsigned char buf[film_chunk.chunk_size]; - for(i = 0; i < film_chunk.chunk_size/2; i++) { - buf[i*2] = tmp[i]; - buf[i*2+1] = tmp[film_chunk.chunk_size/2+i]; - } - memcpy( tmp, buf, film_chunk.chunk_size ); - } - else {/* for 16bit */ - unsigned short *tmp = (unsigned short *)dp->buffer; - unsigned short buf[film_chunk.chunk_size/2]; - for(i = 0; i < film_chunk.chunk_size/4; i++) { - buf[i*2] = tmp[i]; - buf[i*2+1] = tmp[film_chunk.chunk_size/4+i]; - } - memcpy( tmp, buf, film_chunk.chunk_size ); - } - } - - // append packet to DS stream - ds_add_packet(demuxer->audio, dp); - } - } - else - { - // if the demuxer is dealing with CVID data, deal with it a special way - if (sh_video->format == mmioFOURCC('c', 'v', 'i', 'd')) - { - if (film_data->film_version) - length_fix_bytes = 2; - else - length_fix_bytes = 6; - - // account for the fix bytes when allocating the buffer - dp = new_demux_packet(film_chunk.chunk_size - length_fix_bytes); - - // these CVID data chunks have a few extra bytes; skip them - if (stream_read(demuxer->stream, dp->buffer, 10) != 10) - return 0; - stream_skip(demuxer->stream, length_fix_bytes); - - if (stream_read(demuxer->stream, dp->buffer + 10, - film_chunk.chunk_size - (10 + length_fix_bytes)) != - (film_chunk.chunk_size - (10 + length_fix_bytes))) - return 0; - - dp->pts = film_chunk.pts; - dp->pos = film_chunk.chunk_offset; - dp->keyframe = film_chunk.syncinfo1 & 0x80000000; - - // fix the CVID chunk size - cvid_size = film_chunk.chunk_size - length_fix_bytes; - dp->buffer[1] = (cvid_size >> 16) & 0xFF; - dp->buffer[2] = (cvid_size >> 8) & 0xFF; - dp->buffer[3] = (cvid_size >> 0) & 0xFF; - - // append packet to DS stream - ds_add_packet(demuxer->video, dp); - } - else - { - ds_read_packet(demuxer->video, demuxer->stream, film_chunk.chunk_size, - film_chunk.pts, - film_chunk.chunk_offset, (film_chunk.syncinfo1 & 0x80000000) ? 1 : 0); - } - } - film_data->current_chunk++; - - return 1; -} - -static demuxer_t* demux_open_film(demuxer_t* demuxer) -{ - sh_video_t *sh_video = NULL; - sh_audio_t *sh_audio = NULL; - film_data_t *film_data; - film_chunk_t film_chunk; - int header_size; - unsigned int chunk_type; - unsigned int chunk_size; - unsigned int i; - unsigned int video_format; - int audio_channels; - int counting_chunks; - unsigned int total_audio_bytes = 0; - - film_data = malloc(sizeof(film_data_t)); - film_data->total_chunks = 0; - film_data->current_chunk = 0; - film_data->chunks = NULL; - film_data->chunks_per_second = 0; - - // go back to the beginning - stream_reset(demuxer->stream); - stream_seek(demuxer->stream, 0); - - // read the master chunk type - chunk_type = stream_read_fourcc(demuxer->stream); - // validate the chunk type - if (chunk_type != CHUNK_FILM) - { - mp_msg(MSGT_DEMUX, MSGL_ERR, "Not a FILM file\n"); - free(film_data); - return NULL; - } - - // get the header size, which implicitly points past the header and - // to the start of the data - header_size = stream_read_dword(demuxer->stream); - film_data->film_version = stream_read_fourcc(demuxer->stream); - demuxer->movi_start = header_size; - demuxer->movi_end = demuxer->stream->end_pos; - header_size -= 16; - - mp_msg(MSGT_DEMUX, MSGL_HINT, "FILM version %.4s\n", - (char *)&film_data->film_version); - - // skip to where the next chunk should be - stream_skip(demuxer->stream, 4); - - // traverse through the header - while (header_size > 0) - { - // fetch the chunk type and size - chunk_type = stream_read_fourcc(demuxer->stream); - chunk_size = stream_read_dword(demuxer->stream); - header_size -= chunk_size; - - switch (chunk_type) - { - case CHUNK_FDSC: - mp_msg(MSGT_DECVIDEO, MSGL_V, "parsing FDSC chunk\n"); - - // fetch the video codec fourcc to see if there's any video - video_format = stream_read_fourcc(demuxer->stream); - if (video_format) - { - // create and initialize the video stream header - sh_video = new_sh_video(demuxer, 0); - demuxer->video->sh = sh_video; - sh_video->ds = demuxer->video; - - sh_video->format = video_format; - sh_video->disp_h = stream_read_dword(demuxer->stream); - sh_video->disp_w = stream_read_dword(demuxer->stream); - mp_msg(MSGT_DECVIDEO, MSGL_V, - " FILM video: %d x %d\n", sh_video->disp_w, - sh_video->disp_h); - } - else - // skip height and width if no video - stream_skip(demuxer->stream, 8); - - if(demuxer->audio->id<-1){ - mp_msg(MSGT_DECVIDEO, MSGL_INFO,"chunk size = 0x%X \n",chunk_size); - stream_skip(demuxer->stream, chunk_size-12-8); - break; // audio disabled (or no soundcard) - } - - // skip over unknown byte, but only if file had non-NULL version - if (film_data->film_version) - stream_skip(demuxer->stream, 1); - - // fetch the audio channels to see if there's any audio - // don't do this if the file is a quirky file with NULL version - if (film_data->film_version) - { - audio_channels = stream_read_char(demuxer->stream); - if (audio_channels > 0) - { - // create and initialize the audio stream header - sh_audio = new_sh_audio(demuxer, 0); - demuxer->audio->id = 0; - demuxer->audio->sh = sh_audio; - sh_audio->ds = demuxer->audio; - - sh_audio->wf = malloc(sizeof(*sh_audio->wf)); - - // uncompressed PCM format - sh_audio->wf->wFormatTag = 1; - sh_audio->format = 1; - sh_audio->wf->nChannels = audio_channels; - sh_audio->wf->wBitsPerSample = stream_read_char(demuxer->stream); - stream_skip(demuxer->stream, 1); // skip unknown byte - sh_audio->wf->nSamplesPerSec = stream_read_word(demuxer->stream); - sh_audio->wf->nAvgBytesPerSec = - sh_audio->wf->nSamplesPerSec * sh_audio->wf->wBitsPerSample - * sh_audio->wf->nChannels / 8; - stream_skip(demuxer->stream, 6); // skip the rest of the unknown - - mp_msg(MSGT_DECVIDEO, MSGL_V, - " FILM audio: %d channels, %d bits, %d Hz\n", - sh_audio->wf->nChannels, 8 * sh_audio->wf->wBitsPerSample, - sh_audio->wf->nSamplesPerSec); - } - else - stream_skip(demuxer->stream, 10); - } - else - { - // otherwise, make some assumptions about the audio - - // create and initialize the audio stream header - sh_audio = new_sh_audio(demuxer, 0); - demuxer->audio->sh = sh_audio; - sh_audio->ds = demuxer->audio; - - sh_audio->wf = malloc(sizeof(*sh_audio->wf)); - - // uncompressed PCM format - sh_audio->wf->wFormatTag = 1; - sh_audio->format = 1; - sh_audio->wf->nChannels = 1; - sh_audio->wf->wBitsPerSample = 8; - sh_audio->wf->nSamplesPerSec = 22050; - sh_audio->wf->nAvgBytesPerSec = - sh_audio->wf->nSamplesPerSec * sh_audio->wf->wBitsPerSample - * sh_audio->wf->nChannels / 8; - - mp_msg(MSGT_DECVIDEO, MSGL_V, - " FILM audio: %d channels, %d bits, %d Hz\n", - sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample, - sh_audio->wf->nSamplesPerSec); - } - break; - - case CHUNK_STAB: - mp_msg(MSGT_DECVIDEO, MSGL_V, "parsing STAB chunk\n"); - - if (sh_video) - { - sh_video->fps = stream_read_dword(demuxer->stream); - sh_video->frametime = 1.0 / sh_video->fps; - } - - // fetch the number of chunks - film_data->total_chunks = stream_read_dword(demuxer->stream); - film_data->current_chunk = 0; - mp_msg(MSGT_DECVIDEO, MSGL_V, - " STAB chunk contains %d chunks\n", film_data->total_chunks); - - // allocate enough entries for the chunk - film_data->chunks = - calloc(film_data->total_chunks, sizeof(film_chunk_t)); - - // build the chunk index - co |