Revision 0469baf1 libavcodec/imgconvert.c

View differences:

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 \

Also available in: Unified diff