📄 slice.c
字号:
//memset (pContext->pWM + (WM_DATA_SIZE/sizeof(uint32)), 1, WM_DATA_SIZE); uiNumWMs = 2; decoder->bInterMatrixChanged = 0; } } else { if (decoder->bInterMatrixChanged) { pHeaderWord0->wtchgmsk = WM_INTER_Y | WM_INTER_C; // Copy weighting matrix // Luma#ifdef UNDER_CE memcpy ((uint8_t *)pContext->pWM, (char *) (decoder->MAE_Quant_Matrix[1]), WM_DATA_SIZE);#else //!UNDER_CE SWIZ_64B_8A (decoder->MAE_Quant_Matrix[1], pContext->pWM);#endif //UNDER_CE // Chroma #ifdef UNDER_CE memcpy ((uint8_t *) (pContext->pWM + (WM_DATA_SIZE/sizeof(uint32))), (char *) (decoder->MAE_Quant_Matrix[3]), WM_DATA_SIZE); #else //!UNDER_CE SWIZ_64B_8A(decoder->MAE_Quant_Matrix[3], pContext->pWM + (WM_DATA_SIZE/sizeof(uint32)));#endif //UNDER_CE decoder->bInterMatrixChanged = 0; uiNumWMs = 2; } } for (i=0; i<8; i++) nBlocksCoded += ((xCodedBlockParam >> i) & 0x1); // Compute the actual size of the data block. This needs to be included in the descriptor. nMemBlockSize = sizeof(header_words) + uiNumWMs*WM_DATA_SIZE + nNumMVs*sizeof(uint32) + nBlocksCoded*BLOCK_SQUARE_SIZE*sizeof(int16); // Finally set the valid bit //pContext->desc_ptr->Valid = 1;#ifndef DRV_ENABLED pWrapExtraInfo->cur_y_frame = decoder->pict_dest[0]; pWrapExtraInfo->cur_cb_frame = decoder->pict_dest[1]; pWrapExtraInfo->cur_cr_frame = decoder->pict_dest[2];#else if(decoder->bUseMAE) { // Nothing to do } else {#ifndef MAE_HW pWrapExtraInfo->cur_y_frame = decoder->pict_dest[0]; pWrapExtraInfo->cur_cb_frame = decoder->pict_dest[1]; pWrapExtraInfo->cur_cr_frame = decoder->pict_dest[2];#endif }#endif#ifndef MAE_HW pWrapExtraInfo->dmv = 0; pWrapExtraInfo->iFrameNum = decoder->iFrameCount; pWrapExtraInfo->nMB = decoder->iMBCount; pWrapExtraInfo->nForceSend = SEND_BATCH; switch (decoder->coding_type) { case P_TYPE: pWrapExtraInfo->nFrameType = PFRAME; break; case B_TYPE: pWrapExtraInfo->nFrameType = BFRAME; break; }#endif //pContext->desc_ptr->ByteCount += nMemBlockSize; pContext->desc_size += nMemBlockSize; COPY_16B(&local_header, pContext->pHeader); WrapGetNextContext (nMemBlockSize, pContext); return nMemBlockSize;}#define DUMP_FINAL_OUTPUT \if ( (decoder->bDumpFinal || decoder->bDumpFiles) \ && (!decoder->bUseMAE) ) \{ \ \ Write_Final_Output (decoder, \ decoder->offset, \ decoder->v_offset, \ decoder->iMBCount, \ &decoder->dest[0]); \} \void mpeg2_slice_no_dump (mpeg2_decoder_t * const decoder, const int code, const uint8_t * const buffer, void *pContext){#define bit_buf (decoder->bitstream_buf)#define bits (decoder->bitstream_bits)#define bit_ptr (decoder->bitstream_ptr) // $PP wrap_context *pWrapContext = NULL; mae_desc *pMAEDesc = NULL; uint32 nBytesUsed; uint32 nNumMVs = 0; short int *pBlockPointer = NULL; unsigned short *pBlockData; unsigned char xCodedBlockParam = 0; unsigned char bLocal = 0; int DCT_offset, DCT_stride; bitstream_init (decoder, buffer); if (slice_init (decoder, code)) return; if (decoder->bUseMAE && !pWrapContext) { pWrapContext = (wrap_context*)pContext; nBytesUsed = 0; } if (!pWrapContext) return; while (1) { int macroblock_modes; int mba_inc; const MBAtab * mba; NEEDBITS (bit_buf, bits, bit_ptr); macroblock_modes = get_macroblock_modes (decoder); /* maybe integrate MACROBLOCK_QUANT test into get_macroblock_modes ? */ if (macroblock_modes & MACROBLOCK_QUANT) get_quantizer_scale (decoder); if (macroblock_modes & MACROBLOCK_INTRA) { int iLumaStride, iLumaOffset; int iChromaStride, iChromaOffset; int offset; uint8_t * dest_y; if (decoder->concealment_motion_vectors) { if (decoder->picture_structure == FRAME_PICTURE) motion_fr_conceal (decoder); else motion_fi_conceal (decoder); } else { decoder->f_motion.pmv[0][0] = decoder->f_motion.pmv[0][1] = 0; decoder->f_motion.pmv[1][0] = decoder->f_motion.pmv[1][1] = 0; decoder->b_motion.pmv[0][0] = decoder->b_motion.pmv[0][1] = 0; decoder->b_motion.pmv[1][0] = decoder->b_motion.pmv[1][1] = 0; } if (macroblock_modes & DCT_TYPE_INTERLACED) { DCT_offset = decoder->stride; DCT_stride = decoder->stride * 2; } else { DCT_offset = decoder->stride * 8; DCT_stride = decoder->stride; } offset = decoder->offset; dest_y = decoder->dest[0] + offset; iLumaStride = DCT_stride; iLumaOffset = DCT_offset; // $PP if (decoder->bUseMAE) { pWrapContext->pDataBlock = (int16 *)WRAPSKIPMVS(pWrapContext->pMB, (decoder->bIntraMatrixChanged ? 2 : 0), 0); }#ifdef NO_PERF if (pWrapContext == NULL) { // note that 5th param has been added to function slice_intra_DCT (decoder, 0, dest_y, DCT_stride, NULL, Y1_LUMA_BLOCK); slice_intra_DCT (decoder, 0, dest_y + 8, DCT_stride, NULL, Y2_LUMA_BLOCK); slice_intra_DCT (decoder, 0, dest_y + DCT_offset, DCT_stride, NULL, Y3_LUMA_BLOCK); slice_intra_DCT (decoder, 0, dest_y + DCT_offset + 8, DCT_stride, NULL, Y4_LUMA_BLOCK); } else#endif { // note that 5th param has been added to function slice_intra_DCT (decoder, 0, dest_y, DCT_stride, pWrapContext->pDataBlock, Y1_LUMA_BLOCK); slice_intra_DCT (decoder, 0, dest_y + 8, DCT_stride, pWrapContext->pDataBlock + 64, Y2_LUMA_BLOCK); slice_intra_DCT (decoder, 0, dest_y + DCT_offset, DCT_stride, pWrapContext->pDataBlock + 128, Y3_LUMA_BLOCK); slice_intra_DCT (decoder, 0, dest_y + DCT_offset + 8, DCT_stride, pWrapContext->pDataBlock + 192, Y4_LUMA_BLOCK); } if (likely (decoder->chroma_format == 0)) { iChromaStride = decoder->uv_stride; iChromaOffset = offset; // coded block param xCodedBlockParam = ALL_CODED_420;#ifdef NO_PERF if (pWrapContext == NULL) { slice_intra_DCT (decoder, 1, decoder->dest[1] + (offset >> 1), decoder->uv_stride, NULL, U_CHROMA_BLOCK); //dest_u_ptr = decoder->dest[1] + (offset >> 1); slice_intra_DCT (decoder, 2, decoder->dest[2] + (offset >> 1), decoder->uv_stride, NULL, V_CHROMA_BLOCK); //dest_v_ptr = decoder->dest[2] + (offset >> 1); } else#endif //#ifdef NO_PERF { slice_intra_DCT (decoder, 1, decoder->dest[1] + (offset >> 1), decoder->uv_stride, pWrapContext->pDataBlock + 256, U_CHROMA_BLOCK); slice_intra_DCT (decoder, 2, decoder->dest[2] + (offset >> 1), decoder->uv_stride, pWrapContext->pDataBlock + 320, V_CHROMA_BLOCK); } if (decoder->coding_type == D_TYPE) { NEEDBITS (bit_buf, bits, bit_ptr); DUMPBITS (bit_buf, bits, 1); } }#if CHROMA_FORMAT_UNSUPPORTED else if (likely (decoder->chroma_format == 1)) { uint8_t * dest_u = decoder->dest[1] + (offset >> 1); uint8_t * dest_v = decoder->dest[2] + (offset >> 1); dest_u_ptr = dest_u; dest_v_ptr = dest_v; DCT_stride >>= 1; DCT_offset >>= 1; iChromaStride = DCT_stride; iChromaOffset = DCT_offset; // coded block param xCodedBlockParam = ALL_CODED_422; slice_intra_DCT (decoder, 1, dest_u, DCT_stride, NULL, U_CHROMA_BLOCK); slice_intra_DCT (decoder, 2, dest_v, DCT_stride, NULL, V_CHROMA_BLOCK); slice_intra_DCT (decoder, 1, dest_u + DCT_offset, DCT_stride, NULL, U2_CHROMA_BLOCK); slice_intra_DCT (decoder, 2, dest_v + DCT_offset, DCT_stride, NULL, V2_CHROMA_BLOCK); } else { uint8_t * dest_u = decoder->dest[1] + offset; uint8_t * dest_v = decoder->dest[2] + offset; dest_u_ptr = dest_u; dest_v_ptr = dest_v; slice_intra_DCT (decoder, 1, dest_u, DCT_stride, NULL, U_CHROMA_BLOCK); slice_intra_DCT (decoder, 2, dest_v, DCT_stride, NULL, V_CHROMA_BLOCK); slice_intra_DCT (decoder, 1, dest_u + DCT_offset, DCT_stride, NULL, U2_CHROMA_BLOCK); slice_intra_DCT (decoder, 2, dest_v + DCT_offset, DCT_stride, NULL, V2_CHROMA_BLOCK); slice_intra_DCT (decoder, 1, dest_u + 8, DCT_stride, NULL, U3_CHROMA_BLOCK); slice_intra_DCT (decoder, 2, dest_v + 8, DCT_stride, NULL, V3_CHROMA_BLOCK); slice_intra_DCT (decoder, 1, dest_u + DCT_offset + 8, DCT_stride, NULL, U4_CHROMA_BLOCK); slice_intra_DCT (decoder, 2, dest_v + DCT_offset + 8, DCT_stride, NULL, V4_CHROMA_BLOCK); }#endif //#if CHROMA_FORMAT_UNSUPPORTED // In the C Model case we should be doing IQUANT and IDCT here if (decoder->bUseMAE) { // Call the wrapper nBytesUsed = CallWrapperIntra (decoder, pWrapContext, xCodedBlockParam, macroblock_modes); } } else { int iLumaStride; int iChromaStride; motion_parser_t * parser; int offset; uint32 nSkipBytes = 0; // clear coded block parameter xCodedBlockParam = 0; // clear field select decoder->fwd_top_motion_vertical_field_select = decoder->bwd_top_motion_vertical_field_select = decoder->fwd_bot_motion_vertical_field_select = decoder->bwd_bot_motion_vertical_field_select = 0; parser = decoder->motion_parser[macroblock_modes >> MOTION_TYPE_SHIFT]; decoder->iMacroBlockModes = macroblock_modes; if ( macroblock_modes & MACROBLOCK_MOTION_FORWARD ) { // $PP decoder->iRefType = FORWARD_REFERENCES; parser (decoder, &(decoder->f_motion), mpeg2_mc.put); } if ( macroblock_modes & MACROBLOCK_MOTION_BACKWARD ) { decoder->iRefType = BACKWARD_REFERENCES; parser (decoder, &(decoder->b_motion), (macroblock_modes & MACROBLOCK_MOTION_FORWARD ? mpeg2_mc.avg : mpeg2_mc.put)); } if (decoder->bUseMAE) { if ( (macroblock_modes >> MOTION_TYPE_SHIFT) == MC_DMV) { // DMV is a special case nNumMVs = initialize_mcomp_motion_vectors_dmv (pWrapContext, decoder, macroblock_modes);#ifdef NEW_MAE_DRIVER nDMVUpdate1 = nDMVUpdate = 1;#else initialize_mcomp_ref_pointers_dmv (decoder, 0); // 0 for now, later check if this is a field picture#endif //printf("DUAL PRIME\n"); } else { // call local func to gather parameters for motion comp nNumMVs = initialize_mcomp_motion_vectors (pWrapContext, decoder, macroblock_modes); } pWrapContext->pWM = (int16 *)WRAPSKIPMVS (pWrapContext->pMB, 0, nNumMVs); pWrapContext->pDataBlock = (int16 *)WRAPSKIPMVS (pWrapContext->pMB, (decoder->bInterMatrixChanged ? 2 : 0), nNumMVs); } if (macroblock_modes & MACROBLOCK_PATTERN) { int coded_block_pattern; if (macroblock_modes & DCT_TYPE_INTERLACED) { DCT_offset = decoder->stride; DCT_stride = decoder->stride * 2; } else { DCT_offset = decoder->stride * 8; DCT_stride = decoder->stride; } coded_block_pattern = get_coded_block_pattern (decoder); if (likely (decoder->chroma_format == 0)) { uint8_t * dest_y; offset = decoder->offset; dest_y = decoder->dest[0] + offset; iLumaStride = DCT_stride; iChromaStride = decoder->uv_stride;#ifdef NO_PERF if (pWrapContext == NULL) { if (coded_block_pattern & 1) { xCodedBlockParam |= Y0_CODED; slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride, NULL, Y1_LUMA_BLOCK); } if (coded_block_pattern & 2) { xCodedBlockParam |= Y1_CODED; slice_non_intra_DCT (decoder, 0, dest_y + 8, DCT_stride, NULL, Y2_LUMA_BLOCK); } if (coded_block_pattern & 4) { xCodedBlockParam |= Y2_CODED; slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset, DCT_stride, NULL, Y3_LUMA_BLOCK); } if (coded_block_pattern & 8) { xCodedBlockParam |= Y3_CODED; slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset + 8, DCT_stride, NULL, Y4_LUMA_BLOCK); } if (coded_block_pattern & 16) { xCodedBlockParam |= CB0_CODED; //dest_u_ptr = decoder->dest[1] + (offset >> 1); slice_non_intra_DCT (decoder, 1, decoder->dest[1] + (offset >> 1), decoder->uv_stride, NULL, U_CHROMA_BLOCK); } if (coded_block_pattern & 32) { xCodedBlockParam |= CR0_CODED; //dest_v_ptr = decoder->dest[2] + (offset >> 1); slice_non_intra_DCT (decoder, 2, decoder->dest[2] + (offset >> 1), decoder->uv_stride, NULL, V_CHROMA_BLOCK); } } else#endif //#ifdef NO_PERF { pBlockData = pWrapContext->pDataBlock; if (coded_block_pattern & 1) { xCodedBlockParam |= Y0_CODED; slice_non_intra_DCT (decoder, 0, dest_y, DCT_stride, pBlockData, Y1_LUMA_BLOCK); nSkipBytes += 64; } if (coded_block_pattern & 2) { xCodedBlockParam |= Y1_CODED; slice_non_intra_DCT (decoder, 0, dest_y + 8, DCT_stride, pBlockData + nSkipBytes, Y2_LUMA_BLOCK); nSkipBytes += 64; } if (coded_block_pattern & 4) { xCodedBlockParam |= Y2_CODED; slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset, DCT_stride, pBlockData + nSkipBytes, Y3_LUMA_BLOCK); nSkipBytes += 64; } if (coded_block_pattern & 8) { xCodedBlockParam |= Y3_CODED; slice_non_intra_DCT (decoder, 0, dest_y + DCT_offset + 8, DCT_stride, pBlockData + nSkipBytes, Y4_LUMA_BLOCK); nSkipBytes += 64; } if (coded_block_pattern & 16) { xCodedBlockParam |= CB0_CODED; slice_non_intra_DCT (decoder, 1, decoder->dest[1] + (offset >> 1), decoder->uv_stride, pBlockData + nSkipBytes, U_CHROMA_BLOCK); nSkipBytes += 64; } if (coded_block_pattern & 32) { xCodedBlockParam |= CR0_CODED; slice_non_intra_DCT (decoder, 2, decoder->dest[2] + (off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -