FFmpeg
Loading...
Searching...
No Matches
avf_abitscope.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "audio.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  AudioBitScopeContext
 

Macros

#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define BITCOUNTER(type, depth, one)
 
#define BARS(type, depth, one)
 
#define DO_TRACE(type, depth, one)
 

Functions

 AVFILTER_DEFINE_CLASS (abitscope)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *insamples)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption abitscope_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const FFFilter ff_avf_abitscope
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 50 of file avf_abitscope.c.

◆ FLAGS

Definition at line 51 of file avf_abitscope.c.

◆ BITCOUNTER

#define BITCOUNTER ( type,
depth,
one )
Value:
memset(counter, 0, sizeof(s->counter)); \
for (int i = 0; i < nb_samples; i++) { \
const type x = in[i]; \
for (int j = 0; j < depth && x; j++) \
counter[j] += !!(x & (one << j)); \
}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
cl_device_type type

Definition at line 141 of file avf_abitscope.c.

◆ BARS

#define BARS ( type,
depth,
one )
Value:
for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) { \
const int nb_samples = insamples->nb_samples; \
const type *in = (const type *)insamples->extended_data[ch]; \
const int w = outpicref->width / inlink->ch_layout.nb_channels; \
const int h = outpicref->height / depth; \
const uint32_t color = AV_RN32(&s->fg[4 * ch]); \
uint64_t *counter = s->counter; \
\
BITCOUNTER(type, depth, one) \
\
for (int b = 0; b < depth; b++) { \
for (int j = 1; j < h - 1; j++) { \
uint8_t *dst = outpicref->data[0] + (b * h + j) * outpicref->linesize[0] + w * ch * 4; \
const int ww = (counter[depth - b - 1] / (float)nb_samples) * (w - 1); \
\
for (int i = 0; i < ww; i++) { \
AV_WN32(&dst[i * 4], color); \
} \
} \
} \
}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define b
Definition input.c:43
#define AV_RN32(p)
uint8_t w
Definition llvidencdsp.c:39

Definition at line 149 of file avf_abitscope.c.

Referenced by filter_frame().

◆ DO_TRACE

#define DO_TRACE ( type,
depth,
one )
Value:
for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) { \
const int nb_samples = insamples->nb_samples; \
const int w = outpicref->width / inlink->ch_layout.nb_channels; \
const type *in = (const type *)insamples->extended_data[ch]; \
uint64_t *counter = s->counter; \
const int wb = w / depth; \
int wv; \
\
BITCOUNTER(type, depth, one) \
\
for (int b = 0; b < depth; b++) { \
uint8_t colors[4]; \
uint32_t color; \
uint8_t *dst = outpicref->data[0] + w * ch * 4 + wb * b * 4 + \
s->current_vpos * outpicref->linesize[0]; \
wv = (counter[depth - b - 1] * 255) / nb_samples; \
colors[0] = (wv * s->fg[ch * 4 + 0] + 127) / 255; \
colors[1] = (wv * s->fg[ch * 4 + 1] + 127) / 255; \
colors[2] = (wv * s->fg[ch * 4 + 2] + 127) / 255; \
colors[3] = (wv * s->fg[ch * 4 + 3] + 127) / 255; \
color = AV_RN32(colors); \
\
for (int x = 0; x < wb; x++) \
AV_WN32(&dst[x * 4], color); \
} \
}
#define AV_WN32(p, v)

Definition at line 172 of file avf_abitscope.c.

Referenced by filter_frame().

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( abitscope )

◆ query_formats()

static int query_formats ( const AVFilterContext * ctx,
AVFilterFormatsConfig ** cfg_in,
AVFilterFormatsConfig ** cfg_out )
static

Definition at line 68 of file avf_abitscope.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 91 of file avf_abitscope.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 127 of file avf_abitscope.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * insamples )
static

Definition at line 200 of file avf_abitscope.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 263 of file avf_abitscope.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 285 of file avf_abitscope.c.

Variable Documentation

◆ abitscope_options

const AVOption abitscope_options[]
static
Initial value:
= {
{ "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
{ "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="1024x256"}, 0, 0, FLAGS },
{ "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="1024x256"}, 0, 0, FLAGS },
{ "colors", "set channels colors", OFFSET(colors), AV_OPT_TYPE_STRING, {.str = "red|green|blue|yellow|orange|lime|pink|magenta|brown" }, 0, 0, FLAGS },
{ "mode", "set output mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, .unit = "mode" },
{ "m", "set output mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, .unit = "mode" },
{ "bars", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, .unit = "mode" },
{ "trace", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, .unit = "mode" },
{ NULL }
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
mode
Use these values in ebur128_init (or'ed).
Definition ebur128.h:83
#define OFFSET(x)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 53 of file avf_abitscope.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 292 of file avf_abitscope.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 300 of file avf_abitscope.c.

◆ ff_avf_abitscope

const FFFilter ff_avf_abitscope
Initial value:
= {
.p.name = "abitscope",
.p.description = NULL_IF_CONFIG_SMALL("Convert input audio to audio bit scope video output."),
.p.priv_class = &abitscope_class,
.priv_size = sizeof(AudioBitScopeContext),
.uninit = uninit,
.activate = activate,
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static const AVFilterPad inputs[]
Definition af_aap.c:299
static const AVFilterPad outputs[]
Definition af_aap.c:310
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 308 of file avf_abitscope.c.