|
目的 使用 rga 转码yuv->rgba 并旋转
代码如下
/**
* 转码 + 旋转
* @param src
* @param srcFmt
* @param dst
* @param dstFmt
* @param width
* @param height
* @param roation
* @return
*/
int process(void *src, int srcFmt, void *dst, int dstFmt, int width, int height, int roation) {
int ret;
int ret_convert;
int middle_len = width * height * 4;
void *dst_middle = malloc(middle_len);
memset(dst_middle, 0, middle_len);
rga_buffer_t rga_src = wrapbuffer_virtualaddr((void *) src, width, height, srcFmt);
rga_buffer_t rga_dst_middle = wrapbuffer_virtualaddr((void *) dst_middle, width, height,
dstFmt);
ret_convert = imcvtcolor(rga_src, rga_dst_middle, srcFmt, dstFmt);
if (IM_STATUS_SUCCESS != ret_convert) {
LOGE("colorConvert failed. Ret: %s\n", imStrError((IM_STATUS) ret));
return IM_STATUS_FAILED;
}
rga_buffer_t rga_middle_src = wrapbuffer_virtualaddr((void *) dst_middle, width, height,
dstFmt);
rga_buffer_t rga_dst = wrapbuffer_virtualaddr((void *) dst, width, height, dstFmt);
LOGE("rotation step.\n");
rga_dst.width = rga_dst_middle.height;
rga_dst.height = rga_dst_middle.width;
rga_dst.wstride = rga_dst_middle.hstride;
rga_dst.hstride = rga_dst_middle.wstride;
int rotate = IM_HAL_TRANSFORM_ROT_90;
if (roation == 90) {
rotate = IM_HAL_TRANSFORM_ROT_90;
} else if (roation == 180) {
rotate = IM_HAL_TRANSFORM_ROT_180;
} else if (roation == 270) {
rotate = IM_HAL_TRANSFORM_ROT_270;
}
LOGE("rotation step.\n");
ret = imrotate(rga_middle_src, rga_dst, rotate);
if (IM_STATUS_SUCCESS != ret) {
LOGE("rotate failed. Ret: %s\n", imStrError((IM_STATUS) ret));
}
LOGE("rotation end.\n");
free(dst_middle);
return ret;
}
分辨率 1024*1280 总耗时20ms 和官方数据应该有出入 不知道问题出在哪
目前使用的是 wrap_buffer_virtural_add方式
|
|