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

Function sonic_decode_frame

libavcodec/sonic.c:850–936  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

848}
849
850static int sonic_decode_frame(AVCodecContext *avctx,
851 void *data, int *data_size,
852 AVPacket *avpkt)
853{
854 const uint8_t *buf = avpkt->data;
855 int buf_size = avpkt->size;
856 SonicContext *s = avctx->priv_data;
857 GetBitContext gb;
858 int i, quant, ch, j;
859 short *samples = data;
860
861 if (buf_size == 0) return 0;
862
863// av_log(NULL, AV_LOG_INFO, "buf_size: %d\n", buf_size);
864
865 init_get_bits(&gb, buf, buf_size*8);
866
867 intlist_read(&gb, s->predictor_k, s->num_taps, 0);
868
869 // dequantize
870 for (i = 0; i < s->num_taps; i++)
871 s->predictor_k[i] *= s->tap_quant[i];
872
873 if (s->lossless)
874 quant = 1;
875 else
876 quant = get_ue_golomb(&gb) * SAMPLE_FACTOR;
877
878// av_log(NULL, AV_LOG_INFO, "quant: %d\n", quant);
879
880 for (ch = 0; ch < s->channels; ch++)
881 {
882 int x = ch;
883
884 predictor_init_state(s->predictor_k, s->predictor_state[ch], s->num_taps);
885
886 intlist_read(&gb, s->coded_samples[ch], s->block_align, 1);
887
888 for (i = 0; i < s->block_align; i++)
889 {
890 for (j = 0; j < s->downsampling - 1; j++)
891 {
892 s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, 0);
893 x += s->channels;
894 }
895
896 s->int_samples[x] = predictor_calc_error(s->predictor_k, s->predictor_state[ch], s->num_taps, s->coded_samples[ch][i] * quant);
897 x += s->channels;
898 }
899
900 for (i = 0; i < s->num_taps; i++)
901 s->predictor_state[ch][i] = s->int_samples[s->frame_size - s->channels + ch - i*s->channels];
902 }
903
904 switch(s->decorrelation)
905 {
906 case MID_SIDE:
907 for (i = 0; i < s->frame_size; i += s->channels)

Callers

nothing calls this directly

Calls 9

init_get_bitsFunction · 0.85
intlist_readFunction · 0.85
get_ue_golombFunction · 0.85
predictor_init_stateFunction · 0.85
predictor_calc_errorFunction · 0.85
shiftFunction · 0.85
av_clip_int16Function · 0.85
align_get_bitsFunction · 0.85
get_bits_countFunction · 0.85

Tested by

no test coverage detected