00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef _MBUFFER_H_
00016 #define _MBUFFER_H_
00017
00018 #include "global.h"
00019 #include "enc_statistics.h"
00020
00021 #define MAX_LIST_SIZE 33
00022
00023 typedef struct picture_stats
00024 {
00025 double dsum[3];
00026 double dvar[3];
00027 } PictureStats;
00028
00029
00030
00031 typedef struct pic_motion_params
00032 {
00033 int64 *** ref_pic_id;
00034 int64 *** ref_id;
00035 short **** mv;
00036 char *** ref_idx;
00037 byte * mb_field;
00038 byte ** field_frame;
00039
00040 } PicMotionParams;
00041
00042
00043 typedef struct storable_picture
00044 {
00045 PictureStructure structure;
00046
00047 int poc;
00048 int top_poc;
00049 int bottom_poc;
00050 int frame_poc;
00051 int order_num;
00052 int64 ref_pic_num[6][MAX_LIST_SIZE];
00053 int64 frm_ref_pic_num[6][MAX_LIST_SIZE];
00054 int64 top_ref_pic_num[6][MAX_LIST_SIZE];
00055 int64 bottom_ref_pic_num[6][MAX_LIST_SIZE];
00056 unsigned frame_num;
00057 int pic_num;
00058 int long_term_pic_num;
00059 int long_term_frame_idx;
00060
00061 int is_long_term;
00062 int used_for_reference;
00063 int is_output;
00064 int non_existing;
00065
00066 int size_x, size_y, size_x_cr, size_y_cr;
00067 int size_x_padded, size_y_padded;
00068 int size_x_pad, size_y_pad;
00069 int size_x_cr_pad, size_y_cr_pad;
00070 int chroma_vector_adjustment;
00071 int coded_frame;
00072 int MbaffFrameFlag;
00073
00074 imgpel ** imgY;
00075 imgpel **** imgY_sub;
00076 imgpel *** imgUV;
00077 imgpel *****imgUV_sub;
00078
00079
00080 imgpel *** dec_imgY;
00081 imgpel **** dec_imgUV;
00082 imgpel *** p_dec_img[MAX_PLANE];
00083
00084 byte *** mb_error_map;
00085
00086 imgpel ** p_img[MAX_PLANE];
00087 imgpel **** p_img_sub[MAX_PLANE];
00088 imgpel ** p_curr_img;
00089 imgpel **** p_curr_img_sub;
00090
00091
00092 PicMotionParams motion;
00093 PicMotionParams JVmotion[MAX_PLANE];
00094
00095 int colour_plane_id;
00096
00097 struct storable_picture *top_field;
00098 struct storable_picture *bottom_field;
00099 struct storable_picture *frame;
00100
00101 int chroma_format_idc;
00102 int frame_mbs_only_flag;
00103 int frame_cropping_flag;
00104 int frame_cropping_rect_left_offset;
00105 int frame_cropping_rect_right_offset;
00106 int frame_cropping_rect_top_offset;
00107 int frame_cropping_rect_bottom_offset;
00108
00109 PictureStats p_stats;
00110 StatParameters stats;
00111
00112 int type;
00113
00114 } StorablePicture;
00115
00116
00117 typedef struct motion_params
00118 {
00119 int64 *** ref_pic_id;
00120 short **** mv;
00121 char *** ref_idx;
00122 byte ** moving_block;
00123 } MotionParams;
00124
00125
00126 typedef struct colocated_params
00127 {
00128 int mb_adaptive_frame_field_flag;
00129 int size_x, size_y;
00130 byte is_long_term;
00131
00132 MotionParams frame;
00133 MotionParams top;
00134 MotionParams bottom;
00135
00136 } ColocatedParams;
00137
00138
00139 typedef struct frame_store
00140 {
00141 int is_used;
00142 int is_reference;
00143 int is_long_term;
00144 int is_orig_reference;
00145
00146 int is_non_existent;
00147
00148 unsigned frame_num;
00149 int frame_num_wrap;
00150 int long_term_frame_idx;
00151 int is_output;
00152 int poc;
00153
00154 StorablePicture *frame;
00155 StorablePicture *top_field;
00156 StorablePicture *bottom_field;
00157 } FrameStore;
00158
00159
00160
00161 typedef struct decoded_picture_buffer
00162 {
00163 FrameStore **fs;
00164 FrameStore **fs_ref;
00165 FrameStore **fs_ltref;
00166 unsigned size;
00167 unsigned used_size;
00168 unsigned ref_frames_in_buffer;
00169 unsigned ltref_frames_in_buffer;
00170 int last_output_poc;
00171 int max_long_term_pic_idx;
00172
00173 int init_done;
00174
00175 FrameStore *last_picture;
00176 } DecodedPictureBuffer;
00177
00178
00179 extern DecodedPictureBuffer dpb;
00180 extern StorablePicture **listX[6];
00181 extern int listXsize[6];
00182
00183 void init_dpb(void);
00184 void free_dpb(void);
00185 FrameStore* alloc_frame_store(void);
00186 void free_frame_store(FrameStore* f);
00187 StorablePicture* alloc_storable_picture(PictureStructure type, int size_x, int size_y, int size_x_cr, int size_y_cr);
00188 void free_storable_picture(StorablePicture* p);
00189 void store_picture_in_dpb(StorablePicture* p);
00190 void replace_top_pic_with_frame(StorablePicture* p);
00191 void flush_dpb(void);
00192
00193 void dpb_split_field(FrameStore *fs);
00194 void dpb_combine_field(FrameStore *fs);
00195 void dpb_combine_field_yuv(FrameStore *fs);
00196
00197 void init_lists(int currSliceType, PictureStructure currPicStructure);
00198 void reorder_ref_pic_list(StorablePicture **list, int *list_size,
00199 int num_ref_idx_lX_active_minus1, int *reordering_of_pic_nums_idc,
00200 int *abs_diff_pic_num_minus1, int *long_term_pic_idx);
00201
00202 void init_mbaff_lists(void);
00203 void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
00204 void free_ref_pic_list_reordering_buffer(Slice *currSlice);
00205
00206 void fill_frame_num_gap(ImageParameters *img);
00207
00208 ColocatedParams* alloc_colocated(int size_x, int size_y,int mb_adaptive_frame_field_flag);
00209 void free_colocated(ColocatedParams* p);
00210 void compute_colocated(ColocatedParams* p, StorablePicture **listX[6]);
00211
00212
00213 void compute_colocated_JV(ColocatedParams* p, StorablePicture **listX[6]);
00214 void copy_storable_param_JV( int nplane, StorablePicture *d, StorablePicture *s );
00215
00216 #endif
00217