43 0.0F, ( ( 23.0F * 1000.0F ) / 1001.0F ),
44 24.0F, 25.0F, ( ( 30.0F * 1000.0F ) / 1001.0F ),
45 30.0F, 50.0F, ( ( 60.0F * 1000.0F ) / 1001.0F ),
46 60.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F
78 static void ( *
DoMC ) ( void );
82 static int _mpeg12_dec_mb (
int*,
int*,
int[ 2 ][ 2 ][ 2 ],
int [ 2 ][ 2 ],
int[ 2 ] );
85 int ( *apDataCB ) (
void* ),
void* apDataCBParam,
126 int i, lSize, lMBWidth, lMBHeight;
390 *(
volatile unsigned int* )0x10002010 &= 0xFF7FFFFF;
416 if( ( lProfLevel >> 7 ) & 1 ) {
418 if ( ( lProfLevel & 15 ) == 5 ) {
513 for ( i = 0; i < lnFCO; ++i ) {
639 _MPEGMotion* lpMotion = &lpMotions -> m_Motion[ 0 ];
641 while ( lpMotion -> MC_Luma ) {
648 lpMotions -> BlockOp ( lpMotions );
701 int* apPred,
int aRSize,
int aMotionCode,
int aMotionResidual,
int aFullPelVector
704 int lLim = 16 << aRSize;
705 int lVec = aFullPelVector ? *apPred >> 1 : *apPred;
707 if ( aMotionCode > 0 ) {
709 lVec += ( ( aMotionCode - 1 ) << aRSize ) + aMotionResidual + 1;
711 if ( lVec >= lLim ) lVec -= lLim + lLim;
713 }
else if ( aMotionCode < 0 ) {
715 lVec -= ( ( -aMotionCode - 1 ) << aRSize ) + aMotionResidual + 1;
717 if ( lVec < -lLim ) lVec += lLim + lLim;
721 *apPred = aFullPelVector ? lVec << 1 : lVec;
731 aDMV[ 0 ][ 0 ] = ( ( aMVX + ( aMVX > 0 ) ) >> 1 ) + apDMVector[ 0 ];
732 aDMV[ 0 ][ 1 ] = ( ( aMVY + ( aMVY > 0 ) ) >> 1 ) + apDMVector[ 1 ] - 1;
734 aDMV[ 1 ][ 0 ] = ( ( 3 * aMVX + ( aMVX > 0 ) ) >> 1 ) + apDMVector[ 0 ];
735 aDMV[ 1 ][ 1 ] = ( ( 3 * aMVY + ( aMVY > 0 ) ) >> 1 ) + apDMVector[ 1 ] + 1;
739 aDMV[ 0 ][ 0 ] = ( ( 3 * aMVX + ( aMVX > 0 ) ) >> 1 ) + apDMVector[ 0 ];
740 aDMV[ 0 ][ 1 ] = ( ( 3 * aMVY + ( aMVY > 0 ) ) >> 1 ) + apDMVector[ 1 ] - 1;
742 aDMV[ 1 ][ 0 ] = ( ( aMVX + ( aMVX > 0 ) ) >> 1 ) + apDMVector[ 0 ];
743 aDMV[ 1 ][ 1 ] = ( ( aMVY + ( aMVY > 0 ) ) >> 1 ) + apDMVector[ 1 ] + 1;
749 aDMV[ 0 ][ 0 ] = ( ( aMVX + ( aMVX > 0 ) ) >> 1 ) + apDMVector[ 0 ];
750 aDMV[ 0 ][ 1 ] = ( ( aMVY + ( aMVY > 0 ) ) >> 1 ) + apDMVector[ 1 ];
754 else ++aDMV[ 0 ][ 1 ];
761 int* apPMV,
int* apDMVector,
int aHRSize,
int aVRSize,
int aDMV,
int aMVScale,
int aFullPelVector
765 int lMotionResidual = aHRSize && lMotionCode ?
_MPEG_GetBits ( aHRSize ) : 0;
768 &apPMV[ 0 ], aHRSize, lMotionCode, lMotionResidual, aFullPelVector
776 lMotionResidual = aVRSize && lMotionCode ?
_MPEG_GetBits ( aVRSize ) : 0;
778 if ( aMVScale ) apPMV[ 1 ] >>= 1;
781 &apPMV[ 1 ], aVRSize, lMotionCode, lMotionResidual, aFullPelVector
784 if ( aMVScale ) apPMV[ 1 ] <<= 1;
793 int aPMV[ 2 ][ 2 ][ 2 ],
int aDMVector[ 2 ],
int aMVFS[ 2 ][ 2 ],
int aS,
int anMV,
794 int aMVFmt,
int aHRSize,
int aVRSize,
int aDMV,
int aMVScale
803 aPMV[ 1 ][ aS ][ 0 ] = aPMV[ 0 ][ aS ][ 0 ];
804 aPMV[ 1 ][ aS ][ 1 ] = aPMV[ 0 ][ aS ][ 1 ];
819 int* apMBType,
int* apMotionType,
820 int aPMV[ 2 ][ 2 ][ 2 ],
int aMVFS[ 2 ][ 2 ],
int aDMVector[ 2 ]
835 if ( !lMBType )
return 0;
870 aPMV, aDMVector, aMVFS, 0, lnMV, lMVFmt,
885 aPMV, aDMVector, aMVFS, 1, lnMV, lMVFmt,
904 aPMV[ 0 ][ 0 ][ 0 ] = aPMV[ 0 ][ 0 ][ 1 ] =
905 aPMV[ 1 ][ 0 ][ 0 ] = aPMV[ 1 ][ 0 ][ 1 ] =
906 aPMV[ 0 ][ 1 ][ 0 ] = aPMV[ 0 ][ 1 ][ 1 ] =
907 aPMV[ 1 ][ 1 ][ 0 ] = aPMV[ 1 ][ 1 ][ 1 ] = 0;
913 aPMV[ 0 ][ 0 ][ 0 ] = aPMV[ 0 ][ 0 ][ 1 ] =
914 aPMV[ 1 ][ 0 ][ 0 ] = aPMV[ 1 ][ 0 ][ 1 ] = 0;
926 *apMotionType = lMotionType;
934 int aDX,
int aDY,
int aH,
int aFSrc,
int aFDst,
int afAvg
937 int lfInt = ( aH & 8 ) >> 3;
938 int lDXY = ( ( aDY & 1 ) << 1 ) | ( aDX & 1 );
939 int lUVXY = ( ( aDX & 2 ) >> 1 ) | ( aDY & 2 );
940 int lSrcX = aX + ( aDX >> 1 );
941 int lSrcY = ( ( anY + ( aDY >> 1 ) ) << lfInt ) + aFSrc;
942 int lMBX = lSrcX >> 4;
943 int lMBY = lSrcY >> 4;
948 __asm__ __volatile__(
950 "pnor $v0, $zero, $zero\n\t"
952 "pextlw %0, %3, %0\n\t"
953 "paddw $at, $at, $v0\n\t"
954 "pmaxw %0, %0, $zero\n\t"
955 "pminw %0, %0, $at\n\t"
956 "dsrl32 %1, %0, 0\n\t"
959 :
"=r"( lMBX ),
"=r"( lMBY ) :
"r"( lMBX ),
"r"( lMBY ),
"m"(
s_MPEG12Ctx.
m_MBWidth ) :
"at",
"v0"
965 lpMotion -> m_X = lSrcX & 0xF;
966 lpMotion -> m_Y = lSrcY & 0xF;
967 lpMotion -> m_H = aH;
968 lpMotion -> m_fInt = lfInt;
969 lpMotion -> m_Field = aFSrc;
970 lpMotion -> MC_Luma =
LumaOp [ lDXY + afAvg ];
971 lpMotion -> MC_Chroma =
ChromaOp[ lUVXY + afAvg ];
976 int aBX,
int aBY,
int aMBType,
int aMotionType,
int aPMV[ 2 ][ 2 ][ 2 ],
977 int aMVFS[ 2 ][ 2 ],
int aDMVector[ 2 ]
1005 8, aMVFS[ 0 ][ 0 ], 0, 0
1009 8, aMVFS[ 1 ][ 0 ], 8, 0
1048 lpMBSrc, aBX, aBY, aPMV[ 0 ][ 0 ][ 0 ], aPMV[ 0 ][ 0 ][ 1 ], 8,
1049 aMVFS[ 0 ][ 0 ], 0, 0
1052 lpMBSrc, aBX, aBY + 8, aPMV[ 0 ][ 0 ][ 0 ], aPMV[ 0 ][ 0 ][ 1 ], 8,
1053 aMVFS[ 0 ][ 0 ], 8, 0
1059 lpMBSrc, aBX, aBY, aPMV[ 0 ][ 0 ][ 0 ], aPMV[ 0 ][ 0 ][ 1 ], 8,
1060 aMVFS[ 0 ][ 0 ], 0, 0
1068 lpMBSrc, aBX, aBY + 8, aPMV[ 1 ][ 0 ][ 0 ], aPMV[ 1 ][ 0 ][ 1 ], 8,
1069 aMVFS[ 1 ][ 0 ], 8, 0
1083 lpMBSrc, aBX, aBY, lDMV[ 0 ][ 0 ], lDMV[ 0 ][ 1 ], 16, !lCurField, 1, 1
1109 8, aMVFS[ 0 ][ 1 ], 0, lfAdd
1113 8, aMVFS[ 1 ][ 1 ], 8, lfAdd
1124 aMVFS[ 0 ][ 1 ], 0, lfAdd
1128 aMVFS[ 0 ][ 1 ], 8, lfAdd
1135 8, aMVFS[ 0 ][ 1 ], 0, lfAdd
1139 8, aMVFS[ 1 ][ 1 ], 8, lfAdd
1157 int aMBA,
int aMBType,
int aMotionType,
int aPMV[ 2 ][ 2 ][ 2 ],
1158 int aMVFS[ 2 ][ 2 ],
int aDMVector[ 2 ],
int aMBAI
1173 lfNoSkip = aMBAI == 1;
1184 _mpeg12_get_refs ( lBX, lBY, aMBType, aMotionType, aPMV, aMVFS, aDMVector );
1201 int lPMV [ 2 ][ 2 ][ 2 ];
1202 int lMVFS [ 2 ][ 2 ];
1204 int lMBA, lMBAI, lMBType, lMotionType;
1230 lPMV[ 0 ][ 0 ][ 0 ] = lPMV[ 0 ][ 0 ][ 1 ] = lPMV[ 1 ][ 0 ][ 0 ] = lPMV[ 1 ][ 0 ][ 1 ] = 0;
1231 lPMV[ 0 ][ 1 ][ 0 ] = lPMV[ 0 ][ 1 ][ 1 ] = lPMV[ 1 ][ 1 ][ 0 ] = lPMV[ 1 ][ 1 ][ 1 ] = 0;
1252 if ( !lMBAI )
goto resync;
1258 if ( lMBA >= aMBAMax )
return -1;
1262 retVal =
_mpeg12_dec_mb ( &lMBType, &lMotionType, lPMV, lMVFS, lDMVector );
1264 if ( retVal < 0 )
return retVal;
1265 if ( !retVal )
goto resync;
1272 lPMV[ 0 ][ 0 ][ 0 ] = lPMV[ 0 ][ 0 ][ 1 ] =
1273 lPMV[ 1 ][ 0 ][ 0 ] = lPMV[ 1 ][ 0 ][ 1 ] = 0;
1286 _mpeg2_mc ( lMBA, lMBType, lMotionType, lPMV, lMVFS, lDMVector, lMBAI );
1295 if ( lMBA >= aMBAMax )
return -1;
static void * _init_seq(void)
static void *(* _init_cb)(void *, MPEGSequenceInfo *)
static int _get_first_picture(void *, s64 *)
static void _ext_pic_tsc(void)
static void _mpeg12_do_next_mc(void)
static void _mpeg12_motion_vector(int *apPMV, int *apDMVector, int aHRSize, int aVRSize, int aDMV, int aMVScale, int aFullPelVector)
static void _xtra_bitinf(void)
static int _mpeg12_dec_mb(int *, int *, int[2][2][2], int[2][2], int[2])
static void _ext_unknown(void)
int(* MPEG_Picture)(void *, s64 *)
static void _pic_header(void)
static void _ext_seq_scl(void)
static void _ext_cpy_rgt(void)
static void _ext_pic_dsp(void)
static void * s_pInitCBParam
static void(* LumaOp[8])(_MPEGMotion *)
static void _ext_pic_ssc(void)
static void _ext_seq(void)
static void(* PutBlockOp[3])(_MPEGMotions *)
static void _mpeg2_mc(int aMBA, int aMBType, int aMotionType, int aPMV[2][2][2], int aMVFS[2][2], int aDMVector[2], int aMBAI)
static int _get_hdr(void)
static void _ext_and_ud(void)
static void _ext_qnt_mtx(void)
static void _mpeg12_dual_prime_vector(int aDMV[][2], int *apDMVector, int aMVX, int aMVY)
static void _ext_seq_dsp(void)
static void _mpeg12_motion_vectors(int aPMV[2][2][2], int aDMVector[2], int aMVFS[2][2], int aS, int anMV, int aMVFmt, int aHRSize, int aVRSize, int aDMV, int aMVScale)
static void(* ChromaOp[8])(void)
static void(* DoMC)(void)
static void _mpeg12_do_first_mc(void)
static _MPEGContext s_MPEG12Ctx
static void(* AddBlockOp[2][2])(_MPEGMotions *)
static int _get_next_picture(void *, s64 *)
void MPEG_Initialize(int(*apDataCB)(void *), void *apDataCBParam, void *(*apInitCB)(void *, MPEGSequenceInfo *), void *apInitCBParam, s64 *apCurPTS)
static void _destroy_seq(void)
static void _mpeg12_picture_data(void)
static void _mpeg12_decode_motion_vector(int *apPred, int aRSize, int aMotionCode, int aMotionResidual, int aFullPelVector)
static void _seq_header(void)
static void _ext_pic_cod(void)
static void _gop_header(void)
static float s_FrameRate[16]
static int _mpeg12_slice(int)
static void _mpeg12_get_refs(int aBX, int aBY, int aMBType, int aMotionType, int aPMV[2][2][2], int aMVFS[2][2], int aDMVector[2])
static void _mpeg12_get_ref(_MPEGMacroBlock8 *apMBSrc, int aX, int anY, int aDX, int aDY, int aH, int aFSrc, int aFDst, int afAvg)
#define MPEG_VIDEO_FORMAT_UNSPEC
#define MPEG_CHROMA_FORMAT_420
void _MPEG_avg_luma_Y(_MPEGMotion *)
void _MPEG_dma_ref_image(_MPEGMacroBlock8 *, _MPEGMotion *, int, int)
#define _MPEG_CODE_EXTENSION
#define _MPEG_PS_TOP_FIELD
#define _MPEG_PS_BOTTOM_FIELD
#define _MPEG_XID_PIC_COD
void _MPEG_avg_chroma_Y(void)
void _MPEG_put_luma_Y(_MPEGMotion *)
void _MPEG_put_block_il(_MPEGMotions *)
#define _MPEG_XID_QMATRIX
int _MPEG_GetMotionCode(void)
#define _MPEG_CODE_USER_DATA
void _MPEG_avg_luma(_MPEGMotion *)
unsigned int _MPEG_ShowBits(unsigned int)
#define _MPEG_MBT_MOTION_BACKWARD
void _MPEG_put_block_fr(_MPEGMotions *)
void _MPEG_SetQSTIVFAS(void)
void _MPEG_put_chroma_Y(void)
#define _MPEG_XID_PIC_SSC
#define _MPEG_XID_SEQUENCE
int _MPEG_GetDMVector(void)
void _MPEG_put_block_fl(_MPEGMotions *)
void _MPEG_put_luma(_MPEGMotion *)
#define _MPEG_XID_PIC_TSC
void _MPEG_put_luma_X(_MPEGMotion *)
#define _MPEG_CODE_PIC_START
void _MPEG_put_luma_XY(_MPEGMotion *)
#define _MPEG_MBT_MOTION_FORWARD
unsigned int _MPEG_NextStartCode(void)
#define _MPEG_CODE_SEQ_END
void _MPEG_avg_chroma_X(void)
void _MPEG_avg_luma_X(_MPEGMotion *)
int _MPEG_CSCImage(void *, void *, int)
void _MPEG_avg_chroma_XY(void)
void _MPEG_Initialize(_MPEGContext *, int(*)(void *), void *, int *)
void _MPEG_put_chroma_XY(void)
#define _MPEG_MBT_PATTERN
#define _MPEG_XID_SCALABLE
int _MPEG_GetMBType(void)
void _MPEG_add_block_frfr(_MPEGMotions *)
#define _MPEG_CODE_SEQ_HDR
#define _MPEG_CODE_GRP_START
void _MPEG_SetPCT(unsigned int)
void _MPEG_add_block_ilfl(_MPEGMotions *)
void _MPEG_put_chroma_X(void)
void _MPEG_BDEC(int, int, int, int, void *)
void _MPEG_avg_chroma(void)
void _MPEG_add_block_frfl(_MPEGMotions *)
unsigned int _MPEG_GetBits(unsigned int)
#define _MPEG_CODE_SLICE_MAX
#define _MPEG_XID_COPYRIGHT
void _MPEG_avg_luma_XY(_MPEGMotion *)
#define _MPEG_XID_PIC_DSP
void _MPEG_do_mc(_MPEGMotion *)
#define _MPEG_XID_DISPLAY
void _MPEG_put_chroma(void)
_MPEGMacroBlock8 * m_pAuxFrame
_MPEGMacroBlock8 * m_pCurFrame
_MPEGMotions * m_pCurMotions
_MPEGMacroBlock8 * m_pBckFrame
_MPEGMacroBlock8 * m_pFwdFrame
unsigned char * m_pCurFrameY
unsigned char * m_pCurFrameCbCr
unsigned char * m_pSPRBlk
unsigned char * m_pSPRRes