diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2008-12-14 17:28:16 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2008-12-14 17:28:16 +0200 |
commit | a3ab9e8e4649601281f78949e56b92755ae1142a (patch) | |
tree | e31ee1ff4bafbfcf75c16259d9a64d18fea3bd51 /libmpdemux | |
parent | f01f7f6259badb2725be49af914d8db52e025cf6 (diff) | |
parent | bac1f05b4da4339b487e4e6ab972819142b3f13e (diff) | |
download | mpv-a3ab9e8e4649601281f78949e56b92755ae1142a.tar.bz2 mpv-a3ab9e8e4649601281f78949e56b92755ae1142a.tar.xz |
Merge svn changes up to r28149
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_nut.c | 35 | ||||
-rw-r--r-- | libmpdemux/demux_vqf.c | 40 | ||||
-rw-r--r-- | libmpdemux/parse_mp4.c | 26 | ||||
-rw-r--r-- | libmpdemux/parse_mp4.h | 25 |
4 files changed, 81 insertions, 45 deletions
diff --git a/libmpdemux/demux_nut.c b/libmpdemux/demux_nut.c index 53d80b0f68..8fd46e6921 100644 --- a/libmpdemux/demux_nut.c +++ b/libmpdemux/demux_nut.c @@ -14,9 +14,9 @@ typedef struct { int last_pts; // FIXME - nut_context_t * nut; - nut_stream_header_t * s; -} nut_priv_t; + nut_context_tt * nut; + nut_stream_header_tt * s; +} nut_priv_tt; static size_t mp_read(void * h, size_t len, uint8_t * buf) { stream_t * stream = (stream_t*)h; @@ -64,8 +64,7 @@ static int nut_check_file(demuxer_t * demuxer) { } static demuxer_t * demux_open_nut(demuxer_t * demuxer) { - extern int index_mode; - nut_demuxer_opts_t dopts = { + nut_demuxer_opts_tt dopts = { .input = { .priv = demuxer->stream, .seek = mp_seek, @@ -77,9 +76,9 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) { .read_index = index_mode, .cache_syncpoints = 1, }; - nut_priv_t * priv = demuxer->priv = calloc(1, sizeof(nut_priv_t)); - nut_context_t * nut = priv->nut = nut_demuxer_init(&dopts); - nut_stream_header_t * s; + nut_priv_tt * priv = demuxer->priv = calloc(1, sizeof(nut_priv_tt)); + nut_context_tt * nut = priv->nut = nut_demuxer_init(&dopts); + nut_stream_header_tt * s; int ret; int i; @@ -97,8 +96,8 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) { calloc(sizeof(WAVEFORMATEX) + s[i].codec_specific_len, 1); sh_audio_t* sh_audio = new_sh_audio(demuxer, i); - mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "nut", i); int j; + mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_AudioID, "nut", i); sh_audio->wf= wf; sh_audio->ds = demuxer->audio; sh_audio->audio.dwSampleSize = 0; // FIXME @@ -133,8 +132,8 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) { calloc(sizeof(BITMAPINFOHEADER) + s[i].codec_specific_len, 1); sh_video_t * sh_video = new_sh_video(demuxer, i); - mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "nut", i); int j; + mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_VideoID, "nut", i); sh_video->bih = bih; sh_video->ds = demuxer->video; @@ -176,11 +175,11 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) { } static int demux_nut_fill_buffer(demuxer_t * demuxer, demux_stream_t * dsds) { - nut_priv_t * priv = demuxer->priv; - nut_context_t * nut = priv->nut; + nut_priv_tt * priv = demuxer->priv; + nut_context_tt * nut = priv->nut; demux_packet_t *dp; demux_stream_t *ds; - nut_packet_t pd; + nut_packet_tt pd; int ret; double pts; @@ -238,9 +237,8 @@ static int demux_nut_fill_buffer(demuxer_t * demuxer, demux_stream_t * dsds) { } static void demux_seek_nut(demuxer_t * demuxer, float time_pos, float audio_delay, int flags) { - nut_context_t * nut = ((nut_priv_t*)demuxer->priv)->nut; - nut_priv_t * priv = demuxer->priv; - sh_audio_t * sh_audio = demuxer->audio->sh; + nut_context_tt * nut = ((nut_priv_tt*)demuxer->priv)->nut; + nut_priv_tt * priv = demuxer->priv; int nutflags = 0; int ret; const int tmp[] = { 0, -1 }; @@ -258,12 +256,11 @@ static void demux_seek_nut(demuxer_t * demuxer, float time_pos, float audio_dela while ((ret = nut_seek(nut, time_pos, nutflags, tmp)) == NUT_ERR_EAGAIN); priv->last_pts = -1; if (ret) mp_msg(MSGT_HEADER, MSGL_ERR, "NUT error: %s\n", nut_error(ret)); - if (sh_audio) resync_audio_stream(sh_audio); demuxer->filepos = stream_tell(demuxer->stream); } static int demux_control_nut(demuxer_t * demuxer, int cmd, void * arg) { - nut_priv_t * priv = demuxer->priv; + nut_priv_tt * priv = demuxer->priv; switch (cmd) { case DEMUXER_CTRL_GET_TIME_LENGTH: *((double *)arg) = priv->s[0].max_pts * @@ -282,7 +279,7 @@ static int demux_control_nut(demuxer_t * demuxer, int cmd, void * arg) { } static void demux_close_nut(demuxer_t *demuxer) { - nut_priv_t * priv = demuxer->priv; + nut_priv_tt * priv = demuxer->priv; if (!priv) return; nut_demuxer_uninit(priv->nut); free(demuxer->priv); diff --git a/libmpdemux/demux_vqf.c b/libmpdemux/demux_vqf.c index 013929a3bc..3aefa02dd9 100644 --- a/libmpdemux/demux_vqf.c +++ b/libmpdemux/demux_vqf.c @@ -3,6 +3,7 @@ #include <stdlib.h> #include <stdio.h> #include "libavutil/common.h" +#include "libavutil/intreadwrite.h" #include "mpbswap.h" #include "stream/stream.h" @@ -50,19 +51,22 @@ static demuxer_t* demux_open_vqf(demuxer_t* demuxer) { unsigned chunk_size; hi->size=chunk_size=stream_read_dword(s); /* include itself */ stream_read(s,chunk_id,4); - if(*((uint32_t *)&chunk_id[0])==mmioFOURCC('C','O','M','M')) + if (chunk_size < 8) return NULL; + chunk_size -= 8; + if(AV_RL32(chunk_id)==mmioFOURCC('C','O','M','M')) { - char buf[chunk_size-8]; + char buf[BUFSIZ]; unsigned i,subchunk_size; - if(stream_read(s,buf,chunk_size-8)!=chunk_size-8) return NULL; + if (chunk_size > sizeof(buf) || chunk_size < 20) return NULL; + if(stream_read(s,buf,chunk_size)!=chunk_size) return NULL; i=0; - subchunk_size=be2me_32(*((uint32_t *)&buf[0])); - hi->channelMode=be2me_32(*((uint32_t *)&buf[4])); + subchunk_size = AV_RB32(buf); + hi->channelMode = AV_RB32(buf + 4); w->nChannels=sh_audio->channels=hi->channelMode+1; /*0-mono;1-stereo*/ - hi->bitRate=be2me_32(*((uint32_t *)&buf[8])); + hi->bitRate = AV_RB32(buf + 8); sh_audio->i_bps=hi->bitRate*1000/8; /* bitrate kbit/s */ w->nAvgBytesPerSec = sh_audio->i_bps; - hi->samplingRate=be2me_32(*((uint32_t *)&buf[12])); + hi->samplingRate = AV_RB32(buf + 12); switch(hi->samplingRate){ case 44: w->nSamplesPerSec=44100; @@ -78,21 +82,23 @@ static demuxer_t* demux_open_vqf(demuxer_t* demuxer) { break; } sh_audio->samplerate=w->nSamplesPerSec; - hi->securityLevel=be2me_32(*((uint32_t *)&buf[16])); + hi->securityLevel = AV_RB32(buf + 16); w->nBlockAlign = 0; sh_audio->samplesize = 4; w->wBitsPerSample = 8*sh_audio->samplesize; w->cbSize = 0; + if (subchunk_size > chunk_size - 4) continue; i+=subchunk_size+4; - while(i<chunk_size-8) + while(i + 8 < chunk_size) { unsigned slen,sid; - char sdata[chunk_size]; - sid=*((uint32_t *)&buf[i]); i+=4; - slen=be2me_32(*((uint32_t *)&buf[i])); i+=4; + char sdata[BUFSIZ]; + sid = AV_RL32(buf + i); i+=4; + slen = AV_RB32(buf + i); i+=4; + if (slen > sizeof(sdata) - 1 || slen > chunk_size - i) break; if(sid==mmioFOURCC('D','S','I','Z')) { - hi->Dsiz=be2me_32(*((uint32_t *)&buf[i])); + hi->Dsiz=AV_RB32(buf + i); continue; /* describes the same info as size of DATA chunk */ } memcpy(sdata,&buf[i],slen); sdata[slen]=0; i+=slen; @@ -138,18 +144,18 @@ static demuxer_t* demux_open_vqf(demuxer_t* demuxer) { } } else - if(*((uint32_t *)&chunk_id[0])==mmioFOURCC('D','A','T','A')) + if(AV_RL32(chunk_id)==mmioFOURCC('D','A','T','A')) { demuxer->movi_start=stream_tell(s); - demuxer->movi_end=demuxer->movi_start+chunk_size-8; + demuxer->movi_end=demuxer->movi_start+chunk_size; mp_msg(MSGT_DEMUX, MSGL_V, "Found data at %"PRIX64" size %"PRIu64"\n",demuxer->movi_start,demuxer->movi_end); /* Done! play it */ break; } else { - mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled chunk '%c%c%c%c' %u bytes\n",((char *)&chunk_id)[0],((char *)&chunk_id)[1],((char *)&chunk_id)[2],((char *)&chunk_id)[3],chunk_size); - stream_skip(s,chunk_size-8); /*unknown chunk type */ + mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled chunk '%c%c%c%c' %u bytes\n",chunk_id[0],chunk_id[1],chunk_id[2],chunk_id[3],chunk_size); + stream_skip(s,chunk_size); /*unknown chunk type */ } } diff --git a/libmpdemux/parse_mp4.c b/libmpdemux/parse_mp4.c index 02b00341c2..6e4441a17c 100644 --- a/libmpdemux/parse_mp4.c +++ b/libmpdemux/parse_mp4.c @@ -1,10 +1,26 @@ -/* parse_mp4.c - MP4 file format parser code - * This file is part of MPlayer, see http://mplayerhq.hu/ for info. - * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net> - * File licensed under the GPL, see http://www.fsf.org/ for more info. +/* + * MP4 file format parser code + * + * Copyright (C) 2002 Felix Buenemann <atmosfear at users.sourceforge.net> * Code inspired by libmp4 from http://mpeg4ip.sourceforge.net/. + * + * 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 <inttypes.h> #ifdef HAVE_MALLOC_H diff --git a/libmpdemux/parse_mp4.h b/libmpdemux/parse_mp4.h index 585751c320..0591557b08 100644 --- a/libmpdemux/parse_mp4.h +++ b/libmpdemux/parse_mp4.h @@ -1,7 +1,24 @@ -/* parse_mp4.h - Headerfile for MP4 file format parser code - * This file is part of MPlayer, see http://mplayerhq.hu/ for info. - * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net> - * File licensed under the GPL, see http://www.fsf.org/ for more info. +/* + * MP4 file format parser code + * + * Copyright (C) 2002 Felix Buenemann <atmosfear at users.sourceforge.net> + * Code inspired by libmp4 from http://mpeg4ip.sourceforge.net/. + * + * 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_PARSE_MP4_H |