1
0

mbuffer.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*!
  2. ***********************************************************************
  3. * \file
  4. * mbuffer.h
  5. *
  6. * \brief
  7. * Frame buffer functions
  8. *
  9. * \author
  10. * Main contributors (see contributors.h for copyright, address and affiliation details)
  11. * - Karsten Sühring <[email protected]>
  12. * - Alexis Michael Tourapis <[email protected]>
  13. * - Jill Boyce <[email protected]>
  14. * - Saurav K Bandyopadhyay <[email protected]>
  15. * - Zhenyu Wu <[email protected]
  16. * - Purvin Pandit <[email protected]>
  17. *
  18. ***********************************************************************
  19. */
  20. #ifndef _MBUFFER_H_
  21. #define _MBUFFER_H_
  22. #include "global.h"
  23. #include <bfc/platform/types.h>
  24. #define MAX_LIST_SIZE 33
  25. //! definition of pic motion parameters
  26. typedef struct pic_motion_params
  27. {
  28. PicMotion **motion[2];
  29. h264_ref_t ***field_references;
  30. byte * mb_field; //!< field macroblock indicator
  31. byte ** field_frame; //!< indicates if co_located is field or frame.
  32. int padding[1];
  33. } PicMotionParams;
  34. typedef struct video_image
  35. {
  36. imgpel **img;
  37. imgpel *base_address;
  38. size_t stride;
  39. struct video_image *next; // for the memory cacher
  40. } VideoImage;
  41. //! definition a picture (field or frame)
  42. typedef struct storable_picture
  43. {
  44. PictureStructure structure;
  45. int poc;
  46. int top_poc;
  47. int bottom_poc;
  48. int frame_poc;
  49. h264_ref_t ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
  50. h264_ref_t frm_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
  51. h264_ref_t top_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
  52. h264_ref_t bottom_ref_pic_num [MAX_NUM_SLICES][6][MAX_LIST_SIZE];
  53. unsigned frame_num;
  54. unsigned recovery_frame;
  55. int pic_num;
  56. int long_term_pic_num;
  57. int long_term_frame_idx;
  58. byte is_long_term;
  59. int used_for_reference;
  60. int is_output;
  61. int non_existing;
  62. short max_slice_id;
  63. int size_x, size_y, size_x_cr, size_y_cr;
  64. int size_x_m1, size_y_m1, size_x_cr_m1, size_y_cr_m1;
  65. int chroma_vector_adjustment;
  66. int coded_frame;
  67. int mb_aff_frame_flag;
  68. unsigned PicWidthInMbs;
  69. unsigned PicSizeInMbs;
  70. //imgpel ** imgY; //!< Y picture component
  71. union
  72. {
  73. VideoImage *plane_images[3]; // to ensure array alignment
  74. struct
  75. {
  76. VideoImage *imgY;
  77. VideoImage *imgUV[2]; //!< U and V picture components
  78. };
  79. };
  80. struct pic_motion_params motion; //!< Motion info
  81. struct pic_motion_params JVmotion[MAX_PLANE]; //!< Motion info for 4:4:4 independent mode decoding
  82. short ** slice_id; //!< reference picture [mb_x][mb_y]
  83. struct storable_picture *top_field; // for mb aff, if frame for referencing the top field
  84. struct storable_picture *bottom_field; // for mb aff, if frame for referencing the bottom field
  85. struct storable_picture *frame; // for mb aff, if field for referencing the combined frame
  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. int chroma_format_idc;
  92. int frame_mbs_only_flag;
  93. int frame_cropping_flag;
  94. int frame_cropping_rect_left_offset;
  95. int frame_cropping_rect_right_offset;
  96. int frame_cropping_rect_top_offset;
  97. int frame_cropping_rect_bottom_offset;
  98. int qp;
  99. int chroma_qp_offset[2];
  100. int slice_qp_delta;
  101. DecRefPicMarking_t *dec_ref_pic_marking_buffer; //!< stores the memory management control operations
  102. // picture error concealment
  103. int concealed_pic; //indicates if this is a concealed picture
  104. // variables for tone mapping
  105. int seiHasTone_mapping;
  106. int tone_mapping_model_id;
  107. int tonemapped_bit_depth;
  108. imgpel* tone_mapping_lut; //!< tone mapping look up table
  109. int retain_count; // benski> we're going to reference count these things
  110. uint64_t time_code; // user-passed timecode for this frame
  111. } StorablePicture;
  112. //! definition a picture (field or frame)
  113. typedef struct colocated_params
  114. {
  115. int mb_adaptive_frame_field_flag;
  116. int size_x, size_y;
  117. byte is_long_term;
  118. MotionParams frame;
  119. MotionParams top;
  120. MotionParams bottom;
  121. } ColocatedParams;
  122. //! Frame Stores for Decoded Picture Buffer
  123. typedef struct frame_store
  124. {
  125. int is_used; //!< 0=empty; 1=top; 2=bottom; 3=both fields (or frame)
  126. int is_reference; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
  127. int is_long_term; //!< 0=not used for ref; 1=top used; 2=bottom used; 3=both fields (or frame) used
  128. 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
  129. int is_non_existent;
  130. unsigned frame_num;
  131. unsigned recovery_frame;
  132. int frame_num_wrap;
  133. int long_term_frame_idx;
  134. int is_output;
  135. int poc;
  136. // picture error concealment
  137. int concealment_reference;
  138. StorablePicture *frame;
  139. StorablePicture *top_field;
  140. StorablePicture *bottom_field;
  141. } FrameStore;
  142. //! Decoded Picture Buffer
  143. typedef struct decoded_picture_buffer
  144. {
  145. VideoParameters *p_Vid;
  146. InputParameters *p_Inp;
  147. FrameStore **fs;
  148. FrameStore **fs_ref;
  149. FrameStore **fs_ltref;
  150. unsigned size;
  151. unsigned used_size;
  152. unsigned ref_frames_in_buffer;
  153. unsigned ltref_frames_in_buffer;
  154. int last_output_poc;
  155. int max_long_term_pic_idx;
  156. int init_done;
  157. int num_ref_frames;
  158. FrameStore *last_picture;
  159. } DecodedPictureBuffer;
  160. extern void init_dpb(VideoParameters *p_Vid);
  161. extern void free_dpb(VideoParameters *p_Vid);
  162. extern FrameStore* alloc_frame_store(void);
  163. extern void free_frame_store(VideoParameters *p_Vid, FrameStore* f);
  164. extern StorablePicture* alloc_storable_picture(VideoParameters *p_Vid, PictureStructure type, int size_x, int size_y, int size_x_cr, int size_y_cr);
  165. extern void free_storable_picture(VideoParameters *p_Vid, StorablePicture* p);
  166. extern void store_picture_in_dpb(VideoParameters *p_Vid, StorablePicture* p);
  167. extern void flush_dpb(VideoParameters *p_Vid);
  168. extern void dpb_split_field (VideoParameters *p_Vid, FrameStore *fs);
  169. extern void dpb_combine_field(VideoParameters *p_Vid, FrameStore *fs);
  170. extern void dpb_combine_field_yuv(VideoParameters *p_Vid, FrameStore *fs);
  171. extern void init_lists (Slice *currSlice);
  172. extern void reorder_ref_pic_list(VideoParameters *p_Vid, StorablePicture **list, char *list_size,
  173. int num_ref_idx_lX_active_minus1, int *reordering_of_pic_nums_idc,
  174. int *abs_diff_pic_num_minus1, int *long_term_pic_idx);
  175. extern void init_mbaff_lists(VideoParameters *p_Vid);
  176. extern void alloc_ref_pic_list_reordering_buffer(Slice *currSlice);
  177. extern void free_ref_pic_list_reordering_buffer(Slice *currSlice);
  178. extern void fill_frame_num_gap(VideoParameters *p_Vid);
  179. extern ColocatedParams* alloc_colocated(VideoParameters *p_Vid, int size_x, int size_y,int mb_adaptive_frame_field_flag);
  180. extern void free_colocated(VideoParameters *p_Vid, ColocatedParams* p);
  181. extern void compute_colocated (Slice *currSlice, ColocatedParams* p, StorablePicture **listX[6]);
  182. extern void compute_colocated_frames_mbs (Slice *currSlice, ColocatedParams* p, StorablePicture **listX[6]);
  183. // For 4:4:4 independent mode
  184. extern void compute_colocated_JV ( Slice *currSlice, ColocatedParams* p, StorablePicture **listX[6]);
  185. extern void copy_storable_param_JV( VideoParameters *p_Vid, PicMotionParams *JVplane, PicMotionParams *motion );
  186. // benski> decoded output pictures
  187. void out_storable_picture_get(VideoParameters *img, StorablePicture **pic);
  188. void out_storable_picture_add(VideoParameters *img, StorablePicture *pic);
  189. void out_storable_pictures_init(VideoParameters *img, size_t count);
  190. void out_storable_pictures_destroy(VideoParameters *img);
  191. #endif