Commit 9d068c12 authored by Alex Converse's avatar Alex Converse

Deduplicate lcg_rand16 function.

Change-Id: Idc5fb44309b5aaa132833ebb4007416f9d143e3d
parent dfe49b21
......@@ -63,6 +63,7 @@ AV1_CX_SRCS-yes += encoder/lookahead.c
AV1_CX_SRCS-yes += encoder/lookahead.h
AV1_CX_SRCS-yes += encoder/mcomp.h
AV1_CX_SRCS-yes += encoder/encoder.h
AV1_CX_SRCS-yes += encoder/random.h
AV1_CX_SRCS-yes += encoder/ratectrl.h
ifeq ($(CONFIG_XIPHRC),yes)
AV1_CX_SRCS-yes += encoder/ratectrl_xiph.h
......
......@@ -14,6 +14,7 @@
#include "av1/encoder/cost.h"
#include "av1/encoder/palette.h"
#include "av1/encoder/random.h"
static float calc_dist(const float *p1, const float *p2, int dim) {
float dist = 0;
......@@ -42,12 +43,6 @@ void av1_calc_indices(const float *data, const float *centroids,
}
}
// Generate a random number in the range [0, 32768).
static unsigned int lcg_rand16(unsigned int *state) {
*state = (unsigned int)(*state * 1103515245ULL + 12345);
return *state / 65536 % 32768;
}
static void calc_centroids(const float *data, float *centroids,
const uint8_t *indices, int n, int k, int dim) {
int i, j, index;
......
/*
* Copyright (c) 2017, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#ifndef AV1_ENCODER_RANDOM_H_
#define AV1_ENCODER_RANDOM_H_
#ifdef __cplusplus
extern "C" {
#endif
// Generate a random number in the range [0, 32768).
static INLINE unsigned int lcg_rand16(unsigned int *state) {
*state = (unsigned int)(*state * 1103515245ULL + 12345);
return *state / 65536 % 32768;
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AV1_ENCODER_RANDOM_H_
......@@ -17,6 +17,7 @@
#include "av1/encoder/ransac.h"
#include "av1/encoder/mathutils.h"
#include "av1/encoder/random.h"
#define MAX_MINPTS 4
#define MAX_DEGENERATE_ITER 10
......@@ -587,12 +588,6 @@ static int find_homography(int np, double *pts1, double *pts2, double *mat) {
return 0;
}
// Generate a random number in the range [0, 32768).
static unsigned int lcg_rand16(unsigned int *state) {
*state = (unsigned int)(*state * 1103515245ULL + 12345);
return *state / 65536 % 32768;
}
static int get_rand_indices(int npoints, int minpts, int *indices,
unsigned int *seed) {
int i, j;
......
......@@ -29,6 +29,7 @@
#include "av1/common/seg_common.h"
#include "av1/encoder/encodemv.h"
#include "av1/encoder/random.h"
#include "av1/encoder/ratectrl.h"
// Max rate target for 1080P and below encodes under normal circumstances
......@@ -1692,11 +1693,6 @@ void av1_set_target_rate(AV1_COMP *cpi) {
av1_rc_set_frame_target(cpi, target_rate);
}
static unsigned int lcg_rand16(unsigned int *state) {
*state = (unsigned int)(*state * 1103515245ULL + 12345);
return *state / 65536 % 32768;
}
uint8_t av1_calculate_next_resize_scale(const AV1_COMP *cpi) {
static unsigned int seed = 56789;
const AV1EncoderConfig *oxcf = &cpi->oxcf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment