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_STORAGE_H
     29 #define H264SWDEC_STORAGE_H
     30 
     31 /*------------------------------------------------------------------------------
     32     1. Include headers
     33 ------------------------------------------------------------------------------*/
     34 
     35 #include "basetype.h"
     36 #include "h264bsd_cfg.h"
     37 #include "h264bsd_seq_param_set.h"
     38 #include "h264bsd_pic_param_set.h"
     39 #include "h264bsd_macroblock_layer.h"
     40 #include "h264bsd_nal_unit.h"
     41 #include "h264bsd_slice_header.h"
     42 #include "h264bsd_seq_param_set.h"
     43 #include "h264bsd_dpb.h"
     44 #include "h264bsd_pic_order_cnt.h"
     45 
     46 /*------------------------------------------------------------------------------
     47     2. Module defines
     48 ------------------------------------------------------------------------------*/
     49 
     50 /*------------------------------------------------------------------------------
     51     3. Data types
     52 ------------------------------------------------------------------------------*/
     53 
     54 typedef struct
     55 {
     56     u32 sliceId;
     57     u32 numDecodedMbs;
     58     u32 lastMbAddr;
     59 } sliceStorage_t;
     60 
     61 /* structure to store parameters needed for access unit boundary checking */
     62 typedef struct
     63 {
     64     nalUnit_t nuPrev[1];
     65     u32 prevFrameNum;
     66     u32 prevIdrPicId;
     67     u32 prevPicOrderCntLsb;
     68     i32 prevDeltaPicOrderCntBottom;
     69     i32 prevDeltaPicOrderCnt[2];
     70     u32 firstCallFlag;
     71 } aubCheck_t;
     72 
     73 /* storage data structure, holds all data of a decoder instance */
     74 typedef struct
     75 {
     76     /* active paramet set ids and pointers */
     77     u32 oldSpsId;
     78     u32 activePpsId;
     79     u32 activeSpsId;
     80     picParamSet_t *activePps;
     81     seqParamSet_t *activeSps;
     82     seqParamSet_t *sps[MAX_NUM_SEQ_PARAM_SETS];
     83     picParamSet_t *pps[MAX_NUM_PIC_PARAM_SETS];
     84 
     85     /* current slice group map, recomputed for each slice */
     86     u32 *sliceGroupMap;
     87 
     88     u32 picSizeInMbs;
     89 
     90     /* this flag is set after all macroblocks of a picture successfully
     91      * decoded -> redundant slices not decoded */
     92     u32 skipRedundantSlices;
     93     u32 picStarted;
     94 
     95     /* flag to indicate if current access unit contains any valid slices */
     96     u32 validSliceInAccessUnit;
     97 
     98     /* store information needed for handling of slice decoding */
     99     sliceStorage_t slice[1];
    100 
    101     /* number of concealed macroblocks in the current image */
    102     u32 numConcealedMbs;
    103 
    104     /* picId given by application */
    105     u32 currentPicId;
    106 
    107     /* macroblock specific storages, size determined by image dimensions */
    108     mbStorage_t *mb;
    109 
    110     /* flag to store noOutputReordering flag set by the application */
    111     u32 noReordering;
    112 
    113     /* DPB */
    114     dpbStorage_t dpb[1];
    115 
    116     /* structure to store picture order count related information */
    117     pocStorage_t poc[1];
    118 
    119     /* access unit boundary checking related data */
    120     aubCheck_t aub[1];
    121 
    122     /* current processed image */
    123     image_t currImage[1];
    124 
    125     /* last valid NAL unit header is stored here */
    126     nalUnit_t prevNalUnit[1];
    127 
    128     /* slice header, second structure used as a temporary storage while
    129      * decoding slice header, first one stores last successfully decoded
    130      * slice header */
    131     sliceHeader_t sliceHeader[2];
    132 
    133     /* fields to store old stream buffer pointers, needed when only part of
    134      * a stream buffer is processed by h264bsdDecode function */
    135     u32 prevBufNotFinished;
    136     u8 *prevBufPointer;
    137     u32 prevBytesConsumed;
    138     strmData_t strm[1];
    139 
    140     /* macroblock layer structure, there is no need to store this but it
    141      * would have increased the stack size excessively and needed to be
    142      * allocated from head -> easiest to put it here */
    143     macroblockLayer_t *mbLayer;
    144 
    145     u32 pendingActivation; /* Activate parameter sets after returning
    146                               HEADERS_RDY to the user */
    147     u32 intraConcealmentFlag; /* 0 gray picture for corrupted intra
    148                                  1 previous frame used if available */
    149 } storage_t;
    150 
    151 /*------------------------------------------------------------------------------
    152     4. Function prototypes
    153 ------------------------------------------------------------------------------*/
    154 
    155 void h264bsdInitStorage(storage_t *pStorage);
    156 void h264bsdResetStorage(storage_t *pStorage);
    157 u32 h264bsdIsStartOfPicture(storage_t *pStorage);
    158 u32 h264bsdIsEndOfPicture(storage_t *pStorage);
    159 u32 h264bsdStoreSeqParamSet(storage_t *pStorage, seqParamSet_t *pSeqParamSet);
    160 u32 h264bsdStorePicParamSet(storage_t *pStorage, picParamSet_t *pPicParamSet);
    161 u32 h264bsdActivateParamSets(storage_t *pStorage, u32 ppsId, u32 isIdr);
    162 void h264bsdComputeSliceGroupMap(storage_t *pStorage,
    163     u32 sliceGroupChangeCycle);
    164 
    165 u32 h264bsdCheckAccessUnitBoundary(
    166   strmData_t *strm,
    167   nalUnit_t *nuNext,
    168   storage_t *storage,
    169   u32 *accessUnitBoundaryFlag);
    170 
    171 u32 h264bsdValidParamSets(storage_t *pStorage);
    172 
    173 #endif /* #ifdef H264SWDEC_STORAGE_H */
    174 
    175