1 --- libmpeg2/cpu_accel.c 2006-06-16 20:12:26.000000000 +0200
2 +++ libmpeg2/cpu_accel.c 2006-06-16 20:12:50.000000000 +0200
7 +#include "cpudetect.h"
12 #include "mpeg2_internal.h"
16 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
18 +/* MPlayer imports libmpeg2 as decoder, which detects MMX / 3DNow!
19 + * instructions via assembly. However, it is regarded as duplicated work
20 + * in MPlayer, so that we enforce using MPlayer's implementation.
22 +#define USE_MPLAYER_CPUDETECT
24 static inline uint32_t arch_accel (void)
26 +#if !defined(USE_MPLAYER_CPUDETECT)
27 uint32_t eax, ebx, ecx, edx;
31 caps |= MPEG2_ACCEL_X86_MMXEXT;
34 +#else /* USE_MPLAYER_CPUDETECT: Use MPlayer's CPU capability property. */
36 + if (gCpuCaps.hasMMX)
37 + caps |= MPEG2_ACCEL_X86_MMX;
38 + if (gCpuCaps.hasSSE2)
39 + caps |= MPEG2_ACCEL_X86_SSE2;
40 + if (gCpuCaps.hasMMX2)
41 + caps |= MPEG2_ACCEL_X86_MMXEXT;
42 + if (gCpuCaps.has3DNow)
43 + caps |= MPEG2_ACCEL_X86_3DNOW;
47 +#endif /* USE_MPLAYER_CPUDETECT */
49 -#endif /* ARCH_X86 */
50 +#endif /* ARCH_X86 || ARCH_X86_64 */
52 #if defined(ARCH_PPC) || defined(ARCH_SPARC)
57 -#ifdef HAVE_ALTIVEC_H /* gnu */
58 -#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
60 +#if defined(__APPLE_CC__) /* apple */
61 #define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t"
63 +#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
65 asm volatile ("mtspr 256, %0\n\t"
71 -#if defined (ARCH_X86) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
72 +#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
73 accel = arch_accel ();
76 --- libmpeg2/cpu_state.c 2006-06-16 20:12:26.000000000 +0200
77 +++ libmpeg2/cpu_state.c 2006-06-16 20:12:50.000000000 +0200
80 #include "attributes.h"
81 #include "mpeg2_internal.h"
83 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
87 void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
88 void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
91 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
92 static void state_restore_mmx (cpu_state_t * state)
99 -#ifdef HAVE_ALTIVEC_H /* gnu */
100 -#define LI(a,b) "li " #a "," #b "\n\t"
101 -#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
102 -#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
103 -#define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t"
104 -#define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t"
106 +#if defined(__APPLE_CC__) /* apple */
107 #define LI(a,b) "li r" #a "," #b "\n\t"
108 #define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t"
109 #define STVX(a,b,c) "stvx v" #a ",r" #b ",r" #c "\n\t"
110 #define LVX0(a,b,c) "lvx v" #a ",0,r" #c "\n\t"
111 #define LVX(a,b,c) "lvx v" #a ",r" #b ",r" #c "\n\t"
113 +#define LI(a,b) "li " #a "," #b "\n\t"
114 +#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
115 +#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
116 +#define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t"
117 +#define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t"
120 static void state_save_altivec (cpu_state_t * state)
123 void mpeg2_cpu_state_init (uint32_t accel)
126 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
127 if (accel & MPEG2_ACCEL_X86_MMX) {
128 mpeg2_cpu_state_restore = state_restore_mmx;
132 --- libmpeg2/decode.c 2006-06-16 20:12:26.000000000 +0200
133 +++ libmpeg2/decode.c 2006-06-16 20:12:50.000000000 +0200
135 fbuf->buf[1] = buf[1];
136 fbuf->buf[2] = buf[2];
138 + // HACK! FIXME! At first I frame, copy pointers to prediction frame too!
139 + if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){
140 + mpeg2dec->fbuf[1]->buf[0]=buf[0];
141 + mpeg2dec->fbuf[1]->buf[1]=buf[1];
142 + mpeg2dec->fbuf[1]->buf[2]=buf[2];
143 + mpeg2dec->fbuf[1]->id=NULL;
145 +// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
146 +// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
149 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
150 --- libmpeg2/header.c 2006-06-16 20:12:26.000000000 +0200
151 +++ libmpeg2/header.c 2006-06-16 20:12:50.000000000 +0200
153 mpeg2dec->decoder.convert = NULL;
154 mpeg2dec->decoder.convert_id = NULL;
155 mpeg2dec->picture = mpeg2dec->pictures;
156 + memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
157 + memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t));
158 + memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t));
159 mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf;
160 mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf;
161 mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf;
163 if (!(mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)) {
164 picture->nb_fields = (buffer[3] & 2) ? 3 : 2;
165 flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0;
166 + flags |= (buffer[3] & 2) ? PIC_FLAG_REPEAT_FIRST_FIELD : 0;
168 picture->nb_fields = (buffer[3]&2) ? ((buffer[3]&128) ? 6 : 4) : 2;
171 mpeg2dec->scaled[index] = mpeg2dec->q_scale_type;
172 for (i = 0; i < 32; i++) {
173 k = mpeg2dec->q_scale_type ? non_linear_scale[i] : (i << 1);
174 + decoder->quantizer_scales[i] = k;
175 for (j = 0; j < 64; j++)
176 decoder->quantizer_prescale[index][i][j] =
177 k * mpeg2dec->quantizer_matrix[index][j];
178 --- libmpeg2/idct.c (revision 26652)
179 +++ libmpeg2/idct.c (working copy)
181 mpeg2_idct_mmx_init ();
186 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
187 mpeg2_idct_copy = mpeg2_idct_copy_altivec;
188 mpeg2_idct_add = mpeg2_idct_add_altivec;
189 --- libmpeg2/idct_mmx.c 2006-06-16 20:12:26.000000000 +0200
190 +++ libmpeg2/idct_mmx.c 2006-06-16 20:12:50.000000000 +0200
196 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
198 #include <inttypes.h>
200 --- libmpeg2/motion_comp.c 2006-06-16 20:12:26.000000000 +0200
201 +++ libmpeg2/motion_comp.c 2006-06-16 20:12:50.000000000 +0200
203 mpeg2_mc = mpeg2_mc_mmx;
208 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
209 mpeg2_mc = mpeg2_mc_altivec;
212 mpeg2_mc = mpeg2_mc_vis;
216 + if (accel & MPEG2_ACCEL_ARM_IWMMXT)
217 + mpeg2_mc = mpeg2_mc_iwmmxt;
218 + else if (accel & MPEG2_ACCEL_ARM)
219 + mpeg2_mc = mpeg2_mc_arm;
222 mpeg2_mc = mpeg2_mc_c;
225 --- libmpeg2/motion_comp_mmx.c 2006-06-16 20:12:26.000000000 +0200
226 +++ libmpeg2/motion_comp_mmx.c 2006-06-16 20:12:50.000000000 +0200
232 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
234 #include <inttypes.h>
236 --- include/mpeg2.h 2006-06-16 20:12:26.000000000 +0200
237 +++ libmpeg2/mpeg2.h 2006-06-16 20:12:50.000000000 +0200
239 #define PIC_FLAG_COMPOSITE_DISPLAY 32
240 #define PIC_FLAG_SKIP 64
241 #define PIC_FLAG_TAGS 128
242 +#define PIC_FLAG_REPEAT_FIRST_FIELD 256
243 #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
245 typedef struct mpeg2_picture_s {
246 @@ -156,10 +160,13 @@
247 #define MPEG2_ACCEL_X86_3DNOW 2
248 #define MPEG2_ACCEL_X86_MMXEXT 4
249 +#define MPEG2_ACCEL_X86_SSE2 8
250 #define MPEG2_ACCEL_PPC_ALTIVEC 1
251 #define MPEG2_ACCEL_ALPHA 1
252 #define MPEG2_ACCEL_ALPHA_MVI 2
253 #define MPEG2_ACCEL_SPARC_VIS 1
254 #define MPEG2_ACCEL_SPARC_VIS2 2
255 +#define MPEG2_ACCEL_ARM 1
256 +#define MPEG2_ACCEL_ARM_IWMMXT 2
257 #define MPEG2_ACCEL_DETECT 0x80000000
259 uint32_t mpeg2_accel (uint32_t accel);
260 --- libmpeg2/mpeg2_internal.h 2006-06-16 20:12:26.000000000 +0200
261 +++ libmpeg2/mpeg2_internal.h 2006-06-16 20:12:50.000000000 +0200
267 + int quantizer_scales[32];
268 + int quantizer_scale;
275 int8_t q_scale_type, scaled[4];
276 uint8_t quantizer_matrix[4][64];
277 uint8_t new_quantizer_matrix[4][64];
279 + unsigned char *pending_buffer;
280 + int pending_length;
285 extern mpeg2_mc_t mpeg2_mc_altivec;
286 extern mpeg2_mc_t mpeg2_mc_alpha;
287 extern mpeg2_mc_t mpeg2_mc_vis;
288 +extern mpeg2_mc_t mpeg2_mc_arm;
289 +extern mpeg2_mc_t mpeg2_mc_iwmmxt;
290 --- libmpeg2/slice.c 2006-06-16 20:12:26.000000000 +0200
291 +++ libmpeg2/slice.c 2006-06-16 20:12:50.000000000 +0200
294 quantizer_scale_code = UBITS (bit_buf, 5);
295 DUMPBITS (bit_buf, bits, 5);
296 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];
298 decoder->quantizer_matrix[0] =
299 decoder->quantizer_prescale[0][quantizer_scale_code];
300 @@ -1568,6 +1569,18 @@
302 #define NEXT_MACROBLOCK \
304 + if(decoder->quant_store) { \
305 + if (decoder->picture_structure == TOP_FIELD) \
306 + decoder->quant_store[2*decoder->quant_stride*(decoder->v_offset>>4) \
307 + +(decoder->offset>>4)] = decoder->quantizer_scale; \
308 + else if (decoder->picture_structure == BOTTOM_FIELD) \
309 + decoder->quant_store[2*decoder->quant_stride*(decoder->v_offset>>4) \
310 + + decoder->quant_stride \
311 + +(decoder->offset>>4)] = decoder->quantizer_scale; \
313 + decoder->quant_store[decoder->quant_stride*(decoder->v_offset>>4) \
314 + +(decoder->offset>>4)] = decoder->quantizer_scale; \
316 decoder->offset += 16; \
317 if (decoder->offset == decoder->width) { \
318 do { /* just so we can use the break statement */ \
319 @@ -1604,6 +1604,12 @@
323 +static void motion_dummy (mpeg2_decoder_t * const decoder,
324 + motion_t * const motion,
325 + mpeg2_mc_fct * const * const table)
329 void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
330 uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3])
332 @@ -1661,7 +1667,9 @@
334 if (decoder->mpeg1) {
335 decoder->motion_parser[0] = motion_zero_420;
336 + decoder->motion_parser[MC_FIELD] = motion_dummy;
337 decoder->motion_parser[MC_FRAME] = motion_mp1;
338 + decoder->motion_parser[MC_DMV] = motion_dummy;
339 decoder->motion_parser[4] = motion_reuse_420;
340 } else if (decoder->picture_structure == FRAME_PICTURE) {
341 if (decoder->chroma_format == 0) {
342 --- libmpeg2/idct_altivec.c 2004/08/02 11:26:43 12933
343 +++ libmpeg2/idct_altivec.c 2005/05/15 20:11:34 15484
345 typedef vector signed int vector_s32_t;
346 typedef vector unsigned int vector_u32_t;
348 -#if defined(HAVE_ALTIVEC_H) && (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
349 +#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_CC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
350 /* work around gcc <3.3 vec_mergel bug */
351 static inline vector_s16_t my_vec_mergel (vector_s16_t const A,
352 vector_s16_t const B)
354 #define vec_mergel my_vec_mergel
357 -#ifdef HAVE_ALTIVEC_H /* gnu */
358 -#define VEC_S16(a,b,c,d,e,f,g,h) {a, b, c, d, e, f, g, h}
360 +#if defined(__APPLE_CC__) /* apple */
361 #define VEC_S16(a,b,c,d,e,f,g,h) (vector_s16_t) (a, b, c, d, e, f, g, h)
363 +#define VEC_S16(a,b,c,d,e,f,g,h) {a, b, c, d, e, f, g, h}
366 static const vector_s16_t constants ATTR_ALIGN(16) =
367 Index: libmpeg2/motion_comp_arm.c
368 ===================================================================
369 --- libmpeg2/motion_comp_arm.c (revision 0)
370 +++ libmpeg2/motion_comp_arm.c (revision 0)
373 + * motion_comp_arm.c
374 + * Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
376 + * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
377 + * See http://libmpeg2.sourceforge.net/ for updates.
379 + * mpeg2dec is free software; you can redistribute it and/or modify
380 + * it under the terms of the GNU General Public License as published by
381 + * the Free Software Foundation; either version 2 of the License, or
382 + * (at your option) any later version.
384 + * mpeg2dec is distributed in the hope that it will be useful,
385 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
386 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
387 + * GNU General Public License for more details.
389 + * You should have received a copy of the GNU General Public License
390 + * along with this program; if not, write to the Free Software
391 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
398 +#include <inttypes.h>
401 +#include "attributes.h"
402 +#include "mpeg2_internal.h"
404 +#define avg2(a,b) ((a+b+1)>>1)
405 +#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
407 +#define predict_o(i) (ref[i])
408 +#define predict_x(i) (avg2 (ref[i], ref[i+1]))
409 +#define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
410 +#define predict_xy(i) (avg4 (ref[i], ref[i+1], \
411 + (ref+stride)[i], (ref+stride)[i+1]))
413 +#define put(predictor,i) dest[i] = predictor (i)
414 +#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
416 +/* mc function template */
418 +#define MC_FUNC(op,xy) \
419 +static void inline MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
420 + const int stride, int height) \
423 + op (predict_##xy, 0); \
424 + op (predict_##xy, 1); \
425 + op (predict_##xy, 2); \
426 + op (predict_##xy, 3); \
427 + op (predict_##xy, 4); \
428 + op (predict_##xy, 5); \
429 + op (predict_##xy, 6); \
430 + op (predict_##xy, 7); \
431 + op (predict_##xy, 8); \
432 + op (predict_##xy, 9); \
433 + op (predict_##xy, 10); \
434 + op (predict_##xy, 11); \
435 + op (predict_##xy, 12); \
436 + op (predict_##xy, 13); \
437 + op (predict_##xy, 14); \
438 + op (predict_##xy, 15); \
441 + } while (--height); \
443 +static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
444 + const int stride, int height) \
447 + op (predict_##xy, 0); \
448 + op (predict_##xy, 1); \
449 + op (predict_##xy, 2); \
450 + op (predict_##xy, 3); \
451 + op (predict_##xy, 4); \
452 + op (predict_##xy, 5); \
453 + op (predict_##xy, 6); \
454 + op (predict_##xy, 7); \
457 + } while (--height); \
459 +/* definitions of the actual mc functions */
471 +extern void MC_put_o_16_arm (uint8_t * dest, const uint8_t * ref,
472 + int stride, int height);
474 +extern void MC_put_x_16_arm (uint8_t * dest, const uint8_t * ref,
475 + int stride, int height);
478 +static void MC_put_y_16_arm (uint8_t * dest, const uint8_t * ref,
479 + int stride, int height)
481 + MC_put_y_16_c(dest, ref, stride, height);
484 +static void MC_put_xy_16_arm (uint8_t * dest, const uint8_t * ref,
485 + int stride, int height)
487 + MC_put_xy_16_c(dest, ref, stride, height);
490 +extern void MC_put_o_8_arm (uint8_t * dest, const uint8_t * ref,
491 + int stride, int height);
493 +extern void MC_put_x_8_arm (uint8_t * dest, const uint8_t * ref,
494 + int stride, int height);
496 +static void MC_put_y_8_arm (uint8_t * dest, const uint8_t * ref,
497 + int stride, int height)
499 + MC_put_y_8_c(dest, ref, stride, height);
502 +static void MC_put_xy_8_arm (uint8_t * dest, const uint8_t * ref,
503 + int stride, int height)
505 + MC_put_xy_8_c(dest, ref, stride, height);
508 +static void MC_avg_o_16_arm (uint8_t * dest, const uint8_t * ref,
509 + int stride, int height)
511 + MC_avg_o_16_c(dest, ref, stride, height);
514 +static void MC_avg_x_16_arm (uint8_t * dest, const uint8_t * ref,
515 + int stride, int height)
517 + MC_avg_x_16_c(dest, ref, stride, height);
520 +static void MC_avg_y_16_arm (uint8_t * dest, const uint8_t * ref,
521 + int stride, int height)
523 + MC_avg_y_16_c(dest, ref, stride, height);
526 +static void MC_avg_xy_16_arm (uint8_t * dest, const uint8_t * ref,
527 + int stride, int height)
529 + MC_avg_xy_16_c(dest, ref, stride, height);
532 +static void MC_avg_o_8_arm (uint8_t * dest, const uint8_t * ref,
533 + int stride, int height)
535 + MC_avg_o_8_c(dest, ref, stride, height);
538 +static void MC_avg_x_8_arm (uint8_t * dest, const uint8_t * ref,
539 + int stride, int height)
541 + MC_avg_x_8_c(dest, ref, stride, height);
544 +static void MC_avg_y_8_arm (uint8_t * dest, const uint8_t * ref,
545 + int stride, int height)
547 + MC_avg_y_8_c(dest, ref, stride, height);
550 +static void MC_avg_xy_8_arm (uint8_t * dest, const uint8_t * ref,
551 + int stride, int height)
553 + MC_avg_xy_8_c(dest, ref, stride, height);
556 +MPEG2_MC_EXTERN (arm)
559 Index: libmpeg2/motion_comp_arm_s.S
560 ===================================================================
561 --- libmpeg2/motion_comp_arm_s.S (revision 0)
562 +++ libmpeg2/motion_comp_arm_s.S (revision 0)
564 +@ motion_comp_arm_s.S
565 +@ Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
567 +@ This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
568 +@ See http://libmpeg2.sourceforge.net/ for updates.
570 +@ mpeg2dec is free software; you can redistribute it and/or modify
571 +@ it under the terms of the GNU General Public License as published by
572 +@ the Free Software Foundation; either version 2 of the License, or
573 +@ (at your option) any later version.
575 +@ mpeg2dec is distributed in the hope that it will be useful,
576 +@ but WITHOUT ANY WARRANTY; without even the implied warranty of
577 +@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
578 +@ GNU General Public License for more details.
580 +@ You should have received a copy of the GNU General Public License
581 +@ along with this program; if not, write to the Free Software
582 +@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
586 +@ ----------------------------------------------------------------
588 + .global MC_put_o_16_arm
590 + @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
592 + stmfd sp!, {r4-r11, lr} @ R14 is also called LR
594 + adr r5, MC_put_o_16_arm_align_jt
595 + add r5, r5, r4, lsl #2
598 +MC_put_o_16_arm_align0:
605 + bne MC_put_o_16_arm_align0
606 + ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
611 + mov r9, r4, lsr #(\shift)
613 + mov r10, r5, lsr #(\shift)
614 + orr r9, r9, r5, lsl #(32-\shift)
615 + mov r11, r6, lsr #(\shift)
616 + orr r10, r10, r6, lsl #(32-\shift)
617 + mov r12, r7, lsr #(\shift)
618 + orr r11, r11, r7, lsl #(32-\shift)
619 + orr r12, r12, r8, lsl #(32-\shift)
625 +MC_put_o_16_arm_align1:
626 + and r1, r1, #0xFFFFFFFC
629 + ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
630 +MC_put_o_16_arm_align2:
631 + and r1, r1, #0xFFFFFFFC
634 + ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
635 +MC_put_o_16_arm_align3:
636 + and r1, r1, #0xFFFFFFFC
639 + ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
640 +MC_put_o_16_arm_align_jt:
641 + .word MC_put_o_16_arm_align0
642 + .word MC_put_o_16_arm_align1
643 + .word MC_put_o_16_arm_align2
644 + .word MC_put_o_16_arm_align3
646 +@ ----------------------------------------------------------------
648 + .global MC_put_o_8_arm
650 + @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
652 + stmfd sp!, {r4-r10, lr} @ R14 is also called LR
654 + adr r5, MC_put_o_8_arm_align_jt
655 + add r5, r5, r4, lsl #2
657 +MC_put_o_8_arm_align0:
664 + bne MC_put_o_8_arm_align0
665 + ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
670 + mov r9, r4, lsr #(\shift)
672 + mov r10, r5, lsr #(\shift)
673 + orr r9, r9, r5, lsl #(32-\shift)
674 + orr r10, r10, r6, lsl #(32-\shift)
680 +MC_put_o_8_arm_align1:
681 + and r1, r1, #0xFFFFFFFC
684 + ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
686 +MC_put_o_8_arm_align2:
687 + and r1, r1, #0xFFFFFFFC
690 + ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
692 +MC_put_o_8_arm_align3:
693 + and r1, r1, #0xFFFFFFFC
696 + ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
698 +MC_put_o_8_arm_align_jt:
699 + .word MC_put_o_8_arm_align0
700 + .word MC_put_o_8_arm_align1
701 + .word MC_put_o_8_arm_align2
702 + .word MC_put_o_8_arm_align3
704 +@ ----------------------------------------------------------------
705 +.macro AVG_PW rW1, rW2
706 + mov \rW2, \rW2, lsl #24
707 + orr \rW2, \rW2, \rW1, lsr #8
709 + and \rW2, \rW1, \rW2
711 + add \rW2, \rW2, r10, lsr #1
713 + add \rW2, \rW2, r10
717 + .global MC_put_x_16_arm
719 + @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
721 + stmfd sp!, {r4-r11,lr} @ R14 is also called LR
723 + adr r5, MC_put_x_16_arm_align_jt
726 + add r5, r5, r4, lsl #2
729 +.macro ADJ_ALIGN_QW shift, R0, R1, R2, R3, R4
730 + mov \R0, \R0, lsr #(\shift)
731 + orr \R0, \R0, \R1, lsl #(32 - \shift)
732 + mov \R1, \R1, lsr #(\shift)
733 + orr \R1, \R1, \R2, lsl #(32 - \shift)
734 + mov \R2, \R2, lsr #(\shift)
735 + orr \R2, \R2, \R3, lsl #(32 - \shift)
736 + mov \R3, \R3, lsr #(\shift)
737 + orr \R3, \R3, \R4, lsl #(32 - \shift)
738 + mov \R4, \R4, lsr #(\shift)
739 +@ and \R4, \R4, #0xFF
742 +MC_put_x_16_arm_align0:
753 + bne MC_put_x_16_arm_align0
754 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
755 +MC_put_x_16_arm_align1:
756 + and r1, r1, #0xFFFFFFFC
757 +1: ldmia r1, {r4-r8}
760 + ADJ_ALIGN_QW 8, r4, r5, r6, r7, r8
769 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
770 +MC_put_x_16_arm_align2:
771 + and r1, r1, #0xFFFFFFFC
772 +1: ldmia r1, {r4-r8}
775 + ADJ_ALIGN_QW 16, r4, r5, r6, r7, r8
784 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
785 +MC_put_x_16_arm_align3:
786 + and r1, r1, #0xFFFFFFFC
787 +1: ldmia r1, {r4-r8}
790 + ADJ_ALIGN_QW 24, r4, r5, r6, r7, r8
799 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
800 +MC_put_x_16_arm_align_jt:
802 + .word MC_put_x_16_arm_align0
803 + .word MC_put_x_16_arm_align1
804 + .word MC_put_x_16_arm_align2
805 + .word MC_put_x_16_arm_align3
807 +@ ----------------------------------------------------------------
809 + .global MC_put_x_8_arm
811 + @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
813 + stmfd sp!, {r4-r11,lr} @ R14 is also called LR
815 + adr r5, MC_put_x_8_arm_align_jt
818 + add r5, r5, r4, lsl #2
821 +.macro ADJ_ALIGN_DW shift, R0, R1, R2
822 + mov \R0, \R0, lsr #(\shift)
823 + orr \R0, \R0, \R1, lsl #(32 - \shift)
824 + mov \R1, \R1, lsr #(\shift)
825 + orr \R1, \R1, \R2, lsl #(32 - \shift)
826 + mov \R2, \R2, lsr #(\shift)
827 +@ and \R4, \R4, #0xFF
830 +MC_put_x_8_arm_align0:
839 + bne MC_put_x_8_arm_align0
840 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
841 +MC_put_x_8_arm_align1:
842 + and r1, r1, #0xFFFFFFFC
843 +1: ldmia r1, {r4-r6}
846 + ADJ_ALIGN_DW 8, r4, r5, r6
853 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
854 +MC_put_x_8_arm_align2:
855 + and r1, r1, #0xFFFFFFFC
856 +1: ldmia r1, {r4-r6}
859 + ADJ_ALIGN_DW 16, r4, r5, r6
866 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
867 +MC_put_x_8_arm_align3:
868 + and r1, r1, #0xFFFFFFFC
869 +1: ldmia r1, {r4-r6}
872 + ADJ_ALIGN_DW 24, r4, r5, r6
879 + ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
880 +MC_put_x_8_arm_align_jt:
882 + .word MC_put_x_8_arm_align0
883 + .word MC_put_x_8_arm_align1
884 + .word MC_put_x_8_arm_align2
885 + .word MC_put_x_8_arm_align3
886 Index: libmpeg2/motion_comp_iwmmxt.c
887 ===================================================================
888 --- libmpeg2/motion_comp_iwmmxt.c (revision 0)
889 +++ libmpeg2/motion_comp_iwmmxt.c (revision 0)
892 + * motion_comp_iwmmxt.c
893 + * Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
895 + * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
896 + * See http://libmpeg2.sourceforge.net/ for updates.
898 + * mpeg2dec is free software; you can redistribute it and/or modify
899 + * it under the terms of the GNU General Public License as published by
900 + * the Free Software Foundation; either version 2 of the License, or
901 + * (at your option) any later version.
903 + * mpeg2dec is distributed in the hope that it will be useful,
904 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
905 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
906 + * GNU General Public License for more details.
908 + * You should have received a copy of the GNU General Public License
909 + * along with this program; if not, write to the Free Software
910 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
915 +#if defined(ARCH_ARM) && defined(HAVE_IWMMXT)
917 +#include <inttypes.h>
920 +#include "attributes.h"
921 +#include "mpeg2_internal.h"
923 +/* defined in libavcodec */
925 +extern void put_pixels16_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
926 +extern void put_pixels16_x2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
927 +extern void put_pixels16_y2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
928 +extern void put_pixels16_xy2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
929 +extern void put_pixels8_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
930 +extern void put_pixels8_x2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
931 +extern void put_pixels8_y2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
932 +extern void put_pixels8_xy2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
933 +extern void avg_pixels16_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
934 +extern void avg_pixels16_x2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
935 +extern void avg_pixels16_y2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
936 +extern void avg_pixels16_xy2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
937 +extern void avg_pixels8_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
938 +extern void avg_pixels8_x2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
939 +extern void avg_pixels8_y2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
940 +extern void avg_pixels8_xy2_iwmmxt(uint8_t * dest, const uint8_t * ref, const int stride, int height);
942 +mpeg2_mc_t mpeg2_mc_iwmmxt = {
943 + {put_pixels16_iwmmxt, put_pixels16_x2_iwmmxt, put_pixels16_y2_iwmmxt, put_pixels16_xy2_iwmmxt,
944 + put_pixels8_iwmmxt, put_pixels8_x2_iwmmxt, put_pixels8_y2_iwmmxt, put_pixels8_xy2_iwmmxt}, \
945 + {avg_pixels16_iwmmxt, avg_pixels16_x2_iwmmxt, avg_pixels16_y2_iwmmxt, avg_pixels16_xy2_iwmmxt,
946 + avg_pixels8_iwmmxt, avg_pixels8_x2_iwmmxt, avg_pixels8_y2_iwmmxt, avg_pixels8_xy2_iwmmxt}, \
949 +#endif /* defined(ARCH_ARM) && defined(HAVE_IWMMXT) */