33 uint64_t histogram[0x10001];
67 for (plane = 0; plane < nb_planes; plane++) {
69 for (i = 0; i < nb_samples; i++)
78 static inline double logdb(uint64_t
v)
80 double d = v / (double)(0x8000 * 0x8000);
83 return log(d) * -4.3429448190325182765112891891660508229;
89 int i, max_volume,
shift;
90 uint64_t nb_samples = 0, power = 0, nb_samples_shift = 0, sum = 0;
91 uint64_t histdb[
MAX_DB + 1] = { 0 };
93 for (i = 0; i < 0x10000; i++)
103 shift =
av_log2(nb_samples >> 33);
104 for (i = 0; i < 0x10000; i++) {
106 power += (i - 0x8000) * (i - 0x8000) * (vd->
histogram[i] >>
shift);
108 if (!nb_samples_shift)
110 power = (power + nb_samples_shift / 2) / nb_samples_shift;
115 while (max_volume > 0 && !vd->
histogram[0x8000 + max_volume] &&
120 for (i = 0; i < 0x10000; i++)
121 histdb[(
int)
logdb((i - 0x8000) * (i - 0x8000))] += vd->
histogram[i];
122 for (i = 0; i <=
MAX_DB && !histdb[i]; i++);
123 for (; i <=
MAX_DB && sum < nb_samples / 1000; i++) {
152 .
name =
"volumedetect",
157 .
inputs = volumedetect_inputs,
158 .
outputs = volumedetect_outputs,