libavcodec/elbg.c File Reference

Codebook Generator using the ELBG algorithm. More...

#include <string.h>
#include "libavutil/lfg.h"
#include "elbg.h"
#include "avcodec.h"

Go to the source code of this file.

Data Structures

struct  cell_s
 In the ELBG jargon, a cell is the set of points that are closest to a codebook entry. More...
struct  elbg_data
 ELBG internal data. More...

Defines

#define DELTA_ERR_MAX   0.1
 Precision of the ELBG algorithm (as percentual error).
#define BIG_PRIME   433494437LL

Typedefs

typedef struct cell_s cell
 In the ELBG jargon, a cell is the set of points that are closest to a codebook entry.

Functions

static int distance_limited (int *a, int *b, int dim, int limit)
static void vect_division (int *res, int *vect, int div, int dim)
static int eval_error_cell (elbg_data *elbg, int *centroid, cell *cells)
static int get_closest_codebook (elbg_data *elbg, int index)
static int get_high_utility_cell (elbg_data *elbg)
static int simple_lbg (elbg_data *elbg, int dim, int *centroid[3], int newutility[3], int *points, cell *cells)
 Implementation of the simple LBG algorithm for just two codebooks.
static void get_new_centroids (elbg_data *elbg, int huc, int *newcentroid_i, int *newcentroid_p)
static void shift_codebook (elbg_data *elbg, int *indexes, int *newcentroid[3])
 Add the points in the low utility cell to its closest cell.
static void evaluate_utility_inc (elbg_data *elbg)
static void update_utility_and_n_cb (elbg_data *elbg, int idx, int newutility)
static void try_shift_candidate (elbg_data *elbg, int idx[3])
 Evaluate if a shift lower the error.
static void do_shiftings (elbg_data *elbg)
 Implementation of the ELBG block.
void ff_init_elbg (int *points, int dim, int numpoints, int *codebook, int numCB, int max_steps, int *closest_cb, AVLFG *rand_state)
 Initialize the **codebook vector for the elbg algorithm.
void ff_do_elbg (int *points, int dim, int numpoints, int *codebook, int numCB, int max_steps, int *closest_cb, AVLFG *rand_state)
 Implementation of the Enhanced LBG Algorithm Based on the paper "Neural Networks 14:1219-1237" that can be found in http://citeseer.ist.psu.edu/patan01enhanced.html .


Detailed Description

Codebook Generator using the ELBG algorithm.

Definition in file elbg.c.


Define Documentation

#define BIG_PRIME   433494437LL

Definition at line 323 of file elbg.c.

Referenced by ff_init_elbg().

#define DELTA_ERR_MAX   0.1

Precision of the ELBG algorithm (as percentual error).

Definition at line 32 of file elbg.c.

Referenced by ff_do_elbg().


Typedef Documentation

typedef struct cell_s cell

In the ELBG jargon, a cell is the set of points that are closest to a codebook entry.

Not to be confused with a RoQ Video cell.


Function Documentation

static int distance_limited ( int *  a,
int *  b,
int  dim,
int  limit 
) [inline, static]

Definition at line 59 of file elbg.c.

Referenced by eval_error_cell(), ff_do_elbg(), get_closest_codebook(), shift_codebook(), and simple_lbg().

static void do_shiftings ( elbg_data elbg  )  [static]

Implementation of the ELBG block.

Definition at line 304 of file elbg.c.

Referenced by ff_do_elbg().

static int eval_error_cell ( elbg_data elbg,
int *  centroid,
cell cells 
) [static]

Definition at line 82 of file elbg.c.

Referenced by try_shift_candidate().

static void evaluate_utility_inc ( elbg_data elbg  )  [static]

Definition at line 226 of file elbg.c.

Referenced by do_shiftings(), and try_shift_candidate().

void ff_do_elbg ( int *  points,
int  dim,
int  numpoints,
int *  codebook,
int  numCB,
int  num_steps,
int *  closest_cb,
AVLFG rand_state 
)

Implementation of the Enhanced LBG Algorithm Based on the paper "Neural Networks 14:1219-1237" that can be found in http://citeseer.ist.psu.edu/patan01enhanced.html .

Parameters:
points Input points.
dim Dimension of the points.
numpoints Num of points in **points.
codebook Pointer to the output codebook. Must be allocated.
numCB Number of points in the codebook.
num_steps The maximum number of steps. One step is already a good compromise between time and quality.
closest_cb Return the closest codebook to each point. Must be allocated.
rand_state A random number generator state. Should be already initialized by av_lfg_init().

Definition at line 352 of file elbg.c.

Referenced by a64multi_encode_frame(), encode_frame(), ff_init_elbg(), and generate_codebook().

void ff_init_elbg ( int *  points,
int  dim,
int  numpoints,
int *  codebook,
int  numCB,
int  num_steps,
int *  closest_cb,
AVLFG rand_state 
)

Initialize the **codebook vector for the elbg algorithm.

If you have already a codebook and you want to refine it, you shouldn't call this function. If numpoints < 8*numCB this function fills **codebook with random numbers. If not, it calls ff_do_elbg for a (smaller) random sample of the points in **points. Get the same parameters as ff_do_elbg.

Definition at line 325 of file elbg.c.

Referenced by a64multi_encode_frame(), encode_frame(), ff_init_elbg(), and generate_codebook().

static int get_closest_codebook ( elbg_data elbg,
int  index 
) [static]

Definition at line 91 of file elbg.c.

Referenced by do_shiftings().

static int get_high_utility_cell ( elbg_data elbg  )  [static]

Definition at line 105 of file elbg.c.

Referenced by do_shiftings().

static void get_new_centroids ( elbg_data elbg,
int  huc,
int *  newcentroid_i,
int *  newcentroid_p 
) [static]

Definition at line 162 of file elbg.c.

Referenced by try_shift_candidate().

static void shift_codebook ( elbg_data elbg,
int *  indexes,
int *  newcentroid[3] 
) [static]

Add the points in the low utility cell to its closest cell.

Split the high utility cell, putting the separed points in the (now empty) low utility cell.

Parameters:
elbg Internal elbg data
indexes {luc, huc, cluc}
newcentroid A vector with the position of the new centroids

Definition at line 198 of file elbg.c.

Referenced by try_shift_candidate().

static int simple_lbg ( elbg_data elbg,
int  dim,
int *  centroid[3],
int  newutility[3],
int *  points,
cell cells 
) [static]

Implementation of the simple LBG algorithm for just two codebooks.

Definition at line 121 of file elbg.c.

Referenced by try_shift_candidate().

static void try_shift_candidate ( elbg_data elbg,
int  idx[3] 
) [static]

Evaluate if a shift lower the error.

If it does, call shift_codebooks and update elbg->error, elbg->utility and elbg->nearest_cb.

Parameters:
elbg Internal elbg data
idx {luc (low utility cell, huc (high utility cell), cluc (closest cell to low utility cell)}

Definition at line 254 of file elbg.c.

Referenced by do_shiftings().

static void update_utility_and_n_cb ( elbg_data elbg,
int  idx,
int  newutility 
) [static]

Definition at line 238 of file elbg.c.

Referenced by try_shift_candidate().

static void vect_division ( int *  res,
int *  vect,
int  div,
int  dim 
) [inline, static]

Definition at line 71 of file elbg.c.

Referenced by ff_do_elbg(), simple_lbg(), and try_shift_candidate().


Generated on Fri Oct 26 02:38:16 2012 for FFmpeg by  doxygen 1.5.8