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

Function assign_bits

libavcodec/dcaenc.c:924–964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

922}
923
924static void assign_bits(DCAEncContext *c)
925{
926 /* Find the bounds where the binary search should work */
927 int low, high, down;
928 int used_abits = 0;
929 int forbid_zero = 1;
930restart:
931 init_quantization_noise(c, c->worst_quantization_noise, forbid_zero);
932 low = high = c->worst_quantization_noise;
933 if (c->consumed_bits > c->frame_bits) {
934 while (c->consumed_bits > c->frame_bits) {
935 if (used_abits == USED_1ABITS && forbid_zero) {
936 forbid_zero = 0;
937 goto restart;
938 }
939 low = high;
940 high += snr_fudge;
941 used_abits = init_quantization_noise(c, high, forbid_zero);
942 }
943 } else {
944 while (c->consumed_bits <= c->frame_bits) {
945 high = low;
946 if (used_abits == USED_26ABITS)
947 goto out; /* The requested bitrate is too high, pad with zeros */
948 low -= snr_fudge;
949 used_abits = init_quantization_noise(c, low, forbid_zero);
950 }
951 }
952
953 /* Now do a binary search between low and high to see what fits */
954 for (down = snr_fudge >> 1; down; down >>= 1) {
955 init_quantization_noise(c, high - down, forbid_zero);
956 if (c->consumed_bits <= c->frame_bits)
957 high -= down;
958 }
959 init_quantization_noise(c, high, forbid_zero);
960out:
961 c->worst_quantization_noise = high;
962 if (high > c->worst_noise_ever)
963 c->worst_noise_ever = high;
964}
965
966static void shift_history(DCAEncContext *c, const int32_t *input)
967{

Callers 1

encode_frameFunction · 0.85

Calls 1

init_quantization_noiseFunction · 0.85

Tested by

no test coverage detected