History

avfilter/buffersrc: limit link variance logs below debug loglevel

The video param change check will print loglines below debug level for each frame which is different from the inlink parameters. This can spam the console. It is now printed at warning level once for each param change else it is kept at debug level. Partially addresses #10823

Gyan Doshi committed 2 years ago

Commit 94422871 parent fa469541 file · +27 −13Browse files

Unified · Split

libavfilter/buffersrc.c+27−13
@@ -49,10 +49,10 @@ typedef struct BufferSourceContext { · 48 unmodified lines
4949 unsigned nb_failed_requests;
5050
5151 /* video only */
52− int w, h;
53− enum AVPixelFormat pix_fmt;
54− enum AVColorSpace color_space;
55− enum AVColorRange color_range;
52+ int w, h, prev_w, prev_h;
53+ enum AVPixelFormat pix_fmt, prev_pix_fmt;
54+ enum AVColorSpace color_space, prev_color_space;
55+ enum AVColorRange color_range, prev_color_range;
5656 AVRational pixel_aspect;
5757
5858 AVBufferRef *hw_frames_ctx;
@@ -66,16 +66,30 @@ typedef struct BufferSourceContext { · 7 unmodified lines
6666
6767 int eof;
6868 int64_t last_pts;
69+ int link_delta, prev_delta;
6970 } BufferSourceContext;
7071
7172 #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format, csp, range, pts)\
72− if (c->w != width || c->h != height || c->pix_fmt != format ||\
73− c->color_space != csp || c->color_range != range) {\
74− av_log(s, AV_LOG_INFO, "filter context - w: %d h: %d fmt: %d csp: %s range: %s, incoming frame - w: %d h: %d fmt: %d csp: %s range: %s pts_time: %s\n",\
73+ c->link_delta = c->w != width || c->h != height || c->pix_fmt != format ||\
74+ c->color_space != csp || c->color_range != range;\
75+ c->prev_delta = c->prev_w != width || c->prev_h != height || c->prev_pix_fmt != format ||\
76+ c->prev_color_space != csp || c->prev_color_range != range;\
77+ if (c->link_delta) {\
78+ int loglevel = c->prev_delta ? AV_LOG_WARNING : AV_LOG_DEBUG;\
79+ av_log(s, loglevel, "Changing video frame properties on the fly is not supported by all filters.\n");\
80+ av_log(s, loglevel, "filter context - w: %d h: %d fmt: %d csp: %s range: %s, incoming frame - w: %d h: %d fmt: %d csp: %s range: %s pts_time: %s\n",\
7581 c->w, c->h, c->pix_fmt, av_color_space_name(c->color_space), av_color_range_name(c->color_range),\
7682 width, height, format, av_color_space_name(csp), av_color_range_name(range),\
7783 av_ts2timestr(pts, &s->outputs[0]->time_base));\
78− av_log(s, AV_LOG_WARNING, "Changing video frame properties on the fly is not supported by all filters.\n");\
84+ }\
85+ if (c->prev_delta) {\
86+ if (!c->link_delta)\
87+ av_log(s, AV_LOG_VERBOSE, "video frame properties congruent with link at pts_time: %s\n", av_ts2timestr(pts, &s->outputs[0]->time_base));\
88+ c->prev_w = width;\
89+ c->prev_h = height;\
90+ c->prev_pix_fmt = format;\
91+ c->prev_color_space = csp;\
92+ c->prev_color_range = range;\
7993 }
8094
8195 #define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, layout, format, pts)\
@@ -111,12 +125,12 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par · 29 unmodified lines
111125 switch (ctx->filter->outputs[0].type) {
112126 case AVMEDIA_TYPE_VIDEO:
113127 if (param->format != AV_PIX_FMT_NONE) {
114− s->pix_fmt = param->format;
128+ s->pix_fmt = s->prev_pix_fmt = param->format;
115129 }
116130 if (param->width > 0)
117− s->w = param->width;
131+ s->w = s->prev_w = param->width;
118132 if (param->height > 0)
119− s->h = param->height;
133+ s->h = s->prev_h = param->height;
120134 if (param->sample_aspect_ratio.num > 0 && param->sample_aspect_ratio.den > 0)
121135 s->pixel_aspect = param->sample_aspect_ratio;
122136 if (param->frame_rate.num > 0 && param->frame_rate.den > 0)
@@ -128,9 +142,9 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par · 5 unmodified lines
128142 return AVERROR(ENOMEM);
129143 }
130144 if (param->color_space != AVCOL_SPC_UNSPECIFIED)
131− s->color_space = param->color_space;
145+ s->color_space = s->prev_color_space = param->color_space;
132146 if (param->color_range != AVCOL_RANGE_UNSPECIFIED)
133− s->color_range = param->color_range;
147+ s->color_range = s->prev_color_range = param->color_range;
134148 break;
135149 case AVMEDIA_TYPE_AUDIO:
136150 if (param->format != AV_SAMPLE_FMT_NONE) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t