00001
00022 #ifndef _MBUFFER_H_
00023 #define _MBUFFER_H_
00024
00025 #include "global.h"
00026
00027 #define MAX_LIST_SIZE 33
00029 typedef struct pic_motion_params
00030 {
00031 int64 *** ref_pic_id;
00032 int64 *** ref_id;
00033 short **** mv;
00034 char *** ref_idx;
00035 byte * mb_field;
00036 byte ** field_frame;
00037 } PicMotionParams;
00038
00040 typedef struct storable_picture
00041 {
00042 PictureStructure structure;
00043
00044 int poc;
00045 int top_poc;
00046 int bottom_poc;
00047 int frame_poc;
00048 int64 ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
00049 int64 frm_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
00050 int64 top_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
00051 int64 bottom_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
00052 unsigned frame_num;
00053 unsigned recovery_frame;
00054
00055 int pic_num;
00056 int long_term_pic_num;
00057 int long_term_frame_idx;
00058
00059 int is_long_term;
00060 int used_for_reference;
00061 int is_output;
00062 int non_existing;
00063
00064 short max_slice_id;
00065
00066 int size_x, size_y, size_x_cr, size_y_cr;
00067 int size_x_m1, size_y_m1, size_x_cr_m1, size_y_cr_m1;
00068 int chroma_vector_adjustment;
00069 int coded_frame;
00070 int MbaffFrameFlag;
00071 unsigned PicWidthInMbs;
00072 unsigned PicSizeInMbs;
00073
00074 imgpel ** imgY;
00075 imgpel *** imgUV;
00076
00077 PicMotionParams motion;
00078 PicMotionParams JVmotion[MAX_PLANE];
00079
00080 short ** slice_id;
00081
00082 struct storable_picture *top_field;
00083 struct storable_picture *bottom_field;
00084 struct storable_picture *frame;
00085
00086 int slice_type;
00087 int idr_flag;
00088 int no_output_of_prior_pics_flag;
00089 int long_term_reference_flag;
00090 int adaptive_ref_pic_buffering_flag;
00091
00092 int chroma_format_idc;
00093 int frame_mbs_only_flag;
00094 int frame_cropping_flag;
00095 int frame_cropping_rect_left_offset;
00096 int frame_cropping_rect_right_offset;
00097 int frame_cropping_rect_top_offset;
00098 int frame_cropping_rect_bottom_offset;
00099 int qp;
00100 int chroma_qp_offset[2];
00101 int slice_qp_delta;
00102 DecRefPicMarking_t *dec_ref_pic_marking_buffer;
00103
00104
00105 int concealed_pic;
00106
00107
00108 int seiHasTone_mapping;
00109 int tone_mapping_model_id;
00110 int tonemapped_bit_depth;
00111 imgpel* tone_mapping_lut;
00112 } StorablePicture;
00113
00115 typedef struct motion_params
00116 {
00117 int64 *** ref_pic_id;
00118 short **** mv;
00119 char *** ref_idx;
00120 byte ** moving_block;
00121 } MotionParams;
00122
00124 typedef struct colocated_params
00125 {
00126 int mb_adaptive_frame_field_flag;
00127 int size_x, size_y;
00128 byte is_long_term;
00129
00130 MotionParams frame;
00131 MotionParams top;
00132 MotionParams bottom;
00133
00134 } ColocatedParams;
00135
00137 typedef struct frame_store
00138 {
00139 int is_used;
00140 int is_reference;
00141 int is_long_term;
00142 int is_orig_reference;
00143
00144 int is_non_existent;
00145
00146 unsigned frame_num;
00147 unsigned recovery_frame;
00148
00149 int frame_num_wrap;
00150 int long_term_frame_idx;
00151 int is_output;
00152 int poc;
00153
00154
00155 int concealment_reference;
00156
00157 StorablePicture *frame;
00158 StorablePicture *top_field;
00159 StorablePicture *bottom_field;
00160
00161 } FrameStore;
00162
00163
00165 typedef struct decoded_picture_buffer
00166 {
00167 FrameStore **fs;
00168 FrameStore **fs_ref;
00169 FrameStore **fs_ltref;
00170 unsigned size;
00171 unsigned used_size;
00172 unsigned ref_frames_in_buffer;
00173 unsigned ltref_frames_in_buffer;
00174 int last_output_poc;
00175 int max_long_term_pic_idx;
00176
00177 int init_done;
00178 int num_ref_frames;
00179
00180 FrameStore *last_picture;
00181 } DecodedPictureBuffer;
00182
00183
00184 extern DecodedPictureBuffer dpb;
00185 extern StorablePicture **listX[6];
00186 extern int listXsize[6];
00187
00188 void init_dpb(void);
00189 void free_dpb(void);
00190 FrameStore* alloc_frame_store(void);
00191 void free_frame_store(FrameStore* f);
00192 StorablePicture* alloc_storable_picture(PictureStructure type, int size_x, int size_y, int size_x_cr, int size_y_cr);
00193 void free_storable_picture(StorablePicture* p);
00194 void store_picture_in_dpb(StorablePicture* p);
00195 void flush_dpb(void);
00196
00197 void dpb_split_field(FrameStore *fs);
00198 void dpb_combine_field(FrameStore *fs);
00199 void dpb_combine_field_yuv(FrameStore *fs);
00200
00201 void init_lists(int currSliceType, PictureStructure currPicStructure);
00202 void reorder_ref_pic_list(StorablePicture **list, int *list_size,
00203 int num_ref_idx_lX_active_minus1, int *reordering_of_pic_nums_idc,
00204 int *abs_diff_pic_num_minus1, int *long_term_pic_idx);
00205
00206 void init_mbaff_lists(void);
00207 void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
00208 void free_ref_pic_list_reordering_buffer(Slice *currSlice);
00209
00210 void fill_frame_num_gap(ImageParameters *img);
00211
00212 ColocatedParams* alloc_colocated(int size_x, int size_y,int mb_adaptive_frame_field_flag);
00213 void free_colocated(ColocatedParams* p);
00214 void compute_colocated(ColocatedParams* p, StorablePicture **listX[6]);
00215
00216
00217 void compute_colocated_JV(ColocatedParams* p, StorablePicture **listX[6]);
00218 void copy_storable_param_JV( PicMotionParams *JVplane, PicMotionParams *motion );
00219
00220 #endif
00221