• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/minidlna/ffmpeg-2.3.4/libavfilter/

Lines Matching defs:ebur128

169 AVFILTER_DEFINE_CLASS(ebur128);
182 static const uint8_t *get_graph_color(const EBUR128Context *ebur128, int v, int y)
184 const int below0 = y > ebur128->y_zero_lu;
186 const int line = ebur128->y_line_ref[y] || y == ebur128->y_zero_lu;
191 static inline int lu_to_y(const EBUR128Context *ebur128, double v)
193 v += 2 * ebur128->meter; // make it in range [0;...]
194 v = av_clipf(v, 0, ebur128->scale_range); // make sure it's in the graph scale
195 v = ebur128->scale_range - v; // invert value (y=0 is on top)
196 return v * ebur128->graph.h / ebur128->scale_range; // rescale from scale range to px height
256 EBUR128Context *ebur128 = ctx->priv;
260 if (ebur128->w < 640 || ebur128->h < 480) {
262 "minimum size is 640x480\n", ebur128->w, ebur128->h);
265 outlink->w = ebur128->w;
266 outlink->h = ebur128->h;
271 ebur128->text.x = PAD;
272 ebur128->text.y = 40;
273 ebur128->text.w = 3 * 8; // 3 characters
274 ebur128->text.h = ebur128->h - PAD - ebur128->text.y;
277 ebur128->gauge.w = 20;
278 ebur128->gauge.h = ebur128->text.h;
279 ebur128->gauge.x = ebur128->w - PAD - ebur128->gauge.w;
280 ebur128->gauge.y = ebur128->text.y;
283 ebur128->graph.x = ebur128->text.x + ebur128->text.w + PAD;
284 ebur128->graph.y = ebur128->gauge.y;
285 ebur128->graph.w = ebur128->gauge.x - ebur128->graph.x - PAD;
286 ebur128->graph.h = ebur128->gauge.h;
289 av_assert0(ebur128->graph.h == ebur128->gauge.h);
292 av_frame_free(&ebur128->outpicref);
293 ebur128->outpicref = outpicref =
300 ebur128->y_line_ref = av_calloc(ebur128->graph.h + 1, sizeof(*ebur128->y_line_ref));
301 if (!ebur128->y_line_ref)
305 memset(outpicref->data[0], 0, ebur128->h * outpicref->linesize[0]);
309 for (i = ebur128->meter; i >= -ebur128->meter * 2; i--) {
310 y = lu_to_y(ebur128, i);
312 ebur128->y_line_ref[y] = i;
314 drawtext(outpicref, x, y + ebur128->graph.y, FONT8, font_colors+3,
319 ebur128->y_zero_lu = lu_to_y(ebur128, 0);
320 p = outpicref->data[0] + ebur128->graph.y * outpicref->linesize[0]
321 + ebur128->graph.x * 3;
322 for (y = 0; y < ebur128->graph.h; y++) {
323 const uint8_t *c = get_graph_color(ebur128, INT_MAX, y);
325 for (x = 0; x < ebur128->graph.w; x++)
337 DRAW_RECT(ebur128->graph);
338 DRAW_RECT(ebur128->gauge);
348 EBUR128Context *ebur128 = ctx->priv;
356 if (ebur128->metadata || (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS))
368 EBUR128Context *ebur128 = ctx->priv;
376 ebur128->nb_channels = nb_channels;
377 ebur128->ch_weighting = av_calloc(nb_channels, sizeof(*ebur128->ch_weighting));
378 if (!ebur128->ch_weighting)
390 ebur128->ch_weighting[i] = 0;
392 ebur128->ch_weighting[i] = 1.41;
394 ebur128->ch_weighting[i] = 1.0;
399 if (!ebur128->ch_weighting[i])
403 ebur128->i400.cache[i] = av_calloc(I400_BINS, sizeof(*ebur128->i400.cache[0]));
404 ebur128->i3000.cache[i] = av_calloc(I3000_BINS, sizeof(*ebur128->i3000.cache[0]));
405 if (!ebur128->i400.cache[i] || !ebur128->i3000.cache[i])
412 if (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS) {
415 ebur128->swr_buf = av_malloc_array(nb_channels, 19200 * sizeof(double));
416 ebur128->true_peaks = av_calloc(nb_channels, sizeof(*ebur128->true_peaks));
417 ebur128->true_peaks_per_frame = av_calloc(nb_channels, sizeof(*ebur128->true_peaks_per_frame));
418 ebur128->swr_ctx = swr_alloc();
419 if (!ebur128->swr_buf || !ebur128->true_peaks ||
420 !ebur128->true_peaks_per_frame || !ebur128->swr_ctx)
423 av_opt_set_int(ebur128->swr_ctx, "in_channel_layout", outlink->channel_layout, 0);
424 av_opt_set_int(ebur128->swr_ctx, "in_sample_rate", outlink->sample_rate, 0);
425 av_opt_set_sample_fmt(ebur128->swr_ctx, "in_sample_fmt", outlink->format, 0);
427 av_opt_set_int(ebur128->swr_ctx, "out_channel_layout", outlink->channel_layout, 0);
428 av_opt_set_int(ebur128->swr_ctx, "out_sample_rate", 192000, 0);
429 av_opt_set_sample_fmt(ebur128->swr_ctx, "out_sample_fmt", outlink->format, 0);
431 ret = swr_init(ebur128->swr_ctx);
437 if (ebur128->peak_mode & PEAK_MODE_SAMPLES_PEAKS) {
438 ebur128->sample_peaks = av_calloc(nb_channels, sizeof(*ebur128->sample_peaks));
439 if (!ebur128->sample_peaks)
466 EBUR128Context *ebur128 = ctx->priv;
469 if (ebur128->loglevel != AV_LOG_INFO &&
470 ebur128->loglevel != AV_LOG_VERBOSE) {
471 if (ebur128->do_video || ebur128->metadata)
472 ebur128->loglevel = AV_LOG_VERBOSE;
474 ebur128->loglevel = AV_LOG_INFO;
477 if (!CONFIG_SWRESAMPLE && (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS)) {
485 ebur128->scale_range = 3 * ebur128->meter;
487 ebur128->i400.histogram = get_histogram();
488 ebur128->i3000.histogram = get_histogram();
489 if (!ebur128->i400.histogram || !ebur128->i3000.histogram)
492 ebur128->integrated_loudness = ABS_THRES;
493 ebur128->loudness_range = 0;
496 if (ebur128->do_video) {
507 .name = av_asprintf("out%d", ebur128->do_video),
513 ff_insert_outpad(ctx, ebur128->do_video, &pad);
516 av_log(ctx, AV_LOG_VERBOSE, "EBU +%d scale\n", ebur128->meter);
552 EBUR128Context *ebur128 = ctx->priv;
553 const int nb_channels = ebur128->nb_channels;
556 AVFrame *pic = ebur128->outpicref;
559 if (ebur128->peak_mode & PEAK_MODE_TRUE_PEAKS) {
560 const double *swr_samples = ebur128->swr_buf;
561 int ret = swr_convert(ebur128->swr_ctx, (uint8_t**)&ebur128->swr_buf, 19200,
566 ebur128->true_peaks_per_frame[ch] = 0.0;
569 ebur128->true_peaks[ch] = FFMAX(ebur128->true_peaks[ch], FFABS(*swr_samples));
570 ebur128->true_peaks_per_frame[ch] = FFMAX(ebur128->true_peaks_per_frame[ch],
579 const int bin_id_400 = ebur128->i400.cache_pos;
580 const int bin_id_3000 = ebur128->i3000.cache_pos;
583 ebur128->i##time.cache_pos++; \
584 if (ebur128->i##time.cache_pos == I##time##_BINS) { \
585 ebur128->i##time.filled = 1; \
586 ebur128->i##time.cache_pos = 0; \
596 if (ebur128->peak_mode & PEAK_MODE_SAMPLES_PEAKS)
597 ebur128->sample_peaks[ch] = FFMAX(ebur128->sample_peaks[ch], FFABS(*samples));
599 ebur128->x[ch * 3] = *samples++; // set X[i]
601 if (!ebur128->ch_weighting[ch])
606 double *dst = ebur128->Y + ch*3; \
607 double *src = ebur128->X + ch*3; \
616 ebur128->x[ch * 3 + 2] = ebur128->x[ch * 3 + 1];
617 ebur128->x[ch * 3 + 1] = ebur128->x[ch * 3 ];
620 bin = ebur128->z[ch * 3] * ebur128->z[ch * 3];
624 ebur128->i400.sum [ch] = ebur128->i400.sum [ch] + bin - ebur128->i400.cache [ch][bin_id_400];
625 ebur128->i3000.sum[ch] = ebur128->i3000.sum[ch] + bin - ebur128->i3000.cache[ch][bin_id_3000];
628 ebur128->i400.cache [ch][bin_id_400 ] = bin;
629 ebur128->i3000.cache[ch][bin_id_3000] = bin;
635 if (++ebur128->sample_count == 4800) {
643 ebur128->sample_count = 0;
646 if (ebur128->i##time.filled) { \
649 power_##time += ebur128->ch_weighting[ch] * ebur128->i##time.sum[ch]; \
664 int gate_hist_pos = gate_update(&ebur128->i400, power_400,
670 const int nb_v = ebur128->i400.histogram[i].count;
672 integrated_sum += nb_v * ebur128->i400.histogram[i].energy;
675 ebur128->integrated_loudness = LOUDNESS(integrated_sum / nb_integrated);
687 int gate_hist_pos = gate_update(&ebur128->i3000, power_3000,
691 nb_powers += ebur128->i3000.histogram[i].count;
699 n += ebur128->i3000.histogram[i].count;
701 ebur128->lra_low = ebur128->i3000.histogram[i].loudness;
710 n -= ebur128->i3000.histogram[i].count;
712 ebur128->lra_high = ebur128->i3000.histogram[i].loudness;
718 ebur128->loudness_range = ebur128->lra_high - ebur128->lra_low;
725 if (ebur128->do_video) {
729 const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 + 23);
730 const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400 + 23);
733 p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + ebur128->graph.x*3;
734 for (y = 0; y < ebur128->graph.h; y++) {
735 const uint8_t *c = get_graph_color(ebur128, y_loudness_lu_graph, y);
737 memmove(p, p + 3, (ebur128->graph.w - 1) * 3);
738 memcpy(p + (ebur128->graph.w - 1) * 3, c, 3);
743 p = pic->data[0] + ebur128->gauge.y*pic->linesize[0] + ebur128->gauge.x*3;
744 for (y = 0; y < ebur128->gauge.h; y++) {
745 const uint8_t *c = get_graph_color(ebur128, y_loudness_lu_gauge, y);
747 for (x = 0; x < ebur128->gauge.w; x++)
756 ebur128->integrated_loudness, ebur128->loudness_range);
765 if (ebur128->metadata) { /* happens only once per filter_frame call */
775 if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
780 SET_META(key, ebur128->name##_peaks[ch]); \
787 SET_META(META_PREFIX "I", ebur128->integrated_loudness);
788 SET_META(META_PREFIX "LRA", ebur128->loudness_range);
789 SET_META(META_PREFIX "LRA.low", ebur128->lra_low);
790 SET_META(META_PREFIX "LRA.high", ebur128->lra_high);
796 av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT,
799 ebur128->integrated_loudness, ebur128->loudness_range);
802 if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
803 av_log(ctx, ebur128->loglevel, " " str ":"); \
805 av_log(ctx, ebur128->loglevel, " %5.1f", DBFS(sp[ch])); \
806 av_log(ctx, ebur128->loglevel, " dBFS"); \
810 PRINT_PEAKS("SPK", ebur128->sample_peaks, SAMPLES);
811 PRINT_PEAKS("FTPK", ebur128->true_peaks_per_frame, TRUE);
812 PRINT_PEAKS("TPK", ebur128->true_peaks, TRUE);
813 av_log(ctx, ebur128->loglevel, "\n");
817 return ff_filter_frame(ctx->outputs[ebur128->do_video], insamples);
822 EBUR128Context *ebur128 = ctx->priv;
833 if (ebur128->do_video) {
868 EBUR128Context *ebur128 = ctx->priv;
879 ebur128->integrated_loudness, ebur128->i400.rel_threshold,
880 ebur128->loudness_range, ebur128->i3000.rel_threshold,
881 ebur128->lra_low, ebur128->lra_high);
887 if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
888 for (ch = 0; ch < ebur128->nb_channels; ch++) \
896 PRINT_PEAK_SUMMARY("Sample", ebur128->sample_peaks, SAMPLES);
897 PRINT_PEAK_SUMMARY("True", ebur128->true_peaks, TRUE);
900 av_freep(&ebur128->y_line_ref);
901 av_freep(&ebur128->ch_weighting);
902 av_freep(&ebur128->true_peaks);
903 av_freep(&ebur128->sample_peaks);
904 av_freep(&ebur128->true_peaks_per_frame);
905 av_freep(&ebur128->i400.histogram);
906 av_freep(&ebur128->i3000.histogram);
907 for (i = 0; i < ebur128->nb_channels; i++) {
908 av_freep(&ebur128->i400.cache[i]);
909 av_freep(&ebur128->i3000.cache[i]);
913 av_frame_free(&ebur128->outpicref);
915 av_freep(&ebur128->swr_buf);
916 swr_free(&ebur128->swr_ctx);
931 .name = "ebur128",