13 static int diff_y_mmx(unsigned char *a
, unsigned char *b
, int s
)
18 "pxor %%mm4, %%mm4 \n\t"
19 "pxor %%mm7, %%mm7 \n\t"
23 "movq (%%esi), %%mm0 \n\t"
24 "movq (%%esi), %%mm2 \n\t"
25 "addl %%eax, %%esi \n\t"
26 "movq (%%edi), %%mm1 \n\t"
27 "addl %%eax, %%edi \n\t"
28 "psubusb %%mm1, %%mm2 \n\t"
29 "psubusb %%mm0, %%mm1 \n\t"
30 "movq %%mm2, %%mm0 \n\t"
31 "movq %%mm1, %%mm3 \n\t"
32 "punpcklbw %%mm7, %%mm0 \n\t"
33 "punpcklbw %%mm7, %%mm1 \n\t"
34 "punpckhbw %%mm7, %%mm2 \n\t"
35 "punpckhbw %%mm7, %%mm3 \n\t"
36 "paddw %%mm0, %%mm4 \n\t"
37 "paddw %%mm1, %%mm4 \n\t"
38 "paddw %%mm2, %%mm4 \n\t"
39 "paddw %%mm3, %%mm4 \n\t"
44 "movq %%mm4, %%mm3 \n\t"
45 "punpcklwd %%mm7, %%mm4 \n\t"
46 "punpckhwd %%mm7, %%mm3 \n\t"
47 "paddd %%mm4, %%mm3 \n\t"
48 "movd %%mm3, %%eax \n\t"
49 "psrlq $32, %%mm3 \n\t"
50 "movd %%mm3, %%edx \n\t"
51 "addl %%edx, %%eax \n\t"
54 : "S" (a
), "D" (b
), "a" (s
)
60 static int licomb_y_mmx(unsigned char *a
, unsigned char *b
, int s
)
65 "pxor %%mm6, %%mm6 \n\t"
66 "pxor %%mm7, %%mm7 \n\t"
67 "subl %%eax, %%edi \n\t"
71 "movq (%%esi), %%mm0 \n\t"
72 "movq (%%edi), %%mm1 \n\t"
73 "punpcklbw %%mm7, %%mm0 \n\t"
74 "movq (%%edi,%%eax), %%mm2 \n\t"
75 "punpcklbw %%mm7, %%mm1 \n\t"
76 "punpcklbw %%mm7, %%mm2 \n\t"
77 "paddw %%mm0, %%mm0 \n\t"
78 "paddw %%mm2, %%mm1 \n\t"
79 "movq %%mm0, %%mm2 \n\t"
80 "psubusw %%mm1, %%mm0 \n\t"
81 "psubusw %%mm2, %%mm1 \n\t"
82 "paddw %%mm0, %%mm6 \n\t"
83 "paddw %%mm1, %%mm6 \n\t"
85 "movq (%%esi), %%mm0 \n\t"
86 "movq (%%edi), %%mm1 \n\t"
87 "punpckhbw %%mm7, %%mm0 \n\t"
88 "movq (%%edi,%%eax), %%mm2 \n\t"
89 "punpckhbw %%mm7, %%mm1 \n\t"
90 "punpckhbw %%mm7, %%mm2 \n\t"
91 "paddw %%mm0, %%mm0 \n\t"
92 "paddw %%mm2, %%mm1 \n\t"
93 "movq %%mm0, %%mm2 \n\t"
94 "psubusw %%mm1, %%mm0 \n\t"
95 "psubusw %%mm2, %%mm1 \n\t"
96 "paddw %%mm0, %%mm6 \n\t"
97 "paddw %%mm1, %%mm6 \n\t"
99 "movq (%%edi,%%eax), %%mm0 \n\t"
100 "movq (%%esi), %%mm1 \n\t"
101 "punpcklbw %%mm7, %%mm0 \n\t"
102 "movq (%%esi,%%eax), %%mm2 \n\t"
103 "punpcklbw %%mm7, %%mm1 \n\t"
104 "punpcklbw %%mm7, %%mm2 \n\t"
105 "paddw %%mm0, %%mm0 \n\t"
106 "paddw %%mm2, %%mm1 \n\t"
107 "movq %%mm0, %%mm2 \n\t"
108 "psubusw %%mm1, %%mm0 \n\t"
109 "psubusw %%mm2, %%mm1 \n\t"
110 "paddw %%mm0, %%mm6 \n\t"
111 "paddw %%mm1, %%mm6 \n\t"
113 "movq (%%edi,%%eax), %%mm0 \n\t"
114 "movq (%%esi), %%mm1 \n\t"
115 "punpckhbw %%mm7, %%mm0 \n\t"
116 "movq (%%esi,%%eax), %%mm2 \n\t"
117 "punpckhbw %%mm7, %%mm1 \n\t"
118 "punpckhbw %%mm7, %%mm2 \n\t"
119 "paddw %%mm0, %%mm0 \n\t"
120 "paddw %%mm2, %%mm1 \n\t"
121 "movq %%mm0, %%mm2 \n\t"
122 "psubusw %%mm1, %%mm0 \n\t"
123 "psubusw %%mm2, %%mm1 \n\t"
124 "paddw %%mm0, %%mm6 \n\t"
125 "paddw %%mm1, %%mm6 \n\t"
127 "addl %%eax, %%esi \n\t"
128 "addl %%eax, %%edi \n\t"
132 "movq %%mm6, %%mm5 \n\t"
133 "punpcklwd %%mm7, %%mm6 \n\t"
134 "punpckhwd %%mm7, %%mm5 \n\t"
135 "paddd %%mm6, %%mm5 \n\t"
136 "movd %%mm5, %%eax \n\t"
137 "psrlq $32, %%mm5 \n\t"
138 "movd %%mm5, %%edx \n\t"
139 "addl %%edx, %%eax \n\t"
143 : "S" (a
), "D" (b
), "a" (s
)
149 static int var_y_mmx(unsigned char *a
, unsigned char *b
, int s
)
153 "movl $3, %%ecx \n\t"
154 "pxor %%mm4, %%mm4 \n\t"
155 "pxor %%mm7, %%mm7 \n\t"
159 "movq (%%esi), %%mm0 \n\t"
160 "movq (%%esi), %%mm2 \n\t"
161 "movq (%%esi,%%eax), %%mm1 \n\t"
162 "addl %%eax, %%esi \n\t"
163 "psubusb %%mm1, %%mm2 \n\t"
164 "psubusb %%mm0, %%mm1 \n\t"
165 "movq %%mm2, %%mm0 \n\t"
166 "movq %%mm1, %%mm3 \n\t"
167 "punpcklbw %%mm7, %%mm0 \n\t"
168 "punpcklbw %%mm7, %%mm1 \n\t"
169 "punpckhbw %%mm7, %%mm2 \n\t"
170 "punpckhbw %%mm7, %%mm3 \n\t"
171 "paddw %%mm0, %%mm4 \n\t"
172 "paddw %%mm1, %%mm4 \n\t"
173 "paddw %%mm2, %%mm4 \n\t"
174 "paddw %%mm3, %%mm4 \n\t"
179 "movq %%mm4, %%mm3 \n\t"
180 "punpcklwd %%mm7, %%mm4 \n\t"
181 "punpckhwd %%mm7, %%mm3 \n\t"
182 "paddd %%mm4, %%mm3 \n\t"
183 "movd %%mm3, %%eax \n\t"
184 "psrlq $32, %%mm3 \n\t"
185 "movd %%mm3, %%edx \n\t"
186 "addl %%edx, %%eax \n\t"
197 #define ABS(a) (((a)^((a)>>31))-((a)>>31))
199 static int diff_y(unsigned char *a
, unsigned char *b
, int s
)
203 for (j
=0; j
<8; j
++) diff
+= ABS(a
[j
]-b
[j
]);
209 static int licomb_y(unsigned char *a
, unsigned char *b
, int s
)
214 diff
+= ABS((a
[j
]<<1) - b
[j
-s
] - b
[j
])
215 + ABS((b
[j
]<<1) - a
[j
] - a
[j
+s
]);
221 static int qpcomb_y(unsigned char *a
, unsigned char *b
, int s
)
226 diff
+= ABS(a
[j
] - 3*b
[j
-s
] + 3*a
[j
+s
] - b
[j
]);
233 static int licomb_y_test(unsigned char *a
, unsigned char *b
, int s
)
235 int c
= licomb_y(a
,b
,s
);
236 int m
= licomb_y_mmx(a
,b
,s
);
237 if (c
!= m
) printf("%d != %d\n", c
, m
);
242 static int var_y(unsigned char *a
, unsigned char *b
, int s
)
246 for (j
=0; j
<8; j
++) {
247 var
+= ABS(a
[j
]-a
[j
+s
]);
251 return 4*var
; /* match comb scaling */
262 static void alloc_buffer(struct pullup_context
*c
, struct pullup_buffer
*b
)
265 if (b
->planes
) return;
266 b
->planes
= calloc(c
->nplanes
, sizeof(unsigned char *));
267 for (i
= 0; i
< c
->nplanes
; i
++) {
268 b
->planes
[i
] = malloc(c
->h
[i
]*c
->stride
[i
]);
269 /* Deal with idiotic 128=0 for chroma: */
270 memset(b
->planes
[i
], c
->background
[i
], c
->h
[i
]*c
->stride
[i
]);
274 struct pullup_buffer
*pullup_lock_buffer(struct pullup_buffer
*b
, int parity
)
277 if ((parity
+1) & 1) b
->lock
[0]++;
278 if ((parity
+1) & 2) b
->lock
[1]++;
282 void pullup_release_buffer(struct pullup_buffer
*b
, int parity
)
285 if ((parity
+1) & 1) b
->lock
[0]--;
286 if ((parity
+1) & 2) b
->lock
[1]--;
289 struct pullup_buffer
*pullup_get_buffer(struct pullup_context
*c
, int parity
)
293 /* Try first to get the sister buffer for the previous field */
294 if (parity
< 2 && c
->last
&& parity
!= c
->last
->parity
295 && !c
->last
->buffer
->lock
[parity
]) {
296 alloc_buffer(c
, c
->last
->buffer
);
297 return pullup_lock_buffer(c
->last
->buffer
, parity
);
300 /* Prefer a buffer with both fields open */
301 for (i
= 0; i
< c
->nbuffers
; i
++) {
302 if (c
->buffers
[i
].lock
[0]) continue;
303 if (c
->buffers
[i
].lock
[1]) continue;
304 alloc_buffer(c
, &c
->buffers
[i
]);
305 return pullup_lock_buffer(&c
->buffers
[i
], parity
);
308 if (parity
== 2) return 0;
310 /* Search for any half-free buffer */
311 for (i
= 0; i
< c
->nbuffers
; i
++) {
312 if (((parity
+1) & 1) && c
->buffers
[i
].lock
[0]) continue;
313 if (((parity
+1) & 2) && c
->buffers
[i
].lock
[1]) continue;
314 alloc_buffer(c
, &c
->buffers
[i
]);
315 return pullup_lock_buffer(&c
->buffers
[i
], parity
);
326 static void compute_metric(struct pullup_context
*c
,
327 struct pullup_field
*fa
, int pa
,
328 struct pullup_field
*fb
, int pb
,
329 int (*func
)(unsigned char *, unsigned char *, int), int *dest
)
331 unsigned char *a
, *b
;
333 int mp
= c
->metric_plane
;
334 int xstep
= c
->bpp
[mp
];
335 int ystep
= c
->stride
[mp
]<<3;
336 int s
= c
->stride
[mp
]<<1; /* field stride */
337 int w
= c
->metric_w
*xstep
;
339 if (!fa
->buffer
|| !fb
->buffer
) return;
341 /* Shortcut for duplicate fields (e.g. from RFF flag) */
342 if (fa
->buffer
== fb
->buffer
&& pa
== pb
) {
343 memset(dest
, 0, c
->metric_len
* sizeof(int));
347 a
= fa
->buffer
->planes
[mp
] + pa
* c
->stride
[mp
] + c
->metric_offset
;
348 b
= fb
->buffer
->planes
[mp
] + pb
* c
->stride
[mp
] + c
->metric_offset
;
350 for (y
= c
->metric_h
; y
; y
--) {
351 for (x
= 0; x
< w
; x
+= xstep
) {
352 *dest
++ = func(a
+ x
, b
+ x
, s
);
354 a
+= ystep
; b
+= ystep
;
362 static void alloc_metrics(struct pullup_context
*c
, struct pullup_field
*f
)
364 f
->diffs
= calloc(c
->metric_len
, sizeof(int));
365 f
->comb
= calloc(c
->metric_len
, sizeof(int));
366 f
->var
= calloc(c
->metric_len
, sizeof(int));
367 /* add more metrics here as needed */
370 static struct pullup_field
*make_field_queue(struct pullup_context
*c
, int len
)
372 struct pullup_field
*head
, *f
;
373 f
= head
= calloc(1, sizeof(struct pullup_field
));
375 for (; len
> 0; len
--) {
376 f
->next
= calloc(1, sizeof(struct pullup_field
));
386 static void check_field_queue(struct pullup_context
*c
)
388 if (c
->head
->next
== c
->first
) {
389 struct pullup_field
*f
= calloc(1, sizeof(struct pullup_field
));
398 void pullup_submit_field(struct pullup_context
*c
, struct pullup_buffer
*b
, int parity
)
400 struct pullup_field
*f
;
402 /* Grow the circular list if needed */
403 check_field_queue(c
);
405 /* Cannot have two fields of same parity in a row; drop the new one */
406 if (c
->last
&& c
->last
->parity
== parity
) return;
410 f
->buffer
= pullup_lock_buffer(b
, parity
);
415 compute_metric(c
, f
, parity
, f
->prev
->prev
, parity
, c
->diff
, f
->diffs
);
416 compute_metric(c
, parity
?f
->prev
:f
, 0, parity
?f
:f
->prev
, 1, c
->comb
, f
->comb
);
417 compute_metric(c
, f
, parity
, f
, -1, c
->var
, f
->var
);
419 /* Advance the circular list */
420 if (!c
->first
) c
->first
= c
->head
;
422 c
->head
= c
->head
->next
;
425 void pullup_flush_fields(struct pullup_context
*c
)
427 struct pullup_field
*f
;
429 for (f
= c
->first
; f
&& f
!= c
->head
; f
= f
->next
) {
430 pullup_release_buffer(f
->buffer
, f
->parity
);
433 c
->first
= c
->last
= 0;
443 #define F_HAVE_BREAKS 1
444 #define F_HAVE_AFFINITY 2
448 #define BREAK_RIGHT 2
453 static int queue_length(struct pullup_field
*begin
, struct pullup_field
*end
)
456 struct pullup_field
*f
;
458 if (!begin
|| !end
) return 0;
459 for (f
= begin
; f
!= end
; f
= f
->next
) count
++;
463 static int find_first_break(struct pullup_field
*f
, int max
)
466 for (i
= 0; i
< max
; i
++) {
467 if (f
->breaks
& BREAK_RIGHT
|| f
->next
->breaks
& BREAK_LEFT
)
474 static void compute_breaks(struct pullup_context
*c
, struct pullup_field
*f0
)
477 struct pullup_field
*f1
= f0
->next
;
478 struct pullup_field
*f2
= f1
->next
;
479 struct pullup_field
*f3
= f2
->next
;
480 int l
, max_l
=0, max_r
=0;
481 //struct pullup_field *ff;
482 //for (i=0, ff=c->first; ff != f0; i++, ff=ff->next);
484 if (f0
->flags
& F_HAVE_BREAKS
) return;
485 //printf("\n%d: ", i);
486 f0
->flags
|= F_HAVE_BREAKS
;
488 /* Special case when fields are 100% identical */
489 if (f0
->buffer
== f2
->buffer
&& f1
->buffer
!= f3
->buffer
) {
490 f2
->breaks
|= BREAK_RIGHT
;
493 if (f0
->buffer
!= f2
->buffer
&& f1
->buffer
== f3
->buffer
) {
494 f1
->breaks
|= BREAK_LEFT
;
498 for (i
= 0; i
< c
->metric_len
; i
++) {
499 l
= f2
->diffs
[i
] - f3
->diffs
[i
];
500 if (l
> max_l
) max_l
= l
;
501 if (-l
> max_r
) max_r
= -l
;
503 /* Don't get tripped up when differences are mostly quant error */
504 //printf("%d %d\n", max_l, max_r);
505 if (max_l
+ max_r
< 128) return;
506 if (max_l
> 4*max_r
) f1
->breaks
|= BREAK_LEFT
;
507 if (max_r
> 4*max_l
) f2
->breaks
|= BREAK_RIGHT
;
510 static void compute_affinity(struct pullup_context
*c
, struct pullup_field
*f
)
513 int max_l
=0, max_r
=0, l
;
514 if (f
->flags
& F_HAVE_AFFINITY
) return;
515 f
->flags
|= F_HAVE_AFFINITY
;
516 if (f
->buffer
== f
->next
->next
->buffer
) {
518 f
->next
->affinity
= 0;
519 f
->next
->next
->affinity
= -1;
520 f
->next
->flags
|= F_HAVE_AFFINITY
;
521 f
->next
->next
->flags
|= F_HAVE_AFFINITY
;
525 for (i
= 0; i
< c
->metric_len
; i
++) {
526 int lv
= f
->prev
->var
[i
];
527 int rv
= f
->next
->var
[i
];
529 int lc
= f
->comb
[i
] - (v
+lv
) + ABS(v
-lv
);
530 int rc
= f
->next
->comb
[i
] - (v
+rv
) + ABS(v
-rv
);
534 if (l
> max_l
) max_l
= l
;
535 if (-l
> max_r
) max_r
= -l
;
537 if (max_l
+ max_r
< 64) return;
538 if (max_r
> 6*max_l
) f
->affinity
= -1;
539 else if (max_l
> 6*max_r
) f
->affinity
= 1;
541 for (i
= 0; i
< c
->metric_len
; i
++) {
542 l
= f
->comb
[i
] - f
->next
->comb
[i
];
543 if (l
> max_l
) max_l
= l
;
544 if (-l
> max_r
) max_r
= -l
;
546 if (max_l
+ max_r
< 64) return;
547 if (max_r
> 2*max_l
) f
->affinity
= -1;
548 else if (max_l
> 2*max_r
) f
->affinity
= 1;
552 static void foo(struct pullup_context
*c
)
554 struct pullup_field
*f
= c
->first
;
555 int i
, n
= queue_length(f
, c
->last
);
556 for (i
= 0; i
< n
-1; i
++) {
557 if (i
< n
-3) compute_breaks(c
, f
);
558 compute_affinity(c
, f
);
563 static int decide_frame_length(struct pullup_context
*c
)
565 struct pullup_field
*f0
= c
->first
;
566 struct pullup_field
*f1
= f0
->next
;
567 struct pullup_field
*f2
= f1
->next
;
568 struct pullup_field
*f3
= f2
->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
)
612 struct pullup_field
*f0
= f
;
613 const char aff_l
[] = "+..", aff_r
[] = "..+";
614 printf("\naffinity: ");
615 for (i
= 0; i
< 4; i
++) {
616 printf("%c%d%c", aff_l
[1+f
->affinity
], i
, aff_r
[1+f
->affinity
]);
620 printf("\nbreaks: ");
621 for (i
=0; i
<4; i
++) {
622 printf("%c%d%c", f
->breaks
& BREAK_LEFT
? '|' : '.', i
, f
->breaks
& BREAK_RIGHT
? '|' : '.');
632 struct pullup_frame
*pullup_get_frame(struct pullup_context
*c
)
635 struct pullup_frame
*fr
= c
->frame
;
636 int n
= decide_frame_length(c
);
637 int aff
= c
->first
->next
->affinity
;
640 if (fr
->lock
) return 0;
643 print_aff_and_breaks(c
, c
->first
);
644 printf("duration: %d \n", n
);
649 fr
->parity
= c
->first
->parity
;
651 for (i
= 0; i
< n
; i
++) {
652 /* We cheat and steal the buffer without release+relock */
653 fr
->ifields
[i
] = c
->first
->buffer
;
654 c
->first
->buffer
= 0;
655 c
->first
= c
->first
->next
;
659 fr
->ofields
[fr
->parity
] = fr
->ifields
[0];
660 fr
->ofields
[fr
->parity
^1] = 0;
662 fr
->ofields
[fr
->parity
] = fr
->ifields
[0];
663 fr
->ofields
[fr
->parity
^1] = fr
->ifields
[1];
666 aff
= (fr
->ifields
[0] == fr
->ifields
[1]) ? -1 : 1;
667 /* else if (c->verbose) printf("forced aff: %d \n", aff); */
668 fr
->ofields
[fr
->parity
] = fr
->ifields
[1+aff
];
669 fr
->ofields
[fr
->parity
^1] = fr
->ifields
[1];
671 pullup_lock_buffer(fr
->ofields
[0], 0);
672 pullup_lock_buffer(fr
->ofields
[1], 1);
674 if (fr
->ofields
[0] == fr
->ofields
[1]) {
675 fr
->buffer
= fr
->ofields
[0];
676 pullup_lock_buffer(fr
->buffer
, 2);
682 static void copy_field(struct pullup_context
*c
, struct pullup_buffer
*dest
,
683 struct pullup_buffer
*src
, int parity
)
686 unsigned char *d
, *s
;
687 for (i
= 0; i
< c
->nplanes
; i
++) {
688 s
= src
->planes
[i
] + parity
*c
->stride
[i
];
689 d
= dest
->planes
[i
] + parity
*c
->stride
[i
];
690 for (j
= c
->h
[i
]>>1; j
; j
--) {
691 memcpy(d
, s
, c
->stride
[i
]);
692 s
+= c
->stride
[i
]<<1;
693 d
+= c
->stride
[i
]<<1;
698 void pullup_pack_frame(struct pullup_context
*c
, struct pullup_frame
*fr
)
701 int par
= fr
->parity
;
702 if (fr
->buffer
) return;
703 if (fr
->length
< 2) return; /* FIXME: deal with this */
704 for (i
= 0; i
< 2; i
++)
706 if (fr
->ofields
[i
]->lock
[i
^1]) continue;
707 fr
->buffer
= fr
->ofields
[i
];
708 pullup_lock_buffer(fr
->buffer
, 2);
709 copy_field(c
, fr
->buffer
, fr
->ofields
[i
^1], i
^1);
712 fr
->buffer
= pullup_get_buffer(c
, 2);
713 copy_field(c
, fr
->buffer
, fr
->ofields
[0], 0);
714 copy_field(c
, fr
->buffer
, fr
->ofields
[1], 1);
717 void pullup_release_frame(struct pullup_frame
*fr
)
720 for (i
= 0; i
< fr
->length
; i
++)
721 pullup_release_buffer(fr
->ifields
[i
], fr
->parity
^ (i
&1));
722 pullup_release_buffer(fr
->ofields
[0], 0);
723 pullup_release_buffer(fr
->ofields
[1], 1);
724 if (fr
->buffer
) pullup_release_buffer(fr
->buffer
, 2);
733 struct pullup_context
*pullup_alloc_context(void)
735 struct pullup_context
*c
;
737 c
= calloc(1, sizeof(struct pullup_context
));
742 void pullup_preinit_context(struct pullup_context
*c
)
744 c
->bpp
= calloc(c
->nplanes
, sizeof(int));
745 c
->w
= calloc(c
->nplanes
, sizeof(int));
746 c
->h
= calloc(c
->nplanes
, sizeof(int));
747 c
->stride
= calloc(c
->nplanes
, sizeof(int));
748 c
->background
= calloc(c
->nplanes
, sizeof(int));
751 void pullup_init_context(struct pullup_context
*c
)
753 int mp
= c
->metric_plane
;
754 if (c
->nbuffers
< 10) c
->nbuffers
= 10;
755 c
->buffers
= calloc(c
->nbuffers
, sizeof (struct pullup_buffer
));
757 c
->metric_w
= (c
->w
[mp
] - ((c
->junk_left
+ c
->junk_right
) << 3)) >> 3;
758 c
->metric_h
= (c
->h
[mp
] - ((c
->junk_top
+ c
->junk_bottom
) << 1)) >> 3;
759 c
->metric_offset
= c
->junk_left
*c
->bpp
[mp
] + (c
->junk_top
<<1)*c
->stride
[mp
];
760 c
->metric_len
= c
->metric_w
* c
->metric_h
;
762 c
->head
= make_field_queue(c
, 8);
764 c
->frame
= calloc(1, sizeof (struct pullup_frame
));
765 c
->frame
->ifields
= calloc(3, sizeof (struct pullup_buffer
*));
774 if (c
->cpu
& PULLUP_CPU_MMX
) {
775 c
->diff
= diff_y_mmx
;
776 c
->comb
= licomb_y_mmx
;
781 /* c->comb = qpcomb_y; */
784 case PULLUP_FMT_YUY2
:
787 case PULLUP_FMT_RGB32
:
788 c
->diff
= diff_rgb32
;
794 void pullup_free_context(struct pullup_context
*c
)
796 struct pullup_field
*f
;
804 } while (f
!= c
->head
);