mirror of https://git.ffmpeg.org/ffmpeg.git
avfilter/avf_showfreqs: make minimum amplitude for log scaler configurable
This commit is contained in:
parent
345c252e9c
commit
5ee5f4b13c
|
@ -16563,6 +16563,9 @@ It accepts the following values:
|
||||||
@end table
|
@end table
|
||||||
Default is @code{combined}.
|
Default is @code{combined}.
|
||||||
|
|
||||||
|
@item minamp
|
||||||
|
Set minimum amplitude used in @code{log} amplitude scaler.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@anchor{showspectrum}
|
@anchor{showspectrum}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "libavcodec/avfft.h"
|
#include "libavcodec/avfft.h"
|
||||||
|
@ -53,6 +54,7 @@ typedef struct ShowFreqsContext {
|
||||||
float **avg_data;
|
float **avg_data;
|
||||||
float *window_func_lut;
|
float *window_func_lut;
|
||||||
float overlap;
|
float overlap;
|
||||||
|
float minamp;
|
||||||
int hop_size;
|
int hop_size;
|
||||||
int nb_channels;
|
int nb_channels;
|
||||||
int nb_freq;
|
int nb_freq;
|
||||||
|
@ -122,6 +124,7 @@ static const AVOption showfreqs_options[] = {
|
||||||
{ "cmode", "set channel mode", OFFSET(cmode), AV_OPT_TYPE_INT, {.i64=COMBINED}, 0, NB_CMODES-1, FLAGS, "cmode" },
|
{ "cmode", "set channel mode", OFFSET(cmode), AV_OPT_TYPE_INT, {.i64=COMBINED}, 0, NB_CMODES-1, FLAGS, "cmode" },
|
||||||
{ "combined", "show all channels in same window", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "cmode" },
|
{ "combined", "show all channels in same window", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "cmode" },
|
||||||
{ "separate", "show each channel in own window", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "cmode" },
|
{ "separate", "show each channel in own window", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "cmode" },
|
||||||
|
{ "minamp", "set minimum amplitude", OFFSET(minamp), AV_OPT_TYPE_FLOAT, {.dbl=1e-6}, FLT_MIN, 1e-6, FLAGS },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -285,6 +288,7 @@ static inline void plot_freq(ShowFreqsContext *s, int ch,
|
||||||
AVFrame *out, AVFilterLink *outlink)
|
AVFrame *out, AVFilterLink *outlink)
|
||||||
{
|
{
|
||||||
const int w = s->w;
|
const int w = s->w;
|
||||||
|
const float min = s->minamp;
|
||||||
const float avg = s->avg_data[ch][f];
|
const float avg = s->avg_data[ch][f];
|
||||||
const float bsize = get_bsize(s, f);
|
const float bsize = get_bsize(s, f);
|
||||||
const int sx = get_sx(s, f);
|
const int sx = get_sx(s, f);
|
||||||
|
@ -299,7 +303,7 @@ static inline void plot_freq(ShowFreqsContext *s, int ch,
|
||||||
a = 1.0 - cbrt(a);
|
a = 1.0 - cbrt(a);
|
||||||
break;
|
break;
|
||||||
case AS_LOG:
|
case AS_LOG:
|
||||||
a = log(av_clipd(a, 1e-6, 1)) / log(1e-6);
|
a = log(av_clipd(a, min, 1)) / log(min);
|
||||||
break;
|
break;
|
||||||
case AS_LINEAR:
|
case AS_LINEAR:
|
||||||
a = 1.0 - a;
|
a = 1.0 - a;
|
||||||
|
|
Loading…
Reference in New Issue