X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fvideo_decoder%2Fvideo_decoder.c;h=023f19750a1047741fb7fe33e7d1c28c957f1f7a;hb=4c3d1e88b603fffca88d9fa5613520684b4747c8;hp=a8406951573e2bebafac029e71724e0a287f8d06;hpb=c36d3ca686c1152838674eba175823b33f36eeb1;p=vlc diff --git a/src/video_decoder/video_decoder.c b/src/video_decoder/video_decoder.c index a840695157..023f19750a 100644 --- a/src/video_decoder/video_decoder.c +++ b/src/video_decoder/video_decoder.c @@ -3,26 +3,24 @@ ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN * - * Authors: + * Authors: Christophe Massiot + * Gaël Hendryckx * * 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. + * 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-1307, USA. + * 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. *****************************************************************************/ -/* FIXME: passer en terminate/destroy avec les signaux supplémentaires ?? */ - /***************************************************************************** * Preamble *****************************************************************************/ @@ -61,8 +59,6 @@ */ #ifdef VDEC_SMP static int vdec_InitThread ( vdec_thread_t *p_vdec ); -static void vdec_DecodeMacroblock( vdec_thread_t *p_vdec, - macroblock_t * p_mb ); #endif static void RunThread ( vdec_thread_t *p_vdec ); static void ErrorThread ( vdec_thread_t *p_vdec ); @@ -154,7 +150,9 @@ static int vdec_InitThread( vdec_thread_t *p_vdec ) int vdec_InitThread( vdec_thread_t *p_vdec ) #endif { +#ifndef HAVE_MMX int i_dummy; +#endif intf_DbgMsg("vdec debug: initializing video decoder thread %p\n", p_vdec); @@ -168,6 +166,7 @@ int vdec_InitThread( vdec_thread_t *p_vdec ) p_vdec->c_decoded_b_pictures = 0; #endif +#ifndef HAVE_MMX /* Init crop table */ p_vdec->pi_crop = p_vdec->pi_crop_buf + (VDEC_CROPRANGE >> 1); for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ ) @@ -182,6 +181,7 @@ int vdec_InitThread( vdec_thread_t *p_vdec ) { p_vdec->pi_crop[i_dummy] = 255; } +#endif /* Mark thread as running and return */ intf_DbgMsg("vdec debug: InitThread(%p) succeeded\n", p_vdec); @@ -210,7 +210,7 @@ static void ErrorThread( vdec_thread_t *p_vdec ) /***************************************************************************** * EndThread: thread destruction ***************************************************************************** - * This function is called when the thread ends after a sucessfull + * This function is called when the thread ends after a sucessful * initialization. *****************************************************************************/ static void EndThread( vdec_thread_t *p_vdec ) @@ -323,8 +323,8 @@ static __inline__ void AddBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, "packuswb %%mm1,%%mm2\n\t" "movq %%mm2,(%0)\n\t" - "emms" - :"+r" (p_data): "r" (p_block),"r" (i_incr+8)); + //"emms" + :"+r" (p_data): "r" (p_block),"r" (i_incr+8)); } #endif @@ -390,7 +390,7 @@ static __inline__ void CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, "movq 112(%1),%%mm0\n\t" "packuswb 120(%1),%%mm0\n\t" "movq %%mm0,(%0)\n\t" - "emms" + //"emms" :"+r" (p_data): "r" (p_block),"r" (i_incr+8)); } #endif @@ -399,7 +399,7 @@ static __inline__ void CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, /***************************************************************************** * vdec_DecodeMacroblock : decode a macroblock of a picture *****************************************************************************/ -#define DECODEBLOCKS( OPBLOCK ) \ +#define DECODEBLOCKSC( OPBLOCK ) \ { \ int i_b, i_mask; \ \ @@ -447,11 +447,64 @@ static __inline__ void CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block, } \ } -#ifdef VDEC_SMP -static __inline__ void vdec_DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb ) -#else -void vdec_DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb ) -#endif +#define DECODEBLOCKSBW( OPBLOCK ) \ +{ \ + int i_b, i_mask; \ + \ + i_mask = 1 << (3 + p_mb->i_chroma_nb_blocks); \ + \ + /* luminance */ \ + for( i_b = 0; i_b < 4; i_b++, i_mask >>= 1 ) \ + { \ + if( p_mb->i_coded_block_pattern & i_mask ) \ + { \ + /* \ + * Inverse DCT (ISO/IEC 13818-2 section Annex A) \ + */ \ + (p_mb->pf_idct[i_b])( p_vdec, p_mb->ppi_blocks[i_b], \ + p_mb->pi_sparse_pos[i_b] ); \ + \ + /* \ + * Adding prediction and coefficient data (ISO/IEC 13818-2 \ + * section 7.6.8) \ + */ \ + OPBLOCK( p_vdec, p_mb->ppi_blocks[i_b], \ + p_mb->p_data[i_b], p_mb->i_addb_l_stride ); \ + } \ + } \ +} + +void vdec_DecodeMacroblockC ( vdec_thread_t *p_vdec, macroblock_t * p_mb ) +{ + if( !(p_mb->i_mb_type & MB_INTRA) ) + { + /* + * Motion Compensation (ISO/IEC 13818-2 section 7.6) + */ + if( p_mb->pf_motion == 0 ) + { + intf_ErrMsg( "vdec error: pf_motion set to NULL\n" ); + } + else + { + p_mb->pf_motion( p_mb ); + } + + DECODEBLOCKSC( AddBlock ) + } + else + { + DECODEBLOCKSC( CopyBlock ) + } + + /* + * Decoding is finished, release the macroblock and free + * unneeded memory. + */ + vpar_ReleaseMacroblock( &p_vdec->p_vpar->vfifo, p_mb ); +} + +void vdec_DecodeMacroblockBW ( vdec_thread_t *p_vdec, macroblock_t * p_mb ) { if( !(p_mb->i_mb_type & MB_INTRA) ) { @@ -467,11 +520,11 @@ void vdec_DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb ) p_mb->pf_motion( p_mb ); } - DECODEBLOCKS( AddBlock ) + DECODEBLOCKSBW( AddBlock ) } else { - DECODEBLOCKS( CopyBlock ) + DECODEBLOCKSBW( CopyBlock ) } /* @@ -482,6 +535,7 @@ void vdec_DecodeMacroblock( vdec_thread_t *p_vdec, macroblock_t * p_mb ) } + /***************************************************************************** * RunThread: video decoder thread ***************************************************************************** @@ -513,7 +567,7 @@ static void RunThread( vdec_thread_t *p_vdec ) if( (p_mb = vpar_GetMacroblock( &p_vdec->p_vpar->vfifo )) != NULL ) { - vdec_DecodeMacroblock( p_vdec, p_mb ); + p_vdec->p_vpar->p_vout->vdec_DecodeMacroblock ( p_vdec, p_mb ); } }