Commit eba5cb20 authored by Muhammad Faiz's avatar Muhammad Faiz Committed by Michael Niedermayer

avfilter/showcqt: add gamma2 option

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent dff6c925
...@@ -11205,6 +11205,10 @@ Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma ...@@ -11205,6 +11205,10 @@ Specify gamma. Lower gamma makes the spectrum more contrast, higher gamma
makes the spectrum having more range. Acceptable value is [1.0, 7.0]. makes the spectrum having more range. Acceptable value is [1.0, 7.0].
Default value is @code{3.0}. Default value is @code{3.0}.
@item gamma2
Specify gamma of bargraph. Acceptable value is [1.0, 7.0].
Default value is @code{1.0}.
@item fontfile @item fontfile
Specify font file for use with freetype. If not specified, use embedded font. Specify font file for use with freetype. If not specified, use embedded font.
...@@ -11295,6 +11299,12 @@ Custom fontcolor, C-note is colored green, others are colored blue ...@@ -11295,6 +11299,12 @@ Custom fontcolor, C-note is colored green, others are colored blue
fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))' fontcolor='if(mod(floor(midi(f)+0.5),12), 0x0000FF, g(1))'
@end example @end example
@item
Custom gamma, now spectrum is linear to the amplitude.
@example
gamma=2:gamma2=2
@end example
@end itemize @end itemize
@section showspectrum @section showspectrum
......
...@@ -90,6 +90,7 @@ typedef struct { ...@@ -90,6 +90,7 @@ typedef struct {
float coeffclamp; /* lower coeffclamp, more precise, higher coeffclamp, faster */ 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 */ int fullhd; /* if true, output video is at full HD resolution, otherwise it will be halved */
float gamma; /* lower gamma, more contrast, higher gamma, more range */ float gamma; /* lower gamma, more contrast, higher gamma, more range */
float gamma2; /* gamma of bargraph */
int fps; /* the required fps is so strict, so it's enough to be int, but 24000/1001 etc cannot be encoded */ int fps; /* the required fps is so strict, so it's enough to be int, but 24000/1001 etc cannot be encoded */
int count; /* fps * count = transform rate */ int count; /* fps * count = transform rate */
} ShowCQTContext; } ShowCQTContext;
...@@ -103,6 +104,7 @@ static const AVOption showcqt_options[] = { ...@@ -103,6 +104,7 @@ static const AVOption showcqt_options[] = {
{ "timeclamp", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS }, { "timeclamp", "set timeclamp", OFFSET(timeclamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.17 }, 0.1, 1.0, FLAGS },
{ "coeffclamp", "set coeffclamp", OFFSET(coeffclamp), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, 0.1, 10, FLAGS }, { "coeffclamp", "set coeffclamp", OFFSET(coeffclamp), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, 0.1, 10, FLAGS },
{ "gamma", "set gamma", OFFSET(gamma), AV_OPT_TYPE_FLOAT, { .dbl = 3 }, 1, 7, FLAGS }, { "gamma", "set gamma", OFFSET(gamma), AV_OPT_TYPE_FLOAT, { .dbl = 3 }, 1, 7, FLAGS },
{ "gamma2", "set gamma of bargraph", OFFSET(gamma2), AV_OPT_TYPE_FLOAT, { .dbl = 1 }, 1, 7, FLAGS },
{ "fullhd", "set full HD resolution", OFFSET(fullhd), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS }, { "fullhd", "set full HD resolution", OFFSET(fullhd), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS },
{ "fps", "set video fps", OFFSET(fps), AV_OPT_TYPE_INT, { .i64 = 25 }, 10, 100, FLAGS }, { "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 }, { "count", "set number of transform per frame", OFFSET(count), AV_OPT_TYPE_INT, { .i64 = 6 }, 1, 30, FLAGS },
...@@ -566,6 +568,7 @@ static int plot_cqt(AVFilterLink *inlink) ...@@ -566,6 +568,7 @@ static int plot_cqt(AVFilterLink *inlink)
for (x = 0; x < VIDEO_WIDTH; x++) { for (x = 0; x < VIDEO_WIDTH; x++) {
int u; int u;
float g = 1.0f / s->gamma; float g = 1.0f / s->gamma;
float g2 = 1.0f / s->gamma2;
FFTComplex l = {0,0}; FFTComplex l = {0,0};
FFTComplex r = {0,0}; FFTComplex r = {0,0};
...@@ -581,7 +584,7 @@ static int plot_cqt(AVFilterLink *inlink) ...@@ -581,7 +584,7 @@ static int plot_cqt(AVFilterLink *inlink)
result[x][0] = l.re * l.re + l.im * l.im; result[x][0] = l.re * l.re + l.im * l.im;
result[x][2] = r.re * r.re + r.im * r.im; result[x][2] = r.re * r.re + r.im * r.im;
result[x][1] = 0.5f * (result[x][0] + result[x][2]); result[x][1] = 0.5f * (result[x][0] + result[x][2]);
result[x][3] = result[x][1]; result[x][3] = (g2 == 1.0f) ? result[x][1] : powf(result[x][1], g2);
result[x][0] = 255.0f * powf(FFMIN(1.0f,result[x][0]), g); result[x][0] = 255.0f * powf(FFMIN(1.0f,result[x][0]), g);
result[x][1] = 255.0f * powf(FFMIN(1.0f,result[x][1]), g); result[x][1] = 255.0f * powf(FFMIN(1.0f,result[x][1]), g);
result[x][2] = 255.0f * powf(FFMIN(1.0f,result[x][2]), g); result[x][2] = 255.0f * powf(FFMIN(1.0f,result[x][2]), g);
......
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