1 |
14 |
jamey.hick |
|
2 |
|
|
/*!
|
3 |
|
|
***********************************************************************
|
4 |
|
|
* \file
|
5 |
|
|
* mbuffer.h
|
6 |
|
|
*
|
7 |
|
|
* \brief
|
8 |
|
|
* Frame buffer functions
|
9 |
|
|
*
|
10 |
|
|
* \author
|
11 |
|
|
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
12 |
|
|
* - Karsten Sühring <suehring@hhi.de>
|
13 |
|
|
* - Jill Boyce <jill.boyce@thomson.net>
|
14 |
|
|
* - Saurav K Bandyopadhyay <saurav@ieee.org>
|
15 |
|
|
* - Zhenyu Wu <Zhenyu.Wu@thomson.net
|
16 |
|
|
* - Purvin Pandit <Purvin.Pandit@thomson.net>
|
17 |
|
|
*
|
18 |
|
|
***********************************************************************
|
19 |
|
|
*/
|
20 |
|
|
#ifndef _MBUFFER_H_
|
21 |
|
|
#define _MBUFFER_H_
|
22 |
|
|
|
23 |
|
|
#include "global.h"
|
24 |
|
|
|
25 |
|
|
#define MAX_LIST_SIZE 33
|
26 |
|
|
|
27 |
|
|
//! definition a picture (field or frame)
|
28 |
|
|
typedef struct storable_picture
|
29 |
|
|
{
|
30 |
|
|
PictureStructure structure;
|
31 |
|
|
|
32 |
|
|
int poc;
|
33 |
|
|
int top_poc;
|
34 |
|
|
int bottom_poc;
|
35 |
|
|
int frame_poc;
|
36 |
|
|
int64 ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
|
37 |
|
|
int64 frm_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
|
38 |
|
|
int64 top_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
|
39 |
|
|
int64 bottom_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
|
40 |
|
|
unsigned frame_num;
|
41 |
|
|
unsigned recovery_frame;
|
42 |
|
|
|
43 |
|
|
int pic_num;
|
44 |
|
|
int long_term_pic_num;
|
45 |
|
|
int long_term_frame_idx;
|
46 |
|
|
|
47 |
|
|
int is_long_term;
|
48 |
|
|
int used_for_reference;
|
49 |
|
|
int is_output;
|
50 |
|
|
int non_existing;
|
51 |
|
|
|
52 |
|
|
short max_slice_id;
|
53 |
|
|
|
54 |
|
|
int size_x, size_y, size_x_cr, size_y_cr;
|
55 |
|
|
int size_x_m1, size_y_m1, size_x_cr_m1, size_y_cr_m1;
|
56 |
|
|
int chroma_vector_adjustment;
|
57 |
|
|
int coded_frame;
|
58 |
|
|
int MbaffFrameFlag;
|
59 |
|
|
unsigned PicWidthInMbs;
|
60 |
|
|
unsigned PicSizeInMbs;
|
61 |
|
|
|
62 |
|
|
imgpel ** imgY; //!< Y picture component
|
63 |
|
|
imgpel *** imgUV; //!< U and V picture components
|
64 |
|
|
|
65 |
|
|
byte * mb_field; //!< field macroblock indicator
|
66 |
|
|
|
67 |
|
|
short ** slice_id; //!< reference picture [mb_x][mb_y]
|
68 |
|
|
|
69 |
|
|
char *** ref_idx; //!< reference picture [list][subblock_y][subblock_x]
|
70 |
|
|
|
71 |
|
|
int64 *** ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
|
72 |
|
|
// (not simply index)
|
73 |
|
|
|
74 |
|
|
int64 *** ref_id; //!< reference picture identifier [list][subblock_y][subblock_x]
|
75 |
|
|
// (not simply index)
|
76 |
|
|
|
77 |
|
|
short **** mv; //!< motion vector [list][subblock_y][subblock_x][component]
|
78 |
|
|
|
79 |
|
|
byte ** moving_block;
|
80 |
|
|
byte ** field_frame; //!< indicates if co_located is field or frame.
|
81 |
|
|
|
82 |
|
|
struct storable_picture *top_field; // for mb aff, if frame for referencing the top field
|
83 |
|
|
struct storable_picture *bottom_field; // for mb aff, if frame for referencing the bottom field
|
84 |
|
|
struct storable_picture *frame; // for mb aff, if field for referencing the combined frame
|
85 |
|
|
|
86 |
|
|
int slice_type;
|
87 |
|
|
int idr_flag;
|
88 |
|
|
int no_output_of_prior_pics_flag;
|
89 |
|
|
int long_term_reference_flag;
|
90 |
|
|
int adaptive_ref_pic_buffering_flag;
|
91 |
|
|
|
92 |
|
|
int chroma_format_idc;
|
93 |
|
|
int frame_mbs_only_flag;
|
94 |
|
|
int frame_cropping_flag;
|
95 |
|
|
int frame_cropping_rect_left_offset;
|
96 |
|
|
int frame_cropping_rect_right_offset;
|
97 |
|
|
int frame_cropping_rect_top_offset;
|
98 |
|
|
int frame_cropping_rect_bottom_offset;
|
99 |
|
|
int qp;
|
100 |
|
|
int chroma_qp_offset[2];
|
101 |
|
|
int slice_qp_delta;
|
102 |
|
|
DecRefPicMarking_t *dec_ref_pic_marking_buffer; //!< stores the memory management control operations
|
103 |
|
|
|
104 |
|
|
// picture error concealment
|
105 |
|
|
int concealed_pic; //indicates if this is a concealed picutre
|
106 |
|
|
|
107 |
|
|
} StorablePicture;
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
//! definition a picture (field or frame)
|
111 |
|
|
typedef struct colocated_params
|
112 |
|
|
{
|
113 |
|
|
int mb_adaptive_frame_field_flag;
|
114 |
|
|
int size_x, size_y;
|
115 |
|
|
|
116 |
|
|
int64 ref_pic_num[6][MAX_LIST_SIZE];
|
117 |
|
|
|
118 |
|
|
char *** ref_idx; //!< reference picture [list][subblock_y][subblock_x]
|
119 |
|
|
int64 *** ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
|
120 |
|
|
short **** mv; //!< motion vector [list][subblock_y][subblock_x][component]
|
121 |
|
|
byte ** moving_block;
|
122 |
|
|
|
123 |
|
|
// Top field params
|
124 |
|
|
int64 top_ref_pic_num[6][MAX_LIST_SIZE];
|
125 |
|
|
char *** top_ref_idx; //!< reference picture [list][subblock_y][subblock_x]
|
126 |
|
|
int64 *** top_ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
|
127 |
|
|
short **** top_mv; //!< motion vector [list][subblock_y][subblock_x][component]
|
128 |
|
|
byte ** top_moving_block;
|
129 |
|
|
|
130 |
|
|
// Bottom field params
|
131 |
|
|
int64 bottom_ref_pic_num[6][MAX_LIST_SIZE];
|
132 |
|
|
char *** bottom_ref_idx; //!< reference picture [list][subblock_y][subblock_x]
|
133 |
|
|
int64 *** bottom_ref_pic_id; //!< reference picture identifier [list][subblock_y][subblock_x]
|
134 |
|
|
short **** bottom_mv; //!< motion vector [list][subblock_y][subblock_x][component]
|
135 |
|
|
byte ** bottom_moving_block;
|
136 |
|
|
|
137 |
|
|
byte is_long_term;
|
138 |
|
|
byte ** field_frame; //!< indicates if co_located is field or frame.
|
139 |
|
|
|
140 |
|
|
} ColocatedParams;
|
141 |
|
|
|
142 |
|
|
//! Frame Stores for Decoded Picture Buffer
|
143 |
|
|
typedef struct frame_store
|
144 |
|
|
{
|
145 |
|
|
int is_used; //!< 0=empty; 1=top; 2=bottom; 3=both fields (or frame)
|
146 |
|
|
int is_reference; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
|
147 |
|
|
int is_long_term; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
|
148 |
|
|
int is_orig_reference; //!< original marking by nal_ref_idc: 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
|
149 |
|
|
|
150 |
|
|
int is_non_existent;
|
151 |
|
|
|
152 |
|
|
unsigned frame_num;
|
153 |
|
|
unsigned recovery_frame;
|
154 |
|
|
|
155 |
|
|
int frame_num_wrap;
|
156 |
|
|
int long_term_frame_idx;
|
157 |
|
|
int is_output;
|
158 |
|
|
int poc;
|
159 |
|
|
|
160 |
|
|
// picture error concealment
|
161 |
|
|
int concealment_reference;
|
162 |
|
|
|
163 |
|
|
StorablePicture *frame;
|
164 |
|
|
StorablePicture *top_field;
|
165 |
|
|
StorablePicture *bottom_field;
|
166 |
|
|
|
167 |
|
|
} FrameStore;
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
//! Decoded Picture Buffer
|
171 |
|
|
typedef struct decoded_picture_buffer
|
172 |
|
|
{
|
173 |
|
|
FrameStore **fs;
|
174 |
|
|
FrameStore **fs_ref;
|
175 |
|
|
FrameStore **fs_ltref;
|
176 |
|
|
unsigned size;
|
177 |
|
|
unsigned used_size;
|
178 |
|
|
unsigned ref_frames_in_buffer;
|
179 |
|
|
unsigned ltref_frames_in_buffer;
|
180 |
|
|
int last_output_poc;
|
181 |
|
|
int max_long_term_pic_idx;
|
182 |
|
|
|
183 |
|
|
int init_done;
|
184 |
|
|
int num_ref_frames;
|
185 |
|
|
|
186 |
|
|
FrameStore *last_picture;
|
187 |
|
|
} DecodedPictureBuffer;
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
extern DecodedPictureBuffer dpb;
|
191 |
|
|
extern StorablePicture **listX[6];
|
192 |
|
|
extern int listXsize[6];
|
193 |
|
|
|
194 |
|
|
void init_dpb(void);
|
195 |
|
|
void free_dpb(void);
|
196 |
|
|
FrameStore* alloc_frame_store(void);
|
197 |
|
|
void free_frame_store(FrameStore* f);
|
198 |
|
|
StorablePicture* alloc_storable_picture(PictureStructure type, int size_x, int size_y, int size_x_cr, int size_y_cr);
|
199 |
|
|
void free_storable_picture(StorablePicture* p);
|
200 |
|
|
void store_picture_in_dpb(StorablePicture* p);
|
201 |
|
|
void flush_dpb(void);
|
202 |
|
|
|
203 |
|
|
void dpb_split_field(FrameStore *fs);
|
204 |
|
|
void dpb_combine_field(FrameStore *fs);
|
205 |
|
|
void dpb_combine_field_yuv(FrameStore *fs);
|
206 |
|
|
|
207 |
|
|
void init_lists(int currSliceType, PictureStructure currPicStructure);
|
208 |
|
|
void reorder_ref_pic_list(StorablePicture **list, int *list_size,
|
209 |
|
|
int num_ref_idx_lX_active_minus1, int *reordering_of_pic_nums_idc,
|
210 |
|
|
int *abs_diff_pic_num_minus1, int *long_term_pic_idx);
|
211 |
|
|
|
212 |
|
|
void init_mbaff_lists();
|
213 |
|
|
void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
|
214 |
|
|
void free_ref_pic_list_reordering_buffer(Slice *currSlice);
|
215 |
|
|
|
216 |
|
|
void fill_frame_num_gap(ImageParameters *img);
|
217 |
|
|
|
218 |
|
|
ColocatedParams* alloc_colocated(int size_x, int size_y,int mb_adaptive_frame_field_flag);
|
219 |
|
|
void free_colocated(ColocatedParams* p);
|
220 |
|
|
void compute_colocated(ColocatedParams* p, StorablePicture **listX[6]);
|
221 |
|
|
|
222 |
|
|
#endif
|
223 |
|
|
|