[FFmpeg-devel] [PATCH 1/8] avutil/pixdesc: add av_pix_fmt_total_count and av_sample_fmt_total_count

Zhao Zhili quinkblack at foxmail.com
Thu Jan 2 18:17:40 EET 2020


Ping for review, thanks! I'm planning to use these API in ff_all_formats() if the patch is acceptable.

> On Dec 30, 2019, at 9:54 PM, quinkblack at foxmail.com wrote:
> 
> From: Zhao Zhili <zhilizhao at tencent.com>
> 
> ---
> doc/APIchanges        | 3 +++
> libavutil/pixdesc.c   | 5 +++++
> libavutil/pixdesc.h   | 5 +++++
> libavutil/pixfmt.h    | 2 +-
> libavutil/samplefmt.c | 5 +++++
> libavutil/samplefmt.h | 7 ++++++-
> libavutil/version.h   | 2 +-
> 7 files changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 3c24dc6fbc..af2fc78fb9 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2017-10-21
> 
> API changes, most recent first:
> 
> +2019-12-28 - xxxxxxxxxx - lavu 56.39.100 - pixdesc.h
> +  Add av_pix_fmt_total_count() and av_sample_fmt_total_count().
> +
> 2019-12-27 - xxxxxxxxxx - lavu 56.38.100 - eval.h
>   Add av_expr_count_func().
> 
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index 05dd4a1e20..a6f145714e 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -2519,6 +2519,11 @@ char *av_get_pix_fmt_string(char *buf, int buf_size,
>     return buf;
> }
> 
> +int av_pix_fmt_total_count()
> +{
> +    return AV_PIX_FMT_NB;
> +}
> +
> const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
> {
>     if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
> diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
> index c055810ae8..8ed12a67f7 100644
> --- a/libavutil/pixdesc.h
> +++ b/libavutil/pixdesc.h
> @@ -204,6 +204,11 @@ int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
>  */
> int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
> 
> +/**
> + * @return the number of all pixel formats
> + */
> +int av_pix_fmt_total_count(void);
> +
> /**
>  * @return a pixel format descriptor for provided pixel format or NULL if
>  * this pixel format is unknown.
> diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> index 37ecebd501..aaf9602c3e 100644
> --- a/libavutil/pixfmt.h
> +++ b/libavutil/pixfmt.h
> @@ -348,7 +348,7 @@ enum AVPixelFormat {
>     AV_PIX_FMT_NV24,      ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
>     AV_PIX_FMT_NV42,      ///< as above, but U and V bytes are swapped
> 
> -    AV_PIX_FMT_NB         ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
> +    AV_PIX_FMT_NB         ///< number of pixel formats, it's for libavutil internal use. For public access use av_pix_fmt_total_count() instead.
> };
> 
> #if AV_HAVE_BIGENDIAN
> diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
> index fc077f6444..6241523e5d 100644
> --- a/libavutil/samplefmt.c
> +++ b/libavutil/samplefmt.c
> @@ -46,6 +46,11 @@ static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = {
>     [AV_SAMPLE_FMT_DBLP] = { .name = "dblp", .bits = 64, .planar = 1, .altform = AV_SAMPLE_FMT_DBL  },
> };
> 
> +int av_sample_fmt_total_count()
> +{
> +    return AV_SAMPLE_FMT_NB;
> +}
> +
> const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
> {
>     if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
> diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h
> index 8cd43ae856..3173d02e5e 100644
> --- a/libavutil/samplefmt.h
> +++ b/libavutil/samplefmt.h
> @@ -71,9 +71,14 @@ enum AVSampleFormat {
>     AV_SAMPLE_FMT_S64,         ///< signed 64 bits
>     AV_SAMPLE_FMT_S64P,        ///< signed 64 bits, planar
> 
> -    AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
> +    AV_SAMPLE_FMT_NB           ///< Number of sample formats, it's for libavutil internal use. For public access use av_sample_fmt_total_count() instead.
> };
> 
> +/**
> + * @return the number of all sample formats
> + */
> +int av_sample_fmt_total_count(void);
> +
> /**
>  * Return the name of sample_fmt, or NULL if sample_fmt is not
>  * recognized.
> diff --git a/libavutil/version.h b/libavutil/version.h
> index af8f614aff..2bc1b98615 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>  */
> 
> #define LIBAVUTIL_VERSION_MAJOR  56
> -#define LIBAVUTIL_VERSION_MINOR  38
> +#define LIBAVUTIL_VERSION_MINOR  39
> #define LIBAVUTIL_VERSION_MICRO 100
> 
> #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> -- 
> 2.22.0
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".





More information about the ffmpeg-devel mailing list