📄 mp4decvop.c
字号:
pSrc2 = pDst2 - step; j = frameWidth + 2 * expandPels; for (i = 0; i < expandPels; i ++) { ippsCopy_8u(pSrc1, pDst1, j); ippsCopy_8u(pSrc2, pDst2, j); pDst1 += step; pDst2 += step; }}/*// padding VOP (for not complete blocks padd by// 0 for DivX(tm) 5.0 AVI streams// 128 for QuickTime(tm) MP4 streams// replication for other*/void mp4_PadFrame(mp4_Info* pInfo){ int wL, hL, wC, hC, i; //if (pInfo->VisualObject.VideoObject.short_video_header) // return; wL = pInfo->VisualObject.VideoObject.width; hL = pInfo->VisualObject.VideoObject.height; wC = pInfo->VisualObject.VideoObject.width >> 1; hC = pInfo->VisualObject.VideoObject.height >> 1; if ((pInfo->VisualObject.VideoObject.width & 15 || pInfo->VisualObject.VideoObject.height & 15) && ((pInfo->ftype == 1 && pInfo->ftype_f == 0) || (pInfo->ftype == 2 && pInfo->ftype_f == 1))) { Ipp8u pad = (Ipp8u)(pInfo->ftype == 1 ? 128 : 0); if (pInfo->VisualObject.VideoObject.width & 15) { Ipp8u *p; // pad one col p = pInfo->VisualObject.cFrame.pY + pInfo->VisualObject.VideoObject.width; for (i = 0; i < pInfo->VisualObject.VideoObject.height; i ++) { *p = pad; p += pInfo->VisualObject.cFrame.stepY; } p = pInfo->VisualObject.cFrame.pCb + (pInfo->VisualObject.VideoObject.width >> 1); for (i = 0; i < pInfo->VisualObject.VideoObject.height >> 1; i ++) { *p = pad; p += pInfo->VisualObject.cFrame.stepCb; } p = pInfo->VisualObject.cFrame.pCr + (pInfo->VisualObject.VideoObject.width >> 1); for (i = 0; i < pInfo->VisualObject.VideoObject.height >> 1; i ++) { *p = pad; p += pInfo->VisualObject.cFrame.stepCr; } wL ++; wC ++; } if (pInfo->VisualObject.VideoObject.height & 15) { // pad one row ippsSet_8u(pad, pInfo->VisualObject.cFrame.pY + pInfo->VisualObject.cFrame.stepY * pInfo->VisualObject.VideoObject.height, pInfo->VisualObject.VideoObject.width); ippsSet_8u(pad, pInfo->VisualObject.cFrame.pCb + pInfo->VisualObject.cFrame.stepCb * (pInfo->VisualObject.VideoObject.height >> 1), pInfo->VisualObject.VideoObject.width >> 1); ippsSet_8u(pad, pInfo->VisualObject.cFrame.pCr + pInfo->VisualObject.cFrame.stepCr * (pInfo->VisualObject.VideoObject.height >> 1), pInfo->VisualObject.VideoObject.width >> 1); hL ++; hC ++; } } mp4_ExpandFrameReplicate(pInfo->VisualObject.cFrame.apY, wL, hL, 16, pInfo->VisualObject.cFrame.stepY); mp4_ExpandFrameReplicate(pInfo->VisualObject.cFrame.apCb, wC, hC, 8, pInfo->VisualObject.cFrame.stepCb); mp4_ExpandFrameReplicate(pInfo->VisualObject.cFrame.apCr, wC, hC, 8, pInfo->VisualObject.cFrame.stepCr);/* if (pInfo->VisualObject.VideoObject.interlaced) { Ipp8u *psb, *pdb, *pst, *pdt; // pad fields psb = pInfo->VisualObject.cFrame.pY + pInfo->VisualObject.cFrame.stepY - 16; pdb = psb - (pInfo->VisualObject.cFrame.stepY << 1); pst = pInfo->VisualObject.cFrame.pY + pInfo->VisualObject.cFrame.stepY * (pInfo->VisualObject.VideoObject.height - 2) - 16; pdt = pst + (pInfo->VisualObject.cFrame.stepY << 1); for (i = 0; i < 8; i ++) { ippsCopy_8u(psb, pdb, pInfo->VisualObject.cFrame.stepY); pdb -= (pInfo->VisualObject.cFrame.stepY << 1); ippsCopy_8u(pst, pdt, pInfo->VisualObject.cFrame.stepY); pdt += (pInfo->VisualObject.cFrame.stepY << 1); } }*/}mp4_Status mp4_DecodeVideoObjectPlane(mp4_Info* pInfo){ mp4_Status status = MP4_STATUS_OK; Ipp64s vop_time; // set VOP time if (pInfo->VisualObject.VideoObject.short_video_header) { vop_time = pInfo->VisualObject.VideoObject.vop_sync_time + pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.temporal_reference * 1001; if (pInfo->VisualObject.cFrame.time > vop_time) { pInfo->VisualObject.VideoObject.vop_sync_time += 256 * 1001; vop_time += 256 * 1001; } } else { if (pInfo->VisualObject.VideoObject.VideoObjectPlane.coding_type == MP4_VOP_TYPE_B) { vop_time = pInfo->VisualObject.VideoObject.vop_sync_time_b + pInfo->VisualObject.VideoObject.VideoObjectPlane.modulo_time_base * pInfo->VisualObject.VideoObject.vop_time_increment_resolution + pInfo->VisualObject.VideoObject.VideoObjectPlane.time_increment; } else { if (pInfo->VisualObject.VideoObject.GroupOfVideoObjectPlane.time_code > pInfo->VisualObject.VideoObject.vop_sync_time) pInfo->VisualObject.VideoObject.vop_sync_time = pInfo->VisualObject.VideoObject.GroupOfVideoObjectPlane.time_code; vop_time = pInfo->VisualObject.VideoObject.vop_sync_time + pInfo->VisualObject.VideoObject.VideoObjectPlane.modulo_time_base * pInfo->VisualObject.VideoObject.vop_time_increment_resolution + pInfo->VisualObject.VideoObject.VideoObjectPlane.time_increment; if (pInfo->VisualObject.VideoObject.vop_sync_time_b < pInfo->VisualObject.VideoObject.vop_sync_time) pInfo->VisualObject.VideoObject.vop_sync_time_b = pInfo->VisualObject.VideoObject.vop_sync_time; if (pInfo->VisualObject.VideoObject.VideoObjectPlane.modulo_time_base != 0) { pInfo->VisualObject.VideoObject.vop_sync_time = vop_time - pInfo->VisualObject.VideoObject.VideoObjectPlane.time_increment; } } }// if (pInfo->VisualObject.VideoObject.VideoObjectPlane.coded || vop_time != pInfo->VisualObject.rFrame.time) { if (pInfo->VisualObject.VideoObject.VideoObjectPlane.coded || (vop_time != pInfo->VisualObject.cFrame.time && vop_time != pInfo->VisualObject.rFrame.time && vop_time != pInfo->VisualObject.nFrame.time)) { switch (pInfo->VisualObject.VideoObject.VideoObjectPlane.coding_type) { case MP4_VOP_TYPE_I : // set new video frame if (pInfo->VisualObject.VideoObject.VOPindex == 0) { pInfo->VisualObject.vFrame = NULL; pInfo->VisualObject.VideoObject.prevPlaneIsB = 0; } else { if (pInfo->VisualObject.VideoObject.prevPlaneIsB) { mp4_SWAP(mp4_Frame, pInfo->VisualObject.rFrame, pInfo->VisualObject.nFrame); pInfo->VisualObject.VideoObject.prevPlaneIsB = 0; } else { mp4_SWAP(mp4_Frame, pInfo->VisualObject.rFrame, pInfo->VisualObject.cFrame); } pInfo->VisualObject.vFrame = &pInfo->VisualObject.rFrame; } if (pInfo->VisualObject.VideoObject.sprite_enable == MP4_SPRITE_STATIC && pInfo->VisualObject.VideoObject.VOPindex == 0) { mp4_SWAP(mp4_Frame, pInfo->VisualObject.sFrame, pInfo->VisualObject.cFrame); } if (pInfo->VisualObject.VideoObject.VideoObjectPlane.coded) { if (pInfo->VisualObject.VideoObject.shape == MP4_SHAPE_TYPE_RECTANGULAR) {#ifdef _OMP_KARABAS if (!pInfo->VisualObject.VideoObject.data_partitioned && pInfo->num_threads >= 2) status = mp4_DecodeVOP_I_MT(pInfo); else#endif status = mp4_DecodeVOP_I(pInfo); } else status = mp4_DecodeVOP_I_Shape(pInfo); if (pInfo->VisualObject.VideoObject.sprite_enable == MP4_SPRITE_STATIC && pInfo->VisualObject.VideoObject.VOPindex == 0) { mp4_SWAP(mp4_Frame, pInfo->VisualObject.sFrame, pInfo->VisualObject.cFrame); mp4_ExpandFrameReplicate(pInfo->VisualObject.sFrame.apY, pInfo->VisualObject.VideoObject.sprite_width, pInfo->VisualObject.VideoObject.sprite_height, 16, pInfo->VisualObject.sFrame.stepY); mp4_ExpandFrameReplicate(pInfo->VisualObject.sFrame.apCb, pInfo->VisualObject.VideoObject.sprite_width >> 1, pInfo->VisualObject.VideoObject.sprite_height >> 1, 8, pInfo->VisualObject.sFrame.stepCb); mp4_ExpandFrameReplicate(pInfo->VisualObject.sFrame.apCr, pInfo->VisualObject.VideoObject.sprite_width >> 1, pInfo->VisualObject.VideoObject.sprite_height >> 1, 8, pInfo->VisualObject.sFrame.stepCr); } else { mp4_PadFrame(pInfo); } // set past and future time for B-VOP pInfo->VisualObject.VideoObject.rTime = pInfo->VisualObject.VideoObject.nTime; pInfo->VisualObject.VideoObject.nTime = vop_time; } mp4_StatisticInc(&pInfo->VisualObject.Statistic.nVOP_I); break; case MP4_VOP_TYPE_P : // set new video frame if (pInfo->VisualObject.VideoObject.prevPlaneIsB) { mp4_SWAP(mp4_Frame, pInfo->VisualObject.rFrame, pInfo->VisualObject.nFrame); pInfo->VisualObject.VideoObject.prevPlaneIsB = 0; } else { mp4_SWAP(mp4_Frame, pInfo->VisualObject.rFrame, pInfo->VisualObject.cFrame); } pInfo->VisualObject.vFrame = &pInfo->VisualObject.rFrame; if (pInfo->VisualObject.VideoObject.VideoObjectPlane.coded) {#ifdef _OMP_KARABAS if (!pInfo->VisualObject.VideoObject.data_partitioned && pInfo->num_threads >= 2) status = mp4_DecodeVOP_P_MT(pInfo); else#endif status = mp4_DecodeVOP_P(pInfo); mp4_PadFrame(pInfo); // set past and future time for B-VOP pInfo->VisualObject.VideoObject.rTime = pInfo->VisualObject.VideoObject.nTime; pInfo->VisualObject.VideoObject.nTime = vop_time; } mp4_StatisticInc(&pInfo->VisualObject.Statistic.nVOP_P); break; case MP4_VOP_TYPE_B : status = MP4_STATUS_OK; if (!pInfo->VisualObject.VideoObject.prevPlaneIsB) { mp4_SWAP(mp4_Frame, pInfo->VisualObject.nFrame, pInfo->VisualObject.cFrame); pInfo->VisualObject.VideoObject.prevPlaneIsB = 1; } // set Tframe for direct interlaced mode if (!pInfo->VisualObject.VideoObject.Tframe) { pInfo->VisualObject.VideoObject.Tframe = (int)(vop_time - pInfo->VisualObject.rFrame.time); } if (pInfo->VisualObject.VideoObject.VideoObjectPlane.coded) { pInfo->VisualObject.VideoObject.TRB = (int)(vop_time - pInfo->VisualObject.VideoObject.rTime); pInfo->VisualObject.VideoObject.TRD = (int)(pInfo->VisualObject.VideoObject.nTime - pInfo->VisualObject.VideoObject.rTime); // defense from bad streams when B-VOPs are before Past and/or Future if (pInfo->VisualObject.VideoObject.TRB <= 0) pInfo->VisualObject.VideoObject.TRB = 1; if (pInfo->VisualObject.VideoObject.TRD <= 0) pInfo->VisualObject.VideoObject.TRD = 2; if (pInfo->VisualObject.VideoObject.TRD <= pInfo->VisualObject.VideoObject.TRB) { pInfo->VisualObject.VideoObject.TRB = 1; pInfo->VisualObject.VideoObject.TRD = 2; }#ifdef _OMP_KARABAS if (pInfo->num_threads >= 2) status = mp4_DecodeVOP_B_MT(pInfo); else#endif status = mp4_DecodeVOP_B(pInfo); } pInfo->VisualObject.vFrame = &pInfo->VisualObject.cFrame; mp4_StatisticInc(&pInfo->VisualObject.Statistic.nVOP_B); break; case MP4_VOP_TYPE_S : // set new video frame if (pInfo->VisualObject.VideoObject.sprite_enable == MP4_SPRITE_GMC) { if (pInfo->VisualObject.VideoObject.prevPlaneIsB) { mp4_SWAP(mp4_Frame, pInfo->VisualObject.rFrame, pInfo->VisualObject.nFrame); pInfo->VisualObject.VideoObject.prevPlaneIsB = 0; } else { mp4_SWAP(mp4_Frame, pInfo->VisualObject.rFrame, pInfo->VisualObject.cFrame); } pInfo->VisualObject.vFrame = &pInfo->VisualObject.rFrame; } else pInfo->VisualObject.vFrame = &pInfo->VisualObject.cFrame; if (pInfo->VisualObject.VideoObject.VideoObjectPlane.coded) {#ifdef _OMP_KARABAS if (!pInfo->VisualObject.VideoObject.data_partitioned && pInfo->num_threads >= 2) status = mp4_DecodeVOP_S_MT(pInfo); else#endif status = mp4_DecodeVOP_S(pInfo); if (pInfo->VisualObject.VideoObject.sprite_enable == MP4_SPRITE_GMC) { mp4_PadFrame(pInfo); // set past and future time for B-VOP pInfo->VisualObject.VideoObject.rTime = pInfo->VisualObject.VideoObject.nTime; pInfo->VisualObject.VideoObject.nTime = vop_time; } } mp4_StatisticInc(&pInfo->VisualObject.Statistic.nVOP_S); break; } if (!pInfo->VisualObject.VideoObject.VideoObjectPlane.coded) { ippsCopy_8u(pInfo->VisualObject.rFrame.apY, pInfo->VisualObject.cFrame.apY, pInfo->VisualObject.cFrame.stepY * ((pInfo->VisualObject.VideoObject.MacroBlockPerCol + 2) << 4)); ippsCopy_8u(pInfo->VisualObject.rFrame.apCb, pInfo->VisualObject.cFrame.apCb, pInfo->VisualObject.cFrame.stepCb * ((pInfo->VisualObject.VideoObject.MacroBlockPerCol + 2) << 3)); ippsCopy_8u(pInfo->VisualObject.rFrame.apCr, pInfo->VisualObject.cFrame.apCr, pInfo->VisualObject.cFrame.stepCr * ((pInfo->VisualObject.VideoObject.MacroBlockPerCol + 2) << 3)); } mp4_StatisticInc(&pInfo->VisualObject.Statistic.nVOP); } // save current VOP type pInfo->VisualObject.cFrame.type = pInfo->VisualObject.VideoObject.VideoObjectPlane.coding_type; // save current VOP time pInfo->VisualObject.cFrame.time = vop_time; return status;}/*// Intra DC and AC reconstruction for SVH macroblock*/mp4_Status mp4_DecodeIntraMB_SVH(mp4_Info *pInfo, int pat, int quant, Ipp8u *pR[], int stepR[]){ __ALIGN16(Ipp16s, coeff, 64); int blockNum, pm = 32, lnz;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -