summaryrefslogtreecommitdiff
path: root/src/demuxers
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers')
-rw-r--r--src/demuxers/Makefile.am73
-rw-r--r--src/demuxers/asfheader.c78
-rw-r--r--src/demuxers/asfheader.h4
-rw-r--r--src/demuxers/demux.h214
-rw-r--r--src/demuxers/demux_4xm.c104
-rw-r--r--src/demuxers/demux_aac.c88
-rw-r--r--src/demuxers/demux_ac3.c79
-rw-r--r--src/demuxers/demux_aiff.c103
-rw-r--r--src/demuxers/demux_asf.c273
-rw-r--r--src/demuxers/demux_aud.c73
-rw-r--r--src/demuxers/demux_avi.c140
-rw-r--r--src/demuxers/demux_cdda.c62
-rw-r--r--src/demuxers/demux_dts.c81
-rw-r--r--src/demuxers/demux_eawve.c62
-rw-r--r--src/demuxers/demux_elem.c63
-rw-r--r--src/demuxers/demux_film.c97
-rw-r--r--src/demuxers/demux_flac.c126
-rw-r--r--src/demuxers/demux_fli.c83
-rw-r--r--src/demuxers/demux_flv.c299
-rw-r--r--src/demuxers/demux_idcin.c83
-rw-r--r--src/demuxers/demux_iff.c284
-rw-r--r--src/demuxers/demux_image.c70
-rw-r--r--src/demuxers/demux_ipmovie.c82
-rw-r--r--src/demuxers/demux_matroska.c161
-rw-r--r--src/demuxers/demux_mng.c61
-rw-r--r--src/demuxers/demux_mod.c74
-rw-r--r--src/demuxers/demux_mpc.c80
-rw-r--r--src/demuxers/demux_mpeg.c82
-rw-r--r--src/demuxers/demux_mpeg_block.c80
-rw-r--r--src/demuxers/demux_mpeg_pes.c206
-rw-r--r--src/demuxers/demux_mpgaudio.c491
-rw-r--r--src/demuxers/demux_nsf.c392
-rw-r--r--src/demuxers/demux_nsv.c91
-rw-r--r--src/demuxers/demux_ogg.c2202
-rw-r--r--src/demuxers/demux_playlist.c719
-rw-r--r--src/demuxers/demux_pva.c79
-rw-r--r--src/demuxers/demux_qt.c699
-rw-r--r--src/demuxers/demux_rawdv.c68
-rw-r--r--src/demuxers/demux_real.c237
-rw-r--r--src/demuxers/demux_realaudio.c80
-rw-r--r--src/demuxers/demux_roq.c83
-rw-r--r--src/demuxers/demux_shn.c66
-rw-r--r--src/demuxers/demux_slave.c57
-rw-r--r--src/demuxers/demux_smjpeg.c86
-rw-r--r--src/demuxers/demux_snd.c84
-rw-r--r--src/demuxers/demux_str.c93
-rw-r--r--src/demuxers/demux_ts.c317
-rw-r--r--src/demuxers/demux_tta.c79
-rw-r--r--src/demuxers/demux_vmd.c84
-rw-r--r--src/demuxers/demux_voc.c70
-rw-r--r--src/demuxers/demux_vox.c67
-rw-r--r--src/demuxers/demux_vqa.c82
-rw-r--r--src/demuxers/demux_wav.c69
-rw-r--r--src/demuxers/demux_wc3movie.c102
-rw-r--r--src/demuxers/demux_yuv4mpeg2.c68
-rw-r--r--src/demuxers/demux_yuv_frames.c55
-rw-r--r--src/demuxers/ebml.c66
-rw-r--r--src/demuxers/ebml.h11
-rw-r--r--src/demuxers/flacutils.h16
-rw-r--r--src/demuxers/group_audio.c58
-rw-r--r--src/demuxers/group_audio.h11
-rw-r--r--src/demuxers/group_games.c30
-rw-r--r--src/demuxers/group_games.h6
-rw-r--r--src/demuxers/id3.c245
-rw-r--r--src/demuxers/id3.h74
-rw-r--r--src/demuxers/iff.h13
-rw-r--r--src/demuxers/matroska.h12
-rw-r--r--src/demuxers/qtpalette.h6
68 files changed, 3296 insertions, 7137 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am
index 8a931c2d6..276505521 100644
--- a/src/demuxers/Makefile.am
+++ b/src/demuxers/Makefile.am
@@ -1,30 +1,36 @@
include $(top_srcdir)/misc/Makefile.common
-AM_CFLAGS = $(VISIBILITY_FLAG)
+AM_CFLAGS = $(DEFAULT_OCFLAGS) $(VISIBILITY_FLAG)
AM_LDFLAGS = $(xineplug_ldflags)
-if HAVE_VORBIS
-ogg_module = xineplug_dmx_ogg.la
-endif
+##
+# IMPORTANT:
+# ---------
+# All of xine demuxer plugins should be named like the scheme "xineplug_dmx_"
-if BUILD_ASF
+noinst_HEADERS = asfheader.h qtpalette.h group_games.h group_audio.h id3.h ebml.h matroska.h iff.h flacutils.h
+
+if ENABLE_ASF
asf_module = xineplug_dmx_asf.la
endif
-if HAVE_LIBMNG
+if ENABLE_MNG
mng_module = xineplug_dmx_mng.la
endif
+if ENABLE_MODPLUG
+modplug_module = xineplug_dmx_modplug.la
+endif
+
if BUILD_DMX_IMAGE
image_module = xineplug_dmx_image.la
endif
-##
-# IMPORTANT:
-# ---------
-# All of xine demuxer plugins should be named like the scheme "xineplug_dmx_"
-
-xineplug_LTLIBRARIES = $(ogg_module) $(asf_module) $(mng_module) $(image_module) \
+xineplug_LTLIBRARIES = \
+ $(asf_module) \
+ $(mng_module) \
+ $(image_module) \
+ $(modplug_module) \
xineplug_dmx_games.la \
xineplug_dmx_audio.la \
xineplug_dmx_mpeg_ts.la \
@@ -44,17 +50,14 @@ xineplug_LTLIBRARIES = $(ogg_module) $(asf_module) $(mng_module) $(image_module)
xineplug_dmx_nsv.la \
xineplug_dmx_matroska.la \
xineplug_dmx_iff.la \
- xineplug_dmx_flv.la
-
-xineplug_dmx_ogg_la_SOURCES = demux_ogg.c
-xineplug_dmx_ogg_la_LIBADD = $(VORBIS_LIBS) $(SPEEX_LIBS) $(THEORA_LIBS) $(OGG_LIBS) $(XINE_LIB)
-xineplug_dmx_ogg_la_CFLAGS = $(AM_CFLAGS) $(VORBIS_CFLAGS) $(SPEEX_CFLAGS) $(THEORA_CFLAGS) $(OGG_CFLAGS)
+ xineplug_dmx_flv.la \
+ xineplug_dmx_playlist.la
xineplug_dmx_avi_la_SOURCES = demux_avi.c
-xineplug_dmx_avi_la_LIBADD = $(XINE_LIB)
+xineplug_dmx_avi_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
xineplug_dmx_mpeg_block_la_SOURCES = demux_mpeg_block.c
-xineplug_dmx_mpeg_block_la_LIBADD = $(XINE_LIB)
+xineplug_dmx_mpeg_block_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
xineplug_dmx_mpeg_la_SOURCES = demux_mpeg.c
xineplug_dmx_mpeg_la_LIBADD = $(XINE_LIB)
@@ -63,17 +66,17 @@ xineplug_dmx_mpeg_elem_la_SOURCES = demux_elem.c
xineplug_dmx_mpeg_elem_la_LIBADD = $(XINE_LIB)
xineplug_dmx_mpeg_pes_la_SOURCES = demux_mpeg_pes.c
-xineplug_dmx_mpeg_pes_la_LIBADD = $(XINE_LIB)
+xineplug_dmx_mpeg_pes_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
xineplug_dmx_mpeg_ts_la_SOURCES = demux_ts.c
xineplug_dmx_mpeg_ts_la_LIBADD = $(XINE_LIB)
xineplug_dmx_qt_la_SOURCES = demux_qt.c
xineplug_dmx_qt_la_LIBADD = $(XINE_LIB) $(ZLIB_LIBS)
-xineplug_dmx_qt_la_CPPFLAGS = $(ZLIB_CPPFLAGS)
+xineplug_dmx_qt_la_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CPPFLAGS)
xineplug_dmx_asf_la_SOURCES = demux_asf.c asfheader.c
-xineplug_dmx_asf_la_LIBADD = $(XINE_LIB)
+xineplug_dmx_asf_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) $(LTLIBICONV)
xineplug_dmx_asf_la_CFLAGS = $(AM_CFLAGS) -fno-strict-aliasing
xineplug_dmx_fli_la_SOURCES = demux_fli.c
@@ -90,7 +93,7 @@ xineplug_dmx_rawdv_la_LIBADD = $(XINE_LIB)
xineplug_dmx_mng_la_SOURCES = demux_mng.c
xineplug_dmx_mng_la_LIBADD = $(XINE_LIB) $(ZLIB_LIBS) $(MNG_LIBS)
-xineplug_dmx_mng_la_CPPFLAGS = $(ZLIB_CPPFLAGS)
+xineplug_dmx_mng_la_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CPPFLAGS)
xineplug_dmx_pva_la_SOURCES = demux_pva.c
xineplug_dmx_pva_la_LIBADD = $(XINE_LIB)
@@ -100,18 +103,20 @@ xineplug_dmx_games_la_SOURCES = group_games.c demux_eawve.c \
demux_vqa.c demux_wc3movie.c demux_str.c \
demux_film.c demux_smjpeg.c demux_4xm.c \
demux_vmd.c
-xineplug_dmx_games_la_LIBADD = $(XINE_LIB)
-xineplug_dmx_games_la_LDFLAGS = -avoid-version -module
+xineplug_dmx_games_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
xineplug_dmx_audio_la_SOURCES = group_audio.c demux_aud.c demux_aiff.c \
- demux_cdda.c demux_mpgaudio.c demux_nsf.c \
+ demux_cdda.c demux_mpgaudio.c \
demux_realaudio.c demux_snd.c demux_voc.c \
demux_vox.c demux_wav.c demux_ac3.c id3.c \
- demux_aac.c demux_mod.c demux_flac.c \
+ demux_aac.c demux_flac.c \
demux_mpc.c demux_dts.c demux_shn.c \
demux_tta.c
-xineplug_dmx_audio_la_LIBADD = $(XINE_LIB) $(LIBMODPLUG_LIBS)
-xineplug_dmx_audio_la_CFLAGS = $(AM_CFLAGS) $(LIBMODPLUG_CFLAGS)
+xineplug_dmx_audio_la_LIBADD = $(XINE_LIB)
+
+xineplug_dmx_modplug_la_SOURCES = demux_mod.c
+xineplug_dmx_modplug_la_LIBADD = $(XINE_LIB) $(LIBMODPLUG_LIBS)
+xineplug_dmx_modplug_la_CFLAGS = $(AM_CFLAGS) $(LIBMODPLUG_CFLAGS)
xineplug_dmx_yuv_frames_la_SOURCES = demux_yuv_frames.c
xineplug_dmx_yuv_frames_la_LIBADD = $(XINE_LIB)
@@ -127,14 +132,14 @@ xineplug_dmx_nsv_la_LIBADD = $(XINE_LIB)
xineplug_dmx_matroska_la_SOURCES = demux_matroska.c ebml.c
xineplug_dmx_matroska_la_LIBADD = $(XINE_LIB) $(ZLIB_LIBS)
-xineplug_dmx_matroska_la_CPPFLAGS = $(ZLIB_CPPFLAGS)
xineplug_dmx_matroska_la_CFLAGS = $(AM_CFLAGS) -fno-strict-aliasing
+xineplug_dmx_matroska_la_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CPPFLAGS)
xineplug_dmx_iff_la_SOURCES = demux_iff.c
-xineplug_dmx_iff_la_LIBADD = $(XINE_LIB)
+xineplug_dmx_iff_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
xineplug_dmx_flv_la_SOURCES = demux_flv.c
-xineplug_dmx_flv_la_LIBADD = $(XINE_LIB)
+xineplug_dmx_flv_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
-xineinclude_HEADERS = demux.h
-noinst_HEADERS = asfheader.h qtpalette.h group_games.h group_audio.h id3.h ebml.h matroska.h iff.h flacutils.h
+xineplug_dmx_playlist_la_SOURCES = demux_playlist.c
+xineplug_dmx_playlist_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c
index 3c3cdb689..75ad11c75 100644
--- a/src/demuxers/asfheader.c
+++ b/src/demuxers/asfheader.c
@@ -17,7 +17,7 @@
#define LOG
*/
-#include "xineutils.h"
+#include <xine/xineutils.h>
#include "bswap.h"
#include "asfheader.h"
@@ -63,7 +63,6 @@ struct asf_header_internal_s {
/* private part */
int number_count;
uint16_t numbers[ASF_MAX_NUM_STREAMS];
- iconv_t iconv_cd;
uint8_t *bitrate_pointers[ASF_MAX_NUM_STREAMS];
};
@@ -95,7 +94,7 @@ static int asf_reader_get_8(asf_reader_t *reader, uint8_t *value) {
static int asf_reader_get_16(asf_reader_t *reader, uint16_t *value) {
if ((reader->size - reader->pos) < 2)
return 0;
- *value = LE_16(reader->buffer + reader->pos);
+ *value = _X_LE_16(reader->buffer + reader->pos);
reader->pos += 2;
return 1;
}
@@ -103,7 +102,7 @@ static int asf_reader_get_16(asf_reader_t *reader, uint16_t *value) {
static int asf_reader_get_32(asf_reader_t *reader, uint32_t *value) {
if ((reader->size - reader->pos) < 4)
return 0;
- *value = LE_32(reader->buffer + reader->pos);
+ *value = _X_LE_32(reader->buffer + reader->pos);
reader->pos += 4;
return 1;
}
@@ -111,7 +110,7 @@ static int asf_reader_get_32(asf_reader_t *reader, uint32_t *value) {
static int asf_reader_get_64(asf_reader_t *reader, uint64_t *value) {
if ((reader->size - reader->pos) < 8)
return 0;
- *value = LE_64(reader->buffer + reader->pos);
+ *value = _X_LE_64(reader->buffer + reader->pos);
reader->pos += 8;
return 1;
}
@@ -130,8 +129,7 @@ static uint8_t *asf_reader_get_bytes(asf_reader_t *reader, size_t size) {
if ((reader->size - reader->pos) < size)
return NULL;
- buffer = malloc(size);
- if (!buffer)
+ if (! (buffer = malloc(size)) )
return NULL;
memcpy(buffer, reader->buffer + reader->pos, size);
reader->pos += size;
@@ -142,9 +140,9 @@ static uint8_t *asf_reader_get_bytes(asf_reader_t *reader, size_t size) {
static char *asf_reader_get_string(asf_reader_t *reader, size_t size, iconv_t cd) {
char *inbuf, *outbuf;
size_t inbytesleft, outbytesleft;
- char scratch[2048];
+ char scratch[2048];
- if ((reader->size - reader->pos) < size)
+ if ((size == 0) ||((reader->size - reader->pos) < size))
return NULL;
inbuf = (char *)reader->buffer + reader->pos;
@@ -152,7 +150,7 @@ static char *asf_reader_get_string(asf_reader_t *reader, size_t size, iconv_t cd
outbuf = scratch;
outbytesleft = sizeof(scratch);
reader->pos += size;
- if (iconv (cd, (ICONV_CONST char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft) != -1) {
+ if (iconv (cd, (ICONV_CONST char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft) != (size_t)-1) {
return strdup(scratch);
} else {
lprintf("iconv error\n");
@@ -187,9 +185,9 @@ static size_t asf_reader_get_size(asf_reader_t *reader) {
void asf_get_guid(uint8_t *buffer, GUID *value) {
int i;
- value->Data1 = LE_32(buffer);
- value->Data2 = LE_16(buffer + 4);
- value->Data3 = LE_16(buffer + 6);
+ value->Data1 = _X_LE_32(buffer);
+ value->Data2 = _X_LE_16(buffer + 4);
+ value->Data3 = _X_LE_16(buffer + 6);
for(i = 0; i < 8; i++) {
value->Data4[i] = *(buffer + i + 8);
}
@@ -241,8 +239,7 @@ static int asf_header_parse_file_properties(asf_header_t *header, uint8_t *buffe
return 0;
}
- asf_file = malloc(sizeof(asf_file_t));
- if (!asf_file) {
+ if (! (asf_file = malloc(sizeof(asf_file_t))) ) {
lprintf("cannot allocate asf_file_struct\n");
return 0;
}
@@ -296,8 +293,7 @@ static int asf_header_parse_stream_properties(asf_header_t *header, uint8_t *buf
if (buffer_len < 54)
goto exit_error;
- asf_stream = malloc(sizeof(asf_stream_t));
- if (!asf_stream)
+ if (! (asf_stream = malloc(sizeof(asf_stream_t))) )
goto exit_error;
asf_reader_init(&reader, buffer, buffer_len);
@@ -363,8 +359,7 @@ static int asf_header_parse_stream_extended_properties(asf_header_t *header, uin
if (buffer_len < 64)
return 0;
- asf_stream_extension = malloc(sizeof(asf_stream_extension_t));
- if (!asf_stream_extension)
+ if (! (asf_stream_extension = malloc(sizeof(asf_stream_extension_t))) )
return 0;
asf_reader_init(&reader, buffer, buffer_len);
@@ -577,14 +572,16 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_
asf_reader_t reader;
asf_content_t *content;
uint16_t title_length, author_length, copyright_length, description_length, rating_length;
+ iconv_t iconv_cd;
if (buffer_len < 10)
return 0;
- content = malloc(sizeof(asf_content_t));
- if (!content)
+ if (! (content = calloc(1, sizeof(asf_content_t))) )
+ return 0;
+
+ if ( (iconv_cd = iconv_open("UTF-8", "UCS-2LE")) == (iconv_t)-1 )
return 0;
- memset(content, 0, sizeof(asf_content_t));
asf_reader_init(&reader, buffer, buffer_len);
asf_reader_get_16(&reader, &title_length);
@@ -593,13 +590,21 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_
asf_reader_get_16(&reader, &description_length);
asf_reader_get_16(&reader, &rating_length);
- content->title = asf_reader_get_string(&reader, title_length, header->iconv_cd);
- content->author = asf_reader_get_string(&reader, author_length, header->iconv_cd);
- content->copyright = asf_reader_get_string(&reader, copyright_length, header->iconv_cd);
- content->description = asf_reader_get_string(&reader, description_length, header->iconv_cd);
- content->rating = asf_reader_get_string(&reader, rating_length, header->iconv_cd);
+ content->title = asf_reader_get_string(&reader, title_length, iconv_cd);
+ content->author = asf_reader_get_string(&reader, author_length, iconv_cd);
+ content->copyright = asf_reader_get_string(&reader, copyright_length, iconv_cd);
+ content->description = asf_reader_get_string(&reader, description_length, iconv_cd);
+ content->rating = asf_reader_get_string(&reader, rating_length, iconv_cd);
+
+ lprintf("title: %d chars: \"%s\"\n", title_length, content->title);
+ lprintf("author: %d chars: \"%s\"\n", author_length, content->author);
+ lprintf("copyright: %d chars: \"%s\"\n", copyright_length, content->copyright);
+ lprintf("description: %d chars: \"%s\"\n", description_length, content->description);
+ lprintf("rating: %d chars: \"%s\"\n", rating_length, content->rating);
header->pub.content = content;
+
+ iconv_close(iconv_cd);
return 1;
}
@@ -611,24 +616,14 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
uint32_t object_count;
uint16_t junk;
- asf_header = malloc(sizeof(asf_header_internal_t));
- if (!asf_header)
- return NULL;
- memset(asf_header, 0, sizeof(asf_header_internal_t));
-
lprintf("parsing_asf_header\n");
if (buffer_len < 6) {
printf("invalid buffer size\n");
- free(asf_header);
return NULL;
}
- asf_header->iconv_cd = iconv_open ("UTF-8", "UCS-2LE");
- if (asf_header->iconv_cd == (iconv_t)-1) {
- printf("iconv open error\n");
- free(asf_header);
+ if (! (asf_header = calloc(1, sizeof(asf_header_internal_t))) )
return NULL;
- }
asf_reader_init(&reader, buffer, buffer_len);
asf_reader_get_32(&reader, &object_count);
@@ -697,10 +692,8 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
}
if (!asf_header->pub.content) {
lprintf("no content object present\n");
- asf_header->pub.content = malloc(sizeof(asf_content_t));
- if (!asf_header->pub.content)
+ if (! (asf_header->pub.content = calloc(1, sizeof(asf_content_t))) )
goto exit_error;
- memset(asf_header->pub.content, 0, sizeof(asf_content_t));
}
return &asf_header->pub;
@@ -766,9 +759,6 @@ void asf_header_delete (asf_header_t *header_pub) {
asf_header_delete_stream_extended_properties(header->pub.stream_extensions[i]);
}
- if (header->iconv_cd != (iconv_t)-1)
- iconv_close (header->iconv_cd);
-
free(header);
}
diff --git a/src/demuxers/asfheader.h b/src/demuxers/asfheader.h
index d52b1c0fb..4bd13ab3f 100644
--- a/src/demuxers/asfheader.h
+++ b/src/demuxers/asfheader.h
@@ -15,9 +15,7 @@
*
* 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
- *
- * $Id: asfheader.h,v 1.8 2006/09/12 21:24:19 valtri Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* demultiplexer for asf streams
*
diff --git a/src/demuxers/demux.h b/src/demuxers/demux.h
deleted file mode 100644
index 157519a87..000000000
--- a/src/demuxers/demux.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * $Id: demux.h,v 1.40 2007/01/19 00:26:39 dgp85 Exp $
- */
-
-#ifndef HAVE_DEMUX_H
-#define HAVE_DEMUX_H
-
-#ifdef XINE_COMPILE
-# include "input/input_plugin.h"
-# include "buffer.h"
-# include "xine_internal.h"
-#else
-# include <xine/input_plugin.h>
-# include <xine/buffer.h>
-# include <xine/xine_internal.h>
-#endif
-
-#define DEMUXER_PLUGIN_IFACE_VERSION 26
-
-#define DEMUX_OK 0
-#define DEMUX_FINISHED 1
-
-#define DEMUX_CANNOT_HANDLE 0
-#define DEMUX_CAN_HANDLE 1
-
-#define METHOD_BY_CONTENT 1
-#define METHOD_BY_EXTENSION 2
-#define METHOD_EXPLICIT 3
-
-typedef struct demux_class_s demux_class_t ;
-typedef struct demux_plugin_s demux_plugin_t;
-
-struct demux_class_s {
-
- /*
- * open a new instance of this plugin class
- */
- demux_plugin_t* (*open_plugin) (demux_class_t *this, xine_stream_t *stream, input_plugin_t *input);
-
- /*
- * return human readable (verbose = 1 line) description for this plugin
- */
- const char* (*get_description) (demux_class_t *this);
-
- /*
- * return human readable identifier for this plugin
- */
-
- const char* (*get_identifier) (demux_class_t *this);
-
- /*
- * return MIME types supported for this plugin
- */
-
- const char* (*get_mimetypes) (demux_class_t *this);
-
- /*
- * return ' ' seperated list of file extensions this
- * demuxer is likely to handle
- * (will be used to filter media files in
- * file selection dialogs)
- */
-
- const char* (*get_extensions) (demux_class_t *this);
-
- /*
- * close down, free all resources
- */
- void (*dispose) (demux_class_t *this);
-};
-
-
-/*
- * any demux plugin must implement these functions
- */
-
-struct demux_plugin_s {
-
- /*
- * send headers, followed by BUF_CONTROL_HEADERS_DONE down the
- * fifos, then return. do not start demux thread (yet)
- */
-
- void (*send_headers) (demux_plugin_t *this);
-
- /*
- * ask demux to seek
- *
- * for seekable streams, a start position can be specified
- *
- * start_pos : position in input source (0..65535)
- * this is defined as most convenient to demuxer, can be
- * either time or offset based.
- * start_time : position measured in miliseconds from stream start
- * playing : true if this is a new seek within an already playing stream
- * false if playback of this stream has not started yet
- *
- * if both parameters are !=0 start_pos will be used
- * for non-seekable streams both values will be ignored
- *
- * returns the demux status (like get_status, but immediately after
- * starting the demuxer)
- */
-
- int (*seek) (demux_plugin_t *this,
- off_t start_pos, int start_time, int playing );
-
- /*
- * send a chunk of data down to decoder fifos
- *
- * the meaning of "chunk" is specific to every demux, usually
- * it involves parsing one unit of data from stream.
- *
- * this function will be called from demux loop and should return
- * the demux current status
- */
-
- int (*send_chunk) (demux_plugin_t *this);
-
- /*
- * free resources
- */
-
- void (*dispose) (demux_plugin_t *this) ;
-
- /*
- * returns DEMUX_OK or DEMUX_FINISHED
- */
-
- int (*get_status) (demux_plugin_t *this) ;
-
- /*
- * gets stream length in miliseconds (might be estimated)
- * may return 0 for non-seekable streams
- */
-
- int (*get_stream_length) (demux_plugin_t *this);
-
- /*
- * return capabilities of demuxed stream
- */
-
- uint32_t (*get_capabilities) (demux_plugin_t *this);
-
- /*
- * request optional data from input plugin.
- */
- int (*get_optional_data) (demux_plugin_t *this, void *data, int data_type);
-
- /*
- * "backwards" link to plugin class
- */
-
- demux_class_t *demux_class;
-
- void *node; /* used by plugin loader */
-
-} ;
-
-/*
- * possible capabilites a demux plugin can have:
- */
-#define DEMUX_CAP_NOCAP 0x00000000
-
-/*
- * DEMUX_CAP_AUDIOLANG:
- * DEMUX_CAP_SPULANG:
- * demux plugin knows something about audio/spu languages,
- * e.g. knows that audio stream #0 is english,
- * audio stream #1 is german, ... Same bits as INPUT
- * capabilities .
- */
-
-#define DEMUX_CAP_AUDIOLANG 0x00000008
-#define DEMUX_CAP_SPULANG 0x00000010
-
-/*
- * DEMUX_CAP_CHAPTERS:
- * The media streams provided by this plugin have an internal
- * structure dividing it into segments usable for navigation.
- * For those plugins, the behaviour of the skip button in UIs
- * should be changed from "next MRL" to "next chapter" by
- * sending XINE_EVENT_INPUT_NEXT.
- * Same bits as INPUT capabilities.
- */
-
-#define DEMUX_CAP_CHAPTERS 0x00000080
-
-
-#define DEMUX_OPTIONAL_UNSUPPORTED 0
-#define DEMUX_OPTIONAL_SUCCESS 1
-
-#define DEMUX_OPTIONAL_DATA_AUDIOLANG 2
-#define DEMUX_OPTIONAL_DATA_SPULANG 3
-
-#endif
diff --git a/src/demuxers/demux_4xm.c b/src/demuxers/demux_4xm.c
index 56360542c..6256cb042 100644
--- a/src/demuxers/demux_4xm.c
+++ b/src/demuxers/demux_4xm.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* 4X Technologies (.4xm) File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information on the 4xm file format, visit:
* http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: demux_4xm.c,v 1.16 2007/01/19 00:26:39 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,10 +40,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -144,8 +142,8 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
return 0;
/* check for the signature tags */
- if ((LE_32(&preview[0]) != RIFF_TAG) ||
- (LE_32(&preview[8]) != _4XMV_TAG))
+ if ((_X_LE_32(&preview[0]) != RIFF_TAG) ||
+ (_X_LE_32(&preview[8]) != _4XMV_TAG))
return 0;
/* file is qualified; skip over the header bytes in the stream */
@@ -154,12 +152,12 @@ 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 ((LE_32(&preview[0]) != LIST_TAG) ||
- (LE_32(&preview[8]) != HEAD_TAG))
+ if ((_X_LE_32(&preview[0]) != LIST_TAG) ||
+ (_X_LE_32(&preview[8]) != HEAD_TAG))
return 0;
/* read the whole header */
- header_size = LE_32(&preview[4]) - 4;
+ header_size = _X_LE_32(&preview[4]) - 4;
header = xine_xmalloc(header_size);
if (fourxm->input->read(fourxm->input, header, header_size) != header_size) {
free(header);
@@ -174,8 +172,8 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
/* take the lazy approach and search for any and all vtrk and strk chunks */
for (i = 0; i < header_size - 8; i++) {
- fourcc_tag = LE_32(&header[i]);
- size = LE_32(&header[i + 4]);
+ fourcc_tag = _X_LE_32(&header[i]);
+ size = _X_LE_32(&header[i + 4]);
if (fourcc_tag == std__TAG) {
fps = get_le_float(&header[i + 12]);
@@ -186,13 +184,13 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
free(header);
return 0;
}
- total_frames = LE_32(&header[i + 24]);
+ 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;
fourxm->duration_in_ms *= 1000;
- fourxm->bih.biWidth = LE_32(&header[i + 36]);
- fourxm->bih.biHeight = LE_32(&header[i + 40]);
+ fourxm->bih.biWidth = _X_LE_32(&header[i + 36]);
+ fourxm->bih.biHeight = _X_LE_32(&header[i + 40]);
i += 8 + size;
} else if (fourcc_tag == strk_TAG) {
/* check that there is enough data */
@@ -200,7 +198,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
free(header);
return 0;
}
- current_track = LE_32(&header[i + 8]);
+ 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,
@@ -211,10 +209,10 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
}
}
- fourxm->tracks[current_track].channels = LE_32(&header[i + 36]);
- fourxm->tracks[current_track].sample_rate = LE_32(&header[i + 40]);
- fourxm->tracks[current_track].bits = LE_32(&header[i + 44]);
- audio_type = LE_32(&header[i + 12]);
+ 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]);
if (audio_type == 0)
fourxm->tracks[current_track].audio_type = BUF_AUDIO_LPCM_LE;
else if (audio_type == 1)
@@ -253,8 +251,8 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) {
return this->status;
}
- fourcc_tag = LE_32(&header[0]);
- size = LE_32(&header[4]);
+ fourcc_tag = _X_LE_32(&header[0]);
+ size = _X_LE_32(&header[4]);
switch (fourcc_tag) {
@@ -314,8 +312,8 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- current_track = LE_32(&header[0]);
-// size = LE_32(&header[4]);
+ current_track = _X_LE_32(&header[0]);
+// size = _X_LE_32(&header[4]);
if (current_track >= this->track_count) {
lprintf ("bad audio track number (%d >= %d)\n",
@@ -441,12 +439,6 @@ static int demux_fourxm_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_fourxm_dispose (demux_plugin_t *this_gen) {
- demux_fourxm_t *this = (demux_fourxm_t *) this_gen;
-
- free(this->tracks);
-}
-
static int demux_fourxm_get_status (demux_plugin_t *this_gen) {
demux_fourxm_t *this = (demux_fourxm_t *) this_gen;
@@ -481,7 +473,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_fourxm_send_headers;
this->demux_plugin.send_chunk = demux_fourxm_send_chunk;
this->demux_plugin.seek = demux_fourxm_seek;
- this->demux_plugin.dispose = demux_fourxm_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_fourxm_get_status;
this->demux_plugin.get_stream_length = demux_fourxm_get_stream_length;
this->demux_plugin.get_capabilities = demux_fourxm_get_capabilities;
@@ -492,19 +484,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -523,39 +503,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "4X Technologies (4xm) demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "4X Technologies";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "4xm";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_fourxm_class_t *this = (demux_fourxm_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_fourxm_init_plugin (xine_t *xine, void *data) {
demux_fourxm_class_t *this;
this = xine_xmalloc (sizeof (demux_fourxm_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("4X Technologies (4xm) demux plugin");
+ this->demux_class.identifier = "4X Technologies";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "4xm";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c
index ab71e8382..0b02f1d99 100644
--- a/src/demuxers/demux_aac.c
+++ b/src/demuxers/demux_aac.c
@@ -15,13 +15,11 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Raw AAC File Demuxer by Mike Melanson (melanson@pcisys.net)
* This demuxer detects ADIF and ADTS headers in AAC files.
* Then it shovels buffer-sized chunks over to the AAC decoder.
- *
- * $Id: demux_aac.c,v 1.17 2007/03/03 01:41:16 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -41,10 +39,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -72,42 +70,36 @@ typedef struct {
static int open_aac_file(demux_aac_t *this) {
int i;
uint8_t peak[MAX_PREVIEW_SIZE];
+ uint32_t signature;
uint16_t syncword = 0;
uint32_t id3size = 0;
off_t data_start = 0;
_x_assert(MAX_PREVIEW_SIZE > 10);
- /* Get enough data to be able to check the size of ID3 tag */
- if (_x_demux_read_header(this->input, peak, 10) != 10)
+ if (_x_demux_read_header(this->input, &signature, 4) != 4)
return 0;
/* Check if there's an ID3v2 tag at the start */
- if ( id3v2_istag(peak) ) {
- id3size = id3v2_tagsize(&peak[6]);
-
+ if ( id3v2_istag(signature) ) {
this->input->seek(this->input, 4, SEEK_SET);
- id3v2_parse_tag(this->input, this->stream, peak);
-
- lprintf("ID3v2 tag encountered, skipping %u bytes.\n", id3size);
+ id3v2_parse_tag(this->input, this->stream, signature);
}
- if ( this->input->read(this->input, peak, 4) != 4 )
+ if ( this->input->read(this->input, &signature, 4) != 4 )
return 0;
/* Check for an ADIF header - should be at the start of the file */
- if ((peak[0] == 'A') && (peak[1] == 'D') &&
- (peak[2] == 'I') && (peak[3] == 'F')) {
+ if ( signature == ME_FOURCC('A', 'D', 'I', 'F') ) {
lprintf("found ADIF header\n");
return 1;
}
/* Look for an ADTS header - might not be at the start of the file */
- if ( id3size != 0 && this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE ) {
- lprintf("Getting a buffer of size %u starting from %u\n", MAX_PREVIEW_SIZE, id3size);
+ if ( this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE ) {
+ lprintf("Getting a buffer of size %u\n", MAX_PREVIEW_SIZE);
- this->input->seek(this->input, id3size, SEEK_SET);
if ( this->input->read(this->input, peak, MAX_PREVIEW_SIZE) != MAX_PREVIEW_SIZE )
return 0;
this->input->seek(this->input, 0, SEEK_SET);
@@ -232,12 +224,6 @@ static int demux_aac_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_aac_dispose (demux_plugin_t *this_gen) {
- demux_aac_t *this = (demux_aac_t *) this_gen;
-
- free(this);
-}
-
static int demux_aac_get_status (demux_plugin_t *this_gen) {
demux_aac_t *this = (demux_aac_t *) this_gen;
@@ -271,7 +257,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_aac_send_headers;
this->demux_plugin.send_chunk = demux_aac_send_chunk;
this->demux_plugin.seek = demux_aac_seek;
- this->demux_plugin.dispose = demux_aac_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_aac_get_status;
this->demux_plugin.get_stream_length = demux_aac_get_stream_length;
this->demux_plugin.get_capabilities = demux_aac_get_capabilities;
@@ -281,19 +267,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->status = DEMUX_FINISHED;
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* Falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
if (!open_aac_file(this)) {
@@ -310,39 +284,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "ADIF/ADTS AAC demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "AAC";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "aac";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_aac_class_t *this = (demux_aac_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_aac_init_plugin (xine_t *xine, void *data) {
demux_aac_class_t *this;
this = xine_xmalloc (sizeof (demux_aac_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("ADIF/ADTS AAC demux plugin");
+ this->demux_class.identifier = "AAC";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "aac";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c
index 7f3dadeb7..2ccd5217e 100644
--- a/src/demuxers/demux_ac3.c
+++ b/src/demuxers/demux_ac3.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* AC3 File Demuxer by Mike Melanson (melanson@pcisys.net)
* This demuxer detects raw AC3 data in a file and shovels AC3 data
* directly to the AC3 decoder.
- *
- * $Id: demux_ac3.c,v 1.21 2007/03/19 16:42:32 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -36,6 +34,9 @@
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
#define LOG_MODULE "demux_ac3"
#define LOG_VERBOSE
@@ -43,10 +44,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -135,10 +136,10 @@ static int open_ac3_file(demux_ac3_t *this) {
uint8_t *peak;
blocksize = this->input->get_blocksize(this->input);
- if (blocksize) {
+ if (blocksize && INPUT_IS_SEEKABLE(this->input)) {
this->input->seek(this->input, 0, SEEK_SET);
buf_element_t *buf = this->input->read_block(this->input,
- this->audio_fifo,
+ this->stream->audio_fifo,
blocksize);
this->input->seek(this->input, 0, SEEK_SET);
@@ -175,10 +176,10 @@ static int open_ac3_file(demux_ac3_t *this) {
lprintf("looks like a cd audio wav file\n");
/* Find the data chunk */
- offset = 20 + LE_32(&peak[16]);
+ offset = 20 + _X_LE_32(&peak[16]);
while (offset < peak_size-8) {
- unsigned int chunk_tag = LE_32(&peak[offset]);
- unsigned int chunk_size = LE_32(&peak[offset+4]);
+ unsigned int chunk_tag = _X_LE_32(&peak[offset]);
+ unsigned int chunk_size = _X_LE_32(&peak[offset+4]);
if (chunk_tag == DATA_TAG) {
offset += 8;
@@ -383,12 +384,6 @@ static int demux_ac3_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_ac3_dispose (demux_plugin_t *this_gen) {
- demux_ac3_t *this = (demux_ac3_t *) this_gen;
-
- free(this);
-}
-
static int demux_ac3_get_status (demux_plugin_t *this_gen) {
demux_ac3_t *this = (demux_ac3_t *) this_gen;
@@ -423,7 +418,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_ac3_send_headers;
this->demux_plugin.send_chunk = demux_ac3_send_chunk;
this->demux_plugin.seek = demux_ac3_seek;
- this->demux_plugin.dispose = demux_ac3_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_ac3_get_status;
this->demux_plugin.get_stream_length = demux_ac3_get_stream_length;
this->demux_plugin.get_capabilities = demux_ac3_get_capabilities;
@@ -434,19 +429,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -465,39 +448,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Raw AC3 demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "AC3";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "ac3";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_ac3_class_t *this = (demux_ac3_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_ac3_init_plugin (xine_t *xine, void *data) {
demux_ac3_class_t *this;
this = xine_xmalloc (sizeof (demux_ac3_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Raw AC3 demux plugin");
+ this->demux_class.identifier = "AC3";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "ac3";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c
index f88c58572..51bc624e3 100644
--- a/src/demuxers/demux_aiff.c
+++ b/src/demuxers/demux_aiff.c
@@ -15,14 +15,11 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* AIFF File Demuxer by Mike Melanson (melanson@pcisys.net)
- *
- * $Id: demux_aiff.c,v 1.41 2007/01/19 00:26:40 dgp85 Exp $
- *
*/
#ifdef HAVE_CONFIG_H
@@ -36,10 +33,10 @@
#include <stdlib.h>
#include <ctype.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -90,14 +87,13 @@ static int open_aiff_file(demux_aiff_t *this) {
unsigned char preamble[PREAMBLE_SIZE];
unsigned int chunk_type;
unsigned int chunk_size;
- unsigned char buffer[100];
if (_x_demux_read_header(this->input, signature, AIFF_SIGNATURE_SIZE) != AIFF_SIGNATURE_SIZE)
return 0;
/* check the signature */
- if ((BE_32(&signature[0]) != FORM_TAG) ||
- (BE_32(&signature[8]) != AIFF_TAG))
+ if ((_X_BE_32(&signature[0]) != FORM_TAG) ||
+ (_X_BE_32(&signature[8]) != AIFF_TAG))
return 0;
/* file is qualified; skip over the header bytes in the stream */
@@ -118,26 +114,28 @@ static int open_aiff_file(demux_aiff_t *this) {
this->status = DEMUX_FINISHED;
return 0;
}
- chunk_type = BE_32(&preamble[0]);
- chunk_size = BE_32(&preamble[4]);
+ chunk_type = _X_BE_32(&preamble[0]);
+ chunk_size = _X_BE_32(&preamble[4]);
- if (chunk_size > sizeof(buffer) / sizeof(buffer[0])) {
- /* the chunk is too large to fit in the buffer -> this cannot be an aiff chunk */
- this->status = DEMUX_FINISHED;
- return 0;
- }
-
if (chunk_type == COMM_TAG) {
+ unsigned char buffer[100];
+
+ if (chunk_size > sizeof(buffer) / sizeof(buffer[0])) {
+ /* the chunk is too large to fit in the buffer -> this cannot be an aiff chunk */
+ this->status = DEMUX_FINISHED;
+ return 0;
+ }
+
if (this->input->read(this->input, buffer, chunk_size) !=
chunk_size) {
this->status = DEMUX_FINISHED;
return 0;
}
- this->audio_channels = BE_16(&buffer[0]);
- this->audio_frames = BE_32(&buffer[2]);
- this->audio_bits = BE_16(&buffer[6]);
- this->audio_sample_rate = BE_16(&buffer[0x0A]);
+ this->audio_channels = _X_BE_16(&buffer[0]);
+ this->audio_frames = _X_BE_32(&buffer[2]);
+ this->audio_bits = _X_BE_16(&buffer[6]);
+ this->audio_sample_rate = _X_BE_16(&buffer[0x0A]);
this->audio_bytes_per_second = this->audio_channels *
(this->audio_bits / 8) * this->audio_sample_rate;
@@ -307,12 +305,6 @@ static int demux_aiff_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_aiff_dispose (demux_plugin_t *this_gen) {
- demux_aiff_t *this = (demux_aiff_t *) this_gen;
-
- free(this);
-}
-
static int demux_aiff_get_status (demux_plugin_t *this_gen) {
demux_aiff_t *this = (demux_aiff_t *) this_gen;
@@ -347,7 +339,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_aiff_send_headers;
this->demux_plugin.send_chunk = demux_aiff_send_chunk;
this->demux_plugin.seek = demux_aiff_seek;
- this->demux_plugin.dispose = demux_aiff_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_aiff_get_status;
this->demux_plugin.get_stream_length = demux_aiff_get_stream_length;
this->demux_plugin.get_capabilities = demux_aiff_get_capabilities;
@@ -358,19 +350,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -389,41 +369,20 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "AIFF file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "AIFF";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "aif aiff";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "audio/x-aiff: aif, aiff: AIFF audio;"
- "audio/aiff: aif, aiff: AIFF audio;"
- "audio/x-pn-aiff: aif, aiff: AIFF audio;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_aiff_class_t *this = (demux_aiff_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_aiff_init_plugin (xine_t *xine, void *data) {
demux_aiff_class_t *this;
this = xine_xmalloc (sizeof (demux_aiff_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("AIFF file demux plugin");
+ this->demux_class.identifier = "AIFF";
+ this->demux_class.mimetypes =
+ "audio/x-aiff: aif, aiff: AIFF audio;"
+ "audio/aiff: aif, aiff: AIFF audio;"
+ "audio/x-pn-aiff: aif, aiff: AIFF audio;";
+ this->demux_class.extensions = "aif aiff";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c
index 65838138f..57624aa15 100644
--- a/src/demuxers/demux_asf.c
+++ b/src/demuxers/demux_asf.c
@@ -15,9 +15,7 @@
*
* 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
- *
- * $Id: demux_asf.c,v 1.194 2007/03/09 23:18:19 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* demultiplexer for asf streams
*
@@ -47,12 +45,12 @@
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "demux.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/demux.h>
+#include <xine/xineutils.h>
#include "bswap.h"
#include "asfheader.h"
-#include "xmlparser.h"
+#include <xine/xmlparser.h>
#define CODEC_TYPE_AUDIO 0
#define CODEC_TYPE_VIDEO 1
@@ -201,7 +199,7 @@ static uint16_t get_le16 (demux_asf_t *this) {
this->status = DEMUX_FINISHED;
}
- return LE_16(buf);
+ return _X_LE_16(buf);
}
static uint32_t get_le32 (demux_asf_t *this) {
@@ -218,7 +216,7 @@ static uint32_t get_le32 (demux_asf_t *this) {
this->status = DEMUX_FINISHED;
}
- return LE_32(buf);
+ return _X_LE_32(buf);
}
static uint64_t get_le64 (demux_asf_t *this) {
@@ -233,7 +231,7 @@ static uint64_t get_le64 (demux_asf_t *this) {
this->status = DEMUX_FINISHED;
}
- return LE_64(buf);
+ return _X_LE_64(buf);
}
static int get_guid_id (demux_asf_t *this, GUID *g) {
@@ -378,7 +376,7 @@ static void asf_send_video_header (demux_asf_t *this, int stream) {
static int asf_read_header (demux_asf_t *this) {
int i;
uint64_t asf_header_len;
- char *asf_header_buffer = NULL;
+ uint8_t *asf_header_buffer = NULL;
asf_header_len = get_le64(this);
asf_header_buffer = alloca(asf_header_len);
@@ -483,10 +481,10 @@ static int asf_read_header (demux_asf_t *this) {
uint16_t bmiheader_size;
xine_bmiheader *bmiheader;
- width = LE_32(asf_stream->private_data);
- height = LE_32(asf_stream->private_data + 4);
+ width = _X_LE_32(asf_stream->private_data);
+ height = _X_LE_32(asf_stream->private_data + 4);
/* there is one unknown byte between height and the bmiheader size */
- bmiheader_size = LE_16(asf_stream->private_data + 9);
+ bmiheader_size = _X_LE_16(asf_stream->private_data + 9);
/* FIXME: bmiheader_size must be >= sizeof(xine_bmiheader) */
@@ -516,7 +514,7 @@ static int asf_read_header (demux_asf_t *this) {
lprintf ("palette_count: %d\n", demux_stream->palette_count);
if (demux_stream->palette_count > 256) {
- lprintf ("number of colors exceeded 256 (%d)", demux_stream->palette_count);
+ lprintf ("number of colours exceeded 256 (%d)", demux_stream->palette_count);
demux_stream->palette_count = 256;
}
if ((asf_stream->private_data_length - sizeof(xine_bmiheader) - 11) >= (demux_stream->palette_count * 4)) {
@@ -614,14 +612,14 @@ static int demux_asf_send_headers_common (demux_asf_t *this) {
}
static void asf_reorder(demux_asf_t *this, uint8_t *src, int len){
- uint8_t *dst = malloc(len);
+ uint8_t dst[len];
uint8_t *s2 = src;
int i = 0, x, y;
while(len-i >= this->reorder_h * this->reorder_w*this->reorder_b){
for(x = 0; x < this->reorder_w; x++)
for(y = 0; y < this->reorder_h; y++){
- memcpy(dst + i, s2 + (y * this->reorder_w+x) * this->reorder_b,
+ memcpy(&dst[i], s2 + (y * this->reorder_w+x) * this->reorder_b,
this->reorder_b);
i += this->reorder_b;
}
@@ -629,7 +627,6 @@ static void asf_reorder(demux_asf_t *this, uint8_t *src, int len){
}
xine_fast_memcpy(src,dst,i);
- free(dst);
}
/* redefine abs as macro to handle 64-bit diffs.
@@ -725,6 +722,9 @@ static void asf_send_buffer_nodefrag (demux_asf_t *this, asf_demux_stream_t *str
buf->size = bufsize;
timestamp = 0;
+ if (stream->frag_offset == 0)
+ buf->decoder_flags |= BUF_FLAG_FRAME_START;
+
stream->frag_offset += bufsize;
frag_len -= bufsize;
@@ -735,10 +735,6 @@ static void asf_send_buffer_nodefrag (demux_asf_t *this, asf_demux_stream_t *str
else
check_newpts (this, buf->pts, PTS_AUDIO, package_done);
-
- if (frag_offset == 0)
- buf->decoder_flags |= BUF_FLAG_FRAME_START;
-
/* test if whole packet read */
if (package_done) {
buf->decoder_flags |= BUF_FLAG_FRAME_END;
@@ -935,9 +931,9 @@ static int asf_parse_packet_ecd(demux_asf_t *this, uint32_t *p_hdr_size) {
return 1;
}
*p_hdr_size += 15;
- guid->Data1 = LE_32(buf);
- guid->Data2 = LE_16(buf + 4);
- guid->Data3 = LE_16(buf + 6);
+ guid->Data1 = _X_LE_32(buf);
+ guid->Data2 = _X_LE_16(buf + 4);
+ guid->Data3 = _X_LE_16(buf + 6);
if (get_guid_id(this, guid) == GUID_ASF_HEADER) {
lprintf("new asf header detected\n");
_x_demux_control_end(this->stream, 0);
@@ -1538,108 +1534,90 @@ static int demux_asf_parse_asx_references( demux_asf_t *this) {
ENTRYREF, MOREINFO, PARAM, REPEAT, TITLE
*/
- const char *version = xml_parser_get_property (xml_tree, "VERSION");
+ const char *base_href = NULL;
- if (version) {
- int version_major, version_minor = 0;
+ for (asx_entry = xml_tree->child; asx_entry; asx_entry = asx_entry->next)
+ {
+ const char *ref_base_href = base_href;
- if((sscanf (version, "%d.%d", &version_major, &version_minor) == 2 ||
- sscanf (version, "%d", &version_major) == 1) &&
- (version_major == 3 && version_minor == 0))
+ if (!strcasecmp (asx_entry->name, "ENTRY"))
{
- const char *base_href = NULL;
+ /* Attributes: CLIENTSKIP, SKIPIFREF
+ * Child elements: ABSTRACT, AUTHOR, BASE, COPYRIGHT, DURATION,
+ ENDMARKER, MOREINFO, PARAM, REF, STARTMARKER,
+ STARTTIME, TITLE
+ */
+ const char *href = NULL;
+ const char *title = NULL;
+ uint32_t start_time = (uint32_t)-1;
+ uint32_t duration = (uint32_t)-1;
- for (asx_entry = xml_tree->child; asx_entry; asx_entry = asx_entry->next)
+ for (asx_ref = asx_entry->child; asx_ref; asx_ref = asx_ref->next)
{
- const char *ref_base_href = base_href;
-
- if (!strcasecmp (asx_entry->name, "ENTRY"))
+ if (!strcasecmp(asx_ref->name, "REF"))
{
- /* Attributes: CLIENTSKIP, SKIPIFREF
- * Child elements: ABSTRACT, AUTHOR, BASE, COPYRIGHT, DURATION,
- ENDMARKER, MOREINFO, PARAM, REF, STARTMARKER,
- STARTTIME, TITLE
+ xml_node_t *asx_sub;
+ /* Attributes: HREF
+ * Child elements: DURATION, ENDMARKER, STARTMARKER, STARTTIME
+ */
+
+ /* FIXME: multiple REFs => alternative streams
+ * (and per-ref start times and durations?).
+ * Just the one title, though.
*/
- const char *href = NULL;
- const char *title = NULL;
- uint32_t start_time = (uint32_t)-1;
- uint32_t duration = (uint32_t)-1;
+ href = xml_parser_get_property (asx_ref, "HREF");
- for (asx_ref = asx_entry->child; asx_ref; asx_ref = asx_ref->next)
+ for (asx_sub = asx_ref->child; asx_sub; asx_sub = asx_sub->next)
{
- if (!strcasecmp(asx_ref->name, "REF"))
- {
- xml_node_t *asx_sub;
- /* Attributes: HREF
- * Child elements: DURATION, ENDMARKER, STARTMARKER, STARTTIME
- */
-
- /* FIXME: multiple REFs => alternative streams
- * (and per-ref start times and durations?).
- * Just the one title, though.
- */
- href = xml_parser_get_property (asx_ref, "HREF");
-
- for (asx_sub = asx_ref->child; asx_sub; asx_sub = asx_sub->next)
- {
- if (!strcasecmp (asx_sub->name, "STARTTIME"))
- start_time = asx_get_time_value (asx_sub);
- else if (!strcasecmp (asx_sub->name, "DURATION"))
- duration = asx_get_time_value (asx_sub);
- }
- }
-
- else if (!strcasecmp (asx_ref->name, "TITLE"))
- {
- if (!title)
- title = asx_ref->data;
- }
-
- else if (!strcasecmp (asx_ref->name, "STARTTIME"))
- {
- if (start_time == (uint32_t)-1)
- start_time = asx_get_time_value (asx_ref);
- }
-
- else if (!strcasecmp (asx_ref->name, "DURATION"))
- {
- if (duration == (uint32_t)-1)
- duration = asx_get_time_value (asx_ref);
- }
-
- else if (!strcasecmp (asx_ref->name, "BASE"))
- /* Attributes: HREF */
- ref_base_href = xml_parser_get_property (asx_entry, "HREF");
+ if (!strcasecmp (asx_sub->name, "STARTTIME"))
+ start_time = asx_get_time_value (asx_sub);
+ else if (!strcasecmp (asx_sub->name, "DURATION"))
+ duration = asx_get_time_value (asx_sub);
}
+ }
- /* FIXME: prepend ref_base_href to href */
- if (href && *href)
- _x_demux_send_mrl_reference (this->stream, 0, href, title,
- start_time == (uint32_t)-1 ? 0 : start_time,
- duration == (uint32_t)-1 ? -1 : duration);
+ else if (!strcasecmp (asx_ref->name, "TITLE"))
+ {
+ if (!title)
+ title = asx_ref->data;
+ }
+
+ else if (!strcasecmp (asx_ref->name, "STARTTIME"))
+ {
+ if (start_time == (uint32_t)-1)
+ start_time = asx_get_time_value (asx_ref);
}
- else if (!strcasecmp (asx_entry->name, "ENTRYREF"))
+ else if (!strcasecmp (asx_ref->name, "DURATION"))
{
- /* Attributes: HREF, CLIENTBIND */
- const char *href = xml_parser_get_property (asx_entry, "HREF");
- if (href && *href)
- _x_demux_send_mrl_reference (this->stream, 0, href, NULL, 0, -1);
+ if (duration == (uint32_t)-1)
+ duration = asx_get_time_value (asx_ref);
}
- else if (!strcasecmp (asx_entry->name, "BASE"))
+ else if (!strcasecmp (asx_ref->name, "BASE"))
/* Attributes: HREF */
- base_href = xml_parser_get_property (asx_entry, "HREF");
+ ref_base_href = xml_parser_get_property (asx_entry, "HREF");
}
+
+ /* FIXME: prepend ref_base_href to href */
+ if (href && *href)
+ _x_demux_send_mrl_reference (this->stream, 0, href, title,
+ start_time == (uint32_t)-1 ? 0 : start_time,
+ duration == (uint32_t)-1 ? -1 : duration);
}
- else
- xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- _("demux_asf: Wrong ASX version: %s\n"), version);
-
+
+ else if (!strcasecmp (asx_entry->name, "ENTRYREF"))
+ {
+ /* Attributes: HREF, CLIENTBIND */
+ const char *href = xml_parser_get_property (asx_entry, "HREF");
+ if (href && *href)
+ _x_demux_send_mrl_reference (this->stream, 0, href, NULL, 0, -1);
+ }
+
+ else if (!strcasecmp (asx_entry->name, "BASE"))
+ /* Attributes: HREF */
+ base_href = xml_parser_get_property (asx_entry, "HREF");
}
- else
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "demux_asf: Unable to find VERSION tag from ASX.\n");
}
else
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
@@ -1682,7 +1660,7 @@ static int demux_asf_send_chunk (demux_plugin_t *this_gen) {
default:
{
- int header_size = 0;
+ uint32_t header_size = 0;
if (asf_parse_packet_align(this)) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_asf: asf_parse_packet_align failed\n");
@@ -1868,7 +1846,7 @@ static int demux_asf_seek (demux_plugin_t *this_gen,
start_pos -= (start_pos - this->first_packet_pos) % this->packet_size;
while ((start_pos >= this->first_packet_pos) && (state != 5)) {
- int header_size;
+ uint32_t header_size;
/* seek to the beginning of the previous packet */
lprintf ("demux_asf_seek: seek back\n");
@@ -2042,10 +2020,8 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
!strstr(buf,"ASX") &&
strncmp(buf,"[Reference]", 11) &&
strncmp(buf,"ASF ", 4) &&
- ((buf[0] != 0x30)
- || (buf[1] != 0x26)
- || (buf[2] != 0xb2)
- || (buf[3] != 0x75)))
+ memcmp(buf, "\x30\x26\xB2\x75", 4)
+ )
return NULL;
}
@@ -2053,23 +2029,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
break;
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl (input);
- const char *const ending = strrchr (mrl, '.');
-
- if (!ending)
- return NULL;
-
- if (strncasecmp(ending, ".asf", 4) &&
- strncasecmp(ending, ".wmv", 4) &&
- strncasecmp(ending, ".wma", 4) ) {
- return NULL;
- }
-
- lprintf ("extension accepted.\n");
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -2118,38 +2078,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "ASF demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "ASF";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- /* asx, wvx, wax are metafile or playlist */
- return "asf wmv wma asx wvx wax";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
-
- return "video/x-ms-asf: asf: ASF stream;"
- "video/x-ms-wmv: wmv: Windows Media Video;"
- "audio/x-ms-wma: wma: Windows Media Audio;"
- "application/vnd.ms-asf: asf: ASF stream;"
- "application/x-mplayer2: asf,asx,asp: mplayer2;"
- "video/x-ms-asf-plugin: asf,asx,asp: mms animation;"
- "video/x-ms-wvx: wvx: wmv metafile;"
- "video/x-ms-wax: wva: wma metafile;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_asf_class_t *this = (demux_asf_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_asf_class_t *this;
@@ -2159,11 +2087,20 @@ static void *init_class (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("ASF demux plugin");
+ this->demux_class.identifier = "ASF";
+ this->demux_class.mimetypes =
+ "video/x-ms-asf: asf: ASF stream;"
+ "video/x-ms-wmv: wmv: Windows Media Video;"
+ "audio/x-ms-wma: wma: Windows Media Audio;"
+ "application/vnd.ms-asf: asf: ASF stream;"
+ "application/x-mplayer2: asf,asx,asp: mplayer2;"
+ "video/x-ms-asf-plugin: asf,asx,asp: mms animation;"
+ "video/x-ms-wvx: wvx: wmv metafile;"
+ "video/x-ms-wax: wva: wma metafile;";
+ /* asx, wvx, wax are metafile or playlist */
+ this->demux_class.extensions = "asf wmv wma asx wvx wax";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -2178,6 +2115,6 @@ static const demuxer_info_t demux_info_asf = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "asf", XINE_VERSION_CODE, &demux_info_asf, init_class },
+ { PLUGIN_DEMUX, 27, "asf", XINE_VERSION_CODE, &demux_info_asf, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_aud.c b/src/demuxers/demux_aud.c
index ea57a6939..c58500ab2 100644
--- a/src/demuxers/demux_aud.c
+++ b/src/demuxers/demux_aud.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -33,8 +33,6 @@
* initialized to 0 at the start of the file and maintained throughout the
* data. This makes seeking conceptually impossible. Upshot: Random
* seeking is not supported.
- *
- * $Id: demux_aud.c,v 1.20 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -47,10 +45,10 @@
#include <string.h>
#include <stdlib.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_audio.h"
@@ -97,7 +95,7 @@ static int open_aud_file(demux_aud_t *this) {
* of numbers. There is a 80002/16777216 = 0.48% chance of a false
* positive.
*/
- this->audio_samplerate = LE_16(&header[0]);
+ this->audio_samplerate = _X_LE_16(&header[0]);
if ((this->audio_samplerate < 8000) || (this->audio_samplerate > 48000))
return 0;
@@ -133,7 +131,7 @@ static int demux_aud_send_chunk(demux_plugin_t *this_gen) {
demux_aud_t *this = (demux_aud_t *) this_gen;
unsigned char chunk_preamble[AUD_CHUNK_PREAMBLE_SIZE];
- unsigned int chunk_size;
+ int chunk_size;
off_t current_file_pos;
int64_t audio_pts;
buf_element_t *buf;
@@ -145,12 +143,12 @@ static int demux_aud_send_chunk(demux_plugin_t *this_gen) {
}
/* validate the chunk */
- if (LE_32(&chunk_preamble[4]) != 0x0000DEAF) {
+ if (_X_LE_32(&chunk_preamble[4]) != 0x0000DEAF) {
this->status = DEMUX_FINISHED;
return this->status;
}
- chunk_size = LE_16(&chunk_preamble[0]);
+ chunk_size = _X_LE_16(&chunk_preamble[0]);
current_file_pos = this->input->get_current_pos(this->input) -
this->data_start;
@@ -243,11 +241,6 @@ static int demux_aud_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_aud_dispose (demux_plugin_t *this) {
-
- free(this);
-}
-
static int demux_aud_get_status (demux_plugin_t *this_gen) {
demux_aud_t *this = (demux_aud_t *) this_gen;
@@ -279,7 +272,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_aud_send_headers;
this->demux_plugin.send_chunk = demux_aud_send_chunk;
this->demux_plugin.seek = demux_aud_seek;
- this->demux_plugin.dispose = demux_aud_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_aud_get_status;
this->demux_plugin.get_stream_length = demux_aud_get_stream_length;
this->demux_plugin.get_capabilities = demux_aud_get_capabilities;
@@ -291,19 +284,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
case METHOD_BY_CONTENT: /* no reliable detection */
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
if (!open_aud_file(this)) {
@@ -320,39 +301,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Westwood Studios AUD file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "Westwood Studios AUD";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "aud";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_aud_class_t *this = (demux_aud_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_aud_init_plugin (xine_t *xine, void *data) {
demux_aud_class_t *this;
this = xine_xmalloc (sizeof (demux_aud_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Westwood Studios AUD file demux plugin");
+ this->demux_class.identifier = "Westwood Studios AUD";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "aud";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index fe324c2f4..c6a73ebde 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -15,12 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_avi.c,v 1.232 2007/03/29 19:24:18 dgp85 Exp $
- *
* demultiplexer for avi streams
*
* part of the code is taken from
@@ -46,7 +44,6 @@
* expect to find the next A/V frame. We periodically check if we can
* read data from the file at that offset. If we can, we append index
* data for as many frames as we can read at the time.
- *
*/
/*
@@ -55,7 +52,6 @@
* Transcode's and xine's avi code comes from the same source and
* still has a very similar architecture, so it wasn't much effort to
* port it from transcode to xine.
- *
*/
#ifdef HAVE_CONFIG_H
@@ -74,9 +70,9 @@
#define DEBUG_ODML
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
#include "bswap.h"
/*
@@ -333,13 +329,13 @@ typedef struct {
/* bit 31 denotes a keyframe */
static uint32_t odml_len (unsigned char *str)
{
- return LE_32(str) & 0x7fffffff;
+ return _X_LE_32(str) & 0x7fffffff;
}
/* if bit 31 is 0, its a keyframe */
static uint32_t odml_key (unsigned char *str)
{
- return (LE_32(str) & 0x80000000)?0:0x10;
+ return (_X_LE_32(str) & 0x80000000)?0:0x10;
}
static void check_newpts (demux_avi_t *this, int64_t pts, int video) {
@@ -554,7 +550,7 @@ static int idx_grow(demux_avi_t *this, int (*stopper)(demux_avi_t *, void *),
continue;
}
- chunk_len = LE_32(data + 4);
+ chunk_len = _X_LE_32(data + 4);
this->idx_grow.nexttagoffset += PAD_EVEN(chunk_len + AVI_HEADER_SIZE);
@@ -777,7 +773,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
break; /* We assume it's EOF */
}
- n = LE_32(data + 4);
+ n = _X_LE_32(data + 4);
n = PAD_EVEN(n);
next_chunk = this->idx_grow.nexttagoffset + 8 + n;
@@ -850,7 +846,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
continue;
}
- n = LE_32(hdrl_data + i + 4);
+ n = _X_LE_32(hdrl_data + i + 4);
n = PAD_EVEN(n);
/* Interpret the tag and its args */
@@ -862,10 +858,10 @@ static avi_t *AVI_init(demux_avi_t *this) {
if(strncasecmp(hdrl_data + i, "vids", 4) == 0 && !vids_strh_seen) {
AVI->compressor = *(uint32_t *) (hdrl_data + i + 4);
- AVI->dwInitialFrames = LE_32(hdrl_data + i + 16);
- AVI->dwScale = LE_32(hdrl_data + i + 20);
- AVI->dwRate = LE_32(hdrl_data + i + 24);
- AVI->dwStart = LE_32(hdrl_data + i + 28);
+ AVI->dwInitialFrames = _X_LE_32(hdrl_data + i + 16);
+ AVI->dwScale = _X_LE_32(hdrl_data + i + 20);
+ AVI->dwRate = _X_LE_32(hdrl_data + i + 24);
+ AVI->dwStart = _X_LE_32(hdrl_data + i + 28);
if(AVI->dwScale!=0)
AVI->fps = (double)AVI->dwRate/(double)AVI->dwScale;
@@ -890,15 +886,15 @@ static avi_t *AVI_init(demux_avi_t *this) {
AVI->audio[AVI->n_audio] = a;
a->audio_strn = num_stream;
- a->dwInitialFrames = LE_32(hdrl_data + i + 16);
- a->dwScale = LE_32(hdrl_data + i + 20);
- a->dwRate = LE_32(hdrl_data + i + 24);
- a->dwStart = LE_32(hdrl_data + i + 28);
+ a->dwInitialFrames = _X_LE_32(hdrl_data + i + 16);
+ a->dwScale = _X_LE_32(hdrl_data + i + 20);
+ a->dwRate = _X_LE_32(hdrl_data + i + 24);
+ a->dwStart = _X_LE_32(hdrl_data + i + 28);
lprintf("dwScale=%d, dwRate=%d, dwInitialFrames=%d, dwStart=%d, num_stream=%d\n",
a->dwScale, a->dwRate, a->dwInitialFrames, a->dwStart, num_stream);
- a->dwSampleSize = LE_32(hdrl_data + i + 44);
+ a->dwSampleSize = _X_LE_32(hdrl_data + i + 44);
a->audio_tot = 0;
auds_strh_seen = 1;
lprintf("audio stream header, num_stream=%d\n", num_stream);
@@ -913,7 +909,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
num_stream++;
} else if(strncasecmp(hdrl_data+i,"dmlh",4) == 0) {
- AVI->total_frames = LE_32(hdrl_data+i+8);
+ AVI->total_frames = _X_LE_32(hdrl_data+i+8);
#ifdef DEBUG_ODML
lprintf( "AVI: real number of frames %d\n", AVI->total_frames);
#endif
@@ -921,7 +917,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
} else if(strncasecmp(hdrl_data + i, "strf", 4) == 0) {
i += 4;
- strf_size = LE_32(hdrl_data + i);
+ strf_size = _X_LE_32(hdrl_data + i);
i += 4;
if(lasttag == 1) {
/* lprintf ("size : %d\n",sizeof(AVI->bih)); */
@@ -953,7 +949,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
lprintf ("palette_count: %d\n", AVI->palette_count);
if (AVI->palette_count > 256) {
- lprintf ("number of colors exceeded 256 (%d)", AVI->palette_count);
+ lprintf ("number of colours exceeded 256 (%d)", AVI->palette_count);
AVI->palette_count = 256;
}
if ((strf_size - sizeof(xine_bmiheader)) >= (AVI->palette_count * 4)) {
@@ -1000,11 +996,11 @@ static avi_t *AVI_init(demux_avi_t *this) {
superindex = (avisuperindex_chunk *) malloc (sizeof (avisuperindex_chunk));
a = hdrl_data + i;
memcpy (superindex->fcc, a, 4); a += 4;
- superindex->dwSize = LE_32(a); a += 4;
- superindex->wLongsPerEntry = LE_16(a); a += 2;
+ superindex->dwSize = _X_LE_32(a); a += 4;
+ superindex->wLongsPerEntry = _X_LE_16(a); a += 2;
superindex->bIndexSubType = *a; a += 1;
superindex->bIndexType = *a; a += 1;
- superindex->nEntriesInUse = LE_32(a); a += 4;
+ superindex->nEntriesInUse = _X_LE_32(a); a += 4;
memcpy (superindex->dwChunkId, a, 4); a += 4;
#ifdef DEBUG_ODML
@@ -1038,9 +1034,9 @@ static avi_t *AVI_init(demux_avi_t *this) {
superindex->aIndex = malloc (superindex->nEntriesInUse * sizeof (avisuperindex_entry));
/* position of ix## chunks */
for (j = 0; j < superindex->nEntriesInUse; ++j) {
- superindex->aIndex[j].qwOffset = LE_64 (a); a += 8;
- superindex->aIndex[j].dwSize = LE_32 (a); a += 4;
- superindex->aIndex[j].dwDuration = LE_32 (a); a += 4;
+ superindex->aIndex[j].qwOffset = _X_LE_64 (a); a += 8;
+ superindex->aIndex[j].dwSize = _X_LE_32 (a); a += 4;
+ superindex->aIndex[j].dwDuration = _X_LE_32 (a); a += 4;
#ifdef DEBUG_ODML
printf("[%d] 0x%llx 0x%x %u\n", j,
(uint64_t)superindex->aIndex[j].qwOffset,
@@ -1148,21 +1144,21 @@ static avi_t *AVI_init(demux_avi_t *this) {
ERR_EXIT(AVI_ERR_NO_VIDS);
}
- pos = LE_32(AVI->idx[i] + 8);
- len = LE_32(AVI->idx[i] + 12);
+ pos = _X_LE_32(AVI->idx[i] + 8);
+ len = _X_LE_32(AVI->idx[i] + 12);
this->input->seek(this->input, pos, SEEK_SET);
if(this->input->read(this->input, data, 8) != 8)
ERR_EXIT(AVI_ERR_READ) ;
- if( (strncasecmp(data, AVI->idx[i], 4) == 0) && (LE_32(data + 4) == len) ) {
+ if( (strncasecmp(data, AVI->idx[i], 4) == 0) && (_X_LE_32(data + 4) == len) ) {
idx_type = 1; /* Index from start of file */
} else {
this->input->seek(this->input, pos + AVI->movi_start - 4, SEEK_SET);
if(this->input->read(this->input, data, 8) != 8)
ERR_EXIT(AVI_ERR_READ) ;
- if( strncasecmp(data,AVI->idx[i], 4) == 0 && LE_32(data + 4) == len ) {
+ if( strncasecmp(data,AVI->idx[i], 4) == 0 && _X_LE_32(data + 4) == len ) {
idx_type = 2; /* Index from start of movi list */
}
}
@@ -1183,9 +1179,9 @@ static avi_t *AVI_init(demux_avi_t *this) {
if((AVI->idx[i][0] == AVI->video_tag[0]) &&
(AVI->idx[i][1] == AVI->video_tag[1])) {
- off_t pos = LE_32(AVI->idx[i] + 8) + ioff;
- uint32_t len = LE_32(AVI->idx[i] + 12);
- uint32_t flags = LE_32(AVI->idx[i] + 4);
+ off_t pos = _X_LE_32(AVI->idx[i] + 8) + ioff;
+ uint32_t len = _X_LE_32(AVI->idx[i] + 12);
+ uint32_t flags = _X_LE_32(AVI->idx[i] + 4);
if (video_index_append(AVI, pos, len, flags) == -1) {
ERR_EXIT(AVI_ERR_NO_MEM) ;
@@ -1196,8 +1192,8 @@ static avi_t *AVI_init(demux_avi_t *this) {
if((AVI->idx[i][0] == audio->audio_tag[0]) &&
(AVI->idx[i][1] == audio->audio_tag[1])) {
- off_t pos = LE_32(AVI->idx[i] + 8) + ioff;
- uint32_t len = LE_32(AVI->idx[i] + 12);
+ off_t pos = _X_LE_32(AVI->idx[i] + 8) + ioff;
+ uint32_t len = _X_LE_32(AVI->idx[i] + 12);
/* VBR streams (hack from mplayer) */
if (audio->wavex && audio->wavex->nBlockAlign) {
@@ -1255,11 +1251,11 @@ static avi_t *AVI_init(demux_avi_t *this) {
continue;
}
- nrEntries = LE_32(en + 12);
+ nrEntries = _X_LE_32(en + 12);
#ifdef DEBUG_ODML
printf("[%d:0] Video nrEntries %ld\n", j, (long)nrEntries);
#endif
- offset = LE_64(en + 20);
+ offset = _X_LE_64(en + 20);
/* skip header */
en += hdrl_len;
@@ -1270,7 +1266,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
uint32_t len;
uint32_t flags;
- pos = offset + LE_32(en); en += 4;
+ pos = offset + _X_LE_32(en); en += 4;
len = odml_len(en);
flags = odml_key(en); en += 4;
video_index_append(AVI, pos, len, flags);
@@ -1325,11 +1321,11 @@ static avi_t *AVI_init(demux_avi_t *this) {
continue;
}
- nrEntries = LE_32(en + 12);
+ nrEntries = _X_LE_32(en + 12);
#ifdef DEBUG_ODML
/*printf("[%d:%d] Audio nrEntries %ld\n", j, audtr, nrEntries); */
#endif
- offset = LE_64(en + 20);
+ offset = _X_LE_64(en + 20);
/* skip header */
en += hdrl_len;
@@ -1340,7 +1336,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
off_t pos;
uint32_t len;
- pos = offset + LE_32(en); en += 4;
+ pos = offset + _X_LE_32(en); en += 4;
len = odml_len(en); en += 4;
/* VBR streams (hack from mplayer) */
@@ -1647,7 +1643,7 @@ static int get_chunk_header(demux_avi_t *this, uint32_t *len, int *audio_stream)
while (1) {
if (this->input->read(this->input, data, AVI_HEADER_SIZE) != AVI_HEADER_SIZE)
break;
- *len = LE_32(data + 4);
+ *len = _X_LE_32(data + 4);
lprintf("header: %c%c%c%c, pos=%" PRIdMAX ", len=%u\n",
data[0], data[1], data[2], data[3],
@@ -2257,17 +2253,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions))
- return NULL;
- }
- /* we want to fall through here */
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -2314,41 +2300,19 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
/*
* demux avi class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "AVI/RIFF demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "AVI";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "avi";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "video/msvideo: avi: AVI video;"
- "video/x-msvideo: avi: AVI video;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_avi_class_t *this = (demux_avi_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_avi_class_t *this;
this = xine_xmalloc (sizeof (demux_avi_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("AVI/RIFF demux plugin");
+ this->demux_class.identifier = "AVI";
+ this->demux_class.mimetypes =
+ "video/msvideo: avi: AVI video;"
+ "video/x-msvideo: avi: AVI video;";
+ this->demux_class.extensions = "avi";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -2362,6 +2326,6 @@ static const demuxer_info_t demux_info_avi = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "avi", XINE_VERSION_CODE, &demux_info_avi, init_class },
+ { PLUGIN_DEMUX, 27, "avi", XINE_VERSION_CODE, &demux_info_avi, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_cdda.c b/src/demuxers/demux_cdda.c
index d92a8ba23..03dcc2605 100644
--- a/src/demuxers/demux_cdda.c
+++ b/src/demuxers/demux_cdda.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -23,8 +23,6 @@
* All this demuxer does is read raw CD frames and shovel them to the
* linear PCM "decoder" (which in turn sends them directly to the audio
* output target; this is a really fancy CD-playing architecture).
- *
- * $Id: demux_cdda.c,v 1.20 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -43,10 +41,10 @@
/* #define LOG_VERBOSE */
/* #define LOG */
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -155,12 +153,6 @@ static int demux_cdda_seek (demux_plugin_t *this_gen, off_t start_pos, int start
return this->status;
}
-static void demux_cdda_dispose (demux_plugin_t *this_gen) {
- demux_cdda_t *this = (demux_cdda_t *) this_gen;
-
- free(this);
-}
-
static int demux_cdda_get_status (demux_plugin_t *this_gen) {
demux_cdda_t *this = (demux_cdda_t *) this_gen;
@@ -196,7 +188,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_cdda_send_headers;
this->demux_plugin.send_chunk = demux_cdda_send_chunk;
this->demux_plugin.seek = demux_cdda_seek;
- this->demux_plugin.dispose = demux_cdda_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_cdda_get_status;
this->demux_plugin.get_stream_length = demux_cdda_get_stream_length;
this->demux_plugin.get_capabilities = demux_cdda_get_capabilities;
@@ -208,14 +200,8 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
case METHOD_BY_CONTENT:
- case METHOD_BY_EXTENSION:
- if (strncasecmp (input->get_mrl (input), "cdda:", 5)) {
- free (this);
- return NULL;
- }
-
- break;
-
+ return NULL;
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -227,39 +213,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "CD Digital Audio demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "CDDA";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return NULL;
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_cdda_class_t *this = (demux_cdda_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_cdda_init_plugin (xine_t *xine, void *data) {
demux_cdda_class_t *this;
this = xine_xmalloc (sizeof (demux_cdda_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("CD Digital Audio demux plugin");
+ this->demux_class.identifier = "CDDA";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "cdda:/";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c
index 7baeae377..9d3313a72 100644
--- a/src/demuxers/demux_dts.c
+++ b/src/demuxers/demux_dts.c
@@ -15,11 +15,9 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Raw DTS Demuxer by James Stembridge (jstembridge@gmail.com)
- *
- * $Id: demux_dts.c,v 1.8 2007/03/19 16:42:32 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -32,6 +30,9 @@
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
#define LOG_MODULE "demux_dts"
#define LOG_VERBOSE
@@ -39,10 +40,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -85,10 +86,10 @@ static int open_dts_file(demux_dts_t *this) {
lprintf("open_dts_file\n");
blocksize = this->input->get_blocksize(this->input);
- if (blocksize) {
- this->input->seek(this->input, 0, SEEK_SET);
+ if (blocksize && INPUT_IS_SEEKABLE(this->input)) {
+ // this->input->seek(this->input, 0, SEEK_SET);
buf_element_t *buf = this->input->read_block(this->input,
- this->audio_fifo,
+ this->stream->audio_fifo,
blocksize);
this->input->seek(this->input, 0, SEEK_SET);
@@ -125,10 +126,10 @@ static int open_dts_file(demux_dts_t *this) {
lprintf("looks like a cd audio wav file\n");
/* Find the data chunk */
- offset = 20 + LE_32(&peak[16]);
+ offset = 20 + _X_LE_32(&peak[16]);
while (offset < peak_size-8) {
- unsigned int chunk_tag = LE_32(&peak[offset]);
- unsigned int chunk_size = LE_32(&peak[offset+4]);
+ unsigned int chunk_tag = _X_LE_32(&peak[offset]);
+ unsigned int chunk_size = _X_LE_32(&peak[offset+4]);
if (chunk_tag == DATA_TAG) {
offset += 8;
@@ -319,12 +320,6 @@ static int demux_dts_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_dts_dispose (demux_plugin_t *this_gen) {
- demux_dts_t *this = (demux_dts_t *) this_gen;
-
- free(this);
-}
-
static int demux_dts_get_status (demux_plugin_t *this_gen) {
demux_dts_t *this = (demux_dts_t *) this_gen;
@@ -352,7 +347,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_dts_send_headers;
this->demux_plugin.send_chunk = demux_dts_send_chunk;
this->demux_plugin.seek = demux_dts_seek;
- this->demux_plugin.dispose = demux_dts_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_dts_get_status;
this->demux_plugin.get_stream_length = demux_dts_get_stream_length;
this->demux_plugin.get_capabilities = demux_dts_get_capabilities;
@@ -363,19 +358,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
if (!open_dts_file(this)) {
@@ -392,39 +375,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Raw DTS demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "DTS";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "dts";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_dts_class_t *this = (demux_dts_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_dts_init_plugin (xine_t *xine, void *data) {
demux_dts_class_t *this;
this = xine_xmalloc (sizeof (demux_dts_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Raw DTS demux plugin");
+ this->demux_class.identifier = "DTS";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "dts";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_eawve.c b/src/demuxers/demux_eawve.c
index 67c087208..04cc714d7 100644
--- a/src/demuxers/demux_eawve.c
+++ b/src/demuxers/demux_eawve.c
@@ -15,12 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_eawve.c,v 1.29 2007/01/19 00:26:40 dgp85 Exp $
- *
* demux_eawve.c, Demuxer plugin for Electronic Arts' WVE file format
*
* written and currently maintained by Robin Kay <komadori@myrealbox.com>
@@ -41,10 +39,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
-#include "demux.h"
+#include <xine/demux.h>
#include "group_games.h"
#define FOURCC_TAG BE_FOURCC
@@ -247,7 +245,7 @@ static int demux_eawve_send_chunk(demux_eawve_t *this){
if (first_segment) {
buf->decoder_flags |= BUF_FLAG_FRAME_START;
- this->sample_counter += LE_32(buf->content);
+ this->sample_counter += _X_LE_32(buf->content);
first_segment = 0;
}
@@ -324,10 +322,6 @@ static int demux_eawve_seek(demux_eawve_t *this, off_t start_pos, int start_time
return this->status;
}
-static void demux_eawve_dispose(demux_eawve_t *this){
- free(this);
-}
-
static int demux_eawve_get_status(demux_eawve_t *this){
return this->status;
}
@@ -358,7 +352,7 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
this->demux_plugin.send_headers = (void*)demux_eawve_send_headers;
this->demux_plugin.send_chunk = (void*)demux_eawve_send_chunk;
this->demux_plugin.seek = (void*)demux_eawve_seek;
- this->demux_plugin.dispose = (void*)demux_eawve_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = (void*)demux_eawve_get_status;
this->demux_plugin.get_stream_length = (void*)demux_eawve_get_stream_length;
this->demux_plugin.get_capabilities = demux_eawve_get_capabilities;
@@ -369,19 +363,7 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -400,37 +382,17 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
return &this->demux_plugin;
}
-static const char *get_description(demux_class_t *this_gen){
- return "Electronics Arts WVE format demux plugin";
-}
-
-static const char *get_identifier(demux_class_t *this_gen){
- return "EA WVE";
-}
-
-static const char *get_extensions(demux_class_t *this_gen){
- return "wve";
-}
-
-static const char *get_mimetypes(demux_class_t *this_gen){
- return NULL;
-}
-
-static void class_dispose(demux_class_t *this){
- free(this);
-}
-
void *demux_eawve_init_plugin(xine_t *xine, void *data) {
demux_eawve_class_t *this;
this = xine_xmalloc(sizeof(demux_eawve_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Electronics Arts WVE format demux plugin");
+ this->demux_class.identifier = "EA WVE";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "wve";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c
index be86b32ed..e653818c4 100644
--- a/src/demuxers/demux_elem.c
+++ b/src/demuxers/demux_elem.c
@@ -15,12 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_elem.c,v 1.91 2007/02/20 00:34:55 dgp85 Exp $
- *
* demultiplexer for elementary mpeg streams
*/
@@ -40,10 +38,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#define NUM_PREVIEW_BUFFERS 50
#define SCRATCH_SIZE 256
@@ -171,11 +169,6 @@ static int demux_mpeg_elem_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_mpeg_elem_dispose (demux_plugin_t *this) {
-
- free (this);
-}
-
static int demux_mpeg_elem_get_stream_length(demux_plugin_t *this_gen) {
return 0 ; /*FIXME: implement */
}
@@ -224,15 +217,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions))
- return NULL;
- }
+ case METHOD_BY_MRL:
break;
case METHOD_EXPLICIT:
@@ -249,7 +234,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_mpeg_elem_send_headers;
this->demux_plugin.send_chunk = demux_mpeg_elem_send_chunk;
this->demux_plugin.seek = demux_mpeg_elem_seek;
- this->demux_plugin.dispose = demux_mpeg_elem_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_mpeg_elem_get_status;
this->demux_plugin.get_stream_length = demux_mpeg_elem_get_stream_length;
this->demux_plugin.get_capabilities = demux_mpeg_elem_get_capabilities;
@@ -261,39 +246,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Elementary MPEG stream demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MPEG_ELEM";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mpv";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_mpeg_elem_class_t *this = (demux_mpeg_elem_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_elem_class_t *this;
this = xine_xmalloc (sizeof (demux_mpeg_elem_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Elementary MPEG stream demux plugin");
+ this->demux_class.identifier = "MPEG_ELEM";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "mpv";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -307,6 +270,6 @@ static const demuxer_info_t demux_info_elem = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "elem", XINE_VERSION_CODE, &demux_info_elem, init_plugin },
+ { PLUGIN_DEMUX, 27, "elem", XINE_VERSION_CODE, &demux_info_elem, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c
index d3cedc0e1..cc9e90d66 100644
--- a/src/demuxers/demux_film.c
+++ b/src/demuxers/demux_film.c
@@ -15,13 +15,11 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* FILM (CPK) File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information on the FILM file format, visit:
* http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: demux_film.c,v 1.82 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -49,10 +47,10 @@
* demuxer is dispatching to the engine */
#define DEBUG_FILM_DEMUX 0
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -143,7 +141,7 @@ static int open_film_file(demux_film_t *film) {
return 0;
/* FILM signature correct? */
- if (strncmp(scratch, "FILM", 4)) {
+ if (memcmp(scratch, "FILM", 4)) {
return 0;
}
llprintf(DEBUG_FILM_LOAD, "found 'FILM' signature\n");
@@ -152,11 +150,11 @@ static int open_film_file(demux_film_t *film) {
film->input->seek(film->input, 16, SEEK_SET);
/* header size = header size - 16-byte FILM signature */
- film_header_size = BE_32(&scratch[4]) - 16;
+ film_header_size = _X_BE_32(&scratch[4]) - 16;
film_header = xine_xmalloc(film_header_size);
if (!film_header)
return 0;
- strncpy(film->version, &scratch[8], 4);
+ memcpy(film->version, &scratch[8], 4);
llprintf(DEBUG_FILM_LOAD, "0x%X header bytes, version %c%c%c%c\n",
film_header_size,
film->version[0],
@@ -180,8 +178,8 @@ static int open_film_file(demux_film_t *film) {
/* traverse the FILM header */
i = 0;
while (i < film_header_size) {
- chunk_type = BE_32(&film_header[i]);
- chunk_size = BE_32(&film_header[i + 4]);
+ chunk_type = _X_BE_32(&film_header[i]);
+ chunk_size = _X_BE_32(&film_header[i + 4]);
/* sanity check the chunk size */
if (i + chunk_size > film_header_size) {
@@ -197,8 +195,8 @@ static int open_film_file(demux_film_t *film) {
llprintf(DEBUG_FILM_LOAD, "parsing FDSC chunk\n");
/* always fetch the video information */
- film->bih.biWidth = BE_32(&film_header[i + 16]);
- film->bih.biHeight = BE_32(&film_header[i + 12]);
+ film->bih.biWidth = _X_BE_32(&film_header[i + 16]);
+ film->bih.biHeight = _X_BE_32(&film_header[i + 12]);
film->video_codec = *(uint32_t *)&film_header[i + 8];
film->video_type = _x_fourcc_to_buf_video(*(uint32_t *)&film_header[i + 8]);
@@ -209,7 +207,7 @@ static int open_film_file(demux_film_t *film) {
if (chunk_size == 32) {
film->audio_channels = film_header[21];
film->audio_bits = film_header[22];
- film->sample_rate = BE_16(&film_header[24]);
+ film->sample_rate = _X_BE_16(&film_header[24]);
} else {
/* If the FDSC chunk is not 32 bytes long, this is an early FILM
* file. Make a few assumptions about the audio parms based on the
@@ -253,23 +251,22 @@ static int open_film_file(demux_film_t *film) {
llprintf(DEBUG_FILM_LOAD, "parsing STAB chunk\n");
/* load the sample table */
- if (film->sample_table)
- free(film->sample_table);
- film->frequency = BE_32(&film_header[i + 8]);
- film->sample_count = BE_32(&film_header[i + 12]);
+ free(film->sample_table);
+ film->frequency = _X_BE_32(&film_header[i + 8]);
+ film->sample_count = _X_BE_32(&film_header[i + 12]);
film->sample_table =
- xine_xmalloc(film->sample_count * sizeof(film_sample_t));
+ xine_xcalloc(film->sample_count, sizeof(film_sample_t));
for (j = 0; j < film->sample_count; j++) {
film->sample_table[j].sample_offset =
- BE_32(&film_header[(i + 16) + j * 16 + 0])
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 0])
+ film_header_size + 16;
film->sample_table[j].sample_size =
- BE_32(&film_header[(i + 16) + j * 16 + 4]);
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 4]);
pts =
- BE_32(&film_header[(i + 16) + j * 16 + 8]);
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 8]);
film->sample_table[j].duration =
- BE_32(&film_header[(i + 16) + j * 16 + 12]);
+ _X_BE_32(&film_header[(i + 16) + j * 16 + 12]);
if (pts == 0xFFFFFFFF) {
@@ -331,8 +328,7 @@ static int open_film_file(demux_film_t *film) {
/* allocate enough space in the interleave preload buffer for the
* first chunk (which will be more than enough for successive chunks) */
if (film->audio_type) {
- if (film->interleave_buffer)
- free(film->interleave_buffer);
+ free(film->interleave_buffer);
film->interleave_buffer =
xine_xmalloc(film->sample_table[0].sample_size);
}
@@ -823,8 +819,7 @@ static int demux_film_seek (demux_plugin_t *this_gen, off_t start_pos, int start
static void demux_film_dispose (demux_plugin_t *this_gen) {
demux_film_t *this = (demux_film_t *) this_gen;
- if (this->sample_table)
- free(this->sample_table);
+ free(this->sample_table);
free(this->interleave_buffer);
free(this);
}
@@ -873,19 +868,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -904,39 +887,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "FILM (CPK) demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "FILM (CPK)";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "cpk cak film";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_film_class_t *this = (demux_film_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_film_init_plugin (xine_t *xine, void *data) {
demux_film_class_t *this;
this = xine_xmalloc (sizeof (demux_film_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("FILM (CPK) demux plugin");
+ this->demux_class.identifier = "FILM (CPK)";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "cpk cak film";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c
index f52da4d03..b4c5427c5 100644
--- a/src/demuxers/demux_flac.c
+++ b/src/demuxers/demux_flac.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* FLAC File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information on the FLAC file format, visit:
* http://flac.sourceforge.net/
- *
- * $Id: demux_flac.c,v 1.17 2007/03/29 16:52:23 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,10 +40,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_audio.h"
@@ -82,6 +80,7 @@ typedef struct {
* It returns 1 if flac file was opened successfully. */
static int open_flac_file(demux_flac_t *flac) {
+ uint32_t signature;
unsigned char preamble[10];
unsigned int block_length;
unsigned char buffer[FLAC_SEEKPOINT_SIZE];
@@ -90,41 +89,27 @@ static int open_flac_file(demux_flac_t *flac) {
flac->seekpoints = NULL;
- /* fetch the file signature, get enough bytes so that id3 can also
- be skipped and/or parsed */
- if (_x_demux_read_header(flac->input, preamble, 10) != 10)
+ /* fetch the file signature, 4 bytes will read both the fLaC
+ * signature and the */
+ if (_x_demux_read_header(flac->input, &signature, 4) != 4)
return 0;
+ flac->input->seek(flac->input, 4, SEEK_SET);
+
/* Unfortunately some FLAC files have an ID3 flag prefixed on them
* before the actual FLAC headers... these are barely legal, but
* users use them and want them working, so check and skip the ID3
* tag if present.
*/
- if ( id3v2_istag(preamble) ) {
- uint32_t id3size;
-
- /* First 3 bytes are the ID3 signature as above, then comes two bytes
- * encoding the major and minor version of ID3 used, that we can ignore
- * as long as we don't try to read the metadata; after those there's a
- * single byte with flags that depends on the ID3 version used; and now
- * after all that stuff, there's the size of the rest of the tag, which
- * is encoded as four bytes.. but only 7 out of 8 bits of every byte is
- * used... don't ask.
- */
- id3size = id3v2_tagsize(&preamble[6]);
-
- id3v2_parse_tag(flac->input, flac->stream, preamble);
+ if ( id3v2_istag(signature) ) {
+ id3v2_parse_tag(flac->input, flac->stream, signature);
- flac->input->seek(flac->input, id3size, SEEK_SET);
-
- if ( flac->input->read(flac->input, preamble, 4) != 4 )
+ if ( flac->input->read(flac->input, &signature, 4) != 4 )
return 0;
- } else
- flac->input->seek(flac->input, 4, SEEK_SET);
+ }
/* validate signature */
- if ((preamble[0] != 'f') || (preamble[1] != 'L') ||
- (preamble[2] != 'a') || (preamble[3] != 'C'))
+ if ( signature != ME_FOURCC('f', 'L', 'a', 'C') )
return 0;
/* loop through the metadata blocks; use a do-while construct since there
@@ -153,11 +138,11 @@ static int open_flac_file(demux_flac_t *flac) {
flac->streaminfo + sizeof(xine_waveformatex),
FLAC_STREAMINFO_SIZE) != FLAC_STREAMINFO_SIZE)
return 0;
- flac->sample_rate = BE_32(&streaminfo[10]);
+ flac->sample_rate = _X_BE_32(&streaminfo[10]);
flac->channels = ((flac->sample_rate >> 9) & 0x07) + 1;
flac->bits_per_sample = ((flac->sample_rate >> 4) & 0x1F) + 1;
flac->sample_rate >>= 12;
- flac->total_samples = BE_64(&streaminfo[10]) & UINT64_C(0x0FFFFFFFFF); /* 36 bits */
+ flac->total_samples = _X_BE_64(&streaminfo[10]) & UINT64_C(0x0FFFFFFFFF); /* 36 bits */
lprintf ("%d Hz, %d bits, %d channels, %"PRId64" total samples\n",
flac->sample_rate, flac->bits_per_sample,
flac->channels, flac->total_samples);
@@ -179,15 +164,15 @@ static int open_flac_file(demux_flac_t *flac) {
case 3:
lprintf ("SEEKTABLE metadata, %d bytes\n", block_length);
flac->seekpoint_count = block_length / FLAC_SEEKPOINT_SIZE;
- flac->seekpoints = xine_xmalloc(flac->seekpoint_count *
- sizeof(flac_seekpoint_t));
+ flac->seekpoints = xine_xcalloc(flac->seekpoint_count,
+ sizeof(flac_seekpoint_t));
for (i = 0; i < flac->seekpoint_count; i++) {
if (flac->input->read(flac->input, buffer, FLAC_SEEKPOINT_SIZE) != FLAC_SEEKPOINT_SIZE)
return 0;
- flac->seekpoints[i].sample_number = BE_64(&buffer[0]);
+ flac->seekpoints[i].sample_number = _X_BE_64(&buffer[0]);
lprintf (" %d: sample %"PRId64", ", i, flac->seekpoints[i].sample_number);
- flac->seekpoints[i].offset = BE_64(&buffer[8]);
- flac->seekpoints[i].size = BE_16(&buffer[16]);
+ flac->seekpoints[i].offset = _X_BE_64(&buffer[8]);
+ flac->seekpoints[i].size = _X_BE_16(&buffer[16]);
lprintf ("@ 0x%"PRIX64", size = %d bytes, ",
flac->seekpoints[i].offset, flac->seekpoints[i].size);
flac->seekpoints[i].pts = flac->seekpoints[i].sample_number;
@@ -205,9 +190,8 @@ static int open_flac_file(demux_flac_t *flac) {
lprintf ("VORBIS_COMMENT metadata\n");
{
char comments[block_length];
- void *ptr = comments;
- uint32_t length, user_comment_list_length;
- int cn;
+ char *ptr = comments;
+ uint32_t length, user_comment_list_length, cn;
char *comment;
char c;
@@ -215,15 +199,15 @@ static int open_flac_file(demux_flac_t *flac) {
int tracknumber = -1;
int tracktotal = -1;
- length = LE_32(ptr);
+ length = _X_LE_32(ptr);
ptr += 4 + length;
- user_comment_list_length = LE_32(ptr);
+ user_comment_list_length = _X_LE_32(ptr);
ptr += 4;
cn = 0;
for (; cn < user_comment_list_length; cn++) {
- length = LE_32(ptr);
+ length = _X_LE_32(ptr);
ptr += 4;
comment = (char*) ptr;
@@ -455,12 +439,6 @@ static int demux_flac_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_flac_dispose (demux_plugin_t *this_gen) {
- demux_flac_t *this = (demux_flac_t *) this_gen;
-
- free(this->seekpoints);
-}
-
static int demux_flac_get_status (demux_plugin_t *this_gen) {
demux_flac_t *this = (demux_flac_t *) this_gen;
@@ -504,7 +482,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_flac_send_headers;
this->demux_plugin.send_chunk = demux_flac_send_chunk;
this->demux_plugin.seek = demux_flac_seek;
- this->demux_plugin.dispose = demux_flac_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_flac_get_status;
this->demux_plugin.get_stream_length = demux_flac_get_stream_length;
this->demux_plugin.get_capabilities = demux_flac_get_capabilities;
@@ -515,19 +493,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -546,39 +512,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Free Lossless Audio Codec (flac) demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "FLAC";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "flac";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_flac_class_t *this = (demux_flac_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_flac_init_plugin (xine_t *xine, void *data) {
demux_flac_class_t *this;
this = xine_xmalloc (sizeof (demux_flac_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Free Lossless Audio Codec (flac) demux plugin");
+ this->demux_class.identifier = "FLAC";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "flac";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_fli.c b/src/demuxers/demux_fli.c
index c9cc26cf1..0dad5883a 100644
--- a/src/demuxers/demux_fli.c
+++ b/src/demuxers/demux_fli.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -23,8 +23,6 @@
* For information on the FLI format, as well as various traps to
* avoid while programming a FLI decoder, visit:
* http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: demux_fli.c,v 1.60 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -37,10 +35,10 @@
#include <string.h>
#include <stdlib.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#define FLI_HEADER_SIZE 128
@@ -86,7 +84,7 @@ static int open_fli_file(demux_fli_t *this) {
return 0;
/* validate the file */
- this->magic_number = LE_16(&this->fli_header[4]);
+ this->magic_number = _X_LE_16(&this->fli_header[4]);
if ((this->magic_number != FLI_FILE_MAGIC_1) &&
(this->magic_number != FLI_FILE_MAGIC_2))
return 0;
@@ -95,7 +93,7 @@ static int open_fli_file(demux_fli_t *this) {
this->input->seek(this->input, FLI_HEADER_SIZE, SEEK_SET);
/* check if this is a special FLI file from Magic Carpet game */
- if (LE_16(&this->fli_header[16]) == FLI_CHUNK_MAGIC_1) {
+ if (_X_LE_16(&this->fli_header[16]) == FLI_CHUNK_MAGIC_1) {
/* if the input is non-seekable, do not bother with playing the
* special file type */
if (INPUT_IS_SEEKABLE(this->input)) {
@@ -108,11 +106,11 @@ static int open_fli_file(demux_fli_t *this) {
this->magic_number = FLI_FILE_MAGIC_3;
}
- this->frame_count = LE_16(&this->fli_header[6]);
- this->bih.biWidth = LE_16(&this->fli_header[8]);
- this->bih.biHeight = LE_16(&this->fli_header[10]);
+ this->frame_count = _X_LE_16(&this->fli_header[6]);
+ this->bih.biWidth = _X_LE_16(&this->fli_header[8]);
+ this->bih.biHeight = _X_LE_16(&this->fli_header[10]);
- this->speed = LE_32(&this->fli_header[16]);
+ this->speed = _X_LE_32(&this->fli_header[16]);
if (this->magic_number == FLI_FILE_MAGIC_1) {
/*
* in this case, the speed (n) is number of 1/70s ticks between frames:
@@ -169,8 +167,8 @@ static int demux_fli_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- chunk_size = LE_32(&fli_buf[0]);
- chunk_magic = LE_16(&fli_buf[4]);
+ chunk_size = _X_LE_32(&fli_buf[0]);
+ chunk_magic = _X_LE_16(&fli_buf[4]);
if ((chunk_magic == FLI_CHUNK_MAGIC_1) ||
(chunk_magic == FLI_CHUNK_MAGIC_2)) {
@@ -268,11 +266,6 @@ static int demux_fli_seek (demux_plugin_t *this_gen, off_t start_pos, int start_
return this->status;
}
-static void demux_fli_dispose (demux_plugin_t *this) {
-
- free(this);
-}
-
static int demux_fli_get_status (demux_plugin_t *this_gen) {
demux_fli_t *this = (demux_fli_t *) this_gen;
@@ -312,7 +305,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_fli_send_headers;
this->demux_plugin.send_chunk = demux_fli_send_chunk;
this->demux_plugin.seek = demux_fli_seek;
- this->demux_plugin.dispose = demux_fli_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_fli_get_status;
this->demux_plugin.get_stream_length = demux_fli_get_stream_length;
this->demux_plugin.get_capabilities = demux_fli_get_capabilities;
@@ -323,19 +316,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -354,39 +335,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Autodesk Animator FLI/FLC demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "FLI/FLC";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "fli flc";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "video/x-flic: fli,flc: Autodesk FLIC files;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_fli_class_t *this = (demux_fli_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_fli_class_t *this;
this = xine_xmalloc (sizeof (demux_fli_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Autodesk Animator FLI/FLC demux plugin");
+ this->demux_class.identifier = "FLI/FLC";
+ this->demux_class.mimetypes = "video/x-flic: fli,flc: Autodesk FLIC files;";
+ this->demux_class.extensions = "fli flc";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -400,6 +359,6 @@ static const demuxer_info_t demux_info_fli = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "fli", XINE_VERSION_CODE, &demux_info_fli, init_plugin },
+ { PLUGIN_DEMUX, 27, "fli", XINE_VERSION_CODE, &demux_info_fli, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c
index 0588b408e..e6a7e234a 100644
--- a/src/demuxers/demux_flv.c
+++ b/src/demuxers/demux_flv.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -25,8 +25,6 @@
*
* For more information on the FLV file format, visit:
* http://download.macromedia.com/pub/flash/flash_file_format_specification.pdf
- *
- * $Id: demux_flv.c,v 1.21 2007/03/17 11:29:43 klan Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -44,10 +42,10 @@
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -70,13 +68,21 @@ typedef struct {
off_t start; /* in bytes */
off_t size; /* in bytes */
- unsigned char got_video;
- unsigned char got_audio;
+ unsigned char got_video_header;
+ unsigned char got_audio_header;
unsigned int length; /* in ms */
int width;
int height;
- double framerate;
+ int duration;
+ int videocodec;
+
+ int samplerate;
+ int samplesize;
+ int stereo;
+ int audiocodec;
+
+ off_t filesize;
flv_index_entry_t *index;
int num_indices;
@@ -180,13 +186,10 @@ static int open_flv_file(demux_flv_t *this) {
return 0;
}
- this->start = BE_32(&buffer[5]);
+ this->start = _X_BE_32(&buffer[5]);
this->size = this->input->get_length(this->input);
- if (INPUT_IS_SEEKABLE(this->input))
- this->input->seek(this->input, this->start, SEEK_SET);
- else if (this->start > 9)
- this->input->seek(this->input, this->start-9, SEEK_CUR);
+ this->input->seek(this->input, this->start, SEEK_SET);
lprintf(" qualified FLV file, repositioned @ offset 0x%" PRIxMAX "\n",
(intmax_t)this->start);
@@ -196,7 +199,7 @@ static int open_flv_file(demux_flv_t *this) {
#define BE_F64(buf) ({\
union { uint64_t q; double d; } _tmp;\
- _tmp.q = BE_64(buf);\
+ _tmp.q = _X_BE_64(buf);\
_tmp.d;\
})\
@@ -230,10 +233,37 @@ static int parse_flv_var(demux_flv_t *this,
_x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, this->height);
}
else if (keylen == 9 && !strncmp(key, "framerate", 9)) {
- this->framerate = val;
+ if (val > 0) {
+ this->duration = 90000.0 / val;
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->duration);
+ }
}
else if (keylen == 13 && !strncmp(key, "videodatarate", 13)) {
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_BITRATE, val*1000.0);
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_BITRATE, val*1000.0);
+ }
+ else if (keylen == 12 && !strncmp(key, "videocodecid", 12)) {
+ this->videocodec = val;
+ }
+ else if (keylen == 15 && !strncmp(key, "audiosamplerate", 15)) {
+ this->samplerate = val;
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, this->samplerate);
+ }
+ else if (keylen == 15 && !strncmp(key, "audiosamplesize", 15)) {
+ this->samplesize = val;
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS, this->samplesize);
+ }
+ else if (keylen == 5 && !strncmp(key, "stereo", 5)) {
+ this->stereo = val;
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, this->stereo ? 2 : 1);
+ }
+ else if (keylen == 13 && !strncmp(key, "audiodatarate", 13)) {
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, val*1000.0);
+ }
+ else if (keylen == 12 && !strncmp(key, "audiocodecid", 12)) {
+ this->audiocodec = val;
+ }
+ else if (keylen == 8 && !strncmp(key, "filesize", 8)) {
+ this->filesize = val;
}
}
tmp += 8;
@@ -244,11 +274,11 @@ static int parse_flv_var(demux_flv_t *this,
break;
case FLV_DATA_TYPE_STRING:
lprintf(" got string (%s)\n", tmp+2);
- len = BE_16(tmp);
+ len = _X_BE_16(tmp);
tmp += len + 2;
break;
case FLV_DATA_TYPE_OBJECT:
- while ((len = BE_16(tmp)) && tmp < end) {
+ while ((len = _X_BE_16(tmp)) && tmp < end) {
lprintf(" got object var (%s)\n", tmp+2);
str = tmp + 2;
tmp += len + 2;
@@ -259,12 +289,12 @@ static int parse_flv_var(demux_flv_t *this,
return 0;
break;
case FLV_DATA_TYPE_ECMARRAY:
- lprintf(" got EMCA array (%d indices)\n", BE_32(tmp));
- num = BE_32(tmp);
+ lprintf(" got EMCA array (%d indices)\n", _X_BE_32(tmp));
+ num = _X_BE_32(tmp);
tmp += 4;
while (num-- && tmp < end) {
lprintf(" got array key (%s)\n", tmp+2);
- len = BE_16(tmp);
+ len = _X_BE_16(tmp);
str = tmp + 2;
tmp += len + 2;
len = parse_flv_var(this, tmp, end-tmp, str, len);
@@ -272,13 +302,12 @@ static int parse_flv_var(demux_flv_t *this,
}
break;
case FLV_DATA_TYPE_ARRAY:
- lprintf(" got array (%d indices)\n", BE_32(tmp));
- num = BE_32(tmp);
+ lprintf(" got array (%d indices)\n", _X_BE_32(tmp));
+ num = _X_BE_32(tmp);
tmp += 4;
if (key && keylen == 5 && !strncmp(key, "times", 5)) {
- if (this->index)
- free (this->index);
- this->index = xine_xmalloc(num*sizeof(flv_index_entry_t));
+ free (this->index);
+ this->index = xine_xcalloc(num, sizeof(flv_index_entry_t));
this->num_indices = num;
for (num = 0; num < this->num_indices && tmp < end; num++) {
if (*tmp++ == FLV_DATA_TYPE_NUMBER) {
@@ -307,7 +336,7 @@ static int parse_flv_var(demux_flv_t *this,
}
break;
case FLV_DATA_TYPE_DATE:
- lprintf(" got date (%"PRId64", %d)\n", BE_64(tmp), BE_16(tmp+8));
+ lprintf(" got date (%"PRId64", %d)\n", _X_BE_64(tmp), _X_BE_16(tmp+8));
tmp += 10;
break;
default:
@@ -340,7 +369,7 @@ static void parse_flv_script(demux_flv_t *this, int size) {
free(buf);
}
-static int read_flv_packet(demux_flv_t *this) {
+static int read_flv_packet(demux_flv_t *this, int preview) {
fifo_buffer_t *fifo = NULL;
buf_element_t *buf = NULL;
unsigned char buffer[12];
@@ -359,8 +388,8 @@ static int read_flv_packet(demux_flv_t *this) {
}
tag_type = buffer[0];
- remaining_bytes = BE_24(&buffer[1]);
- pts = BE_24(&buffer[4]) | (buffer[7] << 24);
+ remaining_bytes = _X_BE_24(&buffer[1]);
+ pts = _X_BE_24(&buffer[4]) | (buffer[7] << 24);
lprintf(" tag_type = 0x%02X, 0x%X bytes, pts %u\n",
tag_type, remaining_bytes, pts/90);
@@ -374,7 +403,8 @@ static int read_flv_packet(demux_flv_t *this) {
}
remaining_bytes--;
- switch (buffer[0] >> 4) {
+ this->audiocodec = buffer[0] >> 4; /* override */
+ switch (this->audiocodec) {
case FLV_SOUND_FORMAT_PCM_BE:
buf_type = BUF_AUDIO_LPCM_BE;
break;
@@ -394,20 +424,18 @@ static int read_flv_packet(demux_flv_t *this) {
}
fifo = this->audio_fifo;
- if (!this->got_audio) {
+ if (preview && !this->got_audio_header) {
/* send init info to audio decoder */
buf = fifo->buffer_pool_alloc(fifo);
- buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END;
+ buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER | BUF_FLAG_FRAME_END;
buf->decoder_info[0] = 0;
buf->decoder_info[1] = 44100 >> (3 - ((buffer[0] >> 2) & 3)); /* samplerate */
buf->decoder_info[2] = (buffer[0] & 2) ? 16 : 8; /* bits per sample */
buf->decoder_info[3] = (buffer[0] & 1) + 1; /* channels */
buf->size = 0; /* no extra data */
buf->type = buf_type;
-
fifo->put(fifo, buf);
-
- this->got_audio = 1;
+ this->got_audio_header = 1;
}
break;
@@ -422,7 +450,8 @@ static int read_flv_packet(demux_flv_t *this) {
if ((buffer[0] >> 4) == 0x01)
buf_flags = BUF_FLAG_KEYFRAME;
- switch (buffer[0] & 0x0F) {
+ this->videocodec = buffer[0] & 0x0F; /* override */
+ switch (this->videocodec) {
case FLV_VIDEO_FORMAT_FLV1:
buf_type = BUF_VIDEO_FLV1;
break;
@@ -444,15 +473,15 @@ static int read_flv_packet(demux_flv_t *this) {
break;
}
- fifo = this->video_fifo;
- if (!this->got_video) {
+ fifo = this->video_fifo;
+ if (preview && !this->got_video_header) {
xine_bmiheader *bih;
/* send init info to video decoder; send the bitmapinfo header to the decoder
* primarily as a formality since there is no real data inside */
buf = fifo->buffer_pool_alloc(fifo);
buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER |
BUF_FLAG_FRAMERATE | BUF_FLAG_FRAME_END;
- buf->decoder_info[0] = this->framerate ? (90000.0/this->framerate) : 0;
+ buf->decoder_info[0] = this->duration;
bih = (xine_bmiheader *) buf->content;
memset(bih, 0, sizeof(xine_bmiheader));
bih->biSize = sizeof(xine_bmiheader);
@@ -465,16 +494,82 @@ static int read_flv_packet(demux_flv_t *this) {
bih->biSize++;
buf->size++;
}
-
fifo->put(fifo, buf);
-
- this->got_video = 1;
+ this->got_video_header = 1;
}
break;
case FLV_TAG_TYPE_SCRIPT:
lprintf(" got script tag...\n");
parse_flv_script(this, remaining_bytes);
+
+ if (preview) {
+ /* send init info to decoders using script information as reference */
+ if (!this->got_audio_header && this->audiocodec) {
+ buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo);
+ buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER | BUF_FLAG_FRAME_END;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = this->samplerate;
+ buf->decoder_info[2] = this->samplesize;
+ buf->decoder_info[3] = this->stereo ? 2 : 1;
+ switch (this->audiocodec) {
+ case FLV_SOUND_FORMAT_PCM_BE:
+ buf->type = BUF_AUDIO_LPCM_BE;
+ break;
+ case FLV_SOUND_FORMAT_ADPCM:
+ buf->type = BUF_AUDIO_FLVADPCM;
+ break;
+ case FLV_SOUND_FORMAT_MP3:
+ buf->type = BUF_AUDIO_MPEG;
+ break;
+ case FLV_SOUND_FORMAT_PCM_LE:
+ buf->type = BUF_AUDIO_LPCM_LE;
+ break;
+ default:
+ buf->type = BUF_AUDIO_UNKNOWN;
+ break;
+ }
+ buf->size = 0;
+ this->audio_fifo->put(this->audio_fifo, buf);
+ this->got_audio_header = 1;
+ }
+
+ if (!this->got_video_header && this->videocodec) {
+ xine_bmiheader *bih;
+ 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->duration;
+ switch (this->videocodec) {
+ case FLV_VIDEO_FORMAT_FLV1:
+ buf->type = BUF_VIDEO_FLV1;
+ break;
+ case FLV_VIDEO_FORMAT_VP6:
+ case FLV_VIDEO_FORMAT_VP6A:
+ buf->type = BUF_VIDEO_VP6F;
+ break;
+ default:
+ buf->type = BUF_VIDEO_UNKNOWN;
+ break;
+ }
+ buf->size = sizeof(xine_bmiheader);
+ bih = (xine_bmiheader *) buf->content;
+ memset(bih, 0, sizeof(xine_bmiheader));
+ bih->biSize = sizeof(xine_bmiheader);
+ bih->biWidth = this->width;
+ bih->biHeight = this->height;
+ if (buf->type == BUF_VIDEO_VP6F) {
+ *((uint8_t *)buf->content+buf->size) = ((16-(this->width&15)) << 4) |
+ ((16-(this->height&15)) & 0xf);
+ bih->biSize++;
+ buf->size++;
+ }
+ this->video_fifo->put(this->video_fifo, buf);
+ this->got_video_header = 1;
+ }
+
+ return this->status;
+ }
continue;
default:
@@ -487,7 +582,9 @@ static int read_flv_packet(demux_flv_t *this) {
buf = fifo->buffer_pool_alloc(fifo);
buf->type = buf_type;
buf->pts = (int64_t) pts * 90;
- check_newpts(this, buf->pts, (tag_type == FLV_TAG_TYPE_VIDEO));
+
+ if (!preview)
+ check_newpts(this, buf->pts, (tag_type == FLV_TAG_TYPE_VIDEO));
buf->extra_info->input_time = pts;
if (this->input->get_length(this->input)) {
@@ -502,6 +599,8 @@ static int read_flv_packet(demux_flv_t *this) {
remaining_bytes -= buf->size;
buf->decoder_flags = buf_flags;
+ if (preview)
+ buf->decoder_flags |= BUF_FLAG_PREVIEW;
if (!remaining_bytes)
buf->decoder_flags |= BUF_FLAG_FRAME_END;
@@ -521,12 +620,13 @@ static int read_flv_packet(demux_flv_t *this) {
return this->status;
}
-static void seek_flv_file(demux_flv_t *this, int seek_pts) {
+static void seek_flv_file(demux_flv_t *this, off_t seek_pos, int seek_pts) {
unsigned char buffer[16];
unsigned int pts = this->cur_pts;
int len = 0;
int next_tag = 0;
int do_rewind = (seek_pts < this->cur_pts);
+ int i;
lprintf(" seeking %s to %d...\n",
do_rewind ? "backward" : "forward", seek_pts);
@@ -538,8 +638,6 @@ static void seek_flv_file(demux_flv_t *this, int seek_pts) {
}
if (this->index) {
- int i;
-
if (do_rewind) {
for (i = this->num_indices-1; i > 0; i--) {
if (this->index[i-1].pts < seek_pts)
@@ -563,6 +661,43 @@ static void seek_flv_file(demux_flv_t *this, int seek_pts) {
}
}
+ if (seek_pos && this->videocodec) {
+ off_t pos, size;
+
+ pos = this->input->get_current_pos(this->input);
+ size = this->filesize ? : this->input->get_length(this->input);
+ this->input->seek(this->input, (uint64_t)size * seek_pos / 65535, SEEK_SET);
+ lprintf(" resyncing...\n");
+
+ /* resync */
+ for (i = 0; i < 200000; i++) {
+ uint8_t buf[4];
+
+ if (this->input->read(this->input, buf, 1) < 1) {
+ this->status = DEMUX_FINISHED;
+ return;
+ }
+ if (buf[0] == FLV_TAG_TYPE_VIDEO) {
+ this->input->seek(this->input, 7, SEEK_CUR);
+ if (this->input->read(this->input, buf, 4) < 4) {
+ this->status = DEMUX_FINISHED;
+ return;
+ }
+ /* check StreamID and CodecID */
+ if ( _X_ME_32(buf) == ME_FOURCC(0, 0, 0, (this->videocodec | 0x10)) ) {
+ this->input->seek(this->input, -16, SEEK_CUR);
+ lprintf(" ...resynced after %d bytes\n", i);
+ return;
+ }
+ this->input->seek(this->input, -11, SEEK_CUR);
+ }
+ }
+
+ lprintf(" ...resync failed!\n");
+ this->input->seek(this->input, pos, SEEK_SET);
+ return;
+ }
+
while (do_rewind ? (seek_pts < this->cur_pts) : (seek_pts > this->cur_pts)) {
unsigned char tag_type;
int data_size;
@@ -577,10 +712,10 @@ static void seek_flv_file(demux_flv_t *this, int seek_pts) {
break;
}
- ptag_size = BE_32(&buffer[0]);
+ ptag_size = _X_BE_32(&buffer[0]);
tag_type = buffer[4];
- data_size = BE_24(&buffer[5]);
- pts = BE_24(&buffer[8]) | (buffer[11] << 24);
+ data_size = _X_BE_24(&buffer[5]);
+ pts = _X_BE_24(&buffer[8]) | (buffer[11] << 24);
if (do_rewind) {
if (!ptag_size) break; /* beginning of movie */
@@ -609,7 +744,7 @@ static void seek_flv_file(demux_flv_t *this, int seek_pts) {
static int demux_flv_send_chunk(demux_plugin_t *this_gen) {
demux_flv_t *this = (demux_flv_t *) this_gen;
- return read_flv_packet(this);
+ return read_flv_packet(this, 0);
}
static void demux_flv_send_headers(demux_plugin_t *this_gen) {
@@ -620,6 +755,8 @@ static void demux_flv_send_headers(demux_plugin_t *this_gen) {
this->audio_fifo = this->stream->audio_fifo;
this->status = DEMUX_OK;
+
+ this->buf_flag_seek = 1;
/* load stream information */
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO,
@@ -632,10 +769,10 @@ static void demux_flv_send_headers(demux_plugin_t *this_gen) {
/* find first audio/video packets and send headers */
for (i = 0; i < 20; i++) {
- if (read_flv_packet(this) != DEMUX_OK)
+ if (read_flv_packet(this, 1) != DEMUX_OK)
break;
- if (((this->flags & FLV_FLAG_HAS_VIDEO) && this->got_video) &&
- ((this->flags & FLV_FLAG_HAS_AUDIO) && this->got_audio)) {
+ if (((this->flags & FLV_FLAG_HAS_VIDEO) && this->got_video_header) &&
+ ((this->flags & FLV_FLAG_HAS_AUDIO) && this->got_audio_header)) {
lprintf(" headers sent...\n");
break;
}
@@ -654,7 +791,7 @@ static int demux_flv_seek (demux_plugin_t *this_gen,
start_time = (int64_t) this->length * start_pos / 65535;
if (!this->length || start_time < this->length) {
- seek_flv_file(this, start_time);
+ seek_flv_file(this, start_pos, start_time);
if (playing) {
this->buf_flag_seek = 1;
@@ -669,8 +806,7 @@ static int demux_flv_seek (demux_plugin_t *this_gen,
static void demux_flv_dispose (demux_plugin_t *this_gen) {
demux_flv_t *this = (demux_flv_t *) this_gen;
- if (this->index)
- free(this->index);
+ free(this->index);
free(this);
}
@@ -717,13 +853,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->status = DEMUX_FINISHED;
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION:
- if (!_x_demux_check_extension(input->get_mrl(input), "flv")) {
- free (this);
- return NULL;
- }
-
- /* falling through is intended */
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
if (!open_flv_file(this)) {
@@ -740,39 +870,19 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Flash Video file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "FLV";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "flv";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "video/x-flv: flv: Flash video;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_flv_class_t *this = (demux_flv_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_flv_class_t *this;
this = xine_xmalloc (sizeof (demux_flv_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Flash Video file demux plugin");
+ this->demux_class.identifier = "FLV";
+ this->demux_class.mimetypes = "video/x-flv: flv: Flash video;"
+ "video/flv: flv: Flash video;"
+ "application/x-flash-video: flv: Flash video;";
+ this->demux_class.extensions = "flv";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -786,6 +896,7 @@ static const demuxer_info_t demux_info_flv = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "flashvideo", XINE_VERSION_CODE, &demux_info_flv, init_plugin },
+ { PLUGIN_DEMUX, 27, "flashvideo", XINE_VERSION_CODE, &demux_info_flv, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
+
diff --git a/src/demuxers/demux_idcin.c b/src/demuxers/demux_idcin.c
index 461771425..695470415 100644
--- a/src/demuxers/demux_idcin.c
+++ b/src/demuxers/demux_idcin.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -64,8 +64,6 @@
* - scan through all 768 palette bytes
* - if any bytes exceed 63, do not shift the bytes at all before
* transmitting them to the video decoder
- *
- * $Id: demux_idcin.c,v 1.55 2007/02/20 00:34:55 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -85,10 +83,10 @@
* demuxer is dispatching to the engine */
/* #define LOG */
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -130,7 +128,7 @@ static int demux_idcin_send_chunk(demux_plugin_t *this_gen) {
unsigned char disk_palette[PALETTE_SIZE * 3];
palette_entry_t palette[PALETTE_SIZE];
int i;
- unsigned int remaining_sample_bytes;
+ int remaining_sample_bytes;
int scale_bits;
/* figure out what the next data is */
@@ -191,7 +189,7 @@ static int demux_idcin_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- remaining_sample_bytes = LE_32(&preamble[0]) - 4;
+ remaining_sample_bytes = _X_LE_32(&preamble[0]) - 4;
lprintf("dispatching %d video bytes\n", remaining_sample_bytes);
while (remaining_sample_bytes) {
@@ -293,28 +291,28 @@ static int open_idcin_file(demux_idcin_t *this) {
*/
/* check the width */
- bih->biWidth = LE_32(&header[0]);
+ bih->biWidth = _X_LE_32(&header[0]);
if ((bih->biWidth == 0) || (bih->biWidth > 1024))
return 0;
/* check the height */
- bih->biHeight = LE_32(&header[4]);
+ bih->biHeight = _X_LE_32(&header[4]);
if ((bih->biHeight == 0) || (bih->biHeight > 1024))
return 0;
/* check the audio sample rate */
- this->wave.nSamplesPerSec = LE_32(&header[8]);
+ this->wave.nSamplesPerSec = _X_LE_32(&header[8]);
if ((this->wave.nSamplesPerSec != 0) &&
((this->wave.nSamplesPerSec < 8000) || (this->wave.nSamplesPerSec > 48000)))
return 0;
/* check the audio bytes/sample */
- this->wave.wBitsPerSample = LE_32(&header[12]) * 8;
+ this->wave.wBitsPerSample = _X_LE_32(&header[12]) * 8;
if (this->wave.wBitsPerSample > 16)
return 0;
/* check the audio channels */
- this->wave.nChannels = LE_32(&header[16]);
+ this->wave.nChannels = _X_LE_32(&header[16]);
if (this->wave.nChannels > 2)
return 0;
@@ -359,7 +357,8 @@ static void demux_idcin_send_headers(demux_plugin_t *this_gen) {
demux_idcin_t *this = (demux_idcin_t *) this_gen;
buf_element_t *buf;
xine_bmiheader *bih = (xine_bmiheader *)this->bih;
- uint32_t i, size;
+ uint32_t i;
+ int size;
this->video_fifo = this->stream->video_fifo;
this->audio_fifo = this->stream->audio_fifo;
@@ -445,11 +444,6 @@ static int demux_idcin_seek (demux_plugin_t *this_gen, off_t start_pos, int star
return this->status;
}
-static void demux_idcin_dispose (demux_plugin_t *this) {
-
- free(this);
-}
-
static int demux_idcin_get_status (demux_plugin_t *this_gen) {
demux_idcin_t *this = (demux_idcin_t *) this_gen;
@@ -481,7 +475,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_idcin_send_headers;
this->demux_plugin.send_chunk = demux_idcin_send_chunk;
this->demux_plugin.seek = demux_idcin_seek;
- this->demux_plugin.dispose = demux_idcin_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_idcin_get_status;
this->demux_plugin.get_stream_length = demux_idcin_get_stream_length;
this->demux_plugin.get_capabilities = demux_idcin_get_capabilities;
@@ -492,19 +486,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -523,40 +505,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-
-static const char *get_description (demux_class_t *this_gen) {
- return "Id Quake II Cinematic file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "Id CIN";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "cin";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_idcin_class_t *this = (demux_idcin_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_idcin_init_plugin (xine_t *xine, void *data) {
demux_idcin_class_t *this;
this = xine_xmalloc (sizeof (demux_idcin_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Id Quake II Cinematic file demux plugin");
+ this->demux_class.identifier = "Id CIN";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "cin";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_iff.c b/src/demuxers/demux_iff.c
index cc4df0c85..665d29cd2 100644
--- a/src/demuxers/demux_iff.c
+++ b/src/demuxers/demux_iff.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -35,8 +35,6 @@
* - simple pictures work, nothing more (most work is done in bitmap-decoder)
* * ANIM (Animations)
* - Animation works fine, without seeking.
- *
- * $Id: demux_iff.c,v 1.19 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -49,10 +47,10 @@
#include <string.h>
#include <stdlib.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "iff.h"
@@ -148,7 +146,7 @@ typedef struct {
* different decoding deltas
*/
-static int8_t delta_decode_block(int8_t *source, int32_t n, int8_t *dest, int8_t x, int8_t *table) {
+static int8_t delta_decode_block(const int8_t *source, int32_t n, int8_t *dest, int8_t x, const int8_t *table) {
int32_t i;
int lim = n * 2;
@@ -163,7 +161,7 @@ static int8_t delta_decode_block(int8_t *source, int32_t n, int8_t *dest, int8_t
}
/* Decode a complete delta encoded array */
-static void delta_decode(int8_t *dest, int8_t *source, int32_t n, int8_t *table){
+static void delta_decode(int8_t *dest, const int8_t *source, int32_t n, const int8_t *table){
delta_decode_block(&source[2], n-2, dest, source[1], table);
}
@@ -187,8 +185,8 @@ static int read_iff_chunk(demux_iff_t *this) {
if (this->input->read(this->input, &signature[7], 1) != 1)
return 0;
}
- junk_size = BE_32(&signature[4]);
- switch( BE_32(&signature[0]) ) {
+ junk_size = _X_BE_32(&signature[4]);
+ switch( _X_BE_32(&signature[0]) ) {
case IFF_CMAP_CHUNK:
case IFF_BODY_CHUNK:
case IFF_DLTA_CHUNK:
@@ -206,19 +204,19 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
}
- switch( BE_32(&signature[0]) ) {
+ switch( _X_BE_32(&signature[0]) ) {
case IFF_FORM_CHUNK:
if (this->input->read(this->input, buffer, 4) != 4)
return 0;
- this->iff_sub_type = BE_32(&buffer[0]);
+ this->iff_sub_type = _X_BE_32(&buffer[0]);
break;
case IFF_VHDR_CHUNK:
if( this->vhdr == NULL )
this->vhdr = (Voice8Header *)xine_xmalloc(sizeof(Voice8Header));
- this->vhdr->oneShotHiSamples = BE_32(&buffer[0]);
- this->vhdr->repeatHiSamples = BE_32(&buffer[4]);
- this->vhdr->samplesPerHiCycle = BE_32(&buffer[8]);
- this->vhdr->samplesPerSec = BE_16(&buffer[12]);
+ this->vhdr->oneShotHiSamples = _X_BE_32(&buffer[0]);
+ this->vhdr->repeatHiSamples = _X_BE_32(&buffer[4]);
+ this->vhdr->samplesPerHiCycle = _X_BE_32(&buffer[8]);
+ this->vhdr->samplesPerSec = _X_BE_16(&buffer[12]);
this->vhdr->ctOctave = buffer[14];
this->vhdr->sCompression = buffer[15];
this->audio_channels = 1;
@@ -237,7 +235,7 @@ static int read_iff_chunk(demux_iff_t *this) {
return 0;
break;
}
- this->vhdr->volume = BE_32(&buffer[16]);
+ this->vhdr->volume = _X_BE_32(&buffer[16]);
if (this->vhdr->volume > max_volume)
this->vhdr->volume = max_volume;
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->oneShotHiSamples %d\n",
@@ -300,7 +298,7 @@ static int read_iff_chunk(demux_iff_t *this) {
/* not yet implemented */
break;
case IFF_CHAN_CHUNK:
- this->chan_settings = BE_32(&buffer[0]);
+ this->chan_settings = _X_BE_32(&buffer[0]);
switch( this->chan_settings ) {
case STEREO:
this->audio_volume_left = this->vhdr->volume;
@@ -325,7 +323,7 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_PAN_CHUNK:
this->chan_settings = PAN;
- this->pan_sposition = BE_32(&buffer[0]);
+ this->pan_sposition = _X_BE_32(&buffer[0]);
this->audio_channels = 2;
this->audio_volume_left = this->vhdr->volume / (max_volume / this->pan_sposition);
this->audio_volume_right = this->vhdr->volume - this->audio_volume_left;
@@ -333,19 +331,19 @@ static int read_iff_chunk(demux_iff_t *this) {
case IFF_BMHD_CHUNK:
if( this->bmhd == NULL )
this->bmhd = (BitMapHeader *)xine_xmalloc(sizeof(BitMapHeader));
- this->bmhd->w = BE_16(&buffer[0]);
- this->bmhd->h = BE_16(&buffer[2]);
- this->bmhd->x = BE_16(&buffer[4]);
- this->bmhd->y = BE_16(&buffer[6]);
+ this->bmhd->w = _X_BE_16(&buffer[0]);
+ this->bmhd->h = _X_BE_16(&buffer[2]);
+ this->bmhd->x = _X_BE_16(&buffer[4]);
+ this->bmhd->y = _X_BE_16(&buffer[6]);
this->bmhd->nplanes = buffer[8];
this->bmhd->masking = buffer[9];
this->bmhd->compression = buffer[10];
this->bmhd->pad1 = buffer[11];
- this->bmhd->transparentColor = BE_16(&buffer[12]);
+ this->bmhd->transparentColor = _X_BE_16(&buffer[12]);
this->bmhd->xaspect = buffer[14];
this->bmhd->yaspect = buffer[15];
- this->bmhd->pagewidth = BE_16(&buffer[16]);
- this->bmhd->pageheight = BE_16(&buffer[18]);
+ this->bmhd->pagewidth = _X_BE_16(&buffer[16]);
+ this->bmhd->pageheight = _X_BE_16(&buffer[18]);
if (this->bmhd->w > 0)
this->bih.biWidth = this->bmhd->w;
@@ -409,25 +407,25 @@ static int read_iff_chunk(demux_iff_t *this) {
case IFF_GRAB_CHUNK:
if( this->grab == NULL )
this->grab = (Point2D *)xine_xmalloc(sizeof(Point2D));
- this->grab->x = BE_16(&buffer[0]);
- this->grab->y = BE_16(&buffer[2]);
+ this->grab->x = _X_BE_16(&buffer[0]);
+ this->grab->y = _X_BE_16(&buffer[2]);
break;
case IFF_DEST_CHUNK:
if( this->dest == NULL )
this->dest = (DestMerge *)xine_xmalloc(sizeof(DestMerge));
this->dest->depth = buffer[0];
this->dest->pad1 = buffer[1];
- this->dest->plane_pick = BE_16(&buffer[2]);
- this->dest->plane_onoff = BE_16(&buffer[4]);
- this->dest->plane_mask = BE_16(&buffer[6]);
+ this->dest->plane_pick = _X_BE_16(&buffer[2]);
+ this->dest->plane_onoff = _X_BE_16(&buffer[4]);
+ this->dest->plane_mask = _X_BE_16(&buffer[6]);
break;
case IFF_SPRT_CHUNK:
- this->sprt = BE_16(&buffer[0]);
+ this->sprt = _X_BE_16(&buffer[0]);
break;
case IFF_CAMG_CHUNK:
if( this->camg == NULL )
this->camg = (CamgChunk *)xine_xmalloc(sizeof(CamgChunk));
- this->camg->view_modes = BE_32(&buffer[0]);
+ this->camg->view_modes = _X_BE_32(&buffer[0]);
this->bih.biCompression = this->camg->view_modes;
if( this->camg->view_modes & CAMG_PAL &&
this->video_pts_inc == 4500 )
@@ -435,9 +433,9 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_CRNG_CHUNK:
if (this->crng_used < 256) {
- this->crng[this->crng_used].pad1 = BE_16(&buffer[0]);
- this->crng[this->crng_used].rate = BE_16(&buffer[2]);
- this->crng[this->crng_used].active = BE_16(&buffer[4]);
+ this->crng[this->crng_used].pad1 = _X_BE_16(&buffer[0]);
+ this->crng[this->crng_used].rate = _X_BE_16(&buffer[2]);
+ this->crng[this->crng_used].active = _X_BE_16(&buffer[4]);
this->crng[this->crng_used].low = buffer[6];
this->crng[this->crng_used].high = buffer[7];
this->crng_used++;
@@ -446,33 +444,33 @@ static int read_iff_chunk(demux_iff_t *this) {
case IFF_CCRT_CHUNK:
if( this->ccrt == NULL )
this->ccrt = (CcrtChunk *)xine_xmalloc(sizeof(CcrtChunk));
- this->ccrt->direction = BE_16(&buffer[0]);
+ this->ccrt->direction = _X_BE_16(&buffer[0]);
this->ccrt->start = buffer[2];
this->ccrt->end = buffer[3];
- this->ccrt->seconds = BE_32(&buffer[4]);
- this->ccrt->microseconds = BE_32(&buffer[8]);
- this->ccrt->pad = BE_16(&buffer[12]);
+ this->ccrt->seconds = _X_BE_32(&buffer[4]);
+ this->ccrt->microseconds = _X_BE_32(&buffer[8]);
+ this->ccrt->pad = _X_BE_16(&buffer[12]);
break;
case IFF_DPI_CHUNK:
if( this->dpi == NULL )
this->dpi = (DPIHeader *)xine_xmalloc(sizeof(DPIHeader));
- this->dpi->x = BE_16(&buffer[0]);
- this->dpi->y = BE_16(&buffer[0]);
+ this->dpi->x = _X_BE_16(&buffer[0]);
+ this->dpi->y = _X_BE_16(&buffer[0]);
break;
case IFF_ANHD_CHUNK:
if( this->anhd == NULL )
this->anhd = (AnimHeader *)xine_xmalloc(sizeof(AnimHeader));
this->anhd->operation = buffer[0];
this->anhd->mask = buffer[1];
- this->anhd->w = BE_16(&buffer[2]);
- this->anhd->h = BE_16(&buffer[4]);
- this->anhd->x = BE_16(&buffer[6]);
- this->anhd->y = BE_16(&buffer[8]);
- this->anhd->abs_time = BE_32(&buffer[10]);
- this->anhd->rel_time = BE_32(&buffer[14]);
+ this->anhd->w = _X_BE_16(&buffer[2]);
+ this->anhd->h = _X_BE_16(&buffer[4]);
+ this->anhd->x = _X_BE_16(&buffer[6]);
+ this->anhd->y = _X_BE_16(&buffer[8]);
+ this->anhd->abs_time = _X_BE_32(&buffer[10]);
+ this->anhd->rel_time = _X_BE_32(&buffer[14]);
this->anhd->interleave = buffer[18];
this->anhd->pad0 = buffer[19];
- this->anhd->bits = BE_32(&buffer[20]);
+ this->anhd->bits = _X_BE_32(&buffer[20]);
/* Using rel_time deaktivated, seems to be broken in most animations */
/*if( this->dpan == NULL )
this->video_pts += this->video_pts_inc *
@@ -503,8 +501,8 @@ static int read_iff_chunk(demux_iff_t *this) {
case IFF_DPAN_CHUNK:
if( this->dpan == NULL )
this->dpan = (DPAnimChunk *)xine_xmalloc(sizeof(DPAnimChunk));
- this->dpan->version = BE_16(&buffer[0]);
- this->dpan->nframes = BE_16(&buffer[2]);
+ this->dpan->version = _X_BE_16(&buffer[0]);
+ this->dpan->nframes = _X_BE_16(&buffer[2]);
this->dpan->fps = buffer[4];
this->dpan->unused1 = buffer[5];
this->dpan->unused2 = buffer[6];
@@ -626,7 +624,7 @@ static int open_iff_file(demux_iff_t *this) {
this->anhd = NULL;
this->dpan = NULL;
- this->iff_type = BE_32(&signature[8]);
+ this->iff_type = _X_BE_32(&signature[8]);
this->iff_sub_type = this->iff_type;
this->video_type = 0;
@@ -647,7 +645,7 @@ static int open_iff_file(demux_iff_t *this) {
this->bih.biClrImportant = 0;
/* check the signature */
- if (BE_32(&signature[0]) == IFF_FORM_CHUNK)
+ if (_X_BE_32(&signature[0]) == IFF_FORM_CHUNK)
{
switch( this->iff_type )
{
@@ -827,13 +825,13 @@ static int demux_iff_send_chunk(demux_plugin_t *this_gen) {
}
} else {
for (j = 0, k = (interleave_index / 2); j < (buf->size / 2); j += this->audio_channels) {
- zw_16 = BE_16(&pointer16_from[k]);
+ zw_16 = _X_BE_16(&pointer16_from[k]);
k++;
zw_rescale = zw_16;
zw_rescale *= this->audio_volume_left;
zw_rescale /= max_volume;
zw_16 = (zw_rescale>32767) ? 32767 : ((zw_rescale<-32768) ? -32768 : zw_rescale);
- pointer16_to[j] = BE_16(&zw_16);
+ pointer16_to[j] = _X_BE_16(&zw_16);
}
}
} else {
@@ -857,13 +855,13 @@ static int demux_iff_send_chunk(demux_plugin_t *this_gen) {
}
} else {
for (j = 1; j < (buf->size / 2); j += this->audio_channels) {
- zw_16 = BE_16(&pointer16_from[k]);
+ zw_16 = _X_BE_16(&pointer16_from[k]);
k++;
zw_rescale = zw_16;
zw_rescale *= this->audio_volume_left;
zw_rescale /= max_volume;
zw_16 = (zw_rescale>32767) ? 32767 : ((zw_rescale<-32768) ? -32768 : zw_rescale);
- pointer16_to[j] = BE_16(&zw_16);
+ pointer16_to[j] = _X_BE_16(&zw_16);
}
}
} else if (this->chan_settings == LEFT) {
@@ -1118,92 +1116,29 @@ static int demux_iff_seek (demux_plugin_t *this_gen,
static void demux_iff_dispose (demux_plugin_t *this_gen) {
demux_iff_t *this = (demux_iff_t *) this_gen;
- if( this->bmhd ) {
- free(this->bmhd);
- this->bmhd = NULL;
- }
- if( this->cmap ) {
- free( this->cmap );
- this->cmap = NULL;
- }
- if( this->grab ) {
- free(this->grab);
- this->grab = NULL;
- }
- if( this->dest ) {
- free(this->dest);
- this->dest = NULL;
- }
- if( this->camg ) {
- free(this->camg);
- this->camg = NULL;
- }
- if( this->ccrt ) {
- free(this->ccrt);
- this->ccrt = NULL;
- }
- if( this->dpi ) {
- free(this->dpi);
- this->dpi = NULL;
- }
-
- if( this->vhdr ) {
- free(this->vhdr);
- this->vhdr = NULL;
- }
- if( this->atak )
- {
- free( this->atak );
- this->atak = NULL;
- }
- if( this->rlse ) {
- free( this->rlse );
- this->rlse = NULL;
- }
-
- if( this->anhd ) {
- free( this->anhd );
- this->anhd = NULL;
- }
-
- if( this->dpan ) {
- free( this->dpan );
- this->dpan = NULL;
- }
-
- if( this->title ) {
- free (this->title);
- this->title = NULL;
- }
- if( this->copyright ) {
- free (this->copyright);
- this->copyright = NULL;
- }
- if( this->author ) {
- free (this->author);
- this->author = NULL;
- }
- if( this->annotations ) {
- free (this->annotations);
- this->annotations = NULL;
- }
- if( this->version ) {
- free (this->version);
- this->version = NULL;
- }
- if( this->text ) {
- free (this->text);
- this->text = NULL;
- }
+ free(this->bmhd);
+ free(this->cmap);
+ free(this->grab);
+ free(this->dest);
+ free(this->camg);
+ free(this->ccrt);
+ free(this->dpi);
+ free(this->vhdr);
+ free(this->atak);
+ free(this->rlse);
+ free(this->anhd);
+ free(this->dpan);
+
+ free(this->title);
+ free(this->copyright);
+ free(this->author);
+ free(this->annotations);
+ free(this->version);
+ free(this->text);
+
+ free (this->audio_interleave_buffer);
+ free (this->audio_read_buffer);
- if( this->audio_interleave_buffer ) {
- free (this->audio_interleave_buffer);
- this->audio_interleave_buffer = NULL;
- }
- if( this->audio_read_buffer ) {
- free (this->audio_read_buffer);
- this->audio_read_buffer = NULL;
- }
this->audio_buffer_filled = 0;
free(this);
@@ -1254,19 +1189,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -1285,46 +1208,25 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "IFF demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "IFF";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "iff svx 8svx 16sv ilbm ham ham6 ham8 anim anim3 anim5 anim7 anim8";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "audio/x-8svx: 8svx: IFF-8SVX Audio;"
- "audio/8svx: 8svx: IFF-8SVX Audio;"
- "audio/x-16sv: 16sv: IFF-16SV Audio;"
- "audio/168sv: 16sv: IFF-16SV Audio;"
- "image/x-ilbm: ilbm: IFF-ILBM Picture;"
- "image/ilbm: ilbm: IFF-ILBM Picture;"
- "video/x-anim: anim: IFF-ANIM Video;"
- "video/anim: anim: IFF-ANIM Video;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_iff_class_t *this = (demux_iff_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_iff_class_t *this;
this = xine_xmalloc (sizeof (demux_iff_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("IFF demux plugin");
+ this->demux_class.identifier = "IFF";
+ this->demux_class.mimetypes =
+ "audio/x-8svx: 8svx: IFF-8SVX Audio;"
+ "audio/8svx: 8svx: IFF-8SVX Audio;"
+ "audio/x-16sv: 16sv: IFF-16SV Audio;"
+ "audio/168sv: 16sv: IFF-16SV Audio;"
+ "image/x-ilbm: ilbm: IFF-ILBM Picture;"
+ "image/ilbm: ilbm: IFF-ILBM Picture;"
+ "video/x-anim: anim: IFF-ANIM Video;"
+ "video/anim: anim: IFF-ANIM Video;";
+ this->demux_class.extensions = "iff svx 8svx 16sv ilbm ham ham6 ham8 anim anim3 anim5 anim7 anim8";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -1338,7 +1240,7 @@ static const demuxer_info_t demux_info_iff = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "iff", XINE_VERSION_CODE, &demux_info_iff, init_plugin },
+ { PLUGIN_DEMUX, 27, "iff", XINE_VERSION_CODE, &demux_info_iff, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_image.c b/src/demuxers/demux_image.c
index d799c2324..cb6f8c8fe 100644
--- a/src/demuxers/demux_image.c
+++ b/src/demuxers/demux_image.c
@@ -15,12 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_image.c,v 1.26 2007/01/19 00:26:40 dgp85 Exp $
- *
* image dummy demultiplexer
*/
@@ -40,10 +38,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
-#include "demux.h"
+#include <xine/demux.h>
#define IMAGE_HEADER_LEN 4
@@ -145,13 +143,6 @@ static int demux_image_get_optional_data(demux_plugin_t *this_gen,
return DEMUX_OPTIONAL_UNSUPPORTED;
}
-static void demux_image_dispose (demux_plugin_t *this_gen) {
- demux_image_t *this = (demux_image_t *) this_gen;
-
- lprintf("closed\n");
- free (this);
-}
-
static demux_plugin_t *open_plugin (demux_class_t *class_gen,
xine_stream_t *stream,
input_plugin_t *input) {
@@ -168,7 +159,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
}
if (memcmp (header, "GIF", 3) == 0 /* GIF */
|| memcmp (header, "\377\330\377", 3) == 0 /* JPEG */
- || (BE_16(&header[0]) == 0xffd8) /* another JPEG */
+ || (_X_BE_16(&header[0]) == 0xffd8) /* another JPEG */
|| memcmp (header, "\x89PNG", 4) == 0) { /* PNG */
break;
}
@@ -176,18 +167,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
}
break;
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- return NULL;
- }
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -207,7 +187,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
this->demux_plugin.send_headers = demux_image_send_headers;
this->demux_plugin.send_chunk = demux_image_send_chunk;
this->demux_plugin.seek = demux_image_seek;
- this->demux_plugin.dispose = demux_image_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_image_get_status;
this->demux_plugin.get_stream_length = demux_image_get_stream_length;
this->demux_plugin.get_capabilities = demux_image_get_capabilities;
@@ -224,41 +204,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
/*
* image demuxer class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "image demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "imagedmx";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "png gif jpg jpeg";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_image_class_t *this = (demux_image_class_t *) this_gen;
-
- lprintf("class closed\n");
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_image_class_t *this;
this = xine_xmalloc (sizeof (demux_image_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("image demux plugin");
+ this->demux_class.identifier = "imagedmx";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "png gif jpg jpeg";
+ this->demux_class.dispose = default_demux_class_dispose;
lprintf("class opened\n");
return this;
@@ -273,6 +229,6 @@ static const demuxer_info_t demux_info_image = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "image", XINE_VERSION_CODE, &demux_info_image, init_class },
+ { PLUGIN_DEMUX, 27, "image", XINE_VERSION_CODE, &demux_info_image, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_ipmovie.c b/src/demuxers/demux_ipmovie.c
index 6fe185b1a..4d08af6fa 100644
--- a/src/demuxers/demux_ipmovie.c
+++ b/src/demuxers/demux_ipmovie.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* Interplay MVE File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information regarding the Interplay MVE file format, visit:
* http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: demux_ipmovie.c,v 1.27 2007/02/20 00:34:55 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,10 +40,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -144,8 +142,8 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) {
if (this->input->read(this->input, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return CHUNK_BAD;
- chunk_size = LE_16(&chunk_preamble[0]);
- chunk_type = LE_16(&chunk_preamble[2]);
+ chunk_size = _X_LE_16(&chunk_preamble[0]);
+ chunk_type = _X_LE_16(&chunk_preamble[2]);
lprintf("chunk type 0x%04X, 0x%04X bytes:\n", chunk_type, chunk_size);
@@ -191,7 +189,7 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) {
break;
}
- opcode_size = LE_16(&opcode_preamble[0]);
+ opcode_size = _X_LE_16(&opcode_preamble[0]);
opcode_type = opcode_preamble[2];
opcode_version = opcode_preamble[3];
@@ -228,10 +226,10 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) {
chunk_type = CHUNK_BAD;
break;
}
- this->fps = 1000000.0 / (LE_32(&scratch[0]) * LE_16(&scratch[4]));
+ this->fps = 1000000.0 / (_X_LE_32(&scratch[0]) * _X_LE_16(&scratch[4]));
this->frame_pts_inc = (int)(90000.0 / this->fps);
lprintf("%.1f frames/second (timer div = %d, subdiv = %d)\n",
- this->fps, LE_32(&scratch[0]), LE_16(&scratch[4]));
+ this->fps, _X_LE_32(&scratch[0]), _X_LE_16(&scratch[4]));
break;
case OPCODE_INIT_AUDIO_BUFFERS:
@@ -246,8 +244,8 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) {
chunk_type = CHUNK_BAD;
break;
}
- this->wave.nSamplesPerSec = LE_16(&scratch[4]);
- audio_flags = LE_16(&scratch[2]);
+ this->wave.nSamplesPerSec = _X_LE_16(&scratch[4]);
+ audio_flags = _X_LE_16(&scratch[2]);
/* bit 0 of the flags: 0 = mono, 1 = stereo */
this->wave.nChannels = (audio_flags & 1) + 1;
/* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
@@ -282,8 +280,8 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) {
chunk_type = CHUNK_BAD;
break;
}
- this->bih.biWidth = LE_16(&scratch[0]) * 8;
- this->bih.biHeight = LE_16(&scratch[2]) * 8;
+ this->bih.biWidth = _X_LE_16(&scratch[0]) * 8;
+ this->bih.biHeight = _X_LE_16(&scratch[2]) * 8;
/* set up staging area for decode map */
this->decode_map_size = (this->bih.biWidth * this->bih.biHeight) /
(8 * 8) / 2;
@@ -392,8 +390,8 @@ static int process_ipmovie_chunk(demux_ipmovie_t *this) {
}
/* load the palette into internal data structure */
- first_color = LE_16(&scratch[0]);
- color_count = LE_16(&scratch[2]);
+ first_color = _X_LE_16(&scratch[0]);
+ color_count = _X_LE_16(&scratch[2]);
/* sanity check (since they are 16 bit values) */
if ((first_color > 0xFF) || (first_color + color_count > 0x100)) {
lprintf("set_palette indices out of range (%d -> %d)\n",
@@ -533,7 +531,7 @@ static int open_ipmovie_file(demux_ipmovie_t *this) {
IPMOVIE_SIGNATURE_SIZE)
return 0;
- if (strncmp(signature, IPMOVIE_SIGNATURE, IPMOVIE_SIGNATURE_SIZE) != 0)
+ if (memcmp(signature, IPMOVIE_SIGNATURE, IPMOVIE_SIGNATURE_SIZE) != 0)
return 0;
/* file is qualified; skip over the signature bytes (+ 6 unknown) in the stream */
@@ -692,19 +690,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -723,39 +709,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Interplay MVE Movie demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "Interplay MVE";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mve mv8";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_ipmovie_class_t *this = (demux_ipmovie_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_ipmovie_init_plugin (xine_t *xine, void *data) {
demux_ipmovie_class_t *this;
this = xine_xmalloc (sizeof (demux_ipmovie_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Interplay MVE Movie demux plugin");
+ this->demux_class.identifier = "Interplay MVE";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "mve mv8";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c
index 2bd8f3540..4a99492ef 100644
--- a/src/demuxers/demux_matroska.c
+++ b/src/demuxers/demux_matroska.c
@@ -15,9 +15,7 @@
*
* 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
- *
- * $Id: demux_matroska.c,v 1.53 2007/03/12 16:27:21 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* demultiplexer for matroska streams
*
@@ -25,7 +23,6 @@
* more decoders init
* metadata
* non seekable input plugins support
- *
*/
#ifdef HAVE_CONFIG_H
@@ -45,10 +42,10 @@
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "ebml.h"
@@ -68,13 +65,6 @@
#define MAX(a, b) ((a)>(b)?(a):(b))
#endif
-/* FOURCC will be manipulated using machine endian */
-#ifdef WORDS_BIGENDIAN
-#define meFOURCC BE_FOURCC
-#else
-#define meFOURCC LE_FOURCC
-#endif
-
typedef struct {
int track_num;
off_t *pos;
@@ -617,8 +607,7 @@ static void init_codec_real(demux_matroska_t *this, matroska_track_t * track) {
track->fifo->put (track->fifo, buf);
}
-
-static void init_codec_vorbis(demux_matroska_t *this, matroska_track_t *track) {
+static void init_codec_xiph(demux_matroska_t *this, matroska_track_t *track) {
buf_element_t *buf;
uint8_t nb_lace;
int frame[3];
@@ -790,7 +779,7 @@ static int vobsub_parse_custom_colors(matroska_track_t *t, const char *start) {
use_custom_colors = 1;
else if (!strncasecmp(start, "OFF", 3) || (*start == '0'))
use_custom_colors = 0;
- lprintf("VobSub custom colors: %s\n", use_custom_colors ? "ON" : "OFF");
+ lprintf("VobSub custom colours: %s\n", use_custom_colors ? "ON" : "OFF");
if ((start = strstr(start, "colors:")) != NULL) {
start += 7;
while (isspace(*start))
@@ -804,7 +793,7 @@ static int vobsub_parse_custom_colors(matroska_track_t *t, const char *start) {
}
if (i == 4) {
t->sub_track->custom_colors = 4;
- lprintf("VobSub colors: %06x,%06x,%06x,%06x\n", t->sub_track->colors[0],
+ lprintf("VobSub colours: %06x,%06x,%06x,%06x\n", t->sub_track->colors[0],
t->sub_track->colors[1], t->sub_track->colors[2],
t->sub_track->colors[3]);
}
@@ -864,7 +853,7 @@ static void init_codec_vobsub(demux_matroska_t *this,
things_found |= vobsub_parse_size(track, start);
else if (!strncasecmp(start, "palette:", 8))
things_found |= vobsub_parse_palette(track, start);
- else if (!strncasecmp(start, "custom colors:", 14))
+ else if (!strncasecmp(start, "custom colours:", 14))
things_found |= vobsub_parse_custom_colors(track, start);
else if (!strncasecmp(start, "forced subs:", 12))
things_found |= vobsub_parse_forced_subs(track, start);
@@ -1192,18 +1181,22 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
case MATROSKA_ID_TR_CODECID: {
char *codec_id = malloc (elem.len + 1);
lprintf("CodecID\n");
- if (!ebml_read_ascii(ebml, &elem, codec_id))
+ if (!ebml_read_ascii(ebml, &elem, codec_id)) {
+ free(codec_id);
return 0;
+ }
codec_id[elem.len] = '\0';
track->codec_id = codec_id;
}
break;
case MATROSKA_ID_TR_CODECPRIVATE: {
- char *codec_private = malloc (elem.len);
+ uint8_t *codec_private = malloc (elem.len);
lprintf("CodecPrivate\n");
- if (!ebml_read_binary(ebml, &elem, codec_private))
+ if (!ebml_read_binary(ebml, &elem, codec_private)) {
+ free(codec_private);
return 0;
+ }
track->codec_private = codec_private;
track->codec_private_len = elem.len;
}
@@ -1212,8 +1205,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
case MATROSKA_ID_TR_LANGUAGE: {
char *language = malloc (elem.len + 1);
lprintf("Language\n");
- if (!ebml_read_ascii(ebml, &elem, language))
+ if (!ebml_read_ascii(ebml, &elem, language)) {
+ free(language);
return 0;
+ }
language[elem.len] = '\0';
track->language = language;
}
@@ -1320,7 +1315,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
/* create a bitmap info header struct for MPEG 4 */
bih = malloc(sizeof(xine_bmiheader) + track->codec_private_len);
bih->biSize = sizeof(xine_bmiheader) + track->codec_private_len;
- bih->biCompression = meFOURCC('M', 'P', '4', 'S');
+ bih->biCompression = ME_FOURCC('M', 'P', '4', 'S');
bih->biWidth = track->video_track->pixel_width;
bih->biHeight = track->video_track->pixel_height;
_x_bmiheader_le2me(bih);
@@ -1341,7 +1336,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
/* create a bitmap info header struct for h264 */
bih = malloc(sizeof(xine_bmiheader) + track->codec_private_len);
bih->biSize = sizeof(xine_bmiheader) + track->codec_private_len;
- bih->biCompression = meFOURCC('a', 'v', 'c', '1');
+ bih->biCompression = ME_FOURCC('a', 'v', 'c', '1');
bih->biWidth = track->video_track->pixel_width;
bih->biHeight = track->video_track->pixel_height;
_x_bmiheader_le2me(bih);
@@ -1380,6 +1375,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
init_codec = init_codec_real;
} else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_MJPEG)) {
+ } else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_THEORA)) {
+ lprintf("MATROSKA_CODEC_ID_V_THEORA\n");
+ track->buf_type = BUF_VIDEO_THEORA_RAW;
+ init_codec = init_codec_xiph;
} else if ((!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L1)) ||
(!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L2)) ||
(!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L3))) {
@@ -1404,7 +1403,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
lprintf("MATROSKA_CODEC_ID_A_VORBIS\n");
track->buf_type = BUF_AUDIO_VORBIS;
- init_codec = init_codec_vorbis;
+ init_codec = init_codec_xiph;
} else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_ACM)) {
xine_waveformatex *wfh;
@@ -1661,10 +1660,10 @@ static int parse_cue_point(demux_matroska_t *this) {
this->num_indexes++;
}
if ((index->num_entries % 1024) == 0) {
- index->pos = (off_t *)realloc(index->pos, sizeof(off_t) *
- (index->num_entries + 1024));
- index->timecode = (off_t *)realloc(index->timecode, sizeof(uint64_t) *
- (index->num_entries + 1024));
+ index->pos = realloc(index->pos, sizeof(off_t) *
+ (index->num_entries + 1024));
+ index->timecode = realloc(index->timecode, sizeof(uint64_t) *
+ (index->num_entries + 1024));
}
index->pos[index->num_entries] = pos;
index->timecode[index->num_entries] = timecode;
@@ -1750,10 +1749,7 @@ static int parse_tags(demux_matroska_t *this) {
static void alloc_block_data (demux_matroska_t *this, int len) {
/* memory management */
if (this->block_data_size < len) {
- if (this->block_data)
- this->block_data = realloc(this->block_data, len);
- else
- this->block_data = malloc(len);
+ this->block_data = realloc(this->block_data, len);
this->block_data_size = len;
}
}
@@ -1846,11 +1842,11 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size,
int decoder_flags = 0;
data = this->block_data;
- if (!(num_len = parse_ebml_uint(this, data, &track_num)))
+ if (!(num_len = parse_ebml_sint(this, data, &track_num)))
return 0;
data += num_len;
- timecode_diff = (int)BE_16(data);
+ timecode_diff = (int)_X_BE_16(data);
data += 2;
flags = *data;
@@ -1860,6 +1856,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size,
gap = flags & 1;
lacing = (flags >> 1) & 0x3;
+/*fprintf(stderr, "lacing: %x\n", lacing);*/
if (!find_track_by_id(this, (int)track_num, &track)) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
@@ -1977,7 +1974,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size,
lprintf("ebml lacing\n");
/* size of each frame */
- if (!(num_len = parse_ebml_uint(this, data, &tmp)))
+ if (!(num_len = parse_ebml_sint(this, data, &tmp)))
return 0;
data += num_len; block_size_left -= num_len;
frame[0] = (int) tmp;
@@ -2678,37 +2675,26 @@ static void demux_matroska_dispose (demux_plugin_t *this_gen) {
/* free tracks */
for (i = 0; i < this->num_tracks; i++) {
- matroska_track_t *track;
-
- track = this->tracks[i];
- if (track->language)
- free (track->language);
- if (track->codec_id)
- free (track->codec_id);
- if (track->codec_private)
- free (track->codec_private);
- if (track->video_track)
- free (track->video_track);
- if (track->audio_track)
- free (track->audio_track);
- if (track->sub_track)
- free (track->sub_track);
+ matroska_track_t *const track = this->tracks[i];
+
+ free (track->language);
+ free (track->codec_id);
+ free (track->codec_private);
+ free (track->video_track);
+ free (track->audio_track);
+ free (track->sub_track);
free (track);
}
/* Free the cues. */
for (i = 0; i < this->num_indexes; i++) {
- if (this->indexes[i].pos)
- free(this->indexes[i].pos);
- if (this->indexes[i].timecode)
- free(this->indexes[i].timecode);
+ free(this->indexes[i].pos);
+ free(this->indexes[i].timecode);
}
- if (this->indexes)
- free(this->indexes);
+ free(this->indexes);
/* Free the top_level elem list */
- if (this->top_level_list)
- free(this->top_level_list);
+ free(this->top_level_list);
dispose_ebml_parser(this->ebml);
free (this);
@@ -2805,18 +2791,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl(input);
- const char *const extensions = class_gen->get_extensions (class_gen);;
-
- lprintf ("stage by extension %s\n", mrl);
-
- if (!_x_demux_check_extension (mrl, extensions))
- return NULL;
-
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -2867,34 +2842,6 @@ error:
/*
* demux matroska class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "matroska demux plugin";
-}
-
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "matroska";
-}
-
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mkv";
-}
-
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "video/mkv: mkv: matroska;";
-}
-
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_matroska_class_t *this = (demux_matroska_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_matroska_class_t *this;
@@ -2903,11 +2850,11 @@ static void *init_class (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("matroska demux plugin");
+ this->demux_class.identifier = "matroska";
+ this->demux_class.mimetypes = "video/mkv: mkv: matroska;";
+ this->demux_class.extensions = "mkv";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -2921,6 +2868,6 @@ static const demuxer_info_t demux_info_matroska = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "matroska", XINE_VERSION_CODE, &demux_info_matroska, init_class },
+ { PLUGIN_DEMUX, 27, "matroska", XINE_VERSION_CODE, &demux_info_matroska, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_mng.c b/src/demuxers/demux_mng.c
index e2ab1e4ea..18c4b1b57 100644
--- a/src/demuxers/demux_mng.c
+++ b/src/demuxers/demux_mng.c
@@ -15,12 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_mng.c,v 1.29 2007/01/19 00:26:40 dgp85 Exp $
- *
* demux_mng.c, Demuxer plugin for Multiple-image Network Graphics format
*
* written and currently maintained by Robin Kay <komadori@myrealbox.com>
@@ -48,9 +46,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
typedef struct {
demux_plugin_t demux_plugin;
@@ -287,17 +285,7 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
}
break;
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl(input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
+ case METHOD_BY_MRL:
break;
default:
@@ -336,40 +324,21 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
return &this->demux_plugin;
}
-static const char *get_description(demux_class_t *this_gen){
- return "Multiple-image Network Graphics demux plugin";
-}
-
-static const char *get_identifier(demux_class_t *this_gen){
- return "MNG";
-}
-
-static const char *get_extensions(demux_class_t *this_gen){
- return "png mng";
-}
-
-static const char *get_mimetypes(demux_class_t *this_gen){
- return "image/png: png: PNG image;"
- "image/x-png: png: PNG image;"
- "video/mng: mng: MNG animation;"
- "video/x-mng: mng: MNG animation;";
-}
-
-static void class_dispose(demux_class_t *this){
- free (this);
-}
-
static void *init_plugin(xine_t *xine, void *data){
demux_mng_class_t *this;
this = xine_xmalloc (sizeof (demux_mng_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Multiple-image Network Graphics demux plugin");
+ this->demux_class.identifier = "MNG";
+ this->demux_class.mimetypes =
+ "image/png: png: PNG image;"
+ "image/x-png: png: PNG image;"
+ "video/mng: mng: MNG animation;"
+ "video/x-mng: mng: MNG animation;";
+ this->demux_class.extensions = "png mng";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -379,6 +348,6 @@ static const demuxer_info_t demux_info_mng = {
};
const plugin_info_t xine_plugin_info[] EXPORTED = {
- { PLUGIN_DEMUX, 26, "mng", XINE_VERSION_CODE, &demux_info_mng, (void*)init_plugin},
+ { PLUGIN_DEMUX, 27, "mng", XINE_VERSION_CODE, &demux_info_mng, (void*)init_plugin},
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_mod.c b/src/demuxers/demux_mod.c
index 37e066b13..17e744b94 100644
--- a/src/demuxers/demux_mod.c
+++ b/src/demuxers/demux_mod.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -31,8 +31,6 @@
#include "config.h"
#endif
-#ifdef HAVE_MODPLUG
-
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
@@ -44,11 +42,10 @@
/* #define LOG_VERBOSE */
/* #define LOG */
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
-#include "group_audio.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "modplug.h"
#include "bswap.h"
@@ -109,7 +106,7 @@ static int probe_mod_file(demux_mod_t *this) {
return 0;
/* Magic numbers taken from GNU file's magic description */
- switch( ABE_32(header.values + (1080/sizeof(uint32_t))) ) {
+ switch( _X_ABE_32(header.values + (1080/sizeof(uint32_t))) ) {
case FOURCC_32('M', '.', 'K', '.'): /* 4-channel Protracker module sound data */
case FOURCC_32('M', '!', 'K', '!'): /* 4-channel Protracker module sound data */
case FOURCC_32('F', 'L', 'T', '4'): /* 4-channel Startracker module sound data */
@@ -326,21 +323,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
case METHOD_EXPLICIT:
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- if (!open_mod_file(this)) {
- free (this);
- return NULL;
- }
- }
+ case METHOD_BY_MRL:
break;
case METHOD_BY_CONTENT:
@@ -355,41 +338,26 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "ModPlug Amiga MOD Music file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "mod";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mod it stm s3m 669 amf med mdl xm";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_mod_class_t *this = (demux_mod_class_t *) this_gen;
-
- free (this);
-}
-
-void *demux_mod_init_plugin (xine_t *xine, void *data) {
+static void *demux_mod_init_plugin (xine_t *xine, void *data) {
demux_mod_class_t *this;
this = xine_xmalloc (sizeof (demux_mod_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("ModPlug Amiga MOD Music file demux plugin");
+ this->demux_class.identifier = "mod";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "mod it stm s3m 669 amf med mdl xm";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
-#endif /* HAVE_MODPLUG */
+static const demuxer_info_t demux_info_mod = {
+ 10 /* priority */
+};
+
+const plugin_info_t xine_plugin_info[] EXPORTED = {
+ { PLUGIN_DEMUX, 27, "modplug", XINE_VERSION_CODE, &demux_info_mod, demux_mod_init_plugin },
+ { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+};
diff --git a/src/demuxers/demux_mpc.c b/src/demuxers/demux_mpc.c
index e1a3f28b9..6a4cfb285 100644
--- a/src/demuxers/demux_mpc.c
+++ b/src/demuxers/demux_mpc.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Musepack demuxer by James Stembridge <jstembridge@gmail.com>
*
@@ -23,8 +23,6 @@
* ID3 tag reading
* APE tag reading
* Seeking??
- *
- * $Id: demux_mpc.c,v 1.5 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -43,10 +41,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -128,11 +126,11 @@ static int open_mpc_file(demux_mpc_t *this) {
/* Get frame count */
this->current_frame = 0;
- this->frames = LE_32(&this->header[4]);
+ this->frames = _X_LE_32(&this->header[4]);
lprintf("number of frames: %u\n", this->frames);
/* Get sample rate */
- switch ((LE_32(&this->header[8]) >> 16) & 0x3) {
+ switch ((_X_LE_32(&this->header[8]) >> 16) & 0x3) {
case 0:
this->samplerate = 44.1;
break;
@@ -155,7 +153,7 @@ static int open_mpc_file(demux_mpc_t *this) {
lprintf("stream length: %d ms\n", this->length);
/* Calculate the number of bits of the first frame that are still be sent */
- first_frame_size = (LE_32(&this->header[24]) >> 4) & 0xFFFFF;
+ first_frame_size = (_X_LE_32(&this->header[24]) >> 4) & 0xFFFFF;
this->next_frame_bits = first_frame_size - 4;
lprintf("first frame size: %u\n", first_frame_size);
@@ -164,7 +162,7 @@ static int open_mpc_file(demux_mpc_t *this) {
/* Set stream info */
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, ME_32(this->header));
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, _X_ME_32(this->header));
return 1;
}
@@ -229,10 +227,10 @@ static int demux_mpc_send_chunk(demux_plugin_t *this_gen) {
extra_bits_read = bits_to_read - (this->next_frame_bits+20);
if(extra_bits_read <= 12)
- next_frame_size = (LE_32(&buf->content[bytes_to_read-4]) >> extra_bits_read) & 0xFFFFF;
+ next_frame_size = (_X_LE_32(&buf->content[bytes_to_read-4]) >> extra_bits_read) & 0xFFFFF;
else
- next_frame_size = ((LE_32(&buf->content[bytes_to_read-8]) << (32-extra_bits_read)) |
- (LE_32(&buf->content[bytes_to_read-4]) >> extra_bits_read)) & 0xFFFFF;
+ next_frame_size = ((_X_LE_32(&buf->content[bytes_to_read-8]) << (32-extra_bits_read)) |
+ (_X_LE_32(&buf->content[bytes_to_read-4]) >> extra_bits_read)) & 0xFFFFF;
lprintf("next frame size: %u\n", next_frame_size);
@@ -294,12 +292,6 @@ static int demux_mpc_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_mpc_dispose (demux_plugin_t *this_gen) {
- demux_mpc_t *this = (demux_mpc_t *) this_gen;
-
- free(this);
-}
-
static int demux_mpc_get_status (demux_plugin_t *this_gen) {
demux_mpc_t *this = (demux_mpc_t *) this_gen;
@@ -333,7 +325,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_mpc_send_headers;
this->demux_plugin.send_chunk = demux_mpc_send_chunk;
this->demux_plugin.seek = demux_mpc_seek;
- this->demux_plugin.dispose = demux_mpc_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_mpc_get_status;
this->demux_plugin.get_stream_length = demux_mpc_get_stream_length;
this->demux_plugin.get_capabilities = demux_mpc_get_capabilities;
@@ -343,19 +335,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->status = DEMUX_FINISHED;
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* Falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -374,39 +354,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Musepack demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "Musepack";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mpc mp+";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_mpc_class_t *this = (demux_mpc_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_mpc_init_plugin (xine_t *xine, void *data) {
demux_mpc_class_t *this;
this = xine_xmalloc (sizeof (demux_mpc_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Musepack demux plugin");
+ this->demux_class.identifier = "Musepack";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "mpc mp+";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index c9d49efa2..8c339fd88 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -15,12 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_mpeg.c,v 1.152 2007/02/20 00:34:55 dgp85 Exp $
- *
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
*/
@@ -41,9 +39,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "demux.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/demux.h>
+#include <xine/xineutils.h>
#define NUM_PREVIEW_BUFFERS 150
#define SCRATCH_SIZE 256
@@ -140,8 +138,8 @@ static void find_mdat_atom(input_plugin_t *input, off_t *mdat_offset,
ATOM_PREAMBLE_SIZE)
break;
- atom_size = BE_32(&atom_preamble[0]);
- atom = BE_32(&atom_preamble[4]);
+ atom_size = _X_BE_32(&atom_preamble[0]);
+ atom = _X_BE_32(&atom_preamble[4]);
if (atom == MDAT_ATOM) {
*mdat_offset = input->get_current_pos(input) - ATOM_PREAMBLE_SIZE;
@@ -165,9 +163,9 @@ static void find_mdat_atom(input_plugin_t *input, off_t *mdat_offset,
ATOM_PREAMBLE_SIZE)
break;
- atom_size = BE_32(&atom_preamble[0]);
+ atom_size = _X_BE_32(&atom_preamble[0]);
atom_size <<= 32;
- atom_size |= BE_32(&atom_preamble[4]);
+ atom_size |= _X_BE_32(&atom_preamble[4]);
atom_size -= ATOM_PREAMBLE_SIZE * 2;
} else
atom_size -= ATOM_PREAMBLE_SIZE;
@@ -1040,11 +1038,6 @@ static int demux_mpeg_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_mpeg_dispose (demux_plugin_t *this_gen) {
-
- free (this_gen);
-}
-
static int demux_mpeg_get_stream_length (demux_plugin_t *this_gen) {
demux_mpeg_t *this = (demux_mpeg_t *) this_gen;
@@ -1076,7 +1069,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_mpeg_send_headers;
this->demux_plugin.send_chunk = demux_mpeg_send_chunk;
this->demux_plugin.seek = demux_mpeg_seek;
- this->demux_plugin.dispose = demux_mpeg_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_mpeg_get_status;
this->demux_plugin.get_stream_length = demux_mpeg_get_stream_length;
this->demux_plugin.get_capabilities = demux_mpeg_get_capabilities;
@@ -1157,7 +1150,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
/* special case for MPEG streams with a RIFF header */
- fourcc_tag = BE_32(&buf[0]);
+ fourcc_tag = _X_BE_32(&buf[0]);
if (fourcc_tag == RIFF_TAG) {
uint8_t large_buf[1024];
@@ -1165,7 +1158,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
free(this);
return NULL;
}
- fourcc_tag = BE_32(&large_buf[8]);
+ fourcc_tag = _X_BE_32(&large_buf[8]);
/* disregard the RIFF file if it is certainly a better known
* format like AVI or WAVE */
if ((fourcc_tag == WAVE_TAG) ||
@@ -1185,7 +1178,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
if (input->read(input, large_buf, 1024) != 1024)
break;
for (j = 0; j < 1024 - 4; j++) {
- if (BE_32(&large_buf[j]) == MPEG_MARKER) {
+ if (_X_BE_32(&large_buf[j]) == MPEG_MARKER) {
ok = 1;
break;
}
@@ -1198,19 +1191,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -1222,40 +1203,19 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "MPEG program stream demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MPEG";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mpg mpeg";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "video/mpeg: mpeg, mpg, mpe: MPEG animation;"
- "video/x-mpeg: mpeg, mpg, mpe: MPEG animation;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_mpeg_class_t *this = (demux_mpeg_class_t *) this_gen;
-
- free (this);
- }
-
static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_class_t *this;
this = xine_xmalloc (sizeof (demux_mpeg_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("MPEG program stream demux plugin");
+ this->demux_class.identifier = "MPEG";
+ this->demux_class.mimetypes =
+ "video/mpeg: mpeg, mpg, mpe: MPEG animation;"
+ "video/x-mpeg: mpeg, mpg, mpe: MPEG animation;";
+ this->demux_class.extensions = "mpg mpeg";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -1269,6 +1229,6 @@ static const demuxer_info_t demux_info_mpeg = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "mpeg", XINE_VERSION_CODE, &demux_info_mpeg, init_plugin },
+ { PLUGIN_DEMUX, 27, "mpeg", XINE_VERSION_CODE, &demux_info_mpeg, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index 7083d33d9..b46008b94 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -15,13 +15,10 @@
*
* 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
- *
- * $Id: demux_mpeg_block.c,v 1.220 2007/02/20 00:34:55 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* demultiplexer for mpeg 1/2 program streams
* used with fixed blocksize devices (like dvd/vcd)
- *
*/
#ifdef HAVE_CONFIG_H
@@ -40,9 +37,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
#define NUM_PREVIEW_BUFFERS 250
#define DISC_TRESHOLD 90000
@@ -1455,39 +1452,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- char *ending;
-
- const char *const mrl = input->get_mrl (input);
-
- if(!strncmp(mrl, "vcd:", 4)) {
- this->blocksize = 2324;
- demux_mpeg_block_accept_input (this, input);
- } else if(!strncmp(mrl, "dvd:", 4) || !strncmp(mrl, "pvr:", 4)) {
- this->blocksize = 2048;
- demux_mpeg_block_accept_input (this, input);
- } else {
- ending = strrchr(mrl, '.');
-
- if (!ending) {
- free (this->scratch_base);
- free (this);
- return NULL;
- }
- if ( (!strncasecmp (ending, ".vob", 4)) ||
- (!strncmp((ending + 3), "mpeg2", 5)) ||
- (!strncmp((ending + 3), "mpeg1", 5)) ) {
- this->blocksize = 2048;
- demux_mpeg_block_accept_input(this, input);
- } else {
- free (this->scratch_base);
- free (this);
- return NULL;
- }
- }
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT: {
this->blocksize = input->get_blocksize(input);
@@ -1516,29 +1481,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "DVD/VOB demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MPEG_BLOCK";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "vob";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_mpeg_block_class_t *this = (demux_mpeg_block_class_t *) this_gen;
-
- free (this);
- }
-
static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_block_class_t *this;
@@ -1548,11 +1490,11 @@ static void *init_plugin (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("DVD/VOB demux plugin");
+ this->demux_class.identifier = "MPEG_BLOCK";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "vob vcd:/ dvd:/ pvr:/";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -1566,6 +1508,6 @@ static const demuxer_info_t demux_info_mpeg_block = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "mpeg_block", XINE_VERSION_CODE, &demux_info_mpeg_block, init_plugin },
+ { PLUGIN_DEMUX, 27, "mpeg_block", XINE_VERSION_CODE, &demux_info_mpeg_block, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c
index c5769e3e3..f5d554020 100644
--- a/src/demuxers/demux_mpeg_pes.c
+++ b/src/demuxers/demux_mpeg_pes.c
@@ -15,9 +15,7 @@
*
* 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
- *
- * $Id: demux_mpeg_pes.c,v 1.43 2007/03/29 17:11:36 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* demultiplexer for mpeg 2 PES (Packetized Elementary Streams)
* reads streams of variable blocksizes
@@ -25,7 +23,6 @@
* 1-7-2003 New implementation of mpeg 2 PES demuxers.
* (c) 2003 James Courtier-Dutton James@superbug.demon.co.uk
* This code might also decode normal MPG files.
- *
*/
#ifdef HAVE_CONFIG_H
@@ -44,9 +41,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
#define NUM_PREVIEW_BUFFERS 250
#define DISC_TRESHOLD 90000
@@ -136,13 +133,79 @@ static int32_t parse_IEC14496_FlexMux_stream(demux_mpeg_pes_t *this, uint8_t *p,
static int32_t parse_program_stream_directory(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf);
static int32_t parse_program_stream_pack_header(demux_mpeg_pes_t *this, uint8_t *p, buf_element_t *buf);
-static void check_newpts( demux_mpeg_pes_t *this, int64_t pts, int video )
+static int detect_pts_discontinuity( demux_mpeg_pes_t *this, int64_t pts, int video )
{
int64_t diff;
-
+
+ /* discontinuity detection is difficult to implement in the demuxer as it gets
+ * for example video packets in decoding order and there can be multiple audio
+ * and video tracks. So for simplicity, let's just deal with a single audio and
+ * a single video track.
+ *
+ * To start with, let's have a look at the audio and video track independently.
+ * Whenever pts differs from last_pts[video] by at least WRAP_THRESHOLD, a jump
+ * in pts is detected. Such a jump can happen for example when the pts counter
+ * overflows, as shown below (video decoding order ignored for simplicity; the
+ * variable values are shown after returning from the below function check_newpts;
+ * an asterisk means that this value has been cleared (see check_newpts)):
+ *
+ * pts: 7v 7a 8v 9v 9a : 0v 1v 1a 2v 3v 3a 4v
+ * last_pts[0]: 6 7 7 7 9 : * * 1 1 1 3 3
+ * last_pts[1]: 7 7 8 9 9 : 0 1 1 2 3 3 4
+ * | | |
+ * | | +--- audio pts wrap ignored
+ * | +--------- video pts wrap detected
+ * +----------- pts wrap boundary
+ */
diff = pts - this->last_pts[video];
-
- if( pts && (this->send_newpts || (this->last_pts[video] && abs(diff)>WRAP_THRESHOLD) ) ) {
+
+ if (this->last_pts[video] && abs(diff)>WRAP_THRESHOLD)
+ return 1;
+
+ /* but the above code can cause a huge delay while replaying when audio and video
+ * track are not aligned on a common pts wrap boundery, as shown below:
+ *
+ * pts: 7v 8v 7a 9v : 0v 9a 1v 2v : 1a 3v 4v 3a
+ * last_pts[0]: 6 6 7 7 : * 9 9 9 : 1 1 1 3
+ * last_pts[1]: 7 8 8 9 : 0 0 1 2 : * 3 4 4
+ * | | | | |
+ * | | | | +--- audio pts wrap detected
+ * | | | +----- audio pts wrap boundary
+ * | | +-------------- audio packet causes a huge delay
+ * | +----------------- video pts wrap detected
+ * +------------------- video pts wrap boundery
+ *
+ * So there is the need to compare audio track pts against video track pts
+ * to detect when pts values are in between pts wrap bounderies, where a
+ * jump needs to be detected too, as shown below:
+ *
+ * pts: 7v 8v 7a 9v : 0v 9a 1v 2v : 1a 3v 4v 3a
+ * last_pts[0]: 6 6 7 7 : * 9 * * : 1 1 1 3
+ * last_pts[1]: 7 8 8 9 : 0 * 1 2 : 2 3 4 4
+ * | | | | | |
+ * | | | | | +--- (audio pts wrap ignored)
+ * | | | | +----- audio pts wrap boundary
+ * | | | +----------- video pts wrap detected
+ * | | +-------------- audio pts wrap detected
+ * | +----------------- video pts wrap detected
+ * +------------------- (video pts wrap boundery)
+ *
+ * Basically, it's almost the same test like above, but against the other track's
+ * pts value and with a different limit. As the pts counter is a 33 bit unsigned
+ * integer, we choose 2^31 as limit (2^32 would require the tracks to be aligned).
+ */
+ diff = pts - this->last_pts[1-video];
+
+ if (this->last_pts[1-video] && abs(diff)>(1u<<31))
+ return 1;
+
+ /* no discontinuity detected */
+ return 0;
+}
+
+static void check_newpts( demux_mpeg_pes_t *this, int64_t pts, int video )
+{
+ if( pts && (this->send_newpts || detect_pts_discontinuity(this, pts, video) ) ) {
/* check if pts is outside nav pts range. any stream without nav must enter here. */
if( pts > this->nav_last_end_pts || pts < this->nav_last_start_pts )
@@ -159,47 +222,13 @@ static void check_newpts( demux_mpeg_pes_t *this, int64_t pts, int video )
} else {
lprintf("no wrap detected\n" );
}
-
+
+ /* clear pts on the other track to avoid detecting the same discontinuity again */
this->last_pts[1-video] = 0;
}
if( pts )
- {
- /* don't detect a discontinuity only for video respectively audio. It's also a discontinuity
- indication when audio and video pts differ to much e. g. when a pts wrap happens.
- The original code worked well when the wrap happend like this:
-
- V7 A7 V8 V9 A9 Dv V0 V1 da A1 V2 V3 A3 V4
-
- Legend:
- Vn = video packet with timestamp n
- An = audio packet with timestamp n
- Dv = discontinuity detected on following video packet
- Da = discontinuity detected on following audio packet
- dv = discontinuity detected on following video packet but ignored
- da = discontinuity detected on following audio packet but ignored
-
- But with a certain delay between audio and video packets (e. g. the way DVB-S broadcasts
- the packets) the code didn't work:
-
- V7 V8 A7 V9 Dv V0 _A9_ V1 V2 Da _A1_ V3 V4 A3
-
- Packet A9 caused audio to jump forward and A1 caused it to jump backward with inserting
- a delay of almoust 26.5 hours!
-
- The new code gives the following sequences for the above examples:
-
- V7 A7 V8 V9 A9 Dv V0 V1 A1 V2 V3 A3 V4
-
- V7 V8 A7 V9 Dv V0 Da A9 Dv V1 V2 A1 V3 V4 A3
-
- After proving this code it should be cleaned up to use just a single variable "last_pts". */
-
-/*
this->last_pts[video] = pts;
-*/
- this->last_pts[video] = this->last_pts[1-video] = pts;
- }
}
static off_t read_data(demux_mpeg_pes_t *this, uint8_t *buf, off_t nlen)
@@ -1110,7 +1139,7 @@ static int32_t parse_video_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elemen
uint8_t *pp = p + 2, *pp_limit = p + payload_size - 1;
while (0 < pp && pp < pp_limit) {
if (pp[0] == 0x01 && pp[-1] == 0x00 && pp[-2] == 0x00) {
- if (pp[1] >= 0x80) { /* MPEG 1/2 start code */
+ if (pp[1] >= 0x80 || !pp[1]) { /* MPEG 1/2 start code */
this->mpeg12_h264_detected = 2;
break;
} else {
@@ -1135,17 +1164,20 @@ static int32_t parse_video_stream(demux_mpeg_pes_t *this, uint8_t *p, buf_elemen
*/
if (this->mpeg12_h264_detected & 1) {
buf_type = BUF_VIDEO_H264;
- int nal_type_code = -1;
- if (payload_size >= 4 && p[2] == 0x01 && p[1] == 0x00 && p[0] == 0x00)
- nal_type_code = p[3] & 0x1f;
- if (nal_type_code == 9) { /* access unit delimiter */
- buf_element_t *b = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- b->content = b->mem;
- b->size = 0;
- b->pts = 0;
- b->type = buf_type;
- b->decoder_flags = BUF_FLAG_FRAME_END;
- this->video_fifo->put (this->video_fifo, b);
+ /* omit sending BUF_FLAG_FRAME_END for the first AUD occurence */
+ if (this->mpeg12_h264_detected > 2) {
+ int nal_type_code = -1;
+ if (payload_size >= 4 && p[2] == 0x01 && p[1] == 0x00 && p[0] == 0x00)
+ nal_type_code = p[3] & 0x1f;
+ if (nal_type_code == 9) { /* access unit delimiter */
+ buf_element_t *b = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ b->content = b->mem;
+ b->size = 0;
+ b->pts = 0;
+ b->type = buf_type;
+ b->decoder_flags = BUF_FLAG_FRAME_END;
+ this->video_fifo->put (this->video_fifo, b);
+ }
}
}
@@ -1694,25 +1726,8 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl (input);
- const char *const ending = strrchr(mrl, '.');
-
- if (!ending) {
- free (this->scratch_base);
- free (this);
- return NULL;
- }
-
- if (strncasecmp(ending, ".MPEG", 5)
- && strncasecmp (ending, ".vdr", 4)
- && strncasecmp (ending, ".mpg", 4)) {
- free (this->scratch_base);
- free (this);
- return NULL;
- }
- }
- break;
+ case METHOD_BY_MRL:
+ break;
case METHOD_EXPLICIT: {
@@ -1728,29 +1743,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "mpeg pes demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MPEG_PES";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "pes";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_mpeg_pes_class_t *this = (demux_mpeg_pes_class_t *) this_gen;
-
- free (this);
- }
-
static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_pes_class_t *this;
@@ -1759,11 +1751,11 @@ static void *init_plugin (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("mpeg pes demux plugin");
+ this->demux_class.identifier = "MPEG_PES";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "pes vdr:/ netvdr:/";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -1777,6 +1769,6 @@ static const demuxer_info_t demux_info_mpeg_pes = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "mpeg_pes", XINE_VERSION_CODE, &demux_info_mpeg_pes, init_plugin },
+ { PLUGIN_DEMUX, 27, "mpeg_pes", XINE_VERSION_CODE, &demux_info_mpeg_pes, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index 31b2d33ff..cf410eed8 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -15,15 +15,12 @@
*
* 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
- *
- * $Id: demux_mpgaudio.c,v 1.156 2007/03/29 16:32:12 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* demultiplexer for mpeg audio (i.e. mp3) streams
*
* mp3 file structure:
* [id3v2][Xing|Vbri] Frame1 Frame2 Frame3...FrameX [Lyrics][id3v2][id3v1]
- *
*/
#ifdef HAVE_CONFIG_H
@@ -36,15 +33,15 @@
#include <string.h>
#include <stdlib.h>
-#define LOG_MODULE "demux_mpeg_audio"
+#define LOG_MODULE "demux_mpgaudio"
#define LOG_VERBOSE
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "compat.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/compat.h>
#include "bswap.h"
#include "group_audio.h"
#include "id3.h"
@@ -54,19 +51,20 @@
* the second mp3 frame is sent to the decoder
*/
#define NUM_PREVIEW_BUFFERS 2
+#define NUM_VALID_FRAMES 3
-#define WRAP_THRESHOLD 120000
#define FOURCC_TAG BE_FOURCC
#define RIFF_CHECK_BYTES 1024
#define RIFF_TAG FOURCC_TAG('R', 'I', 'F', 'F')
#define AVI_TAG FOURCC_TAG('A', 'V', 'I', ' ')
#define CDXA_TAG FOURCC_TAG('C', 'D', 'X', 'A')
-#define MPEG_MARKER FOURCC_TAG( 0x00, 0x00, 0x01, 0xBA )
+#define MPEG_MARKER ME_FOURCC( 0x00, 0x00, 0x01, 0xBA )
/* Xing header stuff */
#define XING_TAG FOURCC_TAG('X', 'i', 'n', 'g')
+#define INFO_TAG FOURCC_TAG('I', 'n', 'f', 'o')
#define XING_FRAMES_FLAG 0x0001
#define XING_BYTES_FLAG 0x0002
#define XING_TOC_FLAG 0x0004
@@ -79,16 +77,16 @@
/* mp3 frame struct */
typedef struct {
/* header */
- double duration;
- uint32_t size; /* in bytes */
+ double duration; /* in milliseconds */
+ uint32_t size; /* in bytes; including padding */
uint32_t bitrate; /* in bit per second */
uint16_t freq; /* in Hz */
-
uint8_t layer;
-
uint8_t version_idx:2; /* 0: mpeg1, 1: mpeg2, 2: mpeg2.5 */
uint8_t lsf_bit:1;
uint8_t channel_mode:3;
+ uint8_t padding:3; /* in bytes */
+ uint8_t is_free_bitrate:1;
} mpg_audio_frame_t;
/* Xing Vbr Header struct */
@@ -127,7 +125,13 @@ typedef struct {
int br; /* bitrate in bits/second */
uint32_t blocksize;
+ /* current mp3 frame */
mpg_audio_frame_t cur_frame;
+
+ /* next mp3 frame, used when the frame size cannot be computed from the
+ * current frame header */
+ mpg_audio_frame_t next_frame;
+
double cur_time; /* in milliseconds */
off_t mpg_frame_start; /* offset */
@@ -137,7 +141,15 @@ typedef struct {
int check_vbr_header;
xing_header_t *xing_header;
vbri_header_t *vbri_header;
-
+
+ int found_next_frame:1;
+ int free_bitrate_count;
+ off_t free_bitrate_size; /* use this size if 3 free bitrate frames are encountered */
+ uint8_t next_header[4];
+ int mpg_version;
+ int mpg_layer;
+ int valid_frames;
+
} demux_mpgaudio_t ;
/* demuxer class struct */
@@ -205,17 +217,17 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con
#endif
} frame_header;
- const uint32_t head = BE_32(buf);
+ const uint32_t head = _X_BE_32(buf);
const uint16_t frame_sync = head >> 21;
- lprintf("header: %08X\n", head);
if (frame_sync != 0x7ff) {
- lprintf("invalid frame sync\n");
+ lprintf("invalid frame sync %08X\n", head);
return 0;
}
+ lprintf("header: %08X\n", head);
frame_header.mpeg25_bit = (head >> 20) & 0x1;
- frame->lsf_bit = (head >> 19) & 0x1;
+ frame->lsf_bit = (head >> 19) & 0x1;
if (!frame_header.mpeg25_bit) {
if (frame->lsf_bit) {
lprintf("reserved mpeg25 lsf combination\n");
@@ -236,14 +248,14 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con
}
frame_header.bitrate_idx = (head >> 12) & 0xf;
- if ((frame_header.bitrate_idx == 0) || (frame_header.bitrate_idx == 15)) {
- lprintf("invalid bitrate index\n");
+ if (frame_header.bitrate_idx == 15) {
+ lprintf("invalid bitrate index: %d\n", frame_header.bitrate_idx);
return 0;
}
frame_header.freq_idx = (head >> 10) & 0x3;
if (frame_header.freq_idx == 3) {
- lprintf("invalid frequence index\n");
+ lprintf("invalid frequence index: %d\n", frame_header.freq_idx);
return 0;
}
@@ -276,19 +288,27 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con
const uint16_t samples = mp3_samples[frame->version_idx][frame->layer - 1];
frame->bitrate = mp3_bitrates[frame->version_idx][frame->layer - 1][frame_header.bitrate_idx] * 1000;
frame->freq = mp3_freqs[frame->version_idx][frame_header.freq_idx];
-
- frame->size = samples * (frame->bitrate / 8);
- frame->size /= frame->freq;
- /* Padding: only if padding_bit is set; 4 bytes for Layer 1 and 1 byte for others */
- frame->size += ( frame_header.padding_bit ? ( frame->layer == 1 ? 4 : 1 ) : 0 );
-
frame->duration = 1000.0f * (double)samples / (double)frame->freq;
+ frame->padding = ( frame_header.padding_bit ? ( frame->layer == 1 ? 4 : 1 ) : 0 );
+ frame->channel_mode = frame_header.channel_mode;
+
+ if (frame->bitrate > 0) {
+ frame->size = samples * (frame->bitrate / 8);
+ frame->size /= frame->freq;
+ /* Padding: only if padding_bit is set; 4 bytes for Layer 1 and 1 byte for others */
+ frame->size += frame->padding;
+ } else {
+ /* Free bitrate frame, the size of the frame cannot be computed from the header. */
+ frame->is_free_bitrate = 1;
+ frame->size = 0;
+ }
}
- lprintf("mpeg %d, layer %d\n", frame->version_idx + 1, frame->layer);
- lprintf("bitrate: %d bps, samplerate: %d Hz\n", frame->bitrate, frame->freq);
+ lprintf("mpeg %d, layer %d, channel_mode: %d\n", frame->version_idx + 1,
+ frame->layer, frame->channel_mode);
+ lprintf("bitrate: %d bps, output freq: %d Hz\n", frame->bitrate, frame->freq);
lprintf("length: %d bytes, %f ms\n", frame->size, frame->duration);
- lprintf("padding: %d bytes\n", ( frame_header.padding_bit ? ( frame->layer == 1 ? 4 : 1 ) : 0 ));
+ lprintf("padding: %d bytes\n", frame->padding);
return 1;
}
@@ -298,16 +318,8 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con
*/
static xing_header_t* parse_xing_header(mpg_audio_frame_t *frame,
uint8_t *buf, int bufsize) {
-
-#ifdef LOG
- int i;
-#endif
uint8_t *ptr = buf;
- xing_header_t *xing;
-
- xing = xine_xmalloc (sizeof (xing_header_t));
- if (!xing)
- return NULL;
+ xing_header_t *xing = NULL;
/* offset of the Xing header */
if (frame->lsf_bit) {
@@ -322,52 +334,87 @@ static xing_header_t* parse_xing_header(mpg_audio_frame_t *frame,
ptr += (9 + 4);
}
- if (ptr >= (buf + bufsize - 4)) return 0;
+ if (ptr >= (buf + bufsize - 4)) goto exit_error;
lprintf("checking %08X\n", *ptr);
- if (BE_32(ptr) == XING_TAG) {
- lprintf("Xing header found\n");
+
+ if (_X_BE_32(ptr) == XING_TAG) {
+ int has_frames_flag = 0;
+ int has_bytes_flag = 0;
+
+ xing = xine_xmalloc (sizeof (xing_header_t));
+ if (!xing)
+ goto exit_error;
+
+ lprintf("found Xing header\n");
ptr += 4;
- if (ptr >= (buf + bufsize - 4)) return 0;
- xing->flags = BE_32(ptr); ptr += 4;
+ if (ptr >= (buf + bufsize - 4)) goto exit_error;
+ xing->flags = _X_BE_32(ptr); ptr += 4;
if (xing->flags & XING_FRAMES_FLAG) {
- if (ptr >= (buf + bufsize - 4)) return 0;
- xing->stream_frames = BE_32(ptr); ptr += 4;
+ if (ptr >= (buf + bufsize - 4)) goto exit_error;
+ xing->stream_frames = _X_BE_32(ptr); ptr += 4;
lprintf("stream frames: %d\n", xing->stream_frames);
+ has_frames_flag = 1;
}
if (xing->flags & XING_BYTES_FLAG) {
- if (ptr >= (buf + bufsize - 4)) return 0;
- xing->stream_size = BE_32(ptr); ptr += 4;
+ if (ptr >= (buf + bufsize - 4)) goto exit_error;
+ xing->stream_size = _X_BE_32(ptr); ptr += 4;
lprintf("stream size: %d\n", xing->stream_size);
+ has_bytes_flag = 1;
}
+
+ /* check if it's a useful Xing header */
+ if (!has_frames_flag || !has_bytes_flag) {
+ lprintf("Stupid Xing tag, cannot do anything with it !\n");
+ goto exit_error;
+ }
+
if (xing->flags & XING_TOC_FLAG) {
+ int i;
+
lprintf("toc found\n");
- if (ptr >= (buf + bufsize - XING_TOC_LENGTH)) return 0;
+ if (ptr >= (buf + bufsize - XING_TOC_LENGTH)) goto exit_error;
memcpy(xing->toc, ptr, XING_TOC_LENGTH);
#ifdef LOG
for (i = 0; i < XING_TOC_LENGTH; i++) {
- lprintf("%d ", xing->toc[i]);
+ printf("%d ", xing->toc[i]);
}
- lprintf("\n");
+ printf("\n");
#endif
+ /* check the table validity
+ * - MUST start with 0
+ * - values MUST increase
+ */
+ if (xing->toc[0] != 0) {
+ lprintf("invalid Xing toc\n");
+ goto exit_error;
+ }
+ for (i = 1; i < XING_TOC_LENGTH; i++) {
+ if (xing->toc[i] < xing->toc[i-1]) {
+ lprintf("invalid Xing toc\n");
+ goto exit_error;
+ }
+ }
ptr += XING_TOC_LENGTH;
}
xing->vbr_scale = -1;
if (xing->flags & XING_VBR_SCALE_FLAG) {
- if (ptr >= (buf + bufsize - 4)) return 0;
- xing->vbr_scale = BE_32(ptr);
+ if (ptr >= (buf + bufsize - 4)) goto exit_error;
+ xing->vbr_scale = _X_BE_32(ptr);
lprintf("vbr_scale: %d\n", xing->vbr_scale);
}
-
- return xing;
} else {
lprintf("Xing header not found\n");
+ }
+ return xing;
+
+exit_error:
+ lprintf("Xing header parse error\n");
free(xing);
return NULL;
}
-}
/*
* Parse a Vbri header
@@ -388,20 +435,20 @@ static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame,
if ((ptr + 4) >= (buf + bufsize)) return 0;
lprintf("Checking %08X\n", *ptr);
- if (BE_32(ptr) == VBRI_TAG) {
- lprintf("Vbri header found\n");
+ if (_X_BE_32(ptr) == VBRI_TAG) {
+ lprintf("found Vbri header\n");
ptr += 4;
if ((ptr + 22) >= (buf + bufsize)) return 0;
- vbri->version = BE_16(ptr); ptr += 2;
- vbri->delai = BE_16(ptr); ptr += 2;
- vbri->quality = BE_16(ptr); ptr += 2;
- vbri->stream_size = BE_32(ptr); ptr += 4;
- vbri->stream_frames = BE_32(ptr); ptr += 4;
- vbri->toc_entries = BE_16(ptr); ptr += 2;
- vbri->toc_scale_factor = BE_16(ptr); ptr += 2;
- vbri->entry_size = BE_16(ptr); ptr += 2;
- vbri->entry_frames = BE_16(ptr); ptr += 2;
+ vbri->version = _X_BE_16(ptr); ptr += 2;
+ vbri->delai = _X_BE_16(ptr); ptr += 2;
+ vbri->quality = _X_BE_16(ptr); ptr += 2;
+ vbri->stream_size = _X_BE_32(ptr); ptr += 4;
+ vbri->stream_frames = _X_BE_32(ptr); ptr += 4;
+ vbri->toc_entries = _X_BE_16(ptr); ptr += 2;
+ vbri->toc_scale_factor = _X_BE_16(ptr); ptr += 2;
+ vbri->entry_size = _X_BE_16(ptr); ptr += 2;
+ vbri->entry_frames = _X_BE_16(ptr); ptr += 2;
lprintf("version: %d\n", vbri->version);
lprintf("delai: %d\n", vbri->delai);
lprintf("quality: %d\n", vbri->quality);
@@ -413,7 +460,7 @@ static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame,
lprintf("entry_frames: %d\n", vbri->entry_frames);
if ((ptr + (vbri->toc_entries + 1) * vbri->entry_size) >= (buf + bufsize)) return 0;
- vbri->toc = xine_xmalloc (sizeof(int) * (vbri->toc_entries + 1));
+ vbri->toc = xine_xcalloc ((vbri->toc_entries + 1), sizeof(int));
if (!vbri->toc) {
free (vbri);
return NULL;
@@ -453,6 +500,7 @@ static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame,
}
}
+
/*
* Parse a mp3 frame paylod
* return 1 on success, 0 on error
@@ -463,43 +511,97 @@ static int parse_frame_payload(demux_mpgaudio_t *this,
buf_element_t *buf;
off_t frame_pos, len;
uint64_t pts = 0;
+ int payload_size = 0;
frame_pos = this->input->get_current_pos(this->input) - 4;
- lprintf("frame_pos = %"PRId64"\n", frame_pos);
+ lprintf("frame_pos = %"PRId64", header: %08X\n", frame_pos, _X_BE_32(frame_header));
buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo);
if (this->cur_frame.size > buf->max_size) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- "demux_mpgaudio: frame size is greater than fifo buffer size\n");
+ LOG_MODULE ": frame size is greater than fifo buffer size\n");
buf->free_buffer(buf);
return 0;
}
-
- /* the decoder needs the frame header */
- memcpy(buf->mem, frame_header, 4);
- len = this->input->read(this->input, buf->mem + 4, this->cur_frame.size - 4);
- if (len != (this->cur_frame.size - 4)) {
- buf->free_buffer(buf);
- return 0;
+ memcpy(buf->content, frame_header, 4);
+
+ /* compute the payload size */
+ if (this->cur_frame.size > 0) {
+ payload_size = this->cur_frame.size - 4;
+ this->free_bitrate_count = 0;
+ } else if (this->free_bitrate_count >= NUM_VALID_FRAMES) {
+ payload_size = this->free_bitrate_size + this->cur_frame.padding - 4;
+ this->cur_frame.size = payload_size + 4;
+ } else {
+ this->free_bitrate_count++;
+ payload_size = 0;
+ }
+
+ /* Read the payload data. */
+ if (payload_size > 0) {
+ off_t len;
+
+ /* If we know the payload size, it's easy */
+ this->found_next_frame = 0;
+ len = this->input->read(this->input, buf->content + 4, payload_size);
+ if (len != payload_size) {
+ buf->free_buffer(buf);
+ return 0;
+ }
+ } else {
+ /* Search for the beginning of the next frame and deduce the size of the
+ * current frame from the position of the next one. */
+ int payload_size = 0;
+ int max_size = buf->max_size - 4;
+
+ while (payload_size < max_size) {
+ len = this->input->read(this->input, &buf->content[4 + payload_size], 1);
+ if (len != 1) {
+ lprintf("EOF\n");
+ buf->free_buffer(buf);
+ return 0;
+ }
+ payload_size += len;
+
+ if (parse_frame_header(&this->next_frame, &buf->content[payload_size])) {
+ lprintf("found next frame header\n");
+
+ if (this->free_bitrate_size == 0) {
+ this->free_bitrate_size = payload_size - this->cur_frame.padding;
+ }
+
+ /* don't read the frame header twice */
+ this->found_next_frame = 1;
+ memcpy(&this->next_header[0], &buf->content[payload_size], 4);
+ payload_size -= 4;
+ break;
+ }
+ }
+ this->cur_frame.size = payload_size + 4;
+ this->cur_frame.bitrate = 8000 * this->cur_frame.size / this->cur_frame.duration;
+ lprintf("free bitrate: bitrate: %d, frame size: %d\n", this->br, this->cur_frame.size);
}
if (this->check_vbr_header) {
this->check_vbr_header = 0;
this->mpg_frame_start = frame_pos;
- this->xing_header = parse_xing_header(&this->cur_frame, buf->mem, this->cur_frame.size);
+ this->xing_header = parse_xing_header(&this->cur_frame, buf->content, this->cur_frame.size);
if (this->xing_header) {
buf->free_buffer(buf);
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ LOG_MODULE ": found Xing header at offset %PRId64\n", frame_pos);
return 1;
}
- this->vbri_header = parse_vbri_header(&this->cur_frame, buf->mem, this->cur_frame.size);
+ this->vbri_header = parse_vbri_header(&this->cur_frame, buf->content, this->cur_frame.size);
if (this->vbri_header) {
buf->free_buffer(buf);
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ LOG_MODULE ": found Vbri header at offset %PRId64\n", frame_pos);
return 1;
}
}
-
pts = (int64_t)(this->cur_time * 90.0f);
@@ -508,14 +610,13 @@ static int parse_frame_payload(demux_mpgaudio_t *this,
buf->extra_info->input_time = this->cur_time;
buf->pts = pts;
- buf->size = len + 4;
- buf->content = buf->mem;
+ buf->size = this->cur_frame.size;
buf->type = BUF_AUDIO_MPEG;
buf->decoder_info[0] = 1;
buf->decoder_flags = decoder_flags|BUF_FLAG_FRAME_END;
+ lprintf("send buffer: size=%d, pts=%"PRId64"\n", buf->size, pts);
this->audio_fifo->put(this->audio_fifo, buf);
- lprintf("send buffer: pts=%"PRId64"\n", pts);
this->cur_time += this->cur_frame.duration;
return 1;
}
@@ -579,40 +680,51 @@ static int read_frame_header(demux_mpgaudio_t *this, uint8_t *header_buf, int by
* Parse next mp3 frame
*/
static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int send_header) {
- uint8_t header_buf[4];
- int bytes = 4;
-
- for (;;) {
-
- if (read_frame_header(this, header_buf, bytes)) {
-
- if (parse_frame_header(&this->cur_frame, header_buf)) {
-
- /* send header buffer */
- if ( send_header ) {
- buf_element_t *buf;
-
- buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo);
-
- buf->type = BUF_AUDIO_MPEG;
- buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END;
-
- buf->decoder_info[0] = 0;
- buf->decoder_info[1] = this->cur_frame.freq;
- buf->decoder_info[2] = 0; /* bits_per_sample */
-
- /* Only for channel_mode == 3 (mono) there is one channel, for any other case, there are 2 */
- buf->decoder_info[3] = ( this->cur_frame.channel_mode == 3 ) ? 1 : 2;
-
- buf->size = 0; /* No extra header data */
-
- this->audio_fifo->put(this->audio_fifo, buf);
- }
-
- return parse_frame_payload(this, header_buf, decoder_flags);
-
- } else if ( id3v2_istag(header_buf) ) {
- if (!id3v2_parse_tag(this->input, this->stream, header_buf)) {
+ uint8_t buffer[4];
+ uint8_t *header = buffer;
+
+ if (this->found_next_frame) {
+ lprintf("skip header reading\n");
+ header = this->next_header;
+ memcpy(&this->cur_frame, &this->next_frame, sizeof(mpg_audio_frame_t));
+ } else {
+ int bytes = 4;
+ int loose_sync = 0;
+
+ for (;;) {
+ if (!read_frame_header(this, header, bytes))
+ return 0;
+ if (parse_frame_header(&this->cur_frame, header)) {
+ lprintf("frame found\n");
+
+ /* additionnal checks */
+ if ((this->mpg_version == (this->cur_frame.version_idx + 1)) &&
+ (this->mpg_layer == this->cur_frame.layer)) {
+ this->valid_frames++;
+ break;
+ } else {
+ if (this->valid_frames >= NUM_VALID_FRAMES) {
+ lprintf("invalid frame. expected mpeg %d, layer %d\n", this->mpg_version, this->mpg_layer);
+ } else {
+ this->mpg_version = this->cur_frame.version_idx + 1;
+ this->mpg_layer = this->cur_frame.layer;
+ this->valid_frames = 0;
+ break;
+ }
+ }
+ }
+
+ if (!loose_sync) {
+ off_t frame_pos = this->input->get_current_pos(this->input) - 4;
+ loose_sync = 1;
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ LOG_MODULE ": loose mp3 sync at offset %"PRId64"\n", frame_pos);
+ }
+ /* the stream is broken, don't keep info about previous frames */
+ this->free_bitrate_size = 0;
+
+ if ( id3v2_istag(header) ) {
+ if (!id3v2_parse_tag(this->input, this->stream, header)) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
LOG_MODULE ": ID3V2 tag parsing error\n");
bytes = 1; /* resync */
@@ -623,12 +735,31 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s
/* skip */
bytes = 1;
}
-
- } else {
- lprintf("read error\n");
- return 0;
}
}
+
+ /* send header buffer */
+ if ( send_header ) {
+ buf_element_t *buf;
+
+ buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo);
+
+ buf->type = BUF_AUDIO_MPEG;
+ buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END;
+
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = this->cur_frame.freq;
+ buf->decoder_info[2] = 0; /* bits_per_sample */
+
+ /* Only for channel_mode == 3 (mono) there is one channel, for any other case, there are 2 */
+ buf->decoder_info[3] = ( this->cur_frame.channel_mode == 3 ) ? 1 : 2;
+
+ buf->size = 0; /* No extra header data */
+
+ this->audio_fifo->put(this->audio_fifo, buf);
+ }
+
+ return parse_frame_payload(this, header, decoder_flags);
}
static int demux_mpgaudio_send_chunk (demux_plugin_t *this_gen) {
@@ -685,20 +816,16 @@ static int detect_mpgaudio_file(input_plugin_t *input) {
if (preview_len < 4)
return 0;
- lprintf("got preview %02x %02x %02x %02x\n",
- buf[0], buf[1], buf[2], buf[3]);
+ head = _X_ME_32(buf);
- head = BE_32(buf);
+ lprintf("got preview %08x\n", head);
- if ((head == ID3V22_TAG) ||
- (head == ID3V23_TAG) ||
- (head == ID3V24_TAG)) {
+ if (id3v2_istag(head)) {
/* check if a mp3 frame follows the tag
* id3v2 are not specific to mp3 files,
* flac files can contain id3v2 tags
*/
- uint8_t *ptr = &buf[6];
- uint32_t tag_size = id3v2_tagsize(ptr);
+ int tag_size = _X_BE_32_synchsafe(&buf[6]);
lprintf("try to skip id3v2 tag (%d bytes)\n", tag_size);
if ((10 + tag_size) >= preview_len) {
lprintf("cannot skip id3v2 tag\n");
@@ -755,11 +882,12 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) {
*/
this->check_vbr_header = 1;
for (i = 0; i < NUM_PREVIEW_BUFFERS; i++) {
+ lprintf("preview buffer number %d / %d\n", i + 1, NUM_PREVIEW_BUFFERS);
if (!demux_mpgaudio_next (this, BUF_FLAG_PREVIEW, i == 0)) {
break;
}
}
-
+
if (this->xing_header) {
xing_header_t *xing = this->xing_header;
@@ -770,7 +898,7 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) {
if (this->stream_length) {
this->br = ((uint64_t)xing->stream_size * 8 * 1000) / this->stream_length;
}
-
+
} else if (this->vbri_header) {
vbri_header_t *vbri = this->vbri_header;
@@ -812,8 +940,8 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) {
*/
{
char scratch_buf[256];
- char *mpeg_ver[3] = {"1", "2", "2.5"};
-
+ static const char mpeg_ver[3][4] = {"1", "2", "2.5"};
+
snprintf(scratch_buf, 256, "MPEG %s Layer %1d%s",
mpeg_ver[this->cur_frame.version_idx], this->cur_frame.layer,
(this->xing_header)? " VBR" : " CBR" );
@@ -926,7 +1054,7 @@ static int demux_mpgaudio_seek (demux_plugin_t *this_gen,
if (this->stream_length > 0) {
if (this->xing_header &&
- (this->xing_header->flags & (XING_TOC_FLAG | XING_BYTES_FLAG))) {
+ (this->xing_header->flags & XING_TOC_FLAG)) {
seek_pos += xing_get_seek_point(this->xing_header, start_time, this->stream_length);
lprintf("time seek: xing: time=%d, pos=%"PRId64"\n", start_time, seek_pos);
} else if (this->vbri_header) {
@@ -941,7 +1069,8 @@ static int demux_mpgaudio_seek (demux_plugin_t *this_gen,
/* assume seeking is always perfect... */
this->cur_time = start_time;
this->input->seek (this->input, seek_pos, SEEK_SET);
-
+ this->found_next_frame = 0;
+
if (playing) {
_x_demux_flush_engine(this->stream);
}
@@ -954,11 +1083,6 @@ static int demux_mpgaudio_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_mpgaudio_dispose (demux_plugin_t *this) {
-
- free (this);
-}
-
static int demux_mpgaudio_get_stream_length (demux_plugin_t *this_gen) {
demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
@@ -992,18 +1116,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl(input);
- const char *const extensions = class_gen->get_extensions (class_gen);
-
- lprintf ("stage by extension %s\n", mrl);
-
- if (!_x_demux_check_extension (mrl, extensions))
- return NULL;
-
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -1016,7 +1129,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_mpgaudio_send_headers;
this->demux_plugin.send_chunk = demux_mpgaudio_send_chunk;
this->demux_plugin.seek = demux_mpgaudio_seek;
- this->demux_plugin.dispose = demux_mpgaudio_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_mpgaudio_get_status;
this->demux_plugin.get_stream_length = demux_mpgaudio_get_stream_length;
this->demux_plugin.get_capabilities = demux_mpgaudio_get_capabilities;
@@ -1034,49 +1147,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
/*
* demux mpegaudio class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "MPEG audio demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MPEGAUDIO";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- demux_mpgaudio_class_t *this = (demux_mpgaudio_class_t *) this_gen;
-
- if( _x_decoder_available(this->xine, BUF_AUDIO_MPEG) )
- return "mp3 mp2 mpa mpega";
- else
- return "";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- demux_mpgaudio_class_t *this = (demux_mpgaudio_class_t *) this_gen;
-
- if( _x_decoder_available(this->xine, BUF_AUDIO_MPEG) )
- return "audio/mpeg2: mp2: MPEG audio;"
- "audio/x-mpeg2: mp2: MPEG audio;"
- "audio/mpeg3: mp3: MPEG audio;"
- "audio/x-mpeg3: mp3: MPEG audio;"
- "audio/mpeg: mpa,abs,mpega: MPEG audio;"
- "audio/x-mpeg: mpa,abs,mpega: MPEG audio;"
- "audio/x-mpegurl: mp3: MPEG audio;"
- "audio/mpegurl: mp3: MPEG audio;"
- "audio/mp3: mp3: MPEG audio;"
- "audio/x-mp3: mp3: MPEG audio;";
- else
- return "";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_mpgaudio_class_t *this = (demux_mpgaudio_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_mpgaudio_init_class (xine_t *xine, void *data) {
demux_mpgaudio_class_t *this;
@@ -1085,11 +1155,26 @@ void *demux_mpgaudio_init_class (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("MPEG audio demux plugin");
+ this->demux_class.identifier = "MPEGAUDIO";
+ if( _x_decoder_available(this->xine, BUF_AUDIO_MPEG) ) {
+ this->demux_class.mimetypes =
+ "audio/mpeg2: mp2: MPEG audio;"
+ "audio/x-mpeg2: mp2: MPEG audio;"
+ "audio/mpeg3: mp3: MPEG audio;"
+ "audio/x-mpeg3: mp3: MPEG audio;"
+ "audio/mpeg: mpa,abs,mpega: MPEG audio;"
+ "audio/x-mpeg: mpa,abs,mpega: MPEG audio;"
+ "audio/x-mpegurl: mp3: MPEG audio;"
+ "audio/mpegurl: mp3: MPEG audio;"
+ "audio/mp3: mp3: MPEG audio;"
+ "audio/x-mp3: mp3: MPEG audio;";
+ this->demux_class.extensions = "mp3 mp2 mpa mpega";
+ } else {
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = NULL;
+ }
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_nsf.c b/src/demuxers/demux_nsf.c
deleted file mode 100644
index 7408274d5..000000000
--- a/src/demuxers/demux_nsf.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-/*
- * NSF File "Demuxer" by Mike Melanson (melanson@pcisys.net)
- * This is really just a loader for NES Music File Format (extension NSF)
- * which loads an entire NSF file and passes it over to the NSF audio
- * decoder.
- *
- * After the file is sent over, the demuxer controls the playback by
- * sending empty buffers with incrementing pts values.
- *
- * For more information regarding the NSF format, visit:
- * http://www.tripoint.org/kevtris/nes/nsfspec.txt
- *
- * $Id: demux_nsf.c,v 1.24 2007/03/29 17:03:06 dgp85 Exp $
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-
-/********** logging **********/
-#define LOG_MODULE "demux_nsf"
-/* #define LOG_VERBOSE */
-/* #define LOG */
-
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
-#include "bswap.h"
-#include "group_audio.h"
-
-#define NSF_HEADER_SIZE 0x80
-#define NSF_SAMPLERATE 44100
-#define NSF_BITS 8
-#define NSF_CHANNELS 1
-#define NSF_REFRESH_RATE 60
-#define NSF_PTS_INC (90000 / NSF_REFRESH_RATE)
-
-typedef struct {
- demux_plugin_t demux_plugin;
-
- xine_stream_t *stream;
- fifo_buffer_t *video_fifo;
- fifo_buffer_t *audio_fifo;
- input_plugin_t *input;
- int status;
-
- int total_songs;
- int current_song;
- int new_song; /* indicates song change */
-
- char *title;
- char *artist;
- char *copyright;
-
- off_t filesize;
-
- int64_t current_pts;
- int file_sent;
-} demux_nsf_t;
-
-typedef struct {
- demux_class_t demux_class;
-} demux_nsf_class_t;
-
-/* returns 1 if the NSF file was opened successfully, 0 otherwise */
-static int open_nsf_file(demux_nsf_t *this) {
- unsigned char header[NSF_HEADER_SIZE];
-
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, NSF_HEADER_SIZE) !=
- NSF_HEADER_SIZE)
- return 0;
-
- /* check for the signature */
- if ((header[0] != 'N') ||
- (header[1] != 'E') ||
- (header[2] != 'S') ||
- (header[3] != 'M') ||
- (header[4] != 0x1A))
- return 0;
-
- this->total_songs = header[6];
- this->current_song = header[7];
- this->title = strdup(&header[0x0E]);
- this->artist = strdup(&header[0x2E]);
- this->copyright = strdup(&header[0x4E]);
-
- this->filesize = this->input->get_length(this->input);
-
- return 1;
-}
-
-static int demux_nsf_send_chunk(demux_plugin_t *this_gen) {
- demux_nsf_t *this = (demux_nsf_t *) this_gen;
- buf_element_t *buf;
- int bytes_read;
- char title[100];
-
- /* send chunks of the file to the decoder until file is completely
- * loaded; then send control buffers */
- if (!this->file_sent) {
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = BUF_AUDIO_NSF;
- bytes_read = this->input->read(this->input, buf->content, buf->max_size);
-
- if (bytes_read == 0) {
- /* the file has been completely loaded, free the buffer and start
- * sending control buffers */
- buf->free_buffer(buf);
- this->file_sent = 1;
-
- } else {
-
- /* keep loading the file */
- if (bytes_read < buf->max_size)
- buf->size = bytes_read;
- else
- buf->size = buf->max_size;
-
- buf->extra_info->input_normpos = 0;
- buf->extra_info->input_time = 0;
- buf->pts = 0;
-
- this->audio_fifo->put (this->audio_fifo, buf);
- }
- }
-
- /* this is not an 'else' because control might fall through from above */
- if (this->file_sent) {
- /* send a control buffer */
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
-
- if (this->new_song) {
-
- buf->decoder_info[1] = this->current_song;
- this->new_song = 0;
- sprintf(title, "%s, song %d/%d",
- this->title, this->current_song, this->total_songs);
-
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, title);
-
- _x_demux_control_newpts(this->stream, this->current_pts, 0);
-
- } else
- buf->decoder_info[1] = 0;
-
- buf->type = BUF_AUDIO_NSF;
- if(this->total_songs)
- buf->extra_info->input_normpos = (this->current_song - 1) * 65535 / this->total_songs;
- buf->extra_info->input_time = this->current_pts / 90;
- buf->pts = this->current_pts;
- buf->size = 0;
- this->audio_fifo->put (this->audio_fifo, buf);
-
- this->current_pts += NSF_PTS_INC;
- }
-
- return this->status;
-}
-
-static void demux_nsf_send_headers(demux_plugin_t *this_gen) {
- demux_nsf_t *this = (demux_nsf_t *) this_gen;
- buf_element_t *buf;
- char copyright[100];
-
- this->video_fifo = this->stream->video_fifo;
- this->audio_fifo = this->stream->audio_fifo;
-
- this->status = DEMUX_OK;
-
- /* load stream information */
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 0);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS,
- NSF_CHANNELS);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE,
- NSF_SAMPLERATE);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS,
- NSF_BITS);
-
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, this->title);
- _x_meta_info_set(this->stream, XINE_META_INFO_ARTIST, this->artist);
- sprintf(copyright, "(C) %s", this->copyright);
- _x_meta_info_set(this->stream, XINE_META_INFO_COMMENT, copyright);
-
- /* send start buffers */
- _x_demux_control_start(this->stream);
-
- /* send init info to the audio decoder */
- if (this->audio_fifo) {
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = BUF_AUDIO_NSF;
- buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_FRAME_END;
- buf->decoder_info[0] = 5;
- buf->decoder_info[1] = NSF_SAMPLERATE;
- buf->decoder_info[2] = NSF_BITS;
- buf->decoder_info[3] = NSF_CHANNELS;
-
- /* send the NSF filesize in the body, big endian format */
- buf->content[0] = (this->filesize >> 24) & 0xFF;
- buf->content[1] = (this->filesize >> 16) & 0xFF;
- buf->content[2] = (this->filesize >> 8) & 0xFF;
- buf->content[3] = (this->filesize >> 0) & 0xFF;
- /* send the requested song */
- buf->content[4] = this->current_song + 5;
-
- this->audio_fifo->put (this->audio_fifo, buf);
- }
-}
-
-static int demux_nsf_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time, int playing) {
-
- demux_nsf_t *this = (demux_nsf_t *) this_gen;
- start_pos = (off_t) ( (double) start_pos / 65535 *
- this->total_songs );
-
- /* if thread is not running, initialize demuxer */
- if( !playing ) {
-
- /* send new pts */
- _x_demux_control_newpts(this->stream, 0, 0);
-
- this->status = DEMUX_OK;
-
- /* reposition stream at the start for loading */
- this->input->seek(this->input, 0, SEEK_SET);
-
- this->file_sent = 0;
- this->current_pts = 0;
- this->new_song = 1;
- } else {
- this->current_song = start_pos + 1;
- this->new_song = 1;
- this->current_pts = 0;
- _x_demux_flush_engine(this->stream);
- }
-
- return this->status;
-}
-
-static void demux_nsf_dispose (demux_plugin_t *this_gen) {
- demux_nsf_t *this = (demux_nsf_t *) this_gen;
-
- free(this->title);
- free(this->artist);
- free(this->copyright);
- free(this);
-}
-
-static int demux_nsf_get_status (demux_plugin_t *this_gen) {
- demux_nsf_t *this = (demux_nsf_t *) this_gen;
-
- return this->status;
-}
-
-/* return the approximate length in miliseconds */
-static int demux_nsf_get_stream_length (demux_plugin_t *this_gen) {
- return 0;
-}
-
-static uint32_t demux_nsf_get_capabilities(demux_plugin_t *this_gen) {
- return DEMUX_CAP_NOCAP;
-}
-
-static int demux_nsf_get_optional_data(demux_plugin_t *this_gen,
- void *data, int data_type) {
- return DEMUX_OPTIONAL_UNSUPPORTED;
-}
-
-static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *stream,
- input_plugin_t *input) {
-
- demux_nsf_t *this;
-
- if (!INPUT_IS_SEEKABLE(input)) {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "input not seekable, can not handle!\n");
- return NULL;
- }
-
- this = xine_xmalloc (sizeof (demux_nsf_t));
- this->stream = stream;
- this->input = input;
-
- this->demux_plugin.send_headers = demux_nsf_send_headers;
- this->demux_plugin.send_chunk = demux_nsf_send_chunk;
- this->demux_plugin.seek = demux_nsf_seek;
- this->demux_plugin.dispose = demux_nsf_dispose;
- this->demux_plugin.get_status = demux_nsf_get_status;
- this->demux_plugin.get_stream_length = demux_nsf_get_stream_length;
- this->demux_plugin.get_capabilities = demux_nsf_get_capabilities;
- this->demux_plugin.get_optional_data = demux_nsf_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
-
- this->status = DEMUX_FINISHED;
-
- switch (stream->content_detection_method) {
-
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
- case METHOD_BY_CONTENT:
- case METHOD_EXPLICIT:
-
- if (!open_nsf_file(this)) {
- free (this);
- return NULL;
- }
-
- break;
-
- default:
- free (this);
- return NULL;
- }
-
- return &this->demux_plugin;
-}
-
-static const char *get_description (demux_class_t *this_gen) {
- return "NES Music file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "NSF";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "nsf";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_nsf_class_t *this = (demux_nsf_class_t *) this_gen;
-
- free (this);
-}
-
-void *demux_nsf_init_plugin (xine_t *xine, void *data) {
- demux_nsf_class_t *this;
-
- this = xine_xmalloc (sizeof (demux_nsf_class_t));
-
- this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
-
- return this;
-}
diff --git a/src/demuxers/demux_nsv.c b/src/demuxers/demux_nsv.c
index 6d43b247c..74f98c7cd 100644
--- a/src/demuxers/demux_nsv.c
+++ b/src/demuxers/demux_nsv.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* Nullsoft Video (NSV) file demuxer by Mike Melanson (melanson@pcisys.net)
* For more information regarding the NSV file format, visit:
* http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: demux_nsv.c,v 1.25 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,12 +40,12 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
-#include "buffer.h"
+#include <xine/buffer.h>
#define FOURCC_TAG BE_FOURCC
#define NSVf_TAG FOURCC_TAG('N', 'S', 'V', 'f')
@@ -172,7 +170,7 @@ static off_t nsv_read(demux_nsv_t *this, uint8_t *buffer, off_t len) {
return -1;
}
/* read packet payload len */
- this->ultravox_size = BE_16(&ultravox_buf[5]);
+ this->ultravox_size = _X_BE_16(&ultravox_buf[5]);
this->ultravox_pos = 0;
lprintf("ultravox_size: %d\n", this->ultravox_size);
} else {
@@ -287,11 +285,11 @@ static int open_nsv_file(demux_nsv_t *this) {
return 0;
lprintf("found NSVf chunk\n");
- /* this->data_size = LE_32(&preview[8]);*/
+ /* this->data_size = _X_LE_32(&preview[8]);*/
/*lprintf("data_size: %lld\n", this->data_size);*/
/* skip the rest of the data */
- chunk_size = LE_32(&preview[4]);
+ chunk_size = _X_LE_32(&preview[4]);
nsv_seek(this, chunk_size - 28, SEEK_CUR);
}
break;
@@ -303,21 +301,21 @@ static int open_nsv_file(demux_nsv_t *this) {
if (nsv_read(this, &preview[4], 15) != 15)
return 0;
- this->video_fourcc = ME_32(&preview[4]);
- if (BE_32(&preview[4]) == NONE_TAG)
+ this->video_fourcc = _X_ME_32(&preview[4]);
+ if (_X_BE_32(&preview[4]) == NONE_TAG)
this->video_type = 0;
else
this->video_type = _x_fourcc_to_buf_video(this->video_fourcc);
- this->audio_fourcc = ME_32(&preview[8]);
- if (BE_32(&preview[8]) == NONE_TAG)
+ this->audio_fourcc = _X_ME_32(&preview[8]);
+ if (_X_BE_32(&preview[8]) == NONE_TAG)
this->audio_type = 0;
else
this->audio_type = _x_formattag_to_buf_audio(this->audio_fourcc);
this->bih.biSize = sizeof(this->bih);
- this->bih.biWidth = LE_16(&preview[12]);
- this->bih.biHeight = LE_16(&preview[14]);
+ this->bih.biWidth = _X_LE_16(&preview[12]);
+ this->bih.biHeight = _X_LE_16(&preview[14]);
this->bih.biCompression = this->video_fourcc;
this->video_pts = 0;
@@ -493,10 +491,10 @@ static int demux_nsv_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- video_size = LE_32(&buffer[0]);
+ video_size = _X_LE_32(&buffer[0]);
video_size >>= 4;
video_size &= 0xFFFFF;
- audio_size = LE_16(&buffer[3]);
+ audio_size = _X_LE_16(&buffer[3]);
nsv_parse_payload(this, video_size, audio_size);
break;
@@ -567,11 +565,6 @@ static int demux_nsv_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_nsv_dispose (demux_plugin_t *this) {
-
- free(this);
-}
-
static int demux_nsv_get_status (demux_plugin_t *this_gen) {
demux_nsv_t *this = (demux_nsv_t *) this_gen;
@@ -603,7 +596,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_nsv_send_headers;
this->demux_plugin.send_chunk = demux_nsv_send_chunk;
this->demux_plugin.seek = demux_nsv_seek;
- this->demux_plugin.dispose = demux_nsv_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_nsv_get_status;
this->demux_plugin.get_stream_length = demux_nsv_get_stream_length;
this->demux_plugin.get_capabilities = demux_nsv_get_capabilities;
@@ -614,19 +607,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -645,39 +626,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Nullsoft Video demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "Nullsoft NSV";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "nsv";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_nsv_class_t *this = (demux_nsv_class_t *) this_gen;
-
- free (this);
-}
-
static void *demux_nsv_init_plugin (xine_t *xine, void *data) {
demux_nsv_class_t *this;
this = xine_xmalloc (sizeof (demux_nsv_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Nullsoft Video demux plugin");
+ this->demux_class.identifier = "Nullsoft NSV";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "nsv";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -691,6 +650,6 @@ static const demuxer_info_t demux_info_nsv = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "nsv", XINE_VERSION_CODE, &demux_info_nsv, demux_nsv_init_plugin },
+ { PLUGIN_DEMUX, 27, "nsv", XINE_VERSION_CODE, &demux_info_nsv, demux_nsv_init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
deleted file mode 100644
index f868018af..000000000
--- a/src/demuxers/demux_ogg.c
+++ /dev/null
@@ -1,2202 +0,0 @@
-/*
- * Copyright (C) 2000-2004 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-/*
- * $Id: demux_ogg.c,v 1.177 2007/03/29 19:38:51 dgp85 Exp $
- *
- * demultiplexer for ogg streams
- *
- */
-/* 2003.02.09 (dilb) update of the handling for audio/video infos for strongarm cpus. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include <ogg/ogg.h>
-#include <vorbis/codec.h>
-
-#ifdef HAVE_SPEEX
-#include <speex/speex.h>
-#include <speex/speex_header.h>
-#include <speex/speex_stereo.h>
-#include <speex/speex_callbacks.h>
-#endif
-
-#ifdef HAVE_THEORA
-#include <theora/theora.h>
-#endif
-
-#define LOG_MODULE "demux_ogg"
-#define LOG_VERBOSE
-
-/*
-#define LOG
-*/
-
-#define DEBUG_PACKETS 0
-#define DEBUG_PREVIEWS 0
-#define DEBUG_PTS 0
-#define DEBUG_VIDEO_PACKETS 0
-
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "bswap.h"
-#include "flacutils.h"
-
-#define CHUNKSIZE 8500
-#define PACKET_TYPE_HEADER 0x01
-#define PACKET_TYPE_COMMENT 0x03
-#define PACKET_TYPE_CODEBOOK 0x05
-#define PACKET_TYPE_BITS 0x07
-#define PACKET_LEN_BITS01 0xc0
-#define PACKET_LEN_BITS2 0x02
-#define PACKET_IS_SYNCPOINT 0x08
-
-#define MAX_STREAMS 32
-
-#define PTS_AUDIO 0
-#define PTS_VIDEO 1
-
-#define WRAP_THRESHOLD 900000
-
-#define SUB_BUFSIZE 1024
-
-typedef struct chapter_entry_s {
- int64_t start_pts;
- char *name;
-} chapter_entry_t;
-
-typedef struct chapter_info_s {
- int current_chapter;
- int max_chapter;
- chapter_entry_t *entries;
-} chapter_info_t;
-
-typedef struct stream_info_s {
- ogg_stream_state oss;
- uint32_t buf_types;
- int headers;
- int64_t header_granulepos;
- int64_t factor;
- int64_t quotient;
- int resync;
- char *language;
- /* CMML, Ogg Skeleton stream information */
- int granuleshift;
- /* Annodex v2 stream information */
- int hide_first_header;
- int delivered_bos;
- int delivered_eos;
-} stream_info_t;
-
-typedef struct demux_ogg_s {
- demux_plugin_t demux_plugin;
-
- xine_stream_t *stream;
- fifo_buffer_t *audio_fifo;
- fifo_buffer_t *video_fifo;
- input_plugin_t *input;
- int status;
-
- int frame_duration;
-
-#ifdef HAVE_THEORA
- theora_info t_info;
- theora_comment t_comment;
-#endif
-
- ogg_sync_state oy;
- ogg_page og;
-
- int64_t start_pts;
- int64_t last_pts[2];
-
- int time_length;
-
- int num_streams;
- stream_info_t *si[MAX_STREAMS]; /* stream info */
-
- int num_audio_streams;
- int num_video_streams;
- int unhandled_video_streams;
- int num_spu_streams;
-
- off_t avg_bitrate;
-
- char *title;
- chapter_info_t *chapter_info;
- xine_event_queue_t *event_queue;
-
- uint8_t send_newpts:1;
- uint8_t buf_flag_seek:1;
- uint8_t keyframe_needed:1;
- uint8_t ignore_keyframes:1;
-} demux_ogg_t ;
-
-typedef struct {
- demux_class_t demux_class;
-} demux_ogg_class_t;
-
-typedef struct {
- demux_class_t demux_class;
-} demux_anx_class_t;
-
-
-#ifdef HAVE_THEORA
-static int intlog(int num) {
- int ret=0;
-
- while(num>0){
- num=num/2;
- ret=ret+1;
- }
- return(ret);
-}
-#endif
-
-static int get_stream (demux_ogg_t *this, int serno) {
- /*finds the stream_num, which belongs to a ogg serno*/
- int i;
-
- for (i = 0; i<this->num_streams; i++) {
- if (this->si[i]->oss.serialno == serno) {
- return i;
- }
- }
- return -1;
-}
-
-static int new_stream_info (demux_ogg_t *this, const int cur_serno) {
- int stream_num;
-
- this->si[this->num_streams] = (stream_info_t *)xine_xmalloc(sizeof(stream_info_t));
- ogg_stream_init(&this->si[this->num_streams]->oss, cur_serno);
- stream_num = this->num_streams;
- this->si[stream_num]->buf_types = 0;
- this->si[stream_num]->header_granulepos = -1;
- this->si[stream_num]->headers = 0;
- this->num_streams++;
-
- return stream_num;
-}
-
-static int64_t get_pts (demux_ogg_t *this, int stream_num , int64_t granulepos ) {
- /*calculates an pts from an granulepos*/
- if (granulepos<0) {
- if ( this->si[stream_num]->header_granulepos>=0 ) {
- /*return the smallest valid pts*/
- return 1;
- } else
- return 0;
- } else if (this->si[stream_num]->buf_types == BUF_VIDEO_THEORA ||
- (this->si[stream_num]->buf_types & 0xFFFF0000) == BUF_SPU_CMML) {
- int64_t iframe, pframe;
- int granuleshift;
- granuleshift = this->si[stream_num]->granuleshift;
- iframe = granulepos >> granuleshift;
- pframe = granulepos - (iframe << granuleshift);
- if (this->si[stream_num]->quotient)
- return 1+((iframe+pframe) * this->si[stream_num]->factor / this->si[stream_num]->quotient);
- else
- return 0;
- } else if (this->si[stream_num]->quotient)
- return 1+(granulepos * this->si[stream_num]->factor / this->si[stream_num]->quotient);
- else
- return 0;
-}
-
-static int read_ogg_packet (demux_ogg_t *this) {
- char *buffer;
- long bytes;
- while (ogg_sync_pageout(&this->oy,&this->og)!=1) {
- buffer = ogg_sync_buffer(&this->oy, CHUNKSIZE);
- bytes = this->input->read(this->input, buffer, CHUNKSIZE);
- ogg_sync_wrote(&this->oy, bytes);
- if (bytes < CHUNKSIZE/2) {
- return 0;
- }
- }
- return 1;
-}
-
-static void get_stream_length (demux_ogg_t *this) {
- /*determine the streamlenght and set this->time_length accordingly.
- ATTENTION:current_pos and oggbuffers will be destroyed by this function,
- there will be no way to continue playback uninterrupted.
-
- You have to seek afterwards, because after get_stream_length, the
- current_position is at the end of the file */
-
- off_t filelength;
- int done=0;
- int stream_num;
-
- this->time_length=-1;
-
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
- filelength=this->input->get_length(this->input);
-
- if (filelength!=-1) {
- if (filelength>70000) {
- this->demux_plugin.seek(&this->demux_plugin,
- (off_t) ( (double)(filelength-65536)/filelength*65535), 0, 0);
- }
- done=0;
- while (!done) {
- if (!read_ogg_packet (this)) {
- if (this->time_length) {
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_BITRATE,
- ((int64_t) 8000*filelength)/this->time_length);
- /*this is a fine place to compute avg_bitrate*/
- this->avg_bitrate= 8000*filelength/this->time_length;
- }
- return;
- }
- stream_num=get_stream(this, ogg_page_serialno (&this->og) );
- if (stream_num!=-1) {
- if (this->time_length < (get_pts(this, stream_num, ogg_page_granulepos(&this->og) / 90)))
- this->time_length = get_pts(this, stream_num, ogg_page_granulepos(&this->og)) / 90;
- }
- }
- }
- }
-}
-
-#ifdef HAVE_THEORA
-static void send_ogg_packet (demux_ogg_t *this,
- fifo_buffer_t *fifo,
- ogg_packet *op,
- int64_t pts,
- uint32_t decoder_flags,
- int stream_num) {
-
- buf_element_t *buf;
-
- int done=0,todo=op->bytes;
- int op_size = sizeof(ogg_packet);
-
- while (done<todo) {
- int offset=0;
- buf = fifo->buffer_pool_alloc (fifo);
- buf->decoder_flags = decoder_flags;
- if (done==0) {
- memcpy (buf->content, op, op_size);
- offset=op_size;
- buf->decoder_flags = buf->decoder_flags | BUF_FLAG_FRAME_START;
- }
-
- if (done+buf->max_size-offset < todo) {
- memcpy (buf->content+offset, op->packet+done, buf->max_size-offset);
- buf->size = buf->max_size;
- done=done+buf->max_size-offset;
- } else {
- memcpy (buf->content+offset , op->packet+done, todo-done);
- buf->size = todo-done+offset;
- done=todo;
- buf->decoder_flags = buf->decoder_flags | BUF_FLAG_FRAME_END;
- }
-
- buf->pts = pts;
- if( this->input->get_length (this->input) )
- buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) *
- 65535 / this->input->get_length (this->input) );
- buf->extra_info->input_time = buf->pts / 90 ;
- buf->type = this->si[stream_num]->buf_types;
-
- fifo->put (fifo, buf);
- }
-}
-#endif
-
-/* redefine abs as macro to handle 64-bit diffs.
- i guess llabs may not be available everywhere */
-#define abs(x) ( ((x)<0) ? -(x) : (x) )
-
-static void check_newpts (demux_ogg_t *this, int64_t pts, int video, int preview) {
- int64_t diff;
-
- llprintf(DEBUG_PTS, "new pts %" PRId64 " found in stream\n",pts);
-
- diff = pts - this->last_pts[video];
-
- if (!preview && (pts>=0) &&
- (this->send_newpts || (this->last_pts[video] && abs(diff)>WRAP_THRESHOLD) ) ) {
-
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "diff=%" PRId64 " (pts=%" PRId64 ", last_pts=%" PRId64 ")\n", diff, pts, this->last_pts[video]);
-
- if (this->buf_flag_seek) {
- _x_demux_control_newpts(this->stream, pts, BUF_FLAG_SEEK);
- this->buf_flag_seek = 0;
- } else {
- _x_demux_control_newpts(this->stream, pts, 0);
- }
- this->send_newpts = 0;
- this->last_pts[1-video] = 0;
- }
-
- if (!preview && (pts>=0) )
- this->last_pts[video] = pts;
-
- /* use pts for bitrate measurement */
-
- /*compute avg_bitrate if time_length isn't set*/
- if ((pts>180000) && !(this->time_length)) {
- this->avg_bitrate = this->input->get_current_pos (this->input) * 8 * 90000/ pts;
-
- if (this->avg_bitrate<1)
- this->avg_bitrate = 1;
-
- }
-}
-
-static void ogg_handle_event (demux_ogg_t *this) {
- xine_event_t *event;
-
- while ((event = xine_event_get(this->event_queue))) {
- switch(event->type) {
- case XINE_EVENT_INPUT_NEXT:
- {
- if (this->chapter_info) {
- int c_chap = this->chapter_info->current_chapter;
- if (c_chap+1 < this->chapter_info->max_chapter) {
- int start_time = this->chapter_info->entries[c_chap+1].start_pts / 90;
- this->demux_plugin.seek((demux_plugin_t *)this, 0, start_time, 1);
- }
- }
- }
- break;
- case XINE_EVENT_INPUT_PREVIOUS:
- {
- if (this->chapter_info) {
- int c_chap = this->chapter_info->current_chapter;
- if (c_chap >= 1) {
- int start_time = this->chapter_info->entries[c_chap-1].start_pts / 90;
- this->demux_plugin.seek((demux_plugin_t *)this, 0, start_time, 1);
- }
- }
- }
- break;
- }
- xine_event_free(event);
- }
- return;
-}
-
-/*
- * utility function to read a LANGUAGE= line from the user_comments,
- * to label audio and spu streams
- */
-static void read_language_comment (demux_ogg_t *this, ogg_packet *op, int stream_num) {
- char **ptr;
- char *comment;
- vorbis_comment vc;
- vorbis_info vi;
-
- vorbis_comment_init(&vc);
- vorbis_info_init(&vi);
-
- /* this is necessary to make libvorbis accept this vorbis_info*/
- vi.rate=1;
-
- if ( vorbis_synthesis_headerin(&vi, &vc, op) >= 0) {
- ptr=vc.user_comments;
- while(*ptr) {
- comment=*ptr;
- if ( !strncasecmp ("LANGUAGE=", comment, 9) ) {
- this->si[stream_num]->language = strdup (comment + strlen ("LANGUAGE=") );
- }
- ++ptr;
- }
- }
- vorbis_comment_clear(&vc);
- vorbis_info_clear(&vi);
-}
-
-/*
- * utility function to read CHAPTER*= and TITLE= from the user_comments,
- * to name parts of the videostream
- */
-static void read_chapter_comment (demux_ogg_t *this, ogg_packet *op) {
- char **ptr;
- char *comment;
- vorbis_comment vc;
- vorbis_info vi;
-
- vorbis_comment_init(&vc);
- vorbis_info_init(&vi);
-
- /* this is necessary to make libvorbis accept this vorbis_info*/
- vi.rate=1;
-
- if ( vorbis_synthesis_headerin(&vi, &vc, op) >= 0) {
- char *chapter_time = 0;
- char *chapter_name = 0;
- int chapter_no = 0;
- ptr=vc.user_comments;
- while(*ptr) {
- comment=*ptr;
- if ( !strncasecmp ("TITLE=", comment,6) ) {
- this->title = strdup (comment + strlen ("TITLE=") );
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, this->title);
- }
- if ( !chapter_time && strlen(comment) == 22 &&
- !strncasecmp ("CHAPTER" , comment, 7) &&
- isdigit(*(comment+7)) && isdigit(*(comment+8)) &&
- (*(comment+9) == '=')) {
-
- chapter_time = strdup(comment+10);
- chapter_no = strtol(comment+7, NULL, 10);
- }
- if ( !chapter_name && !strncasecmp("CHAPTER", comment, 7) &&
- isdigit(*(comment+7)) && isdigit(*(comment+8)) &&
- !strncasecmp ("NAME=", comment+9, 5)) {
-
- if (strtol(comment+7,NULL,10) == chapter_no) {
- chapter_name = strdup(comment+14);
- }
- }
- if (chapter_time && chapter_name && chapter_no){
- int hour, min, sec, msec;
-
- lprintf("create chapter entry: no=%d name=%s time=%s\n", chapter_no, chapter_name, chapter_time);
- hour= strtol(chapter_time, NULL, 10);
- min = strtol(chapter_time+3, NULL, 10);
- sec = strtol(chapter_time+6, NULL, 10);
- msec = strtol(chapter_time+9, NULL, 10);
- lprintf("time: %d %d %d %d\n", hour, min,sec,msec);
-
- if (!this->chapter_info) {
- this->chapter_info = (chapter_info_t *)xine_xmalloc(sizeof(chapter_info_t));
- this->chapter_info->current_chapter = -1;
- }
- this->chapter_info->max_chapter = chapter_no;
- this->chapter_info->entries = realloc( this->chapter_info->entries, chapter_no*sizeof(chapter_entry_t));
- this->chapter_info->entries[chapter_no-1].name = chapter_name;
- this->chapter_info->entries[chapter_no-1].start_pts = (msec + (1000.0 * sec) + (60000.0 * min) + (3600000.0 * hour))*90;
-
- free (chapter_time);
- chapter_no = 0;
- chapter_time = chapter_name = 0;
- }
- ++ptr;
- }
- }
- vorbis_comment_clear(&vc);
- vorbis_info_clear(&vi);
-}
-
-/*
- * update the display of the title, if needed
- */
-static void update_chapter_display (demux_ogg_t *this, int stream_num, ogg_packet *op) {
- int chapter = 0;
- int64_t pts = get_pts(this, stream_num, op->granulepos );
-
- while (chapter < this->chapter_info->max_chapter &&
- this->chapter_info->entries[chapter].start_pts < pts) {
- chapter++;
- }
- chapter--;
-
- if (chapter != this->chapter_info->current_chapter){
- xine_event_t uevent;
- xine_ui_data_t data;
- int title_len;
- char *title;
-
- this->chapter_info->current_chapter = chapter;
- if (chapter >= 0) {
- char t_title[256];
-
- if (this->title) {
- snprintf(t_title, sizeof (t_title), "%s / %s", this->title, this->chapter_info->entries[chapter].name);
- } else {
- snprintf(t_title, sizeof (t_title), "%s", this->chapter_info->entries[chapter].name);
- }
- title = t_title;
- } else {
- title = this->title;
- }
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, title);
- lprintf("new TITLE: %s\n", title);
-
- uevent.type = XINE_EVENT_UI_SET_TITLE;
- uevent.stream = this->stream;
- uevent.data = &data;
- uevent.data_length = sizeof(data);
- title_len = strlen(title) + 1;
- memcpy(data.str, title, title_len);
- data.str_len = title_len;
- xine_event_send(this->stream, &uevent);
- }
-}
-
-/*
- * utility function to pack one ogg_packet into a xine
- * buffer, fill out all needed fields
- * and send it to the right fifo
- */
-
-static void send_ogg_buf (demux_ogg_t *this,
- ogg_packet *op,
- int stream_num,
- uint32_t decoder_flags) {
-
- int hdrlen;
- int normpos = 0;
-
- if( this->input->get_length (this->input) )
- normpos = (int)( (double) this->input->get_current_pos (this->input) *
- 65535 / this->input->get_length (this->input) );
-
-
- hdrlen = (*op->packet & PACKET_LEN_BITS01) >> 6;
- hdrlen |= (*op->packet & PACKET_LEN_BITS2) << 1;
-
- /* for Annodex files: the first packet after the AnxData info packet needs
- * to have its BOS flag set: we set it here */
- if (!this->si[stream_num]->delivered_bos) {
- op->b_o_s = 1;
- this->si[stream_num]->delivered_bos = 1;
- }
-
- if ( this->audio_fifo
- && (this->si[stream_num]->buf_types & 0xFF000000) == BUF_AUDIO_BASE) {
- uint8_t *data;
- int size;
- int64_t pts;
-
- if (op->packet[0] == PACKET_TYPE_COMMENT ) {
- read_language_comment(this, op, stream_num);
- }
-
- if ((this->si[stream_num]->buf_types & 0xFFFF0000) == BUF_AUDIO_SPEEX ||
- (this->si[stream_num]->buf_types & 0xFFFF0000) == BUF_AUDIO_FLAC ||
- (this->si[stream_num]->buf_types & 0xFFFF0000) == BUF_AUDIO_VORBIS) {
- data = op->packet;
- size = op->bytes;
- } else {
- data = op->packet+1+hdrlen;
- size = op->bytes-1-hdrlen;
- }
- llprintf(DEBUG_PACKETS, "audio data size %d\n", size);
-
- if ((op->granulepos != -1) || (this->si[stream_num]->header_granulepos != -1)) {
- pts = get_pts(this, stream_num, op->granulepos );
- check_newpts( this, pts, PTS_AUDIO, decoder_flags );
- } else
- pts = 0;
-
- llprintf(DEBUG_PACKETS,
- "audiostream %d op-gpos %" PRId64 " hdr-gpos %" PRId64 " pts %" PRId64 " \n",
- stream_num,
- op->granulepos,
- this->si[stream_num]->header_granulepos,
- pts);
-
- _x_demux_send_data(this->audio_fifo, data, size,
- pts, this->si[stream_num]->buf_types, decoder_flags,
- normpos,
- pts / 90, this->time_length, 0);
-
-#ifdef HAVE_THEORA
- } else if ((this->si[stream_num]->buf_types & 0xFFFF0000) == BUF_VIDEO_THEORA) {
-
- int64_t pts;
- theora_info t_info;
- theora_comment t_comment;
-
- theora_info_init (&t_info);
- theora_comment_init (&t_comment);
-
- /*Lets see if this is an Header*/
- if ((theora_decode_header(&t_info, &t_comment, op))>=0) {
- decoder_flags=decoder_flags|BUF_FLAG_HEADER;
- lprintf ("found an header\n");
- }
-
- if ((op->granulepos != -1) || (this->si[stream_num]->header_granulepos != -1)) {
- pts = get_pts(this, stream_num, op->granulepos );
- check_newpts( this, pts, PTS_VIDEO, decoder_flags );
- } else
- pts = 0;
-
- llprintf(DEBUG_PACKETS,
- "theorastream %d op-gpos %" PRId64 " hdr-gpos %" PRId64 " pts %" PRId64 " \n",
- stream_num,
- op->granulepos,
- this->si[stream_num]->header_granulepos,
- pts);
-
- send_ogg_packet (this, this->video_fifo, op, pts, decoder_flags, stream_num);
-
- theora_comment_clear (&t_comment);
- theora_info_clear (&t_info);
-#endif
-
- } else if ((this->si[stream_num]->buf_types & 0xFF000000) == BUF_VIDEO_BASE) {
-
- uint8_t *data;
- int size;
- int64_t pts;
-
- llprintf(DEBUG_VIDEO_PACKETS,
- "video buffer, type=%08x\n", this->si[stream_num]->buf_types);
-
- if (op->packet[0] == PACKET_TYPE_COMMENT ) {
- read_chapter_comment(this, op);
- }else{
- data = op->packet+1+hdrlen;
- size = op->bytes-1-hdrlen;
-
- if ((op->granulepos != -1) || (this->si[stream_num]->header_granulepos != -1)) {
- pts = get_pts(this, stream_num, op->granulepos );
- check_newpts( this, pts, PTS_VIDEO, decoder_flags );
- } else
- pts = 0;
-
- llprintf(DEBUG_VIDEO_PACKETS,
- "videostream %d op-gpos %" PRId64 " hdr-gpos %" PRId64 " pts %" PRId64 " \n",
- stream_num,
- op->granulepos,
- this->si[stream_num]->header_granulepos,
- pts);
-
- _x_demux_send_data(this->video_fifo, data, size,
- pts, this->si[stream_num]->buf_types, decoder_flags,
- normpos,
- pts / 90, this->time_length, 0);
-
- if (this->chapter_info && op->granulepos != -1) {
- update_chapter_display(this, stream_num, op);
- }
- }
- } else if ((this->si[stream_num]->buf_types & 0xFFFF0000) == BUF_SPU_CMML) {
- buf_element_t *buf;
- uint32_t *val;
- char *str;
-
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
-
- buf->type = this->si[stream_num]->buf_types;
-
- buf->pts = get_pts (this, stream_num, op->granulepos);
-
- val = (uint32_t * )buf->content;
- str = (char *)val;
-
- memcpy(str, op->packet, op->bytes);
- str[op->bytes] = '\0';
-
- buf->size = 12 + op->bytes + 1;
-
- lprintf ("CMML stream %d (bytes=%ld): PTS %"PRId64": %s\n",
- stream_num, op->bytes, buf->pts, str);
-
- this->video_fifo->put (this->video_fifo, buf);
- } else if ((this->si[stream_num]->buf_types & 0xFF000000) == BUF_SPU_BASE) {
-
- buf_element_t *buf;
- int i;
- char *subtitle,*str;
- int lenbytes;
- int start,end;
- uint32_t *val;
-
- for (i = 0, lenbytes = 0; i < hdrlen; i++) {
- lenbytes = lenbytes << 8;
- lenbytes += *((unsigned char *) op->packet + hdrlen - i);
- }
-
- if (op->packet[0] == PACKET_TYPE_HEADER ) {
- lprintf ("Textstream-header-packet\n");
- } else if (op->packet[0] == PACKET_TYPE_COMMENT ) {
- lprintf ("Textstream-comment-packet\n");
- read_language_comment(this, op, stream_num);
- } else {
- subtitle = (char *)&op->packet[hdrlen + 1];
-
- if ((strlen(subtitle) > 1) || (*subtitle != ' ')) {
- start = op->granulepos;
- end = start+lenbytes;
- lprintf ("subtitlestream %d: %d -> %d :%s\n",stream_num,start,end,subtitle);
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
-
- buf->type = this->si[stream_num]->buf_types;
- buf->pts = 0;
-
- val = (uint32_t * )buf->content;
- *val++ = start;
- *val++ = end;
- str = (char *)val;
-
- memcpy (str, subtitle, 1+strlen(subtitle));
-
- this->video_fifo->put (this->video_fifo, buf);
- }
- }
- } else {
- lprintf("unknown stream type %x\n", this->si[stream_num]->buf_types);
- }
-}
-
-static void decode_vorbis_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
- vorbis_info vi;
- vorbis_comment vc;
-
- this->si[stream_num]->buf_types = BUF_AUDIO_VORBIS
- +this->num_audio_streams++;
-
- this->si[stream_num]->headers = 3;
-
- vorbis_info_init(&vi);
- vorbis_comment_init(&vc);
- if (vorbis_synthesis_headerin(&vi, &vc, op) >= 0) {
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, vi.bitrate_nominal);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, vi.rate);
-
- this->si[stream_num]->factor = 90000;
- this->si[stream_num]->quotient = vi.rate;
-
- if (vi.bitrate_nominal<1)
- this->avg_bitrate += 100000; /* assume 100 kbit */
- else
- this->avg_bitrate += vi.bitrate_nominal;
-
- } else {
- this->si[stream_num]->factor = 900;
- this->si[stream_num]->quotient = 441;
-
- this->si[stream_num]->headers = 0;
- xine_log (this->stream->xine, XINE_LOG_MSG,
- _("ogg: vorbis audio track indicated but no vorbis stream header found.\n"));
- }
- vorbis_comment_clear(&vc);
- vorbis_info_clear(&vi);
-}
-
-static void decode_speex_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
-#ifdef HAVE_SPEEX
- void *st;
- SpeexMode *mode;
- SpeexHeader *header;
-
- this->si[stream_num]->buf_types = BUF_AUDIO_SPEEX
- +this->num_audio_streams++;
-
- this->si[stream_num]->headers = 1;
-
- header = speex_packet_to_header (op->packet, op->bytes);
-
- if (header) {
- int bitrate;
- mode = (SpeexMode *) speex_mode_list[header->mode];
-
- st = speex_decoder_init (mode);
-
- speex_decoder_ctl (st, SPEEX_GET_BITRATE, &bitrate);
-
- if (bitrate <= 1)
- bitrate = 16000; /* assume 16 kbit */
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, bitrate);
-
- this->si[stream_num]->factor = 90000;
- this->si[stream_num]->quotient = header->rate;
-
- this->avg_bitrate += bitrate;
-
- lprintf ("detected Speex stream,\trate %d\tbitrate %d\n", header->rate, bitrate);
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, header->rate);
- this->si[stream_num]->headers += header->extra_headers;
- }
-#else
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "Speex stream detected, unable to play\n");
-
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
-#endif
-}
-
-static void decode_video_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
- buf_element_t *buf;
- xine_bmiheader bih;
- int channel;
-
- int16_t locbits_per_sample;
- uint32_t locsubtype;
- int32_t locsize, locdefault_len, locbuffersize, locwidth, locheight;
- int64_t loctime_unit, locsamples_per_unit;
-
- /* read fourcc with machine endianness */
- locsubtype = *((uint32_t *)&op->packet[9]);
-
- /* everything else little endian */
- locsize = LE_32(&op->packet[13]);
- loctime_unit = LE_64(&op->packet[17]);
- locsamples_per_unit = LE_64(&op->packet[25]);
- locdefault_len = LE_32(&op->packet[33]);
- locbuffersize = LE_32(&op->packet[37]);
- locbits_per_sample = LE_16(&op->packet[41]);
- locwidth = LE_32(&op->packet[45]);
- locheight = LE_32(&op->packet[49]);
-
- lprintf ("direct show filter created stream detected, hexdump:\n");
-#ifdef LOG
- xine_hexdump (op->packet, op->bytes);
-#endif
-
- channel = this->num_video_streams++;
-
- this->si[stream_num]->buf_types = _x_fourcc_to_buf_video (locsubtype);
- if( !this->si[stream_num]->buf_types )
- this->si[stream_num]->buf_types = BUF_VIDEO_UNKNOWN;
- this->si[stream_num]->buf_types |= channel;
- this->si[stream_num]->headers = 0; /* header is sent below */
-
- lprintf ("subtype %.4s\n", (char*)&locsubtype);
- lprintf ("time_unit %" PRId64 "\n", loctime_unit);
- lprintf ("samples_per_unit %" PRId64 "\n", locsamples_per_unit);
- lprintf ("default_len %d\n", locdefault_len);
- lprintf ("buffersize %d\n", locbuffersize);
- lprintf ("bits_per_sample %d\n", locbits_per_sample);
- lprintf ("width %d\n", locwidth);
- lprintf ("height %d\n", locheight);
- lprintf ("buf_type %08x\n",this->si[stream_num]->buf_types);
-
- bih.biSize=sizeof(xine_bmiheader);
- bih.biWidth = locwidth;
- bih.biHeight= locheight;
- bih.biPlanes= 0;
- memcpy(&bih.biCompression, &locsubtype, 4);
- bih.biBitCount= 0;
- bih.biSizeImage=locwidth*locheight;
- bih.biXPelsPerMeter=1;
- bih.biYPelsPerMeter=1;
- bih.biClrUsed=0;
- bih.biClrImportant=0;
-
- 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;
- this->frame_duration = loctime_unit * 9 / 1000;
- this->si[stream_num]->factor = loctime_unit * 9;
- this->si[stream_num]->quotient = 1000;
- buf->decoder_info[0] = this->frame_duration;
- memcpy (buf->content, &bih, sizeof (xine_bmiheader));
- buf->size = sizeof (xine_bmiheader);
- buf->type = this->si[stream_num]->buf_types;
-
- /* video metadata */
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_FOURCC, locsubtype);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, locwidth);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, locheight);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->frame_duration);
-
- this->avg_bitrate += 500000; /* FIXME */
-
- this->video_fifo->put (this->video_fifo, buf);
-}
-
-static void decode_audio_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
-
- if (this->audio_fifo) {
- buf_element_t *buf;
- int codec;
- char str[5];
- int channel;
-
- int16_t locbits_per_sample, locchannels, locblockalign;
- int32_t locsize, locdefault_len, locbuffersize, locavgbytespersec;
- int64_t loctime_unit, locsamples_per_unit;
-
- locsize = LE_32(&op->packet[13]);
- loctime_unit = LE_64(&op->packet[17]);
- locsamples_per_unit = LE_64(&op->packet[25]);
- locdefault_len = LE_32(&op->packet[33]);
- locbuffersize = LE_32(&op->packet[37]);
- locbits_per_sample = LE_16(&op->packet[41]);
- locchannels = LE_16(&op->packet[45]);
- locblockalign = LE_16(&op->packet[47]);
- locavgbytespersec= LE_32(&op->packet[49]);
-
- lprintf ("direct show filter created audio stream detected, hexdump:\n");
-#ifdef LOG
- xine_hexdump (op->packet, op->bytes);
-#endif
-
- memcpy(str, &op->packet[9], 4);
- str[4] = 0;
- codec = strtoul(str, NULL, 16);
-
- channel= this->num_audio_streams++;
-
- this->si[stream_num]->buf_types = _x_formattag_to_buf_audio(codec);
- if( this->si[stream_num]->buf_types ) {
- this->si[stream_num]->buf_types |= channel;
- } else {
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "demux_ogg: unknown audio codec type 0x%x\n", codec);
- this->si[stream_num]->buf_types = BUF_AUDIO_UNKNOWN;
- /*break;*/
- }
-
- lprintf ("subtype 0x%x\n", codec);
- lprintf ("time_unit %" PRId64 "\n", loctime_unit);
- lprintf ("samples_per_unit %" PRId64 "\n", locsamples_per_unit);
- lprintf ("default_len %d\n", locdefault_len);
- lprintf ("buffersize %d\n", locbuffersize);
- lprintf ("bits_per_sample %d\n", locbits_per_sample);
- lprintf ("channels %d\n", locchannels);
- lprintf ("blockalign %d\n", locblockalign);
- lprintf ("avgbytespersec %d\n", locavgbytespersec);
- lprintf ("buf_type %08x\n",this->si[stream_num]->buf_types);
-
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = this->si[stream_num]->buf_types;
- buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END;
- buf->decoder_info[0] = 0;
- buf->decoder_info[1] = locsamples_per_unit;
- buf->decoder_info[2] = locbits_per_sample;
- buf->decoder_info[3] = locchannels;
- this->audio_fifo->put (this->audio_fifo, buf);
-
- this->si[stream_num]->headers = 0; /* header already sent */
- this->si[stream_num]->factor = 90000;
- this->si[stream_num]->quotient = locsamples_per_unit;
-
- this->avg_bitrate += locavgbytespersec*8;
-
- /* audio metadata */
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC, codec);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, locchannels);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS, locbits_per_sample);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, locsamples_per_unit);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, locavgbytespersec * 8);
-
- } else /* no audio_fifo there */
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
-}
-
-static void decode_dshow_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
-
- lprintf ("older Direct Show filter-generated stream header detected. Hexdump:\n");
-#ifdef LOG
- xine_hexdump (op->packet, op->bytes);
-#endif
-
- this->si[stream_num]->headers = 0; /* header is sent below */
-
- if ( (LE_32(&op->packet[96]) == 0x05589f80) && (op->bytes >= 184)) {
-
- buf_element_t *buf;
- xine_bmiheader bih;
- int channel;
- uint32_t fcc;
-
- lprintf ("seems to be a video stream.\n");
-
- channel = this->num_video_streams++;
- fcc = *(uint32_t*)(op->packet+68);
- lprintf ("fourcc %08x\n", fcc);
-
- this->si[stream_num]->buf_types = _x_fourcc_to_buf_video (fcc);
- if( !this->si[stream_num]->buf_types )
- this->si[stream_num]->buf_types = BUF_VIDEO_UNKNOWN;
- this->si[stream_num]->buf_types |= channel;
-
- bih.biSize = sizeof(xine_bmiheader);
- bih.biWidth = LE_32(&op->packet[176]);
- bih.biHeight = LE_32(&op->packet[180]);
- bih.biPlanes = 0;
- memcpy (&bih.biCompression, op->packet+68, 4);
- bih.biBitCount = LE_16(&op->packet[182]);
- if (!bih.biBitCount)
- bih.biBitCount = 24; /* FIXME ? */
- bih.biSizeImage = (bih.biBitCount>>3)*bih.biWidth*bih.biHeight;
- bih.biXPelsPerMeter = 1;
- bih.biYPelsPerMeter = 1;
- bih.biClrUsed = 0;
- bih.biClrImportant = 0;
-
- 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;
- this->frame_duration = (*(int64_t*)(op->packet+164)) * 9 / 1000;
- this->si[stream_num]->factor = (*(int64_t*)(op->packet+164)) * 9;
- this->si[stream_num]->quotient = 1000;
-
- buf->decoder_info[0] = this->frame_duration;
- memcpy (buf->content, &bih, sizeof (xine_bmiheader));
- buf->size = sizeof (xine_bmiheader);
- buf->type = this->si[stream_num]->buf_types;
- this->video_fifo->put (this->video_fifo, buf);
-
- lprintf ("subtype %.4s\n", (char*)&fcc);
- lprintf ("buf_type %08x\n", this->si[stream_num]->buf_types);
- lprintf ("video size %d x %d\n", bih.biWidth, bih.biHeight);
- lprintf ("frame duration %d\n", this->frame_duration);
-
- /* video metadata */
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, bih.biWidth);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, bih.biHeight);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->frame_duration);
-
- this->avg_bitrate += 500000; /* FIXME */
-
- this->ignore_keyframes = 1;
-
- } else if (LE_32(&op->packet[96]) == 0x05589F81) {
-
-#if 0
- /* FIXME: no test streams */
-
- buf_element_t *buf;
- int codec;
- char str[5];
- int channel;
- int extra_size;
-
- extra_size = *(int16_t*)(op->packet+140);
- format = *(int16_t*)(op->packet+124);
- channels = *(int16_t*)(op->packet+126);
- samplerate = *(int32_t*)(op->packet+128);
- nAvgBytesPerSec = *(int32_t*)(op->packet+132);
- nBlockAlign = *(int16_t*)(op->packet+136);
- wBitsPerSample = *(int16_t*)(op->packet+138);
- samplesize = (sh_a->wf->wBitsPerSample+7)/8;
- cbSize = extra_size;
- if(extra_size > 0)
- memcpy(wf+sizeof(WAVEFORMATEX),op->packet+142,extra_size);
-#endif
-
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "FIXME, old audio format not handled\n");
-
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
-
- } else {
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "old header detected but stream type is unknown\n");
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
- }
-}
-
-static void decode_text_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
- int channel=0;
- uint32_t *val;
- buf_element_t *buf;
-
- lprintf ("textstream detected.\n");
- this->si[stream_num]->headers = 2;
- channel = this->num_spu_streams++;
- this->si[stream_num]->buf_types = BUF_SPU_OGM | channel;
-
- /*send an empty spu to inform the video_decoder, that there is a stream*/
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- buf->type = this->si[stream_num]->buf_types;
- buf->pts = 0;
- val = (uint32_t * )buf->content;
- *val++=0;
- *val++=0;
- *val++=0;
- this->video_fifo->put (this->video_fifo, buf);
-}
-
-static void decode_theora_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
-
-#ifdef HAVE_THEORA
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "demux_ogg: Theorastreamsupport is highly alpha at the moment\n");
-
- if (theora_decode_header(&this->t_info, &this->t_comment, op) >= 0) {
-
- this->num_video_streams++;
-
- this->si[stream_num]->factor = (int64_t) 90000 * (int64_t) this->t_info.fps_denominator;
-
- if (!this->t_info.fps_numerator) {
- this->t_info.fps_numerator = 1; /* FIXME: default value ? */
- }
- this->si[stream_num]->quotient = this->t_info.fps_numerator;
-
- this->frame_duration = ((int64_t) 90000*this->t_info.fps_denominator);
- this->frame_duration /= this->t_info.fps_numerator;
-
- this->si[stream_num]->granuleshift = intlog(this->t_info.keyframe_frequency_force-1);
-
- this->si[stream_num]->headers=3;
- this->si[stream_num]->buf_types = BUF_VIDEO_THEORA;
-
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "theora");
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, this->t_info.frame_width);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, this->t_info.frame_height);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->frame_duration);
-
- /*currently aspect_nominator and -denumerator are 0?*/
- if (this->t_info.aspect_denominator) {
- int64_t ratio = ((int64_t) this->t_info.aspect_numerator * 10000);
-
- ratio /= this->t_info.aspect_denominator;
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_RATIO, ratio);
- }
-
- lprintf ("decoded theora header \n");
- lprintf ("frameduration %d\n",this->frame_duration);
- lprintf ("w:%d h:%d \n",this->t_info.frame_width,this->t_info.frame_height);
- lprintf ("an:%d ad:%d \n",this->t_info.aspect_numerator,this->t_info.aspect_denominator);
- } else {
- /*Rejected stream*/
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "A theora header was rejected by libtheora\n");
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
- this->si[stream_num]->headers = 0; /* FIXME: don't know */
- }
-#else
- this->si[stream_num]->buf_types = BUF_VIDEO_THEORA;
- this->num_video_streams++;
- this->unhandled_video_streams++;
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "theora");
-#endif
-}
-
-static void decode_flac_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
- xine_flac_metadata_header header;
- xine_flac_streaminfo_block streaminfo;
- buf_element_t *buf;
- xine_waveformatex wave;
-
- /* Packet type */
- _x_assert(op->packet[0] == 0x7F);
-
- /* OggFLAC signature */
- _x_assert(op->packet[1] == 'F'); _x_assert(op->packet[2] == 'L');
- _x_assert(op->packet[3] == 'A'); _x_assert(op->packet[4] == 'C');
-
- /* Version: supported only 1.0 */
- _x_assert(op->packet[5] == 1); _x_assert(op->packet[6] == 0);
-
- /* Header count */
- this->si[stream_num]->headers = 0/*BE_16(&op->packet[7]) +1*/;
-
- /* fLaC signature */
- _x_assert(op->packet[9] == 'f'); _x_assert(op->packet[10] == 'L');
- _x_assert(op->packet[11] == 'a'); _x_assert(op->packet[12] == 'C');
-
- _x_parse_flac_metadata_header(&op->packet[13], &header);
-
- switch ( header.blocktype ) {
- case FLAC_BLOCKTYPE_STREAMINFO:
- _x_assert(header.length == FLAC_STREAMINFO_SIZE);
- _x_parse_flac_streaminfo_block(&op->packet[17], &streaminfo);
- break;
- }
-
- this->si[stream_num]->buf_types = BUF_AUDIO_FLAC
- +this->num_audio_streams++;
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, streaminfo.samplerate);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, streaminfo.channels);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS, streaminfo.bits_per_sample);
-
- this->si[stream_num]->factor = 90000;
-
- buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo);
-
- buf->type = BUF_AUDIO_FLAC;
- buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END;
-
- buf->decoder_info[0] = 0;
- buf->decoder_info[1] = streaminfo.samplerate;
- buf->decoder_info[2] = streaminfo.bits_per_sample;
- buf->decoder_info[3] = streaminfo.channels;
- buf->size = sizeof(xine_waveformatex) + FLAC_STREAMINFO_SIZE;
- memcpy(buf->content+sizeof(xine_waveformatex), &op->packet[17], FLAC_STREAMINFO_SIZE);
- xine_hexdump(&op->packet[17], FLAC_STREAMINFO_SIZE);
- wave.cbSize = FLAC_STREAMINFO_SIZE;
- memcpy(buf->content, &wave, sizeof(xine_waveformatex));
-
- this->audio_fifo->put(this->audio_fifo, buf);
-
- /* Skip the Ogg framing info */
- op->bytes -= 9;
- op->packet += 9;
-}
-
-static void decode_annodex_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
- lprintf ("Annodex stream detected\n");
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
- this->si[stream_num]->headers = 1;
- this->si[stream_num]->header_granulepos = op->granulepos;
- _x_meta_info_set(this->stream, XINE_META_INFO_SYSTEMLAYER, "Annodex");
-}
-
-static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
- int64_t granule_rate_n, granule_rate_d;
- uint32_t secondary_headers;
- char content_type[1024];
- int content_type_length;
-
- lprintf("AnxData stream detected\n");
-
- /* read granule rate */
- granule_rate_n = LE_64(&op->packet[8]);
- granule_rate_d = LE_64(&op->packet[16]);
- secondary_headers = LE_32(&op->packet[24]);
-
- lprintf("granule_rate %" PRId64 "/%" PRId64 ", %d secondary headers\n",
- granule_rate_n, granule_rate_d, secondary_headers);
-
- /* read "Content-Tyoe" MIME header */
- sscanf(&op->packet[28], "Content-Type: %1023s\r\n", content_type);
- content_type_length = strlen(content_type);
-
- lprintf("Content-Type: %s (length:%d)\n", content_type, content_type_length);
-
- /* how many header packets in the AnxData stream? */
- this->si[stream_num]->headers = secondary_headers + 1;
- this->si[stream_num]->hide_first_header = 1;
-
- /* set factor and quotient */
- this->si[stream_num]->factor = (int64_t) 90000 * granule_rate_d;
- this->si[stream_num]->quotient = granule_rate_n;
-
- lprintf("factor: %" PRId64 ", quotient: %" PRId64 "\n",
- this->si[stream_num]->factor, this->si[stream_num]->quotient);
-
- /* what type of stream are we dealing with? */
- if (!strncmp(content_type, "audio/x-vorbis", content_type_length)) {
- this->si[stream_num]->buf_types = BUF_AUDIO_VORBIS;
- this->num_audio_streams++;
- } else if (!strncmp(content_type, "audio/x-speex", content_type_length)) {
- this->num_audio_streams++;
-#ifdef HAVE_SPEEX
- this->si[stream_num]->buf_types = BUF_AUDIO_SPEEX;
-#else
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
-#endif
- } else if (!strncmp(content_type, "video/x-theora", content_type_length)) {
- this->num_video_streams++;
-#ifdef HAVE_THEORA
- this->si[stream_num]->buf_types = BUF_VIDEO_THEORA;
-#else
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
-#endif
- } else if (!strncmp(content_type, "text/x-cmml", content_type_length)) {
- unsigned int channel = this->num_spu_streams++;
- this->si[stream_num]->headers = 0;
- this->si[stream_num]->buf_types = BUF_SPU_CMML | channel;
- this->si[stream_num]->granuleshift = 0;
- } else {
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
- }
-
-}
-
-static void decode_cmml_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
- unsigned int channel = this->num_spu_streams++;
- this->si[stream_num]->headers = 0;
- this->si[stream_num]->buf_types = BUF_SPU_CMML | channel;
-
- this->si[stream_num]->factor = 90000 * LE_64(&op->packet[20]);
- this->si[stream_num]->quotient = LE_64(&op->packet[12]);
- this->si[stream_num]->granuleshift = (int)op->packet[28];
-}
-
-/*
- * interpret stream start packages, send headers
- */
-static void send_header (demux_ogg_t *this) {
-
- int stream_num = -1;
- int cur_serno;
- int done = 0;
- ogg_packet op;
- xine_event_t ui_event;
-
- lprintf ("detecting stream types...\n");
-
- this->ignore_keyframes = 0;
-
- while (!done) {
- if (!read_ogg_packet(this)) {
- this->status = DEMUX_FINISHED;
- return;
- }
- /* now we've got at least one new page */
-
- cur_serno = ogg_page_serialno (&this->og);
-
- if (ogg_page_bos(&this->og)) {
- lprintf ("beginning of stream\n");
- lprintf ("serial number %d\n", cur_serno);
-
- if( this->num_streams == MAX_STREAMS ) {
- xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "demux_ogg: MAX_STREAMS exceeded, aborting.\n");
- this->status = DEMUX_FINISHED;
- return;
- }
- stream_num = new_stream_info(this, cur_serno);
-
- } else {
- stream_num = get_stream(this, cur_serno);
- if (stream_num == -1) {
- xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "demux_ogg: stream with no beginning!\n");
- this->status = DEMUX_FINISHED;
- return;
- }
- }
-
- ogg_stream_pagein(&this->si[stream_num]->oss, &this->og);
-
- while (ogg_stream_packetout(&this->si[stream_num]->oss, &op) == 1) {
-
- if (!this->si[stream_num]->buf_types) {
-
- /* detect buftype */
- if (!strncmp (&op.packet[1], "vorbis", 6)) {
- decode_vorbis_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[0], "Speex", 5)) {
- decode_speex_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[1], "video", 5)) {
- decode_video_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[1], "audio", 5)) {
- decode_audio_header(this, stream_num, &op);
- } else if (op.bytes >= 142
- && !strncmp (&op.packet[1], "Direct Show Samples embedded in Ogg", 35) ) {
- decode_dshow_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[1], "text", 4)) {
- decode_text_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[1], "theora", 6)) {
- decode_theora_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[1], "FLAC", 4)) {
- decode_flac_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[0], "Annodex", 7)) {
- decode_annodex_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[0], "AnxData", 7)) {
- decode_anxdata_header(this, stream_num, &op);
- } else if (!strncmp (&op.packet[0], "CMML", 4)) {
- decode_cmml_header(this, stream_num, &op);
- } else {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "demux_ogg: unknown stream type (signature >%.8s<). hex dump of bos packet follows:\n",
- op.packet);
- if(this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- xine_hexdump (op.packet, op.bytes);
-
- this->si[stream_num]->buf_types = BUF_CONTROL_NOP;
- }
- }
-
- /* send preview buffer */
- if (this->si[stream_num]->headers > 0 ||
- op.packet[0] == PACKET_TYPE_COMMENT) {
- if (this->si[stream_num]->hide_first_header)
- this->si[stream_num]->hide_first_header = 0;
- else {
- lprintf ("sending preview buffer of stream type %08x\n",
- this->si[stream_num]->buf_types);
-
- send_ogg_buf (this, &op, stream_num, BUF_FLAG_HEADER);
- this->si[stream_num]->headers --;
- }
- }
-
- /* are we finished ? */
- if (!ogg_page_bos(&this->og)) {
- int i;
- done = 1;
-
- for (i=0; i<this->num_streams; i++) {
- if (this->si[i]->headers > 0)
- done = 0;
-
- llprintf(DEBUG_PREVIEWS,
- "%d preview buffers left to send from stream %d\n",
- this->si[i]->headers, i);
- }
- }
- }
- }
-
- ui_event.type = XINE_EVENT_UI_CHANNELS_CHANGED;
- ui_event.data_length = 0;
- xine_event_send(this->stream, &ui_event);
-
- /*get the streamlength*/
- get_stream_length (this);
-
-}
-
-static int demux_ogg_send_chunk (demux_plugin_t *this_gen) {
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
-
- int stream_num;
- int cur_serno;
-
- ogg_packet op;
-
- ogg_handle_event(this);
-
- llprintf(DEBUG_PACKETS, "send package...\n");
-
- if (!read_ogg_packet(this)) {
- this->status = DEMUX_FINISHED;
- lprintf ("EOF\n");
- return this->status;
- }
-
- /* now we've got one new page */
-
- cur_serno = ogg_page_serialno (&this->og);
- stream_num = get_stream(this, cur_serno);
- if (stream_num < 0) {
- lprintf ("error: unknown stream, serialnumber %d\n", cur_serno);
-
- if (!ogg_page_bos(&this->og)) {
- lprintf ("help, stream with no beginning!\n");
- }
- lprintf ("adding late stream with serial number %d (all content will be discarded)\n", cur_serno);
-
- if( this->num_streams == MAX_STREAMS ) {
- xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "demux_ogg: MAX_STREAMS exceeded, aborting.\n");
- this->status = DEMUX_FINISHED;
- return this->status;
- }
- stream_num = new_stream_info(this, cur_serno);
- }
-
- ogg_stream_pagein(&this->si[stream_num]->oss, &this->og);
-
- if (ogg_page_bos(&this->og)) {
- lprintf ("beginning of stream: serial number %d - discard\n",
- ogg_page_serialno (&this->og));
- while (ogg_stream_packetout(&this->si[stream_num]->oss, &op) == 1) ;
- return this->status;
- }
-
- /*while keyframeseeking only process videostream*/
- if (!this->ignore_keyframes && this->keyframe_needed
- && ((this->si[stream_num]->buf_types & 0xFF000000) != BUF_VIDEO_BASE))
- return this->status;
-
- while (ogg_stream_packetout(&this->si[stream_num]->oss, &op) == 1) {
- /* printf("demux_ogg: packet: %.8s\n", op.packet); */
- /* printf("demux_ogg: got a packet\n"); */
-
- if ((*op.packet & PACKET_TYPE_HEADER) &&
- (this->si[stream_num]->buf_types!=BUF_VIDEO_THEORA) && (this->si[stream_num]->buf_types!=BUF_AUDIO_SPEEX) && (this->si[stream_num]->buf_types!=BUF_AUDIO_FLAC)) {
- if (op.granulepos != -1) {
- this->si[stream_num]->header_granulepos = op.granulepos;
- lprintf ("header with granulepos, remembering granulepos\n");
- } else {
- lprintf ("header => discard\n");
- }
- continue;
- }
-
- /*discard granulepos-less packets and to early audiopackets*/
- if (this->si[stream_num]->resync) {
- if ((this->si[stream_num]->buf_types & 0xFF000000) == BUF_SPU_BASE) {
- /*never drop subtitles*/
- this->si[stream_num]->resync=0;
- } else if ((op.granulepos == -1) && (this->si[stream_num]->header_granulepos == -1)) {
- continue;
- } else {
-
- /*dump too early packets*/
- if ((get_pts(this,stream_num,op.granulepos)-this->start_pts) > -90000)
- this->si[stream_num]->resync=0;
- else
- continue;
- }
- }
-
- if (!this->ignore_keyframes && this->keyframe_needed) {
- lprintf ("keyframe needed... buf_type=%08x\n", this->si[stream_num]->buf_types);
- if (this->si[stream_num]->buf_types == BUF_VIDEO_THEORA) {
-#ifdef HAVE_THEORA
-
- int keyframe_granule_shift;
- int64_t pframe=-1,iframe=-1;
-
- keyframe_granule_shift = this->si[stream_num]->granuleshift;
-
- if(op.granulepos>=0){
- iframe=op.granulepos>>keyframe_granule_shift;
- pframe=op.granulepos-(iframe<<keyframe_granule_shift);
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "seeking keyframe i %" PRId64 " p %" PRId64 "\n", iframe, pframe);
- if (pframe!=0)
- continue;
- } else
- continue;
- this->keyframe_needed = 0;
- this->start_pts=get_pts(this,stream_num,op.granulepos);
-#endif
- } else if ((this->si[stream_num]->buf_types & 0xFF000000) == BUF_VIDEO_BASE) {
-
- /*calculate the current pts*/
- if (op.granulepos!=-1) {
- this->start_pts=get_pts(this, stream_num, op.granulepos);
- } else if (this->start_pts!=-1)
- this->start_pts=this->start_pts+this->frame_duration;
-
- /*seek the keyframe*/
- if ((*op.packet == PACKET_IS_SYNCPOINT) && (this->start_pts!=-1))
- this->keyframe_needed = 0;
- else
- continue;
-
- } else if ((this->si[stream_num]->buf_types & 0xFF000000) == BUF_VIDEO_BASE) continue;
- }
- send_ogg_buf (this, &op, stream_num, 0);
-
- /*delete used header_granulepos*/
- if (op.granulepos == -1)
- this->si[stream_num]->header_granulepos = -1;
-
- }
- if (ogg_page_eos(&this->og)) {
- int i;
- int finished_streams = 0;
-
- lprintf("end of stream, serialnumber %d\n", cur_serno);
- this->si[stream_num]->delivered_eos = 1;
-
- /* check if all logical streams are finished */
- for (i = 0; i < this->num_streams; i++) {
- finished_streams += this->si[i]->delivered_eos;
- }
-
- /* if all streams are finished, perhaps a chained stream follows */
- if (finished_streams == this->num_streams) {
- /* delete current logical streams */
- for (i = 0; i < this->num_streams; i++) {
- ogg_stream_clear(&this->si[i]->oss);
- if (this->si[i]->language) {
- free (this->si[i]->language);
- }
- free (this->si[i]);
- }
- this->num_streams = 0;
- this->num_audio_streams = 0;
- this->num_video_streams = 0;
- this->unhandled_video_streams = 0;
- this->num_spu_streams = 0;
- this->avg_bitrate = 1;
-
- /* try to read a chained stream */
- this->send_newpts = 1;
- this->last_pts[0] = 0;
- this->last_pts[1] = 0;
-
- /* send control buffer to avoid buffer leak */
- _x_demux_control_end(this->stream, 0);
- _x_demux_control_start(this->stream);
- send_header(this);
- }
- }
-
- return this->status;
-}
-
-static void demux_ogg_dispose (demux_plugin_t *this_gen) {
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
- int i;
-
- for (i=0; i<this->num_streams; i++) {
- ogg_stream_clear(&this->si[i]->oss);
-
- if (this->si[i]->language) {
- free (this->si[i]->language);
- }
- free(this->si[i]);
- }
-
- ogg_sync_clear(&this->oy);
-
-#ifdef HAVE_THEORA
- theora_comment_clear (&this->t_comment);
- theora_info_clear (&this->t_info);
-#endif
-
- if (this->chapter_info){
- free (this->chapter_info->entries);
- free (this->chapter_info);
- }
- if (this->title){
- free (this->title);
- }
- if (this->event_queue)
- xine_event_dispose_queue (this->event_queue);
-
- free (this);
-}
-
-static int demux_ogg_get_status (demux_plugin_t *this_gen) {
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
-
- return this->status;
-}
-
-static void demux_ogg_send_headers (demux_plugin_t *this_gen) {
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
-
- this->video_fifo = this->stream->video_fifo;
- this->audio_fifo = this->stream->audio_fifo;
-
- this->status = DEMUX_OK;
-
- /*
- * send start buffers
- */
-
- this->last_pts[0] = 0;
- this->last_pts[1] = 0;
-
- /*
- * initialize ogg engine
- */
- ogg_sync_init(&this->oy);
-
- this->num_streams = 0;
- this->num_audio_streams = 0;
- this->num_video_streams = 0;
- this->num_spu_streams = 0;
- this->avg_bitrate = 1;
-
- this->input->seek (this->input, 0, SEEK_SET);
-
- if (this->status == DEMUX_OK) {
- _x_demux_control_start(this->stream);
- send_header (this);
- lprintf ("headers sent, avg bitrate is %" PRId64 "\n", this->avg_bitrate);
- }
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO,
- this->num_video_streams > 0);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED,
- this->num_video_streams > this->unhandled_video_streams);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO,
- this->num_audio_streams > 0);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_MAX_SPU_CHANNEL,
- this->num_spu_streams);
-}
-
-static int demux_ogg_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time, int playing) {
-
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
- int i;
- start_time /= 1000;
- start_pos = (off_t) ( (double) start_pos / 65535 *
- this->input->get_length (this->input) );
- /*
- * seek to start position
- */
-
- if (INPUT_IS_SEEKABLE(this->input)) {
-
- this->keyframe_needed = (this->num_video_streams>0);
-
- if ( (!start_pos) && (start_time)) {
- if (this->time_length != -1) {
- /*do the seek via time*/
- int current_time=-1;
- off_t current_pos;
- current_pos=this->input->get_current_pos(this->input);
-
- /*try to find out the current time*/
- if (this->last_pts[PTS_VIDEO]) {
- current_time=this->last_pts[PTS_VIDEO]/90000;
- } else if (this->last_pts[PTS_AUDIO]) {
- current_time=this->last_pts[PTS_AUDIO]/90000;
- }
-
- /*fixme, the file could grow, do something
- about this->time_length using get_lenght to verify, that the stream
- hasn` changed its length, otherwise no seek to "new" data is possible*/
-
- lprintf ("seek to time %d called\n",start_time);
- lprintf ("current time is %d\n",current_time);
-
- if (current_time > start_time) {
- /*seek between beginning and current_pos*/
-
- /*fixme - sometimes we seek backwards and during
- keyframeseeking, we undo the seek*/
-
- start_pos = start_time * current_pos
- / current_time ;
- } else {
- /*seek between current_pos and end*/
- start_pos = current_pos +
- ((start_time - current_time) *
- ( this->input->get_length(this->input) - current_pos ) /
- ( (this->time_length / 1000) - current_time)
- );
- }
-
- lprintf ("current_pos is %" PRId64 "\n",current_pos);
- lprintf ("new_pos is %" PRId64 "\n",start_pos);
-
- } else {
- /*seek using avg_bitrate*/
- start_pos = start_time * this->avg_bitrate/8;
- }
-
- lprintf ("seeking to %d seconds => %" PRId64 " bytes\n",
- start_time, start_pos);
-
- }
-
- ogg_sync_reset(&this->oy);
-
- for (i=0; i<this->num_streams; i++) {
- this->si[i]->header_granulepos = -1;
- ogg_stream_reset(&this->si[i]->oss);
- }
-
- /*some strange streams have no syncpoint flag set at the beginning*/
- if (start_pos == 0)
- this->keyframe_needed = 0;
-
- lprintf ("seek to %" PRId64 " called\n",start_pos);
-
- this->input->seek (this->input, start_pos, SEEK_SET);
-
- }
-
- /* fixme - this would be a nice position to do the following tasks
- 1. adjust an ogg videostream to a keyframe
- 2. compare the keyframe_pts with start_time. if the difference is to
- high (e.g. larger than max keyframe_intervall, do a new seek or
- continue reading
- 3. adjust the audiostreams in such a way, that the
- difference is not to high.
-
- In short words, do all the cleanups necessary to continue playback
- without further actions
- */
-
- this->send_newpts = 1;
- this->status = DEMUX_OK;
-
- if( !playing ) {
-
- this->buf_flag_seek = 0;
-
- } else {
- if (start_pos!=0) {
- this->buf_flag_seek = 1;
- /*each stream has to continue with a packet that has an
- granulepos*/
- for (i=0; i<this->num_streams; i++) {
- this->si[i]->resync = 1;
- }
-
- this->start_pts=-1;
- }
-
- _x_demux_flush_engine(this->stream);
- }
-
- return this->status;
-}
-
-static int demux_ogg_get_stream_length (demux_plugin_t *this_gen) {
-
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
-
- if (this->time_length==-1){
- if (this->avg_bitrate) {
- return (int)((int64_t)1000 * this->input->get_length (this->input) * 8 /
- this->avg_bitrate);
- } else {
- return 0;
- }
- } else {
- return this->time_length;
- }
-}
-
-static uint32_t demux_ogg_get_capabilities(demux_plugin_t *this_gen) {
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
- int cap_chapter = 0;
-
- if (this->chapter_info)
- cap_chapter = DEMUX_CAP_CHAPTERS;
-
- return DEMUX_CAP_SPULANG | DEMUX_CAP_AUDIOLANG | cap_chapter;
-}
-
-static int format_lang_string (demux_ogg_t * this, uint32_t buf_mask, uint32_t buf_type, int channel, char *str) {
- int stream_num;
-
- for (stream_num=0; stream_num<this->num_streams; stream_num++) {
- if ((this->si[stream_num]->buf_types & buf_mask) == buf_type) {
- if (this->si[stream_num]->language) {
- if (snprintf (str, XINE_LANG_MAX, "%s", this->si[stream_num]->language) >= XINE_LANG_MAX)
- /* the string got truncated */
- str[XINE_LANG_MAX - 2] = str[XINE_LANG_MAX - 3] = str[XINE_LANG_MAX - 4] = '.';
- /* TODO: provide long version in XINE_META_INFO_FULL_LANG */
- } else {
- snprintf(str, XINE_LANG_MAX, "channel %d",channel);
- }
- return DEMUX_OPTIONAL_SUCCESS;
- }
- }
- return DEMUX_OPTIONAL_UNSUPPORTED;
-}
-
-static int demux_ogg_get_optional_data(demux_plugin_t *this_gen,
- void *data, int data_type) {
-
- demux_ogg_t *this = (demux_ogg_t *) this_gen;
-
- char *str=(char *) data;
- int channel = *((int *)data);
-
- switch (data_type) {
- case DEMUX_OPTIONAL_DATA_SPULANG:
- lprintf ("DEMUX_OPTIONAL_DATA_SPULANG channel = %d\n",channel);
- if (channel==-1) {
- strcpy( str, "none");
- return DEMUX_OPTIONAL_SUCCESS;
- } else if ((channel>=0) && (channel<this->num_streams)) {
- return format_lang_string (this, 0xFFFFFFFF, BUF_SPU_OGM+channel, channel, str);
- }
- return DEMUX_OPTIONAL_UNSUPPORTED;
- case DEMUX_OPTIONAL_DATA_AUDIOLANG:
- lprintf ("DEMUX_OPTIONAL_DATA_AUDIOLANG channel = %d\n",channel);
- if (channel==-1) {
- return format_lang_string (this, 0xFF00001F, BUF_AUDIO_BASE, channel, str);
- } else if ((channel>=0) && (channel<this->num_streams)) {
- return format_lang_string (this, 0xFF00001F, BUF_AUDIO_BASE+channel, channel, str);
- }
- return DEMUX_OPTIONAL_UNSUPPORTED;
- default:
- return DEMUX_OPTIONAL_UNSUPPORTED;
- }
-}
-
-static int detect_ogg_content (int detection_method, demux_class_t *class_gen,
- input_plugin_t *input) {
-
- switch (detection_method) {
-
- case METHOD_BY_CONTENT: {
- uint8_t buf[4];
-
- if (_x_demux_read_header(input, buf, 4) != 4)
- return 0;
-
- if ((buf[0] == 'O') && (buf[1] == 'g') && (buf[2] == 'g') &&
- (buf[3] == 'S'))
- return 1;
- else
- return 0;
- }
-
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (_x_demux_check_extension (mrl, extensions))
- return 1;
- else
- return 0;
- }
-
- case METHOD_EXPLICIT:
- return 1;
-
- default:
- return 0;
- }
-}
-
-static int detect_anx_content (int detection_method, demux_class_t *class_gen,
- input_plugin_t *input) {
-
- if (detect_ogg_content(detection_method, class_gen, input) == 0)
- return 0;
-
- switch (detection_method) {
-
-#define ANNODEX_SIGNATURE_SEARCH 128
-
- case METHOD_BY_CONTENT: {
- uint8_t buf[ANNODEX_SIGNATURE_SEARCH];
- int found_annodex_signature = 0;
- const char *annodex_signature = "Annodex";
- int annodex_signature_length = 7; /* = strlen(annodex_signature) */
- int i, j;
-
- if (_x_demux_read_header(input, buf, ANNODEX_SIGNATURE_SEARCH) !=
- ANNODEX_SIGNATURE_SEARCH)
- return 0;
-
- /* scan for 'Annodex' signature in the first 64 bytes */
- for (i = 0, j = 0; i < ANNODEX_SIGNATURE_SEARCH; i++) {
- if (buf[i] == annodex_signature[j]) {
- if (j >= annodex_signature_length) {
- /* found signature */
- found_annodex_signature = 1;
- break;
- } else {
- j++;
- }
- }
- }
-
- if (found_annodex_signature)
- return 1;
- else
- return 0;
- }
-
-#undef ANNODEX_SIGNATURE_SEARCH
-
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (_x_demux_check_extension (mrl, extensions))
- return 1;
- else
- return 0;
- }
-
- case METHOD_EXPLICIT:
- return 1;
-
- default:
- return 0;
- }
-}
-
-static demux_plugin_t *anx_open_plugin (demux_class_t *class_gen,
- xine_stream_t *stream,
- input_plugin_t *input) {
-
- demux_ogg_t *this;
-
- if (detect_anx_content(stream->content_detection_method, class_gen, input) == 0)
- return NULL;
-
- /*
- * if we reach this point, the input has been accepted.
- */
-
- this = xine_xmalloc (sizeof (demux_ogg_t));
- memset (this, 0, sizeof(demux_ogg_t));
- this->stream = stream;
- this->input = input;
-
- /* the Annodex demuxer currently calls into exactly the same functions as
- * the Ogg demuxer, which seems to make this function a bit redundant, but
- * this design leaves us a bit more room to change an Annodex demuxer's
- * behaviour in the future if necessary */
- this->demux_plugin.send_headers = demux_ogg_send_headers;
- this->demux_plugin.send_chunk = demux_ogg_send_chunk;
- this->demux_plugin.seek = demux_ogg_seek;
- this->demux_plugin.dispose = demux_ogg_dispose;
- this->demux_plugin.get_status = demux_ogg_get_status;
- this->demux_plugin.get_stream_length = demux_ogg_get_stream_length;
- this->demux_plugin.get_capabilities = demux_ogg_get_capabilities;
- this->demux_plugin.get_optional_data = demux_ogg_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
-
- this->status = DEMUX_FINISHED;
-
-#ifdef HAVE_THEORA
- theora_info_init (&this->t_info);
- theora_comment_init (&this->t_comment);
-#endif
-
- this->chapter_info = 0;
- this->title = 0;
- this->event_queue = xine_event_new_queue (this->stream);
-
- return &this->demux_plugin;
-}
-
-static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen,
- xine_stream_t *stream,
- input_plugin_t *input) {
-
- demux_ogg_t *this;
-
- if (detect_ogg_content(stream->content_detection_method, class_gen, input) == 0)
- return NULL;
-
- /*
- * if we reach this point, the input has been accepted.
- */
-
- this = xine_xmalloc (sizeof (demux_ogg_t));
- memset (this, 0, sizeof(demux_ogg_t));
- this->stream = stream;
- this->input = input;
-
- this->demux_plugin.send_headers = demux_ogg_send_headers;
- this->demux_plugin.send_chunk = demux_ogg_send_chunk;
- this->demux_plugin.seek = demux_ogg_seek;
- this->demux_plugin.dispose = demux_ogg_dispose;
- this->demux_plugin.get_status = demux_ogg_get_status;
- this->demux_plugin.get_stream_length = demux_ogg_get_stream_length;
- this->demux_plugin.get_capabilities = demux_ogg_get_capabilities;
- this->demux_plugin.get_optional_data = demux_ogg_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
-
- this->status = DEMUX_FINISHED;
-
-#ifdef HAVE_THEORA
- theora_info_init (&this->t_info);
- theora_comment_init (&this->t_comment);
-#endif
-
- this->chapter_info = 0;
- this->title = 0;
- this->event_queue = xine_event_new_queue (this->stream);
-
- return &this->demux_plugin;
-}
-
-/*
- * Annodex demuxer class
- */
-
-static const char *anx_get_description (demux_class_t *this_gen) {
- return "Annodex demux plugin";
-}
-
-static const char *anx_get_identifier (demux_class_t *this_gen) {
- return "Annodex";
-}
-
-static const char *anx_get_extensions (demux_class_t *this_gen) {
- return "anx axa axv";
-}
-
-static const char *anx_get_mimetypes (demux_class_t *this_gen) {
- return "application/x-annodex: ogg: Annodex media;";
-}
-
-static void anx_class_dispose (demux_class_t *this_gen) {
- demux_anx_class_t *this = (demux_anx_class_t *) this_gen;
-
- free (this);
-}
-
-static void *anx_init_class (xine_t *xine, void *data) {
- demux_anx_class_t *this;
-
- this = xine_xmalloc (sizeof (demux_anx_class_t));
-
- this->demux_class.open_plugin = anx_open_plugin;
- this->demux_class.get_description = anx_get_description;
- this->demux_class.get_identifier = anx_get_identifier;
- this->demux_class.get_mimetypes = anx_get_mimetypes;
- this->demux_class.get_extensions = anx_get_extensions;
- this->demux_class.dispose = anx_class_dispose;
-
- return this;
-}
-
-/*
- * ogg demuxer class
- */
-
-static const char *ogg_get_description (demux_class_t *this_gen) {
- return "OGG demux plugin";
-}
-
-static const char *ogg_get_identifier (demux_class_t *this_gen) {
- return "OGG";
-}
-
-static const char *ogg_get_extensions (demux_class_t *this_gen) {
- return "ogg ogm spx";
-}
-
-static const char *ogg_get_mimetypes (demux_class_t *this_gen) {
- return "audio/x-ogg: ogg: OggVorbis Audio;"
- "audio/x-speex: ogg: Speex Audio;"
- "application/x-ogg: ogg: Ogg Stream;"
- "application/ogg: ogg: Ogg Stream;";
-}
-
-static void ogg_class_dispose (demux_class_t *this_gen) {
- demux_ogg_class_t *this = (demux_ogg_class_t *) this_gen;
-
- free (this);
-}
-
-static void *ogg_init_class (xine_t *xine, void *data) {
- demux_ogg_class_t *this;
-
- this = xine_xmalloc (sizeof (demux_ogg_class_t));
-
- this->demux_class.open_plugin = ogg_open_plugin;
- this->demux_class.get_description = ogg_get_description;
- this->demux_class.get_identifier = ogg_get_identifier;
- this->demux_class.get_mimetypes = ogg_get_mimetypes;
- this->demux_class.get_extensions = ogg_get_extensions;
- this->demux_class.dispose = ogg_class_dispose;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-static const demuxer_info_t demux_info_anx = {
- 20 /* priority */
-};
-
-static const demuxer_info_t demux_info_ogg = {
- 10 /* priority */
-};
-
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "ogg", XINE_VERSION_CODE, &demux_info_ogg, ogg_init_class },
- { PLUGIN_DEMUX, 26, "anx", XINE_VERSION_CODE, &demux_info_anx, anx_init_class },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/demuxers/demux_playlist.c b/src/demuxers/demux_playlist.c
new file mode 100644
index 000000000..3dd689657
--- /dev/null
+++ b/src/demuxers/demux_playlist.c
@@ -0,0 +1,719 @@
+/*
+ * Copyright (C) 2007 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ *
+ * Playlist parser/demuxer by
+ * Claudio Ciccani (klan@users.sourceforge.net)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#define LOG_MODULE "demux_playlist"
+#define LOG_VERBOSE
+/*
+#define LOG
+*/
+
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include "bswap.h"
+#include <xine/demux.h>
+
+typedef enum {
+ XINE_PLT_NONE = 0,
+ XINE_PLT_REF = ME_FOURCC('R','E','F',0),
+ XINE_PLT_M3U = ME_FOURCC('M','3','U',0),
+ XINE_PLT_RAM = ME_FOURCC('R','A','M',0),
+ XINE_PLT_PLS = ME_FOURCC('P','L','S',0),
+ XINE_PLT_ASX = ME_FOURCC('A','S','X',0),
+ XINE_PLT_SMI = ME_FOURCC('S','M','I',0),
+ XINE_PLT_QTL = ME_FOURCC('Q','T','L',0),
+ XINE_PLT_XSPF = ME_FOURCC('X','S','P',0),
+ XINE_PLT_RSS = ME_FOURCC('R','S','S',0)
+} playlist_t;
+
+typedef struct {
+ demux_plugin_t demux_plugin;
+
+ xine_t *xine;
+ xine_stream_t *stream;
+ input_plugin_t *input;
+
+ playlist_t playlist;
+
+ int status;
+} demux_playlist_t;
+
+typedef struct {
+ demux_class_t demux_class;
+} demux_playlist_class_t;
+
+
+static playlist_t detect_by_extension (input_plugin_t *input) {
+ char *ext;
+
+ ext = strrchr (input->get_mrl (input), '.');
+ if (!ext)
+ return XINE_PLT_NONE;
+
+ if (!strcasecmp (ext, ".m3u"))
+ return XINE_PLT_M3U;
+ if (!strcasecmp (ext, ".ram"))
+ return XINE_PLT_RAM;
+ if (!strcasecmp (ext, ".pls"))
+ return XINE_PLT_PLS;
+ if (!strcasecmp (ext, ".wax") ||
+ !strcasecmp (ext, ".wvx") ||
+ !strcasecmp (ext, ".asx"))
+ return XINE_PLT_ASX;
+ if (!strcasecmp (ext, ".smi") ||
+ !strcasecmp (ext, ".smil"))
+ return XINE_PLT_SMI;
+ if (!strcasecmp (ext, ".qtl"))
+ return XINE_PLT_QTL;
+ if (!strcasecmp (ext, ".xspf"))
+ return XINE_PLT_XSPF;
+ if (!strcasecmp (ext, ".rss"))
+ return XINE_PLT_RSS;
+
+ return XINE_PLT_NONE;
+}
+
+static playlist_t detect_by_content (input_plugin_t *input) {
+ char buf[256], *tmp;
+ int len;
+
+ len = _x_demux_read_header (input, buf, sizeof(buf)-1);
+ if (len <= 0)
+ return XINE_PLT_NONE;
+ buf[len] = '\0';
+
+ tmp = buf;
+ while (*tmp && isspace(*tmp))
+ tmp++;
+
+ if (!strncmp (tmp, "[Reference]", 11) ||
+ !strncmp (tmp, "Ref1=", 5))
+ return XINE_PLT_REF;
+ if (!strncmp (tmp, "#EXTM3U", 7))
+ return XINE_PLT_M3U;
+ if (!strncmp (tmp, "file://", 7) ||
+ !strncmp (tmp, "http://", 7) ||
+ !strncmp (tmp, "rtsp://", 7) ||
+ !strncmp (tmp, "pnm://", 6))
+ return XINE_PLT_RAM;
+ if (!strncmp (tmp, "[Playlist]", 10 ))
+ return XINE_PLT_PLS;
+ if (!strncasecmp (tmp, "<ASX", 4))
+ return XINE_PLT_ASX;
+ if (!strncmp (tmp, "<smil", 5))
+ return XINE_PLT_SMI;
+ if (!strncmp (tmp, "<?quicktime", 11))
+ return XINE_PLT_QTL;
+ if (!strncmp (tmp, "<playlist", 9))
+ return XINE_PLT_XSPF;
+ if (!strncmp (tmp, "<rss", 4))
+ return XINE_PLT_RSS;
+
+ if (!strncmp (tmp, "<?xml", 5)) {
+ tmp += 5;
+ while ((tmp = strchr (tmp, '<'))) {
+ if (!strncasecmp (tmp, "<ASX", 4))
+ return XINE_PLT_ASX;
+ if (!strncmp (tmp, "<smil", 5))
+ return XINE_PLT_SMI;
+ if (!strncmp (tmp, "<?quicktime", 11))
+ return XINE_PLT_QTL;
+ if (!strncmp (tmp, "<playlist", 9))
+ return XINE_PLT_XSPF;
+ if (!strncmp (tmp, "<rss", 4))
+ return XINE_PLT_RSS;
+ tmp++;
+ }
+ }
+
+ return XINE_PLT_NONE;
+}
+
+static char* trim (char *s) {
+ char *e;
+
+ while (*s && isspace(*s))
+ s++;
+
+ e = s + strlen(s) - 1;
+ while (e > s && isspace(*e))
+ *e-- = '\0';
+
+ return s;
+}
+
+static int parse_time (const char *s) {
+ int t = 0;
+ int i;
+
+ if (!s)
+ return 0;
+
+ if (!strncmp (s, "npt=", 4))
+ s += 4;
+ else if (!strncmp (s, "smpte=", 6))
+ s += 6;
+
+ for (i = 0; i < 3; i++) {
+ t *= 60;
+ t += atoi(s);
+ s = strchr (s, ':');
+ if (!s)
+ break;
+ s++;
+ }
+
+ return t*1000;
+}
+
+static void parse_ref (demux_playlist_t *this, char *data, int length) {
+ char *src = data;
+ char *end;
+ int alt = 0;
+
+ while (src && *src) {
+ end = strchr (src, '\n');
+ if (end)
+ *end = '\0';
+
+ src = trim (src);
+ if (!strncmp (src, "Ref", 3)) {
+ src = strchr (src, '=');
+ if (src && *(src+1)) {
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, alt++, src+1, NULL, 0, 0);
+ }
+ }
+
+ src = end;
+ if (src)
+ src++;
+ }
+}
+
+static void parse_m3u (demux_playlist_t *this, char *data, int length) {
+ char *src = data;
+ char *end;
+ char *title = NULL;
+
+ while (src && *src) {
+ end = strchr (src, '\n');
+ if (end)
+ *end = '\0';
+
+ src = trim (src);
+ if (*src == '#') {
+ if (!strncmp (src+1, "EXTINF:", 7)) {
+ title = strchr (src+8, ',');
+ if (title)
+ title++;
+ }
+ }
+ else if (*src) {
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
+ }
+
+ src = end;
+ if (src)
+ src++;
+ }
+}
+
+static void parse_ram (demux_playlist_t *this, char *data, int length) {
+ char *src = data;
+ char *end;
+
+ while (src && *src) {
+ end = strchr (src, '\n');
+ if (end)
+ *end = '\0';
+
+ src = trim (src);
+ if (!strcmp (src, "--stop--"))
+ break;
+
+ if (*src && *src != '#') {
+ char *title = NULL;
+
+ if (!strncmp (src, "rtsp://", 7) || !strncmp (src, "pnm://", 7)) {
+ char *tmp = strrchr (src, '?');
+ if (tmp) {
+ *tmp = '\0';
+ title = strstr (tmp+1, "title=");
+ if (title) {
+ title += 6;
+ tmp = strchr (title, '&');
+ if (tmp)
+ *tmp = '\0';
+ }
+ }
+ }
+
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
+ }
+
+ src = end;
+ if (src)
+ src++;
+ }
+}
+
+static void parse_pls (demux_playlist_t *this, char *data, int length) {
+ char *src = data;
+ char *end;
+
+ while (src && *src) {
+ end = strchr (src, '\n');
+ if (end)
+ *end = '\0';
+
+ src = trim (src);
+ if (!strncmp (src, "File", 4)) {
+ src = strchr (src+4, '=');
+ if (src && *(src+1)) {
+ lprintf ("mrl:'%s'\n", src+1);
+ _x_demux_send_mrl_reference (this->stream, 0, src+1, NULL, 0, 0);
+ }
+ }
+
+ src = end;
+ if (src)
+ src++;
+ }
+}
+
+static void parse_asx (demux_playlist_t *this, char *data, int length) {
+ xml_node_t *root, *node, *tmp;
+ int is_asx = 0;
+
+ xml_parser_init (data, length, XML_PARSER_CASE_INSENSITIVE);
+
+ if (xml_parser_build_tree (&root) >= 0) {
+ if (!strcasecmp (root->name, "asx")) {
+ is_asx = 1;
+
+ for (node = root->child; node; node = node->next) {
+ if (!strcasecmp (node->name, "entry")) {
+ const char *title = NULL;
+ const char *src = NULL;
+ const char *start = NULL;
+ const char *duration = NULL;
+
+ for (tmp = node->child; tmp; tmp = tmp->next) {
+ if (!strcasecmp (tmp->name, "title")) {
+ title = tmp->data;
+ }
+ else if (!strcasecmp (tmp->name, "ref")) {
+ src = xml_parser_get_property (tmp, "href");
+ }
+ else if (!strcasecmp (tmp->name, "starttime")) {
+ start = xml_parser_get_property (tmp, "value");
+ }
+ else if (!strcasecmp (tmp->name, "duration")) {
+ duration = xml_parser_get_property (tmp, "value");
+ }
+ }
+
+ if (src) {
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, 0, src, title,
+ parse_time(start), parse_time(duration));
+ }
+ }
+ }
+ }
+
+ xml_parser_free_tree (root);
+ }
+
+ if (!is_asx) {
+ /* No tags found? Might be a references list. */
+ parse_ref (this, data, length);
+ }
+}
+
+static void parse_smi (demux_playlist_t *this, char *data, int length) {
+ xml_node_t *root, *node, *tmp;
+ int is_smi = 0;
+
+ xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
+
+ if (xml_parser_build_tree (&root) >= 0) {
+ for (node = root; node; node = node->next) {
+ if (!strcmp (node->name, "smil"))
+ break;
+ }
+
+ if (node) {
+ is_smi = 1;
+
+ for (node = node->child; node; node = node->next) {
+ if (!strcmp (node->name, "body")) {
+ for (tmp = node->child; tmp; tmp = tmp->next) {
+ if (!strcmp (tmp->name, "audio") || !strcmp (tmp->name, "video")) {
+ const char *src, *title;
+ int start, end;
+
+ src = xml_parser_get_property (tmp, "src");
+ title = xml_parser_get_property (tmp, "title");
+ start = parse_time (xml_parser_get_property (tmp, "clipBegin") ? :
+ xml_parser_get_property (tmp, "clip-begin"));
+ end = parse_time (xml_parser_get_property (tmp, "clipEnd") ? :
+ xml_parser_get_property (tmp, "clip-end"));
+
+ if (src) {
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, 0, src, title,
+ start, end ? (end-start) : 0);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ xml_parser_free_tree (root);
+ }
+
+ if (!is_smi) {
+ /* No tags found? Might be a RAM playlist. */
+ parse_ram (this, data, length);
+ }
+}
+
+static void parse_qtl (demux_playlist_t *this, char *data, int length) {
+ xml_node_t *root, *node;
+
+ xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
+
+ if (xml_parser_build_tree (&root) >= 0) {
+ for (node = root; node; node = node->next) {
+ if (!strcmp (node->name, "embed")) {
+ const char *src;
+
+ src = xml_parser_get_property (node, "src");
+ if (src) {
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, 0, src, NULL, 0, 0);
+ }
+ }
+ }
+
+ xml_parser_free_tree (root);
+ }
+}
+
+static void parse_xspf (demux_playlist_t *this, char *data, int length) {
+ xml_node_t *root, *node, *tmp;
+
+ xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
+
+ if (xml_parser_build_tree (&root) >= 0) {
+ for (node = root; node; node = node->next) {
+ if (!strcmp (node->name, "playlist"))
+ break;
+ }
+ if (node) {
+ for (node = node->child; node; node = node->next) {
+ if (!strcmp (node->name, "trackList"))
+ break;
+ }
+ }
+ if (node) {
+ for (node = node->child; node; node = node->next) {
+ if (!strcmp (node->name, "track")) {
+ char *src = NULL;
+ char *title = NULL;
+
+ for (tmp = node->child; tmp; tmp = tmp->next) {
+ if (!strcmp (tmp->name, "location")) {
+ src = trim((char*)tmp->data);
+ }
+ else if (!strcmp (tmp->name, "title")) {
+ title = trim((char*)tmp->data);
+ }
+ }
+
+ if (src) {
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
+ }
+ }
+ }
+ }
+
+ xml_parser_free_tree (root);
+ }
+}
+
+static void parse_rss (demux_playlist_t *this, char *data, int length) {
+ xml_node_t *root, *node, *item, *tmp;
+
+ xml_parser_init (data, length, XML_PARSER_CASE_SENSITIVE);
+
+ if (xml_parser_build_tree (&root) >= 0) {
+ for (node = root; node; node = node->next) {
+ if (!strcmp (node->name, "rss"))
+ break;
+ }
+
+ if (node) {
+ for (node = node->child; node; node = node->next) {
+ if (strcmp (node->name, "channel"))
+ continue;
+
+ for (item = node->child; item; item = item->next) {
+ if (!strcmp (item->name, "item")) {
+ const char *title = NULL;
+ const char *src = NULL;
+
+ for (tmp = item->child; tmp; tmp = tmp->next) {
+ if (!strcmp (tmp->name, "title")) {
+ title = tmp->data;
+ }
+ else if (!strcmp (tmp->name, "enclosure")) {
+ src = xml_parser_get_property (tmp, "url");
+ }
+ }
+
+ if (src) {
+ lprintf ("mrl:'%s'\n", src);
+ _x_demux_send_mrl_reference (this->stream, 0, src, title, 0, 0);
+ }
+ }
+ }
+ }
+ }
+
+ xml_parser_free_tree (root);
+ }
+}
+
+
+static void demux_playlist_send_headers (demux_plugin_t *this_gen) {
+ demux_playlist_t *this = (demux_playlist_t *) this_gen;
+
+ this->status = DEMUX_OK;
+
+ _x_demux_control_start (this->stream);
+
+ this->input->seek (this->input, 0, SEEK_SET);
+}
+
+
+static int demux_playlist_send_chunk (demux_plugin_t *this_gen) {
+ demux_playlist_t *this = (demux_playlist_t *) this_gen;
+ char *data = NULL;
+ int length;
+
+ length = this->input->get_length (this->input);
+ if (length > 0) {
+ data = xine_xmalloc (length+1);
+ if (data)
+ this->input->read (this->input, data, length);
+ }
+ else {
+ char buf[1024];
+ int len;
+
+ length = 0;
+ while ((len = this->input->read (this->input, buf, sizeof(buf))) > 0) {
+ data = realloc (data, length+len+1);
+ if (!data)
+ break;
+
+ memcpy (data+length, buf, len);
+ length += len;
+ data[length] = '\0';
+ }
+ }
+
+ lprintf ("data:%p length:%d\n", data, length);
+
+ if (data) {
+ switch (this->playlist) {
+ case XINE_PLT_REF:
+ parse_ref (this, data, length);
+ break;
+ case XINE_PLT_M3U:
+ parse_m3u (this, data, length);
+ break;
+ case XINE_PLT_RAM:
+ parse_ram (this, data, length);
+ break;
+ case XINE_PLT_PLS:
+ parse_pls (this, data, length);
+ break;
+ case XINE_PLT_ASX:
+ parse_asx (this, data, length);
+ break;
+ case XINE_PLT_SMI:
+ parse_smi (this, data, length);
+ break;
+ case XINE_PLT_QTL:
+ parse_qtl (this, data, length);
+ break;
+ case XINE_PLT_XSPF:
+ parse_xspf (this, data, length);
+ break;
+ case XINE_PLT_RSS:
+ parse_rss (this, data, length);
+ break;
+ default:
+ lprintf ("unexpected playlist type 0x%08x\n", this->playlist);
+ break;
+ }
+
+ free (data);
+ }
+
+ this->status = DEMUX_FINISHED;
+
+ return DEMUX_FINISHED;
+}
+
+static int demux_playlist_seek (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time, int playing) {
+ return DEMUX_OK;
+}
+
+static int demux_playlist_get_status (demux_plugin_t *this_gen) {
+ demux_playlist_t *this = (demux_playlist_t *) this_gen;
+
+ return this->status;
+}
+
+static int demux_playlist_get_stream_length (demux_plugin_t *this_gen) {
+ return 0;
+}
+
+static uint32_t demux_playlist_get_capabilities (demux_plugin_t *this_gen) {
+ return DEMUX_CAP_NOCAP;
+}
+
+static int demux_playlist_get_optional_data (demux_plugin_t *this_gen,
+ void *data, int data_type) {
+ return DEMUX_OPTIONAL_UNSUPPORTED;
+}
+
+
+static demux_plugin_t *open_plugin (demux_class_t *class_gen,
+ xine_stream_t *stream, input_plugin_t *input) {
+ demux_playlist_t *this;
+
+ this = xine_xmalloc (sizeof (demux_playlist_t));
+ this->xine = stream->xine;
+ this->stream = stream;
+ this->input = input;
+
+ this->demux_plugin.send_headers = demux_playlist_send_headers;
+ this->demux_plugin.send_chunk = demux_playlist_send_chunk;
+ this->demux_plugin.seek = demux_playlist_seek;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
+ this->demux_plugin.get_status = demux_playlist_get_status;
+ this->demux_plugin.get_stream_length = demux_playlist_get_stream_length;
+ this->demux_plugin.get_capabilities = demux_playlist_get_capabilities;
+ this->demux_plugin.get_optional_data = demux_playlist_get_optional_data;
+ this->demux_plugin.demux_class = class_gen;
+
+ switch (stream->content_detection_method) {
+ case METHOD_BY_MRL:
+ lprintf ("detect by extension\n");
+ this->playlist = detect_by_extension (input);
+ if (!this->playlist) {
+ free (this);
+ return NULL;
+ }
+ break;
+
+ case METHOD_BY_CONTENT:
+ case METHOD_EXPLICIT:
+ lprintf ("detect by content\n");
+ this->playlist = detect_by_content (input);
+ if (!this->playlist) {
+ free (this);
+ return NULL;
+ }
+ break;
+
+ default:
+ free (this);
+ return NULL;
+ }
+
+ lprintf ("playlist:0x%08x (%s)\n", this->playlist, (char*)&this->playlist);
+
+ return &this->demux_plugin;
+}
+
+static void *init_plugin (xine_t *xine, void *data) {
+ demux_playlist_class_t *this;
+
+ this = xine_xmalloc (sizeof(demux_playlist_class_t));
+
+ this->demux_class.open_plugin = open_plugin;
+ this->demux_class.description = N_("Playlist demux plugin");
+ this->demux_class.identifier = "playlist";
+ this->demux_class.mimetypes =
+ "audio/mpegurl: m3u: M3U playlist;"
+ "audio/x-mpegurl: m3u: M3U playlist;"
+ //"audio/x-pn-realaudio: ram: RAM playlist;"
+ //"audio/vnd.rn-realaudio: ram: RAM playlist;"
+ "audio/x-scpls: pls: Winamp playlist;"
+ "audio/x-ms-wax: wax, asx: WAX playlist;"
+ "audio/x-ms-wvx: wvx, asx: WVX playlist;"
+ "application/smil: smi, smil: SMIL playlist;"
+ "application/x-quicktimeplayer: qtl: Quicktime playlist;"
+ "application/xspf+xml: xspf: XSPF playlist;";
+ this->demux_class.extensions = "m3u ram pls asx wax wvx smi smil qtl xspf rss";
+ this->demux_class.dispose = default_demux_class_dispose;
+
+ return this;
+}
+
+/*
+ * exported plugin catalog entry
+ */
+static const demuxer_info_t demux_info_flv = {
+ 10 /* priority */
+};
+
+const plugin_info_t xine_plugin_info[] EXPORTED = {
+ /* type, API, "name", version, special_info, init_function */
+ { PLUGIN_DEMUX, 27, "playlist", XINE_VERSION_CODE, &demux_info_flv, init_plugin },
+ { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+};
diff --git a/src/demuxers/demux_pva.c b/src/demuxers/demux_pva.c
index 55b1f7644..9987da057 100644
--- a/src/demuxers/demux_pva.c
+++ b/src/demuxers/demux_pva.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* TechnoTrend PVA File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information regarding the PVA file format, refer to this PDF:
* http://www.technotrend.de/download/av_format_v1.pdf
- *
- * $Id: demux_pva.c,v 1.25 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -41,10 +39,10 @@
/* #define LOG_VERBOSE */
/* #define LOG */
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#define PVA_PREAMBLE_SIZE 8
@@ -145,7 +143,7 @@ static int demux_pva_send_chunk(demux_plugin_t *this_gen) {
return this->status;
}
- chunk_size = BE_16(&preamble[6]);
+ chunk_size = _X_BE_16(&preamble[6]);
current_file_pos = this->input->get_current_pos(this->input);
@@ -160,7 +158,7 @@ static int demux_pva_send_chunk(demux_plugin_t *this_gen) {
return this->status;
}
chunk_size -= 4;
- pts = BE_32(&pts_buf[0]);
+ pts = _X_BE_32(&pts_buf[0]);
check_newpts( this, pts, PTS_VIDEO );
} else
pts = 0;
@@ -207,11 +205,11 @@ static int demux_pva_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- if (BE_32(&preamble[0]) != 0x000001C0) {
+ if (_X_BE_32(&preamble[0]) != 0x000001C0) {
this->status = DEMUX_FINISHED;
return this->status;
}
- chunk_size = BE_16(&preamble[4]);
+ chunk_size = _X_BE_16(&preamble[4]);
/* get next 3 header bytes */
if (this->input->read(this->input, preamble, 3) != 3) {
@@ -234,8 +232,8 @@ static int demux_pva_send_chunk(demux_plugin_t *this_gen) {
}
pts = (int64_t)(preamble[0] & 0x0e) << 29 ;
- pts |= (BE_16(&preamble[1]) & 0xFFFE) << 14;
- pts |= (BE_16(&preamble[3]) & 0xFFFE) >> 1;
+ pts |= (_X_BE_16(&preamble[1]) & 0xFFFE) << 14;
+ pts |= (_X_BE_16(&preamble[3]) & 0xFFFE) >> 1;
header_len -= 5 ;
@@ -398,11 +396,6 @@ static int demux_pva_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_pva_dispose (demux_plugin_t *this) {
-
- free(this);
-}
-
static int demux_pva_get_status (demux_plugin_t *this_gen) {
demux_pva_t *this = (demux_pva_t *) this_gen;
@@ -439,7 +432,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_pva_send_headers;
this->demux_plugin.send_chunk = demux_pva_send_chunk;
this->demux_plugin.seek = demux_pva_seek;
- this->demux_plugin.dispose = demux_pva_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_pva_get_status;
this->demux_plugin.get_stream_length = demux_pva_get_stream_length;
this->demux_plugin.get_capabilities = demux_pva_get_capabilities;
@@ -450,19 +443,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -480,39 +461,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "TechnoTrend PVA demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "TechnoTrend PVA";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "pva";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_pva_class_t *this = (demux_pva_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_pva_class_t *this;
this = xine_xmalloc (sizeof (demux_pva_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("TechnoTrend PVA demux plugin");
+ this->demux_class.identifier = "TechnoTrend PVA";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "pva";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -526,6 +485,6 @@ static const demuxer_info_t demux_info_pva = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "pva", XINE_VERSION_CODE, &demux_info_pva, init_plugin },
+ { PLUGIN_DEMUX, 27, "pva", XINE_VERSION_CODE, &demux_info_pva, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c
index 4144f3049..6b2aa5eea 100644
--- a/src/demuxers/demux_qt.c
+++ b/src/demuxers/demux_qt.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Quicktime File Demuxer by Mike Melanson (melanson@pcisys.net)
* based on a Quicktime parsing experiment entitled 'lazyqt'
@@ -29,9 +29,6 @@
* parse_trak_atom
* build_frame_table
* free_qt_info
- *
- * $Id: demux_qt.c,v 1.214 2007/01/19 01:05:24 dgp85 Exp $
- *
*/
#ifdef HAVE_CONFIG_H
@@ -46,10 +43,10 @@
#include <ctype.h>
#include <zlib.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "qtpalette.h"
@@ -110,6 +107,8 @@ typedef unsigned int qt_atom;
#define UDTA_ATOM QT_ATOM('u', 'd', 't', 'a')
#define META_ATOM QT_ATOM('m', 'e', 't', 'a')
+#define HDLR_ATOM QT_ATOM('h', 'd', 'l', 'r')
+#define ILST_ATOM QT_ATOM('i', 'l', 's', 't')
#define NAM_ATOM QT_ATOM(0xA9, 'n', 'a', 'm')
#define CPY_ATOM QT_ATOM(0xA9, 'c', 'p', 'y')
#define DES_ATOM QT_ATOM(0xA9, 'd', 'e', 's')
@@ -121,6 +120,7 @@ typedef unsigned int qt_atom;
#define WRT_ATOM QT_ATOM(0xA9, 'w', 'r', 't')
#define DAY_ATOM QT_ATOM(0xA9, 'd', 'a', 'y')
+#define RMRA_ATOM QT_ATOM('r', 'm', 'r', 'a')
#define RMDA_ATOM QT_ATOM('r', 'm', 'd', 'a')
#define RDRF_ATOM QT_ATOM('r', 'd', 'r', 'f')
#define RMDR_ATOM QT_ATOM('r', 'm', 'd', 'r')
@@ -135,8 +135,10 @@ typedef unsigned int qt_atom;
#define MAX_PTS_DIFF 100000
-/* network bandwidth, cribbed from src/input/input_mms.c */
-const int64_t bandwidths[]={14400,19200,28800,33600,34430,57600,
+/**
+ * @brief Network bandwidth, cribbed from src/input/input_mms.c
+ */
+static const int64_t bandwidths[]={14400,19200,28800,33600,34430,57600,
115200,262200,393216,524300,1544000,10485800};
/* these are things that can go wrong */
@@ -186,7 +188,7 @@ typedef struct {
} time_to_sample_table_t;
typedef struct {
- unsigned char *url;
+ char *url;
int64_t data_rate;
int qtim_version;
} reference_t;
@@ -403,6 +405,10 @@ typedef struct {
* demuxer is sending off to the audio decoder */
#define DEBUG_AUDIO_DEMUX 0
+/* define DEBUG_META_LOAD as 1 to see details about the metadata chunks the
+ * demuxer is reading from the file */
+#define DEBUG_META_LOAD 0
+
/* Define DEBUG_DUMP_MOOV as 1 to dump the raw moov atom to disk. This is
* particularly useful in debugging a file with a compressed moov (cmov)
* atom. The atom will be dumped to the filename specified as
@@ -410,38 +416,40 @@ typedef struct {
#define DEBUG_DUMP_MOOV 0
#define RAW_MOOV_FILENAME "moovatom.raw"
-#ifndef __GNUC__
-#define __attribute__(x)
-#endif
-
#if DEBUG_ATOM_LOAD
#define debug_atom_load printf
#else
-static inline void __attribute__((format (printf, 1, 2))) debug_atom_load(const char *format, ...) {}
+static inline void XINE_FORMAT_PRINTF(1, 2) debug_atom_load(const char *format, ...) {}
#endif
#if DEBUG_EDIT_LIST
#define debug_edit_list printf
#else
-static inline void __attribute__((format (printf, 1, 2))) debug_edit_list(const char *format, ...) {}
+static inline void XINE_FORMAT_PRINTF(1, 2) debug_edit_list(const char *format, ...) {}
#endif
#if DEBUG_FRAME_TABLE
#define debug_frame_table printf
#else
-static inline void __attribute__((format (printf, 1, 2))) debug_frame_table(const char *format, ...) {}
+static inline void XINE_FORMAT_PRINTF(1, 2) debug_frame_table(const char *format, ...) {}
#endif
#if DEBUG_VIDEO_DEMUX
#define debug_video_demux printf
#else
-static inline void __attribute__((format (printf, 1, 2))) debug_video_demux(const char *format, ...) {}
+static inline void XINE_FORMAT_PRINTF(1, 2) debug_video_demux(const char *format, ...) {}
#endif
#if DEBUG_AUDIO_DEMUX
#define debug_audio_demux printf
#else
-static inline void __attribute__((format (printf, 1, 2))) debug_audio_demux(const char *format, ...) {}
+static inline void XINE_FORMAT_PRINTF(1, 2) debug_audio_demux(const char *format, ...) {}
+#endif
+
+#if DEBUG_META_LOAD
+#define debug_meta_load printf
+#else
+static inline void XINE_FORMAT_PRINTF(1, 2) debug_meta_load(const char *format, ...) {}
#endif
static inline void dump_moov_atom(unsigned char *moov_atom, int moov_atom_size) {
@@ -500,8 +508,8 @@ static void find_moov_atom(input_plugin_t *input, off_t *moov_offset,
ATOM_PREAMBLE_SIZE)
break;
- atom_size = BE_32(&atom_preamble[0]);
- atom = BE_32(&atom_preamble[4]);
+ atom_size = _X_BE_32(&atom_preamble[0]);
+ atom = _X_BE_32(&atom_preamble[4]);
/* Special case alert: 'free' atoms sometimes masquerade as 'moov'
* atoms. If this is a free atom, check for 'cmov' or 'mvhd' immediately
@@ -515,8 +523,8 @@ static void find_moov_atom(input_plugin_t *input, off_t *moov_offset,
/* if there is a cmov, qualify this free atom as the 'moov' atom
* if no actual 'moov' atom is found. */
- if ((BE_32(&atom_preamble[4]) == CMOV_ATOM) ||
- (BE_32(&atom_preamble[4]) == MVHD_ATOM)) {
+ if ((_X_BE_32(&atom_preamble[4]) == CMOV_ATOM) ||
+ (_X_BE_32(&atom_preamble[4]) == MVHD_ATOM)) {
/* pos = current pos minus 2 atom preambles */
free_moov_offset = input->get_current_pos(input) - ATOM_PREAMBLE_SIZE * 2;
free_moov_size = atom_size;
@@ -560,9 +568,9 @@ static void find_moov_atom(input_plugin_t *input, off_t *moov_offset,
ATOM_PREAMBLE_SIZE)
break;
- atom_size = BE_32(&atom_preamble[0]);
+ atom_size = _X_BE_32(&atom_preamble[0]);
atom_size <<= 32;
- atom_size |= BE_32(&atom_preamble[4]);
+ atom_size |= _X_BE_32(&atom_preamble[4]);
atom_size -= ATOM_PREAMBLE_SIZE * 2;
} else
atom_size -= ATOM_PREAMBLE_SIZE;
@@ -643,8 +651,7 @@ static void free_qt_info(qt_info *info) {
for (j = 0; j < info->traks[i].stsd_atoms_count; j++) {
if (info->traks[i].type == MEDIA_AUDIO) {
free(info->traks[i].stsd_atoms[j].audio.properties_atom);
- if (info->traks[i].stsd_atoms[j].audio.wave)
- free(info->traks[i].stsd_atoms[j].audio.wave);
+ free(info->traks[i].stsd_atoms[j].audio.wave);
} else if (info->traks[i].type == MEDIA_VIDEO)
free(info->traks[i].stsd_atoms[j].video.properties_atom);
}
@@ -678,34 +685,28 @@ static int is_qt_file(input_plugin_t *qt_file) {
off_t moov_atom_offset = -1;
int64_t moov_atom_size = -1;
int i;
- unsigned char atom_preamble[ATOM_PREAMBLE_SIZE];
- unsigned char preview[MAX_PREVIEW_SIZE];
int len;
/* if the input is non-seekable, be much more stringent about qualifying
* a QT file: In this case, the moov must be the first atom in the file */
if ((qt_file->get_capabilities(qt_file) & INPUT_CAP_SEEKABLE) == 0) {
- memset (&preview, 0, MAX_PREVIEW_SIZE);
+ unsigned char preview[MAX_PREVIEW_SIZE] = { 0, };
len = qt_file->get_optional_data(qt_file, preview, INPUT_OPTIONAL_DATA_PREVIEW);
- if (BE_32(&preview[4]) == MOOV_ATOM)
+ if (_X_BE_32(&preview[4]) == MOOV_ATOM)
return 1;
else {
- if (BE_32(&preview[4]) == FTYP_ATOM) {
- /* show some lenience if the first atom is 'ftyp'; the second atom
- * could be 'moov' */
- moov_atom_size = BE_32(&preview[0]);
- /* compute the size of the current atom plus the preamble of the
- * next atom; if the size is within the range on the preview buffer
- * then the next atom's preamble is in the preview buffer */
- i = moov_atom_size + ATOM_PREAMBLE_SIZE;
- if (i >= MAX_PREVIEW_SIZE)
- return 0;
- if (BE_32(&preview[i - 4]) == MOOV_ATOM)
- return 1;
- else
- return 0;
- } else
- return 0;
+ if (_X_BE_32(&preview[4]) != FTYP_ATOM)
+ return 0;
+
+ /* show some lenience if the first atom is 'ftyp'; the second atom
+ * could be 'moov'
+ * compute the size of the current atom plus the preamble of the
+ * next atom; if the size is within the range on the preview buffer
+ * then the next atom's preamble is in the preview buffer */
+ uint64_t ftyp_atom_size = _X_BE_32(&preview[0]) + ATOM_PREAMBLE_SIZE;
+ if (ftyp_atom_size >= MAX_PREVIEW_SIZE)
+ return 0;
+ return _X_BE_32(&preview[ftyp_atom_size - 4]) == MOOV_ATOM;
}
}
@@ -713,6 +714,7 @@ static int is_qt_file(input_plugin_t *qt_file) {
if (moov_atom_offset == -1) {
return 0;
} else {
+ unsigned char atom_preamble[ATOM_PREAMBLE_SIZE];
/* check that the next atom in the chunk contains alphanumeric
* characters in the atom type field; if not, disqualify the file
* as a QT file */
@@ -728,52 +730,116 @@ static int is_qt_file(input_plugin_t *qt_file) {
}
}
+static char *parse_data_atom(const uint8_t *data_atom) {
+ const uint32_t data_atom_size = _X_BE_32(&data_atom[0]);
+
+ static const int data_atom_max_version = 0;
+ const int data_atom_version = data_atom[8];
+
+ const size_t alloc_size = data_atom_size - 8 + 1;
+ char *alloc_str = NULL;
+
+ if ( data_atom_version > data_atom_max_version ) {
+ debug_meta_load("demux_qt: version %d for data atom is higher than the highest supported version (%d)\n",
+ data_atom_version, data_atom_max_version);
+ return NULL;
+ }
+
+ alloc_str = xine_xmalloc(alloc_size);
+ xine_fast_memcpy(alloc_str, &data_atom[16], alloc_size-1);
+ alloc_str[alloc_size-1] = '\0';
+
+ debug_meta_load("demux_qt: got a string of size %zd (%s)\n", alloc_size, alloc_str);
+
+ return alloc_str;
+}
+
/* parse out a meta data atom */
static void parse_meta_atom(qt_info *info, unsigned char *meta_atom) {
- int i;
- unsigned int meta_atom_size = BE_32(&meta_atom[0]);
- qt_atom current_atom;
- int string_size;
-
- for (i = 0; i < meta_atom_size - 4; i++) {
- current_atom = BE_32(&meta_atom[i]);
-
- if (current_atom == ART_ATOM) {
- string_size = BE_32(&meta_atom[i + 4]) - 16 + 1;
- info->artist = xine_xmalloc(string_size);
- strncpy(info->artist, &meta_atom[i + 20], string_size - 1);
- info->artist[string_size - 1] = 0;
- } else if (current_atom == NAM_ATOM) {
- string_size = BE_32(&meta_atom[i + 4]) - 16 + 1;
- info->name = xine_xmalloc(string_size);
- strncpy(info->name, &meta_atom[i + 20], string_size - 1);
- info->name[string_size - 1] = 0;
- } else if (current_atom == ALB_ATOM) {
- string_size = BE_32(&meta_atom[i + 4]) - 16 + 1;
- info->album = xine_xmalloc(string_size);
- strncpy(info->album, &meta_atom[i + 20], string_size - 1);
- info->album[string_size - 1] = 0;
- } else if (current_atom == GEN_ATOM) {
- string_size = BE_32(&meta_atom[i + 4]) - 16 + 1;
- info->genre = xine_xmalloc(string_size);
- strncpy(info->genre, &meta_atom[i + 20], string_size - 1);
- info->genre[string_size - 1] = 0;
- } else if (current_atom == TOO_ATOM) {
- string_size = BE_32(&meta_atom[i + 4]) - 16 + 1;
- info->comment = xine_xmalloc(string_size);
- strncpy(info->comment, &meta_atom[i + 20], string_size - 1);
- info->comment[string_size - 1] = 0;
- } else if (current_atom == WRT_ATOM) {
- string_size = BE_32(&meta_atom[i + 4]) - 16 + 1;
- info->composer = xine_xmalloc(string_size);
- strncpy(info->composer, &meta_atom[i + 20], string_size - 1);
- info->composer[string_size - 1] = 0;
- } else if (current_atom == DAY_ATOM) {
- string_size = BE_32(&meta_atom[i + 4]) - 16 + 1;
- info->year = xine_xmalloc(string_size);
- strncpy(info->year, &meta_atom[i + 20], string_size - 1);
- info->year[string_size - 1] = 0;
+ static const uint32_t meta_atom_preamble_size = 12;
+
+ const uint32_t meta_atom_size = _X_BE_32(&meta_atom[0]);
+
+ static const int meta_atom_max_version = 0;
+ const int meta_atom_version = meta_atom[8];
+ /* const uint32_t flags = _X_BE_24(&meta_atom[9]); */
+
+ uint32_t i = meta_atom_preamble_size;
+
+ if ( meta_atom_version > meta_atom_max_version ) {
+ debug_meta_load("demux_qt: version %d for meta atom is higher than the highest supported version (%d)\n",
+ meta_atom_version, meta_atom_max_version);
+ return;
+ }
+
+ while ( i < meta_atom_size ) {
+ const uint8_t *const current_atom = &meta_atom[i];
+ const qt_atom current_atom_code = _X_BE_32(&current_atom[4]);
+ const uint32_t current_atom_size = _X_BE_32(&current_atom[0]);
+ uint32_t handler_type = 0;
+
+ switch (current_atom_code) {
+ case HDLR_ATOM: {
+ static const int hdlr_atom_max_version = 0;
+ const int hdlr_atom_version = current_atom[8];
+
+ /* const uint32_t hdlr_atom_flags = _X_BE_24(&current_atom[9]); */
+
+ if ( hdlr_atom_version > hdlr_atom_max_version ) {
+ debug_meta_load("demux_qt: version %d for hdlr atom is higher than the highest supported version (%d)\n",
+ hdlr_atom_version, hdlr_atom_max_version);
+ return;
+ }
+
+ handler_type = _X_BE_32(&current_atom[12]);
+ }
+ break;
+
+ case ILST_ATOM: {
+ uint32_t j = i + 8;
+ while ( j < current_atom_size ) {
+ const uint8_t *const sub_atom = &meta_atom[j];
+ const qt_atom sub_atom_code = _X_BE_32(&sub_atom[4]);
+ const uint32_t sub_atom_size = _X_BE_32(&sub_atom[0]);
+ char *const data_atom = parse_data_atom(&sub_atom[8]);
+
+ switch(sub_atom_code) {
+ case ART_ATOM:
+ info->artist = data_atom;
+ break;
+ case NAM_ATOM:
+ info->name = data_atom;
+ break;
+ case ALB_ATOM:
+ info->album = data_atom;
+ break;
+ case GEN_ATOM:
+ info->genre = data_atom;
+ break;
+ case CMT_ATOM:
+ info->comment = data_atom;
+ break;
+ case WRT_ATOM:
+ info->composer = data_atom;
+ break;
+ case DAY_ATOM:
+ info->year = data_atom;
+ break;
+ default:
+ debug_meta_load("unknown atom %08x in ilst\n", sub_atom_code);
+ free(data_atom);
+ }
+
+ j += sub_atom_size;
+ }
+ }
+ break;
+
+ default:
+ debug_meta_load("unknown atom %08x in meta\n", current_atom_code);
}
+
+ i += current_atom_size;
}
}
@@ -781,10 +847,10 @@ static void parse_meta_atom(qt_info *info, unsigned char *meta_atom) {
/* fetch interesting information from the movie header atom */
static void parse_mvhd_atom(qt_info *info, unsigned char *mvhd_atom) {
- info->creation_time = BE_32(&mvhd_atom[0x0C]);
- info->modification_time = BE_32(&mvhd_atom[0x10]);
- info->timescale = BE_32(&mvhd_atom[0x14]);
- info->duration = BE_32(&mvhd_atom[0x18]);
+ info->creation_time = _X_BE_32(&mvhd_atom[0x0C]);
+ info->modification_time = _X_BE_32(&mvhd_atom[0x10]);
+ info->timescale = _X_BE_32(&mvhd_atom[0x14]);
+ info->duration = _X_BE_32(&mvhd_atom[0x18]);
debug_atom_load(" qt: timescale = %d, duration = %d (%d seconds)\n",
info->timescale, info->duration,
@@ -815,25 +881,11 @@ static qt_error parse_trak_atom (qt_trak *trak,
unsigned char *trak_atom) {
int i, j, k;
- unsigned int trak_atom_size = BE_32(&trak_atom[0]);
- qt_atom current_atom;
- unsigned int current_atom_size;
+ const unsigned int trak_atom_size = _X_BE_32(&trak_atom[0]);
unsigned int atom_pos;
unsigned int properties_offset;
- unsigned int current_stsd_atom_size;
qt_error last_error = QT_OK;
- /* for palette traversal */
- int color_depth;
- int color_flag;
- int color_start;
- int color_count;
- int color_end;
- int color_index;
- int color_dec;
- int color_greyscale;
- unsigned char *color_table;
-
/* initialize trak structure */
trak->edit_list_count = 0;
trak->edit_list_table = NULL;
@@ -864,12 +916,13 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* search for media type atoms */
for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++) {
- current_atom = BE_32(&trak_atom[i]);
+ const qt_atom current_atom = _X_BE_32(&trak_atom[i]);
- if (current_atom == VMHD_ATOM) {
+ switch (current_atom) {
+ case VMHD_ATOM:
trak->type = MEDIA_VIDEO;
break;
- } else if (current_atom == SMHD_ATOM) {
+ case SMHD_ATOM:
trak->type = MEDIA_AUDIO;
break;
}
@@ -881,20 +934,22 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* search for the useful atoms */
for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++) {
- current_atom_size = BE_32(&trak_atom[i - 4]);
- current_atom = BE_32(&trak_atom[i]);
+ const uint32_t current_atom_size = _X_BE_32(&trak_atom[i - 4]);
+ const qt_atom current_atom = _X_BE_32(&trak_atom[i]);
- if (current_atom == TKHD_ATOM) {
- trak->flags = BE_16(&trak_atom[i + 6]);
- } else if (current_atom == ELST_ATOM) {
+ switch(current_atom) {
+ case TKHD_ATOM:
+ trak->flags = _X_BE_16(&trak_atom[i + 6]);
+ break;
+ case ELST_ATOM:
/* there should only be one edit list table */
if (trak->edit_list_table) {
last_error = QT_HEADER_TROUBLE;
goto free_trak;
}
- trak->edit_list_count = BE_32(&trak_atom[i + 8]);
+ trak->edit_list_count = _X_BE_32(&trak_atom[i + 8]);
debug_atom_load(" qt elst atom (edit list atom): %d entries\n",
trak->edit_list_count);
@@ -909,40 +964,57 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* load the edit list table */
for (j = 0; j < trak->edit_list_count; j++) {
trak->edit_list_table[j].track_duration =
- BE_32(&trak_atom[i + 12 + j * 12 + 0]);
+ _X_BE_32(&trak_atom[i + 12 + j * 12 + 0]);
trak->edit_list_table[j].media_time =
- BE_32(&trak_atom[i + 12 + j * 12 + 4]);
+ _X_BE_32(&trak_atom[i + 12 + j * 12 + 4]);
debug_atom_load(" %d: track duration = %d, media time = %d\n",
j,
trak->edit_list_table[j].track_duration,
trak->edit_list_table[j].media_time);
}
+ break;
- } else if (current_atom == MDHD_ATOM)
- trak->timescale = BE_32(&trak_atom[i + 0x10]);
- else if (current_atom == STSD_ATOM) {
+ case MDHD_ATOM:
+ debug_atom_load ("demux_qt: mdhd atom\n");
+ {
+ const int version = trak_atom[i+4];
+ if ( version > 1 ) continue; /* unsupported, undocumented */
+ trak->timescale = _X_BE_32(&trak_atom[i + (version == 0 ? 0x10 : 0x18) ]);
+ }
+ break;
+
+ case STSD_ATOM:
debug_atom_load ("demux_qt: stsd atom\n");
#if DEBUG_ATOM_LOAD
xine_hexdump (&trak_atom[i], current_atom_size);
#endif
/* allocate space for each of the properties unions */
- trak->stsd_atoms_count = BE_32(&trak_atom[i + 8]);
- trak->stsd_atoms = xine_xmalloc(trak->stsd_atoms_count * sizeof(properties_t));
+ trak->stsd_atoms_count = _X_BE_32(&trak_atom[i + 8]);
+ trak->stsd_atoms = xine_xcalloc(trak->stsd_atoms_count, sizeof(properties_t));
if (!trak->stsd_atoms) {
last_error = QT_NO_MEMORY;
goto free_trak;
}
- memset(trak->stsd_atoms, 0, trak->stsd_atoms_count * sizeof(properties_t));
atom_pos = i + 0x10;
properties_offset = 0x0C;
for (k = 0; k < trak->stsd_atoms_count; k++) {
- current_stsd_atom_size = BE_32(&trak_atom[atom_pos - 4]);
+ const uint32_t current_stsd_atom_size = _X_BE_32(&trak_atom[atom_pos - 4]);
if (trak->type == MEDIA_VIDEO) {
+ /* for palette traversal */
+ int color_depth;
+ int color_flag;
+ int color_start;
+ int color_count;
+ int color_end;
+ int color_index;
+ int color_dec;
+ int color_greyscale;
+ const unsigned char *color_table;
trak->stsd_atoms[k].video.media_id = k + 1;
trak->stsd_atoms[k].video.properties_offset = properties_offset;
@@ -963,15 +1035,15 @@ static qt_error parse_trak_atom (qt_trak *trak,
trak->stsd_atoms[k].video.palette_count = 0;
/* fetch video parameters */
- if( BE_16(&trak_atom[atom_pos + 0x1C]) &&
- BE_16(&trak_atom[atom_pos + 0x1E]) ) {
+ if( _X_BE_16(&trak_atom[atom_pos + 0x1C]) &&
+ _X_BE_16(&trak_atom[atom_pos + 0x1E]) ) {
trak->stsd_atoms[k].video.width =
- BE_16(&trak_atom[atom_pos + 0x1C]);
+ _X_BE_16(&trak_atom[atom_pos + 0x1C]);
trak->stsd_atoms[k].video.height =
- BE_16(&trak_atom[atom_pos + 0x1E]);
+ _X_BE_16(&trak_atom[atom_pos + 0x1E]);
}
trak->stsd_atoms[k].video.codec_fourcc =
- ME_32(&trak_atom[atom_pos + 0x00]);
+ _X_ME_32(&trak_atom[atom_pos + 0x00]);
/* figure out the palette situation */
color_depth = trak_atom[atom_pos + 0x4F];
@@ -982,7 +1054,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* if the depth is 2, 4, or 8 bpp, file is palettized */
if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) {
- color_flag = BE_16(&trak_atom[atom_pos + 0x50]);
+ color_flag = _X_BE_16(&trak_atom[atom_pos + 0x50]);
if (color_greyscale) {
@@ -1034,15 +1106,15 @@ static qt_error parse_trak_atom (qt_trak *trak,
} else {
/* load the palette from the file */
- color_start = BE_32(&trak_atom[atom_pos + 0x52]);
- color_count = BE_16(&trak_atom[atom_pos + 0x56]);
- color_end = BE_16(&trak_atom[atom_pos + 0x58]);
+ color_start = _X_BE_32(&trak_atom[atom_pos + 0x52]);
+ color_count = _X_BE_16(&trak_atom[atom_pos + 0x56]);
+ color_end = _X_BE_16(&trak_atom[atom_pos + 0x58]);
trak->stsd_atoms[k].video.palette_count =
color_end + 1;
for (j = color_start; j <= color_end; j++) {
- color_index = BE_16(&trak_atom[atom_pos + 0x5A + j * 8]);
+ color_index = _X_BE_16(&trak_atom[atom_pos + 0x5A + j * 8]);
if (color_count & 0x8000)
color_index = j;
if (color_index <
@@ -1071,7 +1143,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
trak_atom[atom_pos + 0x1],
trak_atom[atom_pos + 0x2],
trak_atom[atom_pos + 0x3]);
- debug_atom_load(" %d RGB colors\n",
+ debug_atom_load(" %d RGB colours\n",
trak->stsd_atoms[k].video.palette_count);
for (j = 0; j < trak->stsd_atoms[k].video.palette_count;
j++)
@@ -1095,9 +1167,9 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* fetch audio parameters */
trak->stsd_atoms[k].audio.codec_fourcc =
- ME_32(&trak_atom[atom_pos + 0x0]);
+ _X_ME_32(&trak_atom[atom_pos + 0x0]);
trak->stsd_atoms[k].audio.sample_rate =
- BE_16(&trak_atom[atom_pos + 0x1C]);
+ _X_BE_16(&trak_atom[atom_pos + 0x1C]);
trak->stsd_atoms[k].audio.channels = trak_atom[atom_pos + 0x15];
trak->stsd_atoms[k].audio.bits = trak_atom[atom_pos + 0x17];
@@ -1169,18 +1241,18 @@ static qt_error parse_trak_atom (qt_trak *trak,
(trak->stsd_atoms[k].audio.codec_fourcc != SOWT_FOURCC) &&
(trak->stsd_atoms[k].audio.codec_fourcc != RAW_FOURCC)) {
- if (BE_32(&trak_atom[atom_pos + 0x20]))
+ if (_X_BE_32(&trak_atom[atom_pos + 0x20]))
trak->stsd_atoms[k].audio.samples_per_packet =
- BE_32(&trak_atom[atom_pos + 0x20]);
- if (BE_32(&trak_atom[atom_pos + 0x24]))
+ _X_BE_32(&trak_atom[atom_pos + 0x20]);
+ if (_X_BE_32(&trak_atom[atom_pos + 0x24]))
trak->stsd_atoms[k].audio.bytes_per_packet =
- BE_32(&trak_atom[atom_pos + 0x24]);
- if (BE_32(&trak_atom[atom_pos + 0x28]))
+ _X_BE_32(&trak_atom[atom_pos + 0x24]);
+ if (_X_BE_32(&trak_atom[atom_pos + 0x28]))
trak->stsd_atoms[k].audio.bytes_per_frame =
- BE_32(&trak_atom[atom_pos + 0x28]);
- if (BE_32(&trak_atom[atom_pos + 0x2C]))
+ _X_BE_32(&trak_atom[atom_pos + 0x28]);
+ if (_X_BE_32(&trak_atom[atom_pos + 0x2C]))
trak->stsd_atoms[k].audio.bytes_per_sample =
- BE_32(&trak_atom[atom_pos + 0x2C]);
+ _X_BE_32(&trak_atom[atom_pos + 0x2C]);
trak->stsd_atoms[k].audio.samples_per_frame =
(trak->stsd_atoms[k].audio.bytes_per_frame /
trak->stsd_atoms[k].audio.bytes_per_packet) *
@@ -1188,7 +1260,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
}
/* see if the trak deserves a promotion to VBR */
- if (BE_16(&trak_atom[atom_pos + 0x18]) == 0xFFFE)
+ if (_X_BE_16(&trak_atom[atom_pos + 0x18]) == 0xFFFE)
trak->stsd_atoms[k].audio.vbr = 1;
else
trak->stsd_atoms[k].audio.vbr = 0;
@@ -1218,10 +1290,10 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* check for a MS-style WAVE format header */
if ((current_atom_size >= 0x4C) &&
- (BE_32(&trak_atom[atom_pos + 0x34]) == WAVE_ATOM) &&
- (BE_32(&trak_atom[atom_pos + 0x3C]) == FRMA_ATOM) &&
- (ME_32(&trak_atom[atom_pos + 0x48]) == trak->stsd_atoms[k].audio.codec_fourcc)) {
- int wave_size = BE_32(&trak_atom[atom_pos + 0x44]) - 8;
+ (_X_BE_32(&trak_atom[atom_pos + 0x34]) == WAVE_ATOM) &&
+ (_X_BE_32(&trak_atom[atom_pos + 0x3C]) == FRMA_ATOM) &&
+ (_X_ME_32(&trak_atom[atom_pos + 0x48]) == trak->stsd_atoms[k].audio.codec_fourcc)) {
+ const int wave_size = _X_BE_32(&trak_atom[atom_pos + 0x44]) - 8;
if ((wave_size >= sizeof(xine_waveformatex)) &&
(current_atom_size >= (0x4C + wave_size))) {
@@ -1271,15 +1343,15 @@ static qt_error parse_trak_atom (qt_trak *trak,
atom_pos += current_stsd_atom_size;
properties_offset += current_stsd_atom_size;
}
-
- } else if (current_atom == ESDS_ATOM) {
-
- uint32_t len;
+ break;
+
+ case ESDS_ATOM:
debug_atom_load(" qt/mpeg-4 esds atom\n");
if ((trak->type == MEDIA_VIDEO) ||
(trak->type == MEDIA_AUDIO)) {
+ uint32_t len;
j = i + 8;
if( trak_atom[j++] == 0x03 ) {
@@ -1302,25 +1374,25 @@ static qt_error parse_trak_atom (qt_trak *trak,
}
}
}
+ break;
- } else if (current_atom == AVCC_ATOM) {
-
+ case AVCC_ATOM:
debug_atom_load(" avcC atom\n");
trak->decoder_config_len = current_atom_size - 8;
trak->decoder_config = realloc(trak->decoder_config, trak->decoder_config_len);
memcpy(trak->decoder_config, &trak_atom[i + 4], trak->decoder_config_len);
+ break;
- } else if (current_atom == STSZ_ATOM) {
-
+ case STSZ_ATOM:
/* there should only be one of these atoms */
if (trak->sample_size_table) {
last_error = QT_HEADER_TROUBLE;
goto free_trak;
}
- trak->sample_size = BE_32(&trak_atom[i + 8]);
- trak->sample_size_count = BE_32(&trak_atom[i + 12]);
+ trak->sample_size = _X_BE_32(&trak_atom[i + 8]);
+ trak->sample_size_count = _X_BE_32(&trak_atom[i + 12]);
debug_atom_load(" qt stsz atom (sample size atom): sample size = %d, %d entries\n",
trak->sample_size, trak->sample_size_count);
@@ -1336,7 +1408,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* load the sample size table */
for (j = 0; j < trak->sample_size_count; j++) {
trak->sample_size_table[j] =
- BE_32(&trak_atom[i + 16 + j * 4]);
+ _X_BE_32(&trak_atom[i + 16 + j * 4]);
debug_atom_load(" sample size %d: %d\n",
j, trak->sample_size_table[j]);
}
@@ -1344,16 +1416,16 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* set the pointer to non-NULL to indicate that the atom type has
* already been seen for this trak atom */
trak->sample_size_table = (void *)-1;
+ break;
- } else if (current_atom == STSS_ATOM) {
-
+ case STSS_ATOM:
/* there should only be one of these atoms */
if (trak->sync_sample_table) {
last_error = QT_HEADER_TROUBLE;
goto free_trak;
}
- trak->sync_sample_count = BE_32(&trak_atom[i + 8]);
+ trak->sync_sample_count = _X_BE_32(&trak_atom[i + 8]);
debug_atom_load(" qt stss atom (sample sync atom): %d sync samples\n",
trak->sync_sample_count);
@@ -1368,27 +1440,26 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* load the sync sample table */
for (j = 0; j < trak->sync_sample_count; j++) {
trak->sync_sample_table[j] =
- BE_32(&trak_atom[i + 12 + j * 4]);
+ _X_BE_32(&trak_atom[i + 12 + j * 4]);
debug_atom_load(" sync sample %d: sample %d (%d) is a keyframe\n",
j, trak->sync_sample_table[j],
trak->sync_sample_table[j] - 1);
}
+ break;
- } else if (current_atom == STCO_ATOM) {
-
+ case STCO_ATOM:
/* there should only be one of either stco or co64 */
if (trak->chunk_offset_table) {
last_error = QT_HEADER_TROUBLE;
goto free_trak;
}
- trak->chunk_offset_count = BE_32(&trak_atom[i + 8]);
+ trak->chunk_offset_count = _X_BE_32(&trak_atom[i + 8]);
debug_atom_load(" qt stco atom (32-bit chunk offset atom): %d chunk offsets\n",
trak->chunk_offset_count);
- trak->chunk_offset_table = (int64_t *)malloc(
- trak->chunk_offset_count * sizeof(int64_t));
+ trak->chunk_offset_table = calloc(trak->chunk_offset_count, sizeof(int64_t));
if (!trak->chunk_offset_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1397,26 +1468,25 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* load the chunk offset table */
for (j = 0; j < trak->chunk_offset_count; j++) {
trak->chunk_offset_table[j] =
- BE_32(&trak_atom[i + 12 + j * 4]);
+ _X_BE_32(&trak_atom[i + 12 + j * 4]);
debug_atom_load(" chunk %d @ 0x%"PRIX64"\n",
j, trak->chunk_offset_table[j]);
}
+ break;
- } else if (current_atom == CO64_ATOM) {
-
+ case CO64_ATOM:
/* there should only be one of either stco or co64 */
if (trak->chunk_offset_table) {
last_error = QT_HEADER_TROUBLE;
goto free_trak;
}
- trak->chunk_offset_count = BE_32(&trak_atom[i + 8]);
+ trak->chunk_offset_count = _X_BE_32(&trak_atom[i + 8]);
debug_atom_load(" qt co64 atom (64-bit chunk offset atom): %d chunk offsets\n",
trak->chunk_offset_count);
- trak->chunk_offset_table = (int64_t *)malloc(
- trak->chunk_offset_count * sizeof(int64_t));
+ trak->chunk_offset_table = calloc(trak->chunk_offset_count, sizeof(int64_t));
if (!trak->chunk_offset_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1425,29 +1495,28 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* load the 64-bit chunk offset table */
for (j = 0; j < trak->chunk_offset_count; j++) {
trak->chunk_offset_table[j] =
- BE_32(&trak_atom[i + 12 + j * 8 + 0]);
+ _X_BE_32(&trak_atom[i + 12 + j * 8 + 0]);
trak->chunk_offset_table[j] <<= 32;
trak->chunk_offset_table[j] |=
- BE_32(&trak_atom[i + 12 + j * 8 + 4]);
+ _X_BE_32(&trak_atom[i + 12 + j * 8 + 4]);
debug_atom_load(" chunk %d @ 0x%"PRIX64"\n",
j, trak->chunk_offset_table[j]);
}
+ break;
- } else if (current_atom == STSC_ATOM) {
-
+ case STSC_ATOM:
/* there should only be one of these atoms */
if (trak->sample_to_chunk_table) {
last_error = QT_HEADER_TROUBLE;
goto free_trak;
}
- trak->sample_to_chunk_count = BE_32(&trak_atom[i + 8]);
+ trak->sample_to_chunk_count = _X_BE_32(&trak_atom[i + 8]);
debug_atom_load(" qt stsc atom (sample-to-chunk atom): %d entries\n",
trak->sample_to_chunk_count);
- trak->sample_to_chunk_table = (sample_to_chunk_table_t *)malloc(
- trak->sample_to_chunk_count * sizeof(sample_to_chunk_table_t));
+ trak->sample_to_chunk_table = calloc(trak->sample_to_chunk_count, sizeof(sample_to_chunk_table_t));
if (!trak->sample_to_chunk_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1456,33 +1525,32 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* load the sample to chunk table */
for (j = 0; j < trak->sample_to_chunk_count; j++) {
trak->sample_to_chunk_table[j].first_chunk =
- BE_32(&trak_atom[i + 12 + j * 12 + 0]);
+ _X_BE_32(&trak_atom[i + 12 + j * 12 + 0]);
trak->sample_to_chunk_table[j].samples_per_chunk =
- BE_32(&trak_atom[i + 12 + j * 12 + 4]);
+ _X_BE_32(&trak_atom[i + 12 + j * 12 + 4]);
trak->sample_to_chunk_table[j].media_id =
- BE_32(&trak_atom[i + 12 + j * 12 + 8]);
+ _X_BE_32(&trak_atom[i + 12 + j * 12 + 8]);
debug_atom_load(" %d: %d samples/chunk starting at chunk %d (%d) for media id %d\n",
j, trak->sample_to_chunk_table[j].samples_per_chunk,
trak->sample_to_chunk_table[j].first_chunk,
trak->sample_to_chunk_table[j].first_chunk - 1,
trak->sample_to_chunk_table[j].media_id);
}
+ break;
- } else if (current_atom == STTS_ATOM) {
-
+ case STTS_ATOM:
/* there should only be one of these atoms */
if (trak->time_to_sample_table) {
last_error = QT_HEADER_TROUBLE;
goto free_trak;
}
- trak->time_to_sample_count = BE_32(&trak_atom[i + 8]);
+ trak->time_to_sample_count = _X_BE_32(&trak_atom[i + 8]);
debug_atom_load(" qt stts atom (time-to-sample atom): %d entries\n",
trak->time_to_sample_count);
- trak->time_to_sample_table = (time_to_sample_table_t *)malloc(
- (trak->time_to_sample_count+1) * sizeof(time_to_sample_table_t));
+ trak->time_to_sample_table = calloc(trak->time_to_sample_count+1, sizeof(time_to_sample_table_t));
if (!trak->time_to_sample_table) {
last_error = QT_NO_MEMORY;
goto free_trak;
@@ -1491,9 +1559,9 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* load the time to sample table */
for (j = 0; j < trak->time_to_sample_count; j++) {
trak->time_to_sample_table[j].count =
- BE_32(&trak_atom[i + 12 + j * 8 + 0]);
+ _X_BE_32(&trak_atom[i + 12 + j * 8 + 0]);
trak->time_to_sample_table[j].duration =
- BE_32(&trak_atom[i + 12 + j * 8 + 4]);
+ _X_BE_32(&trak_atom[i + 12 + j * 8 + 4]);
debug_atom_load(" %d: count = %d, duration = %d\n",
j, trak->time_to_sample_table[j].count,
trak->time_to_sample_table[j].duration);
@@ -1529,9 +1597,7 @@ static qt_error parse_reference_atom (reference_t *ref,
char *base_mrl) {
int i, j;
- unsigned int ref_atom_size = BE_32(&ref_atom[0]);
- qt_atom current_atom;
- unsigned int current_atom_size;
+ const unsigned int ref_atom_size = _X_BE_32(&ref_atom[0]);
/* initialize reference atom */
ref->url = NULL;
@@ -1540,59 +1606,54 @@ static qt_error parse_reference_atom (reference_t *ref,
/* traverse through the atom looking for the key atoms */
for (i = ATOM_PREAMBLE_SIZE; i < ref_atom_size - 4; i++) {
+ const uint32_t current_atom_size = _X_BE_32(&ref_atom[i - 4]);
+ const qt_atom current_atom = _X_BE_32(&ref_atom[i]);
- current_atom_size = BE_32(&ref_atom[i - 4]);
- current_atom = BE_32(&ref_atom[i]);
-
- if (current_atom == RDRF_ATOM) {
+ switch (current_atom) {
+ case RDRF_ATOM: {
+ size_t string_size = _X_BE_32(&ref_atom[i + 12]);
+ size_t url_offset = 0;
/* if the URL starts with "http://", copy it */
- if (strncmp(&ref_atom[i + 16], "http://", 7) == 0
- || strncmp(&ref_atom[i + 16], "rtsp://", 7) == 0) {
+ if ( memcmp(&ref_atom[i + 16], "http://", 7) &&
+ memcmp(&ref_atom[i + 16], "rtsp://", 7) &&
+ base_mrl )
+ url_offset = strlen(base_mrl);
- /* URL is spec'd to terminate with a NULL; don't trust it */
- ref->url = xine_xmalloc(BE_32(&ref_atom[i + 12]) + 1);
- strncpy(ref->url, &ref_atom[i + 16], BE_32(&ref_atom[i + 12]));
- ref->url[BE_32(&ref_atom[i + 12]) - 1] = '\0';
+ /* otherwise, append relative URL to base MRL */
+ string_size += url_offset;
- } else {
+ ref->url = xine_xmalloc(string_size + 1);
- int string_size;
+ if ( url_offset )
+ strcpy(ref->url, base_mrl);
- if (base_mrl)
- string_size = strlen(base_mrl) + BE_32(&ref_atom[i + 12]) + 1;
- else
- string_size = BE_32(&ref_atom[i + 12]) + 1;
+ memcpy(ref->url + url_offset, &ref_atom[i + 16], _X_BE_32(&ref_atom[i + 12]));
- /* otherwise, append relative URL to base MRL */
- ref->url = xine_xmalloc(string_size);
- if (base_mrl)
- strcpy(ref->url, base_mrl);
- strncat(ref->url, &ref_atom[i + 16], BE_32(&ref_atom[i + 12]));
- ref->url[string_size - 1] = '\0';
- }
+ ref->url[string_size] = '\0';
+ }
debug_atom_load(" qt rdrf URL reference:\n %s\n", ref->url);
+ break;
- } else if (current_atom == RMDR_ATOM) {
-
+ case RMDR_ATOM:
/* load the data rate */
- ref->data_rate = BE_32(&ref_atom[i + 8]);
+ ref->data_rate = _X_BE_32(&ref_atom[i + 8]);
ref->data_rate *= 10;
debug_atom_load(" qt rmdr data rate = %"PRId64"\n", ref->data_rate);
+ break;
- } else if (current_atom == RMVC_ATOM) {
-
+ case RMVC_ATOM:
debug_atom_load(" qt rmvc atom\n");
/* search the rmvc atom for 'qtim'; 2 bytes will follow the qtim
* chars so only search to 6 bytes to the end */
for (j = 4; j < current_atom_size - 6; j++) {
- if (BE_32(&ref_atom[i + j]) == QTIM_ATOM) {
+ if (_X_BE_32(&ref_atom[i + j]) == QTIM_ATOM) {
- ref->qtim_version = BE_16(&ref_atom[i + j + 4]);
+ ref->qtim_version = _X_BE_16(&ref_atom[i + j + 4]);
debug_atom_load(" qtim version = %04X\n", ref->qtim_version);
}
}
@@ -1606,7 +1667,7 @@ static qt_error parse_reference_atom (reference_t *ref,
* building a frame table. */
#define MAX_DURATION 0x7FFFFFFFFFFFFFFFLL
static void get_next_edit_list_entry(qt_trak *trak,
- int *edit_list_index,
+ unsigned int *edit_list_index,
unsigned int *edit_list_media_time,
int64_t *edit_list_duration,
unsigned int global_timescale) {
@@ -1682,8 +1743,7 @@ static qt_error build_frame_table(qt_trak *trak,
/* in this case, the total number of frames is equal to the number of
* entries in the sample size table */
trak->frame_count = trak->sample_size_count;
- trak->frames = (qt_frame *)malloc(
- trak->frame_count * sizeof(qt_frame));
+ trak->frames = calloc(trak->frame_count, sizeof(qt_frame));
if (!trak->frames)
return QT_NO_MEMORY;
trak->current_frame = 0;
@@ -1695,10 +1755,9 @@ static qt_error build_frame_table(qt_trak *trak,
pts_index_countdown =
trak->time_to_sample_table[pts_index].count;
- media_id_counts = xine_xmalloc(trak->stsd_atoms_count * sizeof(int));
+ media_id_counts = xine_xcalloc(trak->stsd_atoms_count, sizeof(int));
if (!media_id_counts)
return QT_NO_MEMORY;
- memset(media_id_counts, 0, trak->stsd_atoms_count * sizeof(int));
/* iterate through each start chunk in the stsc table */
for (i = 0; i < trak->sample_to_chunk_count; i++) {
@@ -1833,8 +1892,7 @@ static qt_error build_frame_table(qt_trak *trak,
/* in this case, the total number of frames is equal to the number of
* chunks */
trak->frame_count = trak->chunk_offset_count;
- trak->frames = (qt_frame *)malloc(
- trak->frame_count * sizeof(qt_frame));
+ trak->frames = calloc(trak->frame_count, sizeof(qt_frame));
if (!trak->frames)
return QT_NO_MEMORY;
@@ -1910,31 +1968,32 @@ static qt_error build_frame_table(qt_trak *trak,
static void parse_moov_atom(qt_info *info, unsigned char *moov_atom,
int64_t bandwidth) {
int i, j;
- unsigned int moov_atom_size = BE_32(&moov_atom[0]);
- qt_atom current_atom;
+ unsigned int moov_atom_size = _X_BE_32(&moov_atom[0]);
int string_size, error;
unsigned int max_video_frames = 0;
unsigned int max_audio_frames = 0;
/* make sure this is actually a moov atom (will also accept 'free' as
* a special case) */
- if ((BE_32(&moov_atom[4]) != MOOV_ATOM) &&
- (BE_32(&moov_atom[4]) != FREE_ATOM)) {
+ if ((_X_BE_32(&moov_atom[4]) != MOOV_ATOM) &&
+ (_X_BE_32(&moov_atom[4]) != FREE_ATOM)) {
info->last_error = QT_NO_MOOV_ATOM;
return;
}
/* prowl through the moov atom looking for very specific targets */
- for (i = ATOM_PREAMBLE_SIZE + 4; i < moov_atom_size - 4; i += BE_32(&moov_atom[i - 4])) {
- current_atom = BE_32(&moov_atom[i]);
+ for (i = ATOM_PREAMBLE_SIZE + 4; i < moov_atom_size - 4; i += _X_BE_32(&moov_atom[i - 4])) {
+ const qt_atom current_atom = _X_BE_32(&moov_atom[i]);
- if (current_atom == MVHD_ATOM) {
+ switch (current_atom) {
+ case MVHD_ATOM:
parse_mvhd_atom(info, &moov_atom[i - 4]);
if (info->last_error != QT_OK)
return;
- } else if (current_atom == TRAK_ATOM) {
+ break;
+ case TRAK_ATOM:
/* create a new trak structure */
info->trak_count++;
info->traks = (qt_trak *)realloc(info->traks,
@@ -1946,43 +2005,50 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom,
info->trak_count--;
return;
}
+ break;
+
+ case UDTA_ATOM:
+ parse_meta_atom(info, &moov_atom[i + 4]);
+ if (info->last_error != QT_OK)
+ return;
+ break;
- } else if (current_atom == META_ATOM) {
-
+ case META_ATOM:
parse_meta_atom(info, &moov_atom[i - 4]);
if (info->last_error != QT_OK)
return;
+ break;
- } else if (current_atom == NAM_ATOM) {
-
- string_size = BE_16(&moov_atom[i + 4]) + 1;
- info->name = realloc (info->name, string_size);
- strncpy(info->name, &moov_atom[i + 8], string_size - 1);
- info->name[string_size - 1] = 0;
-
- } else if (current_atom == CPY_ATOM) {
-
- string_size = BE_16(&moov_atom[i + 4]) + 1;
- info->copyright = realloc (info->copyright, string_size);
- strncpy(info->copyright, &moov_atom[i + 8], string_size - 1);
- info->copyright[string_size - 1] = 0;
-
- } else if (current_atom == DES_ATOM) {
-
- string_size = BE_16(&moov_atom[i + 4]) + 1;
- info->description = realloc (info->description, string_size);
- strncpy(info->description, &moov_atom[i + 8], string_size - 1);
- info->description[string_size - 1] = 0;
+ case NAM_ATOM:
+ string_size = _X_BE_16(&moov_atom[i + 4]);
+ info->name = realloc (info->name, string_size + 1);
+ memcpy(info->name, &moov_atom[i + 8], string_size);
+ info->name[string_size] = 0;
+ break;
- } else if (current_atom == CMT_ATOM) {
+ case CPY_ATOM:
+ string_size = _X_BE_16(&moov_atom[i + 4]);
+ info->copyright = realloc (info->copyright, string_size + 1);
+ memcpy(info->copyright, &moov_atom[i + 8], string_size);
+ info->copyright[string_size] = 0;
+ break;
- string_size = BE_16(&moov_atom[i + 4]) + 1;
- info->comment = realloc (info->comment, string_size);
- strncpy(info->comment, &moov_atom[i + 8], string_size - 1);
- info->comment[string_size - 1] = 0;
+ case DES_ATOM:
+ string_size = _X_BE_16(&moov_atom[i + 4]);
+ info->description = realloc (info->description, string_size + 1);
+ memcpy(info->description, &moov_atom[i + 8], string_size);
+ info->description[string_size] = 0;
+ break;
- } else if (current_atom == RMDA_ATOM) {
+ case CMT_ATOM:
+ string_size = _X_BE_16(&moov_atom[i + 4]);
+ info->comment = realloc (info->comment, string_size + 1);
+ memcpy(info->comment, &moov_atom[i + 8], string_size);
+ info->comment[string_size] = 0;
+ break;
+ case RMDA_ATOM:
+ case RMRA_ATOM:
/* create a new reference structure */
info->reference_count++;
info->references = (reference_t *)realloc(info->references,
@@ -1990,8 +2056,9 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom,
parse_reference_atom(&info->references[info->reference_count - 1],
&moov_atom[i - 4], info->base_mrl);
+ break;
- } else {
+ default:
debug_atom_load(" qt: unknown atom into the moov atom (0x%08X)\n", current_atom);
}
}
@@ -2067,7 +2134,6 @@ static qt_error open_qt_file(qt_info *info, input_plugin_t *input,
unsigned char *moov_atom = NULL;
off_t moov_atom_offset = -1;
int64_t moov_atom_size = -1;
- unsigned char preview[MAX_PREVIEW_SIZE];
/* zlib stuff */
z_stream z_state;
@@ -2090,26 +2156,26 @@ static qt_error open_qt_file(qt_info *info, input_plugin_t *input,
if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE))
find_moov_atom(input, &moov_atom_offset, &moov_atom_size);
else {
- memset (&preview, 0, MAX_PREVIEW_SIZE);
+ unsigned char preview[MAX_PREVIEW_SIZE] = { 0, };
input->get_optional_data(input, preview, INPUT_OPTIONAL_DATA_PREVIEW);
- if (BE_32(&preview[4]) != MOOV_ATOM) {
+ if (_X_BE_32(&preview[4]) != MOOV_ATOM) {
/* special case if there is an ftyp atom first */
- if (BE_32(&preview[4]) == FTYP_ATOM) {
- moov_atom_size = BE_32(&preview[0]);
+ if (_X_BE_32(&preview[4]) == FTYP_ATOM) {
+ moov_atom_size = _X_BE_32(&preview[0]);
if ((moov_atom_size + ATOM_PREAMBLE_SIZE >= MAX_PREVIEW_SIZE) ||
- (BE_32(&preview[moov_atom_size + 4]) != MOOV_ATOM)) {
+ (_X_BE_32(&preview[moov_atom_size + 4]) != MOOV_ATOM)) {
info->last_error = QT_NO_MOOV_ATOM;
return info->last_error;
}
moov_atom_offset = moov_atom_size;
- moov_atom_size = BE_32(&preview[moov_atom_offset]);
+ moov_atom_size = _X_BE_32(&preview[moov_atom_offset]);
} else {
info->last_error = QT_NO_MOOV_ATOM;
return info->last_error;
}
} else {
moov_atom_offset = 0;
- moov_atom_size = BE_32(&preview[0]);
+ moov_atom_size = _X_BE_32(&preview[0]);
}
}
@@ -2140,14 +2206,14 @@ static qt_error open_qt_file(qt_info *info, input_plugin_t *input,
}
/* check if moov is compressed */
- if (BE_32(&moov_atom[12]) == CMOV_ATOM) {
+ if (_X_BE_32(&moov_atom[12]) == CMOV_ATOM) {
info->compressed_header = 1;
z_state.next_in = &moov_atom[0x28];
z_state.avail_in = moov_atom_size - 0x28;
- z_state.avail_out = BE_32(&moov_atom[0x24]);
- unzip_buffer = (unsigned char *)malloc(BE_32(&moov_atom[0x24]));
+ z_state.avail_out = _X_BE_32(&moov_atom[0x24]);
+ unzip_buffer = (unsigned char *)malloc(_X_BE_32(&moov_atom[0x24]));
if (!unzip_buffer) {
free(moov_atom);
info->last_error = QT_NO_MEMORY;
@@ -2186,7 +2252,7 @@ static qt_error open_qt_file(qt_info *info, input_plugin_t *input,
/* replace the compressed moov atom with the decompressed atom */
free (moov_atom);
moov_atom = unzip_buffer;
- moov_atom_size = BE_32(&moov_atom[0]);
+ moov_atom_size = _X_BE_32(&moov_atom[0]);
}
if (!moov_atom) {
@@ -2992,24 +3058,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
break;
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl (input);
- const char *const ending = strrchr(mrl, '.');
-
- if (!ending) {
- free (this);
- return NULL;
- }
-
- if (strncasecmp (ending, ".mov", 4) &&
- strncasecmp (ending, ".qt", 3) &&
- strncasecmp (ending, ".mp4", 4)) {
- free (this);
- return NULL;
- }
- }
-
- /* we want to fall through here */
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT: {
if (!is_qt_file(this->input)) {
@@ -3038,32 +3087,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Apple Quicktime (MOV) and MPEG-4 demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MOV/MPEG-4";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mov qt mp4 m4a m4b";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "video/quicktime: mov,qt: Quicktime animation;"
- "video/x-quicktime: mov,qt: Quicktime animation;"
- "audio/x-m4a: m4a,m4b: MPEG-4 audio;"
- "application/x-quicktimeplayer: qtl: Quicktime list;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_qt_class_t *this = (demux_qt_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_qt_class_t *this;
@@ -3073,11 +3096,15 @@ static void *init_plugin (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Apple Quicktime (MOV) and MPEG-4 demux plugin");
+ this->demux_class.identifier = "MOV/MPEG-4";
+ this->demux_class.mimetypes =
+ "video/quicktime: mov,qt: Quicktime animation;"
+ "video/x-quicktime: mov,qt: Quicktime animation;"
+ "audio/x-m4a: m4a,m4b: MPEG-4 audio;"
+ "application/x-quicktimeplayer: qtl: Quicktime list;";
+ this->demux_class.extensions = "mov qt mp4 m4a m4b";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -3091,6 +3118,6 @@ static const demuxer_info_t demux_info_qt = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "quicktime", XINE_VERSION_CODE, &demux_info_qt, init_plugin },
+ { PLUGIN_DEMUX, 27, "quicktime", XINE_VERSION_CODE, &demux_info_qt, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_rawdv.c b/src/demuxers/demux_rawdv.c
index 7a4cbaec9..10b3170e6 100644
--- a/src/demuxers/demux_rawdv.c
+++ b/src/demuxers/demux_rawdv.c
@@ -15,12 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_rawdv.c,v 1.30 2007/01/19 00:26:40 dgp85 Exp $
- *
* demultiplexer for raw dv streams
*/
@@ -34,10 +32,10 @@
#include <unistd.h>
#include <string.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#define NTSC_FRAME_SIZE 120000
#define NTSC_FRAME_RATE 29.97
@@ -322,12 +320,6 @@ static int demux_raw_dv_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_raw_dv_dispose (demux_plugin_t *this_gen) {
- demux_raw_dv_t *this = (demux_raw_dv_t *) this_gen;
-
- free (this);
-}
-
static int demux_raw_dv_get_stream_length(demux_plugin_t *this_gen) {
demux_raw_dv_t *this = (demux_raw_dv_t *) this_gen;
@@ -356,7 +348,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_raw_dv_send_headers;
this->demux_plugin.send_chunk = demux_raw_dv_send_chunk;
this->demux_plugin.seek = demux_raw_dv_seek;
- this->demux_plugin.dispose = demux_raw_dv_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_raw_dv_get_status;
this->demux_plugin.get_stream_length = demux_raw_dv_get_stream_length;
this->demux_plugin.get_capabilities = demux_raw_dv_get_capabilities;
@@ -384,19 +376,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -413,39 +393,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Raw DV Video stream";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "raw_dv";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "dv dif";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_raw_dv_class_t *this = (demux_raw_dv_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_raw_dv_class_t *this;
this = xine_xmalloc (sizeof (demux_raw_dv_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Raw DV Video stream");
+ this->demux_class.identifier = "raw_dv";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "dv dif";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -459,6 +417,6 @@ static const demuxer_info_t demux_info_raw_dv = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "rawdv", XINE_VERSION_CODE, &demux_info_raw_dv, init_plugin },
+ { PLUGIN_DEMUX, 27, "rawdv", XINE_VERSION_CODE, &demux_info_raw_dv, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index 11b0dbf38..8f6ce0611 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -30,8 +30,6 @@
* (C) Alex Beregszaszi <alex@naxine.org>
*
* Based on FFmpeg's libav/rm.c.
- *
- * $Id: demux_real.c,v 1.113 2007/02/20 00:34:56 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -51,10 +49,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#define FOURCC_TAG BE_FOURCC
@@ -194,11 +192,11 @@ static void real_parse_index(demux_real_t *this) {
}
/* Check chunk is actually an index chunk */
- if(BE_32(&index_chunk_header[0]) == INDX_TAG) {
+ if(_X_BE_32(&index_chunk_header[0]) == INDX_TAG) {
unsigned short version;
/* Check version */
- version = BE_16(&index_chunk_header[8]);
+ 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);
@@ -206,9 +204,9 @@ static void real_parse_index(demux_real_t *this) {
}
/* Read data from header */
- entries = BE_32(&index_chunk_header[10]);
- stream_num = BE_16(&index_chunk_header[14]);
- next_index_chunk = BE_32(&index_chunk_header[16]);
+ 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;
@@ -234,7 +232,7 @@ static void real_parse_index(demux_real_t *this) {
if(index && entries) {
/* Allocate memory for index */
- *index = xine_xmalloc(entries * sizeof(real_index_entry_t));
+ *index = xine_xcalloc(entries, sizeof(real_index_entry_t));
/* Read index */
for(i = 0; i < entries; i++) {
@@ -246,9 +244,9 @@ static void real_parse_index(demux_real_t *this) {
break;
}
- (*index)[i].timestamp = BE_32(&index_record[2]);
- (*index)[i].offset = BE_32(&index_record[6]);
- (*index)[i].packetno = BE_32(&index_record[10]);
+ (*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",
@@ -267,29 +265,23 @@ static void real_parse_index(demux_real_t *this) {
static mdpr_t *real_parse_mdpr(const char *data) {
mdpr_t *mdpr=malloc(sizeof(mdpr_t));
- mdpr->stream_number=BE_16(&data[2]);
- mdpr->max_bit_rate=BE_32(&data[4]);
- mdpr->avg_bit_rate=BE_32(&data[8]);
- mdpr->max_packet_size=BE_32(&data[12]);
- mdpr->avg_packet_size=BE_32(&data[16]);
- mdpr->start_time=BE_32(&data[20]);
- mdpr->preroll=BE_32(&data[24]);
- mdpr->duration=BE_32(&data[28]);
+ mdpr->stream_number=_X_BE_16(&data[2]);
+ mdpr->max_bit_rate=_X_BE_32(&data[4]);
+ mdpr->avg_bit_rate=_X_BE_32(&data[8]);
+ mdpr->max_packet_size=_X_BE_32(&data[12]);
+ mdpr->avg_packet_size=_X_BE_32(&data[16]);
+ mdpr->start_time=_X_BE_32(&data[20]);
+ mdpr->preroll=_X_BE_32(&data[24]);
+ mdpr->duration=_X_BE_32(&data[28]);
mdpr->stream_name_size=data[32];
- mdpr->stream_name=malloc(sizeof(char)*(mdpr->stream_name_size+1));
- memcpy(mdpr->stream_name, &data[33], mdpr->stream_name_size);
- mdpr->stream_name[(int)mdpr->stream_name_size]=0;
+ mdpr->stream_name=xine_memdup0(&data[33], mdpr->stream_name_size);
mdpr->mime_type_size=data[33+mdpr->stream_name_size];
- mdpr->mime_type=malloc(sizeof(char)*(mdpr->mime_type_size+1));
- memcpy(mdpr->mime_type, &data[34+mdpr->stream_name_size], mdpr->mime_type_size);
- mdpr->mime_type[(int)mdpr->mime_type_size]=0;
+ mdpr->mime_type=xine_memdup0(&data[34+mdpr->stream_name_size], mdpr->mime_type_size);
- mdpr->type_specific_len=BE_32(&data[34+mdpr->stream_name_size+mdpr->mime_type_size]);
- mdpr->type_specific_data=malloc(sizeof(char)*(mdpr->type_specific_len));
- memcpy(mdpr->type_specific_data,
- &data[38+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
+ mdpr->type_specific_len=_X_BE_32(&data[34+mdpr->stream_name_size+mdpr->mime_type_size]);
+ mdpr->type_specific_data=xine_memdup(&data[38+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
lprintf("MDPR: stream number: %i\n", mdpr->stream_number);
lprintf("MDPR: maximal bit rate: %i\n", mdpr->max_bit_rate);
@@ -345,14 +337,14 @@ static void real_parse_headers (demux_real_t *this) {
return;
}
- if (BE_32(signature) != RMF_TAG) {
+ if (_X_BE_32(signature) != RMF_TAG) {
this->status = DEMUX_FINISHED;
lprintf ("signature not found '%.4s'\n", signature);
return;
}
/* skip to the start of the first chunk and start traversing */
- chunk_size = BE_32(&signature[4]);
+ 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
@@ -364,8 +356,8 @@ static void real_parse_headers (demux_real_t *this) {
this->status = DEMUX_FINISHED;
return;
}
- chunk_type = BE_32(&preamble[0]);
- chunk_size = BE_32(&preamble[4]);
+ chunk_type = _X_BE_32(&preamble[0]);
+ chunk_size = _X_BE_32(&preamble[4]);
lprintf ("chunktype %.4s len %d\n", (char *) &chunk_type, chunk_size);
switch (chunk_type) {
@@ -383,7 +375,7 @@ static void real_parse_headers (demux_real_t *this) {
return;
}
- version = BE_16(&chunk_buffer[0]);
+ version = _X_BE_16(&chunk_buffer[0]);
if (chunk_type == PROP_TAG) {
@@ -395,10 +387,10 @@ static void real_parse_headers (demux_real_t *this) {
return;
}
- this->duration = BE_32(&chunk_buffer[22]);
- this->index_start = BE_32(&chunk_buffer[30]);
- this->data_start = BE_32(&chunk_buffer[34]);
- this->avg_bitrate = 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);
@@ -427,7 +419,7 @@ static void real_parse_headers (demux_real_t *this) {
lprintf ("parsing type specific data...\n");
- if(BE_32(mdpr->type_specific_data) == RA_TAG) {
+ if(_X_BE_32(mdpr->type_specific_data) == RA_TAG) {
int version, len;
if(this->num_audio_streams == MAX_AUDIO_STREAMS) {
@@ -436,7 +428,7 @@ static void real_parse_headers (demux_real_t *this) {
goto unknown;
}
- version = BE_16(mdpr->type_specific_data + 4);
+ version = _X_BE_16(mdpr->type_specific_data + 4);
lprintf("audio version %d detected\n", version);
@@ -444,14 +436,14 @@ static void real_parse_headers (demux_real_t *this) {
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 = ME_32(mdpr->type_specific_data + mdpr->type_specific_len - 5);
+ fourcc = _X_ME_32(mdpr->type_specific_data + mdpr->type_specific_len - 5);
break;
case 4:
len = *(mdpr->type_specific_data + 56);
- fourcc = ME_32(mdpr->type_specific_data + 58 + len);
+ fourcc = _X_ME_32(mdpr->type_specific_data + 58 + len);
break;
case 5:
- fourcc = ME_32(mdpr->type_specific_data + 66);
+ fourcc = _X_ME_32(mdpr->type_specific_data + 66);
break;
default:
lprintf("unsupported audio header version %d\n", version);
@@ -467,7 +459,7 @@ static void real_parse_headers (demux_real_t *this) {
this->num_audio_streams++;
- } else if(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,
@@ -476,12 +468,12 @@ static void real_parse_headers (demux_real_t *this) {
}
lprintf ("video detected\n");
- fourcc = ME_32(mdpr->type_specific_data + 8);
+ 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 = BE_32(mdpr->type_specific_data + 30);
+ 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;
@@ -506,28 +498,28 @@ unknown:
stream_ptr = 2;
/* load the title string */
- field_size = BE_16(&chunk_buffer[stream_ptr]);
+ 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 = BE_16(&chunk_buffer[stream_ptr]);
+ 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 = BE_16(&chunk_buffer[stream_ptr]);
+ 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 = BE_16(&chunk_buffer[stream_ptr]);
+ 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);
@@ -545,7 +537,7 @@ unknown:
}
/* check version */
- version = BE_16(&data_chunk_header[0]);
+ 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);
@@ -553,8 +545,8 @@ unknown:
return;
}
- this->current_data_chunk_packet_count = BE_32(&data_chunk_header[2]);
- this->next_data_chunk_offset = BE_32(&data_chunk_header[6]);
+ 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;
@@ -625,11 +617,11 @@ unknown:
int i, stream;
/* Check for end of the data chunk */
- if(((id = BE_32(&search_buffer[offset])) == DATA_TAG) ||
+ if(((id = _X_BE_32(&search_buffer[offset])) == DATA_TAG) ||
(id == INDX_TAG))
break;
- stream = BE_16(&search_buffer[offset + 4]);
+ 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) {
@@ -645,7 +637,7 @@ unknown:
}
}
- offset += BE_16(&search_buffer[offset + 2]);
+ offset += _X_BE_16(&search_buffer[offset + 2]);
}
if(INPUT_IS_SEEKABLE(this->input))
@@ -692,7 +684,7 @@ unknown:
this->video_stream->mdpr->avg_bit_rate);
/* Allocate fragment offset table */
- this->fragment_tab = xine_xmalloc(FRAGMENT_TAB_SIZE*sizeof(uint32_t));
+ this->fragment_tab = xine_xcalloc(FRAGMENT_TAB_SIZE, sizeof(uint32_t));
this->fragment_tab_max = FRAGMENT_TAB_SIZE;
}
@@ -716,7 +708,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 = BE_16(mdpr->type_specific_data + 4);
+ int version = _X_BE_16(mdpr->type_specific_data + 4);
if(version != 5) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
@@ -725,9 +717,9 @@ unknown:
goto unsupported;
}
- buf->decoder_info[1] = BE_16(mdpr->type_specific_data + 54);
- buf->decoder_info[2] = BE_16(mdpr->type_specific_data + 58);
- buf->decoder_info[3] = BE_16(mdpr->type_specific_data + 60);
+ buf->decoder_info[1] = _X_BE_16(mdpr->type_specific_data + 54);
+ buf->decoder_info[2] = _X_BE_16(mdpr->type_specific_data + 58);
+ buf->decoder_info[3] = _X_BE_16(mdpr->type_specific_data + 60);
buf->decoder_flags |= BUF_FLAG_STDHEADER;
buf->content = NULL;
@@ -740,7 +732,7 @@ unknown:
buf->type = this->audio_stream->buf_type;
buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_FRAME_END|BUF_FLAG_SPECIAL;
buf->decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG;
- buf->decoder_info[2] = BE_32(mdpr->type_specific_data + 74) - 1;
+ buf->decoder_info[2] = _X_BE_32(mdpr->type_specific_data + 74) - 1;
buf->decoder_info_ptr[2] = buf->content;
buf->size = 0;
@@ -806,8 +798,27 @@ static int demux_real_parse_references( demux_real_t *this) {
lprintf("received %d bytes [%s]\n", buf_used, buf);
- for(i=0;i<buf_used;i++) {
-
+ if (!strncmp(buf,"http://",7))
+ {
+ i = 0;
+ while (buf[i])
+ {
+ j = i;
+ while (buf[i] && !isspace(buf[i]))
+ ++i; /* skip non-space */
+ len = buf[i];
+ buf[i] = 0;
+ if (strncmp (buf + j, "http://", 7) || (i - j) < 8)
+ break; /* stop at the first non-http reference */
+ lprintf("reference [%s] found\n", buf + j);
+ _x_demux_send_mrl_reference (this->stream, 0, buf + j, NULL, 0, 0);
+ buf[i] = (char) len;
+ while (buf[i] && isspace(buf[i]))
+ ++i; /* skip spaces */
+ }
+ }
+ else for (i = 0; i < buf_used; ++i)
+ {
/* "--stop--" is used to have pnm alternative for old real clients
* new real clients will stop processing the file and thus use
* rtsp protocol.
@@ -952,7 +963,7 @@ static int stream_read_char (demux_real_t *this) {
static int stream_read_word (demux_real_t *this) {
uint16_t ret;
this->input->read (this->input, (char *) &ret, 2);
- return BE_16(&ret);
+ return _X_BE_16(&ret);
}
static int demux_real_send_chunk(demux_plugin_t *this_gen) {
@@ -981,7 +992,7 @@ 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 = BE_32(&header[0])) == DATA_TAG) ||
+ if(((id = _X_BE_32(&header[0])) == DATA_TAG) ||
(id == INDX_TAG)) {
lprintf("finished reading data chunk\n");
this->status = DEMUX_FINISHED;
@@ -989,7 +1000,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
}
/* check version */
- version = BE_16(&header[0]);
+ 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);
@@ -998,10 +1009,10 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
}
/* read the packet information */
- stream = BE_16(&header[4]);
+ stream = _X_BE_16(&header[4]);
offset = this->input->get_current_pos(this->input);
- size = BE_16(&header[2]) - DATA_PACKET_HEADER_SIZE;
- timestamp= BE_32(&header[6]);
+ size = _X_BE_16(&header[2]) - DATA_PACKET_HEADER_SIZE;
+ timestamp= _X_BE_32(&header[6]);
pts = (int64_t) timestamp * 90;
/* Data packet header with version 1 contains 1 extra byte */
@@ -1282,7 +1293,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
frames = (stream_read_word(this) & 0xf0) >> 4;
/* 2 bytes per frame size */
- sizes = xine_xmalloc(frames*sizeof(int));
+ sizes = xine_xcalloc(frames, sizeof(int));
for(i = 0; i < frames; i++)
sizes[i] = stream_read_word(this);
@@ -1355,8 +1366,8 @@ discard:
return this->status;
}
lprintf ("**** found next DATA tag\n");
- this->current_data_chunk_packet_count = BE_32(&data_chunk_header[2]);
- this->next_data_chunk_offset = BE_32(&data_chunk_header[6]);
+ 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]);
}
if (!this->current_data_chunk_packet_count) {
@@ -1482,18 +1493,15 @@ static void demux_real_dispose (demux_plugin_t *this_gen) {
for(i = 0; i < this->num_video_streams; i++) {
real_free_mdpr(this->video_streams[i].mdpr);
- if(this->video_streams[i].index)
- free(this->video_streams[i].index);
+ free(this->video_streams[i].index);
}
for(i = 0; i < this->num_audio_streams; i++) {
real_free_mdpr(this->audio_streams[i].mdpr);
- if(this->audio_streams[i].index)
- free(this->audio_streams[i].index);
+ free(this->audio_streams[i].index);
}
- if(this->fragment_tab)
- free(this->fragment_tab);
+ free(this->fragment_tab);
free(this);
}
@@ -1534,7 +1542,8 @@ static int real_check_stream_type(uint8_t *buf, int len)
return 1;
buf[len] = '\0';
- if( strstr(buf,"pnm://") || strstr(buf,"rtsp://") || strstr(buf,"<smil>") )
+ if( strstr(buf,"pnm://") || strstr(buf,"rtsp://") || strstr(buf,"<smil>") ||
+ !strncmp(buf,"http://",7) )
return 2;
return 0;
@@ -1564,22 +1573,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
lprintf ("by content accepted.\n");
break;
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- lprintf ("by extension '%s'\n", mrl);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- return NULL;
- }
- lprintf ("by extension accepted.\n");
- }
-
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -1618,42 +1612,21 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "RealMedia file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "Real";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "rm rmvb ram";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "audio/x-pn-realaudio: ra, rm, ram: Real Media file;"
- "audio/x-pn-realaudio-plugin: rpm: Real Media plugin file;"
- "audio/x-real-audio: ra, rm, ram: Real Media file;"
- "application/vnd.rn-realmedia: ra, rm, ram: Real Media file;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_real_class_t *this = (demux_real_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_real_class_t *this;
this = xine_xmalloc (sizeof (demux_real_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("RealMedia file demux plugin");
+ this->demux_class.identifier = "Real";
+ this->demux_class.mimetypes =
+ "audio/x-pn-realaudio: ra, rm, ram: Real Media file;"
+ "audio/x-pn-realaudio-plugin: rpm: Real Media plugin file;"
+ "audio/x-real-audio: ra, rm, ram: Real Media file;"
+ "application/vnd.rn-realmedia: ra, rm, ram: Real Media file;";
+ this->demux_class.extensions = "rm rmvb ram";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -1667,6 +1640,6 @@ static const demuxer_info_t demux_info_real = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "real", XINE_VERSION_CODE, &demux_info_real, init_class },
+ { PLUGIN_DEMUX, 27, "real", XINE_VERSION_CODE, &demux_info_real, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c
index bf8de0dad..732ddfcc4 100644
--- a/src/demuxers/demux_realaudio.c
+++ b/src/demuxers/demux_realaudio.c
@@ -15,14 +15,12 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* RealAudio File Demuxer by Mike Melanson (melanson@pcisys.net)
* improved by James Stembridge (jstembridge@users.sourceforge.net)
- *
- * $Id: demux_realaudio.c,v 1.34 2007/03/29 17:00:32 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -36,10 +34,10 @@
#include <stdlib.h>
#include <ctype.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -90,13 +88,13 @@ static int open_ra_file(demux_ra_t *this) {
return 0;
/* read version */
- version = BE_16(&file_header[0x04]);
+ version = _X_BE_16(&file_header[0x04]);
/* read header size according to version */
if (version == 3)
- this->header_size = BE_16(&file_header[0x06]) + 8;
+ this->header_size = _X_BE_16(&file_header[0x06]) + 8;
else if (version == 4)
- this->header_size = BE_32(&file_header[0x12]) + 16;
+ this->header_size = _X_BE_32(&file_header[0x12]) + 16;
else {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: unknown version number %d\n", version);
return 0;
@@ -113,18 +111,18 @@ static int open_ra_file(demux_ra_t *this) {
/* read header data according to version */
if((version == 3) && (this->header_size >= 32)) {
- this->data_size = BE_32(&this->header[0x12]);
+ this->data_size = _X_BE_32(&this->header[0x12]);
this->block_align = 240;
offset = 0x16;
} else if(this->header_size >= 72) {
- this->data_size = BE_32(&this->header[0x1C]);
+ this->data_size = _X_BE_32(&this->header[0x1C]);
- this->block_align = BE_16(&this->header[0x2A]);
+ this->block_align = _X_BE_16(&this->header[0x2A]);
if(this->header[0x3D] == 4)
- this->fourcc = ME_32(&this->header[0x3E]);
+ this->fourcc = _X_ME_32(&this->header[0x3E]);
else {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"demux_realaudio: invalid fourcc size %d\n", this->header[0x3D]);
@@ -169,7 +167,7 @@ static int open_ra_file(demux_ra_t *this) {
/* Fourcc for version 3 comes after meta info */
if((version == 3) && ((offset+7) <= this->header_size)) {
if(this->header[offset+2] == 4)
- this->fourcc = ME_32(&this->header[offset+3]);
+ this->fourcc = _X_ME_32(&this->header[offset+3]);
else {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"demux_realaudio: invalid fourcc size %d\n", this->header[offset+2]);
@@ -299,9 +297,7 @@ static int demux_ra_seek (demux_plugin_t *this_gen,
static void demux_ra_dispose (demux_plugin_t *this_gen) {
demux_ra_t *this = (demux_ra_t *) this_gen;
- if(this->header)
- free(this->header);
-
+ free(this->header);
free(this);
}
@@ -313,8 +309,6 @@ static int demux_ra_get_status (demux_plugin_t *this_gen) {
/* return the approximate length in miliseconds */
static int demux_ra_get_stream_length (demux_plugin_t *this_gen) {
- demux_ra_t *this = (demux_ra_t *) this_gen;
-
return 0;
}
@@ -350,19 +344,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -381,39 +363,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "RealAudio file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "RA";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "ra";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "audio/x-realaudio: ra: RealAudio File;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_ra_class_t *this = (demux_ra_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_realaudio_init_plugin (xine_t *xine, void *data) {
demux_ra_class_t *this;
this = xine_xmalloc (sizeof (demux_ra_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("RealAudio file demux plugin");
+ this->demux_class.identifier = "RA";
+ this->demux_class.mimetypes = "audio/x-realaudio: ra: RealAudio File;";
+ this->demux_class.extensions = "ra";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_roq.c b/src/demuxers/demux_roq.c
index 0e7c93b97..83e589be0 100644
--- a/src/demuxers/demux_roq.c
+++ b/src/demuxers/demux_roq.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* RoQ File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information regarding the RoQ file format, visit:
* http://www.csse.monash.edu.au/~timf/
- *
- * $Id: demux_roq.c,v 1.54 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,10 +40,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -95,8 +93,8 @@ static int open_roq_file(demux_roq_t *this) {
return 0;
/* check for the RoQ magic numbers */
- if ((LE_16(&preamble[0]) != RoQ_MAGIC_NUMBER) ||
- (LE_32(&preamble[2]) != 0xFFFFFFFF))
+ if ((_X_LE_16(&preamble[0]) != RoQ_MAGIC_NUMBER) ||
+ (_X_LE_32(&preamble[2]) != 0xFFFFFFFF))
return 0;
this->bih.biSize = sizeof(xine_bmiheader);
@@ -112,7 +110,7 @@ static int open_roq_file(demux_roq_t *this) {
*
* therefore, the frame pts increment is 90000 / fps
*/
- fps = LE_16(&preamble[6]);
+ fps = _X_LE_16(&preamble[6]);
this->frame_pts_inc = 90000 / fps;
/* iterate through the first 2 seconds worth of chunks searching for
@@ -124,16 +122,16 @@ static int open_roq_file(demux_roq_t *this) {
if (this->input->read(this->input, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
break;
- chunk_type = LE_16(&preamble[0]);
- chunk_size = LE_32(&preamble[2]);
+ chunk_type = _X_LE_16(&preamble[0]);
+ chunk_size = _X_LE_32(&preamble[2]);
if (chunk_type == RoQ_INFO) {
/* fetch the width and height; reuse the preamble bytes */
if (this->input->read(this->input, preamble, 8) != 8)
break;
- this->bih.biWidth = LE_16(&preamble[0]);
- this->bih.biHeight = LE_16(&preamble[2]);
+ this->bih.biWidth = _X_LE_16(&preamble[0]);
+ this->bih.biHeight = _X_LE_16(&preamble[2]);
/* if an audio chunk was already found, search is done */
if (this->wave.nChannels)
@@ -188,8 +186,8 @@ static int demux_roq_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- chunk_type = LE_16(&preamble[0]);
- chunk_size = LE_32(&preamble[2]);
+ chunk_type = _X_LE_16(&preamble[0]);
+ chunk_size = _X_LE_32(&preamble[2]);
/* if the chunk is an audio chunk, route it to the audio fifo */
if ((chunk_type == RoQ_SOUND_MONO) || (chunk_type == RoQ_SOUND_STEREO)) {
@@ -379,11 +377,6 @@ static int demux_roq_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_roq_dispose (demux_plugin_t *this) {
-
- free(this);
-}
-
static int demux_roq_get_status (demux_plugin_t *this_gen) {
demux_roq_t *this = (demux_roq_t *) this_gen;
@@ -420,7 +413,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_roq_send_headers;
this->demux_plugin.send_chunk = demux_roq_send_chunk;
this->demux_plugin.seek = demux_roq_seek;
- this->demux_plugin.dispose = demux_roq_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_roq_get_status;
this->demux_plugin.get_stream_length = demux_roq_get_stream_length;
this->demux_plugin.get_capabilities = demux_roq_get_capabilities;
@@ -431,19 +424,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -462,39 +443,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Id RoQ file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "RoQ";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "roq";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_roq_class_t *this = (demux_roq_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_roq_init_plugin (xine_t *xine, void *data) {
demux_roq_class_t *this;
this = xine_xmalloc (sizeof (demux_roq_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Id RoQ file demux plugin");
+ this->demux_class.identifier = "RoQ";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "roq";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_shn.c b/src/demuxers/demux_shn.c
index 3db568aab..d5e46f873 100644
--- a/src/demuxers/demux_shn.c
+++ b/src/demuxers/demux_shn.c
@@ -15,9 +15,7 @@
*
* 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
- *
- * $Id: demux_shn.c,v 1.4 2007/01/19 00:26:40 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
#ifdef HAVE_CONFIG_H
@@ -37,10 +35,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -152,12 +150,6 @@ static int demux_shn_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_shn_dispose (demux_plugin_t *this_gen) {
- demux_shn_t *this = (demux_shn_t *) this_gen;
-
- free(this);
-}
-
static int demux_shn_get_status (demux_plugin_t *this_gen) {
demux_shn_t *this = (demux_shn_t *) this_gen;
@@ -191,7 +183,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_shn_send_headers;
this->demux_plugin.send_chunk = demux_shn_send_chunk;
this->demux_plugin.seek = demux_shn_seek;
- this->demux_plugin.dispose = demux_shn_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_shn_get_status;
this->demux_plugin.get_stream_length = demux_shn_get_stream_length;
this->demux_plugin.get_capabilities = demux_shn_get_capabilities;
@@ -201,19 +193,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->status = DEMUX_FINISHED;
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* Falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
if (!open_shn_file(this)) {
@@ -230,39 +210,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Shorten demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "Shorten";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "shn";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_shn_class_t *this = (demux_shn_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_shn_init_plugin (xine_t *xine, void *data) {
demux_shn_class_t *this;
this = xine_xmalloc (sizeof (demux_shn_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Shorten demux plugin");
+ this->demux_class.identifier = "Shorten";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "shn";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_slave.c b/src/demuxers/demux_slave.c
index a00ad0661..80a5ebbf8 100644
--- a/src/demuxers/demux_slave.c
+++ b/src/demuxers/demux_slave.c
@@ -17,12 +17,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_slave.c,v 1.23 2007/01/19 01:05:24 dgp85 Exp $
- *
* demuxer for slave "protocol"
* master xine must be started with XINE_PARAM_BROADCASTER_PORT set, that is,
* 'xine --broadcast-port <port_number>'
@@ -44,10 +42,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#define SCRATCH_SIZE 1024
#define CHECK_VPTS_INTERVAL 2*90000
@@ -337,16 +335,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl (input);
-
- if(!strncmp(mrl, "slave://", 8))
- break;
-
- free (this);
- return NULL;
- }
-
case METHOD_BY_CONTENT: {
if (_x_demux_read_header(input, this->scratch, SCRATCH_SIZE) > 0) {
@@ -358,6 +346,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -391,39 +380,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "slave";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_slave_class_t *this = (demux_slave_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_slave_class_t *this;
this = xine_xmalloc (sizeof (demux_slave_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = "";
+ this->demux_class.identifier = "slave";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "slave://";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -437,6 +404,6 @@ static const demuxer_info_t demux_info_slave = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "slave", XINE_VERSION_CODE, &demux_info_slave, init_plugin },
+ { PLUGIN_DEMUX, 27, "slave", XINE_VERSION_CODE, &demux_info_slave, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_smjpeg.c b/src/demuxers/demux_smjpeg.c
index 9c86314c5..10cdf8120 100644
--- a/src/demuxers/demux_smjpeg.c
+++ b/src/demuxers/demux_smjpeg.c
@@ -15,15 +15,13 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* SMJPEG File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information on the SMJPEG file format, visit:
* http://www.lokigames.com/development/smjpeg.php3
- *
- * $Id: demux_smjpeg.c,v 1.51 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -41,10 +39,10 @@
/* #define LOG_VERBOSE */
/* #define LOG */
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -119,7 +117,7 @@ static int open_smjpeg_file(demux_smjpeg_t *this) {
this->input->seek(this->input, SMJPEG_SIGNATURE_SIZE + 4, SEEK_SET);
if (this->input->read(this->input, header_chunk, 4) != 4)
return 0;
- this->duration = BE_32(&header_chunk[0]);
+ this->duration = _X_BE_32(&header_chunk[0]);
/* initial state: no video and no audio (until headers found) */
this->video_type = this->audio_type = 0;
@@ -131,7 +129,7 @@ static int open_smjpeg_file(demux_smjpeg_t *this) {
if (this->input->read(this->input, header_chunk, 4) != 4)
return 0;
- chunk_tag = BE_32(&header_chunk[0]);
+ chunk_tag = _X_BE_32(&header_chunk[0]);
switch(chunk_tag) {
@@ -145,8 +143,8 @@ static int open_smjpeg_file(demux_smjpeg_t *this) {
SMJPEG_VIDEO_HEADER_SIZE) != SMJPEG_VIDEO_HEADER_SIZE)
return 0;
- this->bih.biWidth = BE_16(&header_chunk[8]);
- this->bih.biHeight = BE_16(&header_chunk[10]);
+ this->bih.biWidth = _X_BE_16(&header_chunk[8]);
+ this->bih.biHeight = _X_BE_16(&header_chunk[10]);
this->bih.biCompression = *(uint32_t *)&header_chunk[12];
this->video_type = _x_fourcc_to_buf_video(this->bih.biCompression);
break;
@@ -156,13 +154,13 @@ static int open_smjpeg_file(demux_smjpeg_t *this) {
SMJPEG_AUDIO_HEADER_SIZE) != SMJPEG_AUDIO_HEADER_SIZE)
return 0;
- this->audio_sample_rate = BE_16(&header_chunk[4]);
+ this->audio_sample_rate = _X_BE_16(&header_chunk[4]);
this->audio_bits = header_chunk[6];
this->audio_channels = header_chunk[7];
/* ADPCM in these files is ID'd by 'APCM' which is used in other
* files to denote a slightly different format; thus, use the
* following special case */
- if (BE_32(&header_chunk[8]) == APCM_TAG) {
+ if (_X_BE_32(&header_chunk[8]) == APCM_TAG) {
audio_codec = be2me_32(APCM_TAG);
this->audio_type = BUF_AUDIO_SMJPEG_IMA;
} else {
@@ -176,7 +174,7 @@ static int open_smjpeg_file(demux_smjpeg_t *this) {
* of the chunk */
if (this->input->read(this->input, header_chunk, 4) != 4)
return 0;
- this->input->seek(this->input, BE_32(&header_chunk[0]), SEEK_CUR);
+ this->input->seek(this->input, _X_BE_32(&header_chunk[0]), SEEK_CUR);
break;
}
}
@@ -210,8 +208,8 @@ static int demux_smjpeg_send_chunk(demux_plugin_t *this_gen) {
return this->status; /* skip to next while() iteration to bail out */
}
- chunk_tag = BE_32(&preamble[0]);
- remaining_sample_bytes = BE_32(&preamble[8]);
+ chunk_tag = _X_BE_32(&preamble[0]);
+ remaining_sample_bytes = _X_BE_32(&preamble[8]);
/*
* Each sample has an absolute timestamp in millisecond units:
@@ -238,7 +236,7 @@ static int demux_smjpeg_send_chunk(demux_plugin_t *this_gen) {
pts /= (this->audio_sample_rate * this->audio_channels);
audio_frame_count += ((remaining_sample_bytes - 4) * 2);
} else {
- pts = BE_32(&preamble[4]);
+ pts = _X_BE_32(&preamble[4]);
pts *= 90;
}
@@ -364,12 +362,6 @@ static int demux_smjpeg_seek (demux_plugin_t *this_gen, off_t start_pos, int sta
}
-static void demux_smjpeg_dispose (demux_plugin_t *this_gen) {
- demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
-
- free(this);
-}
-
static int demux_smjpeg_get_status (demux_plugin_t *this_gen) {
demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
@@ -409,7 +401,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_smjpeg_send_headers;
this->demux_plugin.send_chunk = demux_smjpeg_send_chunk;
this->demux_plugin.seek = demux_smjpeg_seek;
- this->demux_plugin.dispose = demux_smjpeg_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_smjpeg_get_status;
this->demux_plugin.get_stream_length = demux_smjpeg_get_stream_length;
this->demux_plugin.get_capabilities = demux_smjpeg_get_capabilities;
@@ -420,19 +412,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -451,39 +431,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "SMJPEG file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "SMJPEG";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mjpg";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_smjpeg_class_t *this = (demux_smjpeg_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_smjpeg_init_plugin (xine_t *xine, void *data) {
demux_smjpeg_class_t *this;
this = xine_xmalloc (sizeof (demux_smjpeg_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("SMJPEG file demux plugin");
+ this->demux_class.identifier = "SMJPEG";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "mjpg";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_snd.c b/src/demuxers/demux_snd.c
index 99415890a..d7bdd0839 100644
--- a/src/demuxers/demux_snd.c
+++ b/src/demuxers/demux_snd.c
@@ -15,13 +15,11 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* SND/AU File Demuxer by Mike Melanson (melanson@pcisys.net)
- *
- * $Id: demux_snd.c,v 1.41 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -35,10 +33,10 @@
#include <stdlib.h>
#include <ctype.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -85,17 +83,17 @@ static int open_snd_file(demux_snd_t *this) {
return 0;
/* check the signature */
- if (BE_32(&header[0]) != snd_TAG)
+ if (_X_BE_32(&header[0]) != snd_TAG)
return 0;
/* file is qualified; skip over the header bytes in the stream */
this->input->seek(this->input, SND_HEADER_SIZE, SEEK_SET);
- this->data_start = BE_32(&header[0x04]);
- this->data_size = BE_32(&header[0x08]);
- encoding = BE_32(&header[0x0C]);
- this->audio_sample_rate = BE_32(&header[0x10]);
- this->audio_channels = BE_32(&header[0x14]);
+ this->data_start = _X_BE_32(&header[0x04]);
+ this->data_size = _X_BE_32(&header[0x08]);
+ encoding = _X_BE_32(&header[0x0C]);
+ this->audio_sample_rate = _X_BE_32(&header[0x10]);
+ this->audio_channels = _X_BE_32(&header[0x14]);
/* basic sanity checks on the loaded audio parameters */
if ((!this->audio_sample_rate) ||
@@ -287,12 +285,6 @@ static int demux_snd_seek (demux_plugin_t *this_gen, off_t start_pos, int start_
return this->status;
}
-static void demux_snd_dispose (demux_plugin_t *this_gen) {
- demux_snd_t *this = (demux_snd_t *) this_gen;
-
- free(this);
-}
-
static int demux_snd_get_status (demux_plugin_t *this_gen) {
demux_snd_t *this = (demux_snd_t *) this_gen;
@@ -327,7 +319,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_snd_send_headers;
this->demux_plugin.send_chunk = demux_snd_send_chunk;
this->demux_plugin.seek = demux_snd_seek;
- this->demux_plugin.dispose = demux_snd_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_snd_get_status;
this->demux_plugin.get_stream_length = demux_snd_get_stream_length;
this->demux_plugin.get_capabilities = demux_snd_get_capabilities;
@@ -338,19 +330,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -369,42 +349,20 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "SND/AU file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "SND/AU";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "snd au";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "audio/basic: snd,au: ULAW (Sun) audio;"
- "audio/x-basic: snd,au: ULAW (Sun) audio;"
- "audio/x-pn-au: snd,au: ULAW (Sun) audio;";
-
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_snd_class_t *this = (demux_snd_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_snd_init_plugin (xine_t *xine, void *data) {
demux_snd_class_t *this;
this = xine_xmalloc (sizeof (demux_snd_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("SND/AU file demux plugin");
+ this->demux_class.identifier = "SND/AU";
+ this->demux_class.mimetypes =
+ "audio/basic: snd,au: ULAW (Sun) audio;"
+ "audio/x-basic: snd,au: ULAW (Sun) audio;"
+ "audio/x-pn-au: snd,au: ULAW (Sun) audio;";
+ this->demux_class.extensions = "snd au";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_str.c b/src/demuxers/demux_str.c
index 90dbf2117..f125f09c5 100644
--- a/src/demuxers/demux_str.c
+++ b/src/demuxers/demux_str.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -23,8 +23,6 @@
* and Stuart Caie (kyzer@4u.net)
* This demuxer handles either raw STR files (which are just a concatenation
* of raw compact disc sectors) or STR files with RIFF headers.
- *
- * $Id: demux_str.c,v 1.26 2007/01/19 00:26:40 dgp85 Exp $
*/
/*
@@ -125,10 +123,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -202,8 +200,8 @@ static int open_str_file(demux_str_t *this) {
}
/* check for STR with a RIFF header */
- if ((BE_32(&check_bytes[0]) == RIFF_TAG) &&
- (BE_32(&check_bytes[8]) == CDXA_TAG))
+ if ((_X_BE_32(&check_bytes[0]) == RIFF_TAG) &&
+ (_X_BE_32(&check_bytes[8]) == CDXA_TAG))
local_offset = 0x2C;
else
local_offset = 0;
@@ -220,16 +218,16 @@ static int open_str_file(demux_str_t *this) {
check_bytes[local_offset + 0x13]);
/* check for 12-byte sync marker */
- if ((BE_32(&check_bytes[local_offset + 0]) != 0x00FFFFFF) ||
- (BE_32(&check_bytes[local_offset + 4]) != 0xFFFFFFFF) ||
- (BE_32(&check_bytes[local_offset + 8]) != 0xFFFFFF00)) {
+ 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)) {
lprintf("sector %d sync error\n", sector);
return 0;
}
/* the 32 bits starting at 0x10 and at 0x14 should be the same */
- if (BE_32(&check_bytes[local_offset + 0x10]) !=
- BE_32(&check_bytes[local_offset + 0x14])) {
+ if (_X_BE_32(&check_bytes[local_offset + 0x10]) !=
+ _X_BE_32(&check_bytes[local_offset + 0x14])) {
lprintf("sector %d control bits copy error\n", sector);
return 0;
}
@@ -248,15 +246,15 @@ 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)) &&
- (LE_32(&check_bytes[local_offset + 0x18]) == STR_MAGIC)) {
+ (_X_LE_32(&check_bytes[local_offset + 0x18]) == STR_MAGIC)) {
/* mark this channel as having video data */
this->channel_type[channel] |= CDXA_TYPE_VIDEO;
this->bih[channel].biWidth =
- LE_16(&check_bytes[local_offset + 0x18 + 0x10]);
+ _X_LE_16(&check_bytes[local_offset + 0x18 + 0x10]);
this->bih[channel].biHeight =
- LE_16(&check_bytes[local_offset + 0x18 + 0x12]);
+ _X_LE_16(&check_bytes[local_offset + 0x18 + 0x12]);
}
break;
@@ -349,12 +347,12 @@ static int demux_str_send_chunk(demux_plugin_t *this_gen) {
case CDXA_TYPE_DATA:
/* video chunk */
- if (LE_32(&sector[0x18]) != STR_MAGIC ||
+ if (_X_LE_32(&sector[0x18]) != STR_MAGIC ||
channel != this->default_video_channel) {
return 0;
}
- frame_number = LE_32(&sector[0x18 + 0x08]);
+ frame_number = _X_LE_32(&sector[0x18 + 0x08]);
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->pts = frame_number * FRAME_DURATION;
@@ -365,7 +363,7 @@ static int demux_str_send_chunk(demux_plugin_t *this_gen) {
/* first chunk of frame? sync forthcoming audio packets */
/* FIXME */
- /*if (LE_16(&sector[0x18+0x04]) == 0) {
+ /*if (_X_LE_16(&sector[0x18+0x04]) == 0) {
* int i;
* for (i = 0; i < STR_MAX_CHANNELS; i++) this->audio_pts[i] = buf->pts;
*}
@@ -385,7 +383,7 @@ static int demux_str_send_chunk(demux_plugin_t *this_gen) {
/* if the current chunk is 1 less than the chunk count, this is the
* last chunk of the frame */
- if ((LE_16(&sector[0x18+0x04]) + 1) == LE_16(&sector[0x18+0x06]))
+ if ((_X_LE_16(&sector[0x18+0x04]) + 1) == _X_LE_16(&sector[0x18+0x06]))
buf->decoder_flags |= BUF_FLAG_FRAME_END;
buf->type = BUF_VIDEO_PSX_MDEC | channel;
@@ -520,11 +518,6 @@ static int demux_str_seek (demux_plugin_t *this_gen, off_t start_pos, int start_
return this->status;
}
-static void demux_str_dispose (demux_plugin_t *this) {
-
- free(this);
-}
-
static int demux_str_get_status (demux_plugin_t *this_gen) {
demux_str_t *this = (demux_str_t *) this_gen;
@@ -564,7 +557,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_str_send_headers;
this->demux_plugin.send_chunk = demux_str_send_chunk;
this->demux_plugin.seek = demux_str_seek;
- this->demux_plugin.dispose = demux_str_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_str_get_status;
this->demux_plugin.get_stream_length = demux_str_get_stream_length;
this->demux_plugin.get_capabilities = demux_str_get_capabilities;
@@ -575,19 +568,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -605,39 +586,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Sony Playstation STR file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "PSX STR";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- /* also .mov, but we don't want to hijack that extension */
- return "str iki ik2 dps dat xa xa1 xa2 xas xap";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_str_class_t *this = (demux_str_class_t *) this_gen;
- free (this);
-}
-
void *demux_str_init_plugin (xine_t *xine, void *data) {
demux_str_class_t *this;
this = xine_xmalloc (sizeof (demux_str_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Sony Playstation STR file demux plugin");
+ this->demux_class.identifier = "PSX STR";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "str iki ik2 dps dat xa xa1 xa2 xas xap";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c
index aea0c8ca1..e80e8af70 100644
--- a/src/demuxers/demux_ts.c
+++ b/src/demuxers/demux_ts.c
@@ -15,9 +15,7 @@
*
* 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
- *
- * $Id: demux_ts.c,v 1.129 2007/04/02 10:46:08 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Demultiplexer for MPEG2 Transport Streams.
*
@@ -149,9 +147,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
/*
#define TS_LOG
@@ -180,6 +178,8 @@
#define MAX_PES_BUF_SIZE 2048
+#define CORRUPT_PES_THRESHOLD 10
+
#define NULL_PID 0x1fff
#define INVALID_PID ((unsigned int)(-1))
#define INVALID_PROGRAM ((unsigned int)(-1))
@@ -296,7 +296,7 @@ typedef struct {
uint32_t pmt_pid[MAX_PMTS];
uint8_t *pmt[MAX_PMTS];
uint8_t *pmt_write_ptr[MAX_PMTS];
- uint32_t crc32_table[256];
+ uint32_t last_pmt_crc;
/*
* Stuff to do with the transport header. As well as the video
* and audio PIDs, we keep the index of the corresponding entry
@@ -337,9 +337,10 @@ typedef struct {
int32_t packet_number;
/* NEW: var to keep track of number of last read packets */
int32_t npkt_read;
- int32_t read_zero;
uint8_t buf[BUF_SIZE]; /* == PKT_SIZE * NPKT_PER_READ */
+
+ int numPreview;
} demux_ts_t;
@@ -354,28 +355,6 @@ typedef struct {
} demux_ts_class_t;
-static void demux_ts_build_crc32_table(demux_ts_t*this) {
- uint32_t i, j, k;
-
- for( i = 0 ; i < 256 ; i++ ) {
- k = 0;
- for (j = (i << 24) | 0x800000 ; j != 0x80000000 ; j <<= 1) {
- k = (k << 1) ^ (((k ^ j) & 0x80000000) ? 0x04c11db7 : 0);
- }
- this->crc32_table[i] = k;
- }
-}
-
-static uint32_t demux_ts_compute_crc32(demux_ts_t*this, uint8_t *data,
- uint32_t length, uint32_t crc32) {
- uint32_t i;
-
- for(i = 0; i < length; i++) {
- crc32 = (crc32 << 8) ^ this->crc32_table[(crc32 >> 24) ^ data[i]];
- }
- return crc32;
-}
-
/* redefine abs as macro to handle 64-bit diffs.
i guess llabs may not be available everywhere */
#define abs(x) ( ((x)<0) ? -(x) : (x) )
@@ -443,6 +422,17 @@ static void check_newpts( demux_ts_t *this, int64_t pts, int video )
}
}
+/* Send a BUF_SPU_DVB to let xine know of that channel. */
+static void demux_send_special_spu_buf( demux_ts_t *this, int spu_channel )
+{
+ buf_element_t *buf;
+
+ buf = this->video_fifo->buffer_pool_alloc( this->video_fifo );
+ buf->type = BUF_SPU_DVB|spu_channel;
+ buf->content = buf->mem;
+ buf->size = 0;
+ this->video_fifo->put( this->video_fifo, buf );
+}
/*
* demux_ts_update_spu_channel
@@ -452,7 +442,6 @@ static void check_newpts( demux_ts_t *this, int64_t pts, int video )
*/
static void demux_ts_update_spu_channel(demux_ts_t *this)
{
- xine_event_t ui_event;
buf_element_t *buf;
this->current_spu_channel = this->stream->spu_channel;
@@ -471,6 +460,7 @@ static void demux_ts_update_spu_channel(demux_ts_t *this)
buf->decoder_info[2] = sizeof(lang->desc);
buf->decoder_info_ptr[2] = &(lang->desc);
+ buf->type |= this->current_spu_channel;
this->spu_pid = lang->pid;
this->spu_media = lang->media_index;
@@ -492,11 +482,6 @@ static void demux_ts_update_spu_channel(demux_ts_t *this)
}
this->video_fifo->put(this->video_fifo, buf);
-
- /* Inform UI of SPU channel changes */
- ui_event.type = XINE_EVENT_UI_CHANNELS_CHANGED;
- ui_event.data_length = 0;
- xine_event_send(this->stream, &ui_event);
}
/*
@@ -513,7 +498,7 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt,
unsigned char *pkt, unsigned int pusi) {
uint32_t table_id;
uint32_t section_syntax_indicator;
- uint32_t section_length;
+ int32_t section_length;
uint32_t transport_stream_id;
uint32_t version_number;
uint32_t current_next_indicator;
@@ -588,8 +573,7 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt,
}
/* Check CRC. */
- calc_crc32 = demux_ts_compute_crc32 (this, pkt+5, section_length+3-4,
- 0xffffffff);
+ calc_crc32 = _x_compute_crc32 (pkt+5, section_length+3-4, 0xffffffff);
if (crc32 != calc_crc32) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"demux_ts: demux error! PAT with invalid CRC32: packet_crc32: %.8x calc_crc32: %.8x\n",
@@ -636,6 +620,7 @@ static void demux_ts_parse_pat (demux_ts_t*this, unsigned char *original_pkt,
if (this->pmt_pid[program_count] != pmt_pid) {
this->pmt_pid[program_count] = pmt_pid;
this->audio_tracks_count = 0;
+ this->last_pmt_crc = 0;
this->videoPid = INVALID_PID;
this->spu_pid = INVALID_PID;
}
@@ -683,7 +668,11 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
stream_id = p[3];
if (packet_len==0)
+ {
+ xprintf (xine, XINE_VERBOSITY_DEBUG,
+ "demux_ts: error pes length 0\n");
return 0;
+ }
#ifdef TS_LOG
printf ("demux_ts: packet stream id: %.2x len: %d (%x)\n",
@@ -730,12 +719,11 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
if (stream_id == 0xbd) {
- int track, spu_id;
+ int spu_id;
lprintf ("audio buf = %02X %02X %02X %02X %02X %02X %02X %02X\n",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
- track = p[0] & 0x0F; /* hack : ac3 track */
/*
* we check the descriptor tag first because some stations
* do not include any of the ac3 header info in their audio tracks
@@ -755,7 +743,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
m->content = p;
m->size = packet_len;
- m->type = BUF_SPU_DVB;
+ m->type |= BUF_SPU_DVB;
m->buf->decoder_info[2] = payload_len;
return 1;
} else if ((p[0] & 0xE0) == 0x20) {
@@ -769,7 +757,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
m->content = p+4;
m->size = packet_len - 4;
- m->type |= BUF_AUDIO_A52 + track;
+ m->type |= BUF_AUDIO_A52;
return 1;
} else if ((p[0]&0xf0) == 0xa0) {
@@ -785,7 +773,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
m->content = p+pcm_offset;
m->size = packet_len-pcm_offset;
- m->type |= BUF_AUDIO_LPCM_BE + track;
+ m->type |= BUF_AUDIO_LPCM_BE;
return 1;
}
@@ -816,26 +804,22 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
} else if ((stream_id & 0xe0) == 0xc0) {
- int track;
-
- track = stream_id & 0x1f;
-
m->content = p;
m->size = packet_len;
switch (m->descriptor_tag) {
case ISO_11172_AUDIO:
case ISO_13818_AUDIO:
lprintf ("demux_ts: found MPEG audio track.\n");
- m->type |= BUF_AUDIO_MPEG + track;
+ m->type |= BUF_AUDIO_MPEG;
break;
case ISO_13818_PART7_AUDIO:
case ISO_14496_PART3_AUDIO:
lprintf ("demux_ts: found AAC audio track.\n");
- m->type |= BUF_AUDIO_AAC + track;
+ m->type |= BUF_AUDIO_AAC;
break;
default:
lprintf ("demux_ts: unknown audio type: %d, defaulting to MPEG.\n", m->descriptor_tag);
- m->type |= BUF_AUDIO_MPEG + track;
+ m->type |= BUF_AUDIO_MPEG;
break;
}
return 1;
@@ -890,6 +874,16 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts,
m->buf->decoder_info[1] = BUF_SPECIAL_SPU_DVD_SUBTYPE;
m->buf->decoder_info[2] = SPU_DVD_SUBTYPE_PACKAGE;
}
+ else {
+ if (this->numPreview<5)
+ ++this->numPreview;
+ if ( this->numPreview==1 )
+ m->buf->decoder_flags=BUF_FLAG_HEADER | BUF_FLAG_FRAME_END;
+ else if ( this->numPreview<5 )
+ m->buf->decoder_flags=BUF_FLAG_PREVIEW;
+ else
+ m->buf->decoder_flags=BUF_FLAG_FRAME_END;
+ }
m->buf->pts = m->pts;
m->buf->decoder_info[0] = 1;
@@ -910,12 +904,17 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts,
m->buf = m->fifo->buffer_pool_alloc(m->fifo);
if (!demux_ts_parse_pes_header(this->stream->xine, m, ts, len, this->stream)) {
- m->corrupted_pes = 1;
m->buf->free_buffer(m->buf);
m->buf = NULL;
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+
+ if (m->corrupted_pes > CORRUPT_PES_THRESHOLD) {
+ if (this->videoPid == m->pid)
+ this->videoPid = INVALID_PID;
+ } else {
+ m->corrupted_pes++;
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"demux_ts: PID 0x%.4x: corrupted pes encountered\n", m->pid);
-
+ }
} else {
m->corrupted_pes = 0;
@@ -1073,7 +1072,7 @@ static void demux_ts_parse_pmt (demux_ts_t *this,
unsigned char *stream;
unsigned int i;
int count;
- char *ptr = NULL;
+ uint8_t *ptr = NULL;
unsigned char len;
unsigned int offset=0;
@@ -1180,20 +1179,32 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
crc32 |= (uint32_t) this->pmt[program_count][section_length+3-1] ;
/* Check CRC. */
- calc_crc32 = demux_ts_compute_crc32 (this,
- this->pmt[program_count],
- section_length+3-4, 0xffffffff);
+ calc_crc32 = _x_compute_crc32 (this->pmt[program_count],
+ section_length+3-4, 0xffffffff);
if (crc32 != calc_crc32) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"demux_ts: demux error! PMT with invalid CRC32: packet_crc32: %#.8x calc_crc32: %#.8x\n",
crc32,calc_crc32);
return;
}
-#ifdef TS_PMT_LOG
else {
+#ifdef TS_PMT_LOG
printf ("demux_ts: PMT CRC32 ok.\n");
- }
#endif
+ if ( crc32==this->last_pmt_crc ) {
+#ifdef TS_PMT_LOG
+ printf("demux_ts: PMT with CRC32=%d already parsed. Skipping.\n", crc32);
+#endif
+ return;
+ }
+ else {
+#ifdef TS_PMT_LOG
+ printf("demux_ts: new PMT, parsing...\n");
+#endif
+ this->last_pmt_crc = crc32;
+ }
+ }
+
/*
* ES definitions start here...we are going to learn upto one video
@@ -1244,7 +1255,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
case ISO_14496_PART10_VIDEO:
if (this->videoPid == INVALID_PID) {
#ifdef TS_PMT_LOG
- printf ("demux_ts: PMT video pid 0x%.4x\n", pid);
+ printf ("demux_ts: PMT video pid 0x%.4x type %2.2x\n", pid, stream[0]);
#endif
demux_ts_pes_new(this, this->media_num, pid, this->video_fifo,stream[0]);
this->videoMedia = this->media_num;
@@ -1266,7 +1277,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
}
if(!found) {
#ifdef TS_PMT_LOG
- printf ("demux_ts: PMT audio pid 0x%.4x\n", pid);
+ printf ("demux_ts: PMT audio pid 0x%.4x type %2.2x\n", pid, stream[0]);
#endif
demux_ts_pes_new(this, this->media_num, pid, this->audio_fifo,stream[0]);
this->audio_tracks[this->audio_tracks_count].pid = pid;
@@ -1280,7 +1291,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
break;
case ISO_13818_PRIVATE:
#ifdef TS_PMT_LOG
- printf ("demux_ts: PMT streamtype 13818_PRIVATE, pid: 0x%.4x\n", pid);
+ printf ("demux_ts: PMT streamtype 13818_PRIVATE, pid: 0x%.4x type %2.2x\n", pid, stream[0]);
for (i = 5; i < coded_length; i++)
printf ("%.2x ", stream[i]);
@@ -1289,13 +1300,12 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
break;
case ISO_13818_TYPE_C: /* data carousel */
#ifdef TS_PMT_LOG
- printf ("demux_ts: PMT streamtype 13818_TYPE_C, pid: 0x%.4x\n", pid);
+ printf ("demux_ts: PMT streamtype 13818_TYPE_C, pid: 0x%.4x type %2.2x\n", pid, stream[0]);
#endif
break;
case ISO_13818_PES_PRIVATE:
for (i = 5; i < coded_length; i += stream[i+1] + 2) {
if ((stream[i] == 0x6a) && (this->audio_tracks_count < MAX_AUDIO_TRACKS)) {
- uint32_t format_identifier=0;
int i, found = 0;
for(i = 0; i < this->audio_tracks_count; i++) {
if(this->audio_tracks[i].pid == pid) {
@@ -1305,7 +1315,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
}
if(!found) {
#ifdef TS_PMT_LOG
- printf ("demux_ts: PMT AC3 audio pid 0x%.4x\n", pid);
+ printf ("demux_ts: PMT AC3 audio pid 0x%.4x type %2.2x\n", pid, stream[0]);
#endif
demux_ts_pes_new(this, this->media_num, pid,
this->audio_fifo, 0x81);
@@ -1323,7 +1333,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
else if (stream[i] == 0x56)
{
#ifdef TS_PMT_LOG
- printf ("demux_ts: PMT Teletext, pid: 0x%.4x\n", pid);
+ printf ("demux_ts: PMT Teletext, pid: 0x%.4x type %2.2x\n", pid, stream[0]);
for (i = 5; i < coded_length; i++)
printf ("%.2x ", stream[i]);
@@ -1354,14 +1364,15 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
(stream[pos + 6] << 8) | stream[pos + 7];
lang->pid = pid;
lang->media_index = this->media_num;
- demux_ts_pes_new(this, this->media_num,
- pid, this->video_fifo,
- stream[0]);
+ this->media[this->media_num].type = no;
+ demux_ts_pes_new(this, this->media_num, pid, this->video_fifo, stream[0]);
+ demux_send_special_spu_buf( this, no );
#ifdef TS_LOG
- printf("demux_ts: DVBSUB: pid 0x%.4x: %s page %ld %ld\n",
+ printf("demux_ts: DVBSUB: pid 0x%.4x: %s page %ld %ld type %2.2x\n",
pid, lang->desc.lang,
lang->desc.comp_page_id,
- lang->desc.aux_page_id);
+ lang->desc.aux_page_id,
+ stream[0]);
#endif
}
}
@@ -1433,8 +1444,14 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
this->pcrPid = pid;
}
- /* DVBSUB: update spu decoder */
- demux_ts_update_spu_channel(this);
+ if ( this->stream->spu_channel>=0 && this->spu_langs_count>0 )
+ demux_ts_update_spu_channel( this );
+
+ /* Inform UI of channels changes */
+ xine_event_t ui_event;
+ ui_event.type = XINE_EVENT_UI_CHANNELS_CHANGED;
+ ui_event.data_length = 0;
+ xine_event_send( this->stream, &ui_event );
}
static int sync_correct(demux_ts_t*this, uint8_t *buf, int32_t npkt_read) {
@@ -1531,12 +1548,7 @@ static unsigned char * demux_synchronise(demux_ts_t* this) {
*/
if (this->npkt_read == 0) {
- /* printf ("demux_ts: read 0 packets! (%d)\n", this->read_zero); */
- this->read_zero++;
- } else this->read_zero = 0;
-
- if (this->read_zero > 200) {
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: read 0 packets too many times!\n");
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: read 0 packets\n");
this->status = DEMUX_FINISHED;
return NULL;
}
@@ -1785,13 +1797,27 @@ static void demux_ts_parse_packet (demux_ts_t*this) {
if ( (pes_stream_id >= VIDEO_STREAM_S) && (pes_stream_id <= VIDEO_STREAM_E) ) {
if ( this->videoPid == INVALID_PID) {
-
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "demux_ts: auto-detected video pid 0x%.4x\n", pid);
-
- this->videoPid = pid;
- this->videoMedia = this->media_num;
- demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, pes_stream_id);
+ int i, found = 0;
+ for(i = 0; i < this->media_num; i++) {
+ if (this->media[i].pid == pid) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found && (this->media[i].corrupted_pes == 0)) {
+ this->videoPid = pid;
+ this->videoMedia = i;
+ } else if (!found) {
+ this->videoPid = pid;
+ this->videoMedia = this->media_num;
+ demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, pes_stream_id);
+ }
+
+ if (this->videoPid != INVALID_PID) {
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "demux_ts: auto-detected video pid 0x%.4x\n", pid);
+ }
}
} else if ( (pes_stream_id >= AUDIO_STREAM_S) && (pes_stream_id <= AUDIO_STREAM_E) ) {
if (this->audio_tracks_count < MAX_AUDIO_TRACKS) {
@@ -1891,6 +1917,7 @@ static void demux_ts_event_handler (demux_ts_t *this) {
this->spu_pid = INVALID_PID;
this->spu_media = 0;
this->spu_langs_count= 0;
+ this->last_pmt_crc = 0;
_x_demux_control_start (this->stream);
break;
@@ -1966,6 +1993,7 @@ static void demux_ts_send_headers (demux_plugin_t *this_gen) {
this->videoPid = INVALID_PID;
this->audio_tracks_count = 0;
this->media_num= 0;
+ this->last_pmt_crc = 0;
_x_demux_control_start (this->stream);
@@ -1973,8 +2001,6 @@ static void demux_ts_send_headers (demux_plugin_t *this_gen) {
this->send_newpts = 1;
- demux_ts_build_crc32_table (this);
-
this->status = DEMUX_OK ;
this->send_end_buffers = 1;
@@ -1983,7 +2009,7 @@ static void demux_ts_send_headers (demux_plugin_t *this_gen) {
/* DVBSUB */
this->spu_pid = INVALID_PID;
this->spu_langs_count = 0;
- this->current_spu_channel = this->stream->spu_channel;
+ this->current_spu_channel = -1;
/* FIXME ? */
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1);
@@ -2061,7 +2087,6 @@ static int demux_ts_get_optional_data(demux_plugin_t *this_gen,
demux_ts_t *this = (demux_ts_t *) this_gen;
char *str = data;
int channel = *((int *)data);
- int track_num;
/* be a bit paranoid */
if (this == NULL || this->stream == NULL)
@@ -2072,31 +2097,21 @@ static int demux_ts_get_optional_data(demux_plugin_t *this_gen,
case DEMUX_OPTIONAL_DATA_AUDIOLANG:
if ((channel >= 0) && (channel < this->audio_tracks_count)) {
if(this->audio_tracks[channel].lang)
- strcpy(str, this->audio_tracks[channel].lang);
+ strcpy(str, this->audio_tracks[channel].lang);
else
- sprintf(str, "%3i", _x_get_audio_channel(this->stream));
+ sprintf(str, "%3i", _x_get_audio_channel(this->stream));
+ }
+ else {
+ snprintf(str, XINE_LANG_MAX, "%3i", _x_get_audio_channel(this->stream));
}
- else
- {
- snprintf(str, XINE_LANG_MAX, "%3i", _x_get_audio_channel(this->stream));
- }
return DEMUX_OPTIONAL_SUCCESS;
case DEMUX_OPTIONAL_DATA_SPULANG:
- if (this->current_spu_channel >= 0
- && this->current_spu_channel < this->spu_langs_count)
- {
- memcpy(str, this->spu_langs[this->current_spu_channel].desc.lang, 3);
- str[3] = 0;
- }
- else if (this->current_spu_channel == -1)
- {
- strcpy(str, "none");
- }
- else
- {
- snprintf(str, XINE_LANG_MAX, "%3i", this->current_spu_channel);
- }
+ if (channel>=0 && channel<this->spu_langs_count) {
+ memcpy(str, this->spu_langs[channel].desc.lang, 3);
+ str[3] = 0;}
+ else
+ strcpy(str, "none");
return DEMUX_OPTIONAL_SUCCESS;
default:
@@ -2147,34 +2162,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
}
break;
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl (input);
-
- /* check extension */
- const char *const extensions = class_gen->get_extensions (class_gen);
-
- if (_x_demux_check_extension (mrl, extensions))
- break;
-
- /* accept dvb streams */
- /*
- * Also handle the special dvbs,dvbt and dvbc mrl formats:
- * the content is exactly the same but the input plugin
- * uses a different tuning algorithm [Pragma]
- */
-
- if (!strncasecmp (mrl, "dvb://", 6))
- break;
- if (!strncasecmp (mrl, "dvbs://", 7))
- break;
- if (!strncasecmp (mrl, "dvbc://", 7))
- break;
- if (!strncasecmp (mrl, "dvbt://", 7))
- break;
-
- return NULL;
- }
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -2221,55 +2209,32 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
this->scrambled_npids = 0;
this->videoPid = INVALID_PID;
this->audio_tracks_count = 0;
+ this->last_pmt_crc = 0;
this->rate = 16000; /* FIXME */
this->status = DEMUX_FINISHED;
#ifdef TS_READ_STATS
- for (i=0; i<=NPKT_PER_READ; i++) {
- this->rstat[i] = 0;
- }
+ memset(this-rstat, 0, sizeof(*this->rstat)*NPKT_PER_READ);
#endif
/* DVBSUB */
this->spu_pid = INVALID_PID;
this->spu_langs_count = 0;
- this->current_spu_channel = this->stream->spu_channel;
+ this->current_spu_channel = -1;
/* dvb */
this->event_queue = xine_event_new_queue (this->stream);
+ this->numPreview=0;
+
return &this->demux_plugin;
}
/*
* ts demuxer class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "MPEG Transport Stream demuxer";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MPEG_TS";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "ts m2t trp";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_ts_class_t *this = (demux_ts_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_ts_class_t *this;
@@ -2279,11 +2244,16 @@ static void *init_class (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("MPEG Transport Stream demuxer");
+ this->demux_class.identifier = "MPEG_TS";
+ this->demux_class.mimetypes = NULL;
+
+ /* accept dvb streams; also handle the special dvbs,dvbt and dvbc
+ * mrl formats: the content is exactly the same but the input plugin
+ * uses a different tuning algorithm [Pragma]
+ */
+ this->demux_class.extensions = "ts m2t trp dvb:// dvbs:// dvbc:// dvbt://";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -2298,6 +2268,7 @@ static const demuxer_info_t demux_info_ts = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "mpeg-ts", XINE_VERSION_CODE, &demux_info_ts, init_class },
+ { PLUGIN_DEMUX, 27, "mpeg-ts", XINE_VERSION_CODE, &demux_info_ts, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
+
diff --git a/src/demuxers/demux_tta.c b/src/demuxers/demux_tta.c
index 2e4808b9c..2d35a60e8 100644
--- a/src/demuxers/demux_tta.c
+++ b/src/demuxers/demux_tta.c
@@ -15,23 +15,22 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* True Audio demuxer by Diego Pettenò <flameeyes@gentoo.org>
* Inspired by tta libavformat demuxer by Alex Beregszaszi
- *
- * $Id: demux_tta.c,v 1.4 2007/03/29 16:46:23 dgp85 Exp $
*/
#define LOG_MODULE "demux_tta"
#define LOG_VERBOSE
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
+#include <xine/attributes.h>
typedef struct {
demux_plugin_t demux_plugin;
@@ -56,7 +55,7 @@ typedef struct {
uint32_t samplerate;
uint32_t data_length;
uint32_t crc32;
- } __attribute__((__packed__)) tta;
+ } XINE_PACKED tta;
uint8_t buffer[22]; /* This is the size of the header */
} header;
} demux_tta_t;
@@ -65,16 +64,14 @@ typedef struct {
demux_class_t demux_class;
} demux_tta_class_t;
-#define FOURCC_32(a, b, c, d) (d + (c<<8) + (b<<16) + (a<<24))
-
static int open_tta_file(demux_tta_t *this) {
- uint8_t peek[4];
+ uint32_t peek;
uint32_t framelen;
- if (_x_demux_read_header(this->input, peek, 4) != 4)
+ if (_x_demux_read_header(this->input, &peek, 4) != 4)
return 0;
- if ( BE_32(peek) != FOURCC_32('T', 'T', 'A', '1') )
+ if ( peek != ME_FOURCC('T', 'T', 'A', '1') )
return 0;
if ( this->input->read(this->input, this->header.buffer, sizeof(this->header)) != sizeof(this->header) )
@@ -89,7 +86,7 @@ static int open_tta_file(demux_tta_t *this) {
return 0;
}
- this->seektable = xine_xmalloc(sizeof(uint32_t)*this->totalframes);
+ this->seektable = xine_xcalloc(this->totalframes, sizeof(uint32_t));
this->input->read(this->input, this->seektable, sizeof(uint32_t)*this->totalframes);
/* Skip the CRC32 */
@@ -203,12 +200,6 @@ static int demux_tta_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_tta_dispose (demux_plugin_t *this_gen) {
- demux_tta_t *this = (demux_tta_t *) this_gen;
-
- free(this);
-}
-
static int demux_tta_get_status (demux_plugin_t *this_gen) {
demux_tta_t *this = (demux_tta_t *) this_gen;
@@ -242,7 +233,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_tta_send_headers;
this->demux_plugin.send_chunk = demux_tta_send_chunk;
this->demux_plugin.seek = demux_tta_seek;
- this->demux_plugin.dispose = demux_tta_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_tta_get_status;
this->demux_plugin.get_stream_length = demux_tta_get_stream_length;
this->demux_plugin.get_capabilities = demux_tta_get_capabilities;
@@ -255,19 +246,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* Falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
if (!open_tta_file(this)) {
@@ -284,39 +263,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "True Audio demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "True Audio";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "tta";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_tta_class_t *this = (demux_tta_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_tta_init_plugin (xine_t *xine, void *data) {
demux_tta_class_t *this;
this = xine_xmalloc (sizeof (demux_tta_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("True Audio demux plugin");
+ this->demux_class.identifier = "True Audio";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "tta";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_vmd.c b/src/demuxers/demux_vmd.c
index e2b68fbb1..c2902eac1 100644
--- a/src/demuxers/demux_vmd.c
+++ b/src/demuxers/demux_vmd.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -27,8 +27,6 @@
* Note that the only way that this demuxer validates by content is by
* checking the first 2 bytes, which are 0x2E 0x03 in a Sierra VMD file.
* There is a 1/65536 chance of a false positive using this method.
- *
- * $Id: demux_vmd.c,v 1.4 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -47,10 +45,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -115,7 +113,7 @@ static int open_vmd_file(demux_vmd_t *this) {
VMD_HEADER_SIZE)
return 0;
- if (LE_16(&vmd_header[0]) != VMD_HEADER_SIZE - 2)
+ if (_X_LE_16(&vmd_header[0]) != VMD_HEADER_SIZE - 2)
return 0;
/* file is minimally qualified at this point, proceed to load */
@@ -125,11 +123,11 @@ static int open_vmd_file(demux_vmd_t *this) {
this->data_size = 1;
bih->biSize = sizeof(xine_bmiheader) + VMD_HEADER_SIZE;
- bih->biWidth = LE_16(&vmd_header[12]);
- bih->biHeight = LE_16(&vmd_header[14]);
- this->wave.nSamplesPerSec = LE_16(&vmd_header[804]);
+ bih->biWidth = _X_LE_16(&vmd_header[12]);
+ bih->biHeight = _X_LE_16(&vmd_header[14]);
+ this->wave.nSamplesPerSec = _X_LE_16(&vmd_header[804]);
this->wave.nChannels = (vmd_header[811] & 0x80) ? 2 : 1;
- this->wave.nBlockAlign = LE_16(&vmd_header[806]);
+ this->wave.nBlockAlign = _X_LE_16(&vmd_header[806]);
if (this->wave.nBlockAlign & 0x8000) {
this->wave.nBlockAlign -= 0x8000;
this->wave.wBitsPerSample = 16;
@@ -149,8 +147,8 @@ static int open_vmd_file(demux_vmd_t *this) {
/* skip over the offset table and load the table of contents; don't
* care about the offset table since demuxer will calculate those
* independently */
- toc_offset = LE_32(&vmd_header[812]);
- this->frame_count = LE_16(&vmd_header[6]);
+ toc_offset = _X_LE_32(&vmd_header[812]);
+ this->frame_count = _X_LE_16(&vmd_header[6]);
this->input->seek(this->input, toc_offset + this->frame_count * 6, SEEK_SET);
/* while we have the toal number of blocks, calculate the total running
@@ -172,7 +170,7 @@ static int open_vmd_file(demux_vmd_t *this) {
this->frame_table = xine_xmalloc(this->frame_count * sizeof(vmd_frame_t));
- current_offset = this->data_start = LE_32(&vmd_header[20]);
+ current_offset = this->data_start = _X_LE_32(&vmd_header[20]);
this->data_size = toc_offset - this->data_start;
current_frame_record = raw_frame_table;
total_frames = this->frame_count;
@@ -180,7 +178,7 @@ static int open_vmd_file(demux_vmd_t *this) {
while (total_frames--) {
/* if the frame size is 0, do not count the frame and bring the
* total frame count down */
- this->frame_table[i].frame_size = LE_32(&current_frame_record[2]);
+ this->frame_table[i].frame_size = _X_LE_32(&current_frame_record[2]);
/* this logic is present so that 0-length audio chunks are not
* accounted */
@@ -391,12 +389,6 @@ static int demux_vmd_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_vmd_dispose (demux_plugin_t *this_gen) {
- demux_vmd_t *this = (demux_vmd_t *) this_gen;
-
- free(this);
-}
-
static int demux_vmd_get_status (demux_plugin_t *this_gen) {
demux_vmd_t *this = (demux_vmd_t *) this_gen;
@@ -430,7 +422,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_vmd_send_headers;
this->demux_plugin.send_chunk = demux_vmd_send_chunk;
this->demux_plugin.seek = demux_vmd_seek;
- this->demux_plugin.dispose = demux_vmd_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_vmd_get_status;
this->demux_plugin.get_stream_length = demux_vmd_get_stream_length;
this->demux_plugin.get_capabilities = demux_vmd_get_capabilities;
@@ -441,19 +433,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -472,39 +452,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Sierra VMD file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "VMD";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "vmd";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_vmd_class_t *this = (demux_vmd_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_vmd_init_plugin (xine_t *xine, void *data) {
demux_vmd_class_t *this;
this = xine_xmalloc (sizeof (demux_vmd_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Sierra VMD file demux plugin");
+ this->demux_class.identifier = "VMD";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "vmd";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_voc.c b/src/demuxers/demux_voc.c
index 1c1675b92..ce42d61d8 100644
--- a/src/demuxers/demux_voc.c
+++ b/src/demuxers/demux_voc.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -24,8 +24,6 @@
* possibly be seen in a VOC file. It only plays the first block in a file.
* It will only play that block if it is PCM data. More variations will be
* supported as they are encountered.
- *
- * $Id: demux_voc.c,v 1.41 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -39,10 +37,10 @@
#include <stdlib.h>
#include <ctype.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -87,11 +85,11 @@ static int open_voc_file(demux_voc_t *this) {
return 0;
/* check the signature */
- if (strncmp(header, VOC_SIGNATURE, strlen(VOC_SIGNATURE)) != 0)
+ if (memcmp(header, VOC_SIGNATURE, strlen(VOC_SIGNATURE)) != 0)
return 0;
/* file is qualified */
- first_block_offset = LE_16(&header[0x14]);
+ first_block_offset = _X_LE_16(&header[0x14]);
this->input->seek(this->input, first_block_offset, SEEK_SET);
/* load the block preamble */
@@ -265,12 +263,6 @@ static int demux_voc_seek (demux_plugin_t *this_gen, off_t start_pos, int start_
return this->status;
}
-static void demux_voc_dispose (demux_plugin_t *this_gen) {
- demux_voc_t *this = (demux_voc_t *) this_gen;
-
- free(this);
-}
-
static int demux_voc_get_status (demux_plugin_t *this_gen) {
demux_voc_t *this = (demux_voc_t *) this_gen;
@@ -305,7 +297,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_voc_send_headers;
this->demux_plugin.send_chunk = demux_voc_send_chunk;
this->demux_plugin.seek = demux_voc_seek;
- this->demux_plugin.dispose = demux_voc_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_voc_get_status;
this->demux_plugin.get_stream_length = demux_voc_get_stream_length;
this->demux_plugin.get_capabilities = demux_voc_get_capabilities;
@@ -316,19 +308,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -347,39 +327,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "VOC file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "VOC";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "voc";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_voc_class_t *this = (demux_voc_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_voc_init_plugin (xine_t *xine, void *data) {
demux_voc_class_t *this;
this = xine_xmalloc (sizeof (demux_voc_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("VOC file demux plugin");
+ this->demux_class.identifier = "VOC";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "voc";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_vox.c b/src/demuxers/demux_vox.c
index c772e4978..306f2414f 100644
--- a/src/demuxers/demux_vox.c
+++ b/src/demuxers/demux_vox.c
@@ -15,15 +15,12 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* VOX Demuxer by Mike Melanson (melanson@pcisys.net)
* This a demuxer for .vox files containing raw Dialogic ADPCM data.
- *
- * $Id: demux_vox.c,v 1.14 2007/01/19 00:26:40 dgp85 Exp $
- *
*/
#ifdef HAVE_CONFIG_H
@@ -37,10 +34,10 @@
#include <stdlib.h>
#include <ctype.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -153,12 +150,6 @@ static int demux_vox_seek (demux_plugin_t *this_gen, off_t start_pos, int start_
return this->status;
}
-static void demux_vox_dispose (demux_plugin_t *this_gen) {
- demux_vox_t *this = (demux_vox_t *) this_gen;
-
- free(this);
-}
-
static int demux_vox_get_status (demux_plugin_t *this_gen) {
demux_vox_t *this = (demux_vox_t *) this_gen;
@@ -190,17 +181,11 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
case METHOD_BY_CONTENT:
- case METHOD_EXPLICIT:
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
+ return NULL;
- if (!_x_demux_check_extension (mrl, extensions))
- return NULL;
- }
- break;
+ case METHOD_EXPLICIT:
+ case METHOD_BY_MRL:
+ break;
default:
return NULL;
@@ -213,7 +198,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_vox_send_headers;
this->demux_plugin.send_chunk = demux_vox_send_chunk;
this->demux_plugin.seek = demux_vox_seek;
- this->demux_plugin.dispose = demux_vox_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_vox_get_status;
this->demux_plugin.get_stream_length = demux_vox_get_stream_length;
this->demux_plugin.get_capabilities = demux_vox_get_capabilities;
@@ -225,39 +210,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Dialogic VOX file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "VOX";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "vox";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_vox_class_t *this = (demux_vox_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_vox_init_plugin (xine_t *xine, void *data) {
demux_vox_class_t *this;
this = xine_xmalloc (sizeof (demux_vox_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Dialogic VOX file demux plugin");
+ this->demux_class.identifier = "VOX";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "vox";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_vqa.c b/src/demuxers/demux_vqa.c
index 56fbde7d1..3acd56bc1 100644
--- a/src/demuxers/demux_vqa.c
+++ b/src/demuxers/demux_vqa.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -28,8 +28,6 @@
* However, seeking is infeasible due to the audio encoding: Each audio
* block needs information from the previous audio block in order to be
* decoded, thus making random seeking difficult.
- *
- * $Id: demux_vqa.c,v 1.42 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,10 +40,10 @@
#include <string.h>
#include <stdlib.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -98,8 +96,8 @@ static int open_vqa_file(demux_vqa_t *this) {
return 0;
/* check for the VQA signatures */
- if ((BE_32(&scratch[0]) != FORM_TAG) ||
- (BE_32(&scratch[8]) != WVQA_TAG))
+ if ((_X_BE_32(&scratch[0]) != FORM_TAG) ||
+ (_X_BE_32(&scratch[8]) != WVQA_TAG))
return 0;
/* file is qualified; skip to the start of the VQA header */
@@ -115,9 +113,9 @@ static int open_vqa_file(demux_vqa_t *this) {
return 0;
bih->biSize = sizeof(xine_bmiheader) + VQA_HEADER_SIZE;
- bih->biWidth = LE_16(&vqa_header[6]);
- bih->biHeight = LE_16(&vqa_header[8]);
- this->wave.nSamplesPerSec = LE_16(&vqa_header[24]);
+ bih->biWidth = _X_LE_16(&vqa_header[6]);
+ bih->biHeight = _X_LE_16(&vqa_header[8]);
+ this->wave.nSamplesPerSec = _X_LE_16(&vqa_header[24]);
this->wave.nChannels = vqa_header[26];
this->wave.wBitsPerSample = 16;
@@ -125,7 +123,7 @@ static int open_vqa_file(demux_vqa_t *this) {
if (this->input->read(this->input, scratch, VQA_PREAMBLE_SIZE) !=
VQA_PREAMBLE_SIZE)
return 0;
- chunk_size = BE_32(&scratch[4]);
+ chunk_size = _X_BE_32(&scratch[4]);
this->input->seek(this->input, chunk_size, SEEK_CUR);
this->video_pts = this->audio_frames = 0;
@@ -152,7 +150,7 @@ static int demux_vqa_send_chunk(demux_plugin_t *this_gen) {
}
current_file_pos = this->input->get_current_pos(this->input);
- chunk_size = BE_32(&preamble[4]);
+ chunk_size = _X_BE_32(&preamble[4]);
skip_byte = chunk_size & 0x1;
audio_pts = this->audio_frames;
audio_pts *= 90000;
@@ -204,7 +202,7 @@ static int demux_vqa_send_chunk(demux_plugin_t *this_gen) {
}
current_file_pos = this->input->get_current_pos(this->input);
- chunk_size = BE_32(&preamble[4]);
+ chunk_size = _X_BE_32(&preamble[4]);
while (chunk_size) {
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_VIDEO_VQA;
@@ -306,12 +304,6 @@ static int demux_vqa_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_vqa_dispose (demux_plugin_t *this_gen) {
- demux_vqa_t *this = (demux_vqa_t *) this_gen;
-
- free(this);
-}
-
static int demux_vqa_get_status (demux_plugin_t *this_gen) {
demux_vqa_t *this = (demux_vqa_t *) this_gen;
@@ -343,7 +335,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_vqa_send_headers;
this->demux_plugin.send_chunk = demux_vqa_send_chunk;
this->demux_plugin.seek = demux_vqa_seek;
- this->demux_plugin.dispose = demux_vqa_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_vqa_get_status;
this->demux_plugin.get_stream_length = demux_vqa_get_stream_length;
this->demux_plugin.get_capabilities = demux_vqa_get_capabilities;
@@ -354,19 +346,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -385,39 +365,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Westwood Studios VQA file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "VQA";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "vqa";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_vqa_class_t *this = (demux_vqa_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_vqa_init_plugin (xine_t *xine, void *data) {
demux_vqa_class_t *this;
this = xine_xmalloc (sizeof (demux_vqa_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Westwood Studios VQA file demux plugin");
+ this->demux_class.identifier = "VQA";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "vqa";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c
index 1e46d8526..b8f0d0194 100644
--- a/src/demuxers/demux_wav.c
+++ b/src/demuxers/demux_wav.c
@@ -15,14 +15,12 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* MS WAV File Demuxer by Mike Melanson (melanson@pcisys.net)
* based on WAV specs that are available far and wide
- *
- * $Id: demux_wav.c,v 1.65 2007/03/17 20:57:04 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -36,10 +34,10 @@
#include <stdlib.h>
#include <ctype.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "group_audio.h"
@@ -123,8 +121,8 @@ static int open_wav_file(demux_wav_t *this) {
free (this->wave);
return 0;
}
- chunk_tag = LE_32(&chunk_preamble[0]);
- chunk_size = LE_32(&chunk_preamble[4]);
+ chunk_tag = _X_LE_32(&chunk_preamble[0]);
+ chunk_size = _X_LE_32(&chunk_preamble[4]);
if (chunk_tag == data_TAG) {
this->data_start = this->input->get_current_pos(this->input);
@@ -353,19 +351,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -393,42 +379,21 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "WAV file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "WAV";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "wav";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "audio/x-wav: wav: WAV audio;"
- "audio/wav: wav: WAV audio;"
- "audio/x-pn-wav: wav: WAV audio;"
- "audio/x-pn-windows-acm: wav: WAV audio;";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_wav_class_t *this = (demux_wav_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_wav_init_plugin (xine_t *xine, void *data) {
demux_wav_class_t *this;
this = xine_xmalloc (sizeof (demux_wav_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("WAV file demux plugin");
+ this->demux_class.identifier = "WAV";
+ this->demux_class.mimetypes =
+ "audio/x-wav: wav: WAV audio;"
+ "audio/wav: wav: WAV audio;"
+ "audio/x-pn-wav: wav: WAV audio;"
+ "audio/x-pn-windows-acm: wav: WAV audio;";
+ this->demux_class.extensions = "wav";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c
index fa1cfb17d..bb9a40306 100644
--- a/src/demuxers/demux_wc3movie.c
+++ b/src/demuxers/demux_wc3movie.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -23,8 +23,6 @@
* by Mike Melanson (melanson@pcisys.net)
* For more information on the MVE file format, visit:
* http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: demux_wc3movie.c,v 1.54 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -44,10 +42,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#include "group_games.h"
@@ -104,7 +102,7 @@ typedef struct {
} demux_mve_class_t;
/* bizarre palette lookup table */
-const unsigned char wc3_pal_lookup[] = {
+static const unsigned char wc3_pal_lookup[] = {
0x00, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0E, 0x10, 0x12, 0x13, 0x15, 0x16,
0x18, 0x19, 0x1A,
0x1C, 0x1D, 0x1F, 0x20, 0x21, 0x23, 0x24, 0x25, 0x27, 0x28, 0x29, 0x2A, 0x2C,
@@ -159,9 +157,9 @@ static int demux_mve_send_chunk(demux_plugin_t *this_gen) {
PREAMBLE_SIZE)
this->status = DEMUX_FINISHED;
else {
- chunk_tag = BE_32(&preamble[0]);
+ chunk_tag = _X_BE_32(&preamble[0]);
/* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
+ chunk_size = (_X_BE_32(&preamble[4]) + 1) & (~1);
if (chunk_tag == BRCH_TAG) {
/* empty chunk; do nothing */
@@ -185,7 +183,7 @@ static int demux_mve_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- palette_number = LE_32(&preamble[0]);
+ palette_number = _X_LE_32(&preamble[0]);
if (palette_number >= this->number_of_shots) {
xine_log(this->stream->xine, XINE_LOG_MSG,
@@ -359,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 ((BE_32(&header[0]) != FORM_TAG) ||
- (BE_32(&header[8]) != MOVE_TAG) ||
- (BE_32(&header[12]) != PC_TAG))
+ if ((_X_BE_32(&header[0]) != FORM_TAG) ||
+ (_X_BE_32(&header[8]) != MOVE_TAG) ||
+ (_X_BE_32(&header[12]) != PC_TAG))
return 0;
/* file is qualified */
@@ -377,20 +375,18 @@ static int open_mve_file(demux_mve_t *this) {
this->input->seek(this->input, 0x1C, SEEK_SET);
if (this->input->read(this->input, preamble, 4) != 4)
return 0;
- this->number_of_shots = LE_32(&preamble[0]);
+ this->number_of_shots = _X_LE_32(&preamble[0]);
/* allocate space for the shot offset index and set offsets to 0 */
- this->shot_offsets = xine_xmalloc(this->number_of_shots * sizeof(off_t));
+ this->shot_offsets = xine_xcalloc(this->number_of_shots, sizeof(off_t));
this->current_shot = 0;
- for (i = 0; i < this->number_of_shots; i++)
- this->shot_offsets[i] = 0;
/* skip the SOND chunk */
this->input->seek(this->input, 12, SEEK_CUR);
/* load the palette chunks */
- this->palettes = xine_xmalloc(this->number_of_shots * PALETTE_SIZE *
- sizeof(palette_entry_t));
+ this->palettes = xine_xcalloc(this->number_of_shots, PALETTE_SIZE *
+ sizeof(palette_entry_t));
for (i = 0; i < this->number_of_shots; i++) {
/* make sure there was a valid palette chunk preamble */
if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
@@ -400,8 +396,8 @@ static int open_mve_file(demux_mve_t *this) {
return 0;
}
- if ((BE_32(&preamble[0]) != PALT_TAG) ||
- (BE_32(&preamble[4]) != PALETTE_CHUNK_SIZE)) {
+ if ((_X_BE_32(&preamble[0]) != PALT_TAG) ||
+ (_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);
@@ -450,9 +446,9 @@ static int open_mve_file(demux_mve_t *this) {
return 0;
}
- chunk_tag = BE_32(&preamble[0]);
+ chunk_tag = _X_BE_32(&preamble[0]);
/* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
+ chunk_size = (_X_BE_32(&preamble[4]) + 1) & (~1);
switch (chunk_tag) {
@@ -481,8 +477,8 @@ static int open_mve_file(demux_mve_t *this) {
free (this->shot_offsets);
return 0;
}
- this->bih.biWidth = BE_32(&preamble[0]);
- this->bih.biHeight = BE_32(&preamble[4]);
+ this->bih.biWidth = _X_BE_32(&preamble[0]);
+ this->bih.biHeight = _X_BE_32(&preamble[4]);
break;
case INDX_TAG:
@@ -558,9 +554,9 @@ static int demux_mve_seek (demux_plugin_t *this_gen,
return this->status;
}
- chunk_tag = BE_32(&preamble[0]);
+ chunk_tag = _X_BE_32(&preamble[0]);
/* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
+ chunk_size = (_X_BE_32(&preamble[4]) + 1) & (~1);
if (chunk_tag == SHOT_TAG) {
this->shot_offsets[0] =
@@ -599,9 +595,9 @@ static int demux_mve_seek (demux_plugin_t *this_gen,
return this->status;
}
- chunk_tag = BE_32(&preamble[0]);
+ chunk_tag = _X_BE_32(&preamble[0]);
/* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
+ chunk_size = (_X_BE_32(&preamble[4]) + 1) & (~1);
if (chunk_tag == SHOT_TAG) {
this->shot_offsets[i + 1] =
@@ -687,19 +683,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -718,39 +702,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "Wing Commander III Movie (MVE) demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "WC3 Movie";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mve";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_mve_class_t *this = (demux_mve_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_wc3movie_init_plugin (xine_t *xine, void *data) {
demux_mve_class_t *this;
this = xine_xmalloc (sizeof (demux_mve_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("Wing Commander III Movie (MVE) demux plugin");
+ this->demux_class.identifier = "WC3 Movie";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "mve";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
diff --git a/src/demuxers/demux_yuv4mpeg2.c b/src/demuxers/demux_yuv4mpeg2.c
index 4e0bb1069..a0bf31bce 100644
--- a/src/demuxers/demux_yuv4mpeg2.c
+++ b/src/demuxers/demux_yuv4mpeg2.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -23,8 +23,6 @@
* For more information regarding the YUV4MPEG2 file format and associated
* tools, visit:
* http://mjpeg.sourceforge.net/
- *
- * $Id: demux_yuv4mpeg2.c,v 1.44 2007/01/19 00:26:40 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -38,10 +36,10 @@
#include <string.h>
#include <stdlib.h>
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "compat.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/compat.h>
+#include <xine/demux.h>
#include "bswap.h"
#define Y4M_SIGNATURE_SIZE 9
@@ -372,12 +370,6 @@ static int demux_yuv4mpeg2_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_yuv4mpeg2_dispose (demux_plugin_t *this_gen) {
- demux_yuv4mpeg2_t *this = (demux_yuv4mpeg2_t *) this_gen;
-
- free(this);
-}
-
static int demux_yuv4mpeg2_get_status (demux_plugin_t *this_gen) {
demux_yuv4mpeg2_t *this = (demux_yuv4mpeg2_t *) this_gen;
@@ -412,7 +404,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_yuv4mpeg2_send_headers;
this->demux_plugin.send_chunk = demux_yuv4mpeg2_send_chunk;
this->demux_plugin.seek = demux_yuv4mpeg2_seek;
- this->demux_plugin.dispose = demux_yuv4mpeg2_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_yuv4mpeg2_get_status;
this->demux_plugin.get_stream_length = demux_yuv4mpeg2_get_stream_length;
this->demux_plugin.get_capabilities = demux_yuv4mpeg2_get_capabilities;
@@ -423,19 +415,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_EXTENSION: {
- const char *extensions, *mrl;
-
- mrl = input->get_mrl (input);
- extensions = class_gen->get_extensions (class_gen);
-
- if (!_x_demux_check_extension (mrl, extensions)) {
- free (this);
- return NULL;
- }
- }
- /* falling through is intended */
-
+ case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -454,39 +434,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return &this->demux_plugin;
}
-static const char *get_description (demux_class_t *this_gen) {
- return "YUV4MPEG2 file demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "YUV4MPEG2";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "y4m";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_yuv4mpeg2_class_t *this = (demux_yuv4mpeg2_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_plugin (xine_t *xine, void *data) {
demux_yuv4mpeg2_class_t *this;
this = xine_xmalloc (sizeof (demux_yuv4mpeg2_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("YUV4MPEG2 file demux plugin");
+ this->demux_class.identifier = "YUV4MPEG2";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = "y4m";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -500,6 +458,6 @@ static const demuxer_info_t demux_info_yuv4mpeg2 = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "yuv4mpeg2", XINE_VERSION_CODE, &demux_info_yuv4mpeg2, init_plugin },
+ { PLUGIN_DEMUX, 27, "yuv4mpeg2", XINE_VERSION_CODE, &demux_info_yuv4mpeg2, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/demux_yuv_frames.c b/src/demuxers/demux_yuv_frames.c
index 3866f0437..0cef51f60 100644
--- a/src/demuxers/demux_yuv_frames.c
+++ b/src/demuxers/demux_yuv_frames.c
@@ -16,12 +16,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
- * $Id: demux_yuv_frames.c,v 1.24 2007/01/19 01:05:24 dgp85 Exp $
- *
* dummy demultiplexer for raw yuv frames (delivered by v4l)
*/
@@ -41,9 +39,9 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
#define WRAP_THRESHOLD 20000
@@ -166,12 +164,6 @@ static int demux_yuv_frames_get_optional_data(demux_plugin_t *this_gen,
return DEMUX_OPTIONAL_UNSUPPORTED;
}
-static void demux_yuv_frames_dispose (demux_plugin_t *this_gen) {
- demux_yuv_frames_t *this = (demux_yuv_frames_t *) this_gen;
-
- free (this);
-}
-
static demux_plugin_t *open_plugin (demux_class_t *class_gen,
xine_stream_t *stream,
input_plugin_t *input) {
@@ -184,7 +176,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
return NULL;
break;
- case METHOD_BY_EXTENSION: {
+ case METHOD_BY_MRL: {
const char *const mrl = input->get_mrl (input);
if (strncmp (mrl, "v4l:/", 5))
@@ -212,7 +204,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
this->demux_plugin.send_headers = demux_yuv_frames_send_headers;
this->demux_plugin.send_chunk = demux_yuv_frames_send_chunk;
this->demux_plugin.seek = demux_yuv_frames_seek;
- this->demux_plugin.dispose = demux_yuv_frames_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_yuv_frames_get_status;
this->demux_plugin.get_stream_length = demux_yuv_frames_get_stream_length;
this->demux_plugin.get_capabilities = demux_yuv_frames_get_capabilities;
@@ -229,40 +221,17 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
/*
* demuxer class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "YUV frames dummy demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "YUV_FRAMES";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return NULL;
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return NULL;
-}
-
-static void class_dispose (demux_class_t *this_gen) {
- demux_yuv_frames_class_t *this = (demux_yuv_frames_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_yuv_frames_class_t *this;
this = xine_xmalloc (sizeof (demux_yuv_frames_class_t));
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("YUV frames dummy demux plugin");
+ this->demux_class.identifier = "YUV_FRAMES";
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = NULL;
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -276,7 +245,7 @@ static const demuxer_info_t demux_info_yuv_frames = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "yuv_frames", XINE_VERSION_CODE, &demux_info_yuv_frames, init_class },
+ { PLUGIN_DEMUX, 27, "yuv_frames", XINE_VERSION_CODE, &demux_info_yuv_frames, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/ebml.c b/src/demuxers/ebml.c
index 88492dde6..41a91371e 100644
--- a/src/demuxers/ebml.c
+++ b/src/demuxers/ebml.c
@@ -15,13 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* EBML parser
* a lot of ideas from the gstreamer parser
- *
- * $Id: ebml.c,v 1.4 2005/11/28 12:24:57 valtri Exp $
- *
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -34,8 +31,8 @@
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
#include "ebml.h"
@@ -44,20 +41,10 @@
ebml_parser_t *new_ebml_parser (xine_t *xine, input_plugin_t *input) {
ebml_parser_t *ebml;
- ebml = malloc(sizeof(ebml_parser_t));
+ ebml = xine_xmalloc(sizeof(ebml_parser_t));
ebml->xine = xine;
ebml->input = input;
- ebml->version = 0;
- ebml->read_version = 0;
- ebml->max_id_len = 0;
- ebml->max_size_len = 0;
- ebml->doctype = NULL;
- ebml->doctype_version = 0;
- ebml->doctype_read_version = 0;
-
- ebml->level = 0;
-
return ebml;
}
@@ -188,7 +175,7 @@ static int ebml_read_elem_len(ebml_parser_t *ebml, uint64_t *len) {
}
-static int ebml_read_elem_data(ebml_parser_t *ebml, int8_t *buf, int64_t len) {
+static int ebml_read_elem_data(ebml_parser_t *ebml, void *buf, int64_t len) {
if (ebml->input->read(ebml->input, buf, len) != len) {
off_t pos = ebml->input->get_current_pos(ebml->input);
@@ -247,6 +234,7 @@ int ebml_read_uint(ebml_parser_t *ebml, ebml_elem_t *elem, uint64_t *num) {
return 1;
}
+#if 0
int ebml_read_sint (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *num) {
uint8_t data[8];
uint64_t size = elem->len;
@@ -273,6 +261,7 @@ int ebml_read_sint (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *num) {
return 1;
}
+#endif
int ebml_read_float (ebml_parser_t *ebml, ebml_elem_t *elem, double *num) {
@@ -297,12 +286,12 @@ int ebml_read_float (ebml_parser_t *ebml, ebml_elem_t *elem, double *num) {
if (size == 4) {
float f;
- *((uint32_t *) &f) = BE_32(data);
+ *((uint32_t *) &f) = _X_BE_32(data);
*num = f;
} else {
double d;
- *((uint64_t *) &d) = BE_64(data);
+ *((uint64_t *) &d) = _X_BE_64(data);
*num = d;
}
return 1;
@@ -317,6 +306,7 @@ int ebml_read_ascii(ebml_parser_t *ebml, ebml_elem_t *elem, char *str) {
return 1;
}
+#if 0
int ebml_read_utf8 (ebml_parser_t *ebml, ebml_elem_t *elem, char *str) {
return ebml_read_ascii (ebml, elem, str);
}
@@ -324,38 +314,36 @@ int ebml_read_utf8 (ebml_parser_t *ebml, ebml_elem_t *elem, char *str) {
int ebml_read_date (ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *date) {
return ebml_read_sint (ebml, elem, date);
}
+#endif
int ebml_read_master (ebml_parser_t *ebml, ebml_elem_t *elem) {
ebml_elem_t *top_elem;
- if (ebml->level >= 0) {
- top_elem = &ebml->elem_stack[ebml->level];
- top_elem->start = elem->start;
- top_elem->len = elem->len;
- top_elem->id = elem->id;
-
- ebml->level++;
- lprintf("id: 0x%x, len: %" PRIu64 ", level: %d\n", elem->id, elem->len, ebml->level);
- if (ebml->level >= EBML_STACK_SIZE) {
- xprintf(ebml->xine, XINE_VERBOSITY_LOG,
- "ebml: max level exceeded\n");
- return 0;
- }
- return 1;
- } else {
+ if (ebml->level < 0) {
xprintf(ebml->xine, XINE_VERBOSITY_LOG,
"ebml: invalid current level\n");
return 0;
}
-}
-int ebml_read_binary(ebml_parser_t *ebml, ebml_elem_t *elem, uint8_t *binary) {
- if (!ebml_read_elem_data(ebml, binary, elem->len))
+ top_elem = &ebml->elem_stack[ebml->level];
+ top_elem->start = elem->start;
+ top_elem->len = elem->len;
+ top_elem->id = elem->id;
+
+ ebml->level++;
+ lprintf("id: 0x%x, len: %" PRIu64 ", level: %d\n", elem->id, elem->len, ebml->level);
+ if (ebml->level >= EBML_STACK_SIZE) {
+ xprintf(ebml->xine, XINE_VERBOSITY_LOG,
+ "ebml: max level exceeded\n");
return 0;
-
+ }
return 1;
}
+int ebml_read_binary(ebml_parser_t *ebml, ebml_elem_t *elem, void *binary) {
+ return !!ebml_read_elem_data(ebml, binary, elem->len);
+}
+
int ebml_check_header(ebml_parser_t *ebml) {
uint32_t next_level;
ebml_elem_t master;
diff --git a/src/demuxers/ebml.h b/src/demuxers/ebml.h
index 9b3af4efe..31d825e35 100644
--- a/src/demuxers/ebml.h
+++ b/src/demuxers/ebml.h
@@ -15,13 +15,10 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* EBML parser
* a lot of ideas from the gstreamer parser
- *
- * $Id: ebml.h,v 1.1 2004/01/05 00:40:54 tmattern Exp $
- *
*/
#ifndef EBML_H
#define EBML_H
@@ -86,18 +83,22 @@ int ebml_skip(ebml_parser_t *ebml, ebml_elem_t *elem);
/* EBML types */
int ebml_read_uint(ebml_parser_t *ebml, ebml_elem_t *elem, uint64_t *val);
+#if 0
int ebml_read_sint(ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *val);
+#endif
int ebml_read_float(ebml_parser_t *ebml, ebml_elem_t *elem, double *val);
int ebml_read_ascii(ebml_parser_t *ebml, ebml_elem_t *elem, char *str);
+#if 0
int ebml_read_utf8(ebml_parser_t *ebml, ebml_elem_t *elem, char *str);
int ebml_read_date(ebml_parser_t *ebml, ebml_elem_t *elem, int64_t *date);
+#endif
int ebml_read_master(ebml_parser_t *ebml, ebml_elem_t *elem);
-int ebml_read_binary(ebml_parser_t *ebml, ebml_elem_t *elem, uint8_t *binary);
+int ebml_read_binary(ebml_parser_t *ebml, ebml_elem_t *elem, void *binary);
#endif /* EBML_H */
diff --git a/src/demuxers/flacutils.h b/src/demuxers/flacutils.h
index 67f5d66c9..e69639925 100644
--- a/src/demuxers/flacutils.h
+++ b/src/demuxers/flacutils.h
@@ -16,7 +16,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
#ifndef __FLACUTILS_H__
@@ -73,19 +73,19 @@ static inline void _x_parse_flac_metadata_header(uint8_t *buffer, xine_flac_meta
parsed->last = buffer[0] & 0x80 ? 1 : 0;
parsed->blocktype = buffer[0] & 0x7f;
- parsed->length = BE_24(&buffer[1]);
+ parsed->length = _X_BE_24(&buffer[1]);
}
static inline void _x_parse_flac_streaminfo_block(uint8_t *buffer, xine_flac_streaminfo_block *parsed) {
- parsed->blocksize_min = BE_16(&buffer[0]);
- parsed->blocksize_max = BE_16(&buffer[2]);
- parsed->framesize_min = BE_24(&buffer[4]);
- parsed->framesize_max = BE_24(&buffer[7]);
- parsed->samplerate = BE_32(&buffer[10]);
+ parsed->blocksize_min = _X_BE_16(&buffer[0]);
+ parsed->blocksize_max = _X_BE_16(&buffer[2]);
+ parsed->framesize_min = _X_BE_24(&buffer[4]);
+ parsed->framesize_max = _X_BE_24(&buffer[7]);
+ parsed->samplerate = _X_BE_32(&buffer[10]);
parsed->channels = ((parsed->samplerate >> 9) & 0x07) + 1;
parsed->bits_per_sample = ((parsed->samplerate >> 4) & 0x1F) + 1;
parsed->samplerate >>= 12;
- parsed->total_samples = BE_64(&buffer[10]) & UINT64_C(0x0FFFFFFFFF); /* 36 bits */
+ parsed->total_samples = _X_BE_64(&buffer[10]) & UINT64_C(0x0FFFFFFFFF); /* 36 bits */
}
#endif
diff --git a/src/demuxers/group_audio.c b/src/demuxers/group_audio.c
index b8f0e1ed4..250eeefb4 100644
--- a/src/demuxers/group_audio.c
+++ b/src/demuxers/group_audio.c
@@ -15,19 +15,17 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* This file contains plugin entries for several demuxers used in games
- *
- * $Id: group_audio.c,v 1.26 2007/03/03 02:06:09 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "xine_internal.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/demux.h>
#include "group_audio.h"
@@ -44,7 +42,7 @@ static const demuxer_info_t demux_info_ac3 = {
};
static const demuxer_info_t demux_info_aud = {
- 10 /* priority */
+ -2 /* priority */
};
static const demuxer_info_t demux_info_aiff = {
@@ -68,11 +66,7 @@ static const demuxer_info_t demux_info_mpgaudio = {
};
static const demuxer_info_t demux_info_mpc = {
- 0 /* priority */
-};
-
-static const demuxer_info_t demux_info_nsf = {
- 10 /* priority */
+ 1 /* priority */
};
static const demuxer_info_t demux_info_realaudio = {
@@ -103,33 +97,23 @@ static const demuxer_info_t demux_info_wav = {
6 /* priority */
};
-#ifdef HAVE_MODPLUG
-static const demuxer_info_t demux_info_mod = {
- 10 /* priority */
-};
-#endif
-
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "aac", XINE_VERSION_CODE, &demux_info_aac, demux_aac_init_plugin },
- { PLUGIN_DEMUX, 26, "ac3", XINE_VERSION_CODE, &demux_info_ac3, demux_ac3_init_plugin },
- { PLUGIN_DEMUX, 26, "aud", XINE_VERSION_CODE, &demux_info_aud, demux_aud_init_plugin },
- { PLUGIN_DEMUX, 26, "aiff", XINE_VERSION_CODE, &demux_info_aiff, demux_aiff_init_plugin },
- { PLUGIN_DEMUX, 26, "cdda", XINE_VERSION_CODE, &demux_info_cdda, demux_cdda_init_plugin },
- { PLUGIN_DEMUX, 26, "dts", XINE_VERSION_CODE, &demux_info_dts, demux_dts_init_plugin },
- { PLUGIN_DEMUX, 26, "flac", XINE_VERSION_CODE, &demux_info_flac, demux_flac_init_plugin },
- { PLUGIN_DEMUX, 26, "mp3", XINE_VERSION_CODE, &demux_info_mpgaudio, demux_mpgaudio_init_class },
- { PLUGIN_DEMUX, 26, "mpc", XINE_VERSION_CODE, &demux_info_mpc, demux_mpc_init_plugin },
- { PLUGIN_DEMUX, 26, "nsf", XINE_VERSION_CODE, &demux_info_nsf, demux_nsf_init_plugin },
- { PLUGIN_DEMUX, 26, "realaudio", XINE_VERSION_CODE, &demux_info_realaudio, demux_realaudio_init_plugin },
- { PLUGIN_DEMUX, 26, "shn", XINE_VERSION_CODE, &demux_info_shn, demux_shn_init_plugin },
- { PLUGIN_DEMUX, 26, "snd", XINE_VERSION_CODE, &demux_info_snd, demux_snd_init_plugin },
- { PLUGIN_DEMUX, 26, "tta", XINE_VERSION_CODE, &demux_info_tta, demux_tta_init_plugin },
- { PLUGIN_DEMUX, 26, "voc", XINE_VERSION_CODE, &demux_info_voc, demux_voc_init_plugin },
- { PLUGIN_DEMUX, 26, "vox", XINE_VERSION_CODE, &demux_info_vox, demux_vox_init_plugin },
- { PLUGIN_DEMUX, 26, "wav", XINE_VERSION_CODE, &demux_info_wav, demux_wav_init_plugin },
-#ifdef HAVE_MODPLUG
- { PLUGIN_DEMUX, 26, "mod", XINE_VERSION_CODE, &demux_info_mod, demux_mod_init_plugin },
-#endif
+ { PLUGIN_DEMUX, 27, "aac", XINE_VERSION_CODE, &demux_info_aac, demux_aac_init_plugin },
+ { PLUGIN_DEMUX, 27, "ac3", XINE_VERSION_CODE, &demux_info_ac3, demux_ac3_init_plugin },
+ { PLUGIN_DEMUX, 27, "aud", XINE_VERSION_CODE, &demux_info_aud, demux_aud_init_plugin },
+ { PLUGIN_DEMUX, 27, "aiff", XINE_VERSION_CODE, &demux_info_aiff, demux_aiff_init_plugin },
+ { PLUGIN_DEMUX, 27, "cdda", XINE_VERSION_CODE, &demux_info_cdda, demux_cdda_init_plugin },
+ { PLUGIN_DEMUX, 27, "dts", XINE_VERSION_CODE, &demux_info_dts, demux_dts_init_plugin },
+ { PLUGIN_DEMUX, 27, "flac", XINE_VERSION_CODE, &demux_info_flac, demux_flac_init_plugin },
+ { PLUGIN_DEMUX, 27, "mp3", XINE_VERSION_CODE, &demux_info_mpgaudio, demux_mpgaudio_init_class },
+ { PLUGIN_DEMUX, 27, "mpc", XINE_VERSION_CODE, &demux_info_mpc, demux_mpc_init_plugin },
+ { PLUGIN_DEMUX, 27, "realaudio", XINE_VERSION_CODE, &demux_info_realaudio, demux_realaudio_init_plugin },
+ { PLUGIN_DEMUX, 27, "shn", XINE_VERSION_CODE, &demux_info_shn, demux_shn_init_plugin },
+ { PLUGIN_DEMUX, 27, "snd", XINE_VERSION_CODE, &demux_info_snd, demux_snd_init_plugin },
+ { PLUGIN_DEMUX, 27, "tta", XINE_VERSION_CODE, &demux_info_tta, demux_tta_init_plugin },
+ { PLUGIN_DEMUX, 27, "voc", XINE_VERSION_CODE, &demux_info_voc, demux_voc_init_plugin },
+ { PLUGIN_DEMUX, 27, "vox", XINE_VERSION_CODE, &demux_info_vox, demux_vox_init_plugin },
+ { PLUGIN_DEMUX, 27, "wav", XINE_VERSION_CODE, &demux_info_wav, demux_wav_init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/group_audio.h b/src/demuxers/group_audio.h
index 7f1fccc5e..394cad2a3 100644
--- a/src/demuxers/group_audio.h
+++ b/src/demuxers/group_audio.h
@@ -15,15 +15,13 @@
*
* 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
- *
- * $Id: group_audio.h,v 1.9 2006/12/26 16:59:55 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
#ifndef HAVE_GROUP_AUDIO_H
#define HAVE_GROUP_AUDIO_H
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
void *demux_aac_init_plugin (xine_t *xine, void *data);
void *demux_ac3_init_plugin (xine_t *xine, void *data);
@@ -34,7 +32,6 @@ void *demux_dts_init_plugin (xine_t *xine, void *data);
void *demux_flac_init_plugin (xine_t *xine, void *data);
void *demux_mpgaudio_init_class (xine_t *xine, void *data);
void *demux_mpc_init_plugin (xine_t *xine, void *data);
-void *demux_nsf_init_plugin (xine_t *xine, void *data);
void *demux_realaudio_init_plugin (xine_t *xine, void *data);
void *demux_shn_init_plugin (xine_t *xine, void *data);
void *demux_snd_init_plugin (xine_t *xine, void *data);
@@ -43,8 +40,4 @@ void *demux_voc_init_plugin (xine_t *xine, void *data);
void *demux_vox_init_plugin (xine_t *xine, void *data);
void *demux_wav_init_plugin (xine_t *xine, void *data);
-#ifdef HAVE_MODPLUG
-void *demux_mod_init_plugin (xine_t *xine, void *data);
-#endif
-
#endif
diff --git a/src/demuxers/group_games.c b/src/demuxers/group_games.c
index 52e39db85..2d01b726e 100644
--- a/src/demuxers/group_games.c
+++ b/src/demuxers/group_games.c
@@ -15,19 +15,17 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* This file contains plugin entries for several demuxers used in games
- *
- * $Id: group_games.c,v 1.15 2006/07/10 22:08:13 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "xine_internal.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/demux.h>
#include "group_games.h"
@@ -81,16 +79,16 @@ static const demuxer_info_t demux_info_vmd = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "wve", XINE_VERSION_CODE, &demux_info_eawve, demux_eawve_init_plugin},
- { PLUGIN_DEMUX, 26, "idcin", XINE_VERSION_CODE, &demux_info_idcin, demux_idcin_init_plugin },
- { PLUGIN_DEMUX, 26, "ipmovie", XINE_VERSION_CODE, &demux_info_ipmovie, demux_ipmovie_init_plugin },
- { PLUGIN_DEMUX, 26, "vqa", XINE_VERSION_CODE, &demux_info_vqa, demux_vqa_init_plugin },
- { PLUGIN_DEMUX, 26, "wc3movie", XINE_VERSION_CODE, &demux_info_wc3movie, demux_wc3movie_init_plugin },
- { PLUGIN_DEMUX, 26, "roq", XINE_VERSION_CODE, &demux_info_roq, demux_roq_init_plugin },
- { PLUGIN_DEMUX, 26, "str", XINE_VERSION_CODE, &demux_info_str, demux_str_init_plugin },
- { PLUGIN_DEMUX, 26, "film", XINE_VERSION_CODE, &demux_info_film, demux_film_init_plugin },
- { PLUGIN_DEMUX, 26, "smjpeg", XINE_VERSION_CODE, &demux_info_smjpeg, demux_smjpeg_init_plugin },
- { PLUGIN_DEMUX, 26, "fourxm", XINE_VERSION_CODE, &demux_info_fourxm, demux_fourxm_init_plugin },
- { PLUGIN_DEMUX, 26, "vmd", XINE_VERSION_CODE, &demux_info_vmd, demux_vmd_init_plugin },
+ { PLUGIN_DEMUX, 27, "wve", XINE_VERSION_CODE, &demux_info_eawve, demux_eawve_init_plugin},
+ { PLUGIN_DEMUX, 27, "idcin", XINE_VERSION_CODE, &demux_info_idcin, demux_idcin_init_plugin },
+ { PLUGIN_DEMUX, 27, "ipmovie", XINE_VERSION_CODE, &demux_info_ipmovie, demux_ipmovie_init_plugin },
+ { PLUGIN_DEMUX, 27, "vqa", XINE_VERSION_CODE, &demux_info_vqa, demux_vqa_init_plugin },
+ { PLUGIN_DEMUX, 27, "wc3movie", XINE_VERSION_CODE, &demux_info_wc3movie, demux_wc3movie_init_plugin },
+ { PLUGIN_DEMUX, 27, "roq", XINE_VERSION_CODE, &demux_info_roq, demux_roq_init_plugin },
+ { PLUGIN_DEMUX, 27, "str", XINE_VERSION_CODE, &demux_info_str, demux_str_init_plugin },
+ { PLUGIN_DEMUX, 27, "film", XINE_VERSION_CODE, &demux_info_film, demux_film_init_plugin },
+ { PLUGIN_DEMUX, 27, "smjpeg", XINE_VERSION_CODE, &demux_info_smjpeg, demux_smjpeg_init_plugin },
+ { PLUGIN_DEMUX, 27, "fourxm", XINE_VERSION_CODE, &demux_info_fourxm, demux_fourxm_init_plugin },
+ { PLUGIN_DEMUX, 27, "vmd", XINE_VERSION_CODE, &demux_info_vmd, demux_vmd_init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
diff --git a/src/demuxers/group_games.h b/src/demuxers/group_games.h
index a2e8ef254..352ec5524 100644
--- a/src/demuxers/group_games.h
+++ b/src/demuxers/group_games.h
@@ -15,15 +15,13 @@
*
* 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
- *
- * $Id: group_games.h,v 1.3 2004/02/13 13:48:03 tmmm Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
#ifndef HAVE_GROUP_GAMES_H
#define HAVE_GROUP_GAMES_H
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
void *demux_eawve_init_plugin(xine_t *xine, void *data);
void *demux_idcin_init_plugin (xine_t *xine, void *data);
diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c
index b707166b6..f65d5564c 100644
--- a/src/demuxers/id3.c
+++ b/src/demuxers/id3.c
@@ -15,7 +15,7 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* ID3 tag parser
*
@@ -28,8 +28,6 @@
* unzip support
*
* ID3v2 specs: http://www.id3.org/
- *
- * $Id: id3.c,v 1.13 2007/03/03 00:58:52 dgp85 Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -42,12 +40,12 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
#include "id3.h"
-#define ID3_GENRE_COUNT 126
+#define ID3_GENRE_COUNT (sizeof (id3_genre) / sizeof (id3_genre[0]))
static const char* const id3_genre[] =
{"Blues", "Classic Rock", "Country", "Dance", "Disco",
"Funk", "Grunge", "Hip-Hop", "Jazz", "Metal",
@@ -74,7 +72,11 @@ static const char* const id3_genre[] =
"Satire", "Slow Jam", "Club", "Tango", "Samba",
"Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle",
"Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House",
- "Dance Hall" };
+ "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror",
+ "Indie", "BritPop", "Negerpunk", "Polsk Punk", "Beat",
+ "Christian Gangsta Rap", "Heavy Metal", "Black Metal", "Crossover",
+ "Contemporary Christian", "Christian Rock", "Merengue", "Salsa",
+ "Thrash Metal", "Anime", "JPop", "Synthpop" };
#define ID3_ENCODING_COUNT 4
static const char* const id3_encoding[] = {
@@ -227,49 +229,17 @@ static int id3v2_parse_genre(char* dest, char *src, int len) {
return 1;
}
-#if 0
-/* parse an unsynchronized 16bits integer */
-static uint16_t BE_16_synchsafe(uint8_t buf[2]) {
- return ((uint16_t)(buf[0] & 0x7F) << 7) |
- (uint16_t)(buf[1] & 0x7F);
-}
-#endif
-
-/* parse an unsynchronized 24bits integer */
-static uint32_t BE_24_synchsafe(uint8_t buf[3]) {
- return ((uint32_t)(buf[0] & 0x7F) << 14) |
- ((uint32_t)(buf[1] & 0x7F) << 7) |
- (uint32_t)(buf[2] & 0x7F);
-}
-
-/* parse an unsynchronized 32bits integer */
-static uint32_t BE_32_synchsafe(uint8_t buf[4]) {
- return ((uint32_t)(buf[0] & 0x7F) << 21) |
- ((uint32_t)(buf[1] & 0x7F) << 14) |
- ((uint32_t)(buf[2] & 0x7F) << 7) |
- (uint32_t)(buf[3] & 0x7F);
-}
-
-/* parse an unsynchronized 35bits integer */
-static uint32_t BE_35_synchsafe(uint8_t buf[5]) {
- return ((uint32_t)(buf[0] & 0x07) << 28) |
- ((uint32_t)(buf[1] & 0x7F) << 21) |
- ((uint32_t)(buf[2] & 0x7F) << 14) |
- ((uint32_t)(buf[3] & 0x7F) << 7) |
- (uint32_t)(buf[4] & 0x7F);
-}
-
-static int id3v2_parse_header(input_plugin_t *input, uint8_t *mp3_frame_header,
+static int id3v2_parse_header(input_plugin_t *input, uint32_t id3_signature,
id3v2_header_t *tag_header) {
uint8_t buf[6];
- tag_header->id = BE_32(mp3_frame_header);
+ tag_header->id = be2me_32(id3_signature);
if (input->read (input, buf, 6) == 6) {
tag_header->revision = buf[0];
tag_header->flags = buf[1];
- tag_header->size = BE_32_synchsafe(&buf[2]);
+ tag_header->size = _X_BE_32_synchsafe(&buf[2]);
- lprintf("tag: ID3 v2.%d.%d\n", mp3_frame_header[3], tag_header->revision);
+ lprintf("tag: ID3 v2.%d.%d\n", tag_header->id & 0xFF, tag_header->revision);
lprintf("flags: %d\n", tag_header->flags);
lprintf("size: %d\n", tag_header->size);
return 1;
@@ -289,7 +259,7 @@ static int id3v22_parse_frame_header(input_plugin_t *input,
if (len == ID3V22_FRAME_HEADER_SIZE) {
frame_header->id = (buf[0] << 16) + (buf[1] << 8) + buf[2];
- frame_header->size = BE_24_synchsafe(&buf[3]);
+ frame_header->size = _X_BE_24_synchsafe(&buf[3]);
lprintf("frame: %c%c%c: size: %d\n", buf[0], buf[1], buf[2],
frame_header->size);
@@ -303,15 +273,9 @@ static int id3v22_parse_frame_header(input_plugin_t *input,
static int id3v22_interp_frame(input_plugin_t *input,
xine_stream_t *stream,
id3v22_frame_header_t *frame_header) {
- char *buf;
+ char buf[frame_header->size + 1];
int enc;
- buf = malloc(frame_header->size + 1);
- if (buf == NULL) {
- lprintf("malloc error");
- return 0;
- }
-
if (input->read (input, buf, frame_header->size) == frame_header->size) {
buf[frame_header->size] = 0;
enc = buf[0];
@@ -319,7 +283,7 @@ static int id3v22_interp_frame(input_plugin_t *input,
enc = 0;
switch (frame_header->id) {
- case ( FOURCC_TAG(0, 'T', 'C', 'O') ):
+ case ( BE_FOURCC(0, 'T', 'C', 'O') ):
{
char tmp[1024];
@@ -329,27 +293,27 @@ static int id3v22_interp_frame(input_plugin_t *input,
}
break;
- case ( FOURCC_TAG(0, 'T', 'T', '2') ):
+ case ( BE_FOURCC(0, 'T', 'T', '2') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG(0, 'T', 'P', '1') ):
+ case ( BE_FOURCC(0, 'T', 'P', '1') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG(0, 'T', 'A', 'L') ):
+ case ( BE_FOURCC(0, 'T', 'A', 'L') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG(0, 'T', 'Y', 'E') ):
+ case ( BE_FOURCC(0, 'T', 'Y', 'E') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG(0, 'C', 'O', 'M') ):
+ case ( BE_FOURCC(0, 'C', 'O', 'M') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]);
break;
- case ( FOURCC_TAG(0, 'T', 'R', 'K') ):
+ case ( BE_FOURCC(0, 'T', 'R', 'K') ):
_x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1);
break;
@@ -357,11 +321,9 @@ static int id3v22_interp_frame(input_plugin_t *input,
lprintf("unhandled frame\n");
}
- free(buf);
return 1;
} else {
lprintf("read error\n");
- free(buf);
return 0;
}
}
@@ -369,31 +331,31 @@ static int id3v22_interp_frame(input_plugin_t *input,
int id3v22_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header) {
+ uint32_t id3_signature) {
id3v2_header_t tag_header;
id3v22_frame_header_t tag_frame_header;
int pos = 0;
- if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) {
+ if (id3v2_parse_header(input, id3_signature, &tag_header)) {
if (tag_header.flags & ID3V22_ZERO_FLAG) {
/* invalid flags */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid header flags\n");
+ LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
if (tag_header.flags & ID3V22_COMPRESS_FLAG) {
/* compressed tag: not supported */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: compressed tags are not supported\n");
+ LOG_MODULE ": compressed tags are not supported\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
if (tag_header.flags & ID3V22_UNSYNCH_FLAG) {
/* unsynchronized tag: not supported */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: unsynchronized tags are not supported\n");
+ LOG_MODULE ": unsynchronized tags are not supported\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
@@ -405,11 +367,11 @@ int id3v22_parse_tag(input_plugin_t *input,
if ((pos + tag_frame_header.size) <= tag_header.size) {
if (!id3v22_interp_frame(input, stream, &tag_frame_header)) {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid frame content\n");
+ LOG_MODULE ": invalid frame content\n");
}
} else {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid frame header\n");
+ LOG_MODULE ": invalid frame header\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 1;
}
@@ -421,13 +383,13 @@ int id3v22_parse_tag(input_plugin_t *input,
}
} else {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: id3v2_parse_frame_header problem\n");
+ LOG_MODULE ": id3v2_parse_frame_header problem\n");
return 0;
}
}
return 1;
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3: id3v2_parse_header problem\n");
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n");
return 0;
}
}
@@ -441,9 +403,9 @@ static int id3v23_parse_frame_header(input_plugin_t *input,
len = input->read (input, buf, ID3V23_FRAME_HEADER_SIZE);
if (len == ID3V23_FRAME_HEADER_SIZE) {
- frame_header->id = BE_32(buf);
- frame_header->size = BE_32(&buf[4]);
- frame_header->flags = BE_16(buf + 8);
+ frame_header->id = _X_BE_32(buf);
+ frame_header->size = _X_BE_32(&buf[4]);
+ frame_header->flags = _X_BE_16(buf + 8);
lprintf("frame: %c%c%c%c, size: %d, flags: %X\n", buf[0], buf[1], buf[2], buf[3],
frame_header->size, frame_header->flags);
@@ -460,12 +422,12 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input,
if (input->read (input, buf, 4) == 4) {
- frame_ext_header->size = BE_32_synchsafe(&buf[0]);
+ frame_ext_header->size = _X_BE_32_synchsafe(&buf[0]);
if (frame_ext_header->size == 6) {
if (input->read (input, buf + 4, 6) == 6) {
- frame_ext_header->flags = BE_16(buf + 4);
- frame_ext_header->padding_size = BE_32(buf + 6);
+ frame_ext_header->flags = _X_BE_16(buf + 4);
+ frame_ext_header->padding_size = _X_BE_32(buf + 6);
frame_ext_header->crc = 0;
} else {
return 0;
@@ -473,9 +435,9 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input,
} else if (frame_ext_header->size == 10) {
if (input->read (input, buf + 4, 10) == 10) {
- frame_ext_header->flags = BE_16(buf + 4);
- frame_ext_header->padding_size = BE_32(buf + 6);
- frame_ext_header->crc = BE_32(buf + 10);
+ frame_ext_header->flags = _X_BE_16(buf + 4);
+ frame_ext_header->padding_size = _X_BE_32(buf + 6);
+ frame_ext_header->crc = _X_BE_32(buf + 10);
} else {
return 0;
}
@@ -497,15 +459,9 @@ static int id3v23_parse_frame_ext_header(input_plugin_t *input,
static int id3v23_interp_frame(input_plugin_t *input,
xine_stream_t *stream,
id3v23_frame_header_t *frame_header) {
- char *buf;
+ char buf[frame_header->size + 1];
int enc;
- buf = malloc(frame_header->size + 1);
- if (buf == NULL) {
- lprintf("malloc error");
- return 0;
- }
-
if (input->read (input, buf, frame_header->size) == frame_header->size) {
buf[frame_header->size] = 0;
enc = buf[0];
@@ -513,7 +469,7 @@ static int id3v23_interp_frame(input_plugin_t *input,
enc = 0;
switch (frame_header->id) {
- case ( FOURCC_TAG('T', 'C', 'O', 'N') ):
+ case ( BE_FOURCC('T', 'C', 'O', 'N') ):
{
char tmp[1024];
@@ -523,27 +479,27 @@ static int id3v23_interp_frame(input_plugin_t *input,
}
break;
- case ( FOURCC_TAG('T', 'I', 'T', '2') ):
+ case ( BE_FOURCC('T', 'I', 'T', '2') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'P', 'E', '1') ):
+ case ( BE_FOURCC('T', 'P', 'E', '1') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'A', 'L', 'B') ):
+ case ( BE_FOURCC('T', 'A', 'L', 'B') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'Y', 'E', 'R') ):
+ case ( BE_FOURCC('T', 'Y', 'E', 'R') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('C', 'O', 'M', 'M') ):
+ case ( BE_FOURCC('C', 'O', 'M', 'M') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'R', 'C', 'K') ):
+ case ( BE_FOURCC('T', 'R', 'C', 'K') ):
_x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1);
break;
@@ -551,36 +507,34 @@ static int id3v23_interp_frame(input_plugin_t *input,
lprintf("unhandled frame\n");
}
- free(buf);
return 1;
} else {
lprintf("read error\n");
- free(buf);
return 0;
}
}
int id3v23_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header) {
+ uint32_t id3_signature) {
id3v2_header_t tag_header;
id3v23_frame_header_t tag_frame_header;
id3v23_frame_ext_header_t tag_frame_ext_header;
int pos = 0;
- if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) {
+ if (id3v2_parse_header(input, id3_signature, &tag_header)) {
if (tag_header.flags & ID3V23_ZERO_FLAG) {
/* invalid flags */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid header flags\n");
+ LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
if (tag_header.flags & ID3V23_UNSYNCH_FLAG) {
/* unsynchronized tag: not supported */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: unsynchronized tags are not supported\n");
+ LOG_MODULE ": unsynchronized tags are not supported\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
@@ -598,11 +552,11 @@ int id3v23_parse_tag(input_plugin_t *input,
if ((pos + tag_frame_header.size) <= tag_header.size) {
if (!id3v23_interp_frame(input, stream, &tag_frame_header)) {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid frame content\n");
+ LOG_MODULE ": invalid frame content\n");
}
} else {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid frame header\n");
+ LOG_MODULE ": invalid frame header\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 1;
}
@@ -614,13 +568,13 @@ int id3v23_parse_tag(input_plugin_t *input,
}
} else {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: id3v2_parse_frame_header problem\n");
+ LOG_MODULE ": id3v2_parse_frame_header problem\n");
return 0;
}
}
return 1;
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v23: id3v2_parse_header problem\n");
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n");
return 0;
}
}
@@ -629,15 +583,15 @@ int id3v23_parse_tag(input_plugin_t *input,
/* id3v2 "genre" parsing code. what a ugly format ! */
static int id3v24_parse_genre(char* dest, char *src, int len) {
- int index = 0;
+ unsigned int index = 0;
dest[0] = '\0';
- if (sscanf(src, "%2d", &index) == 1) {
+ if (sscanf(src, "%u", &index) == 1) {
if (index < ID3_GENRE_COUNT) {
strncpy(dest, id3_genre[index], len);
dest[len - 1] = '\0';
} else {
- lprintf("invalid index: %d\n", index);
+ lprintf("invalid index: %u\n", index);
}
}
return 1;
@@ -650,9 +604,9 @@ static int id3v24_parse_frame_header(input_plugin_t *input,
len = input->read (input, buf, ID3V24_FRAME_HEADER_SIZE);
if (len == ID3V24_FRAME_HEADER_SIZE) {
- frame_header->id = BE_32(buf);
- frame_header->size = BE_32_synchsafe(&buf[4]);
- frame_header->flags = BE_16(&buf[8]);
+ frame_header->id = _X_BE_32(buf);
+ frame_header->size = _X_BE_32_synchsafe(&buf[4]);
+ frame_header->flags = _X_BE_16(&buf[8]);
lprintf("frame: %c%c%c%c, size: %d, flags: %X\n", buf[0], buf[1], buf[2], buf[3],
frame_header->size, frame_header->flags);
@@ -669,7 +623,7 @@ static int id3v24_parse_ext_header(input_plugin_t *input,
if (input->read (input, buf, 4) == 4) {
- frame_ext_header->size = BE_32_synchsafe(&buf[0]);
+ frame_ext_header->size = _X_BE_32_synchsafe(&buf[0]);
if (input->read (input, buf, 2) == 2) {
uint8_t flags_size = buf[0];
@@ -746,15 +700,9 @@ static int id3v24_parse_ext_header(input_plugin_t *input,
static int id3v24_interp_frame(input_plugin_t *input,
xine_stream_t *stream,
id3v24_frame_header_t *frame_header) {
- char *buf;
+ char buf[frame_header->size + 1];
int enc;
- buf = malloc(frame_header->size + 1);
- if (buf == NULL) {
- lprintf("malloc error");
- return 0;
- }
-
if (input->read (input, buf, frame_header->size) == frame_header->size) {
buf[frame_header->size] = 0;
enc = buf[0];
@@ -764,7 +712,7 @@ static int id3v24_interp_frame(input_plugin_t *input,
lprintf("data: %s\n", buf+1);
switch (frame_header->id) {
- case ( FOURCC_TAG('T', 'C', 'O', 'N') ):
+ case ( BE_FOURCC('T', 'C', 'O', 'N') ):
{
char tmp[1024];
@@ -774,27 +722,27 @@ static int id3v24_interp_frame(input_plugin_t *input,
}
break;
- case ( FOURCC_TAG('T', 'I', 'T', '2') ):
+ case ( BE_FOURCC('T', 'I', 'T', '2') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_TITLE, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'P', 'E', '1') ):
+ case ( BE_FOURCC('T', 'P', 'E', '1') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_ARTIST, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'A', 'L', 'B') ):
+ case ( BE_FOURCC('T', 'A', 'L', 'B') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_ALBUM, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'Y', 'E', 'R') ):
+ case ( BE_FOURCC('T', 'Y', 'E', 'R') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('C', 'O', 'M', 'M') ):
+ case ( BE_FOURCC('C', 'O', 'M', 'M') ):
_x_meta_info_set_generic(stream, XINE_META_INFO_COMMENT, buf + 1 + 3, id3_encoding[enc]);
break;
- case ( FOURCC_TAG('T', 'R', 'C', 'K') ):
+ case ( BE_FOURCC('T', 'R', 'C', 'K') ):
_x_meta_info_set(stream, XINE_META_INFO_TRACK_NUMBER, buf + 1);
break;
@@ -802,29 +750,27 @@ static int id3v24_interp_frame(input_plugin_t *input,
lprintf("unhandled frame\n");
}
- free(buf);
return 1;
} else {
lprintf("read error\n");
- free(buf);
return 0;
}
}
int id3v24_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header) {
+ uint32_t id3_signature) {
id3v2_header_t tag_header;
id3v24_frame_header_t tag_frame_header;
id3v24_frame_ext_header_t tag_frame_ext_header;
int pos = 0;
- if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) {
+ if (id3v2_parse_header(input, id3_signature, &tag_header)) {
if (tag_header.flags & ID3V24_ZERO_FLAG) {
/* invalid flags */
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid header flags\n");
+ LOG_MODULE ": invalid header flags (%02x)\n", tag_header.flags);
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 0;
}
@@ -848,11 +794,11 @@ int id3v24_parse_tag(input_plugin_t *input,
if ((pos + tag_frame_header.size) <= tag_header.size) {
if (!id3v24_interp_frame(input, stream, &tag_frame_header)) {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid frame content\n");
+ LOG_MODULE ": invalid frame content\n");
}
} else {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: invalid frame header\n");
+ LOG_MODULE ": invalid frame header\n");
input->seek (input, tag_header.size - pos, SEEK_CUR);
return 1;
}
@@ -864,7 +810,7 @@ int id3v24_parse_tag(input_plugin_t *input,
}
} else {
xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
- "id3: id3v2_parse_frame_header problem\n");
+ LOG_MODULE ": id3v2_parse_frame_header problem\n");
return 0;
}
}
@@ -874,37 +820,32 @@ int id3v24_parse_tag(input_plugin_t *input,
}
return 1;
} else {
- xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v23: id3v2_parse_header problem\n");
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": id3v2_parse_header problem\n");
return 0;
}
}
int id3v2_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header) {
- _x_assert(mp3_frame_header[0] == 'I' && mp3_frame_header[1] == 'D' && mp3_frame_header[2] == '3');
-
- int result = 0;
+ uint32_t id3_signature) {
+ _x_assert((id3_signature & ID3V2X_MASK) == ID3V2X_TAG);
- switch(mp3_frame_header[3]) {
- case 2:
- xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.2 tag\n");
- result = id3v22_parse_tag(input, stream, mp3_frame_header);
- break;
+ switch(id3_signature) {
+ case ID3V22_TAG:
+ xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.2 tag\n");
+ return id3v22_parse_tag(input, stream, id3_signature);
- case 3:
- xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n");
- result = id3v23_parse_tag(input, stream, mp3_frame_header);
- break;
+ case ID3V23_TAG:
+ xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.3 tag\n");
+ return id3v23_parse_tag(input, stream, id3_signature);
- case 4:
- xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n");
- result = id3v24_parse_tag(input, stream, mp3_frame_header);
- break;
+ case ID3V24_TAG:
+ xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2.4 tag\n");
+ return id3v24_parse_tag(input, stream, id3_signature);
default:
- xprintf(stream->xine, XINE_VERBOSITY_LOG, "Unknown ID3v2 version: 0x%02x.\n", mp3_frame_header[3]);
+ xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": Unknown ID3v2 signature: 0x%08x.\n", be2me_32(id3_signature));
}
-
- return result;
+
+ return 0;
}
diff --git a/src/demuxers/id3.h b/src/demuxers/id3.h
index 9d08f6817..542a17bc4 100644
--- a/src/demuxers/id3.h
+++ b/src/demuxers/id3.h
@@ -15,29 +15,28 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* ID3 tag parser
*
* Supported versions: v1, v1.1, v2.2, v2.3, v2.4
- *
- * $Id: id3.h,v 1.6 2007/03/03 01:41:16 dgp85 Exp $
*/
#ifndef ID3_H
#define ID3_H
-#include "xine_internal.h"
-#include "xineutils.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
#include "bswap.h"
/* id3v2 */
-#define FOURCC_TAG BE_FOURCC
-#define ID3V22_TAG FOURCC_TAG('I', 'D', '3', 2) /* id3 v2.2 header tag */
-#define ID3V23_TAG FOURCC_TAG('I', 'D', '3', 3) /* id3 v2.3 header tag */
-#define ID3V24_TAG FOURCC_TAG('I', 'D', '3', 4) /* id3 v2.4 header tag */
-#define ID3V24_FOOTER_TAG FOURCC_TAG('3', 'D', 'I', 0) /* id3 v2.4 footer tag */
+#define ID3V22_TAG ME_FOURCC('I', 'D', '3', 2) /* id3 v2.2 header tag */
+#define ID3V23_TAG ME_FOURCC('I', 'D', '3', 3) /* id3 v2.3 header tag */
+#define ID3V24_TAG ME_FOURCC('I', 'D', '3', 4) /* id3 v2.4 header tag */
+#define ID3V24_FOOTER_TAG ME_FOURCC('3', 'D', 'I', 0) /* id3 v2.4 footer tag */
+#define ID3V2X_TAG ME_FOURCC('I', 'D', '3', 0) /* id3 v2.x header tag */
+#define ID3V2X_MASK ~ME_FOURCC( 0 , 0 , 0 , 0xFF) /* id3 v2.x header mask */
/*
* ID3 v2.2
@@ -155,34 +154,59 @@ int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream);
int id3v22_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header);
+ uint32_t id3_signature);
int id3v23_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header);
+ uint32_t id3_signature);
int id3v24_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header);
+ uint32_t id3_signature);
/* Generic function that switch between the three above */
int id3v2_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
- int8_t *mp3_frame_header);
+ uint32_t id3_signature);
+
+/**
+ * @brief Checks if the given buffer is an ID3 tag preamble
+ * @param ptr Pointer to the first 10 bytes of the ID3 tag
+ */
+static inline int id3v2_istag(uint32_t id3_signature) {
+ return (id3_signature & ID3V2X_MASK) == ID3V2X_TAG;
+}
+
+#if 0
+/* parse an unsynchronized 16bits integer */
+static inline uint16_t _X_BE_16_synchsafe(uint8_t buf[2]) {
+ return ((uint16_t)(buf[0] & 0x7F) << 7) |
+ (uint16_t)(buf[1] & 0x7F);
+}
+#endif
+
+/* parse an unsynchronized 24bits integer */
+static inline uint32_t _X_BE_24_synchsafe(uint8_t buf[3]) {
+ return ((uint32_t)(buf[0] & 0x7F) << 14) |
+ ((uint32_t)(buf[1] & 0x7F) << 7) |
+ (uint32_t)(buf[2] & 0x7F);
+}
-static inline int id3v2_istag(uint8_t *ptr) {
- return
- (ptr[0] == 'I') &&
- (ptr[1] == 'D') &&
- (ptr[2] == '3');
+/* parse an unsynchronized 32bits integer */
+static inline uint32_t _X_BE_32_synchsafe(uint8_t buf[4]) {
+ return ((uint32_t)(buf[0] & 0x7F) << 21) |
+ ((uint32_t)(buf[1] & 0x7F) << 14) |
+ ((uint32_t)(buf[2] & 0x7F) << 7) |
+ (uint32_t)(buf[3] & 0x7F);
}
-static inline uint32_t id3v2_tagsize(uint8_t *ptr) {
- return
- ((uint32_t)ptr[0] << 21) +
- ((uint32_t)ptr[1] << 14) +
- ((uint32_t)ptr[2] << 7) +
- (uint32_t)ptr[3];
+/* parse an unsynchronized 35bits integer */
+static inline uint32_t BE_35_synchsafe(uint8_t buf[5]) {
+ return ((uint32_t)(buf[0] & 0x07) << 28) |
+ ((uint32_t)(buf[1] & 0x7F) << 21) |
+ ((uint32_t)(buf[2] & 0x7F) << 14) |
+ ((uint32_t)(buf[3] & 0x7F) << 7) |
+ (uint32_t)(buf[4] & 0x7F);
}
#endif /* ID3_H */
diff --git a/src/demuxers/iff.h b/src/demuxers/iff.h
index 9d4fb5abe..fcfc54f16 100644
--- a/src/demuxers/iff.h
+++ b/src/demuxers/iff.h
@@ -15,14 +15,12 @@
*
* 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* IFF header file by Manfred Tremmel (Manfred.Tremmel@iiv.de)
* Based on the information of the Amiga Developer CD
- *
- * $Id: iff.h,v 1.2 2004/02/25 18:57:36 manfredtremmel Exp $
*/
#ifndef IFFP_IFF_H
@@ -118,7 +116,8 @@
#define HAMBITS_RED 2 /* modify red component */
#define HAMBITS_GREEN 3 /* modify green component */
-int bitplainoffeset[] = { 1, 2, 4, 8,
+static const int bitplainoffeset[] = {
+ 1, 2, 4, 8,
16, 32, 64, 128,
1, 2, 4, 8,
16, 32, 64, 128,
@@ -137,7 +136,7 @@ typedef struct {
uint8_t masking; /* masking technique */
uint8_t compression; /* compression algoithm */
uint8_t pad1; /* UNUSED. For consistency, put 0 here. */
- uint16_t transparentColor; /* transparent "color number" */
+ uint16_t transparentColor; /* transparent "colour number" */
uint8_t xaspect; /* aspect ratio, a rational number x/y */
uint8_t yaspect; /* aspect ratio, a rational number x/y */
int16_t pagewidth; /* source "page" size in pixels */
@@ -237,9 +236,9 @@ typedef struct {
#define max_volume 65536 /* Unity = Fixed 1.0 = maximum volume */
-int8_t fibonacci[] = { -34, -21, -13, -8, -5, -3, -2, -1, 0, 1, 2, 3, 5, 8, 13, 21 };
+static const int8_t fibonacci[] = { -34, -21, -13, -8, -5, -3, -2, -1, 0, 1, 2, 3, 5, 8, 13, 21 };
-int8_t exponential[] = { -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64 };
+static const int8_t exponential[] = { -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64 };
typedef struct {
uint32_t oneShotHiSamples; /* # samples in the high octave 1-shot part */
diff --git a/src/demuxers/matroska.h b/src/demuxers/matroska.h
index 3bfdbdc0c..215c63dd0 100644
--- a/src/demuxers/matroska.h
+++ b/src/demuxers/matroska.h
@@ -15,17 +15,14 @@
*
* 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
- *
- * $Id: matroska.h,v 1.11 2007/01/07 12:33:50 molivier Exp $
- *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
#ifndef MATROSKA_H
#define MATROSKA_H
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
#include "ebml.h"
@@ -264,6 +261,7 @@ struct matroska_track_s {
#define MATROSKA_CODEC_ID_V_REAL_RV30 "V_REAL/RV30"
#define MATROSKA_CODEC_ID_V_REAL_RV40 "V_REAL/RV40"
#define MATROSKA_CODEC_ID_V_MJPEG "V_MJPEG"
+#define MATROSKA_CODEC_ID_V_THEORA "V_THEORA"
#define MATROSKA_CODEC_ID_A_MPEG1_L1 "A_MPEG/L1"
#define MATROSKA_CODEC_ID_A_MPEG1_L2 "A_MPEG/L2"
diff --git a/src/demuxers/qtpalette.h b/src/demuxers/qtpalette.h
index 18b47c697..a8a44e916 100644
--- a/src/demuxers/qtpalette.h
+++ b/src/demuxers/qtpalette.h
@@ -7,14 +7,14 @@
#ifndef QTPALETTE_H
#define QTPALETTE_H
-unsigned char qt_default_palette_4[4 * 4] = {
+static const unsigned char qt_default_palette_4[4 * 4] = {
0x93, 0x65, 0x5E, 0x00,
0xFF, 0xFF, 0xFF, 0x00,
0xDF, 0xD0, 0xAB, 0x00,
0x00, 0x00, 0x00, 0x00
};
-unsigned char qt_default_palette_16[16 * 4] = {
+static const unsigned char qt_default_palette_16[16 * 4] = {
0xFF, 0xFB, 0xFF, 0x00,
0xEF, 0xD9, 0xBB, 0x00,
0xE8, 0xC9, 0xB1, 0x00,
@@ -33,7 +33,7 @@ unsigned char qt_default_palette_16[16 * 4] = {
0x00, 0x00, 0x00, 0x00
};
-unsigned char qt_default_palette_256[256 * 4] = {
+static const unsigned char qt_default_palette_256[256 * 4] = {
/* 0, 0x00 */ 0xFF, 0xFF, 0xFF, 0x00,
/* 1, 0x01 */ 0xFF, 0xFF, 0xCC, 0x00,
/* 2, 0x02 */ 0xFF, 0xFF, 0x99, 0x00,