1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12 #include <assert.h>
13
14 #include "aom_dsp/flow_estimation/corner_match.h"
15 #include "aom_dsp/flow_estimation/disflow.h"
16 #include "aom_dsp/flow_estimation/flow_estimation.h"
17 #include "aom_ports/mem.h"
18 #include "aom_scale/yv12config.h"
19
aom_compute_global_motion(TransformationType type,unsigned char * src_buffer,int src_width,int src_height,int src_stride,int * src_corners,int num_src_corners,YV12_BUFFER_CONFIG * ref,int bit_depth,GlobalMotionEstimationType gm_estimation_type,int * num_inliers_by_motion,MotionModel * params_by_motion,int num_motions)20 int aom_compute_global_motion(TransformationType type,
21 unsigned char *src_buffer, int src_width,
22 int src_height, int src_stride, int *src_corners,
23 int num_src_corners, YV12_BUFFER_CONFIG *ref,
24 int bit_depth,
25 GlobalMotionEstimationType gm_estimation_type,
26 int *num_inliers_by_motion,
27 MotionModel *params_by_motion, int num_motions) {
28 switch (gm_estimation_type) {
29 case GLOBAL_MOTION_FEATURE_BASED:
30 return av1_compute_global_motion_feature_based(
31 type, src_buffer, src_width, src_height, src_stride, src_corners,
32 num_src_corners, ref, bit_depth, num_inliers_by_motion,
33 params_by_motion, num_motions);
34 case GLOBAL_MOTION_DISFLOW_BASED:
35 return av1_compute_global_motion_disflow_based(
36 type, src_buffer, src_width, src_height, src_stride, src_corners,
37 num_src_corners, ref, bit_depth, num_inliers_by_motion,
38 params_by_motion, num_motions);
39 default: assert(0 && "Unknown global motion estimation type");
40 }
41 return 0;
42 }
43
av1_downconvert_frame(YV12_BUFFER_CONFIG * frm,int bit_depth)44 unsigned char *av1_downconvert_frame(YV12_BUFFER_CONFIG *frm, int bit_depth) {
45 int i, j;
46 uint16_t *orig_buf = CONVERT_TO_SHORTPTR(frm->y_buffer);
47 uint8_t *buf_8bit = frm->y_buffer_8bit;
48 assert(buf_8bit);
49 if (!frm->buf_8bit_valid) {
50 for (i = 0; i < frm->y_height; ++i) {
51 for (j = 0; j < frm->y_width; ++j) {
52 buf_8bit[i * frm->y_stride + j] =
53 orig_buf[i * frm->y_stride + j] >> (bit_depth - 8);
54 }
55 }
56 frm->buf_8bit_valid = 1;
57 }
58 return buf_8bit;
59 }
60