Doxygen Source Code Documentation
rate.c File Reference
#include <sys/times.h>
#include "all.h"
#include "mtypes.h"
#include "bitio.h"
#include "frames.h"
#include "prototypes.h"
#include "param.h"
#include "mheaders.h"
#include "fsize.h"
#include "postdct.h"
#include "mpeg.h"
#include "parallel.h"
#include "dct.h"
#include "rate.h"
Go to the source code of this file.
Defines | |
#define | MAX_BIT_RATE 104857600 |
#define | MAX_BUFFER_SIZE 16760832 |
#define | DEFAULT_BUFFER_SIZE 327680 |
#define | DEFAULT_VBV_FULLNESS 3 |
#define | DEFAULT_PICT_RATE_CODE 5 |
#define | DEFAULT_PICT_RATE 30 |
#define | MAX_VBV_DELAY 32768 |
Functions | |
int initGOPRateControl | _ANSI_ARGS_ ((void)) |
void checkBufferFullness | _ANSI_ARGS_ ((int count)) |
void checkSpatialActivity | _ANSI_ARGS_ ((Block blk0, Block blk1, Block blk2, Block blk3)) |
void incNumBlocks | _ANSI_ARGS_ ((int num)) |
void updateVBVBuffer | _ANSI_ARGS_ ((int frameBits)) |
int BlockExperiments | _ANSI_ARGS_ ((int16 *OrigBlock, int16 *NewBlock, int control)) |
int | initRateControl () |
int | initGOPRateControl () |
void | targetRateControl (frame) MpegFrame *frame |
Variables | |
int | RateControlMode = VARIABLE_RATE |
int32 | buffer_size = DEFAULT_BUFFER_SIZE |
int32 | bit_rate = -1 |
int32 | VBV_delay = 0 |
int32 | VBV_buffer = 0 |
int32 | bufferFillRate = 0 |
int32 | frameDelayIncrement = 0 |
int | Xi |
int | Xp |
int | Xb |
int | Si |
int | Sp |
int | Sb |
float | Qi |
float | Qp |
float | Qb |
int | Ti |
int | Tp |
int | Tb |
int | current_Tx |
int | GOP_X = 0 |
int | GOP_I = 0 |
int | GOP_P = 0 |
int | GOP_B = 0 |
int | Nx = 0 |
int | Ni = 0 |
int | Np = 0 |
int | Nb = 0 |
int | rc_numBlocks = 0 |
int | rc_totalQuant = 0 |
int | rc_bitsThisMB |
int | rc_totalMBBits |
int | rc_totalFrameBits |
int | rc_totalOverheadBits = 0 |
int | RC_MB_SAMPLE_RATE = 0 |
float | Ki = .7 |
float | Kp = 1 |
float | Kb = 1.4 |
int | rc_R |
int | rc_G |
int | d0_i |
int | d0_p |
int | d0_b |
int | lastFrameVirtBuf |
int | currentVirtBuf |
int | MB_cnt = -1 |
int | rc_Q |
int | reactionParameter |
int | act_j |
float | N_act |
int | avg_act |
int | total_act_j |
int | var_sblk |
int | P_mean |
int | mquant |
int | Qscale |
char * | Frame_header1 = " Fm # Bit GOP V " |
char * | Frame_header2 = " # type MBs Alloc left Ni Np Nb N_act buff Q_rc Qscale" |
char * | Frame_header3 = "---- - ---- ------ ------- -- -- -- ----- ------ ---- ----" |
char * | Frame_trailer1 = " avg virt % GOP % VBV" |
char * | Frame_trailer2 = " Sx Qx Xx act N_act buffer alloc left left buf delay" |
char * | Frame_trailer3 = "------ --.-- ------- --- --.-- ------- --- ------- --- ------- ------" |
char * | MB_header1 = "MB# #bits Q mqt Dj Q_j actj N_act totbits b/MB %alloc %done" |
char * | MB_header2 = "--- ----- -- --- ------ --- ----- --.-- ------ ---- --- ---" |
char | rc_buffer [101] |
char * | framePattern |
int | framePatternLen |
Block | blk0 |
Block | blk1 |
Block | blk2 |
Block | blk3 |
Define Documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Function Documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 312 of file rate.c. References avg_act, bit_rate, buffer_size, d0_b, d0_i, d0_p, DBG_PRINT, GOP_B, GOP_I, GOP_P, GOP_X, mquant, Nb, Ni, Np, Nx, rc_G, rc_Q, rc_R, Xb, Xi, and Xp. Referenced by initRateControl().
00313 { 00314 DBG_PRINT(("\tInitializing new GOP\n")); 00315 00316 Nx = GOP_X; 00317 Ni = GOP_I; 00318 Np = GOP_P; 00319 Nb = GOP_B; 00320 00321 rc_R += rc_G; 00322 00323 DBG_PRINT(("\tbufsize: %d, bitrate: %d, pictrate: %d, GOP bits: %d\n", 00324 buffer_size, bit_rate, frameRateRounded, rc_R)); 00325 DBG_PRINT(("\tXi: %d, Xp: %d, Xb: %d Nx: %d, Ni: %d, Np: %d, Nb: %d\n", 00326 Xi, Xp, Xb, Nx,Ni,Np,Nb)); 00327 DBG_PRINT(("\td0_i: %d, d0_p: %d, d0_b: %d, avg_act: %d, rc_Q: %d, mquant: %d\n", 00328 d0_i, d0_p, d0_b, avg_act, rc_Q, mquant)); 00329 return 1; 00330 } |
|
Definition at line 218 of file rate.c. References avg_act, bit_rate, buffer_size, bufferFillRate, d0_b, d0_i, d0_p, DBG_PRINT, frameDelayIncrement, framePattern, framePatternLen, GOP_B, GOP_I, GOP_P, GOP_X, initGOPRateControl(), Kb, Kp, lastFrameVirtBuf, mquant, N_act, RateControlMode, rc_bitsThisMB, rc_G, rc_numBlocks, rc_Q, rc_R, rc_totalFrameBits, rc_totalMBBits, rc_totalOverheadBits, rc_totalQuant, reactionParameter, VARIABLE_RATE, VBV_buffer, VBV_delay, Xb, Xi, and Xp.
00219 { 00220 int index; 00221 int result; 00222 00223 DBG_PRINT(("\tInitializing Allocation Data\n")); 00224 00225 #ifdef RC_STATS_FILE 00226 RC_FILE = fopen("RC_STATS_FILE", "w"); 00227 if ( RC_FILE == NULL) { 00228 DBG_PRINT(("\tOpen of RC file failed, using stderr\n")); 00229 RC_FILE = stderr; 00230 fprintf(RC_FILE, "\tOpen of RC file failed, using stderr\n"); 00231 fflush(RC_FILE); 00232 } 00233 #endif 00234 00235 /* Initialize Pattern info */ 00236 GOP_X = framePatternLen; 00237 for ( index = 0; index < framePatternLen; index++ ) { 00238 switch( framePattern[index] ) { 00239 case 'i': 00240 GOP_I++; 00241 break; 00242 case 'p': 00243 GOP_P++; 00244 break; 00245 case 'b': 00246 GOP_B++; 00247 break; 00248 default: 00249 printf("\n\tERROR rate.c - BAD PATTERN!\n"); 00250 RateControlMode = VARIABLE_RATE; 00251 return (0); 00252 } 00253 } 00254 if (GOP_X != (GOP_I + GOP_P + GOP_B )) { 00255 printf("\n\tERROR rate.c - Pattern Length Mismatch\n"); 00256 RateControlMode = VARIABLE_RATE; 00257 return (-1); 00258 } 00259 00260 /* Initializing GOP bit allocation */ 00261 rc_R = 0; 00262 rc_G = (bit_rate * GOP_X/frameRateRounded); 00263 00264 /* Initialize the "global complexity measures" */ 00265 Xi = (160 * bit_rate/115); 00266 Xp = (60 * bit_rate/115); 00267 Xb = (42 * bit_rate/115); 00268 00269 /* Initialize MB counters */ 00270 rc_totalMBBits= rc_bitsThisMB= rc_totalFrameBits=rc_totalOverheadBits = 0; 00271 rc_numBlocks = rc_totalQuant = 0; 00272 00273 /* init virtual buffers */ 00274 reactionParameter = (2 * bit_rate / frameRateRounded); 00275 d0_i = (10 * reactionParameter / 31); 00276 d0_p = (Kp * d0_i); 00277 d0_b = (Kb * d0_i); 00278 00279 lastFrameVirtBuf = d0_i; /* start with I Frame */ 00280 rc_Q = lastFrameVirtBuf * 31 / reactionParameter; 00281 00282 /* init spatial activity measures */ 00283 avg_act = 400; /* Suggested initial value */ 00284 N_act = 1; 00285 00286 mquant = rc_Q * N_act; 00287 00288 frameDelayIncrement = (90000 / frameRateRounded); /* num of "delay" units per frame */ 00289 bufferFillRate = bit_rate / frameRateRounded; /* VBV buf fills at constant rate */ 00290 VBV_buffer = buffer_size; 00291 DBG_PRINT(("\tVBV- delay: %d, fill rate: %d, delay/Frame: %d units, buffer size: %d\n", 00292 VBV_delay, bufferFillRate, frameDelayIncrement, buffer_size)); 00293 00294 result = initGOPRateControl(); 00295 00296 return result; 00297 } |
|
|
Variable Documentation
|
|
|
Definition at line 154 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 84 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
|
|
|
|
|
|
|
|
Definition at line 83 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 90 of file rate.c. Referenced by initRateControl(). |
|
|
|
|
|
Definition at line 140 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 138 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 139 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 91 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 183 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 184 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 109 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 107 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 108 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 106 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 131 of file rate.c. Referenced by initRateControl(). |
|
|
|
Definition at line 130 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 142 of file rate.c. Referenced by initRateControl(). |
|
|
|
|
|
|
|
Definition at line 160 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 153 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 114 of file rate.c. Referenced by extract_assign_directions(), and initGOPRateControl(). |
|
Definition at line 112 of file rate.c. Referenced by initGOPRateControl(), main(), SUMA_CreateTable(), SUMA_Householder(), and SUMA_Surface_Curvature(). |
|
Definition at line 113 of file rate.c. Referenced by initGOPRateControl(). |
|
Definition at line 111 of file rate.c. Referenced by initGOPRateControl(), SUMA_AssignTriBranch(), SUMA_Dijkstra(), and SUMA_IntersectionStrip(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 82 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 120 of file rate.c. Referenced by initRateControl(). |
|
|
|
Definition at line 133 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
|
|
Definition at line 118 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 147 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 132 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 122 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 121 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 123 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 119 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 149 of file rate.c. Referenced by initRateControl(). |
|
|
|
|
|
|
|
|
|
Definition at line 101 of file rate.c. Referenced by SUMA_AddNodeIndexColumn(). |
|
|
|
|
|
|
|
Definition at line 89 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 88 of file rate.c. Referenced by initRateControl(). |
|
Definition at line 94 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 94 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |
|
Definition at line 94 of file rate.c. Referenced by initGOPRateControl(), and initRateControl(). |