[FFmpeg-devel] [PATCH v3] ffprobe: Add bits_per_component to stream output
wm4
nfxjfg at googlemail.com
Thu Sep 4 17:39:26 CEST 2014
On Thu, 04 Sep 2014 16:31:45 +0200
Tobias Rapp <t.rapp at noa-audio.com> wrote:
> From 4a2290540ae0761c6ea2a5f12326ad8dd1257e57 Mon Sep 17 00:00:00 2001
> From: Tobias Rapp <t.rapp at noa-audio.com>
> Date: Thu, 4 Sep 2014 16:25:22 +0200
> Subject: [PATCH] ffprobe: Add bits_per_component to stream output
>
> Adds bits_per_component (bit depth) output for video streams.
> ---
> doc/ffprobe.xsd | 1 +
> ffprobe.c | 6 ++++++
> libavutil/pixdesc.c | 15 +++++++++++++++
> libavutil/pixdesc.h | 7 +++++++
> tests/ref/fate/ffprobe_compact | 4 ++--
> tests/ref/fate/ffprobe_csv | 4 ++--
> tests/ref/fate/ffprobe_default | 2 ++
> tests/ref/fate/ffprobe_flat | 2 ++
> tests/ref/fate/ffprobe_ini | 2 ++
> tests/ref/fate/ffprobe_json | 2 ++
> tests/ref/fate/ffprobe_xml | 4 ++--
> 11 files changed, 43 insertions(+), 6 deletions(-)
>
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index 154392a..1dfcf0f 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -1980,6 +1980,21 @@ int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
> return bits >> log2_pixels;
> }
>
> +int av_get_bits_per_component(const AVPixFmtDescriptor *pixdesc)
> +{
> + int c, bits, first_bits = 0;
> +
> + for (c = 0; c < pixdesc->nb_components; c++) {
> + bits = pixdesc->comp[c].depth_minus1 + 1;
> + if (c == 0)
> + first_bits = bits;
> + else if (bits != first_bits)
> + return 0;
> + }
> +
> + return first_bits;
> +}
> +
> char *av_get_pix_fmt_string(char *buf, int buf_size,
> enum AVPixelFormat pix_fmt)
> {
> diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
> index 41e81db..f8af18f 100644
> --- a/libavutil/pixdesc.h
> +++ b/libavutil/pixdesc.h
> @@ -251,6 +251,13 @@ int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
> int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
>
> /**
> + * Return the number of bits per component (bit depth) for the pixel format
> + * described by pixdesc or 0 if the pixel format has unknown or non-uniform
> + * bit depth.
> + */
> +int av_get_bits_per_component(const AVPixFmtDescriptor *pixdesc);
> +
> +/**
> * @return a pixel format descriptor for provided pixel format or NULL if
> * this pixel format is unknown.
> */
Does something such highly specialized really warrant its own API
function? There are several ways how to handle the case if the
component bit depths are not uniform, or even how the term "bit depth"
is to be interpreted, so IMO this should just be internal to ffprobe.
More information about the ffmpeg-devel
mailing list