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

Function decode_tns

libavcodec/aacdec.c:854–887  ·  view source on GitHub ↗

* Decode Temporal Noise Shaping data; reference: table 4.48. * * @return Returns error status. 0 - OK, !0 - error */

Source from the content-addressed store, hash-verified

852 * @return Returns error status. 0 - OK, !0 - error
853 */
854static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
855 GetBitContext *gb, const IndividualChannelStream *ics)
856{
857 int w, filt, i, coef_len, coef_res, coef_compress;
858 const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE;
859 const int tns_max_order = is8 ? 7 : ac->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;
860 for (w = 0; w < ics->num_windows; w++) {
861 if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) {
862 coef_res = get_bits1(gb);
863
864 for (filt = 0; filt < tns->n_filt[w]; filt++) {
865 int tmp2_idx;
866 tns->length[w][filt] = get_bits(gb, 6 - 2 * is8);
867
868 if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) {
869 av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
870 tns->order[w][filt], tns_max_order);
871 tns->order[w][filt] = 0;
872 return -1;
873 }
874 if (tns->order[w][filt]) {
875 tns->direction[w][filt] = get_bits1(gb);
876 coef_compress = get_bits1(gb);
877 coef_len = coef_res + 3 - coef_compress;
878 tmp2_idx = 2 * coef_compress + coef_res;
879
880 for (i = 0; i < tns->order[w][filt]; i++)
881 tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
882 }
883 }
884 }
885 }
886 return 0;
887}
888
889/**
890 * Decode Mid/Side data; reference: table 4.54.

Callers 1

decode_icsFunction · 0.85

Calls 3

get_bitsFunction · 0.85
get_bits1Function · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected