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
49 unsigned nb_failed_requests;49 unsigned nb_failed_requests;
50 50
51 /* video only */51 /* video only */
52 int w, h;52 int w, h, prev_w, prev_h;
53 enum AVPixelFormat pix_fmt;53 enum AVPixelFormat pix_fmt, prev_pix_fmt;
54 enum AVColorSpace color_space;54 enum AVColorSpace color_space, prev_color_space;
55 enum AVColorRange color_range;55 enum AVColorRange color_range, prev_color_range;
56 AVRational pixel_aspect;56 AVRational pixel_aspect;
57 57
58 AVBufferRef *hw_frames_ctx;58 AVBufferRef *hw_frames_ctx;
@@ -66,16 +66,30 @@ typedef struct BufferSourceContext { · 7 unmodified lines
66 66
67 int eof;67 int eof;
68 int64_t last_pts;68 int64_t last_pts;
69 int link_delta, prev_delta;
69} BufferSourceContext;70} BufferSourceContext;
70 71
71#define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format, csp, range, pts)\72#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->link_delta = c->w != width || c->h != height || c->pix_fmt != format ||\
73 c->color_space != csp || c->color_range != range) {\74 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",\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",\
75 c->w, c->h, c->pix_fmt, av_color_space_name(c->color_space), av_color_range_name(c->color_range),\81 c->w, c->h, c->pix_fmt, av_color_space_name(c->color_space), av_color_range_name(c->color_range),\
76 width, height, format, av_color_space_name(csp), av_color_range_name(range),\82 width, height, format, av_color_space_name(csp), av_color_range_name(range),\
77 av_ts2timestr(pts, &s->outputs[0]->time_base));\83 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;\
79 }93 }
80 94
81#define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, layout, format, pts)\95#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
111 switch (ctx->filter->outputs[0].type) {125 switch (ctx->filter->outputs[0].type) {
112 case AVMEDIA_TYPE_VIDEO:126 case AVMEDIA_TYPE_VIDEO:
113 if (param->format != AV_PIX_FMT_NONE) {127 if (param->format != AV_PIX_FMT_NONE) {
114 s->pix_fmt = param->format;128 s->pix_fmt = s->prev_pix_fmt = param->format;
115 }129 }
116 if (param->width > 0)130 if (param->width > 0)
117 s->w = param->width;131 s->w = s->prev_w = param->width;
118 if (param->height > 0)132 if (param->height > 0)
119 s->h = param->height;133 s->h = s->prev_h = param->height;
120 if (param->sample_aspect_ratio.num > 0 && param->sample_aspect_ratio.den > 0)134 if (param->sample_aspect_ratio.num > 0 && param->sample_aspect_ratio.den > 0)
121 s->pixel_aspect = param->sample_aspect_ratio;135 s->pixel_aspect = param->sample_aspect_ratio;
122 if (param->frame_rate.num > 0 && param->frame_rate.den > 0)136 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
128 return AVERROR(ENOMEM);142 return AVERROR(ENOMEM);
129 }143 }
130 if (param->color_space != AVCOL_SPC_UNSPECIFIED)144 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;
132 if (param->color_range != AVCOL_RANGE_UNSPECIFIED)146 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;
134 break;148 break;
135 case AVMEDIA_TYPE_AUDIO:149 case AVMEDIA_TYPE_AUDIO:
136 if (param->format != AV_SAMPLE_FMT_NONE) {150 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