10c1bc742181ded4930842b46e9507372f0b1b963James Dong/* 20c1bc742181ded4930842b46e9507372f0b1b963James Dong * Copyright (C) 2009 The Android Open Source Project 30c1bc742181ded4930842b46e9507372f0b1b963James Dong * 40c1bc742181ded4930842b46e9507372f0b1b963James Dong * Licensed under the Apache License, Version 2.0 (the "License"); 50c1bc742181ded4930842b46e9507372f0b1b963James Dong * you may not use this file except in compliance with the License. 60c1bc742181ded4930842b46e9507372f0b1b963James Dong * You may obtain a copy of the License at 70c1bc742181ded4930842b46e9507372f0b1b963James Dong * 80c1bc742181ded4930842b46e9507372f0b1b963James Dong * http://www.apache.org/licenses/LICENSE-2.0 90c1bc742181ded4930842b46e9507372f0b1b963James Dong * 100c1bc742181ded4930842b46e9507372f0b1b963James Dong * Unless required by applicable law or agreed to in writing, software 110c1bc742181ded4930842b46e9507372f0b1b963James Dong * distributed under the License is distributed on an "AS IS" BASIS, 120c1bc742181ded4930842b46e9507372f0b1b963James Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130c1bc742181ded4930842b46e9507372f0b1b963James Dong * See the License for the specific language governing permissions and 140c1bc742181ded4930842b46e9507372f0b1b963James Dong * limitations under the License. 150c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 160c1bc742181ded4930842b46e9507372f0b1b963James Dong 170c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 180c1bc742181ded4930842b46e9507372f0b1b963James Dong 190c1bc742181ded4930842b46e9507372f0b1b963James Dong Table of contents 200c1bc742181ded4930842b46e9507372f0b1b963James Dong 210c1bc742181ded4930842b46e9507372f0b1b963James Dong 1. Include headers 220c1bc742181ded4930842b46e9507372f0b1b963James Dong 2. External compiler flags 230c1bc742181ded4930842b46e9507372f0b1b963James Dong 3. Module defines 240c1bc742181ded4930842b46e9507372f0b1b963James Dong 4. Local function prototypes 250c1bc742181ded4930842b46e9507372f0b1b963James Dong 5. Functions 260c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdDecodeSliceHeader 270c1bc742181ded4930842b46e9507372f0b1b963James Dong NumSliceGroupChangeCycleBits 280c1bc742181ded4930842b46e9507372f0b1b963James Dong RefPicListReordering 290c1bc742181ded4930842b46e9507372f0b1b963James Dong DecRefPicMarking 300c1bc742181ded4930842b46e9507372f0b1b963James Dong CheckPpsId 310c1bc742181ded4930842b46e9507372f0b1b963James Dong CheckFrameNum 320c1bc742181ded4930842b46e9507372f0b1b963James Dong CheckIdrPicId 330c1bc742181ded4930842b46e9507372f0b1b963James Dong CheckPicOrderCntLsb 340c1bc742181ded4930842b46e9507372f0b1b963James Dong CheckDeltaPicOrderCntBottom 350c1bc742181ded4930842b46e9507372f0b1b963James Dong CheckDeltaPicOrderCnt 360c1bc742181ded4930842b46e9507372f0b1b963James Dong CheckRedundantPicCnt 370c1bc742181ded4930842b46e9507372f0b1b963James Dong 380c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 390c1bc742181ded4930842b46e9507372f0b1b963James Dong 400c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 410c1bc742181ded4930842b46e9507372f0b1b963James Dong 1. Include headers 420c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 430c1bc742181ded4930842b46e9507372f0b1b963James Dong 440c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_slice_header.h" 450c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_util.h" 460c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_vlc.h" 470c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_nal_unit.h" 480c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_dpb.h" 490c1bc742181ded4930842b46e9507372f0b1b963James Dong 500c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 510c1bc742181ded4930842b46e9507372f0b1b963James Dong 2. External compiler flags 520c1bc742181ded4930842b46e9507372f0b1b963James Dong-------------------------------------------------------------------------------- 530c1bc742181ded4930842b46e9507372f0b1b963James Dong 540c1bc742181ded4930842b46e9507372f0b1b963James Dong-------------------------------------------------------------------------------- 550c1bc742181ded4930842b46e9507372f0b1b963James Dong 3. Module defines 560c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 570c1bc742181ded4930842b46e9507372f0b1b963James Dong 580c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 590c1bc742181ded4930842b46e9507372f0b1b963James Dong 4. Local function prototypes 600c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 610c1bc742181ded4930842b46e9507372f0b1b963James Dong 620c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic u32 RefPicListReordering(strmData_t *, refPicListReordering_t *, 630c1bc742181ded4930842b46e9507372f0b1b963James Dong u32, u32); 640c1bc742181ded4930842b46e9507372f0b1b963James Dong 650c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic u32 NumSliceGroupChangeCycleBits(u32 picSizeInMbs, 660c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 sliceGroupChangeRate); 670c1bc742181ded4930842b46e9507372f0b1b963James Dong 680c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic u32 DecRefPicMarking(strmData_t *pStrmData, 690c1bc742181ded4930842b46e9507372f0b1b963James Dong decRefPicMarking_t *pDecRefPicMarking, nalUnitType_e nalUnitType, 700c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 numRefFrames); 710c1bc742181ded4930842b46e9507372f0b1b963James Dong 720c1bc742181ded4930842b46e9507372f0b1b963James Dong 730c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 740c1bc742181ded4930842b46e9507372f0b1b963James Dong 750c1bc742181ded4930842b46e9507372f0b1b963James Dong Function name: h264bsdDecodeSliceHeader 760c1bc742181ded4930842b46e9507372f0b1b963James Dong 770c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 780c1bc742181ded4930842b46e9507372f0b1b963James Dong Decode slice header data from the stream. 790c1bc742181ded4930842b46e9507372f0b1b963James Dong 800c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 810c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 820c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet pointer to active sequence parameter set 830c1bc742181ded4930842b46e9507372f0b1b963James Dong pPicParamSet pointer to active picture parameter set 840c1bc742181ded4930842b46e9507372f0b1b963James Dong pNalUnit pointer to current NAL unit structure 850c1bc742181ded4930842b46e9507372f0b1b963James Dong 860c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 870c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader decoded data is stored here 880c1bc742181ded4930842b46e9507372f0b1b963James Dong 890c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 900c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 910c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data or end of stream 920c1bc742181ded4930842b46e9507372f0b1b963James Dong 930c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 940c1bc742181ded4930842b46e9507372f0b1b963James Dong 950c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdDecodeSliceHeader(strmData_t *pStrmData, sliceHeader_t *pSliceHeader, 960c1bc742181ded4930842b46e9507372f0b1b963James Dong seqParamSet_t *pSeqParamSet, picParamSet_t *pPicParamSet, 970c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnit_t *pNalUnit) 980c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 990c1bc742181ded4930842b46e9507372f0b1b963James Dong 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, i, value; 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 itmp; 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 picSizeInMbs; 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSliceHeader); 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet); 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pPicParamSet); 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT( pNalUnit->nalUnitType == NAL_CODED_SLICE || 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong pNalUnit->nalUnitType == NAL_CODED_SLICE_IDR ); 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong H264SwDecMemset(pSliceHeader, 0, sizeof(sliceHeader_t)); 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong picSizeInMbs = pSeqParamSet->picWidthInMbs * pSeqParamSet->picHeightInMbs; 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->firstMbInSlice = value; 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value >= picSizeInMbs) 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("first_mb_in_slice"); 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->sliceType = value; 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong /* slice type has to be either I or P slice. P slice is not allowed when 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong * current NAL unit is an IDR NAL unit or num_ref_frames is 0 */ 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( !IS_I_SLICE(pSliceHeader->sliceType) && 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong ( !IS_P_SLICE(pSliceHeader->sliceType) || 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong IS_IDR_NAL_UNIT(pNalUnit) || 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong !pSeqParamSet->numRefFrames ) ) 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("slice_type"); 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1430c1bc742181ded4930842b46e9507372f0b1b963James Dong 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 1450c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 1460c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 1470c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->picParameterSetId = value; 1480c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSliceHeader->picParameterSetId != pPicParamSet->picParameterSetId) 1490c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1500c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("pic_parameter_set_id"); 1510c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 1520c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1530c1bc742181ded4930842b46e9507372f0b1b963James Dong 1540c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 1550c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 1560c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxFrameNum >> i) 1570c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 1580c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 1590c1bc742181ded4930842b46e9507372f0b1b963James Dong 1600c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(pStrmData, i); 1610c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 1620c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 1630c1bc742181ded4930842b46e9507372f0b1b963James Dong if (IS_IDR_NAL_UNIT(pNalUnit) && tmp != 0) 1640c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1650c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("frame_num"); 1660c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 1670c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1680c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->frameNum = tmp; 1690c1bc742181ded4930842b46e9507372f0b1b963James Dong 1700c1bc742181ded4930842b46e9507372f0b1b963James Dong if (IS_IDR_NAL_UNIT(pNalUnit)) 1710c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1720c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 1730c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 1740c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 1750c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->idrPicId = value; 1760c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value > 65535) 1770c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1780c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("idr_pic_id"); 1790c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 1800c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1810c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1820c1bc742181ded4930842b46e9507372f0b1b963James Dong 1830c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSeqParamSet->picOrderCntType == 0) 1840c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1850c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxPicOrderCntLsb) -> num bits to represent pic_order_cnt_lsb */ 1860c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 1870c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxPicOrderCntLsb >> i) 1880c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 1890c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 1900c1bc742181ded4930842b46e9507372f0b1b963James Dong 1910c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(pStrmData, i); 1920c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 1930c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 1940c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->picOrderCntLsb = tmp; 1950c1bc742181ded4930842b46e9507372f0b1b963James Dong 1960c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pPicParamSet->picOrderPresentFlag) 1970c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1980c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp); 1990c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 2000c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 2010c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->deltaPicOrderCntBottom = itmp; 2020c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2030c1bc742181ded4930842b46e9507372f0b1b963James Dong 2040c1bc742181ded4930842b46e9507372f0b1b963James Dong /* check that picOrderCnt for IDR picture will be zero. See 2050c1bc742181ded4930842b46e9507372f0b1b963James Dong * DecodePicOrderCnt function to understand the logic here */ 2060c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( IS_IDR_NAL_UNIT(pNalUnit) && 2070c1bc742181ded4930842b46e9507372f0b1b963James Dong ( (pSliceHeader->picOrderCntLsb > 2080c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet->maxPicOrderCntLsb/2) || 2090c1bc742181ded4930842b46e9507372f0b1b963James Dong MIN((i32)pSliceHeader->picOrderCntLsb, 2100c1bc742181ded4930842b46e9507372f0b1b963James Dong (i32)pSliceHeader->picOrderCntLsb + 2110c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->deltaPicOrderCntBottom) != 0 ) ) 2120c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2130c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 2140c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2150c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2160c1bc742181ded4930842b46e9507372f0b1b963James Dong 2170c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( (pSeqParamSet->picOrderCntType == 1) && 2180c1bc742181ded4930842b46e9507372f0b1b963James Dong !pSeqParamSet->deltaPicOrderAlwaysZeroFlag ) 2190c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2200c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp); 2210c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 2220c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 2230c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->deltaPicOrderCnt[0] = itmp; 2240c1bc742181ded4930842b46e9507372f0b1b963James Dong 2250c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pPicParamSet->picOrderPresentFlag) 2260c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2270c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp); 2280c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 2290c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 2300c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->deltaPicOrderCnt[1] = itmp; 2310c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2320c1bc742181ded4930842b46e9507372f0b1b963James Dong 2330c1bc742181ded4930842b46e9507372f0b1b963James Dong /* check that picOrderCnt for IDR picture will be zero. See 2340c1bc742181ded4930842b46e9507372f0b1b963James Dong * DecodePicOrderCnt function to understand the logic here */ 2350c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( IS_IDR_NAL_UNIT(pNalUnit) && 2360c1bc742181ded4930842b46e9507372f0b1b963James Dong MIN(pSliceHeader->deltaPicOrderCnt[0], 2370c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->deltaPicOrderCnt[0] + 2380c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet->offsetForTopToBottomField + 2390c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->deltaPicOrderCnt[1]) != 0) 2400c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2410c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 2420c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2430c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2440c1bc742181ded4930842b46e9507372f0b1b963James Dong 2450c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pPicParamSet->redundantPicCntPresentFlag) 2460c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2470c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 2480c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 2490c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 2500c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->redundantPicCnt = value; 2510c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value > 127) 2520c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2530c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("redundant_pic_cnt"); 2540c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 2550c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2560c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2570c1bc742181ded4930842b46e9507372f0b1b963James Dong 2580c1bc742181ded4930842b46e9507372f0b1b963James Dong if (IS_P_SLICE(pSliceHeader->sliceType)) 2590c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2600c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(pStrmData, 1); 2610c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 2620c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 2630c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->numRefIdxActiveOverrideFlag = tmp; 2640c1bc742181ded4930842b46e9507372f0b1b963James Dong 2650c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSliceHeader->numRefIdxActiveOverrideFlag) 2660c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2670c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 2680c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 2690c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 2700c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value > 15) 2710c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2720c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("num_ref_idx_l0_active_minus1"); 2730c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 2740c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2750c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->numRefIdxL0Active = value + 1; 2760c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2770c1bc742181ded4930842b46e9507372f0b1b963James Dong /* set numRefIdxL0Active from pic param set */ 2780c1bc742181ded4930842b46e9507372f0b1b963James Dong else 2790c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2800c1bc742181ded4930842b46e9507372f0b1b963James Dong /* if value (minus1) in picture parameter set exceeds 15 it should 2810c1bc742181ded4930842b46e9507372f0b1b963James Dong * have been overridden here */ 2820c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pPicParamSet->numRefIdxL0Active > 16) 2830c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2840c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("num_ref_idx_active_override_flag"); 2850c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 2860c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2870c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->numRefIdxL0Active = pPicParamSet->numRefIdxL0Active; 2880c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2890c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2900c1bc742181ded4930842b46e9507372f0b1b963James Dong 2910c1bc742181ded4930842b46e9507372f0b1b963James Dong if (IS_P_SLICE(pSliceHeader->sliceType)) 2920c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2930c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = RefPicListReordering(pStrmData, 2940c1bc742181ded4930842b46e9507372f0b1b963James Dong &pSliceHeader->refPicListReordering, 2950c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->numRefIdxL0Active, 2960c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet->maxFrameNum); 2970c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 2980c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 2990c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3000c1bc742181ded4930842b46e9507372f0b1b963James Dong 3010c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pNalUnit->nalRefIdc != 0) 3020c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3030c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = DecRefPicMarking(pStrmData, &pSliceHeader->decRefPicMarking, 3040c1bc742181ded4930842b46e9507372f0b1b963James Dong pNalUnit->nalUnitType, pSeqParamSet->numRefFrames); 3050c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 3060c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 3070c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3080c1bc742181ded4930842b46e9507372f0b1b963James Dong 3090c1bc742181ded4930842b46e9507372f0b1b963James Dong /* decode sliceQpDelta and check that initial QP for the slice will be on 3100c1bc742181ded4930842b46e9507372f0b1b963James Dong * the range [0, 51] */ 3110c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp); 3120c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 3130c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 3140c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->sliceQpDelta = itmp; 3150c1bc742181ded4930842b46e9507372f0b1b963James Dong itmp += (i32)pPicParamSet->picInitQp; 3160c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( (itmp < 0) || (itmp > 51) ) 3170c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3180c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("slice_qp_delta"); 3190c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 3200c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3210c1bc742181ded4930842b46e9507372f0b1b963James Dong 3220c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pPicParamSet->deblockingFilterControlPresentFlag) 3230c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3240c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 3250c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 3260c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 3270c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->disableDeblockingFilterIdc = value; 3280c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSliceHeader->disableDeblockingFilterIdc > 2) 3290c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3300c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("disable_deblocking_filter_idc"); 3310c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 3320c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3330c1bc742181ded4930842b46e9507372f0b1b963James Dong 3340c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSliceHeader->disableDeblockingFilterIdc != 1) 3350c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3360c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp); 3370c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 3380c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 3390c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( (itmp < -6) || (itmp > 6) ) 3400c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3410c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("slice_alpha_c0_offset_div2"); 3420c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 3430c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3440c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->sliceAlphaC0Offset = itmp * 2; 3450c1bc742181ded4930842b46e9507372f0b1b963James Dong 3460c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp); 3470c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 3480c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 3490c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( (itmp < -6) || (itmp > 6) ) 3500c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3510c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("slice_beta_offset_div2"); 3520c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 3530c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3540c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->sliceBetaOffset = itmp * 2; 3550c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3560c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3570c1bc742181ded4930842b46e9507372f0b1b963James Dong 3580c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( (pPicParamSet->numSliceGroups > 1) && 3590c1bc742181ded4930842b46e9507372f0b1b963James Dong (pPicParamSet->sliceGroupMapType >= 3) && 3600c1bc742181ded4930842b46e9507372f0b1b963James Dong (pPicParamSet->sliceGroupMapType <= 5) ) 3610c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3620c1bc742181ded4930842b46e9507372f0b1b963James Dong /* set tmp to number of bits used to represent slice_group_change_cycle 3630c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the stream */ 3640c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = NumSliceGroupChangeCycleBits(picSizeInMbs, 3650c1bc742181ded4930842b46e9507372f0b1b963James Dong pPicParamSet->sliceGroupChangeRate); 3660c1bc742181ded4930842b46e9507372f0b1b963James Dong value = h264bsdGetBits(pStrmData, tmp); 3670c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value == END_OF_STREAM) 3680c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 3690c1bc742181ded4930842b46e9507372f0b1b963James Dong pSliceHeader->sliceGroupChangeCycle = value; 3700c1bc742181ded4930842b46e9507372f0b1b963James Dong 3710c1bc742181ded4930842b46e9507372f0b1b963James Dong /* corresponds to tmp = Ceil(picSizeInMbs / sliceGroupChangeRate) */ 3720c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = (picSizeInMbs + pPicParamSet->sliceGroupChangeRate - 1) / 3730c1bc742181ded4930842b46e9507372f0b1b963James Dong pPicParamSet->sliceGroupChangeRate; 3740c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSliceHeader->sliceGroupChangeCycle > tmp) 3750c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3760c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("slice_group_change_cycle"); 3770c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 3780c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3790c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3800c1bc742181ded4930842b46e9507372f0b1b963James Dong 3810c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 3820c1bc742181ded4930842b46e9507372f0b1b963James Dong 3830c1bc742181ded4930842b46e9507372f0b1b963James Dong} 3840c1bc742181ded4930842b46e9507372f0b1b963James Dong 3850c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 3860c1bc742181ded4930842b46e9507372f0b1b963James Dong 3870c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: NumSliceGroupChangeCycleBits 3880c1bc742181ded4930842b46e9507372f0b1b963James Dong 3890c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 3900c1bc742181ded4930842b46e9507372f0b1b963James Dong Determine number of bits needed to represent 3910c1bc742181ded4930842b46e9507372f0b1b963James Dong slice_group_change_cycle in the stream. The standard states that 3920c1bc742181ded4930842b46e9507372f0b1b963James Dong slice_group_change_cycle is represented by 3930c1bc742181ded4930842b46e9507372f0b1b963James Dong Ceil( Log2( (picSizeInMbs / sliceGroupChangeRate) + 1) ) 3940c1bc742181ded4930842b46e9507372f0b1b963James Dong 3950c1bc742181ded4930842b46e9507372f0b1b963James Dong bits. Division "/" in the equation is non-truncating division. 3960c1bc742181ded4930842b46e9507372f0b1b963James Dong 3970c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 3980c1bc742181ded4930842b46e9507372f0b1b963James Dong picSizeInMbs picture size in macroblocks 3990c1bc742181ded4930842b46e9507372f0b1b963James Dong sliceGroupChangeRate 4000c1bc742181ded4930842b46e9507372f0b1b963James Dong 4010c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 4020c1bc742181ded4930842b46e9507372f0b1b963James Dong none 4030c1bc742181ded4930842b46e9507372f0b1b963James Dong 4040c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 4050c1bc742181ded4930842b46e9507372f0b1b963James Dong number of bits needed 4060c1bc742181ded4930842b46e9507372f0b1b963James Dong 4070c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 4080c1bc742181ded4930842b46e9507372f0b1b963James Dong 4090c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 NumSliceGroupChangeCycleBits(u32 picSizeInMbs, u32 sliceGroupChangeRate) 4100c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 4110c1bc742181ded4930842b46e9507372f0b1b963James Dong 4120c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 4130c1bc742181ded4930842b46e9507372f0b1b963James Dong 4140c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp,numBits,mask; 4150c1bc742181ded4930842b46e9507372f0b1b963James Dong 4160c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 4170c1bc742181ded4930842b46e9507372f0b1b963James Dong 4180c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(picSizeInMbs); 4190c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(sliceGroupChangeRate); 4200c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(sliceGroupChangeRate <= picSizeInMbs); 4210c1bc742181ded4930842b46e9507372f0b1b963James Dong 4220c1bc742181ded4930842b46e9507372f0b1b963James Dong /* compute (picSizeInMbs / sliceGroupChangeRate + 1), rounded up */ 4230c1bc742181ded4930842b46e9507372f0b1b963James Dong if (picSizeInMbs % sliceGroupChangeRate) 4240c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = 2 + picSizeInMbs/sliceGroupChangeRate; 4250c1bc742181ded4930842b46e9507372f0b1b963James Dong else 4260c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = 1 + picSizeInMbs/sliceGroupChangeRate; 4270c1bc742181ded4930842b46e9507372f0b1b963James Dong 4280c1bc742181ded4930842b46e9507372f0b1b963James Dong numBits = 0; 4290c1bc742181ded4930842b46e9507372f0b1b963James Dong mask = ~0U; 4300c1bc742181ded4930842b46e9507372f0b1b963James Dong 4310c1bc742181ded4930842b46e9507372f0b1b963James Dong /* set numBits to position of right-most non-zero bit */ 4320c1bc742181ded4930842b46e9507372f0b1b963James Dong while (tmp & (mask<<++numBits)) 4330c1bc742181ded4930842b46e9507372f0b1b963James Dong ; 4340c1bc742181ded4930842b46e9507372f0b1b963James Dong numBits--; 4350c1bc742181ded4930842b46e9507372f0b1b963James Dong 4360c1bc742181ded4930842b46e9507372f0b1b963James Dong /* add one more bit if value greater than 2^numBits */ 4370c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp & ((1<<numBits)-1)) 4380c1bc742181ded4930842b46e9507372f0b1b963James Dong numBits++; 4390c1bc742181ded4930842b46e9507372f0b1b963James Dong 4400c1bc742181ded4930842b46e9507372f0b1b963James Dong return(numBits); 4410c1bc742181ded4930842b46e9507372f0b1b963James Dong 4420c1bc742181ded4930842b46e9507372f0b1b963James Dong} 4430c1bc742181ded4930842b46e9507372f0b1b963James Dong 4440c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 4450c1bc742181ded4930842b46e9507372f0b1b963James Dong 4460c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: RefPicListReordering 4470c1bc742181ded4930842b46e9507372f0b1b963James Dong 4480c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 4490c1bc742181ded4930842b46e9507372f0b1b963James Dong Decode reference picture list reordering syntax elements from 4500c1bc742181ded4930842b46e9507372f0b1b963James Dong the stream. Max number of reordering commands is numRefIdxActive. 4510c1bc742181ded4930842b46e9507372f0b1b963James Dong 4520c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 4530c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 4540c1bc742181ded4930842b46e9507372f0b1b963James Dong numRefIdxActive number of active reference indices to be used for 4550c1bc742181ded4930842b46e9507372f0b1b963James Dong current slice 4560c1bc742181ded4930842b46e9507372f0b1b963James Dong maxPicNum maxFrameNum from the active SPS 4570c1bc742181ded4930842b46e9507372f0b1b963James Dong 4580c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 4590c1bc742181ded4930842b46e9507372f0b1b963James Dong pRefPicListReordering decoded data is stored here 4600c1bc742181ded4930842b46e9507372f0b1b963James Dong 4610c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 4620c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 4630c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 4640c1bc742181ded4930842b46e9507372f0b1b963James Dong 4650c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 4660c1bc742181ded4930842b46e9507372f0b1b963James Dong 4670c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 RefPicListReordering(strmData_t *pStrmData, 4680c1bc742181ded4930842b46e9507372f0b1b963James Dong refPicListReordering_t *pRefPicListReordering, u32 numRefIdxActive, 4690c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 maxPicNum) 4700c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 4710c1bc742181ded4930842b46e9507372f0b1b963James Dong 4720c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 4730c1bc742181ded4930842b46e9507372f0b1b963James Dong 4740c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 4750c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 command; 4760c1bc742181ded4930842b46e9507372f0b1b963James Dong 4770c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 4780c1bc742181ded4930842b46e9507372f0b1b963James Dong 4790c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 4800c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pRefPicListReordering); 4810c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(numRefIdxActive); 4820c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(maxPicNum); 4830c1bc742181ded4930842b46e9507372f0b1b963James Dong 4840c1bc742181ded4930842b46e9507372f0b1b963James Dong 4850c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(pStrmData, 1); 4860c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 4870c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 4880c1bc742181ded4930842b46e9507372f0b1b963James Dong 4890c1bc742181ded4930842b46e9507372f0b1b963James Dong pRefPicListReordering->refPicListReorderingFlagL0 = tmp; 4900c1bc742181ded4930842b46e9507372f0b1b963James Dong 4910c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pRefPicListReordering->refPicListReorderingFlagL0) 4920c1bc742181ded4930842b46e9507372f0b1b963James Dong { 4930c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 4940c1bc742181ded4930842b46e9507372f0b1b963James Dong 4950c1bc742181ded4930842b46e9507372f0b1b963James Dong do 4960c1bc742181ded4930842b46e9507372f0b1b963James Dong { 4970c1bc742181ded4930842b46e9507372f0b1b963James Dong if (i > numRefIdxActive) 4980c1bc742181ded4930842b46e9507372f0b1b963James Dong { 4990c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("Too many reordering commands"); 5000c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 5010c1bc742181ded4930842b46e9507372f0b1b963James Dong } 5020c1bc742181ded4930842b46e9507372f0b1b963James Dong 5030c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &command); 5040c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 5050c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 5060c1bc742181ded4930842b46e9507372f0b1b963James Dong if (command > 3) 5070c1bc742181ded4930842b46e9507372f0b1b963James Dong { 5080c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("reordering_of_pic_nums_idc"); 5090c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 5100c1bc742181ded4930842b46e9507372f0b1b963James Dong } 5110c1bc742181ded4930842b46e9507372f0b1b963James Dong 5120c1bc742181ded4930842b46e9507372f0b1b963James Dong pRefPicListReordering->command[i].reorderingOfPicNumsIdc = command; 5130c1bc742181ded4930842b46e9507372f0b1b963James Dong 5140c1bc742181ded4930842b46e9507372f0b1b963James Dong if ((command == 0) || (command == 1)) 5150c1bc742181ded4930842b46e9507372f0b1b963James Dong { 5160c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 5170c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 5180c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 5190c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value >= maxPicNum) 5200c1bc742181ded4930842b46e9507372f0b1b963James Dong { 5210c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("abs_diff_pic_num_minus1"); 5220c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 5230c1bc742181ded4930842b46e9507372f0b1b963James Dong } 5240c1bc742181ded4930842b46e9507372f0b1b963James Dong pRefPicListReordering->command[i].absDiffPicNum = value + 1; 5250c1bc742181ded4930842b46e9507372f0b1b963James Dong } 5260c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (command == 2) 5270c1bc742181ded4930842b46e9507372f0b1b963James Dong { 5280c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 5290c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 5300c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 5310c1bc742181ded4930842b46e9507372f0b1b963James Dong pRefPicListReordering->command[i].longTermPicNum = value; 5320c1bc742181ded4930842b46e9507372f0b1b963James Dong } 5330c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 5340c1bc742181ded4930842b46e9507372f0b1b963James Dong } while (command != 3); 5350c1bc742181ded4930842b46e9507372f0b1b963James Dong 5360c1bc742181ded4930842b46e9507372f0b1b963James Dong /* there shall be at least one reordering command if 5370c1bc742181ded4930842b46e9507372f0b1b963James Dong * refPicListReorderingFlagL0 was set */ 5380c1bc742181ded4930842b46e9507372f0b1b963James Dong if (i == 1) 5390c1bc742181ded4930842b46e9507372f0b1b963James Dong { 5400c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("ref_pic_list_reordering"); 5410c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 5420c1bc742181ded4930842b46e9507372f0b1b963James Dong } 5430c1bc742181ded4930842b46e9507372f0b1b963James Dong } 5440c1bc742181ded4930842b46e9507372f0b1b963James Dong 5450c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 5460c1bc742181ded4930842b46e9507372f0b1b963James Dong 5470c1bc742181ded4930842b46e9507372f0b1b963James Dong} 5480c1bc742181ded4930842b46e9507372f0b1b963James Dong 5490c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 5500c1bc742181ded4930842b46e9507372f0b1b963James Dong 5510c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: DecRefPicMarking 5520c1bc742181ded4930842b46e9507372f0b1b963James Dong 5530c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 5540c1bc742181ded4930842b46e9507372f0b1b963James Dong Decode decoded reference picture marking syntax elements from 5550c1bc742181ded4930842b46e9507372f0b1b963James Dong the stream. 5560c1bc742181ded4930842b46e9507372f0b1b963James Dong 5570c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 5580c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 5590c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType type of the current NAL unit 5600c1bc742181ded4930842b46e9507372f0b1b963James Dong numRefFrames max number of reference frames from the active SPS 5610c1bc742181ded4930842b46e9507372f0b1b963James Dong 5620c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 5630c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking decoded data is stored here 5640c1bc742181ded4930842b46e9507372f0b1b963James Dong 5650c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 5660c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 5670c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 5680c1bc742181ded4930842b46e9507372f0b1b963James Dong 5690c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 5700c1bc742181ded4930842b46e9507372f0b1b963James Dong 5710c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 DecRefPicMarking(strmData_t *pStrmData, 5720c1bc742181ded4930842b46e9507372f0b1b963James Dong decRefPicMarking_t *pDecRefPicMarking, nalUnitType_e nalUnitType, 5730c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 numRefFrames) 5740c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 5750c1bc742181ded4930842b46e9507372f0b1b963James Dong 5760c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 5770c1bc742181ded4930842b46e9507372f0b1b963James Dong 5780c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value; 5790c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 i; 5800c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 operation; 5810c1bc742181ded4930842b46e9507372f0b1b963James Dong /* variables for error checking purposes, store number of memory 5820c1bc742181ded4930842b46e9507372f0b1b963James Dong * management operations of certain type */ 5830c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 num4 = 0, num5 = 0, num6 = 0, num1to3 = 0; 5840c1bc742181ded4930842b46e9507372f0b1b963James Dong 5850c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 5860c1bc742181ded4930842b46e9507372f0b1b963James Dong 5870c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT( nalUnitType == NAL_CODED_SLICE_IDR || 5880c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType == NAL_CODED_SLICE || 5890c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType == NAL_SEI ); 5900c1bc742181ded4930842b46e9507372f0b1b963James Dong 5910c1bc742181ded4930842b46e9507372f0b1b963James Dong 5920c1bc742181ded4930842b46e9507372f0b1b963James Dong if (nalUnitType == NAL_CODED_SLICE_IDR) 5930c1bc742181ded4930842b46e9507372f0b1b963James Dong { 5940c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(pStrmData, 1); 5950c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 5960c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 5970c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->noOutputOfPriorPicsFlag = tmp; 5980c1bc742181ded4930842b46e9507372f0b1b963James Dong 5990c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(pStrmData, 1); 6000c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 6010c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 6020c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->longTermReferenceFlag = tmp; 6030c1bc742181ded4930842b46e9507372f0b1b963James Dong if (!numRefFrames && pDecRefPicMarking->longTermReferenceFlag) 6040c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6050c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("long_term_reference_flag"); 6060c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 6070c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6080c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6090c1bc742181ded4930842b46e9507372f0b1b963James Dong else 6100c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6110c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(pStrmData, 1); 6120c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 6130c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 6140c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->adaptiveRefPicMarkingModeFlag = tmp; 6150c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pDecRefPicMarking->adaptiveRefPicMarkingModeFlag) 6160c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6170c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 6180c1bc742181ded4930842b46e9507372f0b1b963James Dong do 6190c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6200c1bc742181ded4930842b46e9507372f0b1b963James Dong /* see explanation of the MAX_NUM_MMC_OPERATIONS in 6210c1bc742181ded4930842b46e9507372f0b1b963James Dong * slice_header.h */ 6220c1bc742181ded4930842b46e9507372f0b1b963James Dong if (i > (2 * numRefFrames + 2)) 6230c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6240c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("Too many management operations"); 6250c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 6260c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6270c1bc742181ded4930842b46e9507372f0b1b963James Dong 6280c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &operation); 6290c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 6300c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 6310c1bc742181ded4930842b46e9507372f0b1b963James Dong if (operation > 6) 6320c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6330c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("memory_management_control_operation"); 6340c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 6350c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6360c1bc742181ded4930842b46e9507372f0b1b963James Dong 6370c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->operation[i]. 6380c1bc742181ded4930842b46e9507372f0b1b963James Dong memoryManagementControlOperation = operation; 6390c1bc742181ded4930842b46e9507372f0b1b963James Dong if ((operation == 1) || (operation == 3)) 6400c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6410c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 6420c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 6430c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 6440c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->operation[i].differenceOfPicNums = 6450c1bc742181ded4930842b46e9507372f0b1b963James Dong value + 1; 6460c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6470c1bc742181ded4930842b46e9507372f0b1b963James Dong if (operation == 2) 6480c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6490c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 6500c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 6510c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 6520c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->operation[i].longTermPicNum = value; 6530c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6540c1bc742181ded4930842b46e9507372f0b1b963James Dong if ((operation == 3) || (operation == 6)) 6550c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6560c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 6570c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 6580c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 6590c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->operation[i].longTermFrameIdx = 6600c1bc742181ded4930842b46e9507372f0b1b963James Dong value; 6610c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6620c1bc742181ded4930842b46e9507372f0b1b963James Dong if (operation == 4) 6630c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6640c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value); 6650c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 6660c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 6670c1bc742181ded4930842b46e9507372f0b1b963James Dong /* value shall be in range [0, numRefFrames] */ 6680c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value > numRefFrames) 6690c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6700c1bc742181ded4930842b46e9507372f0b1b963James Dong EPRINT("max_long_term_frame_idx_plus1"); 6710c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 6720c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6730c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value == 0) 6740c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6750c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->operation[i]. 6760c1bc742181ded4930842b46e9507372f0b1b963James Dong maxLongTermFrameIdx = 6770c1bc742181ded4930842b46e9507372f0b1b963James Dong NO_LONG_TERM_FRAME_INDICES; 6780c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6790c1bc742181ded4930842b46e9507372f0b1b963James Dong else 6800c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6810c1bc742181ded4930842b46e9507372f0b1b963James Dong pDecRefPicMarking->operation[i]. 6820c1bc742181ded4930842b46e9507372f0b1b963James Dong maxLongTermFrameIdx = value - 1; 6830c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6840c1bc742181ded4930842b46e9507372f0b1b963James Dong num4++; 6850c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6860c1bc742181ded4930842b46e9507372f0b1b963James Dong if (operation == 5) 6870c1bc742181ded4930842b46e9507372f0b1b963James Dong { 6880c1bc742181ded4930842b46e9507372f0b1b963James Dong num5++; 6890c1bc742181ded4930842b46e9507372f0b1b963James Dong } 6900c1bc742181ded4930842b46e9507372f0b1b963James Dong if (operation && operation <= 3) 6910c1bc742181ded4930842b46e9507372f0b1b963James Dong num1to3++; 6920c1bc742181ded4930842b46e9507372f0b1b963James Dong if (operation == 6) 6930c1bc742181ded4930842b46e9507372f0b1b963James Dong num6++; 6940c1bc742181ded4930842b46e9507372f0b1b963James Dong 6950c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 6960c1bc742181ded4930842b46e9507372f0b1b963James Dong } while (operation != 0); 6970c1bc742181ded4930842b46e9507372f0b1b963James Dong 6980c1bc742181ded4930842b46e9507372f0b1b963James Dong /* error checking */ 6990c1bc742181ded4930842b46e9507372f0b1b963James Dong if (num4 > 1 || num5 > 1 || num6 > 1 || (num1to3 && num5)) 7000c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 7010c1bc742181ded4930842b46e9507372f0b1b963James Dong 7020c1bc742181ded4930842b46e9507372f0b1b963James Dong } 7030c1bc742181ded4930842b46e9507372f0b1b963James Dong } 7040c1bc742181ded4930842b46e9507372f0b1b963James Dong 7050c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 7060c1bc742181ded4930842b46e9507372f0b1b963James Dong} 7070c1bc742181ded4930842b46e9507372f0b1b963James Dong 7080c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 7090c1bc742181ded4930842b46e9507372f0b1b963James Dong 7100c1bc742181ded4930842b46e9507372f0b1b963James Dong Function name: h264bsdCheckPpsId 7110c1bc742181ded4930842b46e9507372f0b1b963James Dong 7120c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 7130c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek value of pic_parameter_set_id from the slice header. Function 7140c1bc742181ded4930842b46e9507372f0b1b963James Dong does not modify current stream positions but copies the stream 7150c1bc742181ded4930842b46e9507372f0b1b963James Dong data structure to tmp structure which is used while accessing 7160c1bc742181ded4930842b46e9507372f0b1b963James Dong stream data. 7170c1bc742181ded4930842b46e9507372f0b1b963James Dong 7180c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 7190c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 7200c1bc742181ded4930842b46e9507372f0b1b963James Dong 7210c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 7220c1bc742181ded4930842b46e9507372f0b1b963James Dong picParamSetId value is stored here 7230c1bc742181ded4930842b46e9507372f0b1b963James Dong 7240c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 7250c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 7260c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 7270c1bc742181ded4930842b46e9507372f0b1b963James Dong 7280c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 7290c1bc742181ded4930842b46e9507372f0b1b963James Dong 7300c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckPpsId(strmData_t *pStrmData, u32 *picParamSetId) 7310c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 7320c1bc742181ded4930842b46e9507372f0b1b963James Dong 7330c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 7340c1bc742181ded4930842b46e9507372f0b1b963James Dong 7350c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value; 7360c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 7370c1bc742181ded4930842b46e9507372f0b1b963James Dong 7380c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 7390c1bc742181ded4930842b46e9507372f0b1b963James Dong 7400c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 7410c1bc742181ded4930842b46e9507372f0b1b963James Dong 7420c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 7430c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 7440c1bc742181ded4930842b46e9507372f0b1b963James Dong 7450c1bc742181ded4930842b46e9507372f0b1b963James Dong /* first_mb_in_slice */ 7460c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 7470c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 7480c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 7490c1bc742181ded4930842b46e9507372f0b1b963James Dong 7500c1bc742181ded4930842b46e9507372f0b1b963James Dong /* slice_type */ 7510c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 7520c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 7530c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 7540c1bc742181ded4930842b46e9507372f0b1b963James Dong 7550c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 7560c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 7570c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 7580c1bc742181ded4930842b46e9507372f0b1b963James Dong if (value >= MAX_NUM_PIC_PARAM_SETS) 7590c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 7600c1bc742181ded4930842b46e9507372f0b1b963James Dong 7610c1bc742181ded4930842b46e9507372f0b1b963James Dong *picParamSetId = value; 7620c1bc742181ded4930842b46e9507372f0b1b963James Dong 7630c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 7640c1bc742181ded4930842b46e9507372f0b1b963James Dong 7650c1bc742181ded4930842b46e9507372f0b1b963James Dong} 7660c1bc742181ded4930842b46e9507372f0b1b963James Dong 7670c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 7680c1bc742181ded4930842b46e9507372f0b1b963James Dong 7690c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdCheckFrameNum 7700c1bc742181ded4930842b46e9507372f0b1b963James Dong 7710c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 7720c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek value of frame_num from the slice header. Function does not 7730c1bc742181ded4930842b46e9507372f0b1b963James Dong modify current stream positions but copies the stream data 7740c1bc742181ded4930842b46e9507372f0b1b963James Dong structure to tmp structure which is used while accessing stream 7750c1bc742181ded4930842b46e9507372f0b1b963James Dong data. 7760c1bc742181ded4930842b46e9507372f0b1b963James Dong 7770c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 7780c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 7790c1bc742181ded4930842b46e9507372f0b1b963James Dong maxFrameNum 7800c1bc742181ded4930842b46e9507372f0b1b963James Dong 7810c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 7820c1bc742181ded4930842b46e9507372f0b1b963James Dong frameNum value is stored here 7830c1bc742181ded4930842b46e9507372f0b1b963James Dong 7840c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 7850c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 7860c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 7870c1bc742181ded4930842b46e9507372f0b1b963James Dong 7880c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 7890c1bc742181ded4930842b46e9507372f0b1b963James Dong 7900c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckFrameNum( 7910c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t *pStrmData, 7920c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 maxFrameNum, 7930c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 *frameNum) 7940c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 7950c1bc742181ded4930842b46e9507372f0b1b963James Dong 7960c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 7970c1bc742181ded4930842b46e9507372f0b1b963James Dong 7980c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 7990c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 8000c1bc742181ded4930842b46e9507372f0b1b963James Dong 8010c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 8020c1bc742181ded4930842b46e9507372f0b1b963James Dong 8030c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 8040c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(maxFrameNum); 8050c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(frameNum); 8060c1bc742181ded4930842b46e9507372f0b1b963James Dong 8070c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 8080c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 8090c1bc742181ded4930842b46e9507372f0b1b963James Dong 8100c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip first_mb_in_slice */ 8110c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 8120c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 8130c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 8140c1bc742181ded4930842b46e9507372f0b1b963James Dong 8150c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip slice_type */ 8160c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 8170c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 8180c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 8190c1bc742181ded4930842b46e9507372f0b1b963James Dong 8200c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_parameter_set_id */ 8210c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 8220c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 8230c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 8240c1bc742181ded4930842b46e9507372f0b1b963James Dong 8250c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 8260c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 8270c1bc742181ded4930842b46e9507372f0b1b963James Dong while (maxFrameNum >> i) 8280c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 8290c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 8300c1bc742181ded4930842b46e9507372f0b1b963James Dong 8310c1bc742181ded4930842b46e9507372f0b1b963James Dong /* frame_num */ 8320c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 8330c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 8340c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 8350c1bc742181ded4930842b46e9507372f0b1b963James Dong *frameNum = tmp; 8360c1bc742181ded4930842b46e9507372f0b1b963James Dong 8370c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 8380c1bc742181ded4930842b46e9507372f0b1b963James Dong 8390c1bc742181ded4930842b46e9507372f0b1b963James Dong} 8400c1bc742181ded4930842b46e9507372f0b1b963James Dong 8410c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 8420c1bc742181ded4930842b46e9507372f0b1b963James Dong 8430c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdCheckIdrPicId 8440c1bc742181ded4930842b46e9507372f0b1b963James Dong 8450c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 8460c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek value of idr_pic_id from the slice header. Function does not 8470c1bc742181ded4930842b46e9507372f0b1b963James Dong modify current stream positions but copies the stream data 8480c1bc742181ded4930842b46e9507372f0b1b963James Dong structure to tmp structure which is used while accessing stream 8490c1bc742181ded4930842b46e9507372f0b1b963James Dong data. 8500c1bc742181ded4930842b46e9507372f0b1b963James Dong 8510c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 8520c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 8530c1bc742181ded4930842b46e9507372f0b1b963James Dong maxFrameNum max frame number from active SPS 8540c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType type of the current NAL unit 8550c1bc742181ded4930842b46e9507372f0b1b963James Dong 8560c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 8570c1bc742181ded4930842b46e9507372f0b1b963James Dong idrPicId value is stored here 8580c1bc742181ded4930842b46e9507372f0b1b963James Dong 8590c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 8600c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 8610c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 8620c1bc742181ded4930842b46e9507372f0b1b963James Dong 8630c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 8640c1bc742181ded4930842b46e9507372f0b1b963James Dong 8650c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckIdrPicId( 8660c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t *pStrmData, 8670c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 maxFrameNum, 8680c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType_e nalUnitType, 8690c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 *idrPicId) 8700c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 8710c1bc742181ded4930842b46e9507372f0b1b963James Dong 8720c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 8730c1bc742181ded4930842b46e9507372f0b1b963James Dong 8740c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 8750c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 8760c1bc742181ded4930842b46e9507372f0b1b963James Dong 8770c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 8780c1bc742181ded4930842b46e9507372f0b1b963James Dong 8790c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 8800c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(maxFrameNum); 8810c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(idrPicId); 8820c1bc742181ded4930842b46e9507372f0b1b963James Dong 8830c1bc742181ded4930842b46e9507372f0b1b963James Dong /* nalUnitType must be equal to 5 because otherwise idrPicId is not 8840c1bc742181ded4930842b46e9507372f0b1b963James Dong * present */ 8850c1bc742181ded4930842b46e9507372f0b1b963James Dong if (nalUnitType != NAL_CODED_SLICE_IDR) 8860c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 8870c1bc742181ded4930842b46e9507372f0b1b963James Dong 8880c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 8890c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 8900c1bc742181ded4930842b46e9507372f0b1b963James Dong 8910c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip first_mb_in_slice */ 8920c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 8930c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 8940c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 8950c1bc742181ded4930842b46e9507372f0b1b963James Dong 8960c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip slice_type */ 8970c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 8980c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 8990c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 9000c1bc742181ded4930842b46e9507372f0b1b963James Dong 9010c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_parameter_set_id */ 9020c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 9030c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 9040c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 9050c1bc742181ded4930842b46e9507372f0b1b963James Dong 9060c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 9070c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 9080c1bc742181ded4930842b46e9507372f0b1b963James Dong while (maxFrameNum >> i) 9090c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 9100c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 9110c1bc742181ded4930842b46e9507372f0b1b963James Dong 9120c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip frame_num */ 9130c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 9140c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 9150c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 9160c1bc742181ded4930842b46e9507372f0b1b963James Dong 9170c1bc742181ded4930842b46e9507372f0b1b963James Dong /* idr_pic_id */ 9180c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, idrPicId); 9190c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 9200c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 9210c1bc742181ded4930842b46e9507372f0b1b963James Dong 9220c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 9230c1bc742181ded4930842b46e9507372f0b1b963James Dong 9240c1bc742181ded4930842b46e9507372f0b1b963James Dong} 9250c1bc742181ded4930842b46e9507372f0b1b963James Dong 9260c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 9270c1bc742181ded4930842b46e9507372f0b1b963James Dong 9280c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdCheckPicOrderCntLsb 9290c1bc742181ded4930842b46e9507372f0b1b963James Dong 9300c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 9310c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek value of pic_order_cnt_lsb from the slice header. Function 9320c1bc742181ded4930842b46e9507372f0b1b963James Dong does not modify current stream positions but copies the stream 9330c1bc742181ded4930842b46e9507372f0b1b963James Dong data structure to tmp structure which is used while accessing 9340c1bc742181ded4930842b46e9507372f0b1b963James Dong stream data. 9350c1bc742181ded4930842b46e9507372f0b1b963James Dong 9360c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 9370c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 9380c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet pointer to active SPS 9390c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType type of the current NAL unit 9400c1bc742181ded4930842b46e9507372f0b1b963James Dong 9410c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 9420c1bc742181ded4930842b46e9507372f0b1b963James Dong picOrderCntLsb value is stored here 9430c1bc742181ded4930842b46e9507372f0b1b963James Dong 9440c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 9450c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 9460c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 9470c1bc742181ded4930842b46e9507372f0b1b963James Dong 9480c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 9490c1bc742181ded4930842b46e9507372f0b1b963James Dong 9500c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckPicOrderCntLsb( 9510c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t *pStrmData, 9520c1bc742181ded4930842b46e9507372f0b1b963James Dong seqParamSet_t *pSeqParamSet, 9530c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType_e nalUnitType, 9540c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 *picOrderCntLsb) 9550c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 9560c1bc742181ded4930842b46e9507372f0b1b963James Dong 9570c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 9580c1bc742181ded4930842b46e9507372f0b1b963James Dong 9590c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 9600c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 9610c1bc742181ded4930842b46e9507372f0b1b963James Dong 9620c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 9630c1bc742181ded4930842b46e9507372f0b1b963James Dong 9640c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 9650c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet); 9660c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(picOrderCntLsb); 9670c1bc742181ded4930842b46e9507372f0b1b963James Dong 9680c1bc742181ded4930842b46e9507372f0b1b963James Dong /* picOrderCntType must be equal to 0 */ 9690c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->picOrderCntType == 0); 9700c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->maxFrameNum); 9710c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->maxPicOrderCntLsb); 9720c1bc742181ded4930842b46e9507372f0b1b963James Dong 9730c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 9740c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 9750c1bc742181ded4930842b46e9507372f0b1b963James Dong 9760c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip first_mb_in_slice */ 9770c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 9780c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 9790c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 9800c1bc742181ded4930842b46e9507372f0b1b963James Dong 9810c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip slice_type */ 9820c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 9830c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 9840c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 9850c1bc742181ded4930842b46e9507372f0b1b963James Dong 9860c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_parameter_set_id */ 9870c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 9880c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 9890c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 9900c1bc742181ded4930842b46e9507372f0b1b963James Dong 9910c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 9920c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 9930c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxFrameNum >> i) 9940c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 9950c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 9960c1bc742181ded4930842b46e9507372f0b1b963James Dong 9970c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip frame_num */ 9980c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 9990c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 10000c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 10010c1bc742181ded4930842b46e9507372f0b1b963James Dong 10020c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip idr_pic_id when necessary */ 10030c1bc742181ded4930842b46e9507372f0b1b963James Dong if (nalUnitType == NAL_CODED_SLICE_IDR) 10040c1bc742181ded4930842b46e9507372f0b1b963James Dong { 10050c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 10060c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 10070c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 10080c1bc742181ded4930842b46e9507372f0b1b963James Dong } 10090c1bc742181ded4930842b46e9507372f0b1b963James Dong 10100c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxPicOrderCntLsb) -> num bits to represent pic_order_cnt_lsb */ 10110c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 10120c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxPicOrderCntLsb >> i) 10130c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 10140c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 10150c1bc742181ded4930842b46e9507372f0b1b963James Dong 10160c1bc742181ded4930842b46e9507372f0b1b963James Dong /* pic_order_cnt_lsb */ 10170c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 10180c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 10190c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 10200c1bc742181ded4930842b46e9507372f0b1b963James Dong *picOrderCntLsb = tmp; 10210c1bc742181ded4930842b46e9507372f0b1b963James Dong 10220c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 10230c1bc742181ded4930842b46e9507372f0b1b963James Dong 10240c1bc742181ded4930842b46e9507372f0b1b963James Dong} 10250c1bc742181ded4930842b46e9507372f0b1b963James Dong 10260c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 10270c1bc742181ded4930842b46e9507372f0b1b963James Dong 10280c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdCheckDeltaPicOrderCntBottom 10290c1bc742181ded4930842b46e9507372f0b1b963James Dong 10300c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 10310c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek value of delta_pic_order_cnt_bottom from the slice header. 10320c1bc742181ded4930842b46e9507372f0b1b963James Dong Function does not modify current stream positions but copies the 10330c1bc742181ded4930842b46e9507372f0b1b963James Dong stream data structure to tmp structure which is used while 10340c1bc742181ded4930842b46e9507372f0b1b963James Dong accessing stream data. 10350c1bc742181ded4930842b46e9507372f0b1b963James Dong 10360c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 10370c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 10380c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet pointer to active SPS 10390c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType type of the current NAL unit 10400c1bc742181ded4930842b46e9507372f0b1b963James Dong 10410c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 10420c1bc742181ded4930842b46e9507372f0b1b963James Dong deltaPicOrderCntBottom value is stored here 10430c1bc742181ded4930842b46e9507372f0b1b963James Dong 10440c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 10450c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 10460c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 10470c1bc742181ded4930842b46e9507372f0b1b963James Dong 10480c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 10490c1bc742181ded4930842b46e9507372f0b1b963James Dong 10500c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckDeltaPicOrderCntBottom( 10510c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t *pStrmData, 10520c1bc742181ded4930842b46e9507372f0b1b963James Dong seqParamSet_t *pSeqParamSet, 10530c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType_e nalUnitType, 10540c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 *deltaPicOrderCntBottom) 10550c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 10560c1bc742181ded4930842b46e9507372f0b1b963James Dong 10570c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 10580c1bc742181ded4930842b46e9507372f0b1b963James Dong 10590c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 10600c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 10610c1bc742181ded4930842b46e9507372f0b1b963James Dong 10620c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 10630c1bc742181ded4930842b46e9507372f0b1b963James Dong 10640c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 10650c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet); 10660c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(deltaPicOrderCntBottom); 10670c1bc742181ded4930842b46e9507372f0b1b963James Dong 10680c1bc742181ded4930842b46e9507372f0b1b963James Dong /* picOrderCntType must be equal to 0 and picOrderPresentFlag must be TRUE 10690c1bc742181ded4930842b46e9507372f0b1b963James Dong * */ 10700c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->picOrderCntType == 0); 10710c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->maxFrameNum); 10720c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->maxPicOrderCntLsb); 10730c1bc742181ded4930842b46e9507372f0b1b963James Dong 10740c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 10750c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 10760c1bc742181ded4930842b46e9507372f0b1b963James Dong 10770c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip first_mb_in_slice */ 10780c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 10790c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 10800c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 10810c1bc742181ded4930842b46e9507372f0b1b963James Dong 10820c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip slice_type */ 10830c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 10840c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 10850c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 10860c1bc742181ded4930842b46e9507372f0b1b963James Dong 10870c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_parameter_set_id */ 10880c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 10890c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 10900c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 10910c1bc742181ded4930842b46e9507372f0b1b963James Dong 10920c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 10930c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 10940c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxFrameNum >> i) 10950c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 10960c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 10970c1bc742181ded4930842b46e9507372f0b1b963James Dong 10980c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip frame_num */ 10990c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 11000c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 11010c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 11020c1bc742181ded4930842b46e9507372f0b1b963James Dong 11030c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip idr_pic_id when necessary */ 11040c1bc742181ded4930842b46e9507372f0b1b963James Dong if (nalUnitType == NAL_CODED_SLICE_IDR) 11050c1bc742181ded4930842b46e9507372f0b1b963James Dong { 11060c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 11070c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 11080c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 11090c1bc742181ded4930842b46e9507372f0b1b963James Dong } 11100c1bc742181ded4930842b46e9507372f0b1b963James Dong 11110c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxPicOrderCntLsb) -> num bits to represent pic_order_cnt_lsb */ 11120c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 11130c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxPicOrderCntLsb >> i) 11140c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 11150c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 11160c1bc742181ded4930842b46e9507372f0b1b963James Dong 11170c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_order_cnt_lsb */ 11180c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 11190c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 11200c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 11210c1bc742181ded4930842b46e9507372f0b1b963James Dong 11220c1bc742181ded4930842b46e9507372f0b1b963James Dong /* delta_pic_order_cnt_bottom */ 11230c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, deltaPicOrderCntBottom); 11240c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 11250c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 11260c1bc742181ded4930842b46e9507372f0b1b963James Dong 11270c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 11280c1bc742181ded4930842b46e9507372f0b1b963James Dong 11290c1bc742181ded4930842b46e9507372f0b1b963James Dong} 11300c1bc742181ded4930842b46e9507372f0b1b963James Dong 11310c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 11320c1bc742181ded4930842b46e9507372f0b1b963James Dong 11330c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdCheckDeltaPicOrderCnt 11340c1bc742181ded4930842b46e9507372f0b1b963James Dong 11350c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 11360c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek values delta_pic_order_cnt[0] and delta_pic_order_cnt[1] 11370c1bc742181ded4930842b46e9507372f0b1b963James Dong from the slice header. Function does not modify current stream 11380c1bc742181ded4930842b46e9507372f0b1b963James Dong positions but copies the stream data structure to tmp structure 11390c1bc742181ded4930842b46e9507372f0b1b963James Dong which is used while accessing stream data. 11400c1bc742181ded4930842b46e9507372f0b1b963James Dong 11410c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 11420c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 11430c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet pointer to active SPS 11440c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType type of the current NAL unit 11450c1bc742181ded4930842b46e9507372f0b1b963James Dong picOrderPresentFlag flag indicating if delta_pic_order_cnt[1] 11460c1bc742181ded4930842b46e9507372f0b1b963James Dong is present in the stream 11470c1bc742181ded4930842b46e9507372f0b1b963James Dong 11480c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 11490c1bc742181ded4930842b46e9507372f0b1b963James Dong deltaPicOrderCnt values are stored here 11500c1bc742181ded4930842b46e9507372f0b1b963James Dong 11510c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 11520c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 11530c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 11540c1bc742181ded4930842b46e9507372f0b1b963James Dong 11550c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 11560c1bc742181ded4930842b46e9507372f0b1b963James Dong 11570c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckDeltaPicOrderCnt( 11580c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t *pStrmData, 11590c1bc742181ded4930842b46e9507372f0b1b963James Dong seqParamSet_t *pSeqParamSet, 11600c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType_e nalUnitType, 11610c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 picOrderPresentFlag, 11620c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 *deltaPicOrderCnt) 11630c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 11640c1bc742181ded4930842b46e9507372f0b1b963James Dong 11650c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 11660c1bc742181ded4930842b46e9507372f0b1b963James Dong 11670c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 11680c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 11690c1bc742181ded4930842b46e9507372f0b1b963James Dong 11700c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 11710c1bc742181ded4930842b46e9507372f0b1b963James Dong 11720c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 11730c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet); 11740c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(deltaPicOrderCnt); 11750c1bc742181ded4930842b46e9507372f0b1b963James Dong 11760c1bc742181ded4930842b46e9507372f0b1b963James Dong /* picOrderCntType must be equal to 1 and deltaPicOrderAlwaysZeroFlag must 11770c1bc742181ded4930842b46e9507372f0b1b963James Dong * be FALSE */ 11780c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->picOrderCntType == 1); 11790c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!pSeqParamSet->deltaPicOrderAlwaysZeroFlag); 11800c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->maxFrameNum); 11810c1bc742181ded4930842b46e9507372f0b1b963James Dong 11820c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 11830c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 11840c1bc742181ded4930842b46e9507372f0b1b963James Dong 11850c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip first_mb_in_slice */ 11860c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 11870c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 11880c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 11890c1bc742181ded4930842b46e9507372f0b1b963James Dong 11900c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip slice_type */ 11910c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 11920c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 11930c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 11940c1bc742181ded4930842b46e9507372f0b1b963James Dong 11950c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_parameter_set_id */ 11960c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 11970c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 11980c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 11990c1bc742181ded4930842b46e9507372f0b1b963James Dong 12000c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 12010c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 12020c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxFrameNum >> i) 12030c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 12040c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 12050c1bc742181ded4930842b46e9507372f0b1b963James Dong 12060c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip frame_num */ 12070c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 12080c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 12090c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 12100c1bc742181ded4930842b46e9507372f0b1b963James Dong 12110c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip idr_pic_id when necessary */ 12120c1bc742181ded4930842b46e9507372f0b1b963James Dong if (nalUnitType == NAL_CODED_SLICE_IDR) 12130c1bc742181ded4930842b46e9507372f0b1b963James Dong { 12140c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 12150c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 12160c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 12170c1bc742181ded4930842b46e9507372f0b1b963James Dong } 12180c1bc742181ded4930842b46e9507372f0b1b963James Dong 12190c1bc742181ded4930842b46e9507372f0b1b963James Dong /* delta_pic_order_cnt[0] */ 12200c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &deltaPicOrderCnt[0]); 12210c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 12220c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 12230c1bc742181ded4930842b46e9507372f0b1b963James Dong 12240c1bc742181ded4930842b46e9507372f0b1b963James Dong /* delta_pic_order_cnt[1] if present */ 12250c1bc742181ded4930842b46e9507372f0b1b963James Dong if (picOrderPresentFlag) 12260c1bc742181ded4930842b46e9507372f0b1b963James Dong { 12270c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &deltaPicOrderCnt[1]); 12280c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 12290c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 12300c1bc742181ded4930842b46e9507372f0b1b963James Dong } 12310c1bc742181ded4930842b46e9507372f0b1b963James Dong 12320c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 12330c1bc742181ded4930842b46e9507372f0b1b963James Dong 12340c1bc742181ded4930842b46e9507372f0b1b963James Dong} 12350c1bc742181ded4930842b46e9507372f0b1b963James Dong 12360c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 12370c1bc742181ded4930842b46e9507372f0b1b963James Dong 12380c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdCheckRedundantPicCnt 12390c1bc742181ded4930842b46e9507372f0b1b963James Dong 12400c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 12410c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek value of redundant_pic_cnt from the slice header. Function 12420c1bc742181ded4930842b46e9507372f0b1b963James Dong does not modify current stream positions but copies the stream 12430c1bc742181ded4930842b46e9507372f0b1b963James Dong data structure to tmp structure which is used while accessing 12440c1bc742181ded4930842b46e9507372f0b1b963James Dong stream data. 12450c1bc742181ded4930842b46e9507372f0b1b963James Dong 12460c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 12470c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 12480c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet pointer to active SPS 12490c1bc742181ded4930842b46e9507372f0b1b963James Dong pPicParamSet pointer to active PPS 12500c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType type of the current NAL unit 12510c1bc742181ded4930842b46e9507372f0b1b963James Dong 12520c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 12530c1bc742181ded4930842b46e9507372f0b1b963James Dong redundantPicCnt value is stored here 12540c1bc742181ded4930842b46e9507372f0b1b963James Dong 12550c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 12560c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 12570c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 12580c1bc742181ded4930842b46e9507372f0b1b963James Dong 12590c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 12600c1bc742181ded4930842b46e9507372f0b1b963James Dong 12610c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckRedundantPicCnt( 12620c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t *pStrmData, 12630c1bc742181ded4930842b46e9507372f0b1b963James Dong seqParamSet_t *pSeqParamSet, 12640c1bc742181ded4930842b46e9507372f0b1b963James Dong picParamSet_t *pPicParamSet, 12650c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType_e nalUnitType, 12660c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 *redundantPicCnt) 12670c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 12680c1bc742181ded4930842b46e9507372f0b1b963James Dong 12690c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 12700c1bc742181ded4930842b46e9507372f0b1b963James Dong 12710c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 12720c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 ivalue; 12730c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 12740c1bc742181ded4930842b46e9507372f0b1b963James Dong 12750c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 12760c1bc742181ded4930842b46e9507372f0b1b963James Dong 12770c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 12780c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet); 12790c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pPicParamSet); 12800c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(redundantPicCnt); 12810c1bc742181ded4930842b46e9507372f0b1b963James Dong 12820c1bc742181ded4930842b46e9507372f0b1b963James Dong /* redundant_pic_cnt_flag must be TRUE */ 12830c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pPicParamSet->redundantPicCntPresentFlag); 12840c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->maxFrameNum); 12850c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet->picOrderCntType > 0 || 12860c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet->maxPicOrderCntLsb); 12870c1bc742181ded4930842b46e9507372f0b1b963James Dong 12880c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 12890c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 12900c1bc742181ded4930842b46e9507372f0b1b963James Dong 12910c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip first_mb_in_slice */ 12920c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 12930c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 12940c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 12950c1bc742181ded4930842b46e9507372f0b1b963James Dong 12960c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip slice_type */ 12970c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 12980c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 12990c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 13000c1bc742181ded4930842b46e9507372f0b1b963James Dong 13010c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_parameter_set_id */ 13020c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 13030c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 13040c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 13050c1bc742181ded4930842b46e9507372f0b1b963James Dong 13060c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 13070c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 13080c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxFrameNum >> i) 13090c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 13100c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 13110c1bc742181ded4930842b46e9507372f0b1b963James Dong 13120c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip frame_num */ 13130c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 13140c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 13150c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 13160c1bc742181ded4930842b46e9507372f0b1b963James Dong 13170c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip idr_pic_id when necessary */ 13180c1bc742181ded4930842b46e9507372f0b1b963James Dong if (nalUnitType == NAL_CODED_SLICE_IDR) 13190c1bc742181ded4930842b46e9507372f0b1b963James Dong { 13200c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 13210c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 13220c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 13230c1bc742181ded4930842b46e9507372f0b1b963James Dong } 13240c1bc742181ded4930842b46e9507372f0b1b963James Dong 13250c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSeqParamSet->picOrderCntType == 0) 13260c1bc742181ded4930842b46e9507372f0b1b963James Dong { 13270c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxPicOrderCntLsb) -> num bits to represent pic_order_cnt_lsb */ 13280c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 13290c1bc742181ded4930842b46e9507372f0b1b963James Dong while (pSeqParamSet->maxPicOrderCntLsb >> i) 13300c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 13310c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 13320c1bc742181ded4930842b46e9507372f0b1b963James Dong 13330c1bc742181ded4930842b46e9507372f0b1b963James Dong /* pic_order_cnt_lsb */ 13340c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 13350c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp == END_OF_STREAM) 13360c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_NOK); 13370c1bc742181ded4930842b46e9507372f0b1b963James Dong 13380c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pPicParamSet->picOrderPresentFlag) 13390c1bc742181ded4930842b46e9507372f0b1b963James Dong { 13400c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip delta_pic_order_cnt_bottom */ 13410c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &ivalue); 13420c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 13430c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 13440c1bc742181ded4930842b46e9507372f0b1b963James Dong } 13450c1bc742181ded4930842b46e9507372f0b1b963James Dong } 13460c1bc742181ded4930842b46e9507372f0b1b963James Dong 13470c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pSeqParamSet->picOrderCntType == 1 && 13480c1bc742181ded4930842b46e9507372f0b1b963James Dong !pSeqParamSet->deltaPicOrderAlwaysZeroFlag) 13490c1bc742181ded4930842b46e9507372f0b1b963James Dong { 13500c1bc742181ded4930842b46e9507372f0b1b963James Dong /* delta_pic_order_cnt[0] */ 13510c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &ivalue); 13520c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 13530c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 13540c1bc742181ded4930842b46e9507372f0b1b963James Dong 13550c1bc742181ded4930842b46e9507372f0b1b963James Dong /* delta_pic_order_cnt[1] if present */ 13560c1bc742181ded4930842b46e9507372f0b1b963James Dong if (pPicParamSet->picOrderPresentFlag) 13570c1bc742181ded4930842b46e9507372f0b1b963James Dong { 13580c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &ivalue); 13590c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 13600c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 13610c1bc742181ded4930842b46e9507372f0b1b963James Dong } 13620c1bc742181ded4930842b46e9507372f0b1b963James Dong } 13630c1bc742181ded4930842b46e9507372f0b1b963James Dong 13640c1bc742181ded4930842b46e9507372f0b1b963James Dong /* redundant_pic_cnt */ 13650c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, redundantPicCnt); 13660c1bc742181ded4930842b46e9507372f0b1b963James Dong if (tmp != HANTRO_OK) 13670c1bc742181ded4930842b46e9507372f0b1b963James Dong return(tmp); 13680c1bc742181ded4930842b46e9507372f0b1b963James Dong 13690c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_OK); 13700c1bc742181ded4930842b46e9507372f0b1b963James Dong 13710c1bc742181ded4930842b46e9507372f0b1b963James Dong} 13720c1bc742181ded4930842b46e9507372f0b1b963James Dong 13730c1bc742181ded4930842b46e9507372f0b1b963James Dong 13740c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 13750c1bc742181ded4930842b46e9507372f0b1b963James Dong 13760c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdCheckPriorPicsFlag 13770c1bc742181ded4930842b46e9507372f0b1b963James Dong 13780c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 13790c1bc742181ded4930842b46e9507372f0b1b963James Dong Peek value of no_output_of_prior_pics_flag from the slice header. 13800c1bc742181ded4930842b46e9507372f0b1b963James Dong Function does not modify current stream positions but copies 13810c1bc742181ded4930842b46e9507372f0b1b963James Dong the stream data structure to tmp structure which is used while 13820c1bc742181ded4930842b46e9507372f0b1b963James Dong accessing stream data. 13830c1bc742181ded4930842b46e9507372f0b1b963James Dong 13840c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 13850c1bc742181ded4930842b46e9507372f0b1b963James Dong pStrmData pointer to stream data structure 13860c1bc742181ded4930842b46e9507372f0b1b963James Dong pSeqParamSet pointer to active SPS 13870c1bc742181ded4930842b46e9507372f0b1b963James Dong pPicParamSet pointer to active PPS 13880c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType type of the current NAL unit 13890c1bc742181ded4930842b46e9507372f0b1b963James Dong 13900c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 13910c1bc742181ded4930842b46e9507372f0b1b963James Dong noOutputOfPriorPicsFlag value is stored here 13920c1bc742181ded4930842b46e9507372f0b1b963James Dong 13930c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 13940c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_OK success 13950c1bc742181ded4930842b46e9507372f0b1b963James Dong HANTRO_NOK invalid stream data 13960c1bc742181ded4930842b46e9507372f0b1b963James Dong 13970c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 13980c1bc742181ded4930842b46e9507372f0b1b963James Dong/*lint -e715 disable lint info nalUnitType not referenced */ 13990c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdCheckPriorPicsFlag(u32 * noOutputOfPriorPicsFlag, 14000c1bc742181ded4930842b46e9507372f0b1b963James Dong const strmData_t * pStrmData, 14010c1bc742181ded4930842b46e9507372f0b1b963James Dong const seqParamSet_t * pSeqParamSet, 14020c1bc742181ded4930842b46e9507372f0b1b963James Dong const picParamSet_t * pPicParamSet, 14030c1bc742181ded4930842b46e9507372f0b1b963James Dong nalUnitType_e nalUnitType) 14040c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 14050c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 14060c1bc742181ded4930842b46e9507372f0b1b963James Dong 14070c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp, value, i; 14080c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 ivalue; 14090c1bc742181ded4930842b46e9507372f0b1b963James Dong strmData_t tmpStrmData[1]; 14100c1bc742181ded4930842b46e9507372f0b1b963James Dong 14110c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 14120c1bc742181ded4930842b46e9507372f0b1b963James Dong 14130c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pStrmData); 14140c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pSeqParamSet); 14150c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pPicParamSet); 14160c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(noOutputOfPriorPicsFlag); 14170c1bc742181ded4930842b46e9507372f0b1b963James Dong 14180c1bc742181ded4930842b46e9507372f0b1b963James Dong /* must be IDR lsice */ 14190c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(nalUnitType == NAL_CODED_SLICE_IDR); 14200c1bc742181ded4930842b46e9507372f0b1b963James Dong 14210c1bc742181ded4930842b46e9507372f0b1b963James Dong /* don't touch original stream position params */ 14220c1bc742181ded4930842b46e9507372f0b1b963James Dong *tmpStrmData = *pStrmData; 14230c1bc742181ded4930842b46e9507372f0b1b963James Dong 14240c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip first_mb_in_slice */ 14250c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 14260c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14270c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 14280c1bc742181ded4930842b46e9507372f0b1b963James Dong 14290c1bc742181ded4930842b46e9507372f0b1b963James Dong /* slice_type */ 14300c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 14310c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14320c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 14330c1bc742181ded4930842b46e9507372f0b1b963James Dong 14340c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_parameter_set_id */ 14350c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 14360c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14370c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 14380c1bc742181ded4930842b46e9507372f0b1b963James Dong 14390c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxFrameNum) -> num bits to represent frame_num */ 14400c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 14410c1bc742181ded4930842b46e9507372f0b1b963James Dong while(pSeqParamSet->maxFrameNum >> i) 14420c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 14430c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 14440c1bc742181ded4930842b46e9507372f0b1b963James Dong 14450c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip frame_num */ 14460c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 14470c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp == END_OF_STREAM) 14480c1bc742181ded4930842b46e9507372f0b1b963James Dong return (HANTRO_NOK); 14490c1bc742181ded4930842b46e9507372f0b1b963James Dong 14500c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip idr_pic_id */ 14510c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 14520c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14530c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 14540c1bc742181ded4930842b46e9507372f0b1b963James Dong 14550c1bc742181ded4930842b46e9507372f0b1b963James Dong if(pSeqParamSet->picOrderCntType == 0) 14560c1bc742181ded4930842b46e9507372f0b1b963James Dong { 14570c1bc742181ded4930842b46e9507372f0b1b963James Dong /* log2(maxPicOrderCntLsb) -> num bits to represent pic_order_cnt_lsb */ 14580c1bc742181ded4930842b46e9507372f0b1b963James Dong i = 0; 14590c1bc742181ded4930842b46e9507372f0b1b963James Dong while(pSeqParamSet->maxPicOrderCntLsb >> i) 14600c1bc742181ded4930842b46e9507372f0b1b963James Dong i++; 14610c1bc742181ded4930842b46e9507372f0b1b963James Dong i--; 14620c1bc742181ded4930842b46e9507372f0b1b963James Dong 14630c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip pic_order_cnt_lsb */ 14640c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdGetBits(tmpStrmData, i); 14650c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp == END_OF_STREAM) 14660c1bc742181ded4930842b46e9507372f0b1b963James Dong return (HANTRO_NOK); 14670c1bc742181ded4930842b46e9507372f0b1b963James Dong 14680c1bc742181ded4930842b46e9507372f0b1b963James Dong if(pPicParamSet->picOrderPresentFlag) 14690c1bc742181ded4930842b46e9507372f0b1b963James Dong { 14700c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip delta_pic_order_cnt_bottom */ 14710c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &ivalue); 14720c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14730c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 14740c1bc742181ded4930842b46e9507372f0b1b963James Dong } 14750c1bc742181ded4930842b46e9507372f0b1b963James Dong } 14760c1bc742181ded4930842b46e9507372f0b1b963James Dong 14770c1bc742181ded4930842b46e9507372f0b1b963James Dong if(pSeqParamSet->picOrderCntType == 1 && 14780c1bc742181ded4930842b46e9507372f0b1b963James Dong !pSeqParamSet->deltaPicOrderAlwaysZeroFlag) 14790c1bc742181ded4930842b46e9507372f0b1b963James Dong { 14800c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip delta_pic_order_cnt[0] */ 14810c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &ivalue); 14820c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14830c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 14840c1bc742181ded4930842b46e9507372f0b1b963James Dong 14850c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip delta_pic_order_cnt[1] if present */ 14860c1bc742181ded4930842b46e9507372f0b1b963James Dong if(pPicParamSet->picOrderPresentFlag) 14870c1bc742181ded4930842b46e9507372f0b1b963James Dong { 14880c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombSigned(tmpStrmData, &ivalue); 14890c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14900c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 14910c1bc742181ded4930842b46e9507372f0b1b963James Dong } 14920c1bc742181ded4930842b46e9507372f0b1b963James Dong } 14930c1bc742181ded4930842b46e9507372f0b1b963James Dong 14940c1bc742181ded4930842b46e9507372f0b1b963James Dong /* skip redundant_pic_cnt */ 14950c1bc742181ded4930842b46e9507372f0b1b963James Dong if(pPicParamSet->redundantPicCntPresentFlag) 14960c1bc742181ded4930842b46e9507372f0b1b963James Dong { 14970c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = h264bsdDecodeExpGolombUnsigned(tmpStrmData, &value); 14980c1bc742181ded4930842b46e9507372f0b1b963James Dong if(tmp != HANTRO_OK) 14990c1bc742181ded4930842b46e9507372f0b1b963James Dong return (tmp); 15000c1bc742181ded4930842b46e9507372f0b1b963James Dong } 15010c1bc742181ded4930842b46e9507372f0b1b963James Dong 15020c1bc742181ded4930842b46e9507372f0b1b963James Dong *noOutputOfPriorPicsFlag = h264bsdGetBits(tmpStrmData, 1); 15030c1bc742181ded4930842b46e9507372f0b1b963James Dong if(*noOutputOfPriorPicsFlag == END_OF_STREAM) 15040c1bc742181ded4930842b46e9507372f0b1b963James Dong return (HANTRO_NOK); 15050c1bc742181ded4930842b46e9507372f0b1b963James Dong 15060c1bc742181ded4930842b46e9507372f0b1b963James Dong return (HANTRO_OK); 15070c1bc742181ded4930842b46e9507372f0b1b963James Dong 15080c1bc742181ded4930842b46e9507372f0b1b963James Dong} 15090c1bc742181ded4930842b46e9507372f0b1b963James Dong/*lint +e715 */ 15100c1bc742181ded4930842b46e9507372f0b1b963James Dong 15110c1bc742181ded4930842b46e9507372f0b1b963James Dong 1512