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 *******************************************************************************
21 * @file
22 *  ihevc_dpb_mgr.h
23 *
24 * @brief
25 *  Function declarations used for decoded picture buffer management
26 *
27 * @author
28 *  Srinivas T
29 *
30 *
31 * @remarks
32 *  None
33 *
34 *******************************************************************************
35 */
36#ifndef _DPB_MANAGER_H
37#define _DPB_MANAGER_H
38
39/* Temporary definitions. Have to be defined later */
40
41#define MAX_DPB_BUFS                (MAX_DPB_SIZE * 4)
42
43#define MARK_ST_PICNUM_AS_NONREF    1
44#define MARK_LT_INDEX_AS_NONREF     2
45#define MARK_ST_PICNUM_AS_LT_INDEX  3
46#define RESET_REF_PICTURES          5
47
48typedef struct dpb_info_t dpb_info_t;
49
50enum
51{
52    UNUSED_FOR_REF = 0,
53    LONG_TERM_REF,
54    SHORT_TERM_REF,
55};
56struct dpb_info_t
57{
58    /**
59     * Pointer to picture buffer structure
60     */
61    pic_buf_t *ps_pic_buf;
62
63    /**
64     * Link to the DPB buffer with previous pic Num
65     */
66    dpb_info_t *ps_prev_dpb;
67
68};
69
70typedef struct
71{
72    /**
73     * Pointer to the most recent pic Num
74     */
75    dpb_info_t *ps_dpb_head;
76
77    /**
78     * Physical storage for dpbInfo for ref bufs
79     */
80    dpb_info_t as_dpb_info[MAX_DPB_BUFS];
81
82    /**
83     * Number of reference buffers
84     */
85    UWORD8 u1_num_ref_bufs;
86
87}dpb_mgr_t;
88
89void ihevc_dpb_mgr_init(dpb_mgr_t *ps_dpb_mgr);
90
91WORD32 ihevc_dpb_mgr_insert_ref(dpb_mgr_t *ps_dpb_mgr,
92                                pic_buf_t *ps_pic_buf,
93                                WORD32 buf_id);
94
95void ihevc_dpb_mgr_del_ref(dpb_mgr_t *ps_dpb_mgr,
96                           buf_mgr_t *ps_buf_mgr,
97                           WORD32 u4_abs_poc);
98
99pic_buf_t* ihevc_dpb_mgr_get_ref_by_nearest_poc(dpb_mgr_t *ps_dpb_mgr, WORD32 cur_abs_poc);
100
101pic_buf_t* ihevc_dpb_mgr_get_ref_by_poc(dpb_mgr_t *ps_dpb_mgr, WORD32 abs_poc);
102
103pic_buf_t* ihevc_dpb_mgr_get_ref_by_poc_lsb(dpb_mgr_t *ps_dpb_mgr, WORD32 poc_lsb);
104
105void ihevc_dpb_mgr_reset(dpb_mgr_t *ps_dpb_mgr, buf_mgr_t *ps_buf_mgr);
106
107void ihevc_dpb_mgr_release_pics(buf_mgr_t *ps_buf_mgr, UWORD8 u1_disp_bufs);
108
109#endif /*  _DPB_MANAGER_H */
110