Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-23 Thread Muhammad Faiz
On Sat, Aug 23, 2014 at 3:09 PM, Clément Bœsch  wrote:

> Next time please send a git-format-patch (git commit ... && git
> format-patch -1, or use git send-email) instead, so it saves the committer
> the time to copy/paste the commit message and author.
>
> Thank's for the suggestion

Muhammad Faiz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-23 Thread Clément Bœsch
On Sat, Aug 23, 2014 at 05:51:31AM +0700, Muhammad Faiz wrote:
[...]
> Update patch to the latest master branch.
> 
> Thank's.
> 
> Muhammad Faiz

> 
> ---
>  doc/filters.texi  |  26 
>  libavfilter/avf_showcqt.c | 102 
> --
>  libavfilter/version.h |   2 +-
>  3 files changed, 98 insertions(+), 32 deletions(-)
> 

Thanks, applied.

Next time please send a git-format-patch (git commit ... && git
format-patch -1, or use git send-email) instead, so it saves the committer
the time to copy/paste the commit message and author.

[...]

-- 
Clément B.


pgpnMiUxLoEFx.pgp
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-22 Thread Muhammad Faiz
On Thu, Aug 21, 2014 at 7:33 AM, Muhammad Faiz  wrote:

> On Thu, Aug 21, 2014 at 3:49 AM, Clément Bœsch  wrote:
>
>> On Wed, Aug 20, 2014 at 07:10:56AM +0700, Muhammad Faiz wrote:
>> [...]
>> > +static double r_func(void *p, double x)
>> > +{
>> > +x = av_clipd(x, 0.0, 1.0);
>> > +return (int)(x*255.0+0.5) << 16;
>>
>> You can probably use lrint() here:
>> return lrint(av_clipd(x, 0.0, 1.0) * 255.0) << 16;
>>
> I don't think so. According to libc doc, lrint round to integer according
> to rounding mode, so sometimes it doesn't round to nearest.
>
>
>> > +av_expr_free(fontcolor_expr);
>> >  av_expr_free(volume_expr);
>> >  av_expr_free(tlength_expr);
>>
>> drop these 3 lines...
>>
>> >  end_time = av_gettime_relative();
>> > @@ -482,6 +515,12 @@ static int config_output(AVFilterLink *outlink)
>> >  outlink->time_base = av_make_q(1, s->fps);
>> >  outlink->frame_rate = av_make_q(s->fps, 1);
>>
>> >  return 0;
>>
>> ...drop this line as well...
>>
>> > +
>> > +eval_error:
>>
>> ...and rename this to "out" or something more generic
>>
>> > +av_expr_free(fontcolor_expr);
>> > +av_expr_free(volume_expr);
>> > +av_expr_free(tlength_expr);
>> > +return ret;
>> >  }
>> >
>>
> It's just programming style. And there are more lines that should be
> changed:
> s->outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
> if (!s->outpicref)
> return AVERROR(ENOMEM);
>
> s->spectogram = av_calloc(spectogram_height,
> s->outpicref->linesize[0]);
> if (!s->spectogram)
> return AVERROR(ENOMEM);
>
>
>  Please bump libavfilter/version.h micro and I'll probably apply this
>> version.
>>
> Incremented.
>
> Thank's
> Muhammad Faiz
>

Update patch to the latest master branch.

Thank's.

Muhammad Faiz

---
 doc/filters.texi  |  26 
 libavfilter/avf_showcqt.c | 102 --
 libavfilter/version.h |   2 +-
 3 files changed, 98 insertions(+), 32 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 8badc54..41a924a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10660,6 +10660,26 @@ Default value is @code{3.0}.
 @item fontfile
 Specify font file for use with freetype. If not specified, use embedded font.
 
+@item fontcolor
+Specify font color expression. This is arithmetic expression that should return
+integer value 0xRRGGBB. The expression can contain variables:
+@table @option
+@item frequency, freq, f
+the frequency where transform is evaluated
+@item timeclamp, tc
+value of timeclamp option
+@end table
+and functions:
+@table @option
+@item midi(f)
+midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
+@item r(x), g(x), b(x)
+red, green, and blue value of intensity x
+@end table
+Default value is @code{st(0, (midi(f)-59.5)/12);
+st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
+r(1-ld(1)) + b(ld(1))}
+
 @item fullhd
 If set to 1 (the default), the video size is 1920x1080 (full HD),
 if set to 0, the video size is 960x540. Use this option to make CPU usage 
lower.
@@ -10721,6 +10741,12 @@ Lower Q factor
 tlength=100/f*tc/(100/f+tc)
 @end example
 
+@item
+Custom fontcolor, C-note is colored green, others are colored blue
+@example
+fontcolor='if(mod(floor(midi(f)+0.5),12), 0xFF, g(1))'
+@end example
+
 @end itemize
 
 @section showspectrum
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 012362b..e650f74 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -54,6 +54,9 @@
 #define TLENGTH_DEFAULT "384/f*tc/(384/f+tc)"
 #define VOLUME_MIN 1e-10
 #define VOLUME_MAX 100.0
+#define FONTCOLOR_DEFAULT "st(0, (midi(f)-59.5)/12);" \
+"st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));" \
+"r(1-ld(1)) + b(ld(1))"
 
 typedef struct {
 FFTSample value;
@@ -73,7 +76,7 @@ typedef struct {
 uint8_t *font_alpha;
 char *fontfile; /* using freetype */
 int coeffs_len[VIDEO_WIDTH];
-uint8_t font_color[VIDEO_WIDTH];
+uint8_t fontcolor_value[VIDEO_WIDTH*3];  /* result of fontcolor option */
 int64_t frame_count;
 int spectogram_count;
 int spectogram_index;
@@ -82,6 +85,7 @@ typedef struct {
 int remaining_fill;
 char *tlength;
 char *volume;
+char *fontcolor;
 double timeclamp;   /* lower timeclamp, time-accurate, higher timeclamp, 
freq-accurate (at low freq)*/
 float coeffclamp;   /* lower coeffclamp, more precise, higher coeffclamp, 
faster */
 int fullhd; /* if true, output video is at full HD resolution, 
otherwise it will be halved */
@@ -103,6 +107,7 @@ static const AVOption showcqt_options[] = {
 { "fps", "set video fps", OFFSET(fps), AV_OPT_TYPE_INT, { .i64 = 25 }, 10, 
100, FLAGS },
 { "count", "set number of transform per frame", OFFSET(count), 
AV_OPT_TYPE_INT, { .i64 = 6 }, 1, 30, FLAGS },
 { "fontfile", "set font file", OFFSET(fontfile), AV_OPT_TYPE_STRING, { 
.str = NUL

Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-20 Thread Muhammad Faiz
On Thu, Aug 21, 2014 at 3:49 AM, Clément Bœsch  wrote:

> On Wed, Aug 20, 2014 at 07:10:56AM +0700, Muhammad Faiz wrote:
> [...]
> > +static double r_func(void *p, double x)
> > +{
> > +x = av_clipd(x, 0.0, 1.0);
> > +return (int)(x*255.0+0.5) << 16;
>
> You can probably use lrint() here:
> return lrint(av_clipd(x, 0.0, 1.0) * 255.0) << 16;
>
I don't think so. According to libc doc, lrint round to integer according
to rounding mode, so sometimes it doesn't round to nearest.


> > +av_expr_free(fontcolor_expr);
> >  av_expr_free(volume_expr);
> >  av_expr_free(tlength_expr);
>
> drop these 3 lines...
>
> >  end_time = av_gettime_relative();
> > @@ -482,6 +515,12 @@ static int config_output(AVFilterLink *outlink)
> >  outlink->time_base = av_make_q(1, s->fps);
> >  outlink->frame_rate = av_make_q(s->fps, 1);
>
> >  return 0;
>
> ...drop this line as well...
>
> > +
> > +eval_error:
>
> ...and rename this to "out" or something more generic
>
> > +av_expr_free(fontcolor_expr);
> > +av_expr_free(volume_expr);
> > +av_expr_free(tlength_expr);
> > +return ret;
> >  }
> >
>
It's just programming style. And there are more lines that should be
changed:
s->outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!s->outpicref)
return AVERROR(ENOMEM);

s->spectogram = av_calloc(spectogram_height, s->outpicref->linesize[0]);
if (!s->spectogram)
return AVERROR(ENOMEM);


 Please bump libavfilter/version.h micro and I'll probably apply this
> version.
>
Incremented.

Thank's
Muhammad Faiz

---
 doc/filters.texi  |  26 
 libavfilter/avf_showcqt.c | 102 --
 libavfilter/version.h |   2 +-
 3 files changed, 98 insertions(+), 32 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index a20253a..108cb00 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10610,6 +10610,26 @@ Default value is @code{3.0}.
 @item fontfile
 Specify font file for use with freetype. If not specified, use embedded font.
 
+@item fontcolor
+Specify font color expression. This is arithmetic expression that should return
+integer value 0xRRGGBB. The expression can contain variables:
+@table @option
+@item frequency, freq, f
+the frequency where transform is evaluated
+@item timeclamp, tc
+value of timeclamp option
+@end table
+and functions:
+@table @option
+@item midi(f)
+midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
+@item r(x), g(x), b(x)
+red, green, and blue value of intensity x
+@end table
+Default value is @code{st(0, (midi(f)-59.5)/12);
+st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
+r(1-ld(1)) + b(ld(1))}
+
 @item fullhd
 If set to 1 (the default), the video size is 1920x1080 (full HD),
 if set to 0, the video size is 960x540. Use this option to make CPU usage 
lower.
@@ -10671,6 +10691,12 @@ Lower Q factor
 tlength=100/f*tc/(100/f+tc)
 @end example
 
+@item
+Custom fontcolor, C-note is colored green, others are colored blue
+@example
+fontcolor='if(mod(floor(midi(f)+0.5),12), 0xFF, g(1))'
+@end example
+
 @end itemize
 
 @section showspectrum
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 012362b..e650f74 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -54,6 +54,9 @@
 #define TLENGTH_DEFAULT "384/f*tc/(384/f+tc)"
 #define VOLUME_MIN 1e-10
 #define VOLUME_MAX 100.0
+#define FONTCOLOR_DEFAULT "st(0, (midi(f)-59.5)/12);" \
+"st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));" \
+"r(1-ld(1)) + b(ld(1))"
 
 typedef struct {
 FFTSample value;
@@ -73,7 +76,7 @@ typedef struct {
 uint8_t *font_alpha;
 char *fontfile; /* using freetype */
 int coeffs_len[VIDEO_WIDTH];
-uint8_t font_color[VIDEO_WIDTH];
+uint8_t fontcolor_value[VIDEO_WIDTH*3];  /* result of fontcolor option */
 int64_t frame_count;
 int spectogram_count;
 int spectogram_index;
@@ -82,6 +85,7 @@ typedef struct {
 int remaining_fill;
 char *tlength;
 char *volume;
+char *fontcolor;
 double timeclamp;   /* lower timeclamp, time-accurate, higher timeclamp, 
freq-accurate (at low freq)*/
 float coeffclamp;   /* lower coeffclamp, more precise, higher coeffclamp, 
faster */
 int fullhd; /* if true, output video is at full HD resolution, 
otherwise it will be halved */
@@ -103,6 +107,7 @@ static const AVOption showcqt_options[] = {
 { "fps", "set video fps", OFFSET(fps), AV_OPT_TYPE_INT, { .i64 = 25 }, 10, 
100, FLAGS },
 { "count", "set number of transform per frame", OFFSET(count), 
AV_OPT_TYPE_INT, { .i64 = 6 }, 1, 30, FLAGS },
 { "fontfile", "set font file", OFFSET(fontfile), AV_OPT_TYPE_STRING, { 
.str = NULL }, CHAR_MIN, CHAR_MAX, FLAGS },
+{ "fontcolor", "set font color", OFFSET(fontcolor), AV_OPT_TYPE_STRING, { 
.str = FONTCOLOR_DEFAULT }, CHAR_MIN, CHAR_MAX, FLAGS },
 { NULL }
 };
 
@@ -275,6 +28

Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-20 Thread Clément Bœsch
On Wed, Aug 20, 2014 at 07:10:56AM +0700, Muhammad Faiz wrote:
[...]
> +static double r_func(void *p, double x)
> +{
> +x = av_clipd(x, 0.0, 1.0);
> +return (int)(x*255.0+0.5) << 16;

You can probably use lrint() here:
return lrint(av_clipd(x, 0.0, 1.0) * 255.0) << 16;

[...]
> +av_expr_free(fontcolor_expr);
>  av_expr_free(volume_expr);
>  av_expr_free(tlength_expr);

drop these 3 lines...

>  end_time = av_gettime_relative();
> @@ -482,6 +515,12 @@ static int config_output(AVFilterLink *outlink)
>  outlink->time_base = av_make_q(1, s->fps);
>  outlink->frame_rate = av_make_q(s->fps, 1);

>  return 0;

...drop this line as well...

> +
> +eval_error:

...and rename this to "out" or something more generic

> +av_expr_free(fontcolor_expr);
> +av_expr_free(volume_expr);
> +av_expr_free(tlength_expr);
> +return ret;
>  }
>  
[...]

Please bump libavfilter/version.h micro and I'll probably apply this
version.

Thanks

-- 
Clément B.


pgpd5UwixfvxR.pgp
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-19 Thread Muhammad Faiz
On Tue, Aug 19, 2014 at 12:38 PM, Clément Bœsch  wrote:

> On Mon, Aug 18, 2014 at 06:54:55AM +0700, Muhammad Faiz wrote:
> > This fontcolor option uses arithmetic expression, not color value,
> > so color names aren't available.
> > Thank's
> Can you suggest an alternative in the examples? (maybe with some green?)
>
An example is added.


> > +static double r_func(void *p, double x)
> > +{
> > +x = FFMAX(0.0, FFMIN(1.0, x));
>
> av_clipd()?
>
Changed.


> > +ret = av_expr_parse(&fontcolor_expr, s->fontcolor, expr_vars,
> expr_fontcolor_func_names,
> > +expr_fontcolor_funcs, NULL, NULL, 0, ctx);
> > +if (ret < 0) {
> > +av_expr_free(volume_expr);
> > +av_expr_free(tlength_expr);
> > +return ret;
> > +}
>
> It would probably be better to consider a goto end to cleanup these
> instead of adding the av_expr_free() in every fail path (Non-blocking
> request).
>
 Changed.

Thank's.

---
 doc/filters.texi  |  26 
 libavfilter/avf_showcqt.c | 102 --
 2 files changed, 97 insertions(+), 31 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 0ca1d6f..62a3dd8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10610,6 +10610,26 @@ Default value is @code{3.0}.
 @item fontfile
 Specify font file for use with freetype. If not specified, use embedded font.
 
+@item fontcolor
+Specify font color expression. This is arithmetic expression that should return
+integer value 0xRRGGBB. The expression can contain variables:
+@table @option
+@item frequency, freq, f
+the frequency where transform is evaluated
+@item timeclamp, tc
+value of timeclamp option
+@end table
+and functions:
+@table @option
+@item midi(f)
+midi number of frequency f, some midi numbers: E0(16), C1(24), C2(36), A4(69)
+@item r(x), g(x), b(x)
+red, green, and blue value of intensity x
+@end table
+Default value is @code{st(0, (midi(f)-59.5)/12);
+st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
+r(1-ld(1)) + b(ld(1))}
+
 @item fullhd
 If set to 1 (the default), the video size is 1920x1080 (full HD),
 if set to 0, the video size is 960x540. Use this option to make CPU usage 
lower.
@@ -10671,6 +10691,12 @@ Lower Q factor
 tlength=100/f*tc/(100/f+tc)
 @end example
 
+@item
+Custom fontcolor, C-note is colored green, others are colored blue
+@example
+fontcolor='if(mod(floor(midi(f)+0.5),12), 0xFF, g(1))'
+@end example
+
 @end itemize
 
 @section showspectrum
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 012362b..e650f74 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -54,6 +54,9 @@
 #define TLENGTH_DEFAULT "384/f*tc/(384/f+tc)"
 #define VOLUME_MIN 1e-10
 #define VOLUME_MAX 100.0
+#define FONTCOLOR_DEFAULT "st(0, (midi(f)-59.5)/12);" \
+"st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));" \
+"r(1-ld(1)) + b(ld(1))"
 
 typedef struct {
 FFTSample value;
@@ -73,7 +76,7 @@ typedef struct {
 uint8_t *font_alpha;
 char *fontfile; /* using freetype */
 int coeffs_len[VIDEO_WIDTH];
-uint8_t font_color[VIDEO_WIDTH];
+uint8_t fontcolor_value[VIDEO_WIDTH*3];  /* result of fontcolor option */
 int64_t frame_count;
 int spectogram_count;
 int spectogram_index;
@@ -82,6 +85,7 @@ typedef struct {
 int remaining_fill;
 char *tlength;
 char *volume;
+char *fontcolor;
 double timeclamp;   /* lower timeclamp, time-accurate, higher timeclamp, 
freq-accurate (at low freq)*/
 float coeffclamp;   /* lower coeffclamp, more precise, higher coeffclamp, 
faster */
 int fullhd; /* if true, output video is at full HD resolution, 
otherwise it will be halved */
@@ -103,6 +107,7 @@ static const AVOption showcqt_options[] = {
 { "fps", "set video fps", OFFSET(fps), AV_OPT_TYPE_INT, { .i64 = 25 }, 10, 
100, FLAGS },
 { "count", "set number of transform per frame", OFFSET(count), 
AV_OPT_TYPE_INT, { .i64 = 6 }, 1, 30, FLAGS },
 { "fontfile", "set font file", OFFSET(fontfile), AV_OPT_TYPE_STRING, { 
.str = NULL }, CHAR_MIN, CHAR_MAX, FLAGS },
+{ "fontcolor", "set font color", OFFSET(fontcolor), AV_OPT_TYPE_STRING, { 
.str = FONTCOLOR_DEFAULT }, CHAR_MIN, CHAR_MAX, FLAGS },
 { NULL }
 };
 
@@ -275,6 +280,29 @@ static double c_weighting(void *p, double f)
 return ret;
 }
 
+static double midi(void *p, double f)
+{
+return log2(f/440.0) * 12.0 + 69.0;
+}
+
+static double r_func(void *p, double x)
+{
+x = av_clipd(x, 0.0, 1.0);
+return (int)(x*255.0+0.5) << 16;
+}
+
+static double g_func(void *p, double x)
+{
+x = av_clipd(x, 0.0, 1.0);
+return (int)(x*255.0+0.5) << 8;
+}
+
+static double b_func(void *p, double x)
+{
+x = av_clipd(x, 0.0, 1.0);
+return (int)(x*255.0+0.5);
+}
+
 static inline int qsort_sparsecoeff(const SparseCoeff *a, const SparseCoeff *b)
 {
 if (fabsf(a->value) >= fabsf(b->value))
@@ -288,10 +316,13 @@ static int config_

Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-18 Thread Clément Bœsch
On Mon, Aug 18, 2014 at 06:54:55AM +0700, Muhammad Faiz wrote:
> This fontcolor option uses arithmetic expression, not color value,
> so color names aren't available.
> Thank's

> 
> ---
>  doc/filters.texi  | 20 +++
>  libavfilter/avf_showcqt.c | 84 
> ++-
>  2 files changed, 81 insertions(+), 23 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 0ca1d6f..958b48e 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -10610,6 +10610,26 @@ Default value is @code{3.0}.
>  @item fontfile
>  Specify font file for use with freetype. If not specified, use embedded font.
>  
> +@item fontcolor
> +Specify font color expression. This is arithmetic expression that should 
> return
> +integer value 0xRRGGBB. The expression can contain variables:
> +@table @option
> +@item frequency, freq, f
> +the frequency where transform is evaluated
> +@item timeclamp, tc
> +value of timeclamp option
> +@end table
> +and functions:
> +@table @option
> +@item midi(f)
> +midi number of frequency f
> +@item r(x), g(x), b(x)
> +red, green, and blue value of intensity x
> +@end table
> +Default value is @code{st(0, (midi(f)-59.5)/12);
> +st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));
> +r(1-ld(1)) + b(ld(1)}
> +

Can you suggest an alternative in the examples? (maybe with some green?)

>  @item fullhd
>  If set to 1 (the default), the video size is 1920x1080 (full HD),
>  if set to 0, the video size is 960x540. Use this option to make CPU usage 
> lower.
> diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
> index 012362b..d349c3d 100644
> --- a/libavfilter/avf_showcqt.c
> +++ b/libavfilter/avf_showcqt.c
> @@ -54,6 +54,9 @@
>  #define TLENGTH_DEFAULT "384/f*tc/(384/f+tc)"
>  #define VOLUME_MIN 1e-10
>  #define VOLUME_MAX 100.0
> +#define FONTCOLOR_DEFAULT "st(0, (midi(f)-59.5)/12);" \
> +"st(1, if(between(ld(0),0,1), 0.5-0.5*cos(2*PI*ld(0)), 0));" \
> +"r(1-ld(1)) + b(ld(1))"
>  
>  typedef struct {
>  FFTSample value;
> @@ -73,7 +76,7 @@ typedef struct {
>  uint8_t *font_alpha;
>  char *fontfile; /* using freetype */
>  int coeffs_len[VIDEO_WIDTH];
> -uint8_t font_color[VIDEO_WIDTH];
> +uint8_t fontcolor_value[VIDEO_WIDTH*3];  /* result of fontcolor option */
>  int64_t frame_count;
>  int spectogram_count;
>  int spectogram_index;
> @@ -82,6 +85,7 @@ typedef struct {
>  int remaining_fill;
>  char *tlength;
>  char *volume;
> +char *fontcolor;
>  double timeclamp;   /* lower timeclamp, time-accurate, higher timeclamp, 
> freq-accurate (at low freq)*/
>  float coeffclamp;   /* lower coeffclamp, more precise, higher 
> coeffclamp, faster */
>  int fullhd; /* if true, output video is at full HD resolution, 
> otherwise it will be halved */
> @@ -103,6 +107,7 @@ static const AVOption showcqt_options[] = {
>  { "fps", "set video fps", OFFSET(fps), AV_OPT_TYPE_INT, { .i64 = 25 }, 
> 10, 100, FLAGS },
>  { "count", "set number of transform per frame", OFFSET(count), 
> AV_OPT_TYPE_INT, { .i64 = 6 }, 1, 30, FLAGS },
>  { "fontfile", "set font file", OFFSET(fontfile), AV_OPT_TYPE_STRING, { 
> .str = NULL }, CHAR_MIN, CHAR_MAX, FLAGS },
> +{ "fontcolor", "set font color", OFFSET(fontcolor), AV_OPT_TYPE_STRING, 
> { .str = FONTCOLOR_DEFAULT }, CHAR_MIN, CHAR_MAX, FLAGS },
>  { NULL }
>  };
>  
> @@ -275,6 +280,29 @@ static double c_weighting(void *p, double f)
>  return ret;
>  }
>  
> +static double midi(void *p, double f)
> +{
> +return log2(f/440.0) * 12.0 + 69.0;
> +}
> +
> +static double r_func(void *p, double x)
> +{
> +x = FFMAX(0.0, FFMIN(1.0, x));

av_clipd()?

> +return (int)(x*255.0+0.5) << 16;
> +}
> +
> +static double g_func(void *p, double x)
> +{
> +x = FFMAX(0.0, FFMIN(1.0, x));
> +return (int)(x*255.0+0.5) << 8;
> +}
> +
> +static double b_func(void *p, double x)
> +{
> +x = FFMAX(0.0, FFMIN(1.0, x));
> +return (int)(x*255.0+0.5);
> +}
> +
>  static inline int qsort_sparsecoeff(const SparseCoeff *a, const SparseCoeff 
> *b)
>  {
>  if (fabsf(a->value) >= fabsf(b->value))
> @@ -288,10 +316,13 @@ static int config_output(AVFilterLink *outlink)
>  AVFilterContext *ctx = outlink->src;
>  AVFilterLink *inlink = ctx->inputs[0];
>  ShowCQTContext *s = ctx->priv;
> -AVExpr *tlength_expr, *volume_expr;
> +AVExpr *tlength_expr, *volume_expr, *fontcolor_expr;
> +uint8_t *fontcolor_value = s->fontcolor_value;
>  static const char * const expr_vars[] = { "timeclamp", "tc", 
> "frequency", "freq", "f", NULL };
>  static const char * const expr_func_names[] = { "a_weighting", 
> "b_weighting", "c_weighting", NULL };
> +static const char * const expr_fontcolor_func_names[] = { "midi", "r", 
> "g", "b", NULL };
>  static double (* const expr_funcs[])(void *, double) = { a_weighting, 
> b_weighting, c_weighting, NULL };
> +static double (* const e

Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-18 Thread Muhammad Faiz
On Mon, Aug 18, 2014 at 7:03 AM, Timothy Gu  wrote:

> On Sun, Aug 17, 2014 at 4:54 PM, Muhammad Faiz  wrote:
> > This fontcolor option uses arithmetic expression, not color value,
> > so color names aren't available.
> > Thank's
>
> You should use AV_OPT_TYPE_COLOR instead of AV_OPT_TYPE_STRING to make
> the color names usable. Look at how vf_drawtext is doing it.
>
The main goal is to compute color from frequency where it is evaluated.
I think AV_OPT_TYPE_COLOR doesn't have this capability.
Thank's
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/showcqt: add fontcolor option

2014-08-17 Thread Timothy Gu
On Sun, Aug 17, 2014 at 4:54 PM, Muhammad Faiz  wrote:
> This fontcolor option uses arithmetic expression, not color value,
> so color names aren't available.
> Thank's

You should use AV_OPT_TYPE_COLOR instead of AV_OPT_TYPE_STRING to make
the color names usable. Look at how vf_drawtext is doing it.

[...]

Timothy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel