tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

flow_estimation.c (2249B)


      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_detect.h"
     15 #include "aom_dsp/flow_estimation/corner_match.h"
     16 #include "aom_dsp/flow_estimation/disflow.h"
     17 #include "aom_dsp/flow_estimation/flow_estimation.h"
     18 #include "aom_ports/mem.h"
     19 #include "aom_scale/yv12config.h"
     20 
     21 // clang-format off
     22 const double kIdentityParams[MAX_PARAMDIM] = {
     23  0.0, 0.0, 1.0, 0.0, 0.0, 1.0
     24 };
     25 // clang-format on
     26 
     27 // Compute a global motion model between the given source and ref frames.
     28 //
     29 // As is standard for video codecs, the resulting model maps from (x, y)
     30 // coordinates in `src` to the corresponding points in `ref`, regardless
     31 // of the temporal order of the two frames.
     32 //
     33 // Returns true if global motion estimation succeeded, false if not.
     34 // The output models should only be used if this function succeeds.
     35 bool aom_compute_global_motion(TransformationType type, YV12_BUFFER_CONFIG *src,
     36                               YV12_BUFFER_CONFIG *ref, int bit_depth,
     37                               GlobalMotionMethod gm_method,
     38                               int downsample_level, MotionModel *motion_models,
     39                               int num_motion_models, bool *mem_alloc_failed) {
     40  switch (gm_method) {
     41    case GLOBAL_MOTION_METHOD_FEATURE_MATCH:
     42      return av1_compute_global_motion_feature_match(
     43          type, src, ref, bit_depth, downsample_level, motion_models,
     44          num_motion_models, mem_alloc_failed);
     45    case GLOBAL_MOTION_METHOD_DISFLOW:
     46      return av1_compute_global_motion_disflow(
     47          type, src, ref, bit_depth, downsample_level, motion_models,
     48          num_motion_models, mem_alloc_failed);
     49    default: assert(0 && "Unknown global motion estimation type");
     50  }
     51  return false;
     52 }