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_DPB_H
     29 #define H264SWDEC_DPB_H
     30 
     31 /*------------------------------------------------------------------------------
     32     1. Include headers
     33 ------------------------------------------------------------------------------*/
     34 
     35 #include "basetype.h"
     36 #include "h264bsd_slice_header.h"
     37 #include "h264bsd_image.h"
     38 
     39 /*------------------------------------------------------------------------------
     40     2. Module defines
     41 ------------------------------------------------------------------------------*/
     42 
     43 /*------------------------------------------------------------------------------
     44     3. Data types
     45 ------------------------------------------------------------------------------*/
     46 
     47 /* enumeration to represent status of buffered image */
     48 typedef enum {
     49     UNUSED = 0,
     50     NON_EXISTING,
     51     SHORT_TERM,
     52     LONG_TERM
     53 } dpbPictureStatus_e;
     54 
     55 /* structure to represent a buffered picture */
     56 typedef struct {
     57     u8 *data;           /* 16-byte aligned pointer of pAllocatedData */
     58     u8 *pAllocatedData; /* allocated picture pointer; (size + 15) bytes */
     59     i32 picNum;
     60     u32 frameNum;
     61     i32 picOrderCnt;
     62     dpbPictureStatus_e status;
     63     u32 toBeDisplayed;
     64     u32 picId;
     65     u32 numErrMbs;
     66     u32 isIdr;
     67 } dpbPicture_t;
     68 
     69 /* structure to represent display image output from the buffer */
     70 typedef struct {
     71     u8 *data;
     72     u32 picId;
     73     u32 numErrMbs;
     74     u32 isIdr;
     75 } dpbOutPicture_t;
     76 
     77 /* structure to represent DPB */
     78 typedef struct {
     79     dpbPicture_t *buffer;
     80     dpbPicture_t **list;
     81     dpbPicture_t *currentOut;
     82     dpbOutPicture_t *outBuf;
     83     u32 numOut;
     84     u32 outIndex;
     85     u32 maxRefFrames;
     86     u32 dpbSize;
     87     u32 maxFrameNum;
     88     u32 maxLongTermFrameIdx;
     89     u32 numRefFrames;
     90     u32 fullness;
     91     u32 prevRefFrameNum;
     92     u32 lastContainsMmco5;
     93     u32 noReordering;
     94     u32 flushed;
     95 } dpbStorage_t;
     96 
     97 /*------------------------------------------------------------------------------
     98     4. Function prototypes
     99 ------------------------------------------------------------------------------*/
    100 
    101 u32 h264bsdInitDpb(
    102   dpbStorage_t *dpb,
    103   u32 picSizeInMbs,
    104   u32 dpbSize,
    105   u32 numRefFrames,
    106   u32 maxFrameNum,
    107   u32 noReordering);
    108 
    109 u32 h264bsdResetDpb(
    110   dpbStorage_t *dpb,
    111   u32 picSizeInMbs,
    112   u32 dpbSize,
    113   u32 numRefFrames,
    114   u32 maxFrameNum,
    115   u32 noReordering);
    116 
    117 void h264bsdInitRefPicList(dpbStorage_t *dpb);
    118 
    119 u8* h264bsdAllocateDpbImage(dpbStorage_t *dpb);
    120 
    121 u8* h264bsdGetRefPicData(dpbStorage_t *dpb, u32 index);
    122 
    123 u32 h264bsdReorderRefPicList(
    124   dpbStorage_t *dpb,
    125   refPicListReordering_t *order,
    126   u32 currFrameNum,
    127   u32 numRefIdxActive);
    128 
    129 u32 h264bsdMarkDecRefPic(
    130   dpbStorage_t *dpb,
    131   decRefPicMarking_t *mark,
    132   image_t *image,
    133   u32 frameNum,
    134   i32 picOrderCnt,
    135   u32 isIdr,
    136   u32 picId,
    137   u32 numErrMbs);
    138 
    139 u32 h264bsdCheckGapsInFrameNum(dpbStorage_t *dpb, u32 frameNum, u32 isRefPic,
    140                                u32 gapsAllowed);
    141 
    142 dpbOutPicture_t* h264bsdDpbOutputPicture(dpbStorage_t *dpb);
    143 
    144 void h264bsdFlushDpb(dpbStorage_t *dpb);
    145 
    146 void h264bsdFreeDpb(dpbStorage_t *dpb);
    147 
    148 #endif /* #ifdef H264SWDEC_DPB_H */
    149 
    150