Commit 88b8bff1 authored by Rafaël Carré's avatar Rafaël Carré

audiobargraph_v: simplify LoadImage

parent 066f2cd5
...@@ -37,10 +37,6 @@ ...@@ -37,10 +37,6 @@
#include <vlc_image.h> #include <vlc_image.h>
#ifdef LoadImage
# undef LoadImage
#endif
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -202,15 +198,25 @@ static void parse_i_values(BarGraph_t *p_BarGraph, char *i_values) ...@@ -202,15 +198,25 @@ static void parse_i_values(BarGraph_t *p_BarGraph, char *i_values)
/***************************************************************************** /*****************************************************************************
* LoadImage: creates and returns the bar graph image * 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) #ifdef LoadImage
# undef LoadImage
#endif
static void LoadImage(BarGraph_t *p)
{ {
VLC_UNUSED(p_this); int nbChannels = p->nbChannels;
picture_t *p_pic; int *i_values = p->i_values;
int scale = p->scale;
int alarm = p->alarm;
int barWidth = p->barWidth;
int i, j, pi; int i, j, pi;
int i_width = 0; int i_width = 0;
int i_line; int i_line;
int minus8, minus10, minus18, minus20, minus30, minus40, minus50, minus60; int minus8, minus10, minus18, minus20, minus30, minus40, minus50, minus60;
if (p->p_pic)
picture_Release(p->p_pic);
if (nbChannels == 0) if (nbChannels == 0)
i_width = 20; i_width = 20;
else else
...@@ -225,8 +231,10 @@ static picture_t *LoadImage(vlc_object_t *p_this, int nbChannels, int* i_values, ...@@ -225,8 +231,10 @@ static picture_t *LoadImage(vlc_object_t *p_this, int nbChannels, int* i_values,
minus50 = iec_scale(-50)*scale + 20; minus50 = iec_scale(-50)*scale + 20;
minus60 = iec_scale(-60)*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); picture_t *p_pic = picture_New(VLC_FOURCC('Y','U','V','A'), i_width+20, scale+30, 1, 1);
if (!p_pic)
return;
p->p_pic = p_pic;
#define DrawLine(a,b,Y,U,V,A) \ #define DrawLine(a,b,Y,U,V,A) \
for (i=a; i<b; i++) {\ for (i=a; i<b; i++) {\
...@@ -549,20 +557,6 @@ static picture_t *LoadImage(vlc_object_t *p_this, int nbChannels, int* i_values, ...@@ -549,20 +557,6 @@ static picture_t *LoadImage(vlc_object_t *p_this, int nbChannels, int* i_values,
} }
} }
} }
return p_pic;
}
/*****************************************************************************
* LoadBarGraph: loads the BarGraph images into memory
*****************************************************************************/
static void LoadBarGraph(vlc_object_t *p_this, BarGraph_t *p_BarGraph)
{
if (p_BarGraph->p_pic)
picture_Release(p_BarGraph->p_pic);
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");
} }
/***************************************************************************** /*****************************************************************************
...@@ -571,7 +565,7 @@ static void LoadBarGraph(vlc_object_t *p_this, BarGraph_t *p_BarGraph) ...@@ -571,7 +565,7 @@ static void LoadBarGraph(vlc_object_t *p_this, BarGraph_t *p_BarGraph)
static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var, static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data) vlc_value_t oldval, vlc_value_t newval, void *p_data)
{ {
VLC_UNUSED(oldval); VLC_UNUSED(p_this); VLC_UNUSED(oldval);
filter_sys_t *p_sys = p_data; filter_sys_t *p_sys = p_data;
BarGraph_t *p_BarGraph = &p_sys->p_BarGraph; BarGraph_t *p_BarGraph = &p_sys->p_BarGraph;
char* res = NULL; char* res = NULL;
...@@ -593,13 +587,13 @@ static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var, ...@@ -593,13 +587,13 @@ static int BarGraphCallback(vlc_object_t *p_this, char const *psz_var,
*res = '\0'; *res = '\0';
parse_i_values(p_BarGraph, psz); parse_i_values(p_BarGraph, psz);
free(psz); free(psz);
LoadBarGraph(p_this,p_BarGraph); LoadImage(p_BarGraph);
} else if (!strcmp(psz_var, "audiobargraph_v-alarm")) { } else if (!strcmp(psz_var, "audiobargraph_v-alarm")) {
p_BarGraph->alarm = newval.b_bool; p_BarGraph->alarm = newval.b_bool;
LoadBarGraph(p_this,p_BarGraph); LoadImage(p_BarGraph);
} else if (!strcmp(psz_var, "audiobargraph_v-barWidth")) { } else if (!strcmp(psz_var, "audiobargraph_v-barWidth")) {
p_BarGraph->barWidth = newval.i_int; p_BarGraph->barWidth = newval.i_int;
LoadBarGraph(p_this,p_BarGraph); LoadImage(p_BarGraph);
} }
p_sys->b_spu_update = true; p_sys->b_spu_update = true;
vlc_mutex_unlock(&p_sys->lock); vlc_mutex_unlock(&p_sys->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment