[FFmpeg-devel] [PATCH] List supported pixel formats

Michael Niedermayer michaelni
Tue May 29 14:21:36 CEST 2007


Hi

On Tue, May 29, 2007 at 11:09:16AM +0200, Stefano Sabatini wrote:
> On date Monday 2007-05-28 01:08:13 +0200, Michael Niedermayer encoded:
> > Hi
> > 
> > On Sat, May 26, 2007 at 03:36:49PM +0200, Stefano Sabatini wrote:
> > > Hi.
> > > 
> > > On date Friday 2007-05-25 19:45:43 +0200, Michael Niedermayer encoded:
> > > > Hi
> > > > 
> > > > On Fri, May 25, 2007 at 05:46:35PM +0200, Stefano Sabatini wrote:
> > > > > Hi dear ffmpeg developers.
> > > > > 
> > > > > This patch is based on a patch recently posted by Panagiotis (see
> > > > > "List compiled in codecs"), and applies the same functionality and
> > > > > interface to -pix_fmt.
> > > > > 
> > > > > In order to get ffmpeg able to list the pixel formats the patch does what follows:
> > > > > 
> > > > > * move the PixFmtInfo structure definition from
> > > > >   libavcodec/imgconvert.c to libavcodec/avcodec.h
> > > > > 
> > > > > * declare as extern in avcodec.h the structure pix_fmt_info containing
> > > > >   all the pixel formats infos.
> > > > 
> > > > rejected this struct array is unfit to be exported like that
> > > > adding a field to the struct would break compatibility ...
> > > 
> > > Got it.
> > > 
> > > What about to define a list_pix_fmts() function in
> > > libavcodec/imgconvert.c and export its interface in
> > > libavcodec/avcodec.h?
> > 
> > hmm, maybe outputing a string similar to avcodec_string() would
> > be more flexible ...
> 
> The following patch creates a new function in libavcodec/imgconvert.c: 
> avcodec_pix_fmt_string (buf, buf_size, pix_fmt)
> 
> modeled after avcodec_string(...), and exported in
> libavcodec/avcodec.h.
> 
> The resulting (admittedly rather ugly) ffmpeg -pix_fmt list output is:
> 
> sds at santefisi:~/src/ffmpeg-snapshot$ ./ffmpeg -pix_fmt list
> FFmpeg version SVN-r9143, Copyright (c) 2000-2007 Fabrice Bellard, et al.
>   configuration: --prefix=/home/sds --mandir=/home/sds/share/man --enable-gpl --enable-swscaler --enable-pp
>   libavutil version: 49.4.0
>   libavcodec version: 51.40.4
>   libavformat version: 51.12.1
>   built on May 28 2007 18:12:02, gcc: 4.1.2 20061028 (prerelease) (Debian 4.1.1-19)
> name=     yuv420p, nb_channels=   3, depth=   8, is_alpha=n
> name=     yuyv422, nb_channels=   1, depth=   8, is_alpha=n
> name=       rgb24, nb_channels=   3, depth=   8, is_alpha=n
> name=       bgr24, nb_channels=   3, depth=   8, is_alpha=n
> name=     yuv422p, nb_channels=   3, depth=   8, is_alpha=n
> name=     yuv444p, nb_channels=   3, depth=   8, is_alpha=n
> name=       rgb32, nb_channels=   4, depth=   8, is_alpha=y
> name=     yuv410p, nb_channels=   3, depth=   8, is_alpha=n
> name=     yuv411p, nb_channels=   3, depth=   8, is_alpha=n
> name=      rgb565, nb_channels=   3, depth=   5, is_alpha=n
> name=      rgb555, nb_channels=   3, depth=   5, is_alpha=n
> name=        gray, nb_channels=   1, depth=   8, is_alpha=n
> name=       monow, nb_channels=   1, depth=   1, is_alpha=n
> name=       monob, nb_channels=   1, depth=   1, is_alpha=n
> name=        pal8, nb_channels=   4, depth=   8, is_alpha=y
> name=    yuvj420p, nb_channels=   3, depth=   8, is_alpha=n
> name=    yuvj422p, nb_channels=   3, depth=   8, is_alpha=n
> name=    yuvj444p, nb_channels=   3, depth=   8, is_alpha=n
> name=      xvmcmc, nb_channels=   0, depth=   0, is_alpha=n
> name=    xvmcidct, nb_channels=   0, depth=   0, is_alpha=n
> name=     uyvy422, nb_channels=   1, depth=   8, is_alpha=n
> name=   uyyvyy411, nb_channels=   1, depth=   8, is_alpha=n
> name=       bgr32, nb_channels=   4, depth=   8, is_alpha=y
> name=      bgr565, nb_channels=   3, depth=   5, is_alpha=n
> name=      bgr555, nb_channels=   3, depth=   5, is_alpha=n
> name=        bgr8, nb_channels=   1, depth=   8, is_alpha=n
> name=        bgr4, nb_channels=   1, depth=   4, is_alpha=n
> name=   bgr4_byte, nb_channels=   1, depth=   8, is_alpha=n
> name=        rgb8, nb_channels=   1, depth=   8, is_alpha=n
> name=        rgb4, nb_channels=   1, depth=   4, is_alpha=n
> name=   rgb4_byte, nb_channels=   1, depth=   8, is_alpha=n
> name=        nv12, nb_channels=   2, depth=   8, is_alpha=n
> name=        nv12, nb_channels=   2, depth=   8, is_alpha=n
> name=     rgb32_1, nb_channels=   4, depth=   8, is_alpha=y
> name=     bgr32_1, nb_channels=   4, depth=   8, is_alpha=y
> name=    gray16be, nb_channels=   1, depth=  16, is_alpha=n
> name=    gray16le, nb_channels=   1, depth=  16, is_alpha=n
> 
> The corresponding format is defined in avcodec_pix_fmt_string as follows:
> snprintf (buf, buf_size,
>          "name=%12s, nb_channels=%4d, depth=%4d, is_alpha=%c",
>          info.name,
>          info.nb_channels,
>          info.depth,
>          is_alpha_char
>     );
> 
> I'd like to add a similiar functionality for other options as well
> (namely: sizes, sws_flags, protocols, codecs) so this format should
> result somehow compatible with the other ones. 

sws_flags can and should be printed via AVOption


> 
> Any idea for improving this format?

avcodec_pix_fmt_string (,, -1)
could return a header liks
"name       nb_channels depth   is_alpha"
so the otput would woud look like:

name       nb_channels depth   is_alpha
rgb4_byte       1        8         n
nv12            2        8         n
nv12            2        8         n
rgb32_1         4        8         y

further improvement can be done when we have a more generic pix format
descriptor ...

[...]

> Index: libavcodec/imgconvert.c
> ===================================================================
> --- libavcodec/imgconvert.c	(revision 9143)
> +++ libavcodec/imgconvert.c	(working copy)
> @@ -382,6 +382,21 @@
>      return i;
>  }
>  
> +void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt)
> +{
> +    PixFmtInfo info= pix_fmt_info[pix_fmt];
> +    

trailing whitespace

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070529/8a7a8bc8/attachment.pgp>



More information about the ffmpeg-devel mailing list