Revision 80a07f6e libavutil/pixdesc.c

View differences:

libavutil/pixdesc.c
654 654
    },
655 655
};
656 656

  
657
static enum PixelFormat get_pix_fmt_internal(const char *name)
658
{
659
    enum PixelFormat pix_fmt;
660

  
661
    for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
662
        if (av_pix_fmt_descriptors[pix_fmt].name &&
663
            !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
664
            return pix_fmt;
665

  
666
    return PIX_FMT_NONE;
667
}
668

  
669
#if HAVE_BIGENDIAN
670
#   define X_NE(be, le) be
671
#else
672
#   define X_NE(be, le) le
673
#endif
674

  
675
enum PixelFormat av_get_pix_fmt(const char *name)
676
{
677
    enum PixelFormat pix_fmt;
678

  
679
    if (!strcmp(name, "rgb32"))
680
        name = X_NE("argb", "bgra");
681
    else if (!strcmp(name, "bgr32"))
682
        name = X_NE("abgr", "rgba");
683

  
684
    pix_fmt = get_pix_fmt_internal(name);
685
    if (pix_fmt == PIX_FMT_NONE) {
686
        char name2[32];
687

  
688
        snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
689
        pix_fmt = get_pix_fmt_internal(name2);
690
    }
691
    return pix_fmt;
692
}
693

  
657 694
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
658 695
{
659 696
    int c, bits = 0;

Also available in: Unified diff