Use FLG pseudo-random number generator in RoQ and ELBG
Originally committed as revision 17881 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
74e2a0784e
commit
9aa2ab4276
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libavutil/random.h"
|
#include "libavutil/lfg.h"
|
||||||
#include "elbg.h"
|
#include "elbg.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ typedef struct{
|
|||||||
int *utility_inc;
|
int *utility_inc;
|
||||||
int *nearest_cb;
|
int *nearest_cb;
|
||||||
int *points;
|
int *points;
|
||||||
AVRandomState *rand_state;
|
AVLFG *rand_state;
|
||||||
} elbg_data;
|
} elbg_data;
|
||||||
|
|
||||||
static inline int distance_limited(int *a, int *b, int dim, int limit)
|
static inline int distance_limited(int *a, int *b, int dim, int limit)
|
||||||
@ -105,7 +105,7 @@ static int get_high_utility_cell(elbg_data *elbg)
|
|||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
/* Using linear search, do binary if it ever turns to be speed critical */
|
/* Using linear search, do binary if it ever turns to be speed critical */
|
||||||
int r = av_random(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
|
int r = av_lfg_get(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
|
||||||
while (elbg->utility_inc[i] < r)
|
while (elbg->utility_inc[i] < r)
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ static void do_shiftings(elbg_data *elbg)
|
|||||||
|
|
||||||
void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
|
void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
|
||||||
int numCB, int max_steps, int *closest_cb,
|
int numCB, int max_steps, int *closest_cb,
|
||||||
AVRandomState *rand_state)
|
AVLFG *rand_state)
|
||||||
{
|
{
|
||||||
int i, k;
|
int i, k;
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
|
|||||||
|
|
||||||
void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
|
void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
|
||||||
int numCB, int max_steps, int *closest_cb,
|
int numCB, int max_steps, int *closest_cb,
|
||||||
AVRandomState *rand_state)
|
AVLFG *rand_state)
|
||||||
{
|
{
|
||||||
int dist;
|
int dist;
|
||||||
elbg_data elbg_d;
|
elbg_data elbg_d;
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
*/
|
*/
|
||||||
void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
|
void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
|
||||||
int numCB, int num_steps, int *closest_cb,
|
int numCB, int num_steps, int *closest_cb,
|
||||||
AVRandomState *rand_state);
|
AVLFG *rand_state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the **codebook vector for the elbg algorithm. If you have already
|
* Initialize the **codebook vector for the elbg algorithm. If you have already
|
||||||
@ -50,6 +50,6 @@ void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
|
|||||||
*/
|
*/
|
||||||
void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
|
void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
|
||||||
int numCB, int num_steps, int *closest_cb,
|
int numCB, int num_steps, int *closest_cb,
|
||||||
AVRandomState *rand_state);
|
AVLFG *rand_state);
|
||||||
|
|
||||||
#endif /* AVCODEC_ELBG_H */
|
#endif /* AVCODEC_ELBG_H */
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef AVCODEC_ROQVIDEO_H
|
#ifndef AVCODEC_ROQVIDEO_H
|
||||||
#define AVCODEC_ROQVIDEO_H
|
#define AVCODEC_ROQVIDEO_H
|
||||||
|
|
||||||
#include "libavutil/random.h"
|
#include "libavutil/lfg.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "dsputil.h"
|
#include "dsputil.h"
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ typedef struct RoqContext {
|
|||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
/* Encoder only data */
|
/* Encoder only data */
|
||||||
AVRandomState randctx;
|
AVLFG randctx;
|
||||||
uint64_t lambda;
|
uint64_t lambda;
|
||||||
|
|
||||||
motion_vect *this_motion4;
|
motion_vect *this_motion4;
|
||||||
|
@ -929,7 +929,7 @@ static int roq_encode_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
RoqContext *enc = avctx->priv_data;
|
RoqContext *enc = avctx->priv_data;
|
||||||
|
|
||||||
av_random_init(&enc->randctx, 1);
|
av_lfg_init(&enc->randctx, 1);
|
||||||
|
|
||||||
enc->framesSinceKeyframe = 0;
|
enc->framesSinceKeyframe = 0;
|
||||||
if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
|
if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user