我在C语言里面调用内嵌的neon汇编的时候,算法运行两次后发生stopped错误,最后发现是内嵌的参数属性错误,于是我调换了参数的位置和某个参数的读写属性
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <chrono>
#include <arm_neon.h>
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
struct YUVBufferAddr{
unsigned char* Yaddr;
unsigned char* Uaddr;
unsigned char* Vaddr;
};
class q_timer {
public:
void start()
{
m_start = std::chrono::steady_clock::now();
}
double stop()
{
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::duration<double> >(end - m_start).count();
}
void time_display(const char *disp = "", int nr_frame = 1)
{
printf("Running time (%s) is: %5.5f Seconds.\n", disp, stop() / nr_frame);
}
void fps_display(const char *disp = "", int nr_frame = 1)
{
printf("Running time (%s) is: %5.5f frame per second.\n", disp, (double)nr_frame / stop());
}
private:
std::chrono::steady_clock::time_point m_start;
};
void ImgYUV2RGB24_neon(unsigned char *pu8RgbBuffer,
unsigned char *pu8SrcYUV,
int l32Width,
int l32Height,
unsigned char* u ,
unsigned char* v)
{
asm volatile (
"add r4, %2, %2 , lsl #1 \n"
"mul r5, r4, %3 \n"
"sub r5, r5, r4 \n"
"mul r5, %2, %3 \n"
"add %4, %1, r5 \n"
"add %5, %4, r5, lsr #2 \n"
"mov r8, %2, lsr #3 \n"
"mov r11, %3, lsr #1 \n"
"add %3, %1, %2 \n"