* video_parser.c : video parser thread
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: video_parser.c,v 1.65 2001/01/12 17:33:18 massiot Exp $
+ * $Id: video_parser.c,v 1.68 2001/01/17 18:17:31 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
#include "threads.h"
#include "mtime.h"
#include "plugins.h"
+#include "modules.h"
#include "intf_msg.h"
#include "video.h"
#include "video_output.h"
-#include "../video_decoder/vdec_idct.h"
-#include "../video_decoder/video_decoder.h"
+#include "video_decoder.h"
#include "../video_decoder/vdec_motion.h"
+#include "../video_decoder/vdec_idct.h"
#include "../video_decoder/vpar_blocks.h"
#include "../video_decoder/vpar_headers.h"
#include "../video_decoder/video_parser.h"
#include "../video_decoder/video_fifo.h"
+#include "main.h"
+
/*
* Local prototypes
*/
static void RunThread ( vpar_thread_t *p_vpar );
static void ErrorThread ( vpar_thread_t *p_vpar );
static void EndThread ( vpar_thread_t *p_vpar );
-static void BitstreamCallback ( bit_stream_t *p_bit_stream );
+static void BitstreamCallback ( bit_stream_t *p_bit_stream,
+ boolean_t b_new_pes );
/*****************************************************************************
* vpar_CreateThread: create a generic parser thread
p_vpar->p_vout = p_config->p_vout;
+ /* Choose the best IDCT module */
+ p_vpar->p_module = module_Need( p_main->p_module_bank,
+ MODULE_CAPABILITY_IDCT, NULL );
+
+ if( p_vpar->p_module == NULL )
+ {
+ intf_ErrMsg( "vpar error: no suitable IDCT module" );
+ free( p_vpar );
+ return( 0 );
+ }
+
+#define idct_functions p_vpar->p_module->p_functions->idct.functions.idct
+ p_vpar->pf_init = idct_functions.pf_init;
+ p_vpar->pf_sparse_idct = idct_functions.pf_sparse_idct;
+ p_vpar->pf_idct = idct_functions.pf_idct;
+ p_vpar->pf_norm_scan = idct_functions.pf_norm_scan;
+#undef idct_functions
+
/* Spawn the video parser thread */
if ( vlc_thread_create( &p_vpar->thread_id, "video parser",
(vlc_thread_func_t)RunThread, (void *)p_vpar ) )
{
intf_ErrMsg("vpar error: can't spawn video parser thread");
+ module_Unneed( p_main->p_module_bank, p_vpar->p_module );
free( p_vpar );
return( 0 );
}
p_vpar->p_config->decoder_config.pf_init_bit_stream( &p_vpar->bit_stream,
p_vpar->p_config->decoder_config.p_decoder_fifo );
+ p_vpar->bit_stream.pf_bitstream_callback = BitstreamCallback;
+ p_vpar->bit_stream.p_callback_arg = (void *)p_vpar;
/* Initialize parsing data */
p_vpar->sequence.p_forward = NULL;
p_vpar->sequence.nonintra_quant.b_allocated = 0;
p_vpar->sequence.chroma_intra_quant.b_allocated = 0;
p_vpar->sequence.chroma_nonintra_quant.b_allocated = 0;
- /* FIXME : initialize matrix_coefficients, but to what value ? */
+ p_vpar->sequence.i_matrix_coefficients = 1;
+ p_vpar->sequence.next_pts = p_vpar->sequence.next_dts = 0;
/* Initialize copyright information */
p_vpar->sequence.b_copyright_flag = 0;
p_vpar->pp_vdec[0]->b_error = 0;
p_vpar->pp_vdec[0]->p_vpar = p_vpar;
+# if VDEC_NICE
/* Re-nice ourself */
if( nice(VDEC_NICE) == -1 )
{
intf_WarnMsg( 2, "vpar warning : couldn't nice() (%s)",
strerror(errno) );
}
+# endif
#endif
/* Initialize lookup tables */
vpar_InitPMBType( p_vpar );
vpar_InitBMBType( p_vpar );
vpar_InitDCTTables( p_vpar );
+ vpar_InitScanTable( p_vpar );
/*
* Initialize the synchro properties
vlc_mutex_destroy( &(p_vpar->synchro.fifo_lock) );
+ module_Unneed( p_main->p_module_bank, p_vpar->p_module );
+
free( p_vpar );
intf_DbgMsg("vpar debug: EndThread(%p)", p_vpar);
/*****************************************************************************
* BitstreamCallback: Import parameters from the new data/PES packet
*****************************************************************************
- * This function is called when the thread ends after a sucessful
- * initialization.
+ * This function is called by input's NextDataPacket.
*****************************************************************************/
-static void BitstreamCallback ( bit_stream_t *p_bit_stream );
+static void BitstreamCallback ( bit_stream_t * p_bit_stream,
+ boolean_t b_new_pes )
+{
+ vpar_thread_t * p_vpar = (vpar_thread_t *)p_bit_stream->p_callback_arg;
+
+ if( b_new_pes )
+ {
+ p_vpar->sequence.next_pts =
+ DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_pts;
+ p_vpar->sequence.next_dts =
+ DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_dts;
+ }
+}