1 |
# Copyright (C) 2002 Guillaume Morin, Alcôve |
# Copyright (C) 2002 Guillaume Morin <guillaume@morinfr.org>, Alcôve |
2 |
# |
# |
3 |
# This program is free software; you can redistribute it and/or modify |
# This program is free software; you can redistribute it and/or modify |
4 |
# it under the terms of the GNU General Public License as published by |
# it under the terms of the GNU General Public License as published by |
19 |
# $Source$ |
# $Source$ |
20 |
# $Date$ |
# $Date$ |
21 |
# $Author$ |
# $Author$ |
22 |
|
# |
23 |
|
# This is my first PPC ASM program. So I might do nasty things. |
24 |
|
# Please send any comments to guillaume@morinfr.org |
25 |
|
|
26 |
|
|
27 |
|
# Returns a field of bits that indicates non zero ac blocks |
28 |
|
# for this macro block |
29 |
|
# |
30 |
#uint32_t calc_cbp_c(const int16_t codes[6][64]) |
#uint32_t calc_cbp_c(const int16_t codes[6][64]) |
31 |
#{ |
#{ |
32 |
# uint32_t i, j; |
# uint32_t i, j; |
33 |
# uint32_t cbp = 0; |
# uint32_t cbp = 0; |
34 |
# |
# |
35 |
# for (i = 0; i < 6; i++) { |
# for (i = 0; i < 6; i++) { |
36 |
# for (j = 1; j < 64/4; j+=4) { |
# for (j = 1; j < 61; j+=4) { |
37 |
# if (codes[i][j] |codes[i][j+1]| |
# if (codes[i][j] |codes[i][j+1]| |
38 |
# codes[i][j+2]|codes[i][j+3]) { |
# codes[i][j+2]|codes[i][j+3]) { |
39 |
# cbp |= 1 << (5 - i); |
# cbp |= 1 << (5 - i); |
40 |
# break; |
# break; |
41 |
# } |
# } |
42 |
# } |
# } |
43 |
|
# |
44 |
|
# if(codes[i][j]|codes[i][j+1]|codes[i][j+2]) |
45 |
|
# cbp |= 1 << (5 - i); |
46 |
|
# |
47 |
# } |
# } |
48 |
|
# |
49 |
# return cbp; |
# return cbp; |
50 |
|
# |
51 |
#} |
#} |
52 |
|
|
53 |
.text |
.text |
54 |
.global calc_cbp_ppc |
.global calc_cbp_ppc |
55 |
calc_cbp_ppc: |
calc_cbp_ppc: |
56 |
|
# r9 will contain coeffs addr |
57 |
mr 9,3 |
mr 9,3 |
58 |
|
# r8 is the loop counter |
59 |
li 8,5 |
li 8,5 |
60 |
|
# r3 contains the result, therefore we set it to 0 |
61 |
xor 3,3,3 |
xor 3,3,3 |
62 |
.loop: |
.loop: |
63 |
|
# r7 is the loop2 counter, FIXME: use CTR |
64 |
li 7,14 |
li 7,14 |
65 |
|
# r6 is coeff pointer for this line |
66 |
mr 6,9 |
mr 6,9 |
67 |
.loop2: |
.loop2: |
68 |
|
# coeffs is a matrix of 16 bits cells |
69 |
lha 4,2(6) |
lha 4,2(6) |
70 |
lha 5,4(6) |
lha 5,4(6) |
71 |
or 4,5,4 |
or 4,5,4 |
72 |
lha 5,6(6) |
lha 5,6(6) |
73 |
or 4,5,4 |
or 4,5,4 |
74 |
lha 5,8(6) |
lha 5,8(6) |
75 |
or 4,5,4 |
# or. updates CR0 |
76 |
cmpwi 4,0 |
or. 4,5,4 |
77 |
bne .cbp |
# testing bit 2 (is zero) of CR0 |
78 |
|
bf 2,.cbp |
79 |
addi 6,6,8 |
addi 6,6,8 |
80 |
subi 7,7,1 |
# subic. updates CR0 |
81 |
cmpwi 7,-1 |
subic. 7,7,1 |
82 |
beq .lastcoeffs |
# testing bit 0 (is negative) of CR0 |
83 |
|
bt 0,.lastcoeffs |
84 |
b .loop2 |
b .loop2 |
85 |
.lastcoeffs: |
.lastcoeffs: |
86 |
lha 4,2(6) |
lha 4,2(6) |
87 |
lha 5,4(6) |
lha 5,4(6) |
88 |
or 4,5,4 |
or 4,5,4 |
89 |
lha 5,6(6) |
lha 5,6(6) |
90 |
or 4,5,4 |
# or. updates CR0 |
91 |
cmpwi 4,0 |
or. 4,5,4 |
92 |
beq .newline |
# testing bit 2 (is zero) of CR0 |
93 |
|
bt 2,.newline |
94 |
.cbp: |
.cbp: |
95 |
li 4,1 |
li 4,1 |
96 |
slw 4,4,8 |
slw 4,4,8 |
98 |
b .newline |
b .newline |
99 |
.newline: |
.newline: |
100 |
addi 9,9,128 |
addi 9,9,128 |
101 |
subi 8,8,1 |
# updates CR0, blabla |
102 |
cmpwi 8,-1 |
subic. 8,8,1 |
103 |
bne .loop |
bf 0,.loop |
104 |
.end: |
.end: |
105 |
blr |
blr |