Go to the documentation of this file.
70 #define OFFSET(x) offsetof(SignalstatsContext, x)
71 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
95 s->filters |= 1 <<
s->outfilter;
100 s->yuv_color[0] = (( 66*
r + 129*
g + 25*
b + (1<<7)) >> 8) + 16;
101 s->yuv_color[1] = ((-38*
r + -74*
g + 112*
b + (1<<7)) >> 8) + 128;
102 s->yuv_color[2] = ((112*
r + -94*
g + -18*
b + (1<<7)) >> 8) + 128;
167 s->hsub =
desc->log2_chroma_w;
168 s->vsub =
desc->log2_chroma_h;
169 s->depth =
desc->comp[0].depth;
170 s->maxsize = 1 <<
s->depth;
176 if (!
s->histy || !
s->histu || !
s->histv || !
s->histsat)
186 s->cfs =
s->chromaw *
s->chromah;
195 if (!
s->frame_sat || !
s->frame_hue)
203 const int chromax = x >>
s->hsub;
204 const int chromay = y >>
s->vsub;
205 f->data[0][y *
f->linesize[0] + x] =
s->yuv_color[0];
206 f->data[1][chromay *
f->linesize[1] + chromax] =
s->yuv_color[1];
207 f->data[2][chromay *
f->linesize[2] + chromax] =
s->yuv_color[2];
212 const int chromax = x >>
s->hsub;
213 const int chromay = y >>
s->vsub;
214 const int mult = 1 << (
s->depth - 8);
215 AV_WN16(
f->data[0] + y *
f->linesize[0] + x * 2,
s->yuv_color[0] *
mult);
216 AV_WN16(
f->data[1] + chromay *
f->linesize[1] + chromax * 2,
s->yuv_color[1] *
mult);
217 AV_WN16(
f->data[2] + chromay *
f->linesize[2] + chromax * 2,
s->yuv_color[2] *
mult);
226 const int w =
in->width;
227 const int h =
in->height;
228 const int slice_start = (
h * jobnr ) / nb_jobs;
229 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
232 for (y = slice_start; y <
slice_end; y++) {
233 const int yc = y >>
s->vsub;
234 const uint8_t *pluma = &
in->data[0][y *
in->linesize[0]];
235 const uint8_t *pchromau = &
in->data[1][yc *
in->linesize[1]];
236 const uint8_t *pchromav = &
in->data[2][yc *
in->linesize[2]];
238 for (x = 0; x <
w; x++) {
239 const int xc = x >>
s->hsub;
240 const int luma = pluma[x];
241 const int chromau = pchromau[xc];
242 const int chromav = pchromav[xc];
243 const int filt = luma < 16 || luma > 235 ||
244 chromau < 16 || chromau > 240 ||
245 chromav < 16 || chromav > 240;
260 const int mult = 1 << (
s->depth - 8);
261 const int w =
in->width;
262 const int h =
in->height;
263 const int slice_start = (
h * jobnr ) / nb_jobs;
264 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
267 for (y = slice_start; y <
slice_end; y++) {
268 const int yc = y >>
s->vsub;
269 const uint16_t *pluma = (uint16_t *)&
in->data[0][y *
in->linesize[0]];
270 const uint16_t *pchromau = (uint16_t *)&
in->data[1][yc *
in->linesize[1]];
271 const uint16_t *pchromav = (uint16_t *)&
in->data[2][yc *
in->linesize[2]];
273 for (x = 0; x <
w; x++) {
274 const int xc = x >>
s->hsub;
275 const int luma = pluma[x];
276 const int chromau = pchromau[xc];
277 const int chromav = pchromav[xc];
278 const int filt = luma < 16 * mult || luma > 235 *
mult ||
279 chromau < 16 * mult || chromau > 240 *
mult ||
280 chromav < 16 * mult || chromav > 240 *
mult;
291 return ((
abs(x - y) +
abs (z - y)) / 2) -
abs(z - x) > 4;
300 const int w =
in->width;
301 const int h =
in->height;
302 const int slice_start = (
h * jobnr ) / nb_jobs;
303 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
305 int lw =
in->linesize[0];
306 int x, y, score = 0,
filt;
308 for (y = slice_start; y <
slice_end; y++) {
310 if (y - 1 < 0 || y + 1 >=
h)
316 #define FILTER(i, j) \
317 filter_tout_outlier(p[(y-j) * lw + x + i], \
318 p[ y * lw + x + i], \
319 p[(y+j) * lw + x + i])
321 #define FILTER3(j) (FILTER(-1, j) && FILTER(0, j) && FILTER(1, j))
323 if (y - 2 >= 0 && y + 2 <
h) {
324 for (x = 1; x <
w - 1; x++) {
331 for (x = 1; x <
w - 1; x++) {
348 const int w =
in->width;
349 const int h =
in->height;
350 const int slice_start = (
h * jobnr ) / nb_jobs;
351 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
352 const uint16_t *p = (uint16_t *)
in->data[0];
353 int lw =
in->linesize[0] / 2;
354 int x, y, score = 0,
filt;
358 if (y - 1 < 0 || y + 1 >=
h)
364 if (y - 2 >= 0 && y + 2 <
h) {
365 for (x = 1; x <
w - 1; x++) {
372 for (x = 1; x <
w - 1; x++) {
391 const int w =
in->width;
392 const int h =
in->height;
393 const int slice_start = (
h * jobnr ) / nb_jobs;
394 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
396 const int lw =
in->linesize[0];
399 for (y = slice_start; y <
slice_end; y++) {
401 const int ylw = y * lw;
402 int filt, totdiff = 0;
407 for (x = 0; x <
w; x++)
408 totdiff +=
abs(p[y2lw + x] - p[ylw + x]);
413 for (x = 0; x <
w; x++)
425 const int w =
in->width;
426 const int h =
in->height;
427 const int slice_start = (
h * jobnr ) / nb_jobs;
428 const int slice_end = (
h * (jobnr+1)) / nb_jobs;
429 const uint16_t *p = (uint16_t *)
in->data[0];
430 const int lw =
in->linesize[0] / 2;
435 const int ylw = y * lw;
442 for (x = 0; x <
w; x++)
443 totdiff +=
abs(p[y2lw + x] - p[ylw + x]);
448 for (x = 0; x <
w; x++)
454 static const struct {
474 const int slice_start = (
s->chromah * jobnr ) / nb_jobs;
475 const int slice_end = (
s->chromah * (jobnr+1)) / nb_jobs;
477 const int lsz_u =
src->linesize[1];
478 const int lsz_v =
src->linesize[2];
479 const uint8_t *p_u =
src->data[1] + slice_start * lsz_u;
480 const uint8_t *p_v =
src->data[2] + slice_start * lsz_v;
482 const int lsz_sat = dst_sat->
linesize[0];
483 const int lsz_hue = dst_hue->
linesize[0];
484 uint8_t *p_sat = dst_sat->
data[0] + slice_start * lsz_sat;
485 uint8_t *p_hue = dst_hue->
data[0] + slice_start * lsz_hue;
487 for (j = slice_start; j <
slice_end; j++) {
488 for (
i = 0;
i <
s->chromaw;
i++) {
489 const int yuvu = p_u[
i];
490 const int yuvv = p_v[
i];
491 p_sat[
i] =
hypot(yuvu - 128, yuvv - 128);
492 ((int16_t*)p_hue)[
i] = fmod(
floor((180 /
M_PI) *
atan2f(yuvu-128, yuvv-128) + 180), 360.);
511 const int mid = 1 << (
s->depth - 1);
513 const int slice_start = (
s->chromah * jobnr ) / nb_jobs;
514 const int slice_end = (
s->chromah * (jobnr+1)) / nb_jobs;
516 const int lsz_u =
src->linesize[1] / 2;
517 const int lsz_v =
src->linesize[2] / 2;
518 const uint16_t *p_u = (uint16_t*)
src->data[1] + slice_start * lsz_u;
519 const uint16_t *p_v = (uint16_t*)
src->data[2] + slice_start * lsz_v;
521 const int lsz_sat = dst_sat->
linesize[0] / 2;
522 const int lsz_hue = dst_hue->
linesize[0] / 2;
523 uint16_t *p_sat = (uint16_t*)dst_sat->
data[0] + slice_start * lsz_sat;
524 uint16_t *p_hue = (uint16_t*)dst_hue->
data[0] + slice_start * lsz_hue;
526 for (j = slice_start; j <
slice_end; j++) {
527 for (
i = 0;
i <
s->chromaw;
i++) {
528 const int yuvu = p_u[
i];
529 const int yuvv = p_v[
i];
530 p_sat[
i] =
hypot(yuvu - mid, yuvv - mid);
531 ((int16_t*)p_hue)[
i] = fmod(
floor((180 /
M_PI) *
atan2f(yuvu-mid, yuvv-mid) + 180), 360.);
558 unsigned int *histy =
s->histy,
562 *histsat =
s->histsat;
563 int miny = -1, minu = -1, minv = -1;
564 int maxy = -1, maxu = -1, maxv = -1;
565 int lowy = -1, lowu = -1, lowv = -1;
566 int highy = -1, highu = -1, highv = -1;
567 int minsat = -1, maxsat = -1, lowsat = -1, highsat = -1;
568 int lowp, highp, clowp, chighp;
569 int accy, accu, accv;
570 int accsat, acchue = 0;
572 int toty = 0, totu = 0, totv = 0, totsat=0;
574 int dify = 0, difu = 0, difv = 0;
575 uint16_t masky = 0, masku = 0, maskv = 0;
584 const int lsz_sat = sat->
linesize[0];
585 const int lsz_hue = hue->
linesize[0];
595 prev =
s->frame_prev;
606 memset(
s->histy, 0,
s->maxsize *
sizeof(*
s->histy));
607 for (j = 0; j <
link->h; j++) {
608 for (
i = 0;
i <
link->w;
i++) {
609 const int yuv =
in->data[0][
w +
i];
613 dify +=
abs(yuv - prev->
data[0][pw +
i]);
615 w +=
in->linesize[0];
620 memset(
s->histu, 0,
s->maxsize *
sizeof(*
s->histu));
621 memset(
s->histv, 0,
s->maxsize *
sizeof(*
s->histv));
622 memset(
s->histsat, 0,
s->maxsize *
sizeof(*
s->histsat));
623 for (j = 0; j <
s->chromah; j++) {
624 for (
i = 0;
i <
s->chromaw;
i++) {
625 const int yuvu =
in->data[1][cw+
i];
626 const int yuvv =
in->data[2][cw+
i];
631 difu +=
abs(yuvu - prev->
data[1][cpw+
i]);
633 difv +=
abs(yuvv - prev->
data[2][cpw+
i]);
636 histhue[((int16_t*)p_hue)[
i]]++;
638 cw +=
in->linesize[1];
645 if (
s->filters & 1<<fil) {
650 memset(
s->jobs_rets, 0,
s->nb_jobs *
sizeof(*
s->jobs_rets));
652 &
td,
s->jobs_rets,
s->nb_jobs);
653 for (
i = 0;
i <
s->nb_jobs;
i++)
654 filtot[fil] +=
s->jobs_rets[
i];
661 lowp =
lrint(
s->fs * 10 / 100.);
662 highp =
lrint(
s->fs * 90 / 100.);
663 clowp =
lrint(
s->cfs * 10 / 100.);
664 chighp =
lrint(
s->cfs * 90 / 100.);
666 accy = accu = accv = accsat = 0;
667 for (fil = 0; fil <
s->maxsize; fil++) {
668 if (miny < 0 && histy[fil]) miny = fil;
669 if (minu < 0 && histu[fil]) minu = fil;
670 if (minv < 0 && histv[fil]) minv = fil;
671 if (minsat < 0 && histsat[fil]) minsat = fil;
673 if (histy[fil]) maxy = fil;
674 if (histu[fil]) maxu = fil;
675 if (histv[fil]) maxv = fil;
676 if (histsat[fil]) maxsat = fil;
678 toty += histy[fil] * fil;
679 totu += histu[fil] * fil;
680 totv += histv[fil] * fil;
681 totsat += histsat[fil] * fil;
686 accsat += histsat[fil];
688 if (lowy == -1 && accy >= lowp) lowy = fil;
689 if (lowu == -1 && accu >= clowp) lowu = fil;
690 if (lowv == -1 && accv >= clowp) lowv = fil;
691 if (lowsat == -1 && accsat >= clowp) lowsat = fil;
693 if (highy == -1 && accy >= highp) highy = fil;
694 if (highu == -1 && accu >= chighp) highu = fil;
695 if (highv == -1 && accv >= chighp) highv = fil;
696 if (highsat == -1 && accsat >= chighp) highsat = fil;
701 for (fil = 0; fil < 360; fil++) {
702 tothue += histhue[fil] * fil;
703 acchue += histhue[fil];
705 if (medhue == -1 && acchue >
s->cfs / 2)
707 if (histhue[fil] > maxhue) {
708 maxhue = histhue[fil];
715 #define SET_META(key, fmt, val) do { \
716 snprintf(metabuf, sizeof(metabuf), fmt, val); \
717 av_dict_set(&out->metadata, "lavfi.signalstats." key, metabuf, 0); \
722 SET_META(
"YAVG",
"%g", 1.0 * toty /
s->fs);
728 SET_META(
"UAVG",
"%g", 1.0 * totu /
s->cfs);
734 SET_META(
"VAVG",
"%g", 1.0 * totv /
s->cfs);
740 SET_META(
"SATAVG",
"%g", 1.0 * totsat /
s->cfs);
745 SET_META(
"HUEAVG",
"%g", 1.0 * tothue /
s->cfs);
747 SET_META(
"YDIF",
"%g", 1.0 * dify /
s->fs);
748 SET_META(
"UDIF",
"%g", 1.0 * difu /
s->cfs);
749 SET_META(
"VDIF",
"%g", 1.0 * difv /
s->cfs);
756 if (
s->filters & 1<<fil) {
758 snprintf(metabuf,
sizeof(metabuf),
"%g", 1.0 * filtot[fil] /
s->fs);
780 unsigned int *histy =
s->histy,
784 *histsat =
s->histsat;
785 int miny = -1, minu = -1, minv = -1;
786 int maxy = -1, maxu = -1, maxv = -1;
787 int lowy = -1, lowu = -1, lowv = -1;
788 int highy = -1, highu = -1, highv = -1;
789 int minsat = -1, maxsat = -1, lowsat = -1, highsat = -1;
790 int lowp, highp, clowp, chighp;
791 int accy, accu, accv;
792 int accsat, acchue = 0;
794 int64_t toty = 0, totu = 0, totv = 0, totsat=0;
796 int64_t dify = 0, difu = 0, difv = 0;
797 uint16_t masky = 0, masku = 0, maskv = 0;
804 const uint16_t *p_sat = (uint16_t *)sat->
data[0];
805 const uint16_t *p_hue = (uint16_t *)hue->
data[0];
806 const int lsz_sat = sat->
linesize[0] / 2;
807 const int lsz_hue = hue->
linesize[0] / 2;
817 prev =
s->frame_prev;
828 memset(
s->histy, 0,
s->maxsize *
sizeof(*
s->histy));
829 for (j = 0; j <
link->h; j++) {
830 for (
i = 0;
i <
link->w;
i++) {
837 w +=
in->linesize[0];
842 memset(
s->histu, 0,
s->maxsize *
sizeof(*
s->histu));
843 memset(
s->histv, 0,
s->maxsize *
sizeof(*
s->histv));
844 memset(
s->histsat, 0,
s->maxsize *
sizeof(*
s->histsat));
845 for (j = 0; j <
s->chromah; j++) {
846 for (
i = 0;
i <
s->chromaw;
i++) {
847 const int yuvu =
AV_RN16(
in->data[1] + cw +
i * 2);
848 const int yuvv =
AV_RN16(
in->data[2] + cw +
i * 2);
858 histhue[((int16_t*)p_hue)[
i]]++;
860 cw +=
in->linesize[1];
867 if (
s->filters & 1<<fil) {
872 memset(
s->jobs_rets, 0,
s->nb_jobs *
sizeof(*
s->jobs_rets));
874 &
td,
s->jobs_rets,
s->nb_jobs);
875 for (
i = 0;
i <
s->nb_jobs;
i++)
876 filtot[fil] +=
s->jobs_rets[
i];
883 lowp =
lrint(
s->fs * 10 / 100.);
884 highp =
lrint(
s->fs * 90 / 100.);
885 clowp =
lrint(
s->cfs * 10 / 100.);
886 chighp =
lrint(
s->cfs * 90 / 100.);
888 accy = accu = accv = accsat = 0;
889 for (fil = 0; fil <
s->maxsize; fil++) {
890 if (miny < 0 && histy[fil]) miny = fil;
891 if (minu < 0 && histu[fil]) minu = fil;
892 if (minv < 0 && histv[fil]) minv = fil;
893 if (minsat < 0 && histsat[fil]) minsat = fil;
895 if (histy[fil]) maxy = fil;
896 if (histu[fil]) maxu = fil;
897 if (histv[fil]) maxv = fil;
898 if (histsat[fil]) maxsat = fil;
900 toty += histy[fil] * fil;
901 totu += histu[fil] * fil;
902 totv += histv[fil] * fil;
903 totsat += histsat[fil] * fil;
908 accsat += histsat[fil];
910 if (lowy == -1 && accy >= lowp) lowy = fil;
911 if (lowu == -1 && accu >= clowp) lowu = fil;
912 if (lowv == -1 && accv >= clowp) lowv = fil;
913 if (lowsat == -1 && accsat >= clowp) lowsat = fil;
915 if (highy == -1 && accy >= highp) highy = fil;
916 if (highu == -1 && accu >= chighp) highu = fil;
917 if (highv == -1 && accv >= chighp) highv = fil;
918 if (highsat == -1 && accsat >= chighp) highsat = fil;
923 for (fil = 0; fil < 360; fil++) {
924 tothue += histhue[fil] * fil;
925 acchue += histhue[fil];
927 if (medhue == -1 && acchue >
s->cfs / 2)
929 if (histhue[fil] > maxhue) {
930 maxhue = histhue[fil];
939 SET_META(
"YAVG",
"%g", 1.0 * toty /
s->fs);
945 SET_META(
"UAVG",
"%g", 1.0 * totu /
s->cfs);
951 SET_META(
"VAVG",
"%g", 1.0 * totv /
s->cfs);
957 SET_META(
"SATAVG",
"%g", 1.0 * totsat /
s->cfs);
962 SET_META(
"HUEAVG",
"%g", 1.0 * tothue /
s->cfs);
964 SET_META(
"YDIF",
"%g", 1.0 * dify /
s->fs);
965 SET_META(
"UDIF",
"%g", 1.0 * difu /
s->cfs);
966 SET_META(
"VDIF",
"%g", 1.0 * difv /
s->cfs);
973 if (
s->filters & 1<<fil) {
975 snprintf(metabuf,
sizeof(metabuf),
"%g", 1.0 * filtot[fil] /
s->fs);
1016 .
name =
"signalstats",
1017 .description =
"Generate statistics from video analysis.",
1024 .priv_class = &signalstats_class,
AVPixelFormat
Pixel format.
static int filter_frame8(AVFilterLink *link, AVFrame *in)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int compute_sat_hue_metrics16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold int init(AVFilterContext *ctx)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static const struct PPFilter filters[]
#define SET_META(key, fmt, val)
static int filter8_brng(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
#define AV_PIX_FMT_YUV420P10
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AVFILTER_DEFINE_CLASS(signalstats)
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
A link between two filters.
static int filter_frame16(AVFilterLink *link, AVFrame *in)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_PIX_FMT_YUV422P9
static int filter16_tout(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_GRAY16
static int filter_tout_outlier(uint8_t x, uint8_t y, uint8_t z)
A filter pad used for either input or output.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_PIX_FMT_YUV444P10
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
static av_cold void uninit(AVFilterContext *ctx)
static int16_t mult(Float11 *f1, Float11 *f2)
#define AV_PIX_FMT_YUV422P16
static const uint16_t mask[17]
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
static AVFrame * alloc_frame(enum AVPixelFormat pixfmt, int w, int h)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static __device__ float floor(float a)
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
static const AVFilterPad outputs[]
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Describe the class of an AVClass context structure.
static void burn_frame16(const SignalstatsContext *s, AVFrame *f, int x, int y)
static int filter8_tout(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
AVFilterLink ** inputs
array of pointers to input links
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV422P10
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static const AVFilterPad signalstats_inputs[]
static const struct @235 filters_def[]
static void burn_frame8(const SignalstatsContext *s, AVFrame *f, int x, int y)
static int filter_frame(AVFilterLink *link, AVFrame *in)
AVFilter ff_vf_signalstats
int format
agreed upon media format
#define AV_PIX_FMT_YUV422P12
static av_const double hypot(double x, double y)
#define AV_PIX_FMT_YUV444P12
static const AVFilterPad signalstats_outputs[]
AVFilterContext * src
source filter
static int compute_sat_hue_metrics8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
int(* process8)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int w
agreed upon image width
#define av_malloc_array(a, b)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
static int config_output(AVFilterLink *outlink)
Used for passing data between threads.
int(* process16)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
static const int8_t filt[NUMTAPS *2]
const char * name
Pad name.
#define AV_PIX_FMT_YUV444P9
enum AVPixelFormat pixfmt
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define AV_PIX_FMT_YUV420P12
static int filter16_brng(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_YUV422P14
int h
agreed upon image height
static const AVOption signalstats_options[]
static int filter8_vrep(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int query_formats(AVFilterContext *ctx)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int filter16_vrep(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV444P14
static unsigned compute_bit_depth(uint16_t mask)
#define AV_PIX_FMT_YUV420P14