From efbc9d9043ff8ff92716ddd00a5f61412d535593 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 9 Apr 2010 14:12:59 +0000 Subject: revert r1783 git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8 --- src/filters/source/D2VSource/MPEG2Dec.h | 418 ++++++++++++++++---------------- 1 file changed, 203 insertions(+), 215 deletions(-) (limited to 'src/filters/source/D2VSource/MPEG2Dec.h') diff --git a/src/filters/source/D2VSource/MPEG2Dec.h b/src/filters/source/D2VSource/MPEG2Dec.h index aea3f4f07..34368208b 100644 --- a/src/filters/source/D2VSource/MPEG2Dec.h +++ b/src/filters/source/D2VSource/MPEG2Dec.h @@ -73,244 +73,232 @@ #define FO_SWAP 2 -typedef void (WINAPI *PBufferOp)(unsigned char*, int, int); +typedef void (WINAPI *PBufferOp) (unsigned char*, int, int); #define MAX_FRAME_NUMBER 1000000 #define MAX_GOP_SIZE 1024 -class CMPEG2Dec +class CMPEG2Dec { protected: - // getbit.cpp - void Initialize_Buffer(); - void Fill_Buffer(); - void Next_Packet(); - void Flush_Buffer_All(unsigned int N); - unsigned int Get_Bits_All(unsigned int N); - void Next_File(); - - unsigned int Show_Bits(unsigned int N); - unsigned int Get_Bits(unsigned int N); - void Flush_Buffer(unsigned int N); - void Fill_Next(); - unsigned int Get_Byte(); - unsigned int Get_Short(); - void next_start_code(); - - unsigned char Rdbfr[BUFFER_SIZE], *Rdptr, *Rdmax; - unsigned int CurrentBfr, NextBfr, BitsLeft, Val, Read; - - // gethdr.cpp - int Get_Hdr(); - void sequence_header(); - int slice_header(); + // getbit.cpp + void Initialize_Buffer(); + void Fill_Buffer(); + void Next_Packet(); + void Flush_Buffer_All(unsigned int N); + unsigned int Get_Bits_All(unsigned int N); + void Next_File(); + + unsigned int Show_Bits(unsigned int N); + unsigned int Get_Bits(unsigned int N); + void Flush_Buffer(unsigned int N); + void Fill_Next(); + unsigned int Get_Byte(); + unsigned int Get_Short(); + void next_start_code(); + + unsigned char Rdbfr[BUFFER_SIZE], *Rdptr, *Rdmax; + unsigned int CurrentBfr, NextBfr, BitsLeft, Val, Read; + + // gethdr.cpp + int Get_Hdr(); + void sequence_header(); + int slice_header(); private: - void group_of_pictures_header(); - void picture_header(); - void sequence_extension(); - void sequence_display_extension(); - void quant_matrix_extension(); - void picture_display_extension(); - void picture_coding_extension(); - void copyright_extension(); - int extra_bit_information(); - void extension_and_user_data(); + void group_of_pictures_header(); + void picture_header(); + void sequence_extension(); + void sequence_display_extension(); + void quant_matrix_extension(); + void picture_display_extension(); + void picture_coding_extension(); + void copyright_extension(); + int extra_bit_information(); + void extension_and_user_data(); protected: - // getpic.cpp - void Decode_Picture(int ref, unsigned char *dst, int pitch); + // getpic.cpp + void Decode_Picture(int ref, unsigned char *dst, int pitch); private: - void Update_Picture_Buffers(); - void picture_data(); - int slice(int MBAmax); - void macroblock_modes(int *pmacroblock_type, int *pmotion_type, - int *pmotion_vector_count, int *pmv_format, int *pdmv, int *pmvscale, int *pdct_type); - void Clear_Block(int count); - void Add_Block(int count, int bx, int by, int dct_type, int addflag); - void motion_compensation(int MBA, int macroblock_type, int motion_type, - int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2], int dct_type); - void skipped_macroblock(int dc_dct_pred[3], int PMV[2][2][2], - int *motion_type, int motion_vertical_field_select[2][2], int *macroblock_type); - int start_of_slice(int *MBA, int *MBAinc, int dc_dct_pred[3], int PMV[2][2][2]); - int decode_macroblock(int *macroblock_type, int *motion_type, int *dct_type, - int PMV[2][2][2], int dc_dct_pred[3], int motion_vertical_field_select[2][2], int dmvector[2]); - void Decode_MPEG2_Intra_Block(int comp, int dc_dct_pred[]); - void Decode_MPEG2_Non_Intra_Block(int comp); - - int Get_macroblock_type(); - int Get_I_macroblock_type(); - int Get_P_macroblock_type(); - int Get_B_macroblock_type(); - int Get_D_macroblock_type(); - int Get_coded_block_pattern(); - int Get_macroblock_address_increment(); - int Get_Luma_DC_dct_diff(); - int Get_Chroma_DC_dct_diff(); - - void form_predictions(int bx, int by, int macroblock_type, int motion_type, - int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2]); - void form_prediction(unsigned char *src[], int sfield, unsigned char *dst[], int dfield, - int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag); - void form_component_prediction(unsigned char *src, unsigned char *dst, - int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag); - - // motion.cpp - void motion_vectors(int PMV[2][2][2], int dmvector[2], int motion_vertical_field_select[2][2], - int s, int motion_vector_count, int mv_format, - int h_r_size, int v_r_size, int dmv, int mvscale); - void Dual_Prime_Arithmetic(int DMV[][2], int *dmvector, int mvx, int mvy); + void Update_Picture_Buffers(); + void picture_data(); + int slice(int MBAmax); + void macroblock_modes(int *pmacroblock_type, int *pmotion_type, + int *pmotion_vector_count, int *pmv_format, int *pdmv, int *pmvscale, int *pdct_type); + void Clear_Block(int count); + void Add_Block(int count, int bx, int by, int dct_type, int addflag); + void motion_compensation(int MBA, int macroblock_type, int motion_type, + int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2], int dct_type); + void skipped_macroblock(int dc_dct_pred[3], int PMV[2][2][2], + int *motion_type, int motion_vertical_field_select[2][2], int *macroblock_type); + int start_of_slice(int *MBA, int *MBAinc, int dc_dct_pred[3], int PMV[2][2][2]); + int decode_macroblock(int *macroblock_type, int *motion_type, int *dct_type, + int PMV[2][2][2], int dc_dct_pred[3], int motion_vertical_field_select[2][2], int dmvector[2]); + void Decode_MPEG2_Intra_Block(int comp, int dc_dct_pred[]); + void Decode_MPEG2_Non_Intra_Block(int comp); + + int Get_macroblock_type(); + int Get_I_macroblock_type(); + int Get_P_macroblock_type(); + int Get_B_macroblock_type(); + int Get_D_macroblock_type(); + int Get_coded_block_pattern(); + int Get_macroblock_address_increment(); + int Get_Luma_DC_dct_diff(); + int Get_Chroma_DC_dct_diff(); + + void form_predictions(int bx, int by, int macroblock_type, int motion_type, + int PMV[2][2][2], int motion_vertical_field_select[2][2], int dmvector[2]); + void form_prediction(unsigned char *src[], int sfield, unsigned char *dst[], int dfield, + int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag); + void form_component_prediction(unsigned char *src, unsigned char *dst, + int lx, int lx2, int w, int h, int x, int y, int dx, int dy, int average_flag); + + // motion.cpp + void motion_vectors(int PMV[2][2][2], int dmvector[2], int motion_vertical_field_select[2][2], + int s, int motion_vector_count, int mv_format, + int h_r_size, int v_r_size, int dmv, int mvscale); + void Dual_Prime_Arithmetic(int DMV[][2], int *dmvector, int mvx, int mvy); private: - void motion_vector(int *PMV, int *dmvector, int h_r_size, int v_r_size, - int dmv, int mvscale, int full_pel_vector); - void decode_motion_vector(int *pred, int r_size, int motion_code, - int motion_residualesidual, int full_pel_vector); - int Get_motion_code(); - int Get_dmvector(); + void motion_vector(int *PMV, int *dmvector, int h_r_size, int v_r_size, + int dmv, int mvscale, int full_pel_vector); + void decode_motion_vector(int *pred, int r_size, int motion_code, + int motion_residualesidual, int full_pel_vector); + int Get_motion_code(); + int Get_dmvector(); protected: - // store.cpp - void assembleFrame(unsigned char *src[], int pf, unsigned char *dst, int pitch); + // store.cpp + void assembleFrame(unsigned char *src[], int pf, unsigned char *dst, int pitch); private: - void Luminance_Filter(unsigned char *src, unsigned char *dst); - void conv420to422(unsigned char *src, unsigned char *dst, int frame_type); - void conv422to444(unsigned char *src, unsigned char *dst); - void conv444toRGB24(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch); - void conv422toYUY2(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch); + void Luminance_Filter(unsigned char *src, unsigned char *dst); + void conv420to422(unsigned char *src, unsigned char *dst, int frame_type); + void conv422to444(unsigned char *src, unsigned char *dst); + void conv444toRGB24(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch); + void conv422toYUY2(unsigned char *py, unsigned char *pu, unsigned char *pv, unsigned char *dst, int pitch); protected: - // decoder operation control flags - int Fault_Flag; - int File_Flag; - int File_Limit; - int FO_Flag; - int IDCT_Flag; - int SystemStream_Flag; - - int Luminance_Flag; - int Resize_Flag; - - int KeyOp_Flag; - int lfsr0, lfsr1; - PBufferOp BufferOp; - - int Infile[MAX_FILE_NUMBER]; - char *Infilename[MAX_FILE_NUMBER]; - - int intra_quantizer_matrix[64]; - int non_intra_quantizer_matrix[64]; - int chroma_intra_quantizer_matrix[64]; - int chroma_non_intra_quantizer_matrix[64]; - - int load_intra_quantizer_matrix; - int load_non_intra_quantizer_matrix; - int load_chroma_intra_quantizer_matrix; - int load_chroma_non_intra_quantizer_matrix; - - int q_scale_type; - int alternate_scan; - int quantizer_scale; - - void *fTempArray, *p_fTempArray; - short *block[8], *p_block[8]; - int pf_backward, pf_forward, pf_current; - - // global values - unsigned char *backward_reference_frame[3], *forward_reference_frame[3]; - unsigned char *auxframe[3], *current_frame[3]; - unsigned char *u422, *v422, *u444, *v444, /* *rgb24,*/ *lum; - unsigned char *dstFrame; // replaces rgb24 - __int64 RGB_Scale, RGB_Offset, RGB_CRV, RGB_CBU, RGB_CGX, LumOffsetMask, LumGainMask; - - int HALF_WIDTH, PROGRESSIVE_HEIGHT, INTERLACED_HEIGHT, DOUBLE_WIDTH; - int /*TWIDTH, SWIDTH,*/ HALF_WIDTH_D8, LUM_AREA, CLIP_AREA, HALF_CLIP_AREA, CLIP_STEP; - int DSTBYTES, DSTBYTES2; // these replace TWIDTH and SWIDTH + // decoder operation control flags + int Fault_Flag; + int File_Flag; + int File_Limit; + int FO_Flag; + int IDCT_Flag; + int SystemStream_Flag; + + int Luminance_Flag; + int Resize_Flag; + + int KeyOp_Flag; + int lfsr0, lfsr1; + PBufferOp BufferOp; + + int Infile[MAX_FILE_NUMBER]; + char *Infilename[MAX_FILE_NUMBER]; + + int intra_quantizer_matrix[64]; + int non_intra_quantizer_matrix[64]; + int chroma_intra_quantizer_matrix[64]; + int chroma_non_intra_quantizer_matrix[64]; + + int load_intra_quantizer_matrix; + int load_non_intra_quantizer_matrix; + int load_chroma_intra_quantizer_matrix; + int load_chroma_non_intra_quantizer_matrix; + + int q_scale_type; + int alternate_scan; + int quantizer_scale; + + void *fTempArray, *p_fTempArray; + short *block[8], *p_block[8]; + int pf_backward, pf_forward, pf_current; + + // global values + unsigned char *backward_reference_frame[3], *forward_reference_frame[3]; + unsigned char *auxframe[3], *current_frame[3]; + unsigned char *u422, *v422, *u444, *v444, /* *rgb24,*/ *lum; + unsigned char *dstFrame; // replaces rgb24 + __int64 RGB_Scale, RGB_Offset, RGB_CRV, RGB_CBU, RGB_CGX, LumOffsetMask, LumGainMask; + + int HALF_WIDTH, PROGRESSIVE_HEIGHT, INTERLACED_HEIGHT, DOUBLE_WIDTH; + int /*TWIDTH, SWIDTH,*/ HALF_WIDTH_D8, LUM_AREA, CLIP_AREA, HALF_CLIP_AREA, CLIP_STEP; + int DSTBYTES, DSTBYTES2; // these replace TWIDTH and SWIDTH public: - int Clip_Width, Clip_Height, Resize_Width, Resize_Height; + int Clip_Width, Clip_Height, Resize_Width, Resize_Height; protected: - int Coded_Picture_Width, Coded_Picture_Height, Chroma_Width, Chroma_Height; - int block_count, Second_Field; - int horizontal_size, vertical_size, mb_width, mb_height; - - /* ISO/IEC 13818-2 section 6.2.2.3: sequence_extension() */ - int progressive_sequence; - int chroma_format; - - /* ISO/IEC 13818-2 section 6.2.3: picture_header() */ - int picture_coding_type; - int temporal_reference; - - /* ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header */ - int f_code[2][2]; - int picture_structure; - int frame_pred_frame_dct; - int progressive_frame; - int concealment_motion_vectors; - int intra_dc_precision; - int top_field_first; - int repeat_first_field; - int intra_vlc_format; - - // interface - typedef struct - { - DWORD number; - int file; - __int64 position; - } GOPLIST; - GOPLIST *GOPList[MAX_FRAME_NUMBER]; - - typedef struct - { - DWORD top; - DWORD bottom; - char forward; - char backward; - } FRAMELIST; - FRAMELIST *FrameList[MAX_FRAME_NUMBER]; - - unsigned char *GOPBuffer[MAX_GOP_SIZE]; + int Coded_Picture_Width, Coded_Picture_Height, Chroma_Width, Chroma_Height; + int block_count, Second_Field; + int horizontal_size, vertical_size, mb_width, mb_height; + + /* ISO/IEC 13818-2 section 6.2.2.3: sequence_extension() */ + int progressive_sequence; + int chroma_format; + + /* ISO/IEC 13818-2 section 6.2.3: picture_header() */ + int picture_coding_type; + int temporal_reference; + + /* ISO/IEC 13818-2 section 6.2.3.1: picture_coding_extension() header */ + int f_code[2][2]; + int picture_structure; + int frame_pred_frame_dct; + int progressive_frame; + int concealment_motion_vectors; + int intra_dc_precision; + int top_field_first; + int repeat_first_field; + int intra_vlc_format; + + // interface + typedef struct { + DWORD number; + int file; + __int64 position; + } GOPLIST; + GOPLIST *GOPList[MAX_FRAME_NUMBER]; + + typedef struct { + DWORD top; + DWORD bottom; + char forward; + char backward; + } FRAMELIST; + FRAMELIST *FrameList[MAX_FRAME_NUMBER]; + + unsigned char *GOPBuffer[MAX_GOP_SIZE]; public: - BOOL Field_Order, Full_Frame; + BOOL Field_Order, Full_Frame; protected: - HINSTANCE hLibrary; + HINSTANCE hLibrary; - void Copyodd(unsigned char *src, unsigned char *dst, int pitch, int forward); - void Copyeven(unsigned char *src, unsigned char *dst, int pitch, int forward); + void Copyodd(unsigned char *src, unsigned char *dst, int pitch, int forward); + void Copyeven(unsigned char *src, unsigned char *dst, int pitch, int forward); public: - FILE *VF_File; - int VF_FrameRate; - DWORD VF_FrameLimit; - DWORD VF_FrameBound; - DWORD VF_GOPLimit; - DWORD VF_GOPNow; - DWORD VF_GOPSize; - int VF_FrameSize; - DWORD VF_OldFrame; - DWORD VF_OldRef; - - enum DstFormat - { - RGB24, YUY2 - }; - DstFormat m_dstFormat; - - CMPEG2Dec(); - ~CMPEG2Dec() - { - Close(); - } - int Open(LPCTSTR path, DstFormat); - void Close(); - void Decode(unsigned char *dst, DWORD frame, int pitch); - bool dstRGB24() const - { - return m_dstFormat == RGB24; - } - bool dstYUY2() const - { - return m_dstFormat == YUY2; - } + FILE *VF_File; + int VF_FrameRate; + DWORD VF_FrameLimit; + DWORD VF_FrameBound; + DWORD VF_GOPLimit; + DWORD VF_GOPNow; + DWORD VF_GOPSize; + int VF_FrameSize; + DWORD VF_OldFrame; + DWORD VF_OldRef; + + enum DstFormat { + RGB24, YUY2 + }; + DstFormat m_dstFormat; + + CMPEG2Dec(); + ~CMPEG2Dec() {Close();} + int Open(LPCTSTR path, DstFormat); + void Close(); + void Decode(unsigned char *dst, DWORD frame, int pitch); + bool dstRGB24() const { return m_dstFormat == RGB24; } + bool dstYUY2() const { return m_dstFormat == YUY2; } }; -- cgit v1.2.3