FFmpeg
Data Structures | Macros | Functions | Variables
avf_abitscope.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "audio.h"
#include "video.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  AudioBitScopeContext
 

Macros

#define OFFSET(x)   offsetof(AudioBitScopeContext, 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 (AVFilterContext *ctx)
 
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 AVFilter ff_avf_abitscope
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(AudioBitScopeContext, x)

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)); \
}

Definition at line 151 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); \
} \
} \
} \
}

Definition at line 159 of file avf_abitscope.c.

◆ 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); \
} \
}

Definition at line 182 of file avf_abitscope.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( abitscope  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 68 of file avf_abitscope.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 102 of file avf_abitscope.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 138 of file avf_abitscope.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 210 of file avf_abitscope.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 273 of file avf_abitscope.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 295 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 }
}

Definition at line 53 of file avf_abitscope.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}

Definition at line 302 of file avf_abitscope.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 310 of file avf_abitscope.c.

◆ ff_avf_abitscope

const AVFilter ff_avf_abitscope
Initial value:
= {
.name = "abitscope",
.description = NULL_IF_CONFIG_SMALL("Convert input audio to audio bit scope video output."),
.priv_size = sizeof(AudioBitScopeContext),
.uninit = uninit,
.activate = activate,
.priv_class = &abitscope_class,
}

Definition at line 318 of file avf_abitscope.c.

color
Definition: vf_paletteuse.c:511
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:248
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
w
uint8_t w
Definition: llviddspenc.c:38
b
#define b
Definition: input.c:41
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
OFFSET
#define OFFSET(x)
Definition: avf_abitscope.c:50
FLAGS
#define FLAGS
Definition: avf_abitscope.c:51
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
NULL
#define NULL
Definition: coverity.c:32
AudioBitScopeContext
Definition: avf_abitscope.c:32
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_abitscope.c:295
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:245
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:362
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: avf_abitscope.c:68
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:374
inputs
static const AVFilterPad inputs[]
Definition: avf_abitscope.c:302
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
color
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:94
outputs
static const AVFilterPad outputs[]
Definition: avf_abitscope.c:310
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
config_input
static int config_input(AVFilterLink *inlink)
Definition: avf_abitscope.c:102
activate
static int activate(AVFilterContext *ctx)
Definition: avf_abitscope.c:273
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
BITCOUNTER
#define BITCOUNTER(type, depth, one)
Definition: avf_abitscope.c:151
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_abitscope.c:138
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
h
h
Definition: vp9dsp_template.c:2038
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244