47 #define FF_COLOR_NA -1
48 #define FF_COLOR_RGB 0
49 #define FF_COLOR_GRAY 1
50 #define FF_COLOR_YUV 2
51 #define FF_COLOR_YUV_JPEG 3
54 #define deinterlace_line_inplace ff_deinterlace_line_inplace_mmx
55 #define deinterlace_line ff_deinterlace_line_mmx
57 #define deinterlace_line_inplace deinterlace_line_inplace_c
58 #define deinterlace_line deinterlace_line_c
61 #define pixdesc_has_alpha(pixdesc) \
62 ((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & AV_PIX_FMT_FLAG_PAL)
77 if(desc->
name && !strncmp(desc->
name,
"yuvj", 4))
99 *min = INT_MAX, *max = -INT_MAX;
109 unsigned *lossp,
unsigned consider)
113 int src_color, dst_color;
114 int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth;
115 int ret, loss, i, nb_components;
116 int score = INT_MAX - 1;
124 if (dst_pix_fmt == src_pix_fmt)
136 for (i = 0; i < nb_components; i++)
181 if (src_color != dst_color)
185 if(loss & FF_LOSS_COLORSPACE)
219 enum AVPixelFormat src_pix_fmt,
int has_alpha,
int *loss_ptr)
222 int loss1, loss2, loss_mask;
227 loss_mask= loss_ptr?~*loss_ptr:~0;
235 if (score1 == score2) {
242 dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1;
250 #if AV_HAVE_INCOMPATIBLE_LIBAV_ABI
253 int has_alpha,
int *loss_ptr){
258 enum AVPixelFormat src_pix_fmt,
int has_alpha,
int *loss_ptr)
266 int has_alpha,
int *loss_ptr){
286 for(;height > 0; height--) {
290 for(w = width;w >= 4; w-=4) {
291 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
292 d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
293 d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
294 d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
300 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
319 for(;height > 0; height--) {
325 for(w = width;w > 0; w--) {
326 d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
327 s2[0] + s2[1] + s2[2] + s2[3] +
328 s3[0] + s3[1] + s3[2] + s3[3] +
329 s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
348 for(;height > 0; height--) {
349 for(w = width;w > 0; w--) {
352 tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7];
355 *(dst++) = (tmp + 32)>>6;
356 src += 8 - 8*src_wrap;
358 src += 8*src_wrap - 8*
width;
359 dst += dst_wrap -
width;
367 int planes[4] = { 0 };
399 dst->
data[1] = src->
data[1] + ((top_band >> y_shift) * src->
linesize[1]) + (left_band >> x_shift);
400 dst->
data[2] = src->
data[2] + ((top_band >> y_shift) * src->
linesize[2]) + (left_band >> x_shift);
402 if(top_band % (1<<y_shift) || left_band % (1<<x_shift))
429 for (i = 0; i < 3; i++) {
433 if (padtop || padleft) {
434 memset(dst->
data[i], color[i],
435 dst->
linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
438 if (padleft || padright) {
439 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
440 (dst->
linesize[i] - (padright >> x_shift));
441 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
442 for (y = 0; y < yheight; y++) {
443 memset(optr, color[i], (padleft + padright) >> x_shift);
450 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
451 (padleft >> x_shift);
452 memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
454 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
455 (dst->
linesize[i] - (padright >> x_shift));
456 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
457 for (y = 0; y < yheight; y++) {
458 memset(optr, color[i], (padleft + padright) >> x_shift);
459 memcpy(optr + ((padleft + padright) >> x_shift), iptr,
460 (width - padleft - padright) >> x_shift);
466 if (padbottom || padright) {
468 ((height - padbottom) >> y_shift) - (padright >> x_shift);
469 memset(optr, color[i],dst->
linesize[i] *
470 (padbottom >> y_shift) + (padright >> x_shift));
476 #if FF_API_DEINTERLACE
478 #if !HAVE_MMX_EXTERNAL
480 static void deinterlace_line_c(
uint8_t *dst,
489 for(;size > 0;size--) {
491 sum += lum_m3[0] << 2;
492 sum += lum_m2[0] << 1;
493 sum += lum_m1[0] << 2;
495 dst[0] = cm[(sum + 4) >> 3];
505 static void deinterlace_line_inplace_c(
uint8_t *lum_m4,
uint8_t *lum_m3,
512 for(;size > 0;size--) {
514 sum += lum_m3[0] << 2;
515 sum += lum_m2[0] << 1;
517 sum += lum_m1[0] << 2;
519 lum_m2[0] = cm[(sum + 4) >> 3];
532 static void deinterlace_bottom_field(
uint8_t *dst,
int dst_wrap,
533 const uint8_t *src1,
int src_wrap,
536 const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
541 src_0=&src_m1[src_wrap];
542 src_p1=&src_0[src_wrap];
543 src_p2=&src_p1[src_wrap];
544 for(y=0;y<(height-2);y+=2) {
545 memcpy(dst,src_m1,width);
551 src_p1 += 2*src_wrap;
552 src_p2 += 2*src_wrap;
555 memcpy(dst,src_m1,width);
561 static void deinterlace_bottom_field_inplace(
uint8_t *src1,
int src_wrap,
562 int width,
int height)
564 uint8_t *src_m1, *src_0, *src_p1, *src_p2;
570 memcpy(buf,src_m1,width);
571 src_0=&src_m1[src_wrap];
572 src_p1=&src_0[src_wrap];
573 src_p2=&src_p1[src_wrap];
574 for(y=0;y<(height-2);y+=2) {
578 src_p1 += 2*src_wrap;
579 src_p2 += 2*src_wrap;
599 if ((width & 3) != 0 || (height & 3) != 0)
625 deinterlace_bottom_field_inplace(dst->
data[i], dst->
linesize[i],
648 if(!desc || !desc->
name) {