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

◆ BARS

#define BARS (   type,
  depth,
  one 
)
Value:
for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) { \
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]); \
\
memset(s->counter, 0, sizeof(s->counter)); \
for (int i = 0; i < insamples->nb_samples; i++) { \
for (int j = 0; j < depth; j++) { \
if (in[i] & (one << j)) \
s->counter[j]++; \
} \
} \
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 = (s->counter[depth - b - 1] / (float)insamples->nb_samples) * (w - 1); \
for (int i = 0; i < ww; i++) { \
AV_WN32(&dst[i * 4], color); \
} \
} \
} \
}

Definition at line 150 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 w = outpicref->width / inlink->ch_layout.nb_channels; \
const type *in = (const type *)insamples->extended_data[ch]; \
const int wb = w / depth; \
int wv; \
\
memset(s->counter, 0, sizeof(s->counter)); \
for (int i = 0; i < insamples->nb_samples; i++) { \
for (int j = 0; j < depth; j++) { \
if (in[i] & (one << j)) \
s->counter[j]++; \
} \
} \
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 = (s->counter[depth - b - 1] * 255) / insamples->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 177 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 209 of file avf_abitscope.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 264 of file avf_abitscope.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 286 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, "mode" },
{ "m", "set output mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS, "mode" },
{ "bars", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "mode" },
{ "trace", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "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 293 of file avf_abitscope.c.

◆ outputs

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

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

color
Definition: vf_paletteuse.c:600
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:238
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:34
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:167
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:256
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
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:286
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:235
AV_RN32
#define AV_RN32(p)
Definition: intreadwrite.h:364
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:116
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: avf_abitscope.c:68
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
inputs
static const AVFilterPad inputs[]
Definition: avf_abitscope.c:293
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:301
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
config_input
static int config_input(AVFilterLink *inlink)
Definition: avf_abitscope.c:102
activate
static int activate(AVFilterContext *ctx)
Definition: avf_abitscope.c:264
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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:191
h
h
Definition: vp9dsp_template.c:2038
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234