Commit 2b4b4a32 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Vobsub: cosmetics and warnings fixes

parent aa4e4b13
...@@ -577,7 +577,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt, ...@@ -577,7 +577,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
{ {
int i_buffer = p_pkt->i_buffer; int i_buffer = p_pkt->i_buffer;
uint8_t *p_buffer = p_pkt->p_buffer; uint8_t *p_buffer = p_pkt->p_buffer;
int i_length, i_version, i_info_length, i_esm_length, i_es_base; int i_length, i_version, i_info_length, i_es_base;
if( !p_psm || p_buffer[3] != 0xbc ) return VLC_EGENERIC; if( !p_psm || p_buffer[3] != 0xbc ) return VLC_EGENERIC;
...@@ -595,8 +595,8 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt, ...@@ -595,8 +595,8 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
if( i_info_length + 10 > i_length ) return VLC_EGENERIC; if( i_info_length + 10 > i_length ) return VLC_EGENERIC;
/* Elementary stream map */ /* Elementary stream map */
i_esm_length = (uint16_t)(p_buffer[ 10 + i_info_length ] << 8) + /* int i_esm_length = (uint16_t)(p_buffer[ 10 + i_info_length ] << 8) +
p_buffer[ 11 + i_info_length]; p_buffer[ 11 + i_info_length]; */
i_es_base = 12 + i_info_length; i_es_base = 12 + i_info_length;
while( i_es_base + 4 < i_length ) while( i_es_base + 4 < i_length )
......
...@@ -25,23 +25,20 @@ ...@@ -25,23 +25,20 @@
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <sys/types.h>
#include <limits.h> #include <limits.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include "ps.h" #include "ps.h"
#include "vobsub.h" #include "vobsub.h"
#define MAX_LINE 8192
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -69,8 +66,6 @@ typedef struct ...@@ -69,8 +66,6 @@ typedef struct
int i_line; int i_line;
char **line; char **line;
} text_t; } text_t;
static int TextLoad( text_t *, stream_t *s );
static void TextUnload( text_t * );
typedef struct typedef struct
{ {
...@@ -93,25 +88,28 @@ typedef struct ...@@ -93,25 +88,28 @@ typedef struct
struct demux_sys_t struct demux_sys_t
{ {
int64_t i_next_demux_date; int64_t i_next_demux_date;
int64_t i_length; int64_t i_length;
text_t txt; text_t txt;
stream_t *p_vobsub_stream; stream_t *p_vobsub_stream;
/* all tracks */ /* all tracks */
int i_tracks; int i_tracks;
vobsub_track_t *track; vobsub_track_t *track;
int i_original_frame_width; int i_original_frame_width;
int i_original_frame_height; int i_original_frame_height;
bool b_palette; bool b_palette;
uint32_t palette[16]; uint32_t palette[16];
}; };
static int Demux( demux_t * ); static int Demux( demux_t * );
static int Control( demux_t *, int, va_list ); static int Control( demux_t *, int, va_list );
static int TextLoad( text_t *, stream_t *s );
static void TextUnload( text_t * );
static int ParseVobSubIDX( demux_t * ); static int ParseVobSubIDX( demux_t * );
static int DemuxVobSub( demux_t *, block_t *); static int DemuxVobSub( demux_t *, block_t *);
...@@ -138,7 +136,6 @@ static int Open ( vlc_object_t *p_this ) ...@@ -138,7 +136,6 @@ static int Open ( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
free( s ); free( s );
} }
else else
{ {
...@@ -146,11 +143,11 @@ static int Open ( vlc_object_t *p_this ) ...@@ -146,11 +143,11 @@ static int Open ( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_demux->pf_demux = Demux; /* */
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
if( unlikely( !p_sys ) ) if( unlikely( !p_sys ) )
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys->i_length = 0; p_sys->i_length = 0;
p_sys->p_vobsub_stream = NULL; p_sys->p_vobsub_stream = NULL;
p_sys->i_tracks = 0; p_sys->i_tracks = 0;
...@@ -174,8 +171,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -174,8 +171,7 @@ static int Open ( vlc_object_t *p_this )
/* Find the total length of the vobsubs */ /* Find the total length of the vobsubs */
if( p_sys->i_tracks > 0 ) if( p_sys->i_tracks > 0 )
{ {
int i; for( int i = 0; i < p_sys->i_tracks; i++ )
for( i = 0; i < p_sys->i_tracks; i++ )
{ {
if( p_sys->track[i].i_subtitles > 1 ) if( p_sys->track[i].i_subtitles > 1 )
{ {
...@@ -185,8 +181,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -185,8 +181,7 @@ static int Open ( vlc_object_t *p_this )
} }
} }
if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access, if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
p_demux->psz_location ) == -1 )
goto error; goto error;
i_len = strlen( psz_vobname ); i_len = strlen( psz_vobname );
...@@ -203,6 +198,9 @@ static int Open ( vlc_object_t *p_this ) ...@@ -203,6 +198,9 @@ static int Open ( vlc_object_t *p_this )
} }
free( psz_vobname ); free( psz_vobname );
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
...@@ -220,19 +218,16 @@ error: ...@@ -220,19 +218,16 @@ error:
*****************************************************************************/ *****************************************************************************/
static void Close( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this )
{ {
int i;
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
/* Clean all subs from all tracks */
for( i = 0; i < p_sys->i_tracks; i++ )
free( p_sys->track[i].p_subtitles );
free( p_sys->track );
if( p_sys->p_vobsub_stream ) if( p_sys->p_vobsub_stream )
stream_Delete( p_sys->p_vobsub_stream ); stream_Delete( p_sys->p_vobsub_stream );
/* Clean all subs from all tracks */
for( int i = 0; i < p_sys->i_tracks; i++ )
free( p_sys->track[i].p_subtitles );
free( p_sys->track );
free( p_sys ); free( p_sys );
} }
...@@ -354,9 +349,9 @@ static int Demux( demux_t *p_demux ) ...@@ -354,9 +349,9 @@ static int Demux( demux_t *p_demux )
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
int64_t i_maxdate; int64_t i_maxdate;
int i, i_read; int i_read;
for( i = 0; i < p_sys->i_tracks; i++ ) for( int i = 0; i < p_sys->i_tracks; i++ )
{ {
#define tk p_sys->track[i] #define tk p_sys->track[i]
if( tk.i_current_subtitle >= tk.i_subtitles ) if( tk.i_current_subtitle >= tk.i_subtitles )
...@@ -459,12 +454,10 @@ static int TextLoad( text_t *txt, stream_t *s ) ...@@ -459,12 +454,10 @@ static int TextLoad( text_t *txt, stream_t *s )
static void TextUnload( text_t *txt ) static void TextUnload( text_t *txt )
{ {
int i; for( int i = 0; i < txt->i_line_count; i++ )
for( i = 0; i < txt->i_line_count; i++ )
free( txt->line[i] ); free( txt->line[i] );
free( txt->line ); free( txt->line );
txt->i_line = 0; txt->i_line = 0;
txt->i_line_count = 0; txt->i_line_count = 0;
} }
......
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