diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-01-15 05:07:09 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-01-15 05:57:31 +0200 |
commit | 9bcd12fdf5c6f85e9bb391caa2713021624a957e (patch) | |
tree | 375eac533ead90a45e7121e5ab307861b4ef52c8 /libmpdemux | |
parent | d419ecd161634e79dab3ac57d57c4bccba2adcdc (diff) | |
parent | e0d66b140e1da7a793bff15003cadab79544b1dd (diff) | |
download | mpv-9bcd12fdf5c6f85e9bb391caa2713021624a957e.tar.bz2 mpv-9bcd12fdf5c6f85e9bb391caa2713021624a957e.tar.xz |
Merge svn changes up to r28310
The libdvdread4 and libdvdnav directories, which are externals in the
svn repository, are at least for now not included in any form. I added
configure checks to automatically disable internal libdvdread and
libdvdnav if the corresponding directories are not present; if they're
added manually then things work the same as in svn.
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/aviprint.c | 7 | ||||
-rw-r--r-- | libmpdemux/demux_avi.c | 19 | ||||
-rw-r--r-- | libmpdemux/demux_ts.c | 69 | ||||
-rw-r--r-- | libmpdemux/demux_xmms.c | 8 | ||||
-rw-r--r-- | libmpdemux/genres.h | 38 |
5 files changed, 120 insertions, 21 deletions
diff --git a/libmpdemux/aviprint.c b/libmpdemux/aviprint.c index f0c3a89d8a..35af2ffbdf 100644 --- a/libmpdemux/aviprint.c +++ b/libmpdemux/aviprint.c @@ -74,7 +74,7 @@ void print_wave_header(WAVEFORMATEX *h, int verbose_level){ else if (h->cbSize > 0) { int i; - uint8_t* p = ((uint8_t*)h) + sizeof(WAVEFORMATEX); + uint8_t* p = (uint8_t*)(h + 1); mp_msg(MSGT_HEADER, verbose_level, "Unknown extra header dump: "); for (i = 0; i < h->cbSize; i++) mp_msg(MSGT_HEADER, verbose_level, "[%x] ", p[i]); @@ -96,7 +96,7 @@ void print_video_header(BITMAPINFOHEADER *h, int verbose_level){ if (h->biSize > sizeof(BITMAPINFOHEADER)) { int i; - uint8_t* p = ((uint8_t*)h) + sizeof(BITMAPINFOHEADER); + uint8_t* p = (uint8_t*)(h + 1); mp_msg(MSGT_HEADER, verbose_level, "Unknown extra header dump: "); for (i = 0; i < h->biSize-sizeof(BITMAPINFOHEADER); i++) mp_msg(MSGT_HEADER, verbose_level, "[%x] ", *(p+i)); @@ -135,7 +135,8 @@ void print_index(AVIINDEXENTRY *idx, int idx_size, int verbose_level){ int i; unsigned int pos[256]; unsigned int num[256]; - for(i=0;i<256;i++) num[i]=pos[i]=0; + memset(pos, 0, sizeof(pos)); + memset(num, 0, sizeof(num)); for(i=0;i<idx_size;i++){ int id=avi_stream_id(idx[i].ckid); if(id<0 || id>255) id=255; diff --git a/libmpdemux/demux_avi.c b/libmpdemux/demux_avi.c index 765463168d..9695fcb556 100644 --- a/libmpdemux/demux_avi.c +++ b/libmpdemux/demux_avi.c @@ -160,6 +160,9 @@ static int demux_avi_read_packet(demuxer_t *demux,demux_stream_t *ds,unsigned in ds_read_packet(ds,demux->stream,len,pts,idxpos,flags); skip-=len; } + skip = FFMAX(skip, 0); + if (avi_stream_id(id) > 99 && id != mmioFOURCC('J','U','N','K')) + skip = FFMIN(skip, 65536); if(skip){ mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_AVI: Skipping %d bytes from packet %04X\n",skip,id); stream_skip(demux->stream,skip); @@ -167,6 +170,18 @@ static int demux_avi_read_packet(demuxer_t *demux,demux_stream_t *ds,unsigned in return ds?1:0; } +static uint32_t avi_find_id(stream_t *stream) { + uint32_t id = stream_read_dword_le(stream); + if (!id) { + mp_msg(MSGT_DEMUX, MSGL_WARN, "Incomplete stream? Trying resync.\n"); + do { + id = stream_read_dword_le(stream); + if (stream_eof(stream)) return 0; + } while (avi_stream_id(id) > 99); + } + return id; +} + // return value: // 0 = EOF or no stream found // 1 = successfully read a packet @@ -224,7 +239,7 @@ do{ demux->stream->eof=1; return 0; } - id=stream_read_dword_le(demux->stream); + id=avi_find_id(demux->stream); len=stream_read_dword_le(demux->stream); if(stream_eof(demux->stream)) return 0; // EOF! @@ -349,7 +364,7 @@ do{ return 0; } - id=stream_read_dword_le(demux->stream); + id=avi_find_id(demux->stream); len=stream_read_dword_le(demux->stream); if(stream_eof(demux->stream)) return 0; diff --git a/libmpdemux/demux_ts.c b/libmpdemux/demux_ts.c index c0924d9ecf..3de0ce404b 100644 --- a/libmpdemux/demux_ts.c +++ b/libmpdemux/demux_ts.c @@ -59,6 +59,7 @@ int ts_prog; int ts_keep_broken=0; off_t ts_probe = 0; +int audio_substream_id = -1; extern char *dvdsub_lang, *audio_lang; //for -alang typedef enum @@ -1280,6 +1281,67 @@ static int mp4_parse_sl_packet(pmt_t *pmt, uint8_t *buf, uint16_t packet_len, in return m; } +//this function parses the extension fields in the PES header and returns the substream_id, or -1 in case of errors +static int parse_pes_extension_fields(unsigned char *p, int pkt_len) +{ + int skip; + unsigned char flags; + + if(!(p[7] & 0x1)) //no extension_field + return -1; + skip = 9; + if(p[7] & 0x80) + { + skip += 5; + if(p[7] & 0x40) + skip += 5; + } + if(p[7] & 0x20) //escr_flag + skip += 6; + if(p[7] & 0x10) //es_rate_flag + skip += 3; + if(p[7] & 0x08)//dsm_trick_mode is unsupported, skip + { + skip = 0;//don't let's parse the extension fields + } + if(p[7] & 0x04) //additional_copy_info + skip += 1; + if(p[7] & 0x02) //pes_crc_flag + skip += 2; + if(skip >= pkt_len) //too few bytes + return -1; + flags = p[skip]; + skip++; + if(flags & 0x80) //pes_private_data_flag + skip += 16; + if(skip >= pkt_len) + return -1; + if(flags & 0x40) //pack_header_field_flag + { + unsigned char l = p[skip]; + skip += l; + } + if(flags & 0x20) //program_packet_sequence_counter + skip += 2; + if(flags & 0x10) //p_std + skip += 2; + if(skip >= pkt_len) + return -1; + if(flags & 0x01) //finally the long desired pes_extension2 + { + unsigned char l = p[skip]; //ext2 flag+len + skip++; + if((l == 0x81) && (skip < pkt_len)) + { + int ssid = p[skip]; + mp_msg(MSGT_IDENTIFY, MSGL_V, "SUBSTREAM_ID=%d (0x%02X)\n", ssid, ssid); + return ssid; + } + } + + return -1; +} + static int pes_parse2(unsigned char *buf, uint16_t packet_len, ES_stream_t *es, int32_t type_from_pmt, pmt_t *pmt, int pid) { unsigned char *p; @@ -1343,6 +1405,13 @@ static int pes_parse2(unsigned char *buf, uint16_t packet_len, ES_stream_t *es, mp_msg(MSGT_DEMUX, MSGL_DBG2, "demux_ts: illegal value for PES_header_data_length (0x%02x)\n", header_len); return 0; } + + if(stream_id==0xfd) + { + int ssid = parse_pes_extension_fields(p, pkt_len); + if((audio_substream_id!=-1) && (ssid != audio_substream_id)) + return 0; + } p += header_len + 9; packet_len -= header_len + 3; diff --git a/libmpdemux/demux_xmms.c b/libmpdemux/demux_xmms.c index c6bf5eae90..b7b2e72d66 100644 --- a/libmpdemux/demux_xmms.c +++ b/libmpdemux/demux_xmms.c @@ -166,11 +166,11 @@ static InputPlugin* input_plugins[100]; static int no_plugins=0; /* Dummy functions */ -static InputVisType input_get_vis_type(){return 0;} +static InputVisType input_get_vis_type(void){return 0;} static void input_add_vis_pcm(int time, AFormat fmt, int nch, int length, void *ptr){} static void input_set_info_text(char * text){} -char *xmms_get_gentitle_format(){ return ""; } +char *xmms_get_gentitle_format(void){ return ""; } /* Dummy functions END*/ static void input_set_info(char* title,int length, int rate, int freq, int nch) @@ -212,7 +212,7 @@ static void init_plugins_from_dir(const char *plugin_dir){ closedir(dir); } -static void init_plugins(){ +static void init_plugins(void) { char *home; no_plugins=0; @@ -227,7 +227,7 @@ static void init_plugins(){ init_plugins_from_dir(XMMS_INPUT_PLUGIN_DIR); } -static void cleanup_plugins(){ +static void cleanup_plugins(void) { while(no_plugins>0){ --no_plugins; mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_XMMS_ClosingPlugin, diff --git a/libmpdemux/genres.h b/libmpdemux/genres.h index 523b48c3db..ea9216354f 100644 --- a/libmpdemux/genres.h +++ b/libmpdemux/genres.h @@ -1,6 +1,20 @@ /*********************************** * Copyright (C) 2001 Jason Carter - * See the file "LICENSE" for details + * + * This program 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * *********************************** * FILE: GENRES.H * NAME: ID3EDIT - ID3 tag v 1.1 editor @@ -71,17 +85,17 @@ const char * const genres[] = { "Darkwave", /* 50 */ "Techno-Industrial", /* 51 */ "Electronic", /* 52 */ -"Jungle", /* 53 */ -"Pop-Folk", /* 54 */ -"Eurodance", /* 55 */ -"Dream", /* 56 */ -"Southern Rock", /* 57 */ -"Comedy", /* 58 */ -"Cult", /* 59 */ -"Gangsta", /* 60 */ -"Top 40", /* 61 */ -"Christian Rap", /* 62 */ -"Pop/Funk", /* 63 */ +"Pop-Folk", /* 53 */ +"Eurodance", /* 54 */ +"Dream", /* 55 */ +"Southern Rock", /* 56 */ +"Comedy", /* 57 */ +"Cult", /* 58 */ +"Gangsta", /* 59 */ +"Top 40", /* 60 */ +"Christian Rap", /* 61 */ +"Pop/Funk", /* 62 */ +"Jungle", /* 63 */ "Native American", /* 64 */ "Cabaret", /* 65 */ "New Wave", /* 66 */ |