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