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
62 uint64_t channel_layout;62 uint64_t channel_layout;
63 char *channel_layout_str;63 char *channel_layout_str;
64 64
65 int got_format_from_params;
66 int eof;65 int eof;
67} BufferSourceContext;66} BufferSourceContext;
68 67
@@ -104,7 +103,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par · 35 unmodified lines
104 switch (ctx->filter->outputs[0].type) {103 switch (ctx->filter->outputs[0].type) {
105 case AVMEDIA_TYPE_VIDEO:104 case AVMEDIA_TYPE_VIDEO:
106 if (param->format != AV_PIX_FMT_NONE) {105 if (param->format != AV_PIX_FMT_NONE) {
107 s->got_format_from_params = 1;
108 s->pix_fmt = param->format;106 s->pix_fmt = param->format;
109 }107 }
110 if (param->width > 0)108 if (param->width > 0)
@@ -124,7 +122,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par · 13 unmodified lines
124 break;122 break;
125 case AVMEDIA_TYPE_AUDIO:123 case AVMEDIA_TYPE_AUDIO:
126 if (param->format != AV_SAMPLE_FMT_NONE) {124 if (param->format != AV_SAMPLE_FMT_NONE) {
127 s->got_format_from_params = 1;
128 s->sample_fmt = param->format;125 s->sample_fmt = param->format;
129 }126 }
130 if (param->sample_rate > 0)127 if (param->sample_rate > 0)
@@ -268,7 +265,7 @@ static av_cold int init_video(AVFilterContext *ctx) · 137 unmodified lines
268{265{
269 BufferSourceContext *c = ctx->priv;266 BufferSourceContext *c = ctx->priv;
270 267
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 ||
272 av_q2d(c->time_base) <= 0) {269 av_q2d(c->time_base) <= 0) {
273 av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n");270 av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n");
274 return AVERROR(EINVAL);271 return AVERROR(EINVAL);
@@ -321,7 +318,7 @@ static av_cold int init_audio(AVFilterContext *ctx) · 46 unmodified lines
321 BufferSourceContext *s = ctx->priv;318 BufferSourceContext *s = ctx->priv;
322 int ret = 0;319 int ret = 0;
323 320
324 if (!(s->sample_fmt != AV_SAMPLE_FMT_NONE || s->got_format_from_params)) {321 if (s->sample_fmt == AV_SAMPLE_FMT_NONE) {
325 av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was invalid\n");322 av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was invalid\n");
326 return AVERROR(EINVAL);323 return AVERROR(EINVAL);
327 }324 }

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