X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fxvmc%2Fxxmc.c;h=8d16ff5b7480f03a7ddd299f30218350e2c41dae;hb=be5d9107a6ba2160a0baa5ea51fc3c121265d5d2;hp=d35ae3c89dae17bd1f88f00caae3ea25e94f83e4;hpb=7b0773e690a9c1388f4cfbe7c8fa3fa43a76e54c;p=vlc diff --git a/modules/codec/xvmc/xxmc.c b/modules/codec/xvmc/xxmc.c index d35ae3c89d..8d16ff5b74 100644 --- a/modules/codec/xvmc/xxmc.c +++ b/modules/codec/xvmc/xxmc.c @@ -25,19 +25,25 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include -#include +#include +#include -#include #include -#include +#ifdef __GLIBC__ + #include +#endif #include "mpeg2.h" -#include "attributes.h" +//#include "attributes.h" #include "mpeg2_internal.h" -#include "xvmc_vld.h" +//#include "xvmc_vld.h" /* Aspect ratio (ISO/IEC 13818-2 section 6.3.3, table 6-3) */ #define AR_SQUARE_PICTURE 1 /* square pixels */ @@ -55,30 +61,29 @@ struct decoder_sys_t */ mpeg2dec_t *p_mpeg2dec; const mpeg2_info_t *p_info; - vlc_bool_t b_skip; + bool b_skip; /* * Input properties */ - mtime_t i_pts; - mtime_t i_previous_pts; - mtime_t i_current_pts; - mtime_t i_previous_dts; - mtime_t i_current_dts; - int i_current_rate; - picture_t * p_picture_to_destroy; - vlc_bool_t b_garbage_pic; - vlc_bool_t b_after_sequence_header; /* is it the next frame after - * the sequence header ? */ - vlc_bool_t b_slice_i; /* intra-slice refresh stream */ + mtime_t i_pts; + mtime_t i_previous_pts; + mtime_t i_current_pts; + mtime_t i_previous_dts; + mtime_t i_current_dts; + int i_current_rate; + picture_t * p_picture_to_destroy; + bool b_garbage_pic; + bool b_after_sequence_header; /* is it the next frame after + * the sequence header ? */ + bool b_slice_i; /* intra-slice refresh stream */ /* * Output properties */ - vout_synchro_t *p_synchro; - int i_aspect; - mtime_t i_last_frame_pts; - + decoder_synchro_t *p_synchro; + int i_aspect; + mtime_t i_last_frame_pts; }; /***************************************************************************** @@ -95,12 +100,12 @@ static picture_t *GetNewPicture( decoder_t *, uint8_t ** ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_description( _("MPEG I/II hw video decoder (using libmpeg2)") ); - set_capability( "decoder", 160 ); - set_callbacks( OpenDecoder, CloseDecoder ); - add_shortcut( "xxmc" ); -vlc_module_end(); +vlc_module_begin () + set_description( N_("MPEG I/II hw video decoder (using libmpeg2)") ) + set_capability( "decoder", 140 ) + set_callbacks( OpenDecoder, CloseDecoder ) + add_shortcut( "xxmc" ) +vlc_module_end () /***************************************************************************** * OpenDecoder: probe the decoder and return score @@ -113,31 +118,38 @@ static int OpenDecoder( vlc_object_t *p_this ) uint32_t i_accel = 0; FILE *f_wd_dec; - msg_Dbg(p_dec, "OpenDecoder Entering"); +#ifdef __GLIBC__ mtrace(); - if( p_dec->fmt_in.i_codec != VLC_FOURCC('m','p','g','v') && - p_dec->fmt_in.i_codec != VLC_FOURCC('m','p','g','1') && - /* Pinnacle hardware-mpeg1 */ - p_dec->fmt_in.i_codec != VLC_FOURCC('P','I','M','1') && - /* VIA hardware-mpeg2 */ - p_dec->fmt_in.i_codec != VLC_FOURCC('X','x','M','C') && - /* ATI Video */ - p_dec->fmt_in.i_codec != VLC_FOURCC('V','C','R','2') && - p_dec->fmt_in.i_codec != VLC_FOURCC('m','p','g','2') ) - { +#endif + if( p_dec->fmt_in.i_codec != VLC_CODEC_MPGV ) return VLC_EGENERIC; + /* Select onl recognized original format (standard mpeg video) */ + switch( p_dec->fmt_in.i_original_fourcc ) + { + case VLC_FOURCC('m','p','g','1'): + case VLC_FOURCC('m','p','g','2'): + case VLC_FOURCC('m','p','g','v'): + /* Pinnacle hardware-mpeg1 */ + case VLC_FOURCC('P','I','M','1'): + /* VIA hardware-mpeg2 */ + case VLC_FOURCC('X','x','M','C'): + /* ATI Video */ + case VLC_FOURCC('V','C','R','2'): + break; + default: + if( p_dec->fmt_in.i_original_fourcc ) + return VLC_EGENERIC; + break; } + msg_Dbg(p_dec, "OpenDecoder Entering"); + /* Allocate the memory needed to store the decoder's structure */ - p_dec->p_sys = p_sys = (decoder_sys_t *)malloc(sizeof(decoder_sys_t)); + p_dec->p_sys = p_sys = calloc( 1, sizeof(*p_sys) ); if( !p_sys ) - { - msg_Err( p_dec, "out of memory" ); - return VLC_EGENERIC; - } + return VLC_ENOMEM; /* Initialize the thread properties */ - memset( p_sys, 0, sizeof(decoder_sys_t) ); p_sys->p_mpeg2dec = NULL; p_sys->p_synchro = NULL; p_sys->p_info = NULL; @@ -194,9 +206,10 @@ static int OpenDecoder( vlc_object_t *p_this ) p_sys->p_info = mpeg2_info( p_sys->p_mpeg2dec ); p_dec->pf_decode_video = DecodeBlock; + p_dec->fmt_out.i_cat = VIDEO_ES; + p_dec->fmt_out.i_codec = 0; f_wd_dec = fopen("/vlc/dec_pid", "w"); - if (f_wd_dec != NULL) { fprintf(f_wd_dec, "%d\n", getpid()); @@ -208,6 +221,7 @@ static int OpenDecoder( vlc_object_t *p_this ) return VLC_SUCCESS; } +#if 0 static void WriteDecodeFile(int value) { FILE *f_wd_ok; @@ -220,6 +234,7 @@ static void WriteDecodeFile(int value) fclose(f_wd_ok); } } +#endif /***************************************************************************** * RunDecoder: the libmpeg2 decoder @@ -252,7 +267,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) p_sys->p_info->sequence && p_sys->p_info->sequence->width != (unsigned int)-1 ) { - vout_SynchroReset( p_sys->p_synchro ); + decoder_SynchroReset( p_sys->p_synchro ); if( p_sys->p_info->current_fbuf != NULL && p_sys->p_info->current_fbuf->id != NULL ) { @@ -271,11 +286,11 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) if ( p_sys->b_slice_i ) { - vout_SynchroNewPicture( p_sys->p_synchro, - I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate, + decoder_SynchroNewPicture( p_sys->p_synchro, + I_CODING_TYPE, 2, 0, 0, p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY ); - vout_SynchroDecode( p_sys->p_synchro ); - vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 ); + decoder_SynchroDecode( p_sys->p_synchro ); + decoder_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 ); } } @@ -374,13 +389,13 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic ); p_pic->date = 0; - p_dec->pf_picture_link( p_dec, p_pic ); + decoder_LinkPicture( p_dec, p_pic ); if( p_sys->p_synchro ) { - vout_SynchroRelease( p_sys->p_synchro ); + decoder_SynchroRelease( p_sys->p_synchro ); } - p_sys->p_synchro = vout_SynchroInit( p_dec, + p_sys->p_synchro = decoder_SynchroInit( p_dec, (uint32_t)((uint64_t)1001000000 * 27 / p_sys->p_info->sequence->frame_period) ); p_sys->b_after_sequence_header = 1; @@ -388,19 +403,19 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) break; case STATE_PICTURE_2ND: - vout_SynchroNewPicture( p_sys->p_synchro, + decoder_SynchroNewPicture( p_sys->p_synchro, p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE, p_sys->p_info->current_picture->nb_fields, - 0, 0, p_sys->i_current_rate, + 0, 0, p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY ); if( p_sys->b_skip ) { - vout_SynchroTrash( p_sys->p_synchro ); + decoder_SynchroTrash( p_sys->p_synchro ); } else { - vout_SynchroDecode( p_sys->p_synchro ); + decoder_SynchroDecode( p_sys->p_synchro ); } break; @@ -416,11 +431,11 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { /* Intra-slice refresh. Simulate a blank I picture. */ msg_Dbg( p_dec, "intra-slice refresh stream" ); - vout_SynchroNewPicture( p_sys->p_synchro, - I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate, + decoder_SynchroNewPicture( p_sys->p_synchro, + I_CODING_TYPE, 2, 0, 0, p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY ); - vout_SynchroDecode( p_sys->p_synchro ); - vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 ); + decoder_SynchroDecode( p_sys->p_synchro ); + decoder_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 ); p_sys->b_slice_i = 1; } p_sys->b_after_sequence_header = 0; @@ -449,16 +464,16 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) p_block->i_pts = p_block->i_dts = 0; /* End hack */ - vout_SynchroNewPicture( p_sys->p_synchro, + decoder_SynchroNewPicture( p_sys->p_synchro, p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE, p_sys->p_info->current_picture->nb_fields, i_pts, - 0, p_sys->i_current_rate, + 0, p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY ); if ( !(p_sys->b_slice_i && ((p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE) == P_CODING_TYPE)) - && !vout_SynchroChoose( p_sys->p_synchro, + && !decoder_SynchroChoose( p_sys->p_synchro, p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE, /*FindVout(p_dec)->render_time*/ 0 /*FIXME*/, @@ -466,14 +481,14 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { mpeg2_skip( p_sys->p_mpeg2dec, 1 ); p_sys->b_skip = 1; - vout_SynchroTrash( p_sys->p_synchro ); + decoder_SynchroTrash( p_sys->p_synchro ); mpeg2_set_buf( p_sys->p_mpeg2dec, buf, NULL ); } else { mpeg2_skip( p_sys->p_mpeg2dec, 0 ); p_sys->b_skip = 0; - vout_SynchroDecode( p_sys->p_synchro ); + decoder_SynchroDecode( p_sys->p_synchro ); if( (p_pic = GetNewPicture( p_dec, buf )) == NULL ) { @@ -481,8 +496,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) return NULL; } - p_sys->p_mpeg2dec->ptr_forward_ref_picture = p_sys->p_mpeg2dec->fbuf[2]->id; - p_sys->p_mpeg2dec->ptr_backward_ref_picture = p_sys->p_mpeg2dec->fbuf[1]->id; + //p_sys->p_mpeg2dec->ptr_forward_ref_picture = p_sys->p_mpeg2dec->fbuf[2]->id; + //p_sys->p_mpeg2dec->ptr_backward_ref_picture = p_sys->p_mpeg2dec->fbuf[1]->id; if ((p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE) != B_CODING_TYPE) { @@ -490,9 +505,9 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) // p_sys->p_mpeg2dec->ptr_forward_ref_picture != picture->backward_reference_frame) // p_pic->forward_reference_frame->free (p_pic->forward_reference_frame); - p_sys->p_mpeg2dec->ptr_forward_ref_picture = - p_sys->p_mpeg2dec->ptr_backward_ref_picture; - p_sys->p_mpeg2dec->ptr_backward_ref_picture = (void *)p_pic; + //p_sys->p_mpeg2dec->ptr_forward_ref_picture = + // p_sys->p_mpeg2dec->ptr_backward_ref_picture; + //p_sys->p_mpeg2dec->ptr_backward_ref_picture = (void *)p_pic; } mpeg2_set_buf( p_sys->p_mpeg2dec, buf, p_pic ); } @@ -507,7 +522,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { p_pic = (picture_t *)p_sys->p_info->display_fbuf->id; - vout_SynchroEnd( p_sys->p_synchro, + decoder_SynchroEnd( p_sys->p_synchro, p_sys->p_info->display_picture->flags & PIC_MASK_CODING_TYPE, p_sys->b_garbage_pic ); @@ -515,7 +530,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) if ( p_sys->p_picture_to_destroy != p_pic ) { - p_pic->date = vout_SynchroDate( p_sys->p_synchro ); + p_pic->date = decoder_SynchroDate( p_sys->p_synchro ); } else { @@ -527,10 +542,10 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) if( p_sys->p_info->discard_fbuf && p_sys->p_info->discard_fbuf->id ) { - p_dec->pf_picture_unlink( p_dec, p_sys->p_info->discard_fbuf->id ); + decoder_UnlinkPicture( p_dec, p_sys->p_info->discard_fbuf->id ); } /* For still frames */ - //if( state == STATE_END && p_pic ) p_pic->b_force = VLC_TRUE; + //if( state == STATE_END && p_pic ) p_pic->b_force = true; if( p_pic ) { @@ -554,7 +569,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) ( ( p_sys->p_info->current_picture->flags & PIC_MASK_CODING_TYPE) != B_CODING_TYPE ) ) { - if( p_sys->p_synchro ) vout_SynchroReset( p_sys->p_synchro ); + if( p_sys->p_synchro ) decoder_SynchroReset( p_sys->p_synchro ); } mpeg2_skip( p_sys->p_mpeg2dec, 1 ); p_sys->b_skip = 1; @@ -589,11 +604,11 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) if( p_sys->b_slice_i ) { - vout_SynchroNewPicture( p_sys->p_synchro, - I_CODING_TYPE, 2, 0, 0, p_sys->i_current_rate, + decoder_SynchroNewPicture( p_sys->p_synchro, + I_CODING_TYPE, 2, 0, 0, p_sys->p_info->sequence->flags & SEQ_FLAG_LOW_DELAY ); - vout_SynchroDecode( p_sys->p_synchro ); - vout_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 ); + decoder_SynchroDecode( p_sys->p_synchro ); + decoder_SynchroEnd( p_sys->p_synchro, I_CODING_TYPE, 0 ); } break; } @@ -614,7 +629,7 @@ static void CloseDecoder( vlc_object_t *p_this ) decoder_sys_t *p_sys = p_dec->p_sys; FILE *f_wd_dec; - if( p_sys->p_synchro ) vout_SynchroRelease( p_sys->p_synchro ); + if( p_sys->p_synchro ) decoder_SynchroRelease( p_sys->p_synchro ); if( p_sys->p_mpeg2dec ) mpeg2_close( p_sys->p_mpeg2dec ); f_wd_dec = fopen("/vlc/dec_pid", "w"); @@ -627,6 +642,7 @@ static void CloseDecoder( vlc_object_t *p_this ) free( p_sys ); } +#if 0 static double get_aspect_ratio( decoder_t *p_dec ) { decoder_sys_t *p_sys = p_dec->p_sys; @@ -639,7 +655,7 @@ static double get_aspect_ratio( decoder_t *p_dec ) { /* these hardcoded values are defined on mpeg2 standard for * aspect ratio. other values are reserved or forbidden. */ - switch( p_sys->p_mpeg2dec->decoder.aspect_ratio_information ) + /*switch( p_sys->p_mpeg2dec->decoder.aspect_ratio_information ) { case 2: ratio = 4.0/3.0; @@ -651,19 +667,21 @@ static double get_aspect_ratio( decoder_t *p_dec ) ratio = 2.11/1.0; break; case 1: - default: + default:*/ ratio = (double)p_sys->p_mpeg2dec->decoder.width/(double)p_sys->p_mpeg2dec->decoder.height; - break; - } + /* break; + }*/ } else { /* mpeg1 constants refer to pixel aspect ratio */ ratio = (double)p_sys->p_mpeg2dec->decoder.width/(double)p_sys->p_mpeg2dec->decoder.height; - ratio /= mpeg1_pel_ratio[p_sys->p_mpeg2dec->decoder.aspect_ratio_information]; + /* ratio /= mpeg1_pel_ratio[p_sys->p_mpeg2dec->decoder.aspect_ratio_information]; */ } return ratio; } +#endif + /***************************************************************************** * GetNewPicture: Get a new picture from the vout and set the buf struct *****************************************************************************/ @@ -688,18 +706,18 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf ) p_dec->fmt_out.i_codec = ( p_sys->p_info->sequence->chroma_height < p_sys->p_info->sequence->height ) ? - VLC_FOURCC('I','4','2','0') : VLC_FOURCC('I','4','2','2'); + VLC_CODEC_I420 : VLC_CODEC_I422; #if 0 p_sys->f_wd_nb = fopen("/vlc/dec_nb", "w"); if (p_sys->f_wd_nb != NULL) { -// fprintf(p_sys->f_wd_nb, "%d\n", mdate()); +// fprintf(p_sys->f_wd_nb, "%d\n", mdate()); fprintf(p_sys->f_wd_nb, "%s\n", mdate()); - fflush(p_sys->f_wd_nb); + fflush(p_sys->f_wd_nb); } #endif - p_pic = p_dec->pf_vout_buffer_new( p_dec ); + p_pic = decoder_NewPicture( p_dec ); if( p_pic == NULL ) return NULL; @@ -712,7 +730,7 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf ) p_pic->format.i_frame_rate = p_dec->fmt_out.video.i_frame_rate; p_pic->format.i_frame_rate_base = p_dec->fmt_out.video.i_frame_rate_base; - p_dec->pf_picture_link( p_dec, p_pic ); + decoder_LinkPicture( p_dec, p_pic ); pp_buf[0] = p_pic->p[0].p_pixels; pp_buf[1] = p_pic->p[1].p_pixels; @@ -725,8 +743,8 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf ) p_dec->fmt_out.video.i_height, p_dec->fmt_out.video.i_aspect, format, flags); -#endif mpeg2_xxmc_choose_coding( p_dec, &p_sys->p_mpeg2dec->decoder, p_pic, get_aspect_ratio(p_dec), 0 ); +#endif return p_pic; }