Revision 0469baf1

View differences:

libavcodec/avcodec.h
15 15

  
16 16
#define LIBAVCODEC_VERSION_INT 0x000406
17 17
#define LIBAVCODEC_VERSION     "0.4.6"
18
#define LIBAVCODEC_BUILD       4665
19
#define LIBAVCODEC_BUILD_STR   "4665"
18
#define LIBAVCODEC_BUILD       4666
19
#define LIBAVCODEC_BUILD_STR   "4666"
20 20

  
21 21
#define LIBAVCODEC_IDENT	"FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
22 22

  
......
1276 1276
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1277 1277
                              int has_alpha, int *loss_ptr);
1278 1278

  
1279
#define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
1280
#define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
1281
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1282

  
1279 1283
/* convert among pixel formats */
1280 1284
int img_convert(AVPicture *dst, int dst_pix_fmt,
1281 1285
                AVPicture *src, int pix_fmt, 
libavcodec/imgconvert.c
475 475
    }
476 476
}
477 477

  
478
/* copy image 'src' to 'dst' */
478
/**
479
 * Copy image 'src' to 'dst'.
480
 */
479 481
void img_copy(AVPicture *dst, AVPicture *src,
480 482
              int pix_fmt, int width, int height)
481 483
{
......
1808 1810
    return ret;
1809 1811
}
1810 1812

  
1813
/* NOTE: we scan all the pixels to have an exact information */
1814
static int get_alpha_info_pal8(AVPicture *src, int width, int height)
1815
{
1816
    const unsigned char *p;
1817
    int src_wrap, ret, x, y;
1818
    unsigned int a;
1819
    uint32_t *palette = (uint32_t *)src->data[1];
1820
    
1821
    p = src->data[0];
1822
    src_wrap = src->linesize[0] - width;
1823
    ret = 0;
1824
    for(y=0;y<height;y++) {
1825
        for(x=0;x<width;x++) {
1826
            a = palette[p[0]] >> 24;
1827
            if (a == 0x00) {
1828
                ret |= FF_ALPHA_TRANSP;
1829
            } else if (a != 0xff) {
1830
                ret |= FF_ALPHA_SEMI_TRANSP;
1831
            }
1832
            p++;
1833
        }
1834
        p += src_wrap;
1835
    }
1836
    return ret;
1837
}
1838

  
1839
/**
1840
 * Tell if an image really has transparent alpha values.
1841
 * @return ored mask of FF_ALPHA_xxx constants
1842
 */
1843
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height)
1844
{
1845
    PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
1846
    int ret;
1847

  
1848
    pf = &pix_fmt_info[pix_fmt];
1849
    /* no alpha can be represented in format */
1850
    if (!pf->is_alpha)
1851
        return 0;
1852
    switch(pix_fmt) {
1853
    case PIX_FMT_RGBA32:
1854
        ret = get_alpha_info_rgba32(src, width, height);
1855
        break;
1856
    case PIX_FMT_RGB555:
1857
        ret = get_alpha_info_rgb555(src, width, height);
1858
        break;
1859
    case PIX_FMT_PAL8:
1860
        ret = get_alpha_info_pal8(src, width, height);
1861
        break;
1862
    default:
1863
        /* we do not know, so everything is indicated */
1864
        ret = FF_ALPHA_TRANSP | FF_ALPHA_SEMI_TRANSP;
1865
        break;
1866
    }
1867
    return ret;
1868
}
1811 1869

  
1812 1870
#ifdef HAVE_MMX
1813 1871
#define DEINT_INPLACE_LINE_LUM \
libavcodec/imgconvert_template.h
814 814

  
815 815
#endif /* defined(FMT_RGB24) || defined(FMT_RGBA32) */
816 816
        
817
#ifdef RGBA_IN
818

  
819
static int glue(get_alpha_info_, RGB_NAME)(AVPicture *src, int width, int height)
820
{
821
    const unsigned char *p;
822
    int src_wrap, ret, x, y;
823
    unsigned int r, g, b, a;
824

  
825
    p = src->data[0];
826
    src_wrap = src->linesize[0] - BPP * width;
827
    ret = 0;
828
    for(y=0;y<height;y++) {
829
        for(x=0;x<width;x++) {
830
            RGBA_IN(r, g, b, a, p);
831
            if (a == 0x00) {
832
                ret |= FF_ALPHA_TRANSP;
833
            } else if (a != 0xff) {
834
                ret |= FF_ALPHA_SEMI_TRANSP;
835
            }
836
            p += BPP;
837
        }
838
        p += src_wrap;
839
    }
840
    return ret;
841
}
842

  
843
#endif /* RGBA_IN */
844

  
817 845
#undef RGB_IN
818 846
#undef RGBA_IN
819 847
#undef RGB_OUT

Also available in: Unified diff