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 & PIX_FMT_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;
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)
218 #if FF_API_FIND_BEST_PIX_FMT
220 int has_alpha,
int *loss_ptr)
230 if (pix_fmt_mask & (1ULL << i))
238 enum AVPixelFormat src_pix_fmt,
int has_alpha,
int *loss_ptr)
241 int loss1, loss2, loss_mask;
246 loss_mask= loss_ptr?~*loss_ptr:~0;
254 if (score1 == score2) {
261 dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1;
269 #if AV_HAVE_INCOMPATIBLE_FORK_ABI
272 int has_alpha,
int *loss_ptr){
277 enum AVPixelFormat src_pix_fmt,
int has_alpha,
int *loss_ptr)
285 int has_alpha,
int *loss_ptr){
298 const uint8_t *src,
int src_wrap,
305 for(;height > 0; height--) {
309 for(w = width;w >= 4; w-=4) {
310 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
311 d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
312 d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
313 d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
319 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
331 const uint8_t *src,
int src_wrap,
338 for(;height > 0; height--) {
344 for(w = width;w > 0; w--) {
345 d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
346 s2[0] + s2[1] + s2[2] + s2[3] +
347 s3[0] + s3[1] + s3[2] + s3[3] +
348 s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
362 const uint8_t *src,
int src_wrap,
367 for(;height > 0; height--) {
368 for(w = width;w > 0; w--) {
371 tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7];
374 *(dst++) = (tmp + 32)>>6;
375 src += 8 - 8*src_wrap;
377 src += 8*src_wrap - 8*
width;
378 dst += dst_wrap -
width;
386 int planes[4] = { 0 };
418 dst->
data[1] = src->
data[1] + ((top_band >> y_shift) * src->
linesize[1]) + (left_band >> x_shift);
419 dst->
data[2] = src->
data[2] + ((top_band >> y_shift) * src->
linesize[2]) + (left_band >> x_shift);
421 if(top_band % (1<<y_shift) || left_band % (1<<x_shift))
448 for (i = 0; i < 3; i++) {
452 if (padtop || padleft) {
453 memset(dst->
data[i], color[i],
454 dst->
linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
457 if (padleft || padright) {
458 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
459 (dst->
linesize[i] - (padright >> x_shift));
460 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
461 for (y = 0; y < yheight; y++) {
462 memset(optr, color[i], (padleft + padright) >> x_shift);
469 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
470 (padleft >> x_shift);
471 memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
473 optr = dst->
data[i] + dst->
linesize[i] * (padtop >> y_shift) +
474 (dst->
linesize[i] - (padright >> x_shift));
475 yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
476 for (y = 0; y < yheight; y++) {
477 memset(optr, color[i], (padleft + padright) >> x_shift);
478 memcpy(optr + ((padleft + padright) >> x_shift), iptr,
479 (width - padleft - padright) >> x_shift);
485 if (padbottom || padright) {
487 ((height - padbottom) >> y_shift) - (padright >> x_shift);
488 memset(optr, color[i],dst->
linesize[i] *
489 (padbottom >> y_shift) + (padright >> x_shift));
495 #if FF_API_DEINTERLACE
497 #if !HAVE_MMX_EXTERNAL
508 for(;size > 0;size--) {
510 sum += lum_m3[0] << 2;
511 sum += lum_m2[0] << 1;
512 sum += lum_m1[0] << 2;
514 dst[0] = cm[(sum + 4) >> 3];
524 static void deinterlace_line_inplace_c(
uint8_t *lum_m4,
uint8_t *lum_m3,
531 for(;size > 0;size--) {
533 sum += lum_m3[0] << 2;
534 sum += lum_m2[0] << 1;
536 sum += lum_m1[0] << 2;
538 lum_m2[0] = cm[(sum + 4) >> 3];
551 static void deinterlace_bottom_field(
uint8_t *dst,
int dst_wrap,
552 const uint8_t *src1,
int src_wrap,
555 const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
560 src_0=&src_m1[src_wrap];
561 src_p1=&src_0[src_wrap];
562 src_p2=&src_p1[src_wrap];
563 for(y=0;y<(height-2);y+=2) {
564 memcpy(dst,src_m1,width);
570 src_p1 += 2*src_wrap;
571 src_p2 += 2*src_wrap;
574 memcpy(dst,src_m1,width);
580 static void deinterlace_bottom_field_inplace(
uint8_t *src1,
int src_wrap,
581 int width,
int height)
583 uint8_t *src_m1, *src_0, *src_p1, *src_p2;
589 memcpy(buf,src_m1,width);
590 src_0=&src_m1[src_wrap];
591 src_p1=&src_0[src_wrap];
592 src_p2=&src_p1[src_wrap];
593 for(y=0;y<(height-2);y+=2) {
597 src_p1 += 2*src_wrap;
598 src_p2 += 2*src_wrap;
618 if ((width & 3) != 0 || (height & 3) != 0)
644 deinterlace_bottom_field_inplace(dst->
data[i], dst->
linesize[i],
667 if(!desc || !desc->
name) {