[FFmpeg-devel] [RFC][PATCH 1/2] pixdesc: add av_find_pix_fmt()

Michael Niedermayer michaelni at gmx.at
Tue Mar 27 00:24:13 CEST 2012


On Mon, Mar 26, 2012 at 10:04:26PM +0000, Paul B Mahol wrote:
> On 3/26/12, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Mon, Mar 26, 2012 at 02:42:40AM +0000, Paul B Mahol wrote:
> >>
> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> ---
> >>  libavutil/pixdesc.c |   37 +++++++++++++++++++++++++++++++++++++
> >>  libavutil/pixdesc.h |    8 ++++++++
> >>  2 files changed, 45 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> >> index 233b217..83f256b 100644
> >> --- a/libavutil/pixdesc.c
> >> +++ b/libavutil/pixdesc.c
> >> @@ -1272,3 +1272,40 @@ char *av_get_pix_fmt_string (char *buf, int
> >> buf_size, enum PixelFormat pix_fmt)
> >>
> >>      return buf;
> >>  }
> >> +
> >> +enum PixelFormat av_find_pix_fmt(const AVPixFmtDescriptor *pixdesc, int
> >> flags)
> >> +{
> >> +    enum PixelFormat pix_fmt;
> >> +    int i;
> >> +
> >> +    for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) {
> >> +        const AVPixFmtDescriptor *c = &av_pix_fmt_descriptors[pix_fmt];
> >> +
> >> +        if ((c->flags         != pixdesc->flags)         ||
> >> +            (c->nb_components != pixdesc->nb_components) ||
> >> +            (c->log2_chroma_w != pixdesc->log2_chroma_w) ||
> >> +            (c->log2_chroma_h != pixdesc->log2_chroma_h))
> >> +            continue;
> >> +        for (i = 0; i < pixdesc->nb_components; i++) {
> >> +            if (flags &  1)
> >> +                if (c->comp[i].plane != pixdesc->comp[i].plane)
> >> +                    break;
> >> +            if (flags &  2)
> >> +                if (c->comp[i].step_minus1 !=
> >> pixdesc->comp[i].step_minus1)
> >> +                    break;
> >> +            if (flags &  4)
> >> +                if (c->comp[i].offset_plus1 !=
> >> pixdesc->comp[i].offset_plus1)
> >> +                    break;
> >> +            if (flags &  8)
> >> +                if (c->comp[i].shift != pixdesc->comp[i].shift)
> >> +                    break;
> >> +            if (flags & 16)
> >> +                if (c->comp[i].depth_minus1 !=
> >> pixdesc->comp[i].depth_minus1)
> >> +                    break;
> >
> > an alternative to the flags would be to pass a second
> > AVPixFmtDescriptor that sets all parts that are to be compared to "-1"
> 
> You can't do that, parameters in comp are unsigned
> and they are less than 8 bits in size.

i meant with "-1" all bits of the field set

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120327/8931e2b3/attachment.asc>


More information about the ffmpeg-devel mailing list