summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-09-02 16:19:44 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-09-02 16:19:44 +0000
commitb2b968f6789da8cf0c69ed955a010b178690908d (patch)
tree34dac3adbd06605cbd5e3cc0b9f3b23f3fab976d
parent421c83c38ae931f62c08510cf511aa98ec01ba26 (diff)
downloadxine-lib-b2b968f6789da8cf0c69ed955a010b178690908d.tar.gz
xine-lib-b2b968f6789da8cf0c69ed955a010b178690908d.tar.bz2
demuxer bugfixes
CVS patchset: 551 CVS date: 2001/09/02 16:19:44
-rw-r--r--src/demuxers/demux_avi.c3
-rw-r--r--src/demuxers/demux_mpeg.c61
2 files changed, 58 insertions, 6 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index 2bdc9f64c..55c7f117d 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -17,7 +17,7 @@
* 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_avi.c,v 1.31 2001/09/01 14:32:59 guenter Exp $
+ * $Id: demux_avi.c,v 1.32 2001/09/02 16:19:44 guenter Exp $
*
* demultiplexer for avi streams
*
@@ -269,6 +269,7 @@ static avi_t *AVI_init(demux_avi_t *this)
/* Read first 12 bytes and check that this is an AVI file */
+ this->input->seek(this->input, 0, SEEK_SET);
if( this->input->read(this->input, data,12) != 12 ) ERR_EXIT(AVI_ERR_READ) ;
if( strncasecmp(data ,"RIFF",4) !=0 ||
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index 5eeb28f81..5d57236e3 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -17,7 +17,7 @@
* 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.c,v 1.32 2001/09/01 14:33:00 guenter Exp $
+ * $Id: demux_mpeg.c,v 1.33 2001/09/02 16:19:44 guenter Exp $
*
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
@@ -42,7 +42,7 @@
#include "demux.h"
#include "utils.h"
-#define NUM_PREVIEW_BUFFERS 250
+#define NUM_PREVIEW_BUFFERS 150
static uint32_t xine_debug;
@@ -436,7 +436,6 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID)
static uint32_t parse_pack(demux_mpeg_t *this)
{
uint32_t buf ;
- char scratch[1024];
int mpeg_version;
xprintf (VERBOSE|DEMUX, "pack {\n");
@@ -483,7 +482,7 @@ static uint32_t parse_pack(demux_mpeg_t *this)
buf = read_bytes (this, 2);
xprintf (VERBOSE|DEMUX, " system_header (%d +6 bytes)\n",buf);
- this->input->read (this->input, scratch, buf);
+ this->input->read (this->input, this->dummy_space, buf);
buf = read_bytes (this, 4) ;
}
@@ -511,6 +510,57 @@ static uint32_t parse_pack(demux_mpeg_t *this)
}
+static uint32_t parse_pack_preview (demux_mpeg_t *this, int *num_buffers)
+{
+ uint32_t buf ;
+ int mpeg_version;
+
+ /* system_clock_reference */
+ buf = read_bytes (this, 1);
+ xprintf (VERBOSE|DEMUX|VIDEO, " mpeg version : %02x",buf>>4);
+
+ if ((buf>>4) == 4) {
+ buf = read_bytes(this, 2);
+ mpeg_version = 2;
+ } else {
+ mpeg_version = 1;
+ }
+
+ buf = read_bytes (this, 4);
+ buf = read_bytes (this, 3) ;
+
+ /* system header */
+
+ buf = read_bytes (this, 4) ;
+
+ if (buf == 0x000001bb) {
+ buf = read_bytes (this, 2);
+ this->input->read (this->input, this->dummy_space, buf);
+ buf = read_bytes (this, 4) ;
+ }
+
+ while ( ((buf & 0xFFFFFF00) == 0x00000100)
+ && ((buf & 0xff) != 0xba)
+ && (*num_buffers > 0)) {
+
+ if (this->status != DEMUX_OK)
+ return buf;
+
+ if (mpeg_version == 1)
+ parse_mpeg1_packet (this, buf & 0xFF);
+ else
+ parse_mpeg2_packet (this, buf & 0xFF);
+
+ buf = read_bytes (this, 4);
+ *num_buffers = *num_buffers - 1;
+ }
+
+ xprintf (VERBOSE|DEMUX, "}\n");
+
+ return buf;
+
+}
+
static void demux_mpeg_resync (demux_mpeg_t *this, uint32_t buf) {
while ((buf !=0x000001ba) && (this->status == DEMUX_OK)) {
@@ -639,7 +689,8 @@ static void demux_mpeg_start (demux_plugin_t *this_gen,
this->status = DEMUX_OK ;
do {
- w = parse_pack (this);
+
+ w = parse_pack_preview (this, &num_buffers);
if (w != 0x000001ba)
demux_mpeg_resync (this, w);