static opus_val32 loss_distortion(const celt_glog *eBands, celt_glog *oldEBands, int start, int end, int len, int C)
{ int c, i;
opus_val32 dist = 0;
c=0; do { for (i=start;i<end;i++)
{
celt_glog d = PSHR32(SUB32(eBands[i+c*len], oldEBands[i+c*len]), DB_SHIFT-7);
dist = MAC16_16(dist, d,d);
}
} while (++c<C); return MIN32(200,SHR32(dist,14));
}
staticint quant_coarse_energy_impl(const CELTMode *m, int start, int end, const celt_glog *eBands, celt_glog *oldEBands,
opus_int32 budget, opus_int32 tell, constunsignedchar *prob_model, celt_glog *error, ec_enc *enc, int C, int LM, int intra, celt_glog max_decay, int lfe)
{ int i, c; int badness = 0;
opus_val32 prev[2] = {0,0};
opus_val16 coef;
opus_val16 beta;
void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, const celt_glog *eBands, celt_glog *oldEBands, opus_uint32 budget,
celt_glog *error, ec_enc *enc, int C, int LM, int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra, int two_pass, int loss_rate, int lfe)
{ int intra;
celt_glog max_decay;
VARDECL(celt_glog, oldEBands_intra);
VARDECL(celt_glog, error_intra);
ec_enc enc_start_state;
opus_uint32 tell; int badness1=0;
opus_int32 intra_bias;
opus_val32 new_distortion;
SAVE_STACK;
void quant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *prev_quant, int *extra_quant, ec_enc *enc, int C)
{ int i, c; /* Encode finer resolution */ for (i=start;i<end;i++)
{
opus_int16 extra, prev;
extra = 1<<extra_quant[i]; if (extra_quant[i] <= 0) continue; if (ec_tell(enc)+C*extra_quant[i] > (opus_int32)enc->storage*8) continue;
prev = (prev_quant!=NULL) ? prev_quant[i] : 0;
c=0; do { int q2;
celt_glog offset; #ifdef FIXED_POINT /* Has to be without rounding */
q2 = VSHR32(ADD32(error[i+c*m->nbEBands], SHR32(GCONST(.5f), prev)), DB_SHIFT-extra_quant[i]-prev); #else
q2 = (int)floor((error[i+c*m->nbEBands]*(1<<prev)+.5f)*extra); #endif if (q2 > extra-1)
q2 = extra-1; if (q2<0)
q2 = 0;
ec_enc_bits(enc, q2, extra_quant[i]); #ifdef FIXED_POINT
offset = SUB32(VSHR32(2*q2+1, extra_quant[i]-DB_SHIFT+1), GCONST(.5f));
offset = SHR32(offset, prev); #else
offset = (q2+.5f)*(1<<(14-extra_quant[i]))*(1.f/16384) - .5f;
offset *= (1<<(14-prev))*(1.f/16384); #endif
oldEBands[i+c*m->nbEBands] += offset;
error[i+c*m->nbEBands] -= offset; /*printf ("%f ", error[i] - offset);*/
} while (++c < C);
}
}
void quant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C)
{ int i, prio, c;
/* Use up the remaining bits */ for (prio=0;prio<2;prio++)
{ for (i=start;i<end && bits_left>=C ;i++)
{ if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i]!=prio) continue;
c=0; do { int q2;
celt_glog offset;
q2 = error[i+c*m->nbEBands]<0 ? 0 : 1;
ec_enc_bits(enc, q2, 1); #ifdef FIXED_POINT
offset = SHR32(SHL32(q2,DB_SHIFT)-GCONST(.5f),fine_quant[i]+1); #else
offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); #endif if (oldEBands != NULL) oldEBands[i+c*m->nbEBands] += offset;
error[i+c*m->nbEBands] -= offset;
bits_left--;
} while (++c < C);
}
}
}
void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int intra, ec_dec *dec, int C, int LM)
{ constunsignedchar *prob_model = e_prob_model[LM][intra]; int i, c;
opus_val64 prev[2] = {0, 0};
opus_val16 coef;
opus_val16 beta;
opus_int32 budget;
opus_int32 tell;
/* Decode at a fixed coarse resolution */ for (i=start;i<end;i++)
{
c=0; do { int qi;
opus_val32 q;
opus_val32 tmp; /* It would be better to express this invariant as a testonCatfunctionentry,butthatisn'tenough
to make the static analyzer happy. */
celt_sig_assert(c<2);
tell = ec_tell(dec); if(budget-tell>=15)
{ int pi;
pi = 2*IMIN(i,20);
qi = ec_laplace_decode(dec,
prob_model[pi]<<7, prob_model[pi+1]<<6);
} elseif(budget-tell>=2)
{
qi = ec_dec_icdf(dec, small_energy_icdf, 2);
qi = (qi>>1)^-(qi&1);
} elseif(budget-tell>=1)
{
qi = -ec_dec_bit_logp(dec, 1);
} else
qi = -1;
q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT);
void unquant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *prev_quant, int *extra_quant, ec_dec *dec, int C)
{ int i, c; /* Decode finer resolution */ for (i=start;i<end;i++)
{
opus_int16 extra, prev;
extra = extra_quant[i]; if (extra_quant[i] <= 0) continue; if (ec_tell(dec)+C*extra_quant[i] > (opus_int32)dec->storage*8) continue;
prev = (prev_quant!=NULL) ? prev_quant[i] : 0;
c=0; do { int q2;
celt_glog offset;
q2 = ec_dec_bits(dec, extra); #ifdef FIXED_POINT
offset = SUB32(VSHR32(2*q2+1, extra-DB_SHIFT+1), GCONST(.5f));
offset = SHR32(offset, prev); #else
offset = (q2+.5f)*(1<<(14-extra))*(1.f/16384) - .5f;
offset *= (1<<(14-prev))*(1.f/16384); #endif
oldEBands[i+c*m->nbEBands] += offset;
} while (++c < C);
}
}
void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C)
{ int i, prio, c;
/* Use up the remaining bits */ for (prio=0;prio<2;prio++)
{ for (i=start;i<end && bits_left>=C ;i++)
{ if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i]!=prio) continue;
c=0; do { int q2;
celt_glog offset;
q2 = ec_dec_bits(dec, 1); #ifdef FIXED_POINT
offset = SHR32(SHL32(q2,DB_SHIFT)-GCONST(.5f),fine_quant[i]+1); #else
offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); #endif if (oldEBands != NULL) oldEBands[i+c*m->nbEBands] += offset;
bits_left--;
} while (++c < C);
}
}
}
void amp2Log2(const CELTMode *m, int effEnd, int end,
celt_ener *bandE, celt_glog *bandLogE, int C)
{ int c, i;
c=0; do { for (i=0;i<effEnd;i++)
{
bandLogE[i+c*m->nbEBands] =
celt_log2_db(bandE[i+c*m->nbEBands])
- SHL32((celt_glog)eMeans[i],DB_SHIFT-4); #ifdef FIXED_POINT /* Compensate for bandE[] being Q12 but celt_log2() taking a Q14 input. */
bandLogE[i+c*m->nbEBands] += GCONST(2.f); #endif
} for (i=effEnd;i<end;i++)
bandLogE[c*m->nbEBands+i] = -GCONST(14.f);
} while (++c < C);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.