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

Function sonic_encode_frame

libavcodec/sonic.c:624–744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

622}
623
624static int sonic_encode_frame(AVCodecContext *avctx,
625 uint8_t *buf, int buf_size, void *data)
626{
627 SonicContext *s = avctx->priv_data;
628 PutBitContext pb;
629 int i, j, ch, quant = 0, x = 0;
630 short *samples = data;
631
632 init_put_bits(&pb, buf, buf_size*8);
633
634 // short -> internal
635 for (i = 0; i < s->frame_size; i++)
636 s->int_samples[i] = samples[i];
637
638 if (!s->lossless)
639 for (i = 0; i < s->frame_size; i++)
640 s->int_samples[i] = s->int_samples[i] << SAMPLE_SHIFT;
641
642 switch(s->decorrelation)
643 {
644 case MID_SIDE:
645 for (i = 0; i < s->frame_size; i += s->channels)
646 {
647 s->int_samples[i] += s->int_samples[i+1];
648 s->int_samples[i+1] -= shift(s->int_samples[i], 1);
649 }
650 break;
651 case LEFT_SIDE:
652 for (i = 0; i < s->frame_size; i += s->channels)
653 s->int_samples[i+1] -= s->int_samples[i];
654 break;
655 case RIGHT_SIDE:
656 for (i = 0; i < s->frame_size; i += s->channels)
657 s->int_samples[i] -= s->int_samples[i+1];
658 break;
659 }
660
661 memset(s->window, 0, 4* s->window_size);
662
663 for (i = 0; i < s->tail_size; i++)
664 s->window[x++] = s->tail[i];
665
666 for (i = 0; i < s->frame_size; i++)
667 s->window[x++] = s->int_samples[i];
668
669 for (i = 0; i < s->tail_size; i++)
670 s->window[x++] = 0;
671
672 for (i = 0; i < s->tail_size; i++)
673 s->tail[i] = s->int_samples[s->frame_size - s->tail_size + i];
674
675 // generate taps
676 modified_levinson_durbin(s->window, s->window_size,
677 s->predictor_k, s->num_taps, s->channels, s->tap_quant);
678 if (intlist_write(&pb, s->predictor_k, s->num_taps, 0) < 0)
679 return -1;
680
681 for (ch = 0; ch < s->channels; ch++)

Callers

nothing calls this directly

Calls 8

init_put_bitsFunction · 0.85
shiftFunction · 0.85
modified_levinson_durbinFunction · 0.85
intlist_writeFunction · 0.85
set_ue_golombFunction · 0.85
divideFunction · 0.85
flush_put_bitsFunction · 0.85
put_bits_countFunction · 0.85

Tested by

no test coverage detected