-/*******************************************************************************
+/*****************************************************************************
* video_fifo.c : video FIFO management
- * (c)1999 VideoLAN
- *******************************************************************************/
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ * $Id: video_fifo.c,v 1.28 2001/01/18 05:13:23 sam Exp $
+ *
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *
+ * 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 <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/uio.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
+ *****************************************************************************/
+#include "defs.h"
#include "config.h"
#include "common.h"
+#include "threads.h"
#include "mtime.h"
-#include "vlc_thread.h"
+#include "plugins.h"
#include "intf_msg.h"
-#include "debug.h" /* ?? temporaire, requis par netlist.h */
-#include "input.h"
-#include "input_netlist.h"
-#include "decoder_fifo.h"
+#include "stream_control.h"
+#include "input_ext-dec.h"
+
#include "video.h"
#include "video_output.h"
-#include "vdec_idct.h"
#include "video_decoder.h"
#include "vdec_motion.h"
+#include "../video_decoder/vdec_idct.h"
#include "vpar_blocks.h"
-#include "vpar_headers.h"
-#include "video_fifo.h"
-#include "vpar_synchro.h"
-#include "video_parser.h"
+#include "../video_decoder/vpar_headers.h"
+#include "../video_decoder/vpar_synchro.h"
+#include "../video_decoder/video_parser.h"
+#include "../video_decoder/video_fifo.h"
/*****************************************************************************
* vpar_InitFIFO : initialize the video FIFO
*****************************************************************************/
void vpar_InitFIFO( vpar_thread_t * p_vpar )
{
+#ifdef VDEC_SMP
int i_dummy;
-
+#endif
+
+ p_vpar->vfifo.p_vpar = p_vpar;
+
+#ifdef VDEC_SMP
+
/* Initialize mutex and cond */
vlc_mutex_init( &p_vpar->vfifo.lock );
vlc_cond_init( &p_vpar->vfifo.wait );
vlc_mutex_init( &p_vpar->vbuffer.lock );
-
+
/* Initialize FIFO properties */
p_vpar->vfifo.i_start = p_vpar->vfifo.i_end = 0;
- p_vpar->vfifo.p_vpar = p_vpar;
-
+
/* Initialize buffer properties */
p_vpar->vbuffer.i_index = VFIFO_SIZE; /* all structures are available */
for( i_dummy = 0; i_dummy < VFIFO_SIZE + 1; i_dummy++ )
p_vpar->vbuffer.pp_mb_free[i_dummy] = p_vpar->vbuffer.p_macroblocks
+ i_dummy;
}
-}
-
-/*****************************************************************************
- * vpar_GetMacroblock : return a macroblock to be decoded
- *****************************************************************************/
-macroblock_t * vpar_GetMacroblock( video_fifo_t * p_fifo )
-{
- macroblock_t * p_mb;
-
- vlc_mutex_lock( &p_fifo->lock );
- while( VIDEO_FIFO_ISEMPTY( *p_fifo ) )
- {
- vlc_cond_wait( &p_fifo->wait, &p_fifo->lock );
- if( p_fifo->p_vpar->b_die )
- {
- vlc_mutex_unlock( &p_fifo->lock );
- return( NULL );
- }
- }
-
- p_mb = VIDEO_FIFO_START( *p_fifo );
- VIDEO_FIFO_INCSTART( *p_fifo );
-
- vlc_mutex_unlock( &p_fifo->lock );
-
- return( p_mb );
-}
-
-/*****************************************************************************
- * vpar_NewMacroblock : return a buffer for the parser
- *****************************************************************************/
-macroblock_t * vpar_NewMacroblock( video_fifo_t * p_fifo )
-{
- macroblock_t * p_mb;
-
-#define P_buffer p_fifo->p_vpar->vbuffer
- vlc_mutex_lock( &P_buffer.lock );
- if( P_buffer.i_index == -1 )
- {
- /* No more structures available. This should not happen ! */
-msleep(VPAR_IDLE_SLEEP);
-return vpar_NewMacroblock( p_fifo );
-// return NULL;
- }
-
- p_mb = P_buffer.pp_mb_free[ P_buffer.i_index-- ];
-
- vlc_mutex_unlock( &P_buffer.lock );
-#undef P_buffer
- return( p_mb );
-}
-
-/*****************************************************************************
- * vpar_DecodeMacroblock : put a macroblock in the video fifo
- *****************************************************************************/
-void vpar_DecodeMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
-{
- /* Place picture in the video FIFO */
- vlc_mutex_lock( &p_fifo->lock );
-
- /* By construction, the video FIFO cannot be full */
- VIDEO_FIFO_END( *p_fifo ) = p_mb;
- VIDEO_FIFO_INCEND( *p_fifo );
-
- vlc_mutex_unlock( &p_fifo->lock );
-}
-
-/*****************************************************************************
- * vpar_ReleaseMacroblock : release a macroblock and put the picture in the
- * video output heap, if it is finished
- *****************************************************************************/
-void vpar_ReleaseMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
-{
- /* Unlink picture buffer */
- vlc_mutex_lock( &p_mb->p_picture->lock_deccount );
- p_mb->p_picture->i_deccount--;
-//fprintf(stderr, "%d ", p_mb->p_picture->i_deccount);
- /* Test if it was the last block of the picture */
- if( p_mb->p_picture->i_deccount == 1 )
- {
-fprintf(stderr, "Image decodee\n");
- /* Mark the picture to be displayed */
- vout_DisplayPicture( p_fifo->p_vpar->p_vout, p_mb->p_picture );
-
- /* Warn Synchro for its records. */
- vpar_SynchroEnd( p_fifo->p_vpar );
-
- /* Unlink referenced pictures */
-/* if( p_mb->p_forward != NULL )
- {
- vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_forward );
- }
- if( p_mb->p_backward != NULL )
- {
- vout_UnlinkPicture( p_fifo->p_vpar->p_vout, p_mb->p_backward );
- }*/
- }
- vlc_mutex_unlock( &p_mb->p_picture->lock_deccount );
-
- /* Release the macroblock_t structure */
-#define P_buffer p_fifo->p_vpar->vbuffer
- vlc_mutex_lock( &P_buffer.lock );
- P_buffer.pp_mb_free[ ++P_buffer.i_index ] = p_mb;
- vlc_mutex_unlock( &P_buffer.lock );
-#undef P_buffer
-}
-
-/*****************************************************************************
- * vpar_DestroyMacroblock : destroy a macroblock in case of error
- *****************************************************************************/
-void vpar_DestroyMacroblock( video_fifo_t * p_fifo, macroblock_t * p_mb )
-{
- /* Release the macroblock_t structure */
-#define P_buffer p_fifo->p_vpar->vbuffer
- vlc_mutex_lock( &P_buffer.lock );
- P_buffer.pp_mb_free[ ++P_buffer.i_index ] = p_mb;
- vlc_mutex_unlock( &P_buffer.lock );
-#undef P_buffer
+#endif
}