]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/audiobargraph_v.c
mft: Link to mfplat when building with msvc
[vlc] / modules / video_filter / audiobargraph_v.c
index 425e75d06bad5e325684f40babd2356708cc2c43..bde9b083dd4f392d57fb8b7e8b163a5c1e60c03f 100644 (file)
 
 #include <vlc_image.h>
 
-#ifdef LoadImage
-#   undef LoadImage
-#endif
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -166,7 +162,7 @@ static float iec_scale(float dB)
         return (dB + 70.0f) * 0.0025f;
     if (dB < -50.0f)
         return (dB + 60.0f) * 0.005f + 0.025f;
-    if (dB < -40.0)
+    if (dB < -40.0f)
         return (dB + 50.0f) * 0.0075f + 0.075f;
     if (dB < -30.0f)
         return (dB + 40.0f) * 0.015f + 0.15f;
@@ -182,386 +178,138 @@ static float iec_scale(float dB)
  *****************************************************************************/
 static void parse_i_values(BarGraph_t *p_BarGraph, char *i_values)
 {
-    char* res = NULL;
     char delim[] = ":";
     char* tok;
-    float db;
 
     p_BarGraph->nbChannels = 0;
+    free(p_BarGraph->i_values);
     p_BarGraph->i_values = NULL;
-    res = strtok_r(i_values, delim, &tok);
+    char *res = strtok_r(i_values, delim, &tok);
     while (res != NULL) {
         p_BarGraph->nbChannels++;
         p_BarGraph->i_values = xrealloc(p_BarGraph->i_values,
                                           p_BarGraph->nbChannels*sizeof(int));
-        db = log10(atof(res)) * 20;
+        float db = log10(atof(res)) * 20;
         p_BarGraph->i_values[p_BarGraph->nbChannels-1] = VLC_CLIP(iec_scale(db)*p_BarGraph->scale, 0, p_BarGraph->scale);
         res = strtok_r(NULL, delim, &tok);
     }
-
 }
 
-/*****************************************************************************
- * LoadImage: creates and returns the bar graph image
- *****************************************************************************/
-static picture_t *LoadImage(vlc_object_t *p_this, int nbChannels, int* i_values, int scale, int alarm, int barWidth)
-{
-    VLC_UNUSED(p_this);
-    picture_t *p_pic;
-    int i, j, pi;
-    int i_width = 0;
-    int i_line;
-    int minus8, minus10, minus18, minus20, minus30, minus40, minus50, minus60;
+/* Drawing */
 
-    if (nbChannels == 0)
-        i_width = 20;
-    else
-        i_width = 2 * nbChannels * barWidth + 10;
-
-    minus8  = iec_scale(-8)*scale + 20;
-    minus10 = iec_scale(-10)*scale + 20;
-    minus18 = iec_scale(-18)*scale + 20;
-    minus20 = iec_scale(-20)*scale + 20;
-    minus30 = iec_scale(-30)*scale + 20;
-    minus40 = iec_scale(-40)*scale + 20;
-    minus50 = iec_scale(-50)*scale + 20;
-    minus60 = iec_scale(-60)*scale + 20;
-
-    p_pic = picture_New(VLC_FOURCC('Y','U','V','A'), i_width+20, scale+30, 1, 1);
-
-
-#define DrawLine(a,b,Y,U,V,A) \
-        for (i=a; i<b; i++) {\
-            *(p_pic->p[0].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[0].i_pitch + i) = Y;\
-            *(p_pic->p[1].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[1].i_pitch + i) = U;\
-            *(p_pic->p[2].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[2].i_pitch + i) = V;\
-            *(p_pic->p[3].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[3].i_pitch + i) = A; \
-        }
-#define DrawLineBlack(a,b) DrawLine(a,b,0,128,128,0xFF)
-#define DrawLineWhite(a,b) DrawLine(a,b,255,128,128,0xFF)
+static const uint8_t bright_red[4]   = { 76, 85, 0xff, 0xff };
+static const uint8_t black[4] = { 0x00, 0x80, 0x80, 0xff };
+static const uint8_t white[4] = { 0xff, 0x80, 0x80, 0xff };
+static const uint8_t bright_green[4] = { 150, 44, 21, 0xff };
+static const uint8_t bright_yellow[4] = { 226, 1, 148, 0xff };
+static const uint8_t green[4] = { 74, 85, 74, 0xff };
+static const uint8_t yellow[4] = { 112, 64, 138, 0xff };
+static const uint8_t red[4] = { 37, 106, 191, 0xff };
 
-    // blacken the whole picture
-    for (i = 0 ; i < p_pic->i_planes ; i++) {
-        memset(p_pic->p[i].p_pixels, 0x00,
-                p_pic->p[i].i_visible_lines * p_pic->p[i].i_pitch);
-    }
+static inline void DrawHLine(plane_t *p, int line, int col, const uint8_t color[4], int w)
+{
+    for (int j = 0; j < 4; j++)
+        memset(&p[j].p_pixels[line * p[j].i_pitch + col], color[j], w);
+}
 
+static void Draw2VLines(plane_t *p, int scale, int col, const uint8_t color[4])
+{
+    for (int i = 10; i < scale + 10; i++)
+        DrawHLine(p, i, col, color, 2);
+}
 
-    // side bar
-    for (i_line = 20; i_line < scale+20; i_line++) {
-        // vertical line
-        DrawLineBlack(20,22);
-        DrawLineWhite(22,24);
+static void DrawHLines(plane_t *p, int line, int col, const uint8_t color[4], int h, int w)
+{
+    for (int i = line; i < line + h; i++)
+        DrawHLine(p, i, col, color, w);
+}
 
-        // -10dB
-        if (i_line == minus10 - 2) {
-            // 1
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-        if (i_line == minus10 - 1) {
-            // 1
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineWhite(24,27); //White
-        }
-        if (i_line == minus10) {
-            // 1
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus10 + 1) {
-            // 1
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus10 + 2) {
-            // 1
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,19);
+static void DrawNumber(plane_t *p, int h, const uint8_t data[5], int l)
+{
+    for (int i = 0; i < 5; i++) {
+        uint8_t x = data[i];
+        for (int j = 0; j < 7; j++) {
+            x <<= 1;
+            if (x & 0x80)
+                DrawHLine(p, h - l + 2 - 1 - i, 12 + j, black, 1);
         }
+    }
+}
+/*****************************************************************************
+ * Draw: creates and returns the bar graph image
+ *****************************************************************************/
+static void Draw(BarGraph_t *b)
+{
+    int nbChannels = b->nbChannels;
+    int scale      = b->scale;
+    int barWidth   = b->barWidth;
+
+    int w = 40;
+    if (nbChannels > 0)
+        w = 2 * nbChannels * barWidth + 30;
+    int h = scale + 30;
+
+    int level[6];
+    for (int i = 0; i < 6; i++)
+        level[i] = iec_scale(-(i+1) * 10) * scale + 20;
+
+    if (b->p_pic)
+        picture_Release(b->p_pic);
+    b->p_pic = picture_New(VLC_FOURCC('Y','U','V','A'), w, h, 1, 1);
+    if (!b->p_pic)
+        return;
+    picture_t *p_pic = b->p_pic;
+    plane_t *p = p_pic->p;
+
+    for (int i = 0 ; i < p_pic->i_planes ; i++)
+        memset(p[i].p_pixels, 0x00, p[i].i_visible_lines * p[i].i_pitch);
+
+    Draw2VLines(p, scale, 20, black);
+    Draw2VLines(p, scale, 22, white);
+
+    static const uint8_t pixmap[6][5] = {
+        { 0x17, 0x15, 0x15, 0x15, 0x17 },
+        { 0x77, 0x45, 0x75, 0x15, 0x77 },
+        { 0x77, 0x15, 0x75, 0x15, 0x77 },
+        { 0x17, 0x15, 0x75, 0x55, 0x57 },
+        { 0x77, 0x15, 0x75, 0x45, 0x77 },
+        { 0x77, 0x55, 0x75, 0x45, 0x77 },
+    };
+
+    for (int i = 0; i < 6; i++) {
+        DrawHLines(p, h - 1 - level[i] - 1, 24, white, 1, 3);
+        DrawHLines(p, h - 1 - level[i],     24, black, 2, 3);
+        DrawNumber(p, h, pixmap[i], level[i]);
+    }
 
-        // -20dB
-        if (i_line == minus20 - 2) {
-            // 2
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-        if (i_line == minus20 - 1) {
-            // 2
-            DrawLineBlack(12,13);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineWhite(24,27); //White
-        }
-        if (i_line == minus20) {
-            // 2
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus20 + 1) {
-            // 2
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus20 + 2) {
-            // 2
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
+    int minus8  = iec_scale(- 8) * scale + 20;
+    int minus18 = iec_scale(-18) * scale + 20;
+    int *i_values  = b->i_values;
+    const uint8_t *indicator_color = b->alarm ? bright_red : black;
 
-        // -30dB
-        if (i_line == minus30 - 2) {
-            // 3
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-        if (i_line == minus30 - 1) {
-            // 3
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineWhite(24,27); //White
-        }
-        if (i_line == minus30) {
-            // 3
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus30 + 1) {
-            // 3
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus30 + 2) {
-            // 3
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
+    for (int i = 0; i < nbChannels; i++) {
+        int pi = 30 + i * (5 + barWidth);
 
-        // -40dB
-        if (i_line == minus40 - 2) {
-            // 4
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-        if (i_line == minus40 - 1) {
-            // 4
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineWhite(24,27); // white
-        }
-        if (i_line == minus40) {
-            // 4
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus40 + 1) {
-            // 4
-            DrawLineBlack(12,13);
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus40 + 2) {
-            // 4
-            DrawLineBlack(12,13);
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
+        DrawHLines(p, h - 20 - 1, pi, indicator_color, 8, barWidth);
 
-        // -50dB
-        if (i_line == minus50 - 2) {
-            // 5
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-        if (i_line == minus50 - 1) {
-            // 5
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineWhite(24,27); //White
-        }
-        if (i_line == minus50) {
-            // 5
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus50 + 1) {
-            // 5
-            DrawLineBlack(12,13);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus50 + 2) {
-            // 2
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-        // -60dB
-        if (i_line == minus60 - 2) {
-            // 6
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-        if (i_line == minus60 - 1) {
-            // 6
-            DrawLineBlack(12,13);
-            DrawLineBlack(14,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineWhite(24,27); //White
+        for (int line = 20; line < i_values[i] + 20; line++) {
+            if (line < minus18)
+                DrawHLines(p, h - line - 1, pi, bright_green, 1, barWidth);
+            else if (line < minus8)
+                DrawHLines(p, h - line - 1, pi, bright_yellow, 1, barWidth);
+            else
+                DrawHLines(p, h - line - 1, pi, bright_red, 1, barWidth);
         }
-        if (i_line == minus60) {
-            // 6
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus60 + 1) {
-            // 6
-            DrawLineBlack(12,13);
-            // 0
-            DrawLineBlack(16,17);
-            DrawLineBlack(18,19);
-            // limit
-            DrawLineBlack(24,27);
-        }
-        if (i_line == minus60 + 2) {
-            // 6
-            DrawLineBlack(12,15);
-            // 0
-            DrawLineBlack(16,19);
-        }
-    }
 
-#define drawPoint(offset,y,u,v,a)  do { \
-                *(p_pic->p[0].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[0].i_pitch + offset) = y; \
-                *(p_pic->p[1].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[1].i_pitch + offset) = u; \
-                *(p_pic->p[2].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[2].i_pitch + offset) = v; \
-                *(p_pic->p[3].p_pixels + (scale + 30 - i_line - 1) * p_pic->p[3].i_pitch + offset) = a; \
-                } while(0)
-
-
-    // draw the bars and channel indicators
-    for (i=0; i<nbChannels; i++) {
-        pi =  25 + ((i+1)*5) + (i*barWidth) ;  // 25 separació amb indicador, 5 separació entre barres
-
-        for (j = pi; j < pi + barWidth; j++) {
-            // channel indicators
-            for (i_line = 12; i_line < 20; i_line++) {
-                if (alarm) {
-                    drawPoint(j,76,85,0xFF,0xFF);  // red
-                } else
-                    drawPoint(j,0,128,128,0xFF); // black             DrawLine(pi,pf,0xFF,128,128,0xFF);
-            }
-
-            // bars
-            for (i_line = 20; i_line < i_values[i]+20; i_line++) {
-                if (i_line < minus18) { // green if < -18 dB
-                    drawPoint(j,150,44,21,0xFF);
-                    //DrawLine(pi,pf,150,44,21,0xFF);
-                } else if (i_line < minus8) { // yellow if > -18dB and < -8dB
-                    drawPoint(j,226,1,148,0xFF);
-                    //DrawLine(pi,pf,226,1,148,0xFF);
-                } else { // red if > -8 dB
-                    drawPoint(j,76,85,0xFF,0xFF);
-                    //DrawLine(pi,pf,76,85,255,0xFF);
-                }
-            }
-            // bars no signal
-            for (; i_line < scale+20; i_line++) {
-                if (i_line < minus18) { // green if < -18 dB
-                    drawPoint(j,74,85,74,0xFF);
-                    //DrawLine(pi,pf,74,85,74,0xFF);
-                } else if (i_line < minus8) { // yellow if > -18dB and < -8dB
-                    drawPoint(j,112,64,138,0xFF);
-                    //DrawLine(pi,pf,112,64,138,0xFF);
-                } else { // red if > -8 dB
-                    drawPoint(j,37,106,191,0xFF);
-                    //DrawLine(pi,pf,37,106,191,0xFF);
-                }
-            }
+        for (int line = i_values[i] + 20; line < scale + 20; line++) {
+            if (line < minus18)
+                DrawHLines(p, h - line - 1, pi, green, 1, barWidth);
+            else if (line < minus8)
+                DrawHLines(p, h - line - 1, pi, yellow, 1, barWidth);
+            else
+                DrawHLines(p, h - line - 1, pi, red, 1, barWidth);
         }
     }
-
-    return p_pic;
-}
-/*****************************************************************************
- * LoadBarGraph: loads the BarGraph images into memory
- *****************************************************************************/
-static void LoadBarGraph(vlc_object_t *p_this, BarGraph_t *p_BarGraph)
-{
-    p_BarGraph->p_pic = LoadImage(p_this, p_BarGraph->nbChannels, p_BarGraph->i_values, p_BarGraph->scale, p_BarGraph->alarm, p_BarGraph->barWidth);
-    if (!p_BarGraph->p_pic)
-        msg_Warn(p_this, "error while creating picture");
 }
 
 /*****************************************************************************
@@ -570,51 +318,35 @@ static void LoadBarGraph(vlc_object_t *p_this, BarGraph_t *p_BarGraph)
 static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var,
                          vlc_value_t oldval, vlc_value_t newval, void *p_data)
 {
-    VLC_UNUSED(oldval);
-    filter_sys_t *p_sys = (filter_sys_t *)p_data;
-    BarGraph_t *p_BarGraph = &(p_sys->p_BarGraph);
+    VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+    filter_sys_t *p_sys = p_data;
+    BarGraph_t *p_BarGraph = &p_sys->p_BarGraph;
     char* res = NULL;
 
     vlc_mutex_lock(&p_sys->lock);
-    if (!strcmp(psz_var, "audiobargraph_v-x"))
+    if (!strcmp(psz_var, CFG_PREFIX "x"))
         p_sys->i_pos_x = newval.i_int;
-    else if (!strcmp(psz_var, "audiobargraph_v-y"))
+    else if (!strcmp(psz_var, CFG_PREFIX "y"))
         p_sys->i_pos_y = newval.i_int;
-    else if (!strcmp(psz_var, "audiobargraph_v-position"))
+    else if (!strcmp(psz_var, CFG_PREFIX "position"))
         p_sys->i_pos = newval.i_int;
-    else if (!strcmp(psz_var, "audiobargraph_v-transparency"))
+    else if (!strcmp(psz_var, CFG_PREFIX "transparency"))
         p_BarGraph->i_alpha = VLC_CLIP(newval.i_int, 0, 255);
-    else if (!strcmp(psz_var, "audiobargraph_v-i_values")) {
-        if (p_BarGraph->p_pic) {
-            picture_Release(p_BarGraph->p_pic);
-            p_BarGraph->p_pic = NULL;
-        }
-
+    else if (!strcmp(psz_var, CFG_PREFIX "i_values")) {
         char *psz = xstrdup(newval.psz_string ? newval.psz_string : "");
-        free(p_BarGraph->i_values);
-        //p_BarGraph->i_values = NULL;
-        //p_BarGraph->nbChannels = 0;
         // in case many answer are received at the same time, only keep one
         res = strchr(psz, '@');
         if (res)
-            *res = 0;
+            *res = '\0';
         parse_i_values(p_BarGraph, psz);
         free(psz);
-        LoadBarGraph(p_this,p_BarGraph);
-    } else if (!strcmp(psz_var, "audiobargraph_v-alarm")) {
-        if (p_BarGraph->p_pic) {
-            picture_Release(p_BarGraph->p_pic);
-            p_BarGraph->p_pic = NULL;
-        }
+        Draw(p_BarGraph);
+    } else if (!strcmp(psz_var, CFG_PREFIX "alarm")) {
         p_BarGraph->alarm = newval.b_bool;
-        LoadBarGraph(p_this,p_BarGraph);
-    } else if (!strcmp(psz_var, "audiobargraph_v-barWidth")) {
-        if (p_BarGraph->p_pic) {
-            picture_Release(p_BarGraph->p_pic);
-            p_BarGraph->p_pic = NULL;
-        }
+        Draw(p_BarGraph);
+    } else if (!strcmp(psz_var, CFG_PREFIX "barWidth")) {
         p_BarGraph->barWidth = newval.i_int;
-        LoadBarGraph(p_this,p_BarGraph);
+        Draw(p_BarGraph);
     }
     p_sys->b_spu_update = true;
     vlc_mutex_unlock(&p_sys->lock);
@@ -668,7 +400,7 @@ static subpicture_t *FilterSub(filter_t *p_filter, mtime_t date)
     p_region = subpicture_region_New(&fmt);
     if (!p_region) {
         msg_Err(p_filter, "cannot allocate SPU region");
-        p_filter->pf_sub_buffer_del(p_filter, p_spu);
+        subpicture_Delete(p_spu);
         p_spu = NULL;
         goto exit;
     }
@@ -792,18 +524,18 @@ static int OpenCommon(vlc_object_t *p_this, bool b_sub)
                        p_filter->p_cfg);
 
     /* create and initialize variables */
-    p_sys->i_pos = var_CreateGetIntegerCommand(p_filter, "audiobargraph_v-position");
-    p_sys->i_pos_x = var_CreateGetIntegerCommand(p_filter, "audiobargraph_v-x");
-    p_sys->i_pos_y = var_CreateGetIntegerCommand(p_filter, "audiobargraph_v-y");
+    p_sys->i_pos = var_CreateGetInteger(p_filter, CFG_PREFIX "position");
+    p_sys->i_pos_x = var_CreateGetInteger(p_filter, CFG_PREFIX "x");
+    p_sys->i_pos_y = var_CreateGetInteger(p_filter, CFG_PREFIX "y");
     BarGraph_t *p_BarGraph = &p_sys->p_BarGraph;
     p_BarGraph->p_pic = NULL;
-    p_BarGraph->i_alpha = var_CreateGetIntegerCommand(p_filter,
-                                                        "audiobargraph_v-transparency");
+    p_BarGraph->i_alpha = var_CreateGetInteger(p_filter, CFG_PREFIX "transparency");
     p_BarGraph->i_alpha = VLC_CLIP(p_BarGraph->i_alpha, 0, 255);
+    p_BarGraph->i_values = NULL;
     parse_i_values(p_BarGraph, &(char){ 0 });
     p_BarGraph->alarm = false;
 
-    p_BarGraph->barWidth = var_CreateGetIntegerCommand(p_filter, "audiobargraph_v-barWidth");
+    p_BarGraph->barWidth = var_CreateGetInteger(p_filter, CFG_PREFIX "barWidth");
     p_BarGraph->scale = 400;
 
     /* Ignore aligment if a position is given for video filter */
@@ -812,16 +544,16 @@ static int OpenCommon(vlc_object_t *p_this, bool b_sub)
 
     vlc_mutex_init(&p_sys->lock);
 
-    var_Create(p_filter->p_libvlc, "audiobargraph_v-alarm", VLC_VAR_BOOL);
-    var_Create(p_filter->p_libvlc, "audiobargraph_v-i_values", VLC_VAR_STRING);
+    var_Create(p_filter->p_libvlc, CFG_PREFIX "alarm", VLC_VAR_BOOL);
+    var_Create(p_filter->p_libvlc, CFG_PREFIX "i_values", VLC_VAR_STRING);
 
-    var_AddCallback(p_filter->p_libvlc, "audiobargraph_v-alarm",
+    var_AddCallback(p_filter->p_libvlc, CFG_PREFIX "alarm",
                     BarGraphCallback, p_sys);
-    var_AddCallback(p_filter->p_libvlc, "audiobargraph_v-i_values",
+    var_AddCallback(p_filter->p_libvlc, CFG_PREFIX "i_values",
                     BarGraphCallback, p_sys);
 
-    var_TriggerCallback(p_filter->p_libvlc, "audiobargraph_v-alarm");
-    var_TriggerCallback(p_filter->p_libvlc, "audiobargraph_v-i_values");
+    var_TriggerCallback(p_filter->p_libvlc, CFG_PREFIX "alarm");
+    var_TriggerCallback(p_filter->p_libvlc, CFG_PREFIX "i_values");
 
     for (int i = 0; ppsz_filter_callbacks[i]; i++)
         var_AddCallback(p_filter, ppsz_filter_callbacks[i],
@@ -863,12 +595,12 @@ static void Close(vlc_object_t *p_this)
         var_DelCallback(p_filter, ppsz_filter_callbacks[i],
                          BarGraphCallback, p_sys);
 
-    var_DelCallback(p_filter->p_libvlc, "audiobargraph_v-i_values",
+    var_DelCallback(p_filter->p_libvlc, CFG_PREFIX "i_values",
                     BarGraphCallback, p_sys);
-    var_DelCallback(p_filter->p_libvlc, "audiobargraph_v-alarm",
+    var_DelCallback(p_filter->p_libvlc, CFG_PREFIX "alarm",
                     BarGraphCallback, p_sys);
-    var_Destroy(p_filter->p_libvlc, "audiobargraph_v-i_values");
-    var_Destroy(p_filter->p_libvlc, "audiobargraph_v-alarm");
+    var_Destroy(p_filter->p_libvlc, CFG_PREFIX "i_values");
+    var_Destroy(p_filter->p_libvlc, CFG_PREFIX "alarm");
 
     if (p_sys->p_blend)
         filter_DeleteBlend(p_sys->p_blend);