Skip to content

Instantly share code, notes, and snippets.

@MaZderMind
Created January 4, 2017 20:47
Show Gist options
  • Save MaZderMind/0f4db43ba99873f8db4a114897c11e38 to your computer and use it in GitHub Desktop.
Save MaZderMind/0f4db43ba99873f8db4a114897c11e38 to your computer and use it in GitHub Desktop.
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index c4b30b4926..7bbce7b1a5 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -111,6 +111,7 @@ typedef struct {
struct rect gauge; ///< rectangle for the gauge on the right
AVFrame *outpicref; ///< output picture reference, updated regularly
int meter; ///< select a EBU mode between +9 and +18
+ int reference; ///< reference level in LUFS
int scale_range; ///< the range of LU values according to the meter
int y_zero_lu; ///< the y value (pixel position) for 0 LU
int *y_line_ref; ///< y reference values for drawing the LU lines in the graph and the gauge
@@ -157,6 +158,7 @@ static const AVOption ebur128_options[] = {
{ "video", "set video output", OFFSET(do_video), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, V|F },
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, V|F },
{ "meter", "set scale meter (+9 to +18)", OFFSET(meter), AV_OPT_TYPE_INT, {.i64 = 9}, 9, 18, V|F },
+ { "reference", "set reference level (-30 to 0)", OFFSET(reference), AV_OPT_TYPE_INT, {.i64 = -23}, -30, 0, V|F },
{ "framelog", "force frame logging level", OFFSET(loglevel), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, A|V|F, "level" },
{ "info", "information logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_INFO}, INT_MIN, INT_MAX, A|V|F, "level" },
{ "verbose", "verbose logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_VERBOSE}, INT_MIN, INT_MAX, A|V|F, "level" },
@@ -729,8 +731,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
int x, y, ret;
uint8_t *p;
- const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 + 23);
- const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400 + 23);
+ const int y_loudness_lu_graph = lu_to_y(ebur128, loudness_3000 - ebur128->reference);
+ const int y_loudness_lu_gauge = lu_to_y(ebur128, loudness_400 - ebur128->reference);
/* draw the graph using the short-term loudness */
p = pic->data[0] + ebur128->graph.y*pic->linesize[0] + ebur128->graph.x*3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment