From 2ea1a7ecd32957a70e59d0d74ae7d370f9706c7a Mon Sep 17 00:00:00 2001 From: Hery Xu Date: Mon, 15 Apr 2024 16:45:00 +0800 Subject: [PATCH] [vpu_api]: support nv21 format encode Change-Id: I82af5c70702b759afbce8665ff536c517d164831 Signed-off-by: Hery Xu --- inc/vpu_api.h | 3 ++- mpp/legacy/vpu_api_legacy.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/vpu_api.h b/inc/vpu_api.h index 80c7a599..b20126af 100644 --- a/inc/vpu_api.h +++ b/inc/vpu_api.h @@ -72,7 +72,8 @@ typedef enum { ENC_INPUT_RGB888 = 10, /**< 24-bit RGB */ ENC_INPUT_BGR888 = 11, /**< 24-bit RGB */ ENC_INPUT_RGB101010 = 12, /**< 30-bit RGB */ - ENC_INPUT_BGR101010 = 13 /**< 30-bit RGB */ + ENC_INPUT_BGR101010 = 13, /**< 30-bit RGB */ + ENC_INPUT_YUV420_SEMIPLANAR_VU = 0X100 /**< YYYY... VUVUVUVU... */ } EncInputPictureType; typedef enum VPU_API_CMD { diff --git a/mpp/legacy/vpu_api_legacy.cpp b/mpp/legacy/vpu_api_legacy.cpp index 406017b1..12537c06 100644 --- a/mpp/legacy/vpu_api_legacy.cpp +++ b/mpp/legacy/vpu_api_legacy.cpp @@ -44,6 +44,9 @@ static MppFrameFormat vpu_pic_type_remap_to_mpp(EncInputPictureType type) case ENC_INPUT_YUV420_SEMIPLANAR : { ret = MPP_FMT_YUV420SP; } break; + case ENC_INPUT_YUV420_SEMIPLANAR_VU : { + ret = MPP_FMT_YUV420SP_VU; + } break; case ENC_INPUT_YUV422_INTERLEAVED_YUYV : { ret = MPP_FMT_YUV422_YUYV; } break; @@ -231,7 +234,8 @@ static int copy_align_raw_buffer_to_dest(RK_U8 *dst, RK_U8 *src, RK_U32 width, RK_U8 *dst_v = dst_u + hor_stride * ver_stride / 4; switch (fmt) { - case MPP_FMT_YUV420SP : { + case MPP_FMT_YUV420SP : + case MPP_FMT_YUV420SP_VU : { for (row = 0; row < height; row++) { memcpy(dst_buf + row * hor_stride, src_buf + index, width); index += width; @@ -1409,6 +1413,8 @@ RK_S32 VpuApiLegacy::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *a } if (format >= MPP_FMT_YUV420SP && format < MPP_FMT_YUV_BUTT) { align_size = hor_stride * MPP_ALIGN(ver_stride, 16) * 3 / 2; + } else if (format >= MPP_FMT_YUV420SP_VU && format < MPP_FMT_YUV_BUTT) { + align_size = hor_stride * MPP_ALIGN(ver_stride, 16) * 3 / 2; } else if (format >= MPP_FMT_RGB565 && format < MPP_FMT_BGR888) { align_size = hor_stride * MPP_ALIGN(ver_stride, 16) * 3; } else if (format >= MPP_FMT_RGB101010 && format < MPP_FMT_RGB_BUTT) {