Commit cf3bb5c0 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* ALL:

  - Removed all the RLE subtitle font code.
  - Removed the .rle and even older .psf font files.
  - Moved the filesubtitle code from spudec to subsdec.
  - spudec is again DVD only.
parent 1f4b5609
dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.39 2003/07/21 17:48:31 gbazin Exp $
dnl $Id: configure.ac,v 1.40 2003/07/22 20:49:10 hartman Exp $
AC_INIT(vlc,0.6.1-test1)
......@@ -768,7 +768,7 @@ dnl
#AX_ADD_BUILTINS([mpeg_video_old idct idctclassic motion])
AX_ADD_PLUGINS([dummy rc logger gestures memcpy])
AX_ADD_PLUGINS([es audio m4v mpeg_system ps ts avi asf aac mp4 rawdv])
AX_ADD_PLUGINS([mpeg_audio lpcm a52 dts cinepak])
AX_ADD_PLUGINS([spudec mpeg_audio lpcm a52 dts cinepak])
AX_ADD_PLUGINS([deinterlace invert adjust wall transform distort clone crop motionblur])
AX_ADD_PLUGINS([float32tos16 float32tos8 float32tou16 float32tou8 a52tospdif dtstospdif fixed32tofloat32 fixed32tos16 s16tofixed32 s16tofloat32 s16tofloat32swab s8tofloat32 u8tofixed32 u8tofloat32])
AX_ADD_PLUGINS([trivial_resampler ugly_resampler linear_resampler bandlimited_resampler])
......@@ -1701,7 +1701,7 @@ then
AC_CHECK_HEADERS(QuickTime/QuickTime.h,
[ AX_ADD_BUILTINS([quicktime])
AX_ADD_LDFLAGS([quicktime],[-framework QuickTime -framework Carbon])
], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
], [ AC_MSG_ERROR([cannot find QuickTime headers]) ])
fi
fi
......@@ -1951,11 +1951,11 @@ You also need to check that you have a libogg posterior to the 1.0 release.])],
fi
dnl
dnl spudec support
dnl subsdec support
dnl
AX_ADD_LDFLAGS([spudec],[${LIBICONV}])
AX_ADD_CPPFLAGS([spudec],[${INCICONV}])
AX_ADD_PLUGINS([spudec])
AX_ADD_LDFLAGS([subsdec],[${LIBICONV}])
AX_ADD_CPPFLAGS([subsdec],[${INCICONV}])
AX_ADD_PLUGINS([subsdec])
dnl
......@@ -3254,6 +3254,7 @@ AC_OUTPUT([
modules/codec/mpeg_video/idct/Makefile
modules/codec/mpeg_video/motion/Makefile
modules/codec/spudec/Makefile
modules/codec/subsdec/Makefile
modules/control/Makefile
modules/control/corba/Makefile
modules/control/lirc/Makefile
......
......@@ -2,7 +2,5 @@ SOURCES_spudec = \
spudec.c \
parse.c \
render.c \
text.c \
subtitler.c \
spudec.h \
$(NULL)
......@@ -2,7 +2,7 @@
* parse.c: SPU parser
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: parse.c,v 1.11 2003/03/09 19:25:08 gbazin Exp $
* $Id: parse.c,v 1.12 2003/07/22 20:49:10 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -10,7 +10,7 @@
* 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
......@@ -166,6 +166,7 @@ void E_(ParsePacket)( spudec_thread_t *p_spudec )
vlc_mutex_lock( p_mutex );
UpdateSPU( p_spu, VLC_OBJECT(p_spu->p_sys->p_input) );
var_AddCallback( p_spu->p_sys->p_input,
"highlight", CropCallback, p_spu );
vlc_mutex_unlock( p_mutex );
......@@ -273,18 +274,18 @@ static int ParseControlSeq( spudec_thread_t *p_spudec,
/* Get the control sequence date */
date = (mtime_t)GetBits( &p_spudec->bit_stream, 16 ) * 11000
* p_spudec->bit_stream.p_pes->i_rate / DEFAULT_RATE;
/* Next offset */
i_cur_seq = i_index;
i_next_seq = GetBits( &p_spudec->bit_stream, 16 );
/* Skip what we just read */
i_index += 4;
}
i_command = GetBits( &p_spudec->bit_stream, 8 );
i_index++;
switch( i_command )
{
case SPU_CMD_FORCE_DISPLAY: /* 00 (force displaying) */
......@@ -412,11 +413,11 @@ static int ParseControlSeq( spudec_thread_t *p_spudec,
msg_Err( p_spudec->p_fifo, "no `start display' command" );
}
if( p_spu->i_stop <= p_spu->i_start && !p_spu->b_ephemer )
if( !p_spu->i_stop <= p_spu->i_start && !p_spu->b_ephemer )
{
/* This subtitle will live for 5 seconds or until the next subtitle */
p_spu->i_stop = p_spu->i_start + (mtime_t)500 * 11000
* p_spudec->bit_stream.p_pes->i_rate / DEFAULT_RATE;
* p_spudec->bit_stream.p_pes->i_rate / DEFAULT_RATE;
p_spu->b_ephemer = VLC_TRUE;
}
......
......@@ -2,7 +2,7 @@
* render.c : SPU renderer
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: render.c,v 1.4 2002/11/06 21:48:24 gbazin Exp $
* $Id: render.c,v 1.5 2003/07/22 20:49:10 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Rudolf Cornelissen <rag.cornelissen@inter.nl.net>
......
......@@ -2,7 +2,7 @@
* spudec.c : SPU decoder thread
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: spudec.c,v 1.23 2003/07/21 18:24:51 gbazin Exp $
* $Id: spudec.c,v 1.24 2003/07/22 20:49:10 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -10,7 +10,7 @@
* 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
......@@ -36,40 +36,17 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int OpenDecoder ( vlc_object_t * );
static int OpenDecoder ( vlc_object_t * );
static int RunDecoder ( decoder_fifo_t * );
static int InitThread ( spudec_thread_t * );
static void EndThread ( spudec_thread_t * );
static vout_thread_t *FindVout( spudec_thread_t * );
static vout_thread_t *FindVout( spudec_thread_t *);
/*****************************************************************************
* 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.")
#define DEFAULT_FONT "font-eutopiabold21.rle"
#define ENCODING_TEXT N_("subtitle text encoding")
#define ENCODING_LONGTEXT N_("change the encoding used in text subtitles")
vlc_module_begin();
add_category_hint( N_("subtitles"), NULL, VLC_TRUE );
#if defined(SYS_DARWIN) || defined(SYS_BEOS) \
|| (defined(WIN32) && !defined(UNDER_CE))
add_file( "spudec-font", NULL, NULL,
FONT_TEXT, FONT_LONGTEXT, VLC_TRUE );
#else
add_file( "spudec-font", "share/" DEFAULT_FONT, NULL,
FONT_TEXT, FONT_LONGTEXT, VLC_TRUE );
#endif
#if defined(HAVE_ICONV)
add_string( "spudec-encoding", "ISO-8859-1", NULL, ENCODING_TEXT,
ENCODING_LONGTEXT, VLC_FALSE );
#endif
set_description( _("subtitles decoder") );
set_description( _("DVD subtitles decoder") );
set_capability( "decoder", 50 );
set_callbacks( OpenDecoder, NULL );
vlc_module_end();
......@@ -77,7 +54,7 @@ vlc_module_end();
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
*****************************************************************************
* Tries to launch a decoder and return score so that the interface is able
* Tries to launch a decoder and return score so that the interface is able
* to chose.
*****************************************************************************/
static int OpenDecoder( vlc_object_t *p_this )
......@@ -85,12 +62,11 @@ static int OpenDecoder( vlc_object_t *p_this )
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
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','u','b','t') )
{
&& p_fifo->i_fourcc != VLC_FOURCC('s','p','u','b') )
{
return VLC_EGENERIC;
}
p_fifo->pf_run = RunDecoder;
return VLC_SUCCESS;
......@@ -102,11 +78,6 @@ static int OpenDecoder( vlc_object_t *p_this )
static int RunDecoder( decoder_fifo_t * p_fifo )
{
spudec_thread_t * p_spudec;
subtitler_font_t * p_font = NULL;
char * psz_font;
#if 0
vout_thread_t * p_vout_backup = NULL;
#endif
/* Allocate the memory needed to store the thread's structure */
p_spudec = (spudec_thread_t *)malloc( sizeof(spudec_thread_t) );
......@@ -117,16 +88,13 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
DecoderError( p_fifo );
return( -1 );
}
/*
* Initialize the thread properties
*/
p_spudec->p_vout = NULL;
p_spudec->p_fifo = p_fifo;
#if defined(HAVE_ICONV)
p_spudec->iconv_handle = (iconv_t)-1;
#endif
/*
* Initialize thread and free configuration
*/
......@@ -136,106 +104,19 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
* Main loop - it is not executed if an error occured during
* initialization
*/
if( p_fifo->i_fourcc == VLC_FOURCC('s','u','b','t') )
while( (!p_spudec->p_fifo->b_die) && (!p_spudec->p_fifo->b_error) )
{
/* Here we are dealing with text subtitles */
#if defined(SYS_DARWIN) || defined(SYS_BEOS)
if ( (psz_font = config_GetPsz( p_fifo, "spudec-font" )) == NULL )
{
char * psz_vlcpath = p_fifo->p_libvlc->psz_vlcpath;
psz_font = malloc( strlen(psz_vlcpath) + strlen("/share/")
+ strlen(DEFAULT_FONT) + 1 );
sprintf(psz_font, "%s/share/" DEFAULT_FONT, psz_vlcpath);
}
#elif defined(WIN32) && !defined(UNDER_CE)
if ( (psz_font = config_GetPsz( p_fifo, "spudec-font" )) == NULL )
{
char * psz_vlcpath = p_fifo->p_libvlc->psz_vlcpath;
psz_font = malloc( strlen(psz_vlcpath) + strlen("\\share\\")
+ strlen(DEFAULT_FONT) + 1 );
sprintf(psz_font, "%s\\share\\" DEFAULT_FONT, psz_vlcpath);
}
#else
if( (psz_font = config_GetPsz( p_fifo, "spudec-font" )) == NULL )
{
msg_Err( p_fifo, "no default font selected" );
p_spudec->p_fifo->b_error = VLC_TRUE;
}
#endif
#if defined(HAVE_ICONV)
p_spudec->iconv_handle = iconv_open( "UTF-8",
config_GetPsz( p_spudec->p_fifo, "spudec-encoding" ) );
if( p_spudec->iconv_handle == (iconv_t)-1 )
{
msg_Warn( p_spudec->p_fifo, "Unable to do requested conversion" );
}
#endif
while( (!p_spudec->p_fifo->b_die) && (!p_spudec->p_fifo->b_error) )
{
/* Find/Wait for a video output */
p_spudec->p_vout = FindVout( p_spudec );
if( p_spudec->p_vout )
{
#if 0
if( p_spudec->p_vout != p_vout_backup )
{
/* The vout has changed, we need to reload the fonts */
p_vout_backup = p_spudec->p_vout;
p_font = E_(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 = VLC_TRUE;
vlc_object_release( p_spudec->p_vout );
break;
}
}
#endif
E_(ParseText)( p_spudec, p_font );
vlc_object_release( p_spudec->p_vout );
}
}
if( psz_font ) free( psz_font );
if( p_font )
if( E_(SyncPacket)( p_spudec ) )
{
/* Find/Wait for a video output */
p_spudec->p_vout = FindVout( p_spudec );
if( p_spudec->p_vout )
{
E_(subtitler_UnloadFont)( p_spudec->p_vout, p_font );
vlc_object_release( p_spudec->p_vout );
}
continue;
}
}
else
{
/* Here we are dealing with sub-pictures subtitles*/
while( (!p_spudec->p_fifo->b_die) && (!p_spudec->p_fifo->b_error) )
/* Find/Wait for a video output */
p_spudec->p_vout = FindVout( p_spudec );
if( p_spudec->p_vout)
{
if( E_(SyncPacket)( p_spudec ) )
{
continue;
}
/* Find/Wait for a video output */
p_spudec->p_vout = FindVout( p_spudec );
if( p_spudec->p_vout )
{
E_(ParsePacket)( p_spudec );
vlc_object_release( p_spudec->p_vout );
}
E_(ParsePacket)( p_spudec );
vlc_object_release( p_spudec->p_vout );
}
}
......@@ -268,24 +149,24 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
static int InitThread( spudec_thread_t *p_spudec )
{
int i_ret;
/* Call InitBitstream anyway so p_spudec->bit_stream is in a known
* state before calling CloseBitstream */
i_ret = InitBitstream( &p_spudec->bit_stream, p_spudec->p_fifo,
NULL, NULL );
NULL, NULL );
/* Check for a video output */
p_spudec->p_vout = FindVout( p_spudec );
if( !p_spudec->p_vout )
{
return -1;
}
/* It was just a check */
vlc_object_release( p_spudec->p_vout );
p_spudec->p_vout = NULL;
return i_ret;
}
......@@ -295,7 +176,7 @@ static int InitThread( spudec_thread_t *p_spudec )
static vout_thread_t *FindVout( spudec_thread_t *p_spudec )
{
vout_thread_t *p_vout = NULL;
/* Find an available video output */
do
{
......@@ -305,7 +186,7 @@ static vout_thread_t *FindVout( spudec_thread_t *p_spudec )
}
p_vout = vlc_object_find( p_spudec->p_fifo, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
FIND_ANYWHERE );
if( p_vout )
{
......@@ -327,12 +208,12 @@ static vout_thread_t *FindVout( spudec_thread_t *p_spudec )
*****************************************************************************/
static void EndThread( spudec_thread_t *p_spudec )
{
if( p_spudec->p_vout != NULL
if( p_spudec->p_vout != NULL
&& p_spudec->p_vout->p_subpicture != NULL )
{
subpicture_t * p_subpic;
int i_subpic;
for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
{
p_subpic = &p_spudec->p_vout->p_subpicture[i_subpic];
......@@ -345,12 +226,8 @@ static void EndThread( spudec_thread_t *p_spudec )
}
}
}
#if defined(HAVE_ICONV)
if( p_spudec->iconv_handle != (iconv_t)-1 )
{
iconv_close( p_spudec->iconv_handle );
}
#endif
CloseBitstream( &p_spudec->bit_stream );
free( p_spudec );
}
/*****************************************************************************
* spudec.h : sub picture unit decoder thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: spudec.h,v 1.6 2003/07/14 21:32:58 sigmunau Exp $
* $Id: spudec.h,v 1.7 2003/07/22 20:49:10 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -11,7 +10,7 @@
* 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
......@@ -22,11 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#if defined(HAVE_ICONV)
#include <iconv.h>
#endif
typedef struct spudec_thread_t spudec_thread_t;
struct subpicture_sys_t
......@@ -50,18 +44,6 @@ struct subpicture_sys_t
unsigned int i_x_start, i_y_start, i_x_end, i_y_end;
};
/*****************************************************************************
* subtitler_font_t : proportional font
*****************************************************************************/
typedef struct subtitler_font_s
{
unsigned int i_height; /* character height in pixels */
unsigned int i_width[256]; /* character widths in pixels */
unsigned int i_memory[256]; /* amount of memory used by character */
unsigned int * p_length[256]; /* line byte widths */
uint16_t ** p_offset[256]; /* pointer to RLE data */
} subtitler_font_t;
/*****************************************************************************
* spudec_thread_t : sub picture unit decoder thread descriptor
*****************************************************************************/
......@@ -89,9 +71,6 @@ struct spudec_thread_t
*/
unsigned int i_spu_size; /* size of current SPU packet */
unsigned int i_rle_size; /* size of the RLE part */
#if defined(HAVE_ICONV)
iconv_t iconv_handle; /* handle to iconv instance */
#endif
};
/*****************************************************************************
......@@ -120,9 +99,3 @@ void E_(ParsePacket) ( spudec_thread_t * );
void E_(RenderSPU) ( vout_thread_t *, picture_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 );
/*****************************************************************************
* subtitler.c : subtitler font routines
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors: Andrew Flintham <amf@cus.org.uk>
*
* 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 <errno.h> /* errno */
#include <fcntl.h> /* open() */
#include <ctype.h> /* toascii() */
#include <vlc/vlc.h>
#include <vlc/vout.h>
#include <vlc/decoder.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* read(), close() */
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "spudec.h"
/*****************************************************************************
* subtitler_line : internal structure for an individual line in a subtitle
*****************************************************************************/
typedef struct subtitler_line_s
{
struct subtitler_line_s * p_next;
char * p_text;
} subtitler_line_t;
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static uint16_t *PlotSubtitleLine( char *, subtitler_font_t *, unsigned int,
uint16_t * );
static void DestroySPU ( subpicture_t * );
/*****************************************************************************
* subtitler_LoadFont: load a run-length encoded font file into memory
*****************************************************************************
* RLE font files have the following format:
*
* 2 bytes : magic number: 0x36 0x05
* 1 byte : font height in rows
*
* then, per character:
* 1 byte : character
* 1 byte : character width in pixels
*
* then, per row:
* 1 byte : length of row, in entries
*
* then, per entry
* 1 byte : colour
* 1 byte : number of pixels of that colour
*
* to end:
* 1 byte : 0xff
*****************************************************************************/
subtitler_font_t* E_(subtitler_LoadFont)( vout_thread_t * p_vout,
const char * psz_name )
{
subtitler_font_t * p_font;
unsigned int i;
unsigned int i_char;
unsigned int i_length;
unsigned int i_line;
unsigned int i_total_length;
int i_file;
byte_t pi_buffer[512]; /* file buffer */
msg_Dbg( p_vout, "loading font '%s'", psz_name );
i_file = open( psz_name, O_RDONLY );
if( i_file == -1 )
{
msg_Err( p_vout, "can't open font file '%s' (%s)", psz_name,
strerror(errno) );
return( NULL );
}
/* Read magick number */
if( read( i_file, pi_buffer, 2 ) != 2 )
{
msg_Err( p_vout, "unexpected end of font file '%s'", psz_name );
close( i_file );
return( NULL );
}
if( pi_buffer[0] != 0x36 || pi_buffer[1] != 0x05 )
{
msg_Err( p_vout, "file '%s' is not a font file", psz_name );
close( i_file );
return( NULL );
}
p_font = malloc( sizeof( subtitler_font_t ) );
if( p_font == NULL )
{
msg_Err( p_vout, "out of memory" );
close( i_file );
return NULL;
}
/* Read font height */
if( read( i_file, pi_buffer, 1 ) != 1 )
{
msg_Err( p_vout, "unexpected end of font file '%s'", psz_name );
free( p_font );
close( i_file );
return( NULL );
}
p_font->i_height = pi_buffer[0];
/* Initialise font character data */
for( i = 0; i < 256; i++ )
{
p_font->i_width[i] = 0;
p_font->i_memory[i] = 0;
p_font->p_offset[i] = NULL;
p_font->p_length[i] = NULL;
}
while(1)
{
/* Read character number */
if( read( i_file, pi_buffer, 1 ) != 1)
{
msg_Err( p_vout, "unexpected end of font file '%s'", psz_name );