FFmpeg
Data Structures | Macros | Functions | Variables
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)   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 (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 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 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); \
} \
} \
} \
}

Definition at line 149 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 172 of file avf_abitscope.c.

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 }
}

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 292 of file avf_abitscope.c.

◆ outputs

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

Definition at line 300 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 308 of file avf_abitscope.c.

color
Definition: vf_paletteuse.c:513
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
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
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
mode
Definition: swscale.c:52
w
uint8_t w
Definition: llviddspenc.c:38
b
#define b
Definition: input.c:41
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: avf_abitscope.c:68
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_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:285
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:360
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:94
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:372
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
inputs
static const AVFilterPad inputs[]
Definition: avf_abitscope.c:292
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:300
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
config_input
static int config_input(AVFilterLink *inlink)
Definition: avf_abitscope.c:91
activate
static int activate(AVFilterContext *ctx)
Definition: avf_abitscope.c:263
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
BITCOUNTER
#define BITCOUNTER(type, depth, one)
Definition: avf_abitscope.c:141
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_abitscope.c:127
h
h
Definition: vp9dsp_template.c:2070
AV_OPT_TYPE_STRING
@ 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:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299