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

Michael Niedermayer michaelni
Wed May 30 15:59:01 CEST 2007


Hi

On Tue, May 29, 2007 at 06:01:47PM +0200, Stefano Sabatini wrote:
> On date Tuesday 2007-05-29 14:21:36 +0200, Michael Niedermayer encoded:
> > [...]
> > > > > 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
> [...] 
> 
> > > 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
> 
> OK.
> 
> > > 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
> 
> Applied your suggestion, now the output looks like this:
> 
> 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 29 2007 17:38:48, gcc: 4.1.2 20061028 (prerelease) (Debian 4.1.1-19)
> name       nb_channels depth is_alpha
> yuv420p         3         8      n
> yuyv422         1         8      n
> rgb24           3         8      n
> bgr24           3         8      n
> yuv422p         3         8      n
> yuv444p         3         8      n
> rgb32           4         8      y
> yuv410p         3         8      n
> yuv411p         3         8      n
> rgb565          3         5      n
> ...
> nv12            2         8      n   
> nv12            2         8      n   
> rgb32_1         4         8      y   
> bgr32_1         4         8      y   
> gray16be        1        16      n   
> gray16le        1        16      n   
> 
> > 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
> 
> Fixed.

patch looks ok

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- 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/20070530/3ee80d7e/attachment.pgp>



More information about the ffmpeg-devel mailing list