📄 vpar_headers.c
字号:
if( !b_parsable ) { /* Update the reference pointers. */ ReferenceUpdate( p_vpar, p_vpar->picture.i_coding_type, NULL );#ifndef POLUX_SYNCHRO /* Warn Synchro we have trashed a picture. */ vpar_SynchroTrash( p_vpar, p_vpar->picture.i_coding_type, i_structure );#endif /* Update context. */ if( i_structure != FRAME_STRUCTURE ) p_vpar->picture.i_current_structure = i_structure; p_vpar->picture.p_picture = NULL; return; } /* OK, now we are sure we will decode the picture. */#define P_picture p_vpar->picture.p_picture p_vpar->picture.b_error = 0; p_vpar->picture.b_frame_structure = (i_structure == FRAME_STRUCTURE); if( !p_vpar->picture.i_current_structure ) { /* This is a new frame. Get a structure from the video_output. */ while( ( P_picture = vout_CreatePicture( p_vpar->p_vout, 99+p_vpar->sequence.i_chroma_format, /*XXX??*/ p_vpar->sequence.i_width, p_vpar->sequence.i_height ) ) == NULL ) { intf_DbgMsg("vpar debug: allocation error in vout_CreatePicture, delaying\n"); if( p_vpar->b_die || p_vpar->b_error ) { return; } msleep( VPAR_OUTMEM_SLEEP ); } /* Initialize values. */ vpar_SynchroDecode( p_vpar, p_vpar->picture.i_coding_type, i_structure ); P_picture->i_aspect_ratio = p_vpar->sequence.i_aspect_ratio; P_picture->i_matrix_coefficients = p_vpar->sequence.i_matrix_coefficients; p_vpar->picture.i_l_stride = ( p_vpar->sequence.i_width << ( 1 - p_vpar->picture.b_frame_structure ) ); p_vpar->picture.i_c_stride = ( p_vpar->sequence.i_chroma_width << ( 1 - p_vpar->picture.b_frame_structure )); P_picture->i_deccount = p_vpar->sequence.i_mb_size; vlc_mutex_init( &p_vpar->picture.p_picture->lock_deccount );#ifdef VDEC_SMP memset( p_vpar->picture.pp_mb, 0, MAX_MB*sizeof(macroblock_t *) );#endif/* FIXME ! remove asap ?? *///memset( P_picture->p_data, 0, (p_vpar->sequence.i_mb_size*384)); /* Update the reference pointers. */ ReferenceUpdate( p_vpar, p_vpar->picture.i_coding_type, P_picture );#ifdef VDEC_SMP /* Link referenced pictures for the decoder * They are unlinked in vpar_ReleaseMacroblock() & vpar_DestroyMacroblock() */ if( p_vpar->picture.i_coding_type == P_CODING_TYPE || p_vpar->picture.i_coding_type == B_CODING_TYPE ) { vout_LinkPicture( p_vpar->p_vout, p_vpar->sequence.p_forward ); } if( p_vpar->picture.i_coding_type == B_CODING_TYPE ) { vout_LinkPicture( p_vpar->p_vout, p_vpar->sequence.p_backward ); }#endif } p_vpar->picture.i_current_structure |= i_structure; p_vpar->picture.i_structure = i_structure; /* Initialize picture data for decoding. */ if( i_structure == BOTTOM_FIELD ) { i_mb_base = p_vpar->sequence.i_mb_size >> 1; p_vpar->mb.i_l_y = 1; p_vpar->mb.i_c_y = 1; } else { i_mb_base = 0; p_vpar->mb.i_l_y = p_vpar->mb.i_c_y = 0; } p_vpar->mb.i_l_x = p_vpar->mb.i_c_x = 0; /* Extension and User data. */ ExtensionAndUserData( p_vpar ); /* Picture data (ISO/IEC 13818-2 6.2.3.7). */ if( p_vpar->sequence.i_chroma_format != CHROMA_420 || !p_vpar->sequence.b_mpeg2 || p_vpar->sequence.i_height > 2800 || p_vpar->sequence.i_scalable_mode == SC_DP ) { /* Weird stream. Use the slower generic function. */ vpar_PictureDataGENERIC( p_vpar, i_mb_base ); } else { /* Try to find an optimized function. */ if( ppf_picture_data[p_vpar->picture.i_structure][p_vpar->picture.i_coding_type] == NULL ) { intf_ErrMsg( "vpar error: bad ppf_picture_data function pointer (struct:%d, coding type:%d)\n", p_vpar->picture.i_structure, p_vpar->picture.i_coding_type ); } else { ppf_picture_data[p_vpar->picture.i_structure] [p_vpar->picture.i_coding_type]( p_vpar, i_mb_base ); } } if( p_vpar->b_die || p_vpar->b_error ) { return; } if( p_vpar->picture.b_error ) { /* Trash picture. *///fprintf(stderr, "Image trashee\n");#ifdef VDEC_SMP for( i_mb = 1; p_vpar->picture.pp_mb[i_mb] != NULL; i_mb++ ) { vpar_DestroyMacroblock( &p_vpar->vfifo, p_vpar->picture.pp_mb[i_mb] ); }#endif if( P_picture->i_deccount != 1 ) { vout_DestroyPicture( p_vpar->p_vout, P_picture ); } ReferenceReplace( p_vpar, p_vpar->picture.i_coding_type, NULL ); /* Prepare context for the next picture. */ P_picture = NULL; if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE ) p_vpar->picture.i_current_structure = 0; } else if( p_vpar->picture.i_current_structure == FRAME_STRUCTURE ) {//fprintf(stderr, "Image parsee (%d)\n", p_vpar->picture.i_coding_type); /* Frame completely parsed. */#ifdef VDEC_SMP for( i_mb = 1; p_vpar->picture.pp_mb[i_mb] != NULL; i_mb++ ) { vpar_DecodeMacroblock( &p_vpar->vfifo, p_vpar->picture.pp_mb[i_mb] ); } /* Send signal to the video_decoder. */ vlc_mutex_lock( &p_vpar->vfifo.lock ); vlc_cond_signal( &p_vpar->vfifo.wait ); vlc_mutex_unlock( &p_vpar->vfifo.lock );#endif /* Prepare context for the next picture. */ P_picture = NULL; p_vpar->picture.i_current_structure = 0; }#undef P_picture}/***************************************************************************** * ExtensionAndUserData : Parse the extension_and_user_data structure *****************************************************************************/static void ExtensionAndUserData( vpar_thread_t * p_vpar ){ while( !p_vpar->b_die ) { NextStartCode( p_vpar ); switch( ShowBits( &p_vpar->bit_stream, 32 ) ) { case EXTENSION_START_CODE: RemoveBits32( &p_vpar->bit_stream ); switch( GetBits( &p_vpar->bit_stream, 4 ) ) { case SEQUENCE_DISPLAY_EXTENSION_ID: SequenceDisplayExtension( p_vpar ); break; case QUANT_MATRIX_EXTENSION_ID: QuantMatrixExtension( p_vpar ); break; case SEQUENCE_SCALABLE_EXTENSION_ID: SequenceScalableExtension( p_vpar ); break; case PICTURE_DISPLAY_EXTENSION_ID: PictureDisplayExtension( p_vpar ); break; case PICTURE_SPATIAL_SCALABLE_EXTENSION_ID: PictureSpatialScalableExtension( p_vpar ); break; case PICTURE_TEMPORAL_SCALABLE_EXTENSION_ID: PictureTemporalScalableExtension( p_vpar ); break; case COPYRIGHT_EXTENSION_ID: CopyrightExtension( p_vpar ); break; default: } break; case USER_DATA_START_CODE: RemoveBits32( &p_vpar->bit_stream ); /* Wait for the next start code */ break; default: return; } }}/***************************************************************************** * SequenceDisplayExtension : Parse the sequence_display_extension structure * *****************************************************************************/static void SequenceDisplayExtension( vpar_thread_t * p_vpar ){ /* We don't care sequence_display_extension. */ /* video_format */ RemoveBits( &p_vpar->bit_stream, 3 ); if( GetBits( &p_vpar->bit_stream, 1 ) ) { /* Two bytes for color_desciption */ RemoveBits( &p_vpar->bit_stream, 16 ); p_vpar->sequence.i_matrix_coefficients = GetBits( &p_vpar->bit_stream, 8 ); } /* display_horizontal and vertical_size and a marker_bit */ RemoveBits( &p_vpar->bit_stream, 29 );}/***************************************************************************** * QuantMatrixExtension : Load quantization matrices for luminance * * and chrominance * *****************************************************************************/static void QuantMatrixExtension( vpar_thread_t * p_vpar ){ if( GetBits( &p_vpar->bit_stream, 1 ) ) { /* Load intra_quantiser_matrix for luminance. */ LoadMatrix( p_vpar, &p_vpar->sequence.intra_quant ); } else { /* Use the default matrix. */ LinkMatrix( &p_vpar->sequence.intra_quant, pi_default_intra_quant ); } if( GetBits( &p_vpar->bit_stream, 1 ) ) { /* Load non_intra_quantiser_matrix for luminance. */ LoadMatrix( p_vpar, &p_vpar->sequence.nonintra_quant ); } else { /* Use the default matrix. */ LinkMatrix( &p_vpar->sequence.nonintra_quant, pi_default_nonintra_quant ); } if( GetBits( &p_vpar->bit_stream, 1 ) ) { /* Load intra_quantiser_matrix for chrominance. */ LoadMatrix( p_vpar, &p_vpar->sequence.chroma_intra_quant ); } else { /* Link the chrominance intra matrix to the luminance one. */ LinkMatrix( &p_vpar->sequence.chroma_intra_quant, p_vpar->sequence.intra_quant.pi_matrix ); } if( GetBits( &p_vpar->bit_stream, 1 ) ) { /* Load non_intra_quantiser_matrix for chrominance. */ LoadMatrix( p_vpar, &p_vpar->sequence.chroma_nonintra_quant ); } else { /* Link the chrominance intra matrix to the luminance one. */ LinkMatrix( &p_vpar->sequence.chroma_intra_quant, p_vpar->sequence.intra_quant.pi_matrix ); } if( GetBits( &p_vpar->bit_stream, 1 ) ) { /* Load non_intra_quantiser_matrix for chrominance. */ LoadMatrix( p_vpar, &p_vpar->sequence.chroma_nonintra_quant ); } else { /* Link the chrominance nonintra matrix to the luminance one. */ LinkMatrix( &p_vpar->sequence.chroma_nonintra_quant, p_vpar->sequence.nonintra_quant.pi_matrix ); }}/***************************************************************************** * SequenceScalableExtension : Parse the sequence_scalable_extension * * structure to handle scalable coding * *****************************************************************************/static void SequenceScalableExtension( vpar_thread_t * p_vpar ){ /* We don't care about anything scalable except the scalable mode. */ switch( p_vpar->sequence.i_scalable_mode = GetBits( &p_vpar->bit_stream, 2 ) ) /* The length of the structure depends on the value of the scalable_mode */ { case 1: RemoveBits32( &p_vpar->bit_stream ); RemoveBits( &p_vpar->bit_stream, 21 ); break; case 2: RemoveBits( &p_vpar->bit_stream, 12 ); break; default: RemoveBits( &p_vpar->bit_stream, 4 ); }}/***************************************************************************** * PictureDisplayExtension : Parse the picture_display_extension structure * *****************************************************************************/static void PictureDisplayExtension( vpar_thread_t * p_vpar ){ /* Number of frame center offset */ int i_nb, i_dummy; /* I am not sure it works but it should (fewer tests than shown in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -