mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-07 01:52:46 +08:00
[vpu_api_legacy] add write right frame out to file, and rescale to 960x540
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@694 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -24,8 +24,11 @@
|
|||||||
#include "mpp_common.h"
|
#include "mpp_common.h"
|
||||||
#include "mpp_env.h"
|
#include "mpp_env.h"
|
||||||
|
|
||||||
#define VPU_API_DBG_OUTPUT 0x00000001
|
#define VPU_API_DBG_OUTPUT (0x00000001)
|
||||||
#define VPU_API_DBG_DUMP_YUV 0x00000002
|
#define VPU_API_DBG_DUMP_YUV (0x00000002)
|
||||||
|
#define VPU_API_DBG_DUMP_LOG (0x00000004)
|
||||||
|
#define MAX_WRITE_HEIGHT (480)
|
||||||
|
#define MAX_WRITE_WIDTH (960)
|
||||||
|
|
||||||
VpuApi::VpuApi()
|
VpuApi::VpuApi()
|
||||||
{
|
{
|
||||||
@@ -38,9 +41,11 @@ VpuApi::VpuApi()
|
|||||||
set_eos = 0;
|
set_eos = 0;
|
||||||
vpu_api_debug = 0;
|
vpu_api_debug = 0;
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
|
fp_buf = NULL;
|
||||||
mpp_env_get_u32("vpu_api_debug", &vpu_api_debug, 0);
|
mpp_env_get_u32("vpu_api_debug", &vpu_api_debug, 0);
|
||||||
if (vpu_api_debug & VPU_API_DBG_DUMP_YUV) {
|
if (vpu_api_debug & VPU_API_DBG_DUMP_YUV) {
|
||||||
fp = fopen("data/hevcdump.yuv", "wb");
|
fp = fopen("/sdcard/rk_mpp_dump.yuv", "wb");
|
||||||
|
fp_buf = mpp_malloc(RK_U8, (MAX_WRITE_HEIGHT * MAX_WRITE_WIDTH * 2));
|
||||||
}
|
}
|
||||||
mpp_log_f("ok\n");
|
mpp_log_f("ok\n");
|
||||||
}
|
}
|
||||||
@@ -50,6 +55,11 @@ VpuApi::~VpuApi()
|
|||||||
mpp_log_f("in\n");
|
mpp_log_f("in\n");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
fp = NULL;
|
||||||
|
}
|
||||||
|
if (fp_buf) {
|
||||||
|
mpp_free(fp_buf);
|
||||||
|
fp_buf = NULL;
|
||||||
}
|
}
|
||||||
mpp_destroy(mpp_ctx);
|
mpp_destroy(mpp_ctx);
|
||||||
mpp_log_f("ok\n");
|
mpp_log_f("ok\n");
|
||||||
@@ -75,7 +85,10 @@ RK_S32 VpuApi::init(VpuCodecContext *ctx, RK_U8 *extraData, RK_U32 extra_size)
|
|||||||
return MPP_ERR_NULL_PTR;
|
return MPP_ERR_NULL_PTR;
|
||||||
}
|
}
|
||||||
ret = mpp_init(mpp_ctx, type, (MppCodingType)ctx->videoCoding);
|
ret = mpp_init(mpp_ctx, type, (MppCodingType)ctx->videoCoding);
|
||||||
|
if (ret) {
|
||||||
|
mpp_err_f(" init error. \n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
VPU_GENERIC vpug;
|
VPU_GENERIC vpug;
|
||||||
vpug.CodecType = ctx->codecType;
|
vpug.CodecType = ctx->codecType;
|
||||||
vpug.ImgWidth = ctx->width;
|
vpug.ImgWidth = ctx->width;
|
||||||
@@ -181,7 +194,7 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
vframe->ColorType = VPU_OUTPUT_FORMAT_YUV422;
|
vframe->ColorType = VPU_OUTPUT_FORMAT_YUV422;
|
||||||
vframe->ColorType |= VPU_OUTPUT_FORMAT_BIT_10;
|
vframe->ColorType |= VPU_OUTPUT_FORMAT_BIT_10;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -193,8 +206,43 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
vframe->vpumem.vir_addr = (RK_U32*)ptr;
|
vframe->vpumem.vir_addr = (RK_U32*)ptr;
|
||||||
frame_count++;
|
frame_count++;
|
||||||
//!< Dump yuv
|
//!< Dump yuv
|
||||||
if (fp && (frame_count > 350)) {
|
if (fp && !vframe->ErrorInfo) {
|
||||||
|
if ((vframe->FrameWidth >= 1920) || (vframe->FrameHeight >= 1080)) {
|
||||||
|
RK_U32 i = 0, j = 0, step = 0;
|
||||||
|
RK_U32 img_w = 0, img_h = 0;
|
||||||
|
RK_U8 *pdes = NULL, *psrc = NULL;
|
||||||
|
step = MPP_MAX(vframe->FrameWidth / MAX_WRITE_WIDTH, vframe->FrameHeight / MAX_WRITE_HEIGHT);
|
||||||
|
img_w = vframe->FrameWidth / step;
|
||||||
|
img_h = vframe->FrameHeight / step;
|
||||||
|
pdes = fp_buf;
|
||||||
|
psrc = (RK_U8 *)ptr;
|
||||||
|
for (i = 0; i < img_h; i++) {
|
||||||
|
for (j = 0; j < img_w; j++) {
|
||||||
|
pdes[j] = psrc[j * step];
|
||||||
|
}
|
||||||
|
pdes += img_w;
|
||||||
|
psrc += step * vframe->FrameWidth;
|
||||||
|
}
|
||||||
|
pdes = fp_buf + img_w * img_h;
|
||||||
|
psrc = (RK_U8 *)ptr + vframe->FrameWidth * vframe->FrameHeight;
|
||||||
|
for (i = 0; i < (img_h / 2); i++) {
|
||||||
|
for (j = 0; j < (img_w / 2); j++) {
|
||||||
|
pdes[2 * j + 0] = psrc[2 * j * step + 0];
|
||||||
|
pdes[2 * j + 1] = psrc[2 * j * step + 1];
|
||||||
|
}
|
||||||
|
pdes += img_w;
|
||||||
|
psrc += step * vframe->FrameWidth;
|
||||||
|
}
|
||||||
|
fwrite(fp_buf, 1, img_w * img_h * 3 / 2, fp);
|
||||||
|
if (vpu_api_debug & VPU_API_DBG_DUMP_LOG) {
|
||||||
|
mpp_log("[write_out_yuv] FrameWidth = %d, FrameHeight = %d", img_w, img_h);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
fwrite(ptr, 1, vframe->FrameWidth * vframe->FrameHeight * 3 / 2, fp);
|
fwrite(ptr, 1, vframe->FrameWidth * vframe->FrameHeight * 3 / 2, fp);
|
||||||
|
if (vpu_api_debug & VPU_API_DBG_DUMP_LOG) {
|
||||||
|
mpp_log("[write_out_yuv] FrameWidth = %d, FrameHeight = %d", vframe->FrameWidth, vframe->FrameHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
vframe->vpumem.phy_addr = fd;
|
vframe->vpumem.phy_addr = fd;
|
||||||
@@ -202,8 +250,8 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
vframe->vpumem.offset = (RK_U32*)buf;
|
vframe->vpumem.offset = (RK_U32*)buf;
|
||||||
}
|
}
|
||||||
if (vpu_api_debug & VPU_API_DBG_OUTPUT) {
|
if (vpu_api_debug & VPU_API_DBG_OUTPUT) {
|
||||||
mpp_log("get one frame timeUs %lld, fd=0x%x, poc=%d, errinfo=%d, discard=%d, eos=%d", aDecOut->timeUs, fd,
|
mpp_log("get one frame timeUs %lld, fd=0x%x, poc=%d, errinfo=%d, discard=%d, eos=%d, verr=%d", aDecOut->timeUs, fd,
|
||||||
mpp_frame_get_poc(mframe), mpp_frame_get_errinfo(mframe), mpp_frame_get_discard(mframe), mpp_frame_get_eos(mframe));
|
mpp_frame_get_poc(mframe), mpp_frame_get_errinfo(mframe), mpp_frame_get_discard(mframe), mpp_frame_get_eos(mframe), vframe->ErrorInfo);
|
||||||
}
|
}
|
||||||
if (mpp_frame_get_eos(mframe)) {
|
if (mpp_frame_get_eos(mframe)) {
|
||||||
set_eos = 1;
|
set_eos = 1;
|
||||||
@@ -211,7 +259,7 @@ RK_S32 VpuApi:: decode_getoutframe(DecoderOut_t *aDecOut)
|
|||||||
aDecOut->size = 0;
|
aDecOut->size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mpp_free(mframe);
|
mpp_frame_deinit(&mframe);
|
||||||
} else {
|
} else {
|
||||||
aDecOut->size = 0;
|
aDecOut->size = 0;
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ private:
|
|||||||
RK_U32 set_eos;
|
RK_U32 set_eos;
|
||||||
RK_U32 vpu_api_debug;
|
RK_U32 vpu_api_debug;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
RK_U8 *fp_buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*_VPU_API_H_*/
|
#endif /*_VPU_API_H_*/
|
||||||
|
Reference in New Issue
Block a user