MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / bit_allocation

Function bit_allocation

libavcodec/imc.c:298–458  ·  view source on GitHub ↗

* Perform bit allocation depending on bits available */

Source from the content-addressed store, hash-verified

296 * Perform bit allocation depending on bits available
297 */
298static int bit_allocation (IMCContext* q, int stream_format_code, int freebits, int flag) {
299 int i, j;
300 const float limit = -1.e20;
301 float highest = 0.0;
302 int indx;
303 int t1 = 0;
304 int t2 = 1;
305 float summa = 0.0;
306 int iacc = 0;
307 int summer = 0;
308 int rres, cwlen;
309 float lowest = 1.e10;
310 int low_indx = 0;
311 float workT[32];
312 int flg;
313 int found_indx = 0;
314
315 for(i = 0; i < BANDS; i++)
316 highest = FFMAX(highest, q->flcoeffs1[i]);
317
318 for(i = 0; i < BANDS-1; i++) {
319 q->flcoeffs4[i] = q->flcoeffs3[i] - log(q->flcoeffs5[i])/log(2);
320 }
321 q->flcoeffs4[BANDS - 1] = limit;
322
323 highest = highest * 0.25;
324
325 for(i = 0; i < BANDS; i++) {
326 indx = -1;
327 if ((band_tab[i+1] - band_tab[i]) == q->bandWidthT[i])
328 indx = 0;
329
330 if ((band_tab[i+1] - band_tab[i]) > q->bandWidthT[i])
331 indx = 1;
332
333 if (((band_tab[i+1] - band_tab[i])/2) >= q->bandWidthT[i])
334 indx = 2;
335
336 if (indx == -1)
337 return -1;
338
339 q->flcoeffs4[i] = q->flcoeffs4[i] + xTab[(indx*2 + (q->flcoeffs1[i] < highest)) * 2 + flag];
340 }
341
342 if (stream_format_code & 0x2) {
343 q->flcoeffs4[0] = limit;
344 q->flcoeffs4[1] = limit;
345 q->flcoeffs4[2] = limit;
346 q->flcoeffs4[3] = limit;
347 }
348
349 for(i = (stream_format_code & 0x2)?4:0; i < BANDS-1; i++) {
350 iacc += q->bandWidthT[i];
351 summa += q->bandWidthT[i] * q->flcoeffs4[i];
352 }
353 q->bandWidthT[BANDS-1] = 0;
354 summa = (summa * 0.5 - freebits) / iacc;
355

Callers 1

imc_decode_frameFunction · 0.85

Calls 1

av_clipFunction · 0.85

Tested by

no test coverage detected