History

avfilter/buffersrc: remove redundant flag

!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params) equals (c->pix_fmt == AV_PIX_FMT_NONE) && !c->got_format_from_params 1. When (c->pix_fmt == AV_PIX_FMT_NONE) is true, got_format_from_params is always false, the flag doesn't contribute to the result. 2. When the first part is false, the second part doesn't matter, the flag doesn't contribute to the result. The result only depends on c->pix_fmt.

Zhao Zhili committed 6 years ago

Commit bf082641 parent f0b3b551 file · +2 −5Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/buffersrc.c+2−5
@@ -62,7 +62,6 @@ typedef struct BufferSourceContext { · 61 unmodified lines
6262 uint64_t channel_layout;
6363 char *channel_layout_str;
6464
65− int got_format_from_params;
6665 int eof;
6766 } BufferSourceContext;
6867
@@ -104,7 +103,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par · 35 unmodified lines
104103 switch (ctx->filter->outputs[0].type) {
105104 case AVMEDIA_TYPE_VIDEO:
106105 if (param->format != AV_PIX_FMT_NONE) {
107− s->got_format_from_params = 1;
108106 s->pix_fmt = param->format;
109107 }
110108 if (param->width > 0)
@@ -124,7 +122,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par · 13 unmodified lines
124122 break;
125123 case AVMEDIA_TYPE_AUDIO:
126124 if (param->format != AV_SAMPLE_FMT_NONE) {
127− s->got_format_from_params = 1;
128125 s->sample_fmt = param->format;
129126 }
130127 if (param->sample_rate > 0)
@@ -268,7 +265,7 @@ static av_cold int init_video(AVFilterContext *ctx) · 137 unmodified lines
268265 {
269266 BufferSourceContext *c = ctx->priv;
270267
271− if (!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params) || !c->w || !c->h ||
268+ if (c->pix_fmt == AV_PIX_FMT_NONE || !c->w || !c->h ||
272269 av_q2d(c->time_base) <= 0) {
273270 av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n");
274271 return AVERROR(EINVAL);
@@ -321,7 +318,7 @@ static av_cold int init_audio(AVFilterContext *ctx) · 46 unmodified lines
321318 BufferSourceContext *s = ctx->priv;
322319 int ret = 0;
323320
324− if (!(s->sample_fmt != AV_SAMPLE_FMT_NONE || s->got_format_from_params)) {
321+ if (s->sample_fmt == AV_SAMPLE_FMT_NONE) {
325322 av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was invalid\n");
326323 return AVERROR(EINVAL);
327324 }

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