Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
46
Добавлен:
27.04.2015
Размер:
4.26 Mб
Скачать

B.1.12 N Point 3x3 2-D FIR Convolution

The two-dimensional FIR uses a 3x3 coefficient mask as shown in Figure B-9.

c11 c12 c13

c21 c22 c23

c31 c32 c33

AA0087

Figure B-9. 3x3 Coefficient Mask

The image is an array of 512 pixels x 512 pixels. To provide boundary conditions for the FIR filtering, the image is surrounded by a set of zeros such that the image is actually stored as a 514x514 array (see Figure B-10).

 

 

514

 

0

0

 

0

0

 

512

0

 

 

 

 

 

 

514

0

Image

 

0

 

Area

 

 

0

0

 

0

AA0088

Figure B-10. Image Stored as 514x514 Array

The image (with boundary) is stored in row-major storage. The first element of the array image is image(1,1) followed by image(1,2). The last element of the first row is image(1,514) followed by the beginning of the next column image(2,1). These are stored sequentially in the array “im” in d memory. For example:

Image(1,1) maps to index 0.

Image(1,514) maps to index 513.

Image(2,1) maps to index 514.

See Table B-2 for the definitions of r0, r2, and r3.

Although many other implementations are possible, this is a realistic type of image environment where the actual size of the image may not be an exact power of two. Other possibilities include storing a 512x512 image but computing only a 511x511 result, computing a 512x512 result without boundary conditions but throwing away the pixels on the border, and so on.

Table B-2. Variable Descriptions

Variable

 

Description

 

 

 

 

 

 

 

 

 

 

 

r0

image(n,m)

image(n,m+1)

image(n,m+2)

 

 

 

 

 

image(n+514,m)

image(n+514,m+1)

image(n+514,m+2)

 

 

 

 

 

image(n+2*514,m)

image(n+2*514,m+1)

image(n+2*514,m+2)

 

 

 

 

 

r2

output image

 

 

 

 

 

 

 

 

r3

FIR coefficients

 

 

 

 

 

 

 

 

 

DSP Benchmarks

B-17

opt

cc

 

 

 

 

 

move

#coeffs,r3

 

 

; 2

2

pt to coef.

move

#image,r0

 

 

; 2

2

top boundary

move

#512,y1

 

 

; 2

2

 

move

#-1029,r1

 

 

; 2

2

 

move

#output,r2

 

 

; 2

2

output image

move

 

x:(r0)+,y0

x:(r3)+,x0

; 1

1

y0=im(1,1 ),

 

 

 

 

 

 

x0=c11

move

y1,n

 

 

; 1

1

row i to i+1

 

 

 

 

 

 

adjust

push

lc

 

 

; 1

1

 

push

la

 

 

; 1

1

 

do

y1,rows

 

 

; 2

3

 

push

lc

 

 

; 1

1

 

push

la

 

 

; 1

1

 

do

y1,cols

 

 

; 2

3

 

mpy

y0,x0,a

x:(r0)+,y0

x:(r3)+,x0

; 1

1

im(1,1)*c11

mac

y0,x0,a

x:(r0)+n,y0

x:(r3)+,x0

; 1

1

+im(1,2)*c12

mac

y0,x0,a

x:(r0)+,y0

x:(r3)+,x0

; 1

1

+im(1,3)*c13

mac

y0,x0,a

x:(r0)+,y0

x:(r3)+,x0

; 1

1

+im(2,1)*c21

mac

y0,x0,a

x:(r0)+n,y0

x:(r3)+,x0

; 1

1

+im(2,2)*c22

move

r1,n

 

 

; 1

1

row i to i-2

 

 

 

 

 

 

adjust

mac

y0,x0,a

x:(r0)+,y0

x:(r3)+,x0

; 1

1

+im(2,3)*c23

mac

y0,x0,a

x:(r0)+,y0

x:(r3)+,x0

; 1

1

+im(3,1)*c31

mac

y0,x0,a

x:(r0)+n,y0

x:(r3)+,x0

; 1

1

+im(3,2)*c32

move

#0,r3

 

 

; 1

1

back to first

 

 

 

 

 

 

coeff

move

y1,n

 

 

; 1

1

row i to i+1

 

 

 

 

 

 

adjust

macr

y0,x0,a

x:(r0)+,y0

x:(r3)+,x0

; 1

1

+im(3,3)*c33

move

a,x:(r2)+

 

 

; 1

1

 

cols

 

 

 

 

 

 

pop

la

 

 

; 1

1

 

pop

lc

 

 

; 1

1

 

;adjust pointers for frame boundary

lea

(r0)+

; 1

1

adjust

r0

lea

(r0)+

; 1

1

 

 

lea

(r2)+

;

1

1

adjust

r2

lea

(r2)+

;

1

1

 

 

rows

B-18

DSP56800 Family Manual

 

pop

la

 

; 1

1

pop

lc

 

; 1

1

 

 

 

; _______ 2

;

 

Total:

41

13N +11N+16

;

 

 

 

Kernel: 13

 

DSP Benchmarks

B-19

Соседние файлы в папке DSP568xx