Commit 85071f34 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/spudec/*: modified the spu decoder to handle text subtitles.
   Only one format of text subtitles is supported right now but we should be able
   to expand this by modifying modules/codec/spudec/text.c.
   Most of this work comes from by Andrew Flintham ( thanks a bunch Andrew :).

* share/font-eutopiabold36.rle: new font for the text subtitler, courtesy of
   Andrew Flintham.

* AUTHORS: added Andrew Flintham to the authors file.

* modules/demux/ogg.c: modified the ogg demuxer to handle subtitles.

* modules/codec/ffmpeg/*: modified the ffmpeg decoder to always keep the last decoded
   frame linked.
parent 8b09b55d
...@@ -419,3 +419,7 @@ C: ipkiss ...@@ -419,3 +419,7 @@ C: ipkiss
D: Win32 interface D: Win32 interface
S: France S: France
N: Andrew Flintham
E: amf@cus.org.uk
D: text subtitler and font scripts
S: United Kingdom
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video.c: video decoder using ffmpeg library * video.c: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: video.c,v 1.2 2002/11/05 10:07:56 gbazin Exp $ * $Id: video.c,v 1.3 2002/11/06 21:48:24 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com> * Gildas Bazin <gbazin@netcourrier.com>
...@@ -349,6 +349,8 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec ) ...@@ -349,6 +349,8 @@ int E_( InitThread_Video )( vdec_thread_t *p_vdec )
p_vdec->b_hurry_up = config_GetInt(p_vdec->p_fifo, "ffmpeg-hurry-up"); p_vdec->b_hurry_up = config_GetInt(p_vdec->p_fifo, "ffmpeg-hurry-up");
p_vdec->p_lastpic = NULL;
p_vdec->p_secondlastpic = NULL;
p_vdec->b_direct_rendering = 0; p_vdec->b_direct_rendering = 0;
#if LIBAVCODEC_BUILD > 4615 #if LIBAVCODEC_BUILD > 4615
if( (p_vdec->p_codec->capabilities & CODEC_CAP_DR1) if( (p_vdec->p_codec->capabilities & CODEC_CAP_DR1)
...@@ -668,6 +670,11 @@ void E_( DecodeThread_Video )( vdec_thread_t *p_vdec ) ...@@ -668,6 +670,11 @@ void E_( DecodeThread_Video )( vdec_thread_t *p_vdec )
*****************************************************************************/ *****************************************************************************/
void E_( EndThread_Video )( vdec_thread_t *p_vdec ) void E_( EndThread_Video )( vdec_thread_t *p_vdec )
{ {
if( p_vdec->p_secondlastpic )
vout_UnlinkPicture( p_vdec->p_vout, p_vdec->p_secondlastpic );
if( p_vdec->p_lastpic )
vout_UnlinkPicture( p_vdec->p_vout, p_vdec->p_lastpic );
if( p_vdec->p_pp ) if( p_vdec->p_pp )
{ {
/* release postprocessing module */ /* release postprocessing module */
...@@ -797,8 +804,13 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *avctx, int width, ...@@ -797,8 +804,13 @@ static int ffmpeg_GetFrameBuf( struct AVCodecContext *avctx, int width,
msleep( VOUT_OUTMEM_SLEEP ); msleep( VOUT_OUTMEM_SLEEP );
} }
/* FIXME: we may have to use link/unlinkPicture to fully support streams /* FIXME: We keep the last picture linked until the current one is decoded,
* with B FRAMES */ * this trick won't work with streams with B frames though. */
vout_LinkPicture( p_vdec->p_vout, p_pic );
if( p_vdec->p_secondlastpic )
vout_UnlinkPicture( p_vdec->p_vout, p_vdec->p_secondlastpic );
p_vdec->p_secondlastpic = p_vdec->p_lastpic;
p_vdec->p_lastpic = p_pic;
avctx->draw_horiz_band= NULL; avctx->draw_horiz_band= NULL;
avctx->dr_buffer[0]= p_pic->p[0].p_pixels; avctx->dr_buffer[0]= p_pic->p[0].p_pixels;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video.h: video decoder using ffmpeg library * video.h: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: video.h,v 1.2 2002/11/05 10:07:56 gbazin Exp $ * $Id: video.h,v 1.3 2002/11/06 21:48:24 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -41,7 +41,8 @@ typedef struct vdec_thread_s ...@@ -41,7 +41,8 @@ typedef struct vdec_thread_s
/* for direct rendering */ /* for direct rendering */
int b_direct_rendering; int b_direct_rendering;
picture_t *p_lastpic;
picture_t *p_secondlastpic;
} vdec_thread_t; } vdec_thread_t;
......
SOURCES_spudec = \ SOURCES_spudec = \
modules/codec/spudec/spudec.c \ modules/codec/spudec/spudec.c \
modules/codec/spudec/parse.c \ modules/codec/spudec/parse.c \
modules/codec/spudec/render.c modules/codec/spudec/render.c \
modules/codec/spudec/text.c \
modules/codec/spudec/subtitler.c
noinst_HEADERS += \ noinst_HEADERS += \
modules/codec/spudec/spudec.h modules/codec/spudec/spudec.h
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* parse.c: SPU parser * parse.c: SPU parser
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: parse.c,v 1.4 2002/11/06 18:07:57 sam Exp $ * $Id: parse.c,v 1.5 2002/11/06 21:48:24 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -31,14 +31,6 @@ ...@@ -31,14 +31,6 @@
#include <vlc/vout.h> #include <vlc/vout.h>
#include <vlc/decoder.h> #include <vlc/decoder.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* getpid() */
#endif
#ifdef WIN32 /* getpid() for win32 is located in process.h */
# include <process.h>
#endif
#include "spudec.h" #include "spudec.h"
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* render.c : SPU renderer * render.c : SPU renderer
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: render.c,v 1.3 2002/11/06 18:07:57 sam Exp $ * $Id: render.c,v 1.4 2002/11/06 21:48:24 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Rudolf Cornelissen <rag.cornelissen@inter.nl.net> * Rudolf Cornelissen <rag.cornelissen@inter.nl.net>
...@@ -33,14 +33,6 @@ ...@@ -33,14 +33,6 @@
#include <vlc/vout.h> #include <vlc/vout.h>
#include <vlc/decoder.h> #include <vlc/decoder.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* getpid() */
#endif
#ifdef WIN32 /* getpid() for win32 is located in process.h */
# include <process.h>
#endif
#include "spudec.h" #include "spudec.h"
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spudec.c : SPU decoder thread * spudec.c : SPU decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: spudec.c,v 1.7 2002/11/06 18:07:57 sam Exp $ * $Id: spudec.c,v 1.8 2002/11/06 21:48:24 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -31,14 +31,6 @@ ...@@ -31,14 +31,6 @@
#include <vlc/vout.h> #include <vlc/vout.h>
#include <vlc/decoder.h> #include <vlc/decoder.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* getpid() */
#endif
#ifdef WIN32 /* getpid() for win32 is located in process.h */
# include <process.h>
#endif
#include "spudec.h" #include "spudec.h"
/***************************************************************************** /*****************************************************************************
...@@ -52,8 +44,16 @@ static void EndThread ( spudec_thread_t * ); ...@@ -52,8 +44,16 @@ static void EndThread ( spudec_thread_t * );
/***************************************************************************** /*****************************************************************************
* Module descriptor. * Module descriptor.
*****************************************************************************/ *****************************************************************************/
#define FONT_TEXT N_("Font used by the text subtitler")
#define FONT_LONGTEXT N_(\
"When the subtitles are coded in text form then, you can choose " \
"which font will be used to display them.")
vlc_module_begin(); vlc_module_begin();
set_description( _("DVD subtitles decoder module") ); add_category_hint( N_("subtitles"), NULL );
add_file( "spudec-font", "./share/font-eutopiabold36.rle", NULL,
FONT_TEXT, FONT_LONGTEXT );
set_description( _("subtitles decoder module") );
set_capability( "decoder", 50 ); set_capability( "decoder", 50 );
set_callbacks( OpenDecoder, NULL ); set_callbacks( OpenDecoder, NULL );
vlc_module_end(); vlc_module_end();
...@@ -69,7 +69,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -69,7 +69,8 @@ static int OpenDecoder( vlc_object_t *p_this )
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
if( p_fifo->i_fourcc != VLC_FOURCC('s','p','u',' ') if( p_fifo->i_fourcc != VLC_FOURCC('s','p','u',' ')
&& p_fifo->i_fourcc != VLC_FOURCC('s','p','u','b') ) && p_fifo->i_fourcc != VLC_FOURCC('s','p','u','b')
&& p_fifo->i_fourcc != VLC_FOURCC('s','u','b','t') )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -85,6 +86,8 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -85,6 +86,8 @@ static int OpenDecoder( vlc_object_t *p_this )
static int RunDecoder( decoder_fifo_t * p_fifo ) static int RunDecoder( decoder_fifo_t * p_fifo )
{ {
spudec_thread_t * p_spudec; spudec_thread_t * p_spudec;
subtitler_font_t * p_font;
char * psz_font;
/* Allocate the memory needed to store the thread's structure */ /* Allocate the memory needed to store the thread's structure */
p_spudec = (spudec_thread_t *)malloc( sizeof(spudec_thread_t) ); p_spudec = (spudec_thread_t *)malloc( sizeof(spudec_thread_t) );
...@@ -111,6 +114,39 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -111,6 +114,39 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
* Main loop - it is not executed if an error occured during * Main loop - it is not executed if an error occured during
* initialization * initialization
*/ */
if( p_fifo->i_fourcc == VLC_FOURCC('s','u','b','t') )
{
/* Here we are dealing with text subtitles */
if( (psz_font = config_GetPsz( p_fifo, "spudec-font" )) == NULL )
{
msg_Err( p_fifo, "no default font selected" );
p_font = NULL;
p_spudec->p_fifo->b_error;
}
else
{
p_font = subtitler_LoadFont( p_spudec->p_vout, psz_font );
if ( p_font == NULL )
{
msg_Err( p_fifo, "unable to load font: %s", psz_font );
p_spudec->p_fifo->b_error;
}
}
if( psz_font ) free( psz_font );
while( (!p_spudec->p_fifo->b_die) && (!p_spudec->p_fifo->b_error) )
{
E_(ParseText)( p_spudec, p_font );
}
if( p_font ) subtitler_UnloadFont( p_spudec->p_vout, p_font );
}
else
{
/* Here we are dealing with sub-pictures subtitles*/
while( (!p_spudec->p_fifo->b_die) && (!p_spudec->p_fifo->b_error) ) while( (!p_spudec->p_fifo->b_die) && (!p_spudec->p_fifo->b_error) )
{ {
if( E_(SyncPacket)( p_spudec ) ) if( E_(SyncPacket)( p_spudec ) )
...@@ -120,6 +156,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -120,6 +156,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
E_(ParsePacket)( p_spudec ); E_(ParsePacket)( p_spudec );
} }
}
/* /*
* Error loop * Error loop
...@@ -154,8 +191,8 @@ static int InitThread( spudec_thread_t *p_spudec ) ...@@ -154,8 +191,8 @@ static int InitThread( spudec_thread_t *p_spudec )
{ {
if( p_spudec->p_fifo->b_die || p_spudec->p_fifo->b_error ) if( p_spudec->p_fifo->b_die || p_spudec->p_fifo->b_error )
{ {
/* Call InitBitstream anyway so p_spudec is in a known state /* Call InitBitstream anyway so p_spudec->bit_stream is in a known
* before calling CloseBitstream */ * state before calling CloseBitstream */
InitBitstream( &p_spudec->bit_stream, p_spudec->p_fifo, InitBitstream( &p_spudec->bit_stream, p_spudec->p_fifo,
NULL, NULL ); NULL, NULL );
return -1; return -1;
...@@ -209,4 +246,3 @@ static void EndThread( spudec_thread_t *p_spudec ) ...@@ -209,4 +246,3 @@ static void EndThread( spudec_thread_t *p_spudec )
CloseBitstream( &p_spudec->bit_stream ); CloseBitstream( &p_spudec->bit_stream );
free( p_spudec ); free( p_spudec );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spudec.h : sub picture unit decoder thread interface * spudec.h : sub picture unit decoder thread interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: spudec.h,v 1.3 2002/11/06 18:07:57 sam Exp $ * $Id: spudec.h,v 1.4 2002/11/06 21:48:24 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -44,6 +44,18 @@ struct subpicture_sys_t ...@@ -44,6 +44,18 @@ struct subpicture_sys_t
int i_x_start, i_y_start, i_x_end, i_y_end; int i_x_start, i_y_start, i_x_end, i_y_end;
}; };
/*****************************************************************************
* subtitler_font_t : proportional font
*****************************************************************************/
typedef struct subtitler_font_s
{
int i_height; /* character height in pixels */
int i_width[256]; /* character widths in pixels */
int i_memory[256]; /* amount of memory used by character */
int * p_length[256]; /* line byte widths */
u16 ** p_offset[256]; /* pointer to RLE data */
} subtitler_font_t;
/***************************************************************************** /*****************************************************************************
* spudec_thread_t : sub picture unit decoder thread descriptor * spudec_thread_t : sub picture unit decoder thread descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -99,3 +111,9 @@ void E_(ParsePacket) ( spudec_thread_t * ); ...@@ -99,3 +111,9 @@ void E_(ParsePacket) ( spudec_thread_t * );
void E_(RenderSPU) ( vout_thread_t *, picture_t *, void E_(RenderSPU) ( vout_thread_t *, picture_t *,
const subpicture_t * ); const subpicture_t * );
void E_(ParseText) ( spudec_thread_t *, subtitler_font_t * );
subtitler_font_t *E_(subtitler_LoadFont) ( vout_thread_t *, const char * );
void E_(subtitler_UnloadFont) ( vout_thread_t *, subtitler_font_t * );
void E_(subtitler_PlotSubtitle) ( vout_thread_t *, char *, subtitler_font_t *,
mtime_t, mtime_t );
This diff is collapsed.
/*****************************************************************************
* text.c: text subtitles parser
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: text.c,v 1.1 2002/11/06 21:48:24 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* memcpy(), memset() */
#include <vlc/vlc.h>
#include <vlc/vout.h>
#include <vlc/decoder.h>
#include "spudec.h"
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
/*****************************************************************************
* ParseText: parse an text subtitle packet and send it to the video output
*****************************************************************************/
void E_(ParseText)( spudec_thread_t *p_spudec, subtitler_font_t *p_font )
{
char * psz_subtitle;
mtime_t i_pts;
/* We cannot display a subpicture with no date */
i_pts = p_spudec->bit_stream.p_pes->i_pts;
if( i_pts == 0 )
{
/* Dump the packet */
NextDataPacket( p_spudec->p_fifo, &p_spudec->bit_stream );
msg_Warn( p_spudec->p_fifo, "subtitle without a date" );
return;
}
else
/* Check validity of packet data */
if( (p_spudec->bit_stream.p_data->p_payload_end
- p_spudec->bit_stream.p_data->p_payload_start) <= 0
|| (strlen(p_spudec->bit_stream.p_data->p_payload_start)
> p_spudec->bit_stream.p_data->p_payload_end
- p_spudec->bit_stream.p_data->p_payload_start) )
{
/* Dump the packet */
NextDataPacket( p_spudec->p_fifo, &p_spudec->bit_stream );
msg_Warn( p_spudec->p_fifo, "invalid subtitle" );
return;
}
psz_subtitle = p_spudec->bit_stream.p_data->p_payload_start;
if( psz_subtitle[0] != '\0' )
{
subtitler_PlotSubtitle( p_spudec->p_vout,
psz_subtitle, p_font,
i_pts,
0 );
}
/* Prepare for next time. No need to check that
* p_spudec->bit_stream->p_data is valid since we check later on
* for b_die and b_error */
NextDataPacket( p_spudec->p_fifo, &p_spudec->bit_stream );
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ogg.c : ogg stream input module for vlc * ogg.c : ogg stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: ogg.c,v 1.7 2002/11/05 21:57:41 gbazin Exp $ * $Id: ogg.c,v 1.8 2002/11/06 21:48:23 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -87,6 +87,7 @@ struct demux_sys_t ...@@ -87,6 +87,7 @@ struct demux_sys_t
/* current audio and video es */ /* current audio and video es */
logical_stream_t *p_stream_video; logical_stream_t *p_stream_video;
logical_stream_t *p_stream_audio; logical_stream_t *p_stream_audio;
logical_stream_t *p_stream_spu;
/* stream we use as a time reference for demux reading speed */ /* stream we use as a time reference for demux reading speed */
logical_stream_t *p_stream_timeref; logical_stream_t *p_stream_timeref;
...@@ -168,7 +169,6 @@ static int Demux ( input_thread_t * ); ...@@ -168,7 +169,6 @@ static int Demux ( input_thread_t * );
/* Stream managment */ /* Stream managment */
static int Ogg_StreamStart ( input_thread_t *, demux_sys_t *, int ); static int Ogg_StreamStart ( input_thread_t *, demux_sys_t *, int );
static int Ogg_StreamSeek ( input_thread_t *, demux_sys_t *, int, mtime_t );
static void Ogg_StreamStop ( input_thread_t *, demux_sys_t *, int ); static void Ogg_StreamStop ( input_thread_t *, demux_sys_t *, int );
/* Bitstream manipulation */ /* Bitstream manipulation */
...@@ -227,8 +227,6 @@ static int Ogg_StreamStart( input_thread_t *p_input, ...@@ -227,8 +227,6 @@ static int Ogg_StreamStart( input_thread_t *p_input,
} }
} }
//Ogg_StreamSeek( p_input, p_ogg, i_stream, p_ogg->i_time );
return( p_stream->i_activated ); return( p_stream->i_activated );
#undef p_stream #undef p_stream
} }
...@@ -256,17 +254,6 @@ static void Ogg_StreamStop( input_thread_t *p_input, ...@@ -256,17 +254,6 @@ static void Ogg_StreamStop( input_thread_t *p_input,
#undef p_stream #undef p_stream
} }
static int Ogg_StreamSeek( input_thread_t *p_input, demux_sys_t *p_ogg,
int i_stream, mtime_t i_date )
{
#define p_stream p_ogg->pp_stream[i_stream]
/* FIXME: todo */
return 1;
#undef p_stream
}
/**************************************************************************** /****************************************************************************
* Ogg_Check: Check we are dealing with an ogg stream. * Ogg_Check: Check we are dealing with an ogg stream.
****************************************************************************/ ****************************************************************************/
...@@ -383,9 +370,20 @@ static void Ogg_DecodePacket( input_thread_t *p_input, ...@@ -383,9 +370,20 @@ static void Ogg_DecodePacket( input_thread_t *p_input,
} }
/* Convert the pcr into a pts */ /* Convert the pcr into a pts */
if( p_stream->i_cat != SPU_ES )
{
p_pes->i_pts = ( p_stream->i_pcr < 0 ) ? 0 : p_pes->i_pts = ( p_stream->i_pcr < 0 ) ? 0 :
input_ClockGetTS( p_input, p_input->stream.p_selected_program, input_ClockGetTS( p_input, p_input->stream.p_selected_program,
p_stream->i_pcr ); p_stream->i_pcr );
}
else
{
/* Of course subtitles had to be different! */
p_pes->i_pts = ( p_oggpacket->granulepos < 0 ) ? 0 :
input_ClockGetTS( p_input, p_input->stream.p_selected_program,
p_oggpacket->granulepos * 90000 /
p_stream->i_rate );
}
/* Convert the next granule into a pcr */ /* Convert the next granule into a pcr */
if( p_oggpacket->granulepos < 0 ) if( p_oggpacket->granulepos < 0 )
...@@ -435,6 +433,7 @@ static void Ogg_DecodePacket( input_thread_t *p_input, ...@@ -435,6 +433,7 @@ static void Ogg_DecodePacket( input_thread_t *p_input,
p_oggpacket->bytes - i_header_len ); p_oggpacket->bytes - i_header_len );
p_data->p_payload_end = p_data->p_payload_start + p_pes->i_pes_size; p_data->p_payload_end = p_data->p_payload_start + p_pes->i_pes_size;
p_data->b_discard_payload = 0;
input_DecodePES( p_stream->p_es->p_decoder_fifo, p_pes ); input_DecodePES( p_stream->p_es->p_decoder_fifo, p_pes );
} }
...@@ -649,10 +648,14 @@ static int Ogg_FindLogicalStreams( input_thread_t *p_input, demux_sys_t *p_ogg) ...@@ -649,10 +648,14 @@ static int Ogg_FindLogicalStreams( input_thread_t *p_input, demux_sys_t *p_ogg)
/* Check for text (subtitles) header */ /* Check for text (subtitles) header */
else if( !strncmp(st->streamtype, "text", 4) ) else if( !strncmp(st->streamtype, "text", 4) )
{ {
/* We need to get rid of the header packet */
ogg_stream_packetout( &p_stream->os, &oggpacket );
msg_Dbg( p_input, "found text subtitles header" ); msg_Dbg( p_input, "found text subtitles header" );
p_stream->i_cat = SPU_ES; p_stream->i_cat = SPU_ES;
p_stream->i_fourcc = p_stream->i_fourcc =
VLC_FOURCC( 's', 'u', 'b', 't' ); VLC_FOURCC( 's', 'u', 'b', 't' );
p_stream->i_rate = 1000; /* granulepos is in milisec */
} }
else else
{ {
...@@ -772,7 +775,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -772,7 +775,7 @@ static int Activate( vlc_object_t * p_this )
p_ogg->i_streams + 1, 0 ); p_ogg->i_streams + 1, 0 );
p_input->stream.i_mux_rate += (p_stream->i_bitrate / ( 8 * 50 )); p_input->stream.i_mux_rate += (p_stream->i_bitrate / ( 8 * 50 ));
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
p_stream->p_es->i_stream_id = i_stream; p_stream->p_es->i_stream_id = p_stream->p_es->i_id = i_stream;
p_stream->p_es->i_fourcc = p_stream->i_fourcc; p_stream->p_es->i_fourcc = p_stream->i_fourcc;
p_stream->p_es->i_cat = p_stream->i_cat; p_stream->p_es->i_cat = p_stream->i_cat;
p_stream->p_es->p_demux_data = p_stream->p_bih ? p_stream->p_es->p_demux_data = p_stream->p_bih ?
...@@ -786,7 +789,6 @@ static int Activate( vlc_object_t * p_this ) ...@@ -786,7 +789,6 @@ static int Activate( vlc_object_t * p_this )
switch( p_stream->p_es->i_cat ) switch( p_stream->p_es->i_cat )
{ {
case( VIDEO_ES ): case( VIDEO_ES ):
if( (p_ogg->p_stream_video == NULL) ) if( (p_ogg->p_stream_video == NULL) )
{ {
p_ogg->p_stream_video = p_stream; p_ogg->p_stream_video = p_stream;
...@@ -797,11 +799,35 @@ static int Activate( vlc_object_t * p_this ) ...@@ -797,11 +799,35 @@ static int Activate( vlc_object_t * p_this )
case( AUDIO_ES ): case( AUDIO_ES ):
if( (p_ogg->p_stream_audio == NULL) ) if( (p_ogg->p_stream_audio == NULL) )
{
int i_audio = config_GetInt( p_input, "audio-channel" );
if( i_audio == i_stream || i_audio <= 0 ||
i_audio >= p_ogg->i_streams ||
p_ogg->pp_stream[i_audio]->p_es->i_cat != AUDIO_ES )
{ {
p_ogg->p_stream_audio = p_stream; p_ogg->p_stream_audio = p_stream;
p_ogg->p_stream_timeref = p_stream; p_ogg->p_stream_timeref = p_stream;
Ogg_StreamStart( p_input, p_ogg, i_stream ); Ogg_StreamStart( p_input, p_ogg, i_stream );
} }
}
break;
case( SPU_ES ):
if( (p_ogg->p_stream_spu == NULL) )
{
/* for spu, default is none */
int i_spu = config_GetInt( p_input, "spu-channel" );
if( i_spu < 0 || i_spu >= p_ogg->i_streams ||
p_ogg->pp_stream[i_spu]->p_es->i_cat != SPU_ES )
{
break;
}
else if( i_spu == i_stream )
{
p_ogg->p_stream_spu = p_stream;
Ogg_StreamStart( p_input, p_ogg, i_stream );
}
}
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment