Home | History | Annotate | Download | only in source
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /*------------------------------------------------------------------------------
     18 
     19     Table of contents
     20 
     21     1. Include headers
     22     2. Module defines
     23     3. Data types
     24     4. Function prototypes
     25 
     26 ------------------------------------------------------------------------------*/
     27 
     28 #ifndef H264SWDEC_SLICE_HEADER_H
     29 #define H264SWDEC_SLICE_HEADER_H
     30 
     31 /*------------------------------------------------------------------------------
     32     1. Include headers
     33 ------------------------------------------------------------------------------*/
     34 
     35 #include "basetype.h"
     36 #include "h264bsd_stream.h"
     37 #include "h264bsd_cfg.h"
     38 #include "h264bsd_seq_param_set.h"
     39 #include "h264bsd_pic_param_set.h"
     40 #include "h264bsd_nal_unit.h"
     41 
     42 /*------------------------------------------------------------------------------
     43     2. Module defines
     44 ------------------------------------------------------------------------------*/
     45 
     46 enum {
     47     P_SLICE = 0,
     48     I_SLICE = 2
     49 };
     50 
     51 enum {NO_LONG_TERM_FRAME_INDICES = 0xFFFF};
     52 
     53 /* macro to determine if slice is an inter slice, sliceTypes 0 and 5 */
     54 #define IS_P_SLICE(sliceType) (((sliceType) == P_SLICE) || \
     55     ((sliceType) == P_SLICE + 5))
     56 
     57 /* macro to determine if slice is an intra slice, sliceTypes 2 and 7 */
     58 #define IS_I_SLICE(sliceType) (((sliceType) == I_SLICE) || \
     59     ((sliceType) == I_SLICE + 5))
     60 
     61 /*------------------------------------------------------------------------------
     62     3. Data types
     63 ------------------------------------------------------------------------------*/
     64 
     65 /* structure to store data of one reference picture list reordering operation */
     66 typedef struct
     67 {
     68     u32 reorderingOfPicNumsIdc;
     69     u32 absDiffPicNum;
     70     u32 longTermPicNum;
     71 } refPicListReorderingOperation_t;
     72 
     73 /* structure to store reference picture list reordering operations */
     74 typedef struct
     75 {
     76     u32 refPicListReorderingFlagL0;
     77     refPicListReorderingOperation_t command[MAX_NUM_REF_PICS+1];
     78 } refPicListReordering_t;
     79 
     80 /* structure to store data of one DPB memory management control operation */
     81 typedef struct
     82 {
     83     u32 memoryManagementControlOperation;
     84     u32 differenceOfPicNums;
     85     u32 longTermPicNum;
     86     u32 longTermFrameIdx;
     87     u32 maxLongTermFrameIdx;
     88 } memoryManagementOperation_t;
     89 
     90 /* worst case scenario: all MAX_NUM_REF_PICS pictures in the buffer are
     91  * short term pictures, each one of them is first marked as long term
     92  * reference picture which is then marked as unused for reference.
     93  * Additionally, max long-term frame index is set and current picture is
     94  * marked as long term reference picture. Last position reserved for
     95  * end memory_management_control_operation command */
     96 #define MAX_NUM_MMC_OPERATIONS (2*MAX_NUM_REF_PICS+2+1)
     97 
     98 /* structure to store decoded reference picture marking data */
     99 typedef struct
    100 {
    101     u32 noOutputOfPriorPicsFlag;
    102     u32 longTermReferenceFlag;
    103     u32 adaptiveRefPicMarkingModeFlag;
    104     memoryManagementOperation_t operation[MAX_NUM_MMC_OPERATIONS];
    105 } decRefPicMarking_t;
    106 
    107 /* structure to store slice header data decoded from the stream */
    108 typedef struct
    109 {
    110     u32 firstMbInSlice;
    111     u32 sliceType;
    112     u32 picParameterSetId;
    113     u32 frameNum;
    114     u32 idrPicId;
    115     u32 picOrderCntLsb;
    116     i32 deltaPicOrderCntBottom;
    117     i32 deltaPicOrderCnt[2];
    118     u32 redundantPicCnt;
    119     u32 numRefIdxActiveOverrideFlag;
    120     u32 numRefIdxL0Active;
    121     i32 sliceQpDelta;
    122     u32 disableDeblockingFilterIdc;
    123     i32 sliceAlphaC0Offset;
    124     i32 sliceBetaOffset;
    125     u32 sliceGroupChangeCycle;
    126     refPicListReordering_t refPicListReordering;
    127     decRefPicMarking_t decRefPicMarking;
    128 } sliceHeader_t;
    129 
    130 /*------------------------------------------------------------------------------
    131     4. Function prototypes
    132 ------------------------------------------------------------------------------*/
    133 
    134 u32 h264bsdDecodeSliceHeader(strmData_t *pStrmData,
    135   sliceHeader_t *pSliceHeader,
    136   seqParamSet_t *pSeqParamSet,
    137   picParamSet_t *pPicParamSet,
    138   nalUnit_t *pNalUnit);
    139 
    140 u32 h264bsdCheckPpsId(strmData_t *pStrmData, u32 *ppsId);
    141 
    142 u32 h264bsdCheckFrameNum(
    143   strmData_t *pStrmData,
    144   u32 maxFrameNum,
    145   u32 *frameNum);
    146 
    147 u32 h264bsdCheckIdrPicId(
    148   strmData_t *pStrmData,
    149   u32 maxFrameNum,
    150   nalUnitType_e nalUnitType,
    151   u32 *idrPicId);
    152 
    153 u32 h264bsdCheckPicOrderCntLsb(
    154   strmData_t *pStrmData,
    155   seqParamSet_t *pSeqParamSet,
    156   nalUnitType_e nalUnitType,
    157   u32 *picOrderCntLsb);
    158 
    159 u32 h264bsdCheckDeltaPicOrderCntBottom(
    160   strmData_t *pStrmData,
    161   seqParamSet_t *pSeqParamSet,
    162   nalUnitType_e nalUnitType,
    163   i32 *deltaPicOrderCntBottom);
    164 
    165 u32 h264bsdCheckDeltaPicOrderCnt(
    166   strmData_t *pStrmData,
    167   seqParamSet_t *pSeqParamSet,
    168   nalUnitType_e nalUnitType,
    169   u32 picOrderPresentFlag,
    170   i32 *deltaPicOrderCnt);
    171 
    172 u32 h264bsdCheckRedundantPicCnt(
    173   strmData_t *pStrmData,
    174   seqParamSet_t *pSeqParamSet,
    175   picParamSet_t *pPicParamSet,
    176   nalUnitType_e nalUnitType,
    177   u32 *redundantPicCnt);
    178 
    179 u32 h264bsdCheckPriorPicsFlag(u32 * noOutputOfPriorPicsFlag,
    180                               const strmData_t * pStrmData,
    181                               const seqParamSet_t * pSeqParamSet,
    182                               const picParamSet_t * pPicParamSet,
    183                               nalUnitType_e nalUnitType);
    184 
    185 #endif /* #ifdef H264SWDEC_SLICE_HEADER_H */
    186 
    187