41 #if HAVE_MMX && HAVE_YASM
45 #define FF_COLOR_RGB 0
46 #define FF_COLOR_GRAY 1
47 #define FF_COLOR_YUV 2
48 #define FF_COLOR_YUV_JPEG 3
50 #define FF_PIXEL_PLANAR 0
51 #define FF_PIXEL_PACKED 1
52 #define FF_PIXEL_PALETTE 2
54 #if HAVE_MMX && HAVE_YASM
55 #define deinterlace_line_inplace ff_deinterlace_line_inplace_mmx
56 #define deinterlace_line ff_deinterlace_line_mmx
58 #define deinterlace_line_inplace deinterlace_line_inplace_c
59 #define deinterlace_line deinterlace_line_c
207 .nb_channels = 4, .is_alpha = 1,
295 .nb_channels = 4, .is_alpha = 1,
307 .nb_channels = 4, .is_alpha = 1,
398 .nb_channels = 4, .is_alpha = 1,
404 .nb_channels = 4, .is_alpha = 1,
417 #if FF_API_GET_PIX_FMT_NAME
444 unsigned char *dest,
int dest_size)
446 int i, j, nb_planes = 0, linesizes[4];
450 if (size > dest_size || size < 0)
458 for (i = 0; i < nb_planes; i++) {
460 const unsigned char *s = src->
data[i];
461 h = (height + (1 << shift) - 1) >> shift;
463 for (j = 0; j < h; j++) {
464 memcpy(dest, s, linesizes[i]);
465 dest += linesizes[i];
471 memcpy((
unsigned char *)(((
size_t)dest + 3) & ~3), src->
data[1], 256 * 4);
501 ps = &pix_fmt_info[src_pix_fmt];
505 pf = &pix_fmt_info[dst_pix_fmt];
609 int dist, i, loss, min_dist;
614 min_dist = 0x7fffffff;
616 for (i = 0; i < 64; i++) {
617 if (pix_fmt_mask & (1ULL << i)) {
621 if (dist < min_dist) {
632 int has_alpha,
int *loss_ptr)
636 static const int loss_mask_order[] = {
649 loss_mask = loss_mask_order[i++];
651 has_alpha, loss_mask);
652 if (dst_pix_fmt >= 0)
668 src->
linesize, pix_fmt, width, height);
673 const uint8_t *src,
int src_wrap,
677 const uint8_t *
s1, *
s2;
680 for(;height > 0; height--) {
684 for(w = width;w >= 4; w-=4) {
685 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
686 d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
687 d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
688 d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
694 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
706 const uint8_t *src,
int src_wrap,
713 for(;height > 0; height--) {
719 for(w = width;w > 0; w--) {
720 d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
721 s2[0] + s2[1] + s2[2] + s2[3] +
722 s3[0] + s3[1] + s3[2] + s3[3] +
723 s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
737 const uint8_t *src,
int src_wrap,
742 for(;height > 0; height--) {
743 for(w = width;w > 0; w--) {
746 tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7];
749 *(dst++) = (tmp + 32)>>6;
750 src += 8 - 8*src_wrap;
752 src += 8*src_wrap - 8*
width;
753 dst += dst_wrap -
width;
797 dst->
data[1] = src->
data[1] + ((top_band >> y_shift) * src->
linesize[1]) + (left_band >> x_shift);
798 dst->
data[2] = src->
data[2] + ((top_band >> y_shift) * src->
linesize[2]) + (left_band >> x_shift);
819 for (i = 0; i < 3; i++) {
823 if (padtop || padleft) {
824 memset(dst->
data[i], color[i],
825 dst->
linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
828 if (padleft || padright) {
829 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
830 (dst->
linesize[i] - (padright >> x_shift));
831 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
832 for (y = 0; y < yheight; y++) {
833 memset(optr, color[i], (padleft + padright) >> x_shift);
839 uint8_t *iptr = src->
data[i];
840 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
841 (padleft >> x_shift);
842 memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
844 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
845 (dst->
linesize[i] - (padright >> x_shift));
846 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
847 for (y = 0; y < yheight; y++) {
848 memset(optr, color[i], (padleft + padright) >> x_shift);
849 memcpy(optr + ((padleft + padright) >> x_shift), iptr,
850 (width - padleft - padright) >> x_shift);
856 if (padbottom || padright) {
858 ((height - padbottom) >> y_shift) - (padright >> x_shift);
859 memset(optr, color[i],dst->
linesize[i] *
860 (padbottom >> y_shift) + (padright >> x_shift));
866 #if FF_API_GET_ALPHA_INFO
870 const unsigned char *p;
871 int src_wrap, ret, x, y;
876 src_wrap = src->
linesize[0] - width;
878 for(y=0;y<height;y++) {
879 for(x=0;x<
width;x++) {
880 a = palette[p[0]] >> 24;
882 ret |= FF_ALPHA_TRANSP;
883 }
else if (a != 0xff) {
884 ret |= FF_ALPHA_SEMI_TRANSP;
893 int img_get_alpha_info(
const AVPicture *src,
904 ret = get_alpha_info_pal8(src, width, height);
908 ret = FF_ALPHA_TRANSP | FF_ALPHA_SEMI_TRANSP;
915 #if !(HAVE_MMX && HAVE_YASM)
918 const uint8_t *lum_m4,
const uint8_t *lum_m3,
919 const uint8_t *lum_m2,
const uint8_t *lum_m1,
926 for(;size > 0;size--) {
928 sum += lum_m3[0] << 2;
929 sum += lum_m2[0] << 1;
930 sum += lum_m1[0] << 2;
932 dst[0] = cm[(sum + 4) >> 3];
943 uint8_t *lum_m2, uint8_t *lum_m1,
944 uint8_t *lum,
int size)
949 for(;size > 0;size--) {
951 sum += lum_m3[0] << 2;
952 sum += lum_m2[0] << 1;
954 sum += lum_m1[0] << 2;
956 lum_m2[0] = cm[(sum + 4) >> 3];
970 const uint8_t *src1,
int src_wrap,
971 int width,
int height)
973 const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
978 src_0=&src_m1[src_wrap];
979 src_p1=&src_0[src_wrap];
980 src_p2=&src_p1[src_wrap];
981 for(y=0;y<(height-2);y+=2) {
982 memcpy(dst,src_m1,width);
988 src_p1 += 2*src_wrap;
989 src_p2 += 2*src_wrap;
992 memcpy(dst,src_m1,width);
999 int width,
int height)
1001 uint8_t *src_m1, *src_0, *src_p1, *src_p2;
1007 memcpy(buf,src_m1,width);
1008 src_0=&src_m1[src_wrap];
1009 src_p1=&src_0[src_wrap];
1010 src_p2=&src_p1[src_wrap];
1011 for(y=0;y<(height-2);y+=2) {
1015 src_p1 += 2*src_wrap;
1016 src_p2 += 2*src_wrap;
1036 if ((width & 3) != 0 || (height & 3) != 0)
uint8_t is_alpha
true if alpha can be specified
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define FF_LOSS_COLORQUANT
loss due to color quantization
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
#define deinterlace_line_inplace
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, enum PixelFormat pix_fmt, int width, int height)
void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift)
static const PixFmtInfo pix_fmt_info[PIX_FMT_NB]
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 ...
int av_picture_crop(AVPicture *dst, const AVPicture *src, enum PixelFormat pix_fmt, int top_band, int left_band)
Crop image top and left side.
#define FF_LOSS_DEPTH
loss due to color depth change
int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt, int has_alpha)
Compute what kind of losses will occur when converting from one specific pixel format to another...
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Various defines for YUV<->RGB conversion.
four components are given, that's all.
static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap, const uint8_t *src1, int src_wrap, int width, int height)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap, int width, int height)
int avpicture_layout(const AVPicture *src, enum PixelFormat pix_fmt, int width, int height, unsigned char *dest, int dest_size)
Copy pixel data from an AVPicture into a buffer.
static void deinterlace_line_c(uint8_t *dst, const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Find the best pixel format to convert to given a certain source pixel format.
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
uint8_t nb_channels
number of channels (including alpha)
#define FF_COLOR_YUV_JPEG
YUV color space.
#define FF_LOSS_ALPHA
loss of alpha bits
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 ...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
uint8_t * data[AV_NUM_DATA_POINTERS]
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4])
Fill plane data pointers for an image with pixel format pix_fmt and height height.
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
uint8_t color_type
color type (see FF_COLOR_xxx constants)
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
void avpicture_free(AVPicture *picture)
Free a picture previously allocated by avpicture_alloc().
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
static int avg_bits_per_pixel(enum PixelFormat pix_fmt)
void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
Y , 16bpp, little-endian.
#define FF_PIXEL_PALETTE
one components containing indexes for a palette
int avpicture_fill(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, int width, int height)
Fill in the AVPicture fields.
static int is_yuv_planar(const PixFmtInfo *ps)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
uint8_t pixel_type
pixel storage type (see FF_PIXEL_xxx constants)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
uint8_t depth
bit depth of the color components
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
#define PIX_FMT_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static av_always_inline void emms_c(void)
Empty mmx state.
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
uint8_t nb_components
The number of components each pixel has, (1-4)
void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum PixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
#define FF_LOSS_CHROMA
loss of chroma (e.g.
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
#define FF_PIXEL_PLANAR
each channel has one component in AVPicture
const char * av_get_pix_fmt_name(enum PixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum PixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
as above, but U and V bytes are swapped
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)
Calculate the size in bytes that a picture of the given width and height would occupy if stored in th...
#define PIX_FMT_HWACCEL
Pixel format is an HW accelerated format.
packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 ...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FF_COLOR_RGB
RGB color space.
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 ...
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
void av_picture_copy(AVPicture *dst, const AVPicture *src, enum PixelFormat pix_fmt, int width, int height)
Copy image src to dst.
packed RGB 8:8:8, 24bpp, BGRBGR...
#define FF_PIXEL_PACKED
only one components containing all the channels
uint16_t plane
which of the 4 planes contains the component
common internal api header.
#define FF_COLOR_GRAY
gray color space
#define FF_LOSS_COLORSPACE
loss due to color space conversion
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
8 bit with PIX_FMT_RGB32 palette
static const uint8_t color[]
packed RGB 8:8:8, 24bpp, RGBRGB...
int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height)
Allocate memory for a picture.
#define FF_COLOR_YUV
YUV color space.
struct PixFmtInfo PixFmtInfo
static enum PixelFormat avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt, int has_alpha, int loss_mask)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt)
Determine whether pix_fmt is a hardware accelerated format.
#define FF_LOSS_RESOLUTION
loss due to resolution change
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright, int *color)
Pad image.
static void deinterlace_line_inplace_c(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum, int size)
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)