Home | History | Annotate | Download | only in common
      1 /******************************************************************************
      2 *
      3 * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
      4 *
      5 * Licensed under the Apache License, Version 2.0 (the "License");
      6 * you may not use this file except in compliance with the License.
      7 * You may obtain a copy of the License at:
      8 *
      9 * http://www.apache.org/licenses/LICENSE-2.0
     10 *
     11 * Unless required by applicable law or agreed to in writing, software
     12 * distributed under the License is distributed on an "AS IS" BASIS,
     13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 * See the License for the specific language governing permissions and
     15 * limitations under the License.
     16 *
     17 ******************************************************************************/
     18 /**
     19 *******************************************************************************
     20 * @file
     21 *  ihevc_buf_mgr.h
     22 *
     23 * @brief
     24 *  Function declarations used for buffer management
     25 *
     26 * @author
     27 *  Srinivas T
     28 *
     29 * @remarks
     30 *  None
     31 *
     32 *******************************************************************************
     33 */
     34 #ifndef _BUF_MGR_H_
     35 #define _BUF_MGR_H_
     36 
     37 #define BUF_MGR_MAX_CNT 64
     38 
     39 #define BUF_MGR_DEC         1
     40 #define BUF_MGR_REF         (1 << 1)
     41 #define BUF_MGR_DISP        (1 << 2)
     42 
     43 typedef struct
     44 {
     45     /**
     46      * max_buf_cnt
     47      */
     48     UWORD32 u4_max_buf_cnt;
     49 
     50     /**
     51      * active_buf_cnt
     52      */
     53     UWORD32 u4_active_buf_cnt;
     54     /**
     55      *  au4_status[BUF_MGR_MAX_CNT]
     56      */
     57     UWORD32 au4_status[BUF_MGR_MAX_CNT];
     58     /* The last three bit of status are:    */
     59     /* Bit 0 - DEC                          */
     60     /* Bit 1 - REF                          */
     61     /* Bit 2 - DISP                         */
     62 
     63     void    *apv_ptr[BUF_MGR_MAX_CNT];
     64 }buf_mgr_t;
     65 
     66 // intializes the buffer API structure
     67 void ihevc_buf_mgr_init(
     68                 buf_mgr_t *ps_buf_mgr);
     69 
     70 // Add buffer to buffer manager. 0: success, -1: fail (u4_active_buf_cnt has reached u4_max_buf_cnt)
     71 WORD32 ihevc_buf_mgr_add(
     72                 buf_mgr_t *ps_buf_mgr,
     73                 void *pv_ptr,
     74                 WORD32 buf_id);
     75 
     76 // this function will set the buffer status to DEC
     77 void* ihevc_buf_mgr_get_next_free(
     78                 buf_mgr_t *ps_buf_mgr,
     79                 WORD32 *pi4_id);
     80 
     81 // this function will check if there are any free buffers
     82 WORD32 ihevc_buf_mgr_check_free(
     83                 buf_mgr_t *ps_buf_mgr);
     84 
     85 // mask will have who released it: DISP:REF:DEC
     86 WORD32 ihevc_buf_mgr_release(
     87                 buf_mgr_t *ps_buf_mgr,
     88                 WORD32 id,
     89                 UWORD32 mask);
     90 
     91 // sets the status to one or all of DISP:REF:DEC
     92 WORD32 ihevc_buf_mgr_set_status(
     93                 buf_mgr_t *ps_buf_mgr,
     94                 WORD32 id,
     95                 UWORD32 mask);
     96 
     97 // Gets status of the buffer
     98 UWORD32 ihevc_buf_mgr_get_status(
     99                 buf_mgr_t *ps_buf_mgr,
    100                 WORD32 id);
    101 
    102 // pass the ID - buffer will be returned
    103 void* ihevc_buf_mgr_get_buf(
    104                 buf_mgr_t *ps_buf_mgr,
    105                 WORD32 id);
    106 
    107 // will return number of active buffers
    108 UWORD32 ihevc_buf_mgr_get_num_active_buf(
    109                 buf_mgr_t *ps_buf_mgr);
    110 
    111 
    112 
    113 #endif  //_BUF_MGR_H_
    114