38 #include "libavutil/common.h"
39 #include "libavutil/pixdesc.h"
40 #include "libavutil/imgutils.h"
66 if (dst_pix_fmt == src_pix_fmt)
69 for (i = 0; i < nb_components; i++)
99 int dist, i, loss, min_dist;
104 min_dist = 0x7fffffff;
111 "it is either not properly terminated or contains duplicates\n");
118 if (dist < min_dist) {
130 int has_alpha,
int *loss_ptr)
134 static const int loss_mask_order[] = {
147 loss_mask = loss_mask_order[i++];
149 has_alpha, loss_mask);
150 if (dst_pix_fmt >= 0)
164 const uint8_t *src,
int src_wrap,
171 for(;height > 0; height--) {
175 for(w = width;w >= 4; w-=4) {
176 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
177 d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
178 d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
179 d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
185 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
197 const uint8_t *src,
int src_wrap,
201 const uint8_t *s1, *s2, *s3, *s4;
204 for(;height > 0; height--) {
210 for(w = width;w > 0; w--) {
211 d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
212 s2[0] + s2[1] + s2[2] + s2[3] +
213 s3[0] + s3[1] + s3[2] + s3[3] +
214 s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
228 const uint8_t *src,
int src_wrap,
233 for(;height > 0; height--) {
234 for(w = width;w > 0; w--) {
237 tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7];
240 *(dst++) = (tmp + 32)>>6;
241 src += 8 - 8*src_wrap;
243 src += 8*src_wrap - 8*
width;
244 dst += dst_wrap -
width;
269 dst->
data[1] = src->
data[1] + ((top_band >> y_shift) * src->
linesize[1]) + (left_band >> x_shift);
270 dst->
data[2] = src->
data[2] + ((top_band >> y_shift) * src->
linesize[2]) + (left_band >> x_shift);
292 for (i = 0; i < 3; i++) {
296 if (padtop || padleft) {
297 memset(dst->
data[i], color[i],
298 dst->
linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
301 if (padleft || padright) {
302 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
303 (dst->
linesize[i] - (padright >> x_shift));
304 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
305 for (y = 0; y < yheight; y++) {
306 memset(optr, color[i], (padleft + padright) >> x_shift);
313 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
314 (padleft >> x_shift);
315 memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
317 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
318 (dst->
linesize[i] - (padright >> x_shift));
319 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
320 for (y = 0; y < yheight; y++) {
321 memset(optr, color[i], (padleft + padright) >> x_shift);
322 memcpy(optr + ((padleft + padright) >> x_shift), iptr,
323 (width - padleft - padright) >> x_shift);
329 if (padbottom || padright) {
331 ((height - padbottom) >> y_shift) - (padright >> x_shift);
332 memset(optr, color[i],dst->
linesize[i] *
333 (padbottom >> y_shift) + (padright >> x_shift));
339 #if FF_API_DEINTERLACE
341 #if HAVE_MMX_EXTERNAL
342 #define deinterlace_line_inplace ff_deinterlace_line_inplace_mmx
343 #define deinterlace_line ff_deinterlace_line_mmx
345 #define deinterlace_line_inplace deinterlace_line_inplace_c
346 #define deinterlace_line deinterlace_line_c
358 for(;size > 0;size--) {
360 sum += lum_m3[0] << 2;
361 sum += lum_m2[0] << 1;
362 sum += lum_m1[0] << 2;
364 dst[0] = cm[(sum + 4) >> 3];
381 for(;size > 0;size--) {
383 sum += lum_m3[0] << 2;
384 sum += lum_m2[0] << 1;
386 sum += lum_m1[0] << 2;
388 lum_m2[0] = cm[(sum + 4) >> 3];
402 const uint8_t *src1,
int src_wrap,
405 const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
410 src_0=&src_m1[src_wrap];
411 src_p1=&src_0[src_wrap];
412 src_p2=&src_p1[src_wrap];
413 for(y=0;y<(height-2);y+=2) {
414 memcpy(dst,src_m1,width);
420 src_p1 += 2*src_wrap;
421 src_p2 += 2*src_wrap;
424 memcpy(dst,src_m1,width);
433 uint8_t *src_m1, *src_0, *src_p1, *src_p2;
439 memcpy(buf,src_m1,width);
440 src_0=&src_m1[src_wrap];
441 src_p1=&src_0[src_wrap];
442 src_p2=&src_p1[src_wrap];
443 for(y=0;y<(height-2);y+=2) {
447 src_p1 += 2*src_wrap;
448 src_p2 += 2*src_wrap;
468 if ((width & 3) != 0 || (height & 3) != 0)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define deinterlace_line_inplace
#define FF_LOSS_COLORQUANT
loss due to color quantization
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height)
deinterlace - if not supported return -1
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
static int is_yuv_planar(const AVPixFmtDescriptor *desc)
static int is_gray(const AVPixFmtDescriptor *desc)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Various defines for YUV<->RGB conversion.
int av_picture_crop(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int top_band, int left_band)
Crop image top and left side.
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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 avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, int has_alpha)
Compute what kind of losses will occur when converting from one specific pixel format to another...
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)
uint8_t * data[AV_NUM_DATA_POINTERS]
void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
uint16_t depth_minus1
Number of bits in the component minus 1.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Libavcodec external API header.
AVPixelFormat
Pixel format.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
#define FF_LOSS_ALPHA
loss of alpha bits
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)
void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
enum AVPixelFormat pix_fmt
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
8 bit with PIX_FMT_RGB32 palette
static enum AVPixelFormat avcodec_find_best_pix_fmt1(enum AVPixelFormat *pix_fmt_list, enum AVPixelFormat src_pix_fmt, int has_alpha, int loss_mask)
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FF_LOSS_CHROMA
loss of chroma (e.g.
#define FF_LOSS_DEPTH
loss due to color depth change
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define FF_LOSS_COLORSPACE
loss due to color space conversion
common internal api header.
static const uint8_t color[]
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright, int *color)
Pad image.
#define FF_LOSS_RESOLUTION
loss due to resolution change
enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list, enum AVPixelFormat 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:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
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)