📄 slice.c
字号:
decoder->b_motion.ref[1][0] = backward_fbuf[0] + offset; decoder->b_motion.ref[1][1] = backward_fbuf[1] + (offset >> 1); decoder->b_motion.ref[1][2] = backward_fbuf[2] + (offset >> 1); stride <<= 1; height >>= 1; } decoder->stride = stride; decoder->uv_stride = stride >> 1; decoder->slice_stride = 16 * stride; decoder->slice_uv_stride = decoder->slice_stride >> (2 - decoder->chroma_format); decoder->limit_x = 2 * decoder->width - 32; decoder->limit_y_16 = 2 * height - 32; decoder->limit_y_8 = 2 * height - 16; decoder->limit_y = height - 16; if (decoder->mpeg1) { decoder->motion_parser[0] = motion_zero_420; decoder->motion_parser[MC_FRAME] = motion_mp1; decoder->motion_parser[4] = motion_reuse_420; } else if (decoder->picture_structure == FRAME_PICTURE) { if (decoder->chroma_format == 0) { decoder->motion_parser[0] = motion_zero_420; decoder->motion_parser[MC_FIELD] = motion_fr_field_420; decoder->motion_parser[MC_FRAME] = motion_fr_frame_420; decoder->motion_parser[MC_DMV] = motion_fr_dmv_420; decoder->motion_parser[4] = motion_reuse_420; } else if (decoder->chroma_format == 1) { decoder->motion_parser[0] = motion_zero_422; decoder->motion_parser[MC_FIELD] = motion_fr_field_422; decoder->motion_parser[MC_FRAME] = motion_fr_frame_422; decoder->motion_parser[MC_DMV] = motion_fr_dmv_422; decoder->motion_parser[4] = motion_reuse_422; } else { decoder->motion_parser[0] = motion_zero_444; decoder->motion_parser[MC_FIELD] = motion_fr_field_444; decoder->motion_parser[MC_FRAME] = motion_fr_frame_444; decoder->motion_parser[MC_DMV] = motion_fr_dmv_444; decoder->motion_parser[4] = motion_reuse_444; } } else { if (decoder->chroma_format == 0) { decoder->motion_parser[0] = motion_zero_420; decoder->motion_parser[MC_FIELD] = motion_fi_field_420; decoder->motion_parser[MC_16X8] = motion_fi_16x8_420; decoder->motion_parser[MC_DMV] = motion_fi_dmv_420; decoder->motion_parser[4] = motion_reuse_420; } else if (decoder->chroma_format == 1) { decoder->motion_parser[0] = motion_zero_422; decoder->motion_parser[MC_FIELD] = motion_fi_field_422; decoder->motion_parser[MC_16X8] = motion_fi_16x8_422; decoder->motion_parser[MC_DMV] = motion_fi_dmv_422; decoder->motion_parser[4] = motion_reuse_422; } else { decoder->motion_parser[0] = motion_zero_444; decoder->motion_parser[MC_FIELD] = motion_fi_field_444; decoder->motion_parser[MC_16X8] = motion_fi_16x8_444; decoder->motion_parser[MC_DMV] = motion_fi_dmv_444; decoder->motion_parser[4] = motion_reuse_444; } } // $PP // initialize frame parameters (e.g ref pointers) for MAE // this is done on a per frame/field basis /* if (decoder->bUseMAE && bottom_field) { initialize_mcomp_ref_pointers (decoder, bottom_field); // PPKK - called for the bottom field here }*/}#endif //#ifdef NEW_MAE_DRIVERSTATIC_INLINE int slice_init (mpeg2_decoder_t * const decoder, int code){#define bit_buf (decoder->bitstream_buf)#define bits (decoder->bitstream_bits)#define bit_ptr (decoder->bitstream_ptr) int offset; const MBAtab * mba; // $PP if (decoder->bUseMAE) decoder->dc_dct_pred[0] = decoder->dc_dct_pred[1] = decoder->dc_dct_pred[2] = decoder->intra_dc_pred_reset_value; else decoder->dc_dct_pred[0] = decoder->dc_dct_pred[1] = decoder->dc_dct_pred[2] = 16384; 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 (decoder->vertical_position_extension) { code += UBITS (bit_buf, 3) << 7; DUMPBITS (bit_buf, bits, 3); } decoder->v_offset = (code - 1) * 16;#ifndef NEW_MAE_DRIVER offset = 0; if (!(decoder->convert) || decoder->coding_type != B_TYPE) offset = (code - 1) * decoder->slice_stride; decoder->dest[0] = decoder->picture_dest[0] + offset; offset >>= (2 - decoder->chroma_format); decoder->dest[1] = decoder->picture_dest[1] + offset; decoder->dest[2] = decoder->picture_dest[2] + offset;#endif // #ifndef NEW_MAE_DRIVER get_quantizer_scale (decoder); /* ignore intra_slice and all the extra data */ while (bit_buf & 0x80000000) { DUMPBITS (bit_buf, bits, 9); NEEDBITS (bit_buf, bits, bit_ptr); } /* decode initial macroblock address increment */ offset = 0; while (1) { if (bit_buf >= 0x08000000) { mba = MBA_5 + (UBITS (bit_buf, 6) - 2); break; } else if (bit_buf >= 0x01800000) { mba = MBA_11 + (UBITS (bit_buf, 12) - 24); break; } else switch (UBITS (bit_buf, 12)) { case 8: /* macroblock_escape */ offset += 33; DUMPBITS (bit_buf, bits, 11); NEEDBITS (bit_buf, bits, bit_ptr); continue; case 15: /* macroblock_stuffing (MPEG1 only) */ bit_buf &= 0xfffff; DUMPBITS (bit_buf, bits, 11); NEEDBITS (bit_buf, bits, bit_ptr); continue; default: /* error */ return 1; } } DUMPBITS (bit_buf, bits, mba->len + 1); decoder->offset = (offset + mba->mba) << 4; while (decoder->offset - decoder->width >= 0) { decoder->offset -= decoder->width;#ifndef NEW_MAE_DRIVER if (!(decoder->convert) || decoder->coding_type != B_TYPE) { decoder->dest[0] += decoder->slice_stride; decoder->dest[1] += decoder->slice_uv_stride; decoder->dest[2] += decoder->slice_uv_stride; }#endif // #ifndef NEW_MAE_DRIVER decoder->v_offset += 16; } if (decoder->v_offset > decoder->limit_y) return 1; return 0;#undef bit_buf#undef bits#undef bit_ptr}static uint32 CallWrapperIntra(mpeg2_decoder_t * const decoder, wrap_context *pContext, uint32 xCodedBlockParam, uint32 macroblock_modes){ uint32 *pWrapMB; uint32 uiNumWMs = 0; uint32 nMemBlockSize; static header_words const *pHeader = &local_header; _header_word0 *pHeaderWord0; _header_word1 *pHeaderWord1; _header_word2 *pHeaderWord2; _header_word3 *pHeaderWord3;#ifndef MAE_HW wrap_extra_info *pWrapExtraInfo;#endif // Get a pointer to the header words //pHeader = &local_header; pWrapMB = pContext->pMB;#ifndef MAE_HW pWrapExtraInfo = (wrap_extra_info*)pContext->pWrapExtraInfo;#endif // Header word 0 pHeaderWord0 = &pHeader->header_word0; pHeaderWord0->bblk = MAE_BIG_BLOCK_ON; pHeaderWord0->iqmul2 = (decoder->mpeg1 == 1 ? 1 : decoder->iQuant_Scale); pHeaderWord0->wtchgmsk = 0; pHeaderWord0->iqadd1 = 0; pHeaderWord0->dcluma = pHeaderWord0->dcchroma = decoder->intra_dc_mult; // Header word 1 pHeaderWord1 = &pHeader->header_word1; pHeaderWord1->cbp = xCodedBlockParam; pHeaderWord1->iqdiv3 = (decoder->mpeg1 == 1 ? 0 : 4); pHeaderWord1->iqadd2 = 0; // Header word 2 pHeaderWord2 = &pHeader->header_word2; pHeaderWord2->mbmode = MBMODE_INTRA_ALL; pHeaderWord2->xformsize = XFORMSIZE_8_8; // Header word 3 pHeaderWord3 = &pHeader->header_word3; pHeaderWord3->rnd = 0; if (decoder->picture_structure == FRAME_PICTURE) pHeaderWord3->ps = MAE_FRAME_PICTURE; else pHeaderWord3->ps = MAE_FIELD_PICTURE; if (macroblock_modes & DCT_TYPE_INTERLACED) pHeaderWord3->dctt = MAE_DCT_TYPE_FIELD; else pHeaderWord3->dctt = MAE_DCT_TYPE_FRAME;#ifdef MAE_HW // Hack for MAE hardware issue // For an intra macroblock that has field picture, frame type DCTT, // set fp to 1. This forces the correct stride if((pHeaderWord3->ps == MAE_FIELD_PICTURE) && (pHeaderWord3->dctt == MAE_DCT_TYPE_FRAME)) { //printf("Into MAE hack!!!\n"); pHeaderWord3->fp = 1; } else if((pHeaderWord3->ps == MAE_FIELD_PICTURE) && (pHeaderWord3->dctt == MAE_DCT_TYPE_FIELD)) { //printf("Field picture and Field DCT!!!\n"); pHeaderWord3->fp = 1; } else { pHeaderWord3->fp = 0; }#else pHeaderWord3->fp = 0;#endif // original code //pHeaderWord3->fp = pHeaderWord3->ft = pHeaderWord3->fb = pHeaderWord3->bt = pHeaderWord3->bb = 0; pHeaderWord3->mbtype = MBT_16x16; pHeaderWord3->mcprecy = pHeaderWord3->mcprecuv = MAE_HALF_PEL_BILINEAR; pHeaderWord3->xpos = decoder->offset >> 3; pHeaderWord3->ypos = decoder->v_offset >> 3 ; //pHeaderWord3->ypos = (decoder->picture_structure == FRAME_PICTURE) ? (decoder->v_offset >> 3) : (decoder->v_offset >> 4) ; // PPKK - Chris if (decoder->mpeg1) { /* If it is mpeg1, we do the IQUANT in s/w hence we have to send down a WM of all 1's Send it only once */ // NOTE: sending WM once does not seem to work, maybe bcos of CMODEL // so, sending WM each time if(decoder->bIntraMatrixChanged) { pHeaderWord0->wtchgmsk = WM_INTRA_Y | WM_INTRA_C; // Luma //memset (pContext->pWM, 1, WM_DATA_SIZE); // KK memset (pContext->pWM, 1, (2*WM_DATA_SIZE)); // Chroma //memset (pContext->pWM + (WM_DATA_SIZE/sizeof(uint32)), 1, WM_DATA_SIZE); // KK uiNumWMs = 2; decoder->bIntraMatrixChanged = 0; } } else { if (decoder->bIntraMatrixChanged) { pHeaderWord0->wtchgmsk = WM_INTRA_Y | WM_INTRA_C; // Luma#ifdef UNDER_CE memcpy ((uint8_t *)pContext->pWM, (char *) (decoder->MAE_Quant_Matrix[0]), WM_DATA_SIZE);#else //!UNDER_CE SWIZ_64B_8A(decoder->MAE_Quant_Matrix[0], pContext->pWM);#endif //UNDER_CE // Chroma #ifdef UNDER_CE memcpy ((uint8_t *) (pContext->pWM + (WM_DATA_SIZE/sizeof(uint32))),(char *) (decoder->MAE_Quant_Matrix[2]), WM_DATA_SIZE); #else //!UNDER_CE SWIZ_64B_8A(decoder->MAE_Quant_Matrix[2], pContext->pWM + (WM_DATA_SIZE/sizeof(uint32)));#endif //UNDER_CE decoder->bIntraMatrixChanged = 0; uiNumWMs = 2; } } // Compute the actual size of the data block. This needs to be included in the descriptor. nMemBlockSize = sizeof(header_words) + uiNumWMs*WM_DATA_SIZE + 6*BLOCK_SQUARE_SIZE*sizeof(int16); // Finally set the valid bit //pContext->desc_ptr->Valid = 1; // ***************************************************************** // This is now being filled into the registers and sent down to the driver (look at initialize_mcomp_ref_pointers() - slice.c)// printf("CallWrapperIntra: current_y_buf 0x%x \n",decoder->pict_dest[0]);#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; pWrapExtraInfo->nFrameType = IFRAME;#endif //pContext->desc_ptr->ByteCount += nMemBlockSize; pContext->desc_size += nMemBlockSize; COPY_16B(&local_header, pContext->pHeader); WrapGetNextContext (nMemBlockSize, pContext); return nMemBlockSize;}static uint32 CallWrapperInter(mpeg2_decoder_t * const decoder, wrap_context *pContext, uint32 xCodedBlockParam, uint32 macroblock_modes, uint32 nNumMVs){ uint32 *pWrapMB; uint32 uiNumWMs = 0; uint32 nBlocksCoded = 0, i; static header_words const *pHeader = &local_header; _header_word0 *pHeaderWord0; _header_word1 *pHeaderWord1; _header_word2 *pHeaderWord2; _header_word3 *pHeaderWord3; uint32 nMemBlockSize;#ifndef MAE_HW wrap_extra_info* pWrapExtraInfo;#endif // Get a pointer to the header words //pHeader = &local_header; pWrapMB = pContext->pMB;#ifndef MAE_HW pWrapExtraInfo = (wrap_extra_info*)pContext->pWrapExtraInfo;#endif // Header word 0 pHeaderWord0 = &pHeader->header_word0; pHeaderWord0->bblk = MAE_BIG_BLOCK_ON; pHeaderWord0->iqmul2 = (decoder->mpeg1 == 1 ? 1 : decoder->iQuant_Scale); pHeaderWord0->wtchgmsk = 0; pHeaderWord0->iqadd1 = 0; pHeaderWord0->dcluma = pHeaderWord0->dcchroma = decoder->intra_dc_mult; // Header word 1 pHeaderWord1 = &pHeader->header_word1; pHeaderWord1->cbp = xCodedBlockParam; pHeaderWord1->iqdiv3 = (decoder->mpeg1 == 1 ? 0 : 5); pHeaderWord1->iqadd2 = 0; // Header word 2 pHeaderWord2 = &pHeader->header_word2; pHeaderWord2->xformsize = XFORMSIZE_8_8; // Header word 3 pHeaderWord3 = &pHeader->header_word3; pHeaderWord3->rnd = 0; if (decoder->picture_structure == FRAME_PICTURE) pHeaderWord3->ps = MAE_FRAME_PICTURE; else pHeaderWord3->ps = MAE_FIELD_PICTURE; if (macroblock_modes & DCT_TYPE_INTERLACED) pHeaderWord3->dctt = MAE_DCT_TYPE_FIELD; else pHeaderWord3->dctt = MAE_DCT_TYPE_FRAME; pHeaderWord3->mcprecy = pHeaderWord3->mcprecuv = MAE_HALF_PEL_BILINEAR; pHeaderWord3->xpos = decoder->offset >> 3; pHeaderWord3->ypos = decoder->v_offset >> 3; if (decoder->mpeg1) { /* If it is mpeg1, we do the IQUANT in s/w hence we have to send down a WM of all 1's Send it only once */ // NOTE: sending WM once does not seem to work, maybe bcos of CMODEL // so, sending WM each time if(decoder->bInterMatrixChanged) { pHeaderWord0->wtchgmsk = WM_INTER_Y | WM_INTER_C; // Luma //memset (pContext->pWM, 1, WM_DATA_SIZE); memset (pContext->pWM, 1, (2*WM_DATA_SIZE)); // Chroma
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -