|  | #ifndef AOM_AV1_ENCODER_INTERINTRA_ML_DATA_COLLECT_H_ | 
|  | #define AOM_AV1_ENCODER_INTERINTRA_ML_DATA_COLLECT_H_ | 
|  |  | 
|  | #include <stdint.h> | 
|  | #include "av1/encoder/block.h" | 
|  | #include "av1/encoder/encoder.h" | 
|  |  | 
|  | #ifdef __cplusplus | 
|  | extern "C" { | 
|  | #endif | 
|  |  | 
|  | // Data collection for the interintra ML training data. The program must be | 
|  | // run in single-threaded mode. | 
|  |  | 
|  | // Build the inter-predictor (with border), and record it, along with the | 
|  | // intra-predictor and source image. Note that only a subset of the border | 
|  | // may end up being recorded. | 
|  | void av1_interintra_ml_data_collect(const AV1_COMP *const cpi, | 
|  | MACROBLOCK *const x, BLOCK_SIZE bsize); | 
|  |  | 
|  | // After the data is collected, it is not immediately written out, since the | 
|  | // encoder may later decide to save it as a skip block. This function | 
|  | // indicates that the data is safe to write out (not a skip block). | 
|  | void av1_interintra_ml_data_collect_finalize(); | 
|  |  | 
|  | // The block ended up being skipped. Abandon the previously collected data. | 
|  | void av1_interintra_ml_data_collect_abandon(); | 
|  |  | 
|  | // Is this block a valid block for collecting interintra ML data? | 
|  | bool av1_interintra_ml_data_collect_valid(MACROBLOCK *const x, | 
|  | BLOCK_SIZE bsize); | 
|  |  | 
|  | // These functions / data structures are internal implementation details, but | 
|  | // are exposed for testing. | 
|  |  | 
|  | // The data structure encoding the information we wish to write out, | 
|  | // for a given plane. | 
|  | typedef struct IIMLPlaneInfo { | 
|  | // Width and height of the block. | 
|  | uint8_t width; | 
|  | uint8_t height; | 
|  | // Plane, one of AOM_PLANE_Y, AOM_PLANE_U, AOM_PLANE_V. | 
|  | uint8_t plane; | 
|  | // Number of bits per pixel, either 8, 10, or 12. | 
|  | uint8_t bitdepth; | 
|  | // The border width recorded for this block. | 
|  | uint8_t border; | 
|  | // The location of this block (in pixels) in the video. | 
|  | int x; | 
|  | int y; | 
|  | int frame_order_hint; | 
|  | // Information about the rate-cost calculation. | 
|  | int32_t lambda; | 
|  | uint8_t ref_q; | 
|  | uint8_t base_q; | 
|  |  | 
|  | // The original source block. Size is width * height. If bit-depth | 
|  | // is 10 or 12, it is actually a uint16_t pointer. | 
|  | uint8_t *source_image; | 
|  |  | 
|  | // The top (border + width) * (border) pixels, followed by | 
|  | // the (border * height) left pixels, in raster scan order, of | 
|  | // the top-left border of the intra-predictor. If bit-depth is | 
|  | // 10 or 12, actually a uint16_t pointer. | 
|  | uint8_t *intrapred_lshape; | 
|  |  | 
|  | // The (border + width) * (border + height) inter-predictor. | 
|  | // The inter-predictor starts at the (width * border + border) offset. | 
|  | // If bit-depth is 10 or 12, actually a uint16_t pointer. | 
|  | uint8_t *interpred; | 
|  | } IIMLPlaneInfo; | 
|  |  | 
|  | // Serialize the plane info data structure into a byte array. Allocates | 
|  | // memory into buf (the caller must free it afterward). | 
|  | void av1_interintra_ml_data_collect_serialize(IIMLPlaneInfo *info, | 
|  | uint8_t **buf, size_t *buf_size); | 
|  |  | 
|  | // Copy over the top and left pixels (in an L shape) from the top-left | 
|  | // corner, into the buffer. Note that source points to the start of the | 
|  | // intrapred block (the border is at a negative offset). | 
|  | void av1_interintra_ml_data_collect_copy_intrapred_lshape( | 
|  | uint8_t *dst, const uint8_t *src, int src_stride, int width, int height, | 
|  | int border, int bitdepth, bool is_src_hbd); | 
|  |  | 
|  | #ifdef __cplusplus | 
|  | }  // extern "C" | 
|  | #endif | 
|  |  | 
|  | #endif  // AOM_AV1_ENCODER_INTERINTRA_ML_DATA_COLLECT_H_ |