60 #define OFFSET(x) offsetof(VectorscopeContext, x)
61 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
143 int depth, rgb, i, ret;
153 if ((s->
x == 1 && s->
y == 2) || (s->
x == 2 && s->
y == 1))
172 if (rgb && depth == 8)
174 else if (rgb && depth == 9)
176 else if (rgb && depth == 10)
180 else if (depth == 10)
198 outlink->
h = outlink->
w = s->
size;
205 const int dlinesize = out->
linesize[0] / 2;
207 const int max = s->
size - 1;
210 for (i = 0; i < out->
height; i++) {
211 for (j = 0; j < out->
width; j++) {
212 const int pos = i * dlinesize + j;
213 const int poa = (i - 1) * dlinesize + j;
214 const int pob = (i + 1) * dlinesize + j;
216 if (dpd[pos] && (((!j || !dpd[pos - 1]) || ((j == (out->
width - 1)) || !dpd[pos + 1]))
217 || ((!i || !dpd[poa]) || ((i == (out->
height - 1)) || !dpd[pob])))) {
226 const int dlinesize = out->
linesize[0] / 2;
228 const int max = s->
size - 1;
231 for (i = 0; i < out->
height; i++) {
232 for (j = 0; j < out->
width; j++) {
233 const int pos = i * dlinesize + j;
243 for (i = 0; i < out->
height; i++) {
244 for (j = 0; j < out->
width; j++) {
245 const int pos = i * dlinesize + j;
247 if (s->
peak[i][j] && (((!j || !s->
peak[i][j-1]) || ((j == (out->
width - 1)) || !s->
peak[i][j + 1]))
248 || ((!i || !s->
peak[i-1][j]) || ((i == (out->
height - 1)) || !s->
peak[i + 1][j])))) {
257 const int dlinesize = out->
linesize[0];
261 for (i = 0; i < out->
height; i++) {
262 for (j = 0; j < out->
width; j++) {
263 const int pos = i * dlinesize + j;
264 const int poa = (i - 1) * dlinesize + j;
265 const int pob = (i + 1) * dlinesize + j;
267 if (dpd[pos] && (((!j || !dpd[pos - 1]) || ((j == (out->
width - 1)) || !dpd[pos + 1]))
268 || ((!i || !dpd[poa]) || ((i == (out->
height - 1)) || !dpd[pob])))) {
277 const int dlinesize = out->
linesize[0];
281 for (i = 0; i < out->
height; i++) {
282 for (j = 0; j < out->
width; j++) {
283 const int pos = i * dlinesize + j;
293 for (i = 0; i < out->
height; i++) {
294 for (j = 0; j < out->
width; j++) {
295 const int pos = i * dlinesize + j;
297 if (s->
peak[i][j] && (((!j || !s->
peak[i][j-1]) || ((j == (out->
width - 1)) || !s->
peak[i][j + 1]))
298 || ((!i || !s->
peak[i-1][j]) || ((i == (out->
height - 1)) || !s->
peak[i + 1][j])))) {
329 const uint16_t *
const *
src = (
const uint16_t *
const *)in->
data;
330 const int slinesizex = in->
linesize[s->
x] / 2;
331 const int slinesizey = in->
linesize[s->
y] / 2;
332 const int slinesized = in->
linesize[pd] / 2;
333 const int dlinesize = out->
linesize[0] / 2;
335 const int px = s->
x, py = s->
y;
338 const uint16_t *spx = src[px];
339 const uint16_t *spy = src[py];
340 const uint16_t *spd = src[pd];
343 uint16_t **dst = (uint16_t **)out->
data;
344 uint16_t *dpx = dst[px];
345 uint16_t *dpy = dst[py];
346 uint16_t *dpd = dst[
pd];
347 const int max = s->
size - 1;
348 const int mid = s->
size / 2;
351 for (k = 0; k < 4 && dst[k]; k++) {
354 for (i = 0; i < out->
height ; i++)
355 for (j = 0; j < out->
width; j++)
364 for (i = 0; i <
h; i++) {
365 const int iwx = i * slinesizex;
366 const int iwy = i * slinesizey;
367 for (j = 0; j < w; j++) {
368 const int x =
FFMIN(spx[iwx + j], max);
369 const int y =
FFMIN(spy[iwy + j], max);
370 const int pos = y * dlinesize +
x;
378 for (i = 0; i <
h; i++) {
379 const int iwx = i * slinesizex;
380 const int iwy = i * slinesizey;
381 for (j = 0; j < w; j++) {
382 const int x =
FFMIN(spx[iwx + j], max);
383 const int y =
FFMIN(spy[iwy + j], max);
384 const int pos = y * dlinesize +
x;
397 for (i = 0; i <
h; i++) {
398 const int iw1 = i * slinesizex;
399 const int iw2 = i * slinesizey;
400 for (j = 0; j < w; j++) {
401 const int x =
FFMIN(spx[iw1 + j], max);
402 const int y =
FFMIN(spy[iw2 + j], max);
403 const int pos = y * dlinesize +
x;
414 for (i = 0; i <
h; i++) {
415 const int iw1 = i * slinesizex;
416 const int iw2 = i * slinesizey;
417 for (j = 0; j < w; j++) {
418 const int x =
FFMIN(spx[iw1 + j], max);
419 const int y =
FFMIN(spy[iw2 + j], max);
420 const int pos = y * dlinesize +
x;
423 dpd[pos] =
FFMIN(x + y, max);
433 for (i = 0; i <
h; i++) {
434 const int iw1 = i * slinesizex;
435 const int iw2 = i * slinesizey;
436 for (j = 0; j < w; j++) {
437 const int x =
FFMIN(spx[iw1 + j], max);
438 const int y =
FFMIN(spy[iw2 + j], max);
439 const int pos = y * dlinesize +
x;
450 for (i = 0; i < in->
height; i++) {
451 const int iwx = (i >>
vsub) * slinesizex;
452 const int iwy = (i >>
vsub) * slinesizey;
453 const int iwd = i * slinesized;
454 for (j = 0; j < in->
width; j++) {
455 const int x =
FFMIN(spx[iwx + (j >>
hsub)], max);
456 const int y =
FFMIN(spy[iwy + (j >>
hsub)], max);
457 const int pos = y * dlinesize +
x;
459 dpd[pos] =
FFMAX(spd[iwd + j], dpd[pos]);
474 for (i = 0; i < out->
height; i++) {
475 for (j = 0; j < out->
width; j++) {
476 if (!dpd[i * dlinesize + j]) {
477 dpx[i * dlinesize + j] = j;
478 dpy[i * dlinesize + j] = i;
479 dpd[i * dlinesize + j] = mid;
489 const int slinesizex = in->
linesize[s->
x];
490 const int slinesizey = in->
linesize[s->
y];
491 const int slinesized = in->
linesize[pd];
492 const int dlinesize = out->
linesize[0];
494 const int px = s->
x, py = s->
y;
508 for (k = 0; k < 4 && dst[k]; k++)
509 for (i = 0; i < out->
height ; i++)
510 memset(dst[k] + i * out->
linesize[k],
517 for (i = 0; i <
h; i++) {
518 const int iwx = i * slinesizex;
519 const int iwy = i * slinesizey;
520 for (j = 0; j < w; j++) {
521 const int x = spx[iwx + j];
522 const int y = spy[iwy + j];
523 const int pos = y * dlinesize +
x;
531 for (i = 0; i <
h; i++) {
532 const int iwx = i * slinesizex;
533 const int iwy = i * slinesizey;
534 for (j = 0; j < w; j++) {
535 const int x = spx[iwx + j];
536 const int y = spy[iwy + j];
537 const int pos = y * dlinesize +
x;
550 for (i = 0; i <
h; i++) {
551 const int iw1 = i * slinesizex;
552 const int iw2 = i * slinesizey;
553 for (j = 0; j < w; j++) {
554 const int x = spx[iw1 + j];
555 const int y = spy[iw2 + j];
556 const int pos = y * dlinesize +
x;
567 for (i = 0; i <
h; i++) {
568 const int iw1 = i * slinesizex;
569 const int iw2 = i * slinesizey;
570 for (j = 0; j < w; j++) {
571 const int x = spx[iw1 + j];
572 const int y = spy[iw2 + j];
573 const int pos = y * dlinesize +
x;
576 dpd[pos] =
FFMIN(x + y, 255);
586 for (i = 0; i <
h; i++) {
587 const int iw1 = i * slinesizex;
588 const int iw2 = i * slinesizey;
589 for (j = 0; j < w; j++) {
590 const int x = spx[iw1 + j];
591 const int y = spy[iw2 + j];
592 const int pos = y * dlinesize +
x;
603 for (i = 0; i < in->
height; i++) {
604 const int iwx = (i >>
vsub) * slinesizex;
605 const int iwy = (i >>
vsub) * slinesizey;
606 const int iwd = i * slinesized;
607 for (j = 0; j < in->
width; j++) {
608 const int x = spx[iwx + (j >>
hsub)];
609 const int y = spy[iwy + (j >>
hsub)];
610 const int pos = y * dlinesize +
x;
612 dpd[pos] =
FFMAX(spd[iwd + j], dpd[pos]);
627 for (i = 0; i < out->
height; i++) {
628 for (j = 0; j < out->
width; j++) {
629 if (!dpd[i * out->
linesize[pd] + j]) {
671 if ((s->
x == 1 && s->
y == 2) || (s->
x == 2 && s->
y == 1))
673 else if ((s->
x == 0 && s->
y == 2) || (s->
x == 2 && s->
y == 0))
675 else if ((s->
x == 0 && s->
y == 1) || (s->
x == 1 && s->
y == 0))
725 .
name =
"vectorscope",
728 .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)
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)
#define AV_PIX_FMT_GBRP10
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.
static void envelope_instant16(VectorscopeContext *s, AVFrame *out)
static enum AVPixelFormat out_yuv8_pix_fmts[]
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.
static enum AVPixelFormat out_rgb8_pix_fmts[]
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
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.
#define AV_PIX_FMT_YUV444P10
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
static enum AVPixelFormat out_yuv10_pix_fmts[]
int w
agreed upon image width
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
static enum AVPixelFormat out_rgb9_pix_fmts[]
#define AV_PIX_FMT_YUV422P9
static void envelope(VectorscopeContext *s, AVFrame *out)
static enum AVPixelFormat in1_pix_fmts[]
static enum AVPixelFormat out_rgb10_pix_fmts[]
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
AVFilterContext * src
source filter
#define AV_PIX_FMT_YUV444P9
int format
agreed upon media format
static void envelope_peak16(VectorscopeContext *s, AVFrame *out)
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
static int16_t mult(Float11 *f1, Float11 *f2)
#define AV_PIX_FMT_YUV420P10
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.
#define AV_PIX_FMT_YUV420P9
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
static void envelope_instant(VectorscopeContext *s, AVFrame *out)
#define AV_PIX_FMT_YUV422P10
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 enum AVPixelFormat out_yuv9_pix_fmts[]
AVFilterContext * dst
dest filter
static void envelope16(VectorscopeContext *s, AVFrame *out)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
void(* vectorscope)(struct VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd)
static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd)
int depth
Number of bits in the component.
AVPixelFormat
Pixel format.
AVFilterFormats * out_formats
#define AV_CEIL_RSHIFT(a, b)