Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Fei Wang <fei.w.wang@intel.com>, Linjie Fu <linjie.fu@intel.com>
Subject: Re: [FFmpeg-devel] [PATCH v1 1/3] lavc/decode: Add get_hw_config function
Date: Tue, 16 Aug 2022 13:22:37 +0200
Message-ID: <166064895716.3205.18227206247708899551@lain.khirnov.net> (raw)
In-Reply-To: <20220812125545.1229410-1-fei.w.wang@intel.com>

The commit message is misleading - you are not adding code, you are
moving code.

Quoting Fei Wang (2022-08-12 14:55:43)
> From: Linjie Fu <linjie.fu@intel.com>
> 
> Wrap the procedure of getting the hardware config from a pixel format
> into a function.
> 
> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>  libavcodec/decode.c | 33 +++++++++++++++++++++------------
>  1 file changed, 21 insertions(+), 12 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 75373989c6..d66d5a4160 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1156,6 +1156,26 @@ static void hwaccel_uninit(AVCodecContext *avctx)
>      av_buffer_unref(&avctx->hw_frames_ctx);
>  }
>  
> +static const AVCodecHWConfigInternal *get_hw_config(AVCodecContext *avctx, enum AVPixelFormat fmt)
> +{
> +    const AVCodecHWConfigInternal *hw_config;
> +    int i;

Should be declared in the loop

> +    if (ffcodec(avctx->codec)->hw_configs) {
> +        for (i = 0;; i++) {
> +            hw_config = ffcodec(avctx->codec)->hw_configs[i];
> +            if (!hw_config)
> +                break;

return NULL;

> +            if (hw_config->public.pix_fmt == fmt)
> +                break;

return hw_config;

> +        }
> +    } else {
> +        hw_config = NULL;
> +    }

You can save one level of indentation by starting with

if (!ffcodec(avctx->codec)->hw_configs)
    return NULL;

-- 
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

  parent reply	other threads:[~2022-08-16 11:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 12:55 Fei Wang
2022-08-12 12:55 ` [FFmpeg-devel] [PATCH v1 2/3] lavc/decode: Add internal surface re-allocate method for hwaccel Fei Wang
2022-08-16 11:26   ` Anton Khirnov
2022-08-12 12:55 ` [FFmpeg-devel] [PATCH v1 3/3] lavc/vaapi_vp9: add surface internal re-allocation capability Fei Wang
2022-08-16 11:22 ` Anton Khirnov [this message]
2022-08-18  2:34   ` [FFmpeg-devel] [PATCH v1 1/3] lavc/decode: Add get_hw_config function Wang, Fei W

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=166064895716.3205.18227206247708899551@lain.khirnov.net \
    --to=anton@khirnov.net \
    --cc=fei.w.wang@intel.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=linjie.fu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git