/* Copyright (c) 2007-2008 CSIRO Copyright (c) 2007-2009 Xiph.Org Foundation
Written by Jean-Marc Valin */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
static opus_val32 loss_distortion(const opus_val16 *eBands, opus_val16 *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++)
{
opus_val16 d = SUB16(SHR16(eBands[i+c*len], 3), SHR16(oldEBands[i+c*len], 3));
dist = MAC16_16(dist, d,d);
}
} while (++c<C); return MIN32(200,SHR32(dist,2*DB_SHIFT-6));
}
staticint quant_coarse_energy_impl(const CELTMode *m, int start, int end, const opus_val16 *eBands, opus_val16 *oldEBands,
opus_int32 budget, opus_int32 tell, constunsignedchar *prob_model, opus_val16 *error, ec_enc *enc, int C, int LM, int intra, opus_val16 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 opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget,
opus_val16 *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;
opus_val16 max_decay;
VARDECL(opus_val16, oldEBands_intra);
VARDECL(opus_val16, 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, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int C)
{ int i, c;
/* Encode finer resolution */ for (i=start;i<end;i++)
{
opus_int16 frac = 1<<fine_quant[i]; if (fine_quant[i] <= 0) continue;
c=0; do { int q2;
opus_val16 offset; #ifdef FIXED_POINT /* Has to be without rounding */
q2 = (error[i+c*m->nbEBands]+QCONST16(.5f,DB_SHIFT))>>(DB_SHIFT-fine_quant[i]); #else
q2 = (int)floor((error[i+c*m->nbEBands]+.5f)*frac); #endif if (q2 > frac-1)
q2 = frac-1; if (q2<0)
q2 = 0;
ec_enc_bits(enc, q2, fine_quant[i]); #ifdef FIXED_POINT
offset = SUB16(SHR32(SHL32(EXTEND32(q2),DB_SHIFT)+QCONST16(.5f,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT)); #else
offset = (q2+.5f)*(1<<(14-fine_quant[i]))*(1.f/16384) - .5f; #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, opus_val16 *oldEBands, opus_val16 *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;
opus_val16 offset;
q2 = error[i+c*m->nbEBands]<0 ? 0 : 1;
ec_enc_bits(enc, q2, 1); #ifdef FIXED_POINT
offset = SHR16(SHL16(q2,DB_SHIFT)-QCONST16(.5f,DB_SHIFT),fine_quant[i]+1); #else
offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); #endif
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, opus_val16 *oldEBands, int intra, ec_dec *dec, int C, int LM)
{ constunsignedchar *prob_model = e_prob_model[LM][intra]; int i, c;
opus_val32 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 test on C at function entry, but that isn't enough
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, opus_val16 *oldEBands, int*fine_quant, ec_dec *dec, int C)
{ int i, c; /* Decode finer resolution */ for (i=start;i<end;i++)
{ if (fine_quant[i] <= 0) continue;
c=0; do { int q2;
opus_val16 offset;
q2 = ec_dec_bits(dec, fine_quant[i]); #ifdef FIXED_POINT
offset = SUB16(SHR32(SHL32(EXTEND32(q2),DB_SHIFT)+QCONST16(.5f,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT)); #else
offset = (q2+.5f)*(1<<(14-fine_quant[i]))*(1.f/16384) - .5f; #endif
oldEBands[i+c*m->nbEBands] += offset;
} while (++c < C);
}
}
void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *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;
opus_val16 offset;
q2 = ec_dec_bits(dec, 1); #ifdef FIXED_POINT
offset = SHR16(SHL16(q2,DB_SHIFT)-QCONST16(.5f,DB_SHIFT),fine_quant[i]+1); #else
offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); #endif
oldEBands[i+c*m->nbEBands] += offset;
bits_left--;
} while (++c < C);
}
}
}
void amp2Log2(const CELTMode *m, int effEnd, int end,
celt_ener *bandE, opus_val16 *bandLogE, int C)
{ int c, i;
c=0; do { for (i=0;i<effEnd;i++)
{
bandLogE[i+c*m->nbEBands] =
celt_log2(bandE[i+c*m->nbEBands])
- SHL16((opus_val16)eMeans[i],6); #ifdef FIXED_POINT /* Compensate for bandE[] being Q12 but celt_log2() taking a Q14 input. */
bandLogE[i+c*m->nbEBands] += QCONST16(2.f, DB_SHIFT); #endif
} for (i=effEnd;i<end;i++)
bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT);
} while (++c < C);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
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.