54 #define OFFSET(x) offsetof(VectorscopeContext, x)
55 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
122 if ((s->
x == 1 && s->
y == 2) || (s->
x == 2 && s->
y == 1))
160 if ((s->
x == 1 && s->
y == 2) || (s->
x == 2 && s->
y == 1))
162 else if ((s->
x == 0 && s->
y == 2) || (s->
x == 2 && s->
y == 0))
164 else if ((s->
x == 0 && s->
y == 1) || (s->
x == 1 && s->
y == 0))
194 outlink->
h = outlink->
w = 1 <<
depth;
201 const int dlinesize = out->
linesize[0];
205 for (i = 0; i < out->
height; i++) {
206 for (j = 0; j < out->
width; j++) {
207 const int pos = i * dlinesize + j;
208 const int poa = (i - 1) * dlinesize + j;
209 const int pob = (i + 1) * dlinesize + j;
211 if (dpd[pos] && (((!j || !dpd[pos - 1]) || ((j == (out->
width - 1)) || !dpd[pos + 1]))
212 || ((!i || !dpd[poa]) || ((i == (out->
height - 1)) || !dpd[pob])))) {
221 const int dlinesize = out->
linesize[0];
225 for (i = 0; i < out->
height; i++) {
226 for (j = 0; j < out->
width; j++) {
227 const int pos = i * dlinesize + j;
237 for (i = 0; i < out->
height; i++) {
238 for (j = 0; j < out->
width; j++) {
239 const int pos = i * dlinesize + j;
241 if (s->
peak[i][j] && (((!j || !s->
peak[i][j-1]) || ((j == (out->
width - 1)) || !s->
peak[i][j + 1]))
242 || ((!i || !s->
peak[i-1][j]) || ((i == (out->
height - 1)) || !s->
peak[i + 1][j])))) {
263 const int slinesizex = in->
linesize[s->
x];
264 const int slinesizey = in->
linesize[s->
y];
265 const int slinesized = in->
linesize[pd];
266 const int dlinesize = out->
linesize[0];
268 const int px = s->
x, py = s->
y;
274 const int hsub = s->
hsub;
275 const int vsub = s->
vsub;
286 for (i = 0; i <
h; i++) {
287 const int iwx = i * slinesizex;
288 const int iwy = i * slinesizey;
289 for (j = 0; j < w; j++) {
290 const int x = spx[iwx + j];
291 const int y = spy[iwy + j];
292 const int pos = y * dlinesize + x;
294 dpd[pos] =
FFMIN(dpd[pos] + intensity, 255);
300 for (i = 0; i <
h; i++) {
301 const int iwx = i * slinesizex;
302 const int iwy = i * slinesizey;
303 for (j = 0; j < w; j++) {
304 const int x = spx[iwx + j];
305 const int y = spy[iwy + j];
306 const int pos = y * dlinesize + x;
308 dst[0][pos] =
FFMIN(dst[0][pos] + intensity, 255);
309 dst[1][pos] =
FFMIN(dst[1][pos] + intensity, 255);
310 dst[2][pos] =
FFMIN(dst[2][pos] + intensity, 255);
319 for (i = 0; i <
h; i++) {
320 const int iw1 = i * slinesizex;
321 const int iw2 = i * slinesizey;
322 for (j = 0; j < w; j++) {
323 const int x = spx[iw1 + j];
324 const int y = spy[iw2 + j];
325 const int pos = y * dlinesize + x;
336 for (i = 0; i <
h; i++) {
337 const int iw1 = i * slinesizex;
338 const int iw2 = i * slinesizey;
339 for (j = 0; j < w; j++) {
340 const int x = spx[iw1 + j];
341 const int y = spy[iw2 + j];
342 const int pos = y * dlinesize + x;
345 dpd[pos] =
FFMIN(x + y, 255);
355 for (i = 0; i <
h; i++) {
356 const int iw1 = i * slinesizex;
357 const int iw2 = i * slinesizey;
358 for (j = 0; j < w; j++) {
359 const int x = spx[iw1 + j];
360 const int y = spy[iw2 + j];
361 const int pos = y * dlinesize + x;
363 dpd[pos] =
FFMIN(255, dpd[pos] + intensity);
372 for (i = 0; i < in->
height; i++) {
373 const int iwx = (i >> vsub) * slinesizex;
374 const int iwy = (i >> vsub) * slinesizey;
375 const int iwd = i * slinesized;
376 for (j = 0; j < in->
width; j++) {
377 const int x = spx[iwx + (j >> hsub)];
378 const int y = spy[iwy + (j >> hsub)];
379 const int pos = y * dlinesize + x;
381 dpd[pos] =
FFMAX(spd[iwd + j], dpd[pos]);
396 for (i = 0; i < out->
height; i++) {
397 for (j = 0; j < out->
width; j++) {
398 if (!dpd[i * out->
linesize[pd] + j]) {
401 dpd[i * out->
linesize[pd] + j] = 128;
425 for (k = 0; k < 4 && dst[k]; k++)
426 for (i = 0; i < outlink->
h ; i++)
427 memset(dst[k] + i * out->
linesize[k],
456 .
name =
"vectorscope",
459 .priv_class = &vectorscope_class,
static int config_input(AVFilterLink *inlink)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
AVFILTER_DEFINE_CLASS(vectorscope)
static enum AVPixelFormat out_yuv_pix_fmts[]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
int h
agreed upon image height
static void envelope_peak(VectorscopeContext *s, AVFrame *out)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static const uint8_t black_gbrp_color[4]
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
static enum AVPixelFormat in2_pix_fmts[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
A filter pad used for either input or output.
static const AVOption vectorscope_options[]
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
uint16_t depth_minus1
Number of bits in the component minus 1.
int width
width and height of the video frame
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
static const AVFilterPad inputs[]
simple assert() macros that are a bit more flexible than ISO C assert().
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
static const uint8_t black_yuva_color[4]
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVFilter ff_vf_vectorscope
int w
agreed upon image width
static void envelope(VectorscopeContext *s, AVFrame *out)
static enum AVPixelFormat in1_pix_fmts[]
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define FF_CEIL_RSHIFT(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
AVFilterContext * src
source filter
int format
agreed upon media format
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const AVFilterPad outputs[]
static int config_output(AVFilterLink *outlink)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
static int query_formats(AVFilterContext *ctx)
rational number numerator/denominator
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static enum AVPixelFormat out_rgb_pix_fmts[]
AVFilterLink ** outputs
array of pointers to output links
static void envelope_instant(VectorscopeContext *s, AVFrame *out)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar GBRA 4:4:4:4 32bpp
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd)
AVFilterContext * dst
dest filter
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AVPixelFormat
Pixel format.
AVFilterFormats * out_formats