From d70784c3d0596f1df167c7c8b4f50734429d1ab0 Mon Sep 17 00:00:00 2001 From: enm10k Date: Thu, 5 Oct 2023 17:15:42 +0900 Subject: [PATCH] =?UTF-8?q?=E6=98=A0=E5=83=8F=E3=81=AE=E5=8F=97=E4=BF=A1?= =?UTF-8?q?=E3=81=8C=E8=90=BD=E3=81=A1=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3?= =?UTF-8?q?=E3=81=9F=20(=E7=B7=91=E3=81=AE=E7=94=BB=E9=9D=A2=E3=81=8C?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hwenc_jetson/jetson_buffer.cpp | 3 ++- src/hwenc_jetson/jetson_video_decoder.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/hwenc_jetson/jetson_buffer.cpp b/src/hwenc_jetson/jetson_buffer.cpp index 6ef8bf9f..77832a99 100644 --- a/src/hwenc_jetson/jetson_buffer.cpp +++ b/src/hwenc_jetson/jetson_buffer.cpp @@ -143,7 +143,8 @@ rtc::scoped_refptr JetsonBuffer::ToI420() { } for (int i = 0; i < height; i++) { memcpy(dest_addr + width * i, - (uint8_t*)data_addr + dst_surface->surfaceList->pitch * i, + (uint8_t*)data_addr + + dst_surface->surfaceList->planeParams.pitch[i] * i, width); } } diff --git a/src/hwenc_jetson/jetson_video_decoder.cpp b/src/hwenc_jetson/jetson_video_decoder.cpp index e811ab10..bf5810a9 100644 --- a/src/hwenc_jetson/jetson_video_decoder.cpp +++ b/src/hwenc_jetson/jetson_video_decoder.cpp @@ -220,6 +220,7 @@ bool JetsonVideoDecoder::JetsonRelease() { } if (dst_surface_ != nullptr) { NvBufSurfaceDestroy(dst_surface_); + dst_surface_ = nullptr; } return true; } @@ -419,6 +420,7 @@ int JetsonVideoDecoder::SetCapture() { if (dst_surface_ != nullptr) { NvBufSurfaceDestroy(dst_surface_); + dst_surface_ = nullptr; } NvBufSurfaceAllocateParams input_params = {0}; @@ -426,14 +428,10 @@ int JetsonVideoDecoder::SetCapture() { input_params.params.height = capture_crop_->c.height; input_params.params.layout = NVBUF_LAYOUT_PITCH; input_params.params.colorFormat = NVBUF_COLOR_FORMAT_YUV420; + input_params.params.memType = NVBUF_MEM_SURFACE_ARRAY; input_params.memtag = NvBufSurfaceTag_VIDEO_DEC; - dst_surface_ = new NvBufSurface; - dst_surface_->memType = NVBUF_MEM_SURFACE_ARRAY; - - NvBufSurface* dst_surfaces[] = {dst_surface_}; - - ret = NvBufSurfaceAllocate(dst_surfaces, 1, &input_params); + ret = NvBufSurfaceAllocate(&dst_surface_, 1, &input_params); INIT_ERROR(ret == -1, "failed to NvBufSurfaceAllocate"); decoder_->capture_plane.deinitPlane();