Re: [FFmpeg-devel] [PATCH] avfilter/buffersrc: remove redundant flag

2019-12-23 Thread Nicolas George
quinkbl...@foxmail.com (12019-12-04):
> From: Zhao Zhili 
> 
> !(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.
> ---
>  libavfilter/buffersrc.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)

Well spotted. Pushed. Thanks.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avfilter/buffersrc: remove redundant flag

2019-12-04 Thread quinkblack
From: Zhao Zhili 

!(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.
---
 libavfilter/buffersrc.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..b7ff40b045 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -63,7 +63,6 @@ typedef struct BufferSourceContext {
 uint64_t channel_layout;
 char*channel_layout_str;
 
-int got_format_from_params;
 int eof;
 } BufferSourceContext;
 
@@ -105,7 +104,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, 
AVBufferSrcParameters *par
 switch (ctx->filter->outputs[0].type) {
 case AVMEDIA_TYPE_VIDEO:
 if (param->format != AV_PIX_FMT_NONE) {
-s->got_format_from_params = 1;
 s->pix_fmt = param->format;
 }
 if (param->width > 0)
@@ -125,7 +123,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, 
AVBufferSrcParameters *par
 break;
 case AVMEDIA_TYPE_AUDIO:
 if (param->format != AV_SAMPLE_FMT_NONE) {
-s->got_format_from_params = 1;
 s->sample_fmt = param->format;
 }
 if (param->sample_rate > 0)
@@ -278,7 +275,7 @@ static av_cold int init_video(AVFilterContext *ctx)
 {
 BufferSourceContext *c = ctx->priv;
 
-if (!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params) || !c->w 
|| !c->h ||
+if (c->pix_fmt == AV_PIX_FMT_NONE || !c->w || !c->h ||
 av_q2d(c->time_base) <= 0) {
 av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n");
 return AVERROR(EINVAL);
@@ -334,7 +331,7 @@ static av_cold int init_audio(AVFilterContext *ctx)
 BufferSourceContext *s = ctx->priv;
 int ret = 0;
 
-if (!(s->sample_fmt != AV_SAMPLE_FMT_NONE || s->got_format_from_params)) {
+if (s->sample_fmt == AV_SAMPLE_FMT_NONE) {
 av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was 
invalid\n");
 return AVERROR(EINVAL);
 }
-- 
2.22.0



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".