xref: /aosp_15_r20/external/libaom/av1/encoder/global_motion_facade.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2020, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_ENCODER_GLOBAL_MOTION_FACADE_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_GLOBAL_MOTION_FACADE_H_
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
16*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
17*77c1e3ccSAndroid Build Coastguard Worker #endif
18*77c1e3ccSAndroid Build Coastguard Worker struct yv12_buffer_config;
19*77c1e3ccSAndroid Build Coastguard Worker struct AV1_COMP;
20*77c1e3ccSAndroid Build Coastguard Worker 
21*77c1e3ccSAndroid Build Coastguard Worker // Allocates memory for members of GlobalMotionData.
gm_alloc_data(AV1_COMP * cpi,GlobalMotionData * gm_data)22*77c1e3ccSAndroid Build Coastguard Worker static inline void gm_alloc_data(AV1_COMP *cpi, GlobalMotionData *gm_data) {
23*77c1e3ccSAndroid Build Coastguard Worker   AV1_COMMON *cm = &cpi->common;
24*77c1e3ccSAndroid Build Coastguard Worker   GlobalMotionInfo *gm_info = &cpi->gm_info;
25*77c1e3ccSAndroid Build Coastguard Worker 
26*77c1e3ccSAndroid Build Coastguard Worker   CHECK_MEM_ERROR(cm, gm_data->segment_map,
27*77c1e3ccSAndroid Build Coastguard Worker                   aom_malloc(sizeof(*gm_data->segment_map) *
28*77c1e3ccSAndroid Build Coastguard Worker                              gm_info->segment_map_w * gm_info->segment_map_h));
29*77c1e3ccSAndroid Build Coastguard Worker 
30*77c1e3ccSAndroid Build Coastguard Worker   av1_zero_array(gm_data->motion_models, RANSAC_NUM_MOTIONS);
31*77c1e3ccSAndroid Build Coastguard Worker   for (int m = 0; m < RANSAC_NUM_MOTIONS; m++) {
32*77c1e3ccSAndroid Build Coastguard Worker     CHECK_MEM_ERROR(cm, gm_data->motion_models[m].inliers,
33*77c1e3ccSAndroid Build Coastguard Worker                     aom_malloc(sizeof(*gm_data->motion_models[m].inliers) * 2 *
34*77c1e3ccSAndroid Build Coastguard Worker                                MAX_CORNERS));
35*77c1e3ccSAndroid Build Coastguard Worker   }
36*77c1e3ccSAndroid Build Coastguard Worker }
37*77c1e3ccSAndroid Build Coastguard Worker 
38*77c1e3ccSAndroid Build Coastguard Worker // Deallocates the memory allocated for members of GlobalMotionData.
gm_dealloc_data(GlobalMotionData * gm_data)39*77c1e3ccSAndroid Build Coastguard Worker static inline void gm_dealloc_data(GlobalMotionData *gm_data) {
40*77c1e3ccSAndroid Build Coastguard Worker   aom_free(gm_data->segment_map);
41*77c1e3ccSAndroid Build Coastguard Worker   gm_data->segment_map = NULL;
42*77c1e3ccSAndroid Build Coastguard Worker   for (int m = 0; m < RANSAC_NUM_MOTIONS; m++) {
43*77c1e3ccSAndroid Build Coastguard Worker     aom_free(gm_data->motion_models[m].inliers);
44*77c1e3ccSAndroid Build Coastguard Worker     gm_data->motion_models[m].inliers = NULL;
45*77c1e3ccSAndroid Build Coastguard Worker   }
46*77c1e3ccSAndroid Build Coastguard Worker }
47*77c1e3ccSAndroid Build Coastguard Worker 
48*77c1e3ccSAndroid Build Coastguard Worker void av1_compute_gm_for_valid_ref_frames(
49*77c1e3ccSAndroid Build Coastguard Worker     AV1_COMP *cpi, struct aom_internal_error_info *error_info,
50*77c1e3ccSAndroid Build Coastguard Worker     YV12_BUFFER_CONFIG *ref_buf[REF_FRAMES], int frame,
51*77c1e3ccSAndroid Build Coastguard Worker     MotionModel *motion_models, uint8_t *segment_map, int segment_map_w,
52*77c1e3ccSAndroid Build Coastguard Worker     int segment_map_h);
53*77c1e3ccSAndroid Build Coastguard Worker void av1_compute_global_motion_facade(struct AV1_COMP *cpi);
54*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
55*77c1e3ccSAndroid Build Coastguard Worker }  // extern "C"
56*77c1e3ccSAndroid Build Coastguard Worker #endif
57*77c1e3ccSAndroid Build Coastguard Worker 
58*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AV1_ENCODER_GLOBAL_MOTION_FACADE_H_
59