56 lines
2 KiB
Diff
56 lines
2 KiB
Diff
From 4cff3eb1cb6faebfbc82ec500d8441313d02e1d7 Mon Sep 17 00:00:00 2001
|
|
From: Damiano Galassi <damiog@gmail.com>
|
|
Date: Fri, 22 Nov 2024 10:51:25 +0100
|
|
Subject: [PATCH 5/6] Fix Dolby Vision RPU memory management
|
|
|
|
---
|
|
source/common/frame.cpp | 5 +++++
|
|
source/encoder/encoder.cpp | 13 +++++++++++--
|
|
2 files changed, 16 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/source/common/frame.cpp b/source/common/frame.cpp
|
|
index 200717425..1244fdc24 100644
|
|
--- a/source/common/frame.cpp
|
|
+++ b/source/common/frame.cpp
|
|
@@ -370,6 +370,11 @@ void Frame::destroy()
|
|
delete[] m_userSEI.payloads;
|
|
}
|
|
|
|
+ if (m_rpu.payloadSize)
|
|
+ {
|
|
+ delete[] m_rpu.payload;
|
|
+ }
|
|
+
|
|
if (m_ctuInfo)
|
|
{
|
|
uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
|
|
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
|
|
index 39ca2ada1..4461ed8e2 100644
|
|
--- a/source/encoder/encoder.cpp
|
|
+++ b/source/encoder/encoder.cpp
|
|
@@ -1689,11 +1689,20 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)
|
|
}
|
|
copyUserSEIMessages(inFrame[0], inputPic[0]);
|
|
|
|
- /*Copy Dolby Vision RPU from inputPic to frame*/
|
|
+ /* Copy Dolby Vision RPU from inputPic to frame. */
|
|
+ if (inFrame[0]->m_rpu.payload && inFrame[0]->m_rpu.payloadSize < inputPic[0]->rpu.payloadSize)
|
|
+ {
|
|
+ delete[] inFrame[0]->m_rpu.payload;
|
|
+ inFrame[0]->m_rpu.payload = NULL;
|
|
+ }
|
|
+
|
|
if (inputPic[0]->rpu.payloadSize)
|
|
{
|
|
+ if (inFrame[0]->m_rpu.payload == NULL)
|
|
+ {
|
|
+ inFrame[0]->m_rpu.payload = new uint8_t[inputPic[0]->rpu.payloadSize];
|
|
+ }
|
|
inFrame[0]->m_rpu.payloadSize = inputPic[0]->rpu.payloadSize;
|
|
- inFrame[0]->m_rpu.payload = new uint8_t[inputPic[0]->rpu.payloadSize];
|
|
memcpy(inFrame[0]->m_rpu.payload, inputPic[0]->rpu.payload, inputPic[0]->rpu.payloadSize);
|
|
}
|
|
|
|
--
|
|
2.39.5 (Apple Git-154)
|
|
|