Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -26,13 +26,15 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "avfilter.h" |
| 27 | 27 | #include "internal.h" |
| 28 | 28 | |
| 29 | +#define BINS 10000 | |
| 30 | + | |
| 29 | 31 | typedef struct ChannelStats { |
| 30 | 32 | uint64_t nb_samples; |
| 31 | 33 | uint64_t blknum; |
| 32 | 34 | float peak; |
| 33 | 35 | float sum; |
| 34 | − uint32_t peaks[10001]; | |
| 35 | − uint32_t rms[10001]; | |
| 36 | + uint32_t peaks[BINS+1]; | |
| 37 | + uint32_t rms[BINS+1]; | |
| 36 | 38 | } ChannelStats; |
| 37 | 39 | |
| 38 | 40 | typedef struct DRMeterContext { |
| @@ -73,8 +75,8 @@ static void finish_block(ChannelStats *p) · 34 unmodified lines | ||
| 73 | 75 | |
| 74 | 76 | rms = sqrt(2 * p->sum / p->nb_samples); |
| 75 | 77 | peak = p->peak; |
| 76 | − rms_bin = av_clip(rms * 10000, 0, 10000); | |
| 77 | − peak_bin = av_clip(peak * 10000, 0, 10000); | |
| 78 | + rms_bin = av_clip(rms * BINS, 0, BINS); | |
| 79 | + peak_bin = av_clip(peak * BINS, 0, BINS); | |
| 78 | 80 | p->rms[rms_bin]++; |
| 79 | 81 | p->peaks[peak_bin]++; |
| 80 | 82 | |
| @@ -144,29 +146,29 @@ static void print_stats(AVFilterContext *ctx) · 63 unmodified lines | ||
| 144 | 146 | |
| 145 | 147 | finish_block(p); |
| 146 | 148 | |
| 147 | − for (i = 0; i <= 10000; i++) { | |
| 148 | − if (p->peaks[10000 - i]) { | |
| 149 | + for (i = 0; i <= BINS; i++) { | |
| 150 | + if (p->peaks[BINS - i]) { | |
| 149 | 151 | if (first) |
| 150 | 152 | break; |
| 151 | 153 | first = 1; |
| 152 | 154 | } |
| 153 | 155 | } |
| 154 | 156 | |
| 155 | − secondpeak = (10000 - i) / 10000.; | |
| 157 | + secondpeak = (BINS - i) / (double)BINS; | |
| 156 | 158 | |
| 157 | − for (i = 10000, j = 0; i >= 0 && j < 0.2 * p->blknum; i--) { | |
| 159 | + for (i = BINS, j = 0; i >= 0 && j < 0.2 * p->blknum; i--) { | |
| 158 | 160 | if (p->rms[i]) { |
| 159 | − rmssum += SQR(i / 10000.) * p->rms[i]; | |
| 161 | + rmssum += SQR(i / (double)BINS) * p->rms[i]; | |
| 160 | 162 | j += p->rms[i]; |
| 161 | 163 | } |
| 162 | 164 | } |
| 163 | 165 | |
| 164 | 166 | chdr = 20 * log10(secondpeak / sqrt(rmssum / (0.2 * p->blknum))); |
| 165 | 167 | dr += chdr; |
| 166 | − av_log(ctx, AV_LOG_INFO, "Channel %d: DR: %.1f\n", ch + 1, chdr); | |
| 168 | + av_log(ctx, AV_LOG_INFO, "Channel %d: DR: %g\n", ch + 1, chdr); | |
| 167 | 169 | } |
| 168 | 170 | |
| 169 | − av_log(ctx, AV_LOG_INFO, "Overall DR: %.1f\n", dr / s->nb_channels); | |
| 171 | + av_log(ctx, AV_LOG_INFO, "Overall DR: %g\n", dr / s->nb_channels); | |
| 170 | 172 | } |
| 171 | 173 | |
| 172 | 174 | static av_cold void uninit(AVFilterContext *ctx) |