14 static int diff_y_mmx(unsigned char *a
, unsigned char *b
, int s
)
19 "pxor %%mm4, %%mm4 \n\t"
20 "pxor %%mm7, %%mm7 \n\t"
24 "movq (%%"REG_S
"), %%mm0 \n\t"
25 "movq (%%"REG_S
"), %%mm2 \n\t"
26 "add %%"REG_a
", %%"REG_S
" \n\t"
27 "movq (%%"REG_D
"), %%mm1 \n\t"
28 "add %%"REG_a
", %%"REG_D
" \n\t"
29 "psubusb %%mm1, %%mm2 \n\t"
30 "psubusb %%mm0, %%mm1 \n\t"
31 "movq %%mm2, %%mm0 \n\t"
32 "movq %%mm1, %%mm3 \n\t"
33 "punpcklbw %%mm7, %%mm0 \n\t"
34 "punpcklbw %%mm7, %%mm1 \n\t"
35 "punpckhbw %%mm7, %%mm2 \n\t"
36 "punpckhbw %%mm7, %%mm3 \n\t"
37 "paddw %%mm0, %%mm4 \n\t"
38 "paddw %%mm1, %%mm4 \n\t"
39 "paddw %%mm2, %%mm4 \n\t"
40 "paddw %%mm3, %%mm4 \n\t"
45 "movq %%mm4, %%mm3 \n\t"
46 "punpcklwd %%mm7, %%mm4 \n\t"
47 "punpckhwd %%mm7, %%mm3 \n\t"
48 "paddd %%mm4, %%mm3 \n\t"
49 "movd %%mm3, %%eax \n\t"
50 "psrlq $32, %%mm3 \n\t"
51 "movd %%mm3, %%edx \n\t"
52 "addl %%edx, %%eax \n\t"
55 : "S" (a
), "D" (b
), "a" (s
)
61 static int licomb_y_mmx(unsigned char *a
, unsigned char *b
, int s
)
66 "pxor %%mm6, %%mm6 \n\t"
67 "pxor %%mm7, %%mm7 \n\t"
68 "sub %%"REG_a
", %%"REG_D
" \n\t"
72 "movq (%%"REG_D
"), %%mm0 \n\t"
73 "movq (%%"REG_D
"), %%mm1 \n\t"
74 "punpcklbw %%mm7, %%mm0 \n\t"
75 "movq (%%"REG_D
",%%"REG_a
"), %%mm2 \n\t"
76 "punpcklbw %%mm7, %%mm1 \n\t"
77 "punpcklbw %%mm7, %%mm2 \n\t"
78 "paddw %%mm0, %%mm0 \n\t"
79 "paddw %%mm2, %%mm1 \n\t"
80 "movq %%mm0, %%mm2 \n\t"
81 "psubusw %%mm1, %%mm0 \n\t"
82 "psubusw %%mm2, %%mm1 \n\t"
83 "paddw %%mm0, %%mm6 \n\t"
84 "paddw %%mm1, %%mm6 \n\t"
86 "movq (%%"REG_S
"), %%mm0 \n\t"
87 "movq (%%"REG_D
"), %%mm1 \n\t"
88 "punpckhbw %%mm7, %%mm0 \n\t"
89 "movq (%%"REG_D
",%%"REG_a
"), %%mm2 \n\t"
90 "punpckhbw %%mm7, %%mm1 \n\t"
91 "punpckhbw %%mm7, %%mm2 \n\t"
92 "paddw %%mm0, %%mm0 \n\t"
93 "paddw %%mm2, %%mm1 \n\t"
94 "movq %%mm0, %%mm2 \n\t"
95 "psubusw %%mm1, %%mm0 \n\t"
96 "psubusw %%mm2, %%mm1 \n\t"
97 "paddw %%mm0, %%mm6 \n\t"
98 "paddw %%mm1, %%mm6 \n\t"
100 "movq (%%"REG_D
",%%"REG_a
"), %%mm0 \n\t"
101 "movq (%%"REG_S
"), %%mm1 \n\t"
102 "punpcklbw %%mm7, %%mm0 \n\t"
103 "movq (%%"REG_S
",%%"REG_a
"), %%mm2 \n\t"
104 "punpcklbw %%mm7, %%mm1 \n\t"
105 "punpcklbw %%mm7, %%mm2 \n\t"
106 "paddw %%mm0, %%mm0 \n\t"
107 "paddw %%mm2, %%mm1 \n\t"
108 "movq %%mm0, %%mm2 \n\t"
109 "psubusw %%mm1, %%mm0 \n\t"
110 "psubusw %%mm2, %%mm1 \n\t"
111 "paddw %%mm0, %%mm6 \n\t"
112 "paddw %%mm1, %%mm6 \n\t"
114 "movq (%%"REG_D
",%%"REG_a
"), %%mm0 \n\t"
115 "movq (%%"REG_S
"), %%mm1 \n\t"
116 "punpckhbw %%mm7, %%mm0 \n\t"
117 "movq (%%"REG_S
",%%"REG_a
"), %%mm2 \n\t"
118 "punpckhbw %%mm7, %%mm1 \n\t"
119 "punpckhbw %%mm7, %%mm2 \n\t"
120 "paddw %%mm0, %%mm0 \n\t"
121 "paddw %%mm2, %%mm1 \n\t"
122 "movq %%mm0, %%mm2 \n\t"
123 "psubusw %%mm1, %%mm0 \n\t"
124 "psubusw %%mm2, %%mm1 \n\t"
125 "paddw %%mm0, %%mm6 \n\t"
126 "paddw %%mm1, %%mm6 \n\t"
128 "add %%"REG_a
", %%"REG_S
" \n\t"
129 "add %%"REG_a
", %%"REG_D
" \n\t"
133 "movq %%mm6, %%mm5 \n\t"
134 "punpcklwd %%mm7, %%mm6 \n\t"
135 "punpckhwd %%mm7, %%mm5 \n\t"
136 "paddd %%mm6, %%mm5 \n\t"
137 "movd %%mm5, %%eax \n\t"
138 "psrlq $32, %%mm5 \n\t"
139 "movd %%mm5, %%edx \n\t"
140 "addl %%edx, %%eax \n\t"
144 : "S" (a
), "D" (b
), "a" (s
)
150 static int var_y_mmx(unsigned char *a
, unsigned char *b
, int s
)
154 "movl $3, %%ecx \n\t"
155 "pxor %%mm4, %%mm4 \n\t"
156 "pxor %%mm7, %%mm7 \n\t"
160 "movq (%%"REG_S
"), %%mm0 \n\t"
161 "movq (%%"REG_S
"), %%mm2 \n\t"
162 "movq (%%"REG_S
",%%"REG_a
"), %%mm1 \n\t"
163 "add %%"REG_a
", %%"REG_S
" \n\t"
164 "psubusb %%mm1, %%mm2 \n\t"
165 "psubusb %%mm0, %%mm1 \n\t"
166 "movq %%mm2, %%mm0 \n\t"
167 "movq %%mm1, %%mm3 \n\t"
168 "punpcklbw %%mm7, %%mm0 \n\t"
169 "punpcklbw %%mm7, %%mm1 \n\t"
170 "punpckhbw %%mm7, %%mm2 \n\t"
171 "punpckhbw %%mm7, %%mm3 \n\t"
172 "paddw %%mm0, %%mm4 \n\t"
173 "paddw %%mm1, %%mm4 \n\t"
174 "paddw %%mm2, %%mm4 \n\t"
175 "paddw %%mm3, %%mm4 \n\t"
180 "movq %%mm4, %%mm3 \n\t"
181 "punpcklwd %%mm7, %%mm4 \n\t"
182 "punpckhwd %%mm7, %%mm3 \n\t"
183 "paddd %%mm4, %%mm3 \n\t"
184 "movd %%mm3, %%eax \n\t"
185 "psrlq $32, %%mm3 \n\t"
186 "movd %%mm3, %%edx \n\t"
187 "addl %%edx, %%eax \n\t"
198 #define ABS(a) (((a)^((a)>>31))-((a)>>31))
200 static int diff_y(unsigned char *a
, unsigned char *b
, int s
)
204 for (j
=0; j
<8; j
++) diff
+= ABS(a
[j
]-b
[j
]);
210 static int licomb_y(unsigned char *a
, unsigned char *b
, int s
)
215 diff
+= ABS((a
[j
]<<1) - b
[j
-s
] - b
[j
])
216 + ABS((b
[j
]<<1) - a
[j
] - a
[j
+s
]);
223 static int qpcomb_y(unsigned char *a
, unsigned char *b
, int s
)
228 diff
+= ABS(a
[j
] - 3*b
[j
-s
] + 3*a
[j
+s
] - b
[j
]);
234 static int licomb_y_test(unsigned char *a
, unsigned char *b
, int s
)
236 int c
= licomb_y(a
,b
,s
);
237 int m
= licomb_y_mmx(a
,b
,s
);
238 if (c
!= m
) printf("%d != %d\n", c
, m
);
243 static int var_y(unsigned char *a
, unsigned char *b
, int s
)
247 for (j
=0; j
<8; j
++) {
248 var
+= ABS(a
[j
]-a
[j
+s
]);
252 return 4*var
; /* match comb scaling */
263 static void alloc_buffer(struct pullup_context
*c
, struct pullup_buffer
*b
)
266 if (b
->planes
) return;
267 b
->planes
= calloc(c
->nplanes
, sizeof(unsigned char *));
268 for (i
= 0; i
< c
->nplanes
; i
++) {
269 b
->planes
[i
] = malloc(c
->h
[i
]*c
->stride
[i
]);
270 /* Deal with idiotic 128=0 for chroma: */
271 memset(b
->planes
[i
], c
->background
[i
], c
->h
[i
]*c
->stride
[i
]);
275 struct pullup_buffer
*pullup_lock_buffer(struct pullup_buffer
*b
, int parity
)
278 if ((parity
+1) & 1) b
->lock
[0]++;
279 if ((parity
+1) & 2) b
->lock
[1]++;
283 void pullup_release_buffer(struct pullup_buffer
*b
, int parity
)
286 if ((parity
+1) & 1) b
->lock
[0]--;
287 if ((parity
+1) & 2) b
->lock
[1]--;
290 struct pullup_buffer
*pullup_get_buffer(struct pullup_context
*c
, int parity
)
294 /* Try first to get the sister buffer for the previous field */
295 if (parity
< 2 && c
->last
&& parity
!= c
->last
->parity
296 && !c
->last
->buffer
->lock
[parity
]) {
297 alloc_buffer(c
, c
->last
->buffer
);
298 return pullup_lock_buffer(c
->last
->buffer
, parity
);
301 /* Prefer a buffer with both fields open */
302 for (i
= 0; i
< c
->nbuffers
; i
++) {
303 if (c
->buffers
[i
].lock
[0]) continue;
304 if (c
->buffers
[i
].lock
[1]) continue;
305 alloc_buffer(c
, &c
->buffers
[i
]);
306 return pullup_lock_buffer(&c
->buffers
[i
], parity
);
309 if (parity
== 2) return 0;
311 /* Search for any half-free buffer */
312 for (i
= 0; i
< c
->nbuffers
; i
++) {
313 if (((parity
+1) & 1) && c
->buffers
[i
].lock
[0]) continue;
314 if (((parity
+1) & 2) && c
->buffers
[i
].lock
[1]) continue;
315 alloc_buffer(c
, &c
->buffers
[i
]);
316 return pullup_lock_buffer(&c
->buffers
[i
], parity
);
327 static void compute_metric(struct pullup_context
*c
,
328 struct pullup_field
*fa
, int pa
,
329 struct pullup_field
*fb
, int pb
,
330 int (*func
)(unsigned char *, unsigned char *, int), int *dest
)
332 unsigned char *a
, *b
;
334 int mp
= c
->metric_plane
;
335 int xstep
= c
->bpp
[mp
];
336 int ystep
= c
->stride
[mp
]<<3;
337 int s
= c
->stride
[mp
]<<1; /* field stride */
338 int w
= c
->metric_w
*xstep
;
340 if (!fa
->buffer
|| !fb
->buffer
) return;
342 /* Shortcut for duplicate fields (e.g. from RFF flag) */
343 if (fa
->buffer
== fb
->buffer
&& pa
== pb
) {
344 memset(dest
, 0, c
->metric_len
* sizeof(int));
348 a
= fa
->buffer
->planes
[mp
] + pa
* c
->stride
[mp
] + c
->metric_offset
;
349 b
= fb
->buffer
->planes
[mp
] + pb
* c
->stride
[mp
] + c
->metric_offset
;
351 for (y
= c
->metric_h
; y
; y
--) {
352 for (x
= 0; x
< w
; x
+= xstep
) {
353 *dest
++ = func(a
+ x
, b
+ x
, s
);
355 a
+= ystep
; b
+= ystep
;
363 static void alloc_metrics(struct pullup_context
*c
, struct pullup_field
*f
)
365 f
->diffs
= calloc(c
->metric_len
, sizeof(int));
366 f
->comb
= calloc(c
->metric_len
, sizeof(int));
367 f
->var
= calloc(c
->metric_len
, sizeof(int));
368 /* add more metrics here as needed */
371 static struct pullup_field
*make_field_queue(struct pullup_context
*c
, int len
)
373 struct pullup_field
*head
, *f
;
374 f
= head
= calloc(1, sizeof(struct pullup_field
));
376 for (; len
> 0; len
--) {
377 f
->next
= calloc(1, sizeof(struct pullup_field
));
387 static void check_field_queue(struct pullup_context
*c
)
389 if (c
->head
->next
== c
->first
) {
390 struct pullup_field
*f
= calloc(1, sizeof(struct pullup_field
));
399 void pullup_submit_field(struct pullup_context
*c
, struct pullup_buffer
*b
, int parity
)
401 struct pullup_field
*f
;
403 /* Grow the circular list if needed */
404 check_field_queue(c
);
406 /* Cannot have two fields of same parity in a row; drop the new one */
407 if (c
->last
&& c
->last
->parity
== parity
) return;
411 f
->buffer
= pullup_lock_buffer(b
, parity
);
416 compute_metric(c
, f
, parity
, f
->prev
->prev
, parity
, c
->diff
, f
->diffs
);
417 compute_metric(c
, parity
?f
->prev
:f
, 0, parity
?f
:f
->prev
, 1, c
->comb
, f
->comb
);
418 compute_metric(c
, f
, parity
, f
, -1, c
->var
, f
->var
);
420 /* Advance the circular list */
421 if (!c
->first
) c
->first
= c
->head
;
423 c
->head
= c
->head
->next
;
426 void pullup_flush_fields(struct pullup_context
*c
)
428 struct pullup_field
*f
;
430 for (f
= c
->first
; f
&& f
!= c
->head
; f
= f
->next
) {
431 pullup_release_buffer(f
->buffer
, f
->parity
);
434 c
->first
= c
->last
= 0;
444 #define F_HAVE_BREAKS 1
445 #define F_HAVE_AFFINITY 2
449 #define BREAK_RIGHT 2
454 static int queue_length(struct pullup_field
*begin
, struct pullup_field
*end
)
457 struct pullup_field
*f
;
459 if (!begin
|| !end
) return 0;
460 for (f
= begin
; f
!= end
; f
= f
->next
) count
++;
464 static int find_first_break(struct pullup_field
*f
, int max
)
467 for (i
= 0; i
< max
; i
++) {
468 if (f
->breaks
& BREAK_RIGHT
|| f
->next
->breaks
& BREAK_LEFT
)
475 static void compute_breaks(struct pullup_context
*c
, struct pullup_field
*f0
)
478 struct pullup_field
*f1
= f0
->next
;
479 struct pullup_field
*f2
= f1
->next
;
480 struct pullup_field
*f3
= f2
->next
;
481 int l
, max_l
=0, max_r
=0;
482 //struct pullup_field *ff;
483 //for (i=0, ff=c->first; ff != f0; i++, ff=ff->next);
485 if (f0
->flags
& F_HAVE_BREAKS
) return;
486 //printf("\n%d: ", i);
487 f0
->flags
|= F_HAVE_BREAKS
;
489 /* Special case when fields are 100% identical */
490 if (f0
->buffer
== f2
->buffer
&& f1
->buffer
!= f3
->buffer
) {
491 f2
->breaks
|= BREAK_RIGHT
;
494 if (f0
->buffer
!= f2
->buffer
&& f1
->buffer
== f3
->buffer
) {
495 f1
->breaks
|= BREAK_LEFT
;
499 for (i
= 0; i
< c
->metric_len
; i
++) {
500 l
= f2
->diffs
[i
] - f3
->diffs
[i
];
501 if (l
> max_l
) max_l
= l
;
502 if (-l
> max_r
) max_r
= -l
;
504 /* Don't get tripped up when differences are mostly quant error */
505 //printf("%d %d\n", max_l, max_r);
506 if (max_l
+ max_r
< 128) return;
507 if (max_l
> 4*max_r
) f1
->breaks
|= BREAK_LEFT
;
508 if (max_r
> 4*max_l
) f2
->breaks
|= BREAK_RIGHT
;
511 static void compute_affinity(struct pullup_context
*c
, struct pullup_field
*f
)
514 int max_l
=0, max_r
=0, l
;
515 if (f
->flags
& F_HAVE_AFFINITY
) return;
516 f
->flags
|= F_HAVE_AFFINITY
;
517 if (f
->buffer
== f
->next
->next
->buffer
) {
519 f
->next
->affinity
= 0;
520 f
->next
->next
->affinity
= -1;
521 f
->next
->flags
|= F_HAVE_AFFINITY
;
522 f
->next
->next
->flags
|= F_HAVE_AFFINITY
;
526 for (i
= 0; i
< c
->metric_len
; i
++) {
527 int lv
= f
->prev
->var
[i
];
528 int rv
= f
->next
->var
[i
];
530 int lc
= f
->comb
[i
] - (v
+lv
) + ABS(v
-lv
);
531 int rc
= f
->next
->comb
[i
] - (v
+rv
) + ABS(v
-rv
);
535 if (l
> max_l
) max_l
= l
;
536 if (-l
> max_r
) max_r
= -l
;
538 if (max_l
+ max_r
< 64) return;
539 if (max_r
> 6*max_l
) f
->affinity
= -1;
540 else if (max_l
> 6*max_r
) f
->affinity
= 1;
542 for (i
= 0; i
< c
->metric_len
; i
++) {
543 l
= f
->comb
[i
] - f
->next
->comb
[i
];
544 if (l
> max_l
) max_l
= l
;
545 if (-l
> max_r
) max_r
= -l
;
547 if (max_l
+ max_r
< 64) return;
548 if (max_r
> 2*max_l
) f
->affinity
= -1;
549 else if (max_l
> 2*max_r
) f
->affinity
= 1;
553 static void foo(struct pullup_context
*c
)
555 struct pullup_field
*f
= c
->first
;
556 int i
, n
= queue_length(f
, c
->last
);
557 for (i
= 0; i
< n
-1; i
++) {
558 if (i
< n
-3) compute_breaks(c
, f
);
559 compute_affinity(c
, f
);
564 static int decide_frame_length(struct pullup_context
*c
)
566 struct pullup_field
*f0
= c
->first
;
567 struct pullup_field
*f1
= f0
->next
;
568 struct pullup_field
*f2
= f1
->next
;
571 if (queue_length(c
->first
, c
->last
) < 4) return 0;
574 if (f0
->affinity
== -1) return 1;
576 l
= find_first_break(f0
, 3);
577 if (l
== 1 && c
->strict_breaks
< 0) l
= 0;
581 if (c
->strict_breaks
< 1 && f0
->affinity
== 1 && f1
->affinity
== -1)
585 /* FIXME: strictly speaking, f0->prev is no longer valid... :) */
587 && (f0
->prev
->breaks
& BREAK_RIGHT
) && (f2
->breaks
& BREAK_LEFT
)
588 && (f0
->affinity
!= 1 || f1
->affinity
!= -1) )
590 if (f1
->affinity
== 1) return 1;
593 if (f2
->affinity
== 1) return 2;
596 /* 9 possibilities covered before switch */
597 if (f1
->affinity
== 1) return 1; /* covers 6 */
598 else if (f1
->affinity
== -1) return 2; /* covers 6 */
599 else if (f2
->affinity
== -1) { /* covers 2 */
600 if (f0
->affinity
== 1) return 3;
603 else return 2; /* the remaining 6 */
608 static void print_aff_and_breaks(struct pullup_context
*c
, struct pullup_field
*f
)
611 struct pullup_field
*f0
= f
;
612 const char aff_l
[] = "+..", aff_r
[] = "..+";
613 printf("\naffinity: ");
614 for (i
= 0; i
< 4; i
++) {
615 printf("%c%d%c", aff_l
[1+f
->affinity
], i
, aff_r
[1+f
->affinity
]);
619 printf("\nbreaks: ");
620 for (i
=0; i
<4; i
++) {
621 printf("%c%d%c", f
->breaks
& BREAK_LEFT
? '|' : '.', i
, f
->breaks
& BREAK_RIGHT
? '|' : '.');
631 struct pullup_frame
*pullup_get_frame(struct pullup_context
*c
)
634 struct pullup_frame
*fr
= c
->frame
;
635 int n
= decide_frame_length(c
);
636 int aff
= c
->first
->next
->affinity
;
639 if (fr
->lock
) return 0;
642 print_aff_and_breaks(c
, c
->first
);
643 printf("duration: %d \n", n
);
648 fr
->parity
= c
->first
->parity
;
650 for (i
= 0; i
< n
; i
++) {
651 /* We cheat and steal the buffer without release+relock */
652 fr
->ifields
[i
] = c
->first
->buffer
;
653 c
->first
->buffer
= 0;
654 c
->first
= c
->first
->next
;
658 fr
->ofields
[fr
->parity
] = fr
->ifields
[0];
659 fr
->ofields
[fr
->parity
^1] = 0;
661 fr
->ofields
[fr
->parity
] = fr
->ifields
[0];
662 fr
->ofields
[fr
->parity
^1] = fr
->ifields
[1];
665 aff
= (fr
->ifields
[0] == fr
->ifields
[1]) ? -1 : 1;
666 /* else if (c->verbose) printf("forced aff: %d \n", aff); */
667 fr
->ofields
[fr
->parity
] = fr
->ifields
[1+aff
];
668 fr
->ofields
[fr
->parity
^1] = fr
->ifields
[1];
670 pullup_lock_buffer(fr
->ofields
[0], 0);
671 pullup_lock_buffer(fr
->ofields
[1], 1);
673 if (fr
->ofields
[0] == fr
->ofields
[1]) {
674 fr
->buffer
= fr
->ofields
[0];
675 pullup_lock_buffer(fr
->buffer
, 2);
681 static void copy_field(struct pullup_context
*c
, struct pullup_buffer
*dest
,
682 struct pullup_buffer
*src
, int parity
)
685 unsigned char *d
, *s
;
686 for (i
= 0; i
< c
->nplanes
; i
++) {
687 s
= src
->planes
[i
] + parity
*c
->stride
[i
];
688 d
= dest
->planes
[i
] + parity
*c
->stride
[i
];
689 for (j
= c
->h
[i
]>>1; j
; j
--) {
690 memcpy(d
, s
, c
->stride
[i
]);
691 s
+= c
->stride
[i
]<<1;
692 d
+= c
->stride
[i
]<<1;
697 void pullup_pack_frame(struct pullup_context
*c
, struct pullup_frame
*fr
)
700 if (fr
->buffer
) return;
701 if (fr
->length
< 2) return; /* FIXME: deal with this */
702 for (i
= 0; i
< 2; i
++)
704 if (fr
->ofields
[i
]->lock
[i
^1]) continue;
705 fr
->buffer
= fr
->ofields
[i
];
706 pullup_lock_buffer(fr
->buffer
, 2);
707 copy_field(c
, fr
->buffer
, fr
->ofields
[i
^1], i
^1);
710 fr
->buffer
= pullup_get_buffer(c
, 2);
711 copy_field(c
, fr
->buffer
, fr
->ofields
[0], 0);
712 copy_field(c
, fr
->buffer
, fr
->ofields
[1], 1);
715 void pullup_release_frame(struct pullup_frame
*fr
)
718 for (i
= 0; i
< fr
->length
; i
++)
719 pullup_release_buffer(fr
->ifields
[i
], fr
->parity
^ (i
&1));
720 pullup_release_buffer(fr
->ofields
[0], 0);
721 pullup_release_buffer(fr
->ofields
[1], 1);
722 if (fr
->buffer
) pullup_release_buffer(fr
->buffer
, 2);
731 struct pullup_context
*pullup_alloc_context(void)
733 struct pullup_context
*c
;
735 c
= calloc(1, sizeof(struct pullup_context
));
740 void pullup_preinit_context(struct pullup_context
*c
)
742 c
->bpp
= calloc(c
->nplanes
, sizeof(int));
743 c
->w
= calloc(c
->nplanes
, sizeof(int));
744 c
->h
= calloc(c
->nplanes
, sizeof(int));
745 c
->stride
= calloc(c
->nplanes
, sizeof(int));
746 c
->background
= calloc(c
->nplanes
, sizeof(int));
749 void pullup_init_context(struct pullup_context
*c
)
751 int mp
= c
->metric_plane
;
752 if (c
->nbuffers
< 10) c
->nbuffers
= 10;
753 c
->buffers
= calloc(c
->nbuffers
, sizeof (struct pullup_buffer
));
755 c
->metric_w
= (c
->w
[mp
] - ((c
->junk_left
+ c
->junk_right
) << 3)) >> 3;
756 c
->metric_h
= (c
->h
[mp
] - ((c
->junk_top
+ c
->junk_bottom
) << 1)) >> 3;
757 c
->metric_offset
= c
->junk_left
*c
->bpp
[mp
] + (c
->junk_top
<<1)*c
->stride
[mp
];
758 c
->metric_len
= c
->metric_w
* c
->metric_h
;
760 c
->head
= make_field_queue(c
, 8);
762 c
->frame
= calloc(1, sizeof (struct pullup_frame
));
763 c
->frame
->ifields
= calloc(3, sizeof (struct pullup_buffer
*));
772 if (c
->cpu
& PULLUP_CPU_MMX
) {
773 c
->diff
= diff_y_mmx
;
774 c
->comb
= licomb_y_mmx
;
779 /* c->comb = qpcomb_y; */
782 case PULLUP_FMT_YUY2
:
785 case PULLUP_FMT_RGB32
:
786 c
->diff
= diff_rgb32
;
792 void pullup_free_context(struct pullup_context
*c
)
794 struct pullup_field
*f
;
803 } while (f
!= c
->head
);