2011/03/21

ARM Address Access Problem

Convert odd size frame from NV12 format to YUV420 format.
Two problem happens
1. if odd size, last row or last col Y data does not have UV data to match
2. ldrh should start from EVEN address, otherwise data abortion will happen.

--------------
There problem happens in this line.
udata = *( uvPlaneData + ( y / 2 )* uvStride + ( x / 2 ) );

notice that "udata" and "uvPlaneData" are of type uint_16.

The assembly code generated for above code are:
...
mla r11,r3,r4,r7
add r5,r6,r5,ls1 #0x1
bic r6,r1,#0x1
ldrh r6,[r5,+r6]
...

Data abortion happens at first round of the FOR loop.
when x is 0 and y is 0, r5 stores the value of uvPlaneData, the start address of uvPlane.
r6 is 0 "ldrh r6,[r5,+r6]" loads the data at the start address of uvPlane to r6(udata).

When "ldrh r6,[r5,+r6]" executes, the data abortion happened!

Here is the reason:
1. ldrh stands for "half word load", and it should start at EVEN address.
2. when the frame is odd size, uvPlane starts at ODD address

So I changed the some data type from uint_16 to uint_8 to avoid generation of "ldrh" asm code.

No comments:

Post a Comment

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...