Showing the changes to codec/decoder/core/src/au_parser.cpp (1 of 29 files). Show all
Unified · Split
| @@ -246,9 +246,9 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 245 unmodified lines | |||
| 246 | pBs = &pCtx->sBs; | 246 | pBs = &pCtx->sBs; |
| 247 | iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit | 247 | iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit |
| 248 | 248 | ||
| 249 | iErr = InitBits (pBs, pNal, iBitSize); | 249 | iErr = DecInitBits (pBs, pNal, iBitSize); |
| 250 | if (iErr) { | 250 | if (iErr) { |
| 251 | WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_PREFIX: InitBits() fail due invalid access."); | 251 | WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_PREFIX: DecInitBits() fail due invalid access."); |
| 252 | pCtx->iErrorCode |= dsBitstreamError; | 252 | pCtx->iErrorCode |= dsBitstreamError; |
| 253 | return NULL; | 253 | return NULL; |
| 254 | } | 254 | } |
| @@ -375,7 +375,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 120 unmodified lines | |||
| 375 | 375 | ||
| 376 | pBs = &pCurAu->pNalUnitsList[uiAvailNalNum - 1]->sNalData.sVclNal.sSliceBitsRead; | 376 | pBs = &pCurAu->pNalUnitsList[uiAvailNalNum - 1]->sNalData.sVclNal.sSliceBitsRead; |
| 377 | iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit | 377 | iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit |
| 378 | iErr = InitBits (pBs, pNal, iBitSize); | 378 | iErr = DecInitBits (pBs, pNal, iBitSize); |
| 379 | if (iErr) { | 379 | if (iErr) { |
| 380 | ForceClearCurrentNal (pCurAu); | 380 | ForceClearCurrentNal (pCurAu); |
| 381 | if (uiAvailNalNum > 1) { | 381 | if (uiAvailNalNum > 1) { |
| @@ -384,7 +384,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 2 unmodified lines | |||
| 384 | pCtx->bAuReadyFlag = true; | 384 | pCtx->bAuReadyFlag = true; |
| 385 | } | 385 | } |
| 386 | } | 386 | } |
| 387 | WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_CODED_SLICE: InitBits() fail due invalid access."); | 387 | WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_CODED_SLICE: DecInitBits() fail due invalid access."); |
| 388 | pCtx->iErrorCode |= dsBitstreamError; | 388 | pCtx->iErrorCode |= dsBitstreamError; |
| 389 | return NULL; | 389 | return NULL; |
| 390 | } | 390 | } |
| @@ -592,7 +592,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t · 201 unmodified lines | |||
| 592 | case NAL_UNIT_SPS: | 592 | case NAL_UNIT_SPS: |
| 593 | case NAL_UNIT_SUBSET_SPS: | 593 | case NAL_UNIT_SUBSET_SPS: |
| 594 | if (iBitSize > 0) { | 594 | if (iBitSize > 0) { |
| 595 | iErr = InitBits (pBs, pRbsp, iBitSize); | 595 | iErr = DecInitBits (pBs, pRbsp, iBitSize); |
| 596 | if (ERR_NONE != iErr) { | 596 | if (ERR_NONE != iErr) { |
| 597 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) | 597 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) |
| 598 | pCtx->iErrorCode |= dsNoParamSets; | 598 | pCtx->iErrorCode |= dsNoParamSets; |
| @@ -614,7 +614,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t · 15 unmodified lines | |||
| 614 | 614 | ||
| 615 | case NAL_UNIT_PPS: | 615 | case NAL_UNIT_PPS: |
| 616 | if (iBitSize > 0) { | 616 | if (iBitSize > 0) { |
| 617 | iErr = InitBits (pBs, pRbsp, iBitSize); | 617 | iErr = DecInitBits (pBs, pRbsp, iBitSize); |
| 618 | if (ERR_NONE != iErr) { | 618 | if (ERR_NONE != iErr) { |
| 619 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) | 619 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) |
| 620 | pCtx->iErrorCode |= dsNoParamSets; | 620 | pCtx->iErrorCode |= dsNoParamSets; |
| @@ -1149,46 +1149,46 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 528 unmodified lines | |||
| 1149 | pCtx->iErrorCode |= dsOutOfMemory; | 1149 | pCtx->iErrorCode |= dsOutOfMemory; |
| 1150 | return pCtx->iErrorCode; | 1150 | return pCtx->iErrorCode; |
| 1151 | } | 1151 | } |
| 1152 | DecInitBitsForEncoding (&sSubsetSpsBs, pBsBuf, (int32_t) (pBs->pEndBuf - pBs->pStartBuf)); | 1152 | InitBits (&sSubsetSpsBs, pBsBuf, (int32_t) (pBs->pEndBuf - pBs->pStartBuf)); |
| 1153 | DecBsWriteBits (&sSubsetSpsBs, 8, 77); //profile_idc, forced to Main profile | 1153 | BsWriteBits (&sSubsetSpsBs, 8, 77); //profile_idc, forced to Main profile |
| 1154 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet0Flag); // constraint_set0_flag | 1154 | BsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet0Flag); // constraint_set0_flag |
| 1155 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet1Flag); // constraint_set1_flag | 1155 | BsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet1Flag); // constraint_set1_flag |
| 1156 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet2Flag); // constraint_set2_flag | 1156 | BsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet2Flag); // constraint_set2_flag |
| 1157 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet3Flag); // constraint_set3_flag | 1157 | BsWriteOneBit (&sSubsetSpsBs, pSps->bConstraintSet3Flag); // constraint_set3_flag |
| 1158 | DecBsWriteBits (&sSubsetSpsBs, 4, 0); //constraint_set4_flag, constraint_set5_flag, reserved_zero_2bits | 1158 | BsWriteBits (&sSubsetSpsBs, 4, 0); //constraint_set4_flag, constraint_set5_flag, reserved_zero_2bits |
| 1159 | DecBsWriteBits (&sSubsetSpsBs, 8, pSps->uiLevelIdc); //level_idc | 1159 | BsWriteBits (&sSubsetSpsBs, 8, pSps->uiLevelIdc); //level_idc |
| 1160 | DecBsWriteUe (&sSubsetSpsBs, pSps->iSpsId); //sps_id | 1160 | BsWriteUE (&sSubsetSpsBs, pSps->iSpsId); //sps_id |
| 1161 | DecBsWriteUe (&sSubsetSpsBs, pSps->uiLog2MaxFrameNum - 4); //log2_max_frame_num_minus4 | 1161 | BsWriteUE (&sSubsetSpsBs, pSps->uiLog2MaxFrameNum - 4); //log2_max_frame_num_minus4 |
| 1162 | DecBsWriteUe (&sSubsetSpsBs, pSps->uiPocType); //pic_order_cnt_type | 1162 | BsWriteUE (&sSubsetSpsBs, pSps->uiPocType); //pic_order_cnt_type |
| 1163 | if (pSps->uiPocType == 0) { | 1163 | if (pSps->uiPocType == 0) { |
| 1164 | DecBsWriteUe (&sSubsetSpsBs, pSps->iLog2MaxPocLsb - 4); //log2_max_pic_order_cnt_lsb_minus4 | 1164 | BsWriteUE (&sSubsetSpsBs, pSps->iLog2MaxPocLsb - 4); //log2_max_pic_order_cnt_lsb_minus4 |
| 1165 | } else if (pSps->uiPocType == 1) { | 1165 | } else if (pSps->uiPocType == 1) { |
| 1166 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bDeltaPicOrderAlwaysZeroFlag); //delta_pic_order_always_zero_flag | 1166 | BsWriteOneBit (&sSubsetSpsBs, pSps->bDeltaPicOrderAlwaysZeroFlag); //delta_pic_order_always_zero_flag |
| 1167 | DecBsWriteSe (&sSubsetSpsBs, pSps->iOffsetForNonRefPic); //offset_for_no_ref_pic | 1167 | BsWriteSE (&sSubsetSpsBs, pSps->iOffsetForNonRefPic); //offset_for_no_ref_pic |
| 1168 | DecBsWriteSe (&sSubsetSpsBs, pSps->iOffsetForTopToBottomField); //offset_for_top_to_bottom_field | 1168 | BsWriteSE (&sSubsetSpsBs, pSps->iOffsetForTopToBottomField); //offset_for_top_to_bottom_field |
| 1169 | DecBsWriteUe (&sSubsetSpsBs, pSps->iNumRefFramesInPocCycle); //num_ref_frames_in_pic_order_cnt_cycle | 1169 | BsWriteUE (&sSubsetSpsBs, pSps->iNumRefFramesInPocCycle); //num_ref_frames_in_pic_order_cnt_cycle |
| 1170 | for (int32_t i = 0; i < pSps->iNumRefFramesInPocCycle; ++i) { | 1170 | for (int32_t i = 0; i < pSps->iNumRefFramesInPocCycle; ++i) { |
| 1171 | DecBsWriteSe (&sSubsetSpsBs, pSps->iOffsetForRefFrame[i]); //offset_for_ref_frame[i] | 1171 | BsWriteSE (&sSubsetSpsBs, pSps->iOffsetForRefFrame[i]); //offset_for_ref_frame[i] |
| 1172 | } | 1172 | } |
| 1173 | } | 1173 | } |
| 1174 | DecBsWriteUe (&sSubsetSpsBs, pSps->iNumRefFrames); //max_num_ref_frames | 1174 | BsWriteUE (&sSubsetSpsBs, pSps->iNumRefFrames); //max_num_ref_frames |
| 1175 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bGapsInFrameNumValueAllowedFlag); //gaps_in_frame_num_value_allowed_flag | 1175 | BsWriteOneBit (&sSubsetSpsBs, pSps->bGapsInFrameNumValueAllowedFlag); //gaps_in_frame_num_value_allowed_flag |
| 1176 | DecBsWriteUe (&sSubsetSpsBs, pSps->iMbWidth - 1); //pic_width_in_mbs_minus1 | 1176 | BsWriteUE (&sSubsetSpsBs, pSps->iMbWidth - 1); //pic_width_in_mbs_minus1 |
| 1177 | DecBsWriteUe (&sSubsetSpsBs, pSps->iMbHeight - 1); //pic_height_in_map_units_minus1 | 1177 | BsWriteUE (&sSubsetSpsBs, pSps->iMbHeight - 1); //pic_height_in_map_units_minus1 |
| 1178 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bFrameMbsOnlyFlag); //frame_mbs_only_flag | 1178 | BsWriteOneBit (&sSubsetSpsBs, pSps->bFrameMbsOnlyFlag); //frame_mbs_only_flag |
| 1179 | if (!pSps->bFrameMbsOnlyFlag) { | 1179 | if (!pSps->bFrameMbsOnlyFlag) { |
| 1180 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bMbaffFlag); //mb_adaptive_frame_field_flag | 1180 | BsWriteOneBit (&sSubsetSpsBs, pSps->bMbaffFlag); //mb_adaptive_frame_field_flag |
| 1181 | } | 1181 | } |
| 1182 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bDirect8x8InferenceFlag); //direct_8x8_inference_flag | 1182 | BsWriteOneBit (&sSubsetSpsBs, pSps->bDirect8x8InferenceFlag); //direct_8x8_inference_flag |
| 1183 | DecBsWriteOneBit (&sSubsetSpsBs, pSps->bFrameCroppingFlag); //frame_cropping_flag | 1183 | BsWriteOneBit (&sSubsetSpsBs, pSps->bFrameCroppingFlag); //frame_cropping_flag |
| 1184 | if (pSps->bFrameCroppingFlag) { | 1184 | if (pSps->bFrameCroppingFlag) { |
| 1185 | DecBsWriteUe (&sSubsetSpsBs, pSps->sFrameCrop.iLeftOffset); //frame_crop_left_offset | 1185 | BsWriteUE (&sSubsetSpsBs, pSps->sFrameCrop.iLeftOffset); //frame_crop_left_offset |
| 1186 | DecBsWriteUe (&sSubsetSpsBs, pSps->sFrameCrop.iRightOffset); //frame_crop_right_offset | 1186 | BsWriteUE (&sSubsetSpsBs, pSps->sFrameCrop.iRightOffset); //frame_crop_right_offset |
| 1187 | DecBsWriteUe (&sSubsetSpsBs, pSps->sFrameCrop.iTopOffset); //frame_crop_top_offset | 1187 | BsWriteUE (&sSubsetSpsBs, pSps->sFrameCrop.iTopOffset); //frame_crop_top_offset |
| 1188 | DecBsWriteUe (&sSubsetSpsBs, pSps->sFrameCrop.iBottomOffset); //frame_crop_bottom_offset | 1188 | BsWriteUE (&sSubsetSpsBs, pSps->sFrameCrop.iBottomOffset); //frame_crop_bottom_offset |
| 1189 | } | 1189 | } |
| 1190 | DecBsWriteOneBit (&sSubsetSpsBs, 0); //vui_parameters_present_flag | 1190 | BsWriteOneBit (&sSubsetSpsBs, 0); //vui_parameters_present_flag |
| 1191 | DecBsRbspTrailingBits (&sSubsetSpsBs); //finished, rbsp trailing bit | 1191 | BsRbspTrailingBits (&sSubsetSpsBs); //finished, rbsp trailing bit |
| 1192 | int32_t iRbspSize = (int32_t) (sSubsetSpsBs.pCurBuf - sSubsetSpsBs.pStartBuf); | 1192 | int32_t iRbspSize = (int32_t) (sSubsetSpsBs.pCurBuf - sSubsetSpsBs.pStartBuf); |
| 1193 | RBSP2EBSP (pSpsBs->pSpsBsBuf + 5, sSubsetSpsBs.pStartBuf, iRbspSize); | 1193 | RBSP2EBSP (pSpsBs->pSpsBsBuf + 5, sSubsetSpsBs.pStartBuf, iRbspSize); |
| 1194 | pSpsBs->uiSpsBsLen = (uint16_t) (sSubsetSpsBs.pCurBuf - sSubsetSpsBs.pStartBuf + 5); | 1194 | pSpsBs->uiSpsBsLen = (uint16_t) (sSubsetSpsBs.pCurBuf - sSubsetSpsBs.pStartBuf + 5); |