<div dir="ltr">Pushed the updated patch into default.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 4, 2020 at 11:17 AM Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com">aruna@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 4, 2020 at 8:42 AM Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Looks good to me overall. One suggestion - since encoder open is now a part of threadMain, can we also move the cliopt parse to threadMain?</div></blockquote><div>yes, we shall do that. I'll update and resend the patch. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 28, 2020 at 3:23 PM Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com" target="_blank">aruna@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># HG changeset patch<br>
# User Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com" target="_blank">aruna@multicorewareinc.com</a>><br>
# Date 1586956494 -19800<br>
# Wed Apr 15 18:44:54 2020 +0530<br>
# Node ID 23da64aedc8e5dcbed9ecd6e531f5649e6906c91<br>
# Parent 94bfe7f2c0c12616145f8fc1a1762ed55204a0a6<br>
Cleanup<br>
<br>
diff -r 94bfe7f2c0c1 -r 23da64aedc8e source/abrEncApp.cpp<br>
--- a/source/abrEncApp.cpp Thu Apr 16 18:48:56 2020 +0530<br>
+++ b/source/abrEncApp.cpp Wed Apr 15 18:44:54 2020 +0530<br>
@@ -41,62 +41,6 @@<br>
b_ctrl_c = 1;<br>
}<br>
<br>
-#define START_CODE 0x00000001<br>
-#define START_CODE_BYTES 4<br>
-<br>
-/* Parse the RPU file and extract the RPU corresponding to the current picture<br>
-* and fill the rpu field of the input picture */<br>
-static int rpuParser(x265_picture * pic, FILE * ptr)<br>
-{<br>
- uint8_t byteVal;<br>
- uint32_t code = 0;<br>
- int bytesRead = 0;<br>
- pic->rpu.payloadSize = 0;<br>
-<br>
- if (!pic->pts)<br>
- {<br>
- while (bytesRead++ < 4 && fread(&byteVal, sizeof(uint8_t), 1, ptr))<br>
- code = (code << 8) | byteVal;<br>
-<br>
- if (code != START_CODE)<br>
- {<br>
- x265_log(NULL, X265_LOG_ERROR, "Invalid Dolby Vision RPU startcode in POC %d\n", pic->pts);<br>
- return 1;<br>
- }<br>
- }<br>
-<br>
- bytesRead = 0;<br>
- while (fread(&byteVal, sizeof(uint8_t), 1, ptr))<br>
- {<br>
- code = (code << 8) | byteVal;<br>
- if (bytesRead++ < 3)<br>
- continue;<br>
- if (bytesRead >= 1024)<br>
- {<br>
- x265_log(NULL, X265_LOG_ERROR, "Invalid Dolby Vision RPU size in POC %d\n", pic->pts);<br>
- return 1;<br>
- }<br>
-<br>
- if (code != START_CODE)<br>
- pic->rpu.payload[pic->rpu.payloadSize++] = (code >> (3 * 8)) & 0xFF;<br>
- else<br>
- return 0;<br>
- }<br>
-<br>
- int ShiftBytes = START_CODE_BYTES - (bytesRead - pic->rpu.payloadSize);<br>
- int bytesLeft = bytesRead - pic->rpu.payloadSize;<br>
- code = (code << ShiftBytes * 8);<br>
- for (int i = 0; i < bytesLeft; i++)<br>
- {<br>
- pic->rpu.payload[pic->rpu.payloadSize++] = (code >> (3 * 8)) & 0xFF;<br>
- code = (code << 8);<br>
- }<br>
- if (!pic->rpu.payloadSize)<br>
- x265_log(NULL, X265_LOG_WARNING, "Dolby Vision RPU not found for POC %d\n", pic->pts);<br>
- return 0;<br>
-}<br>
-<br>
-<br>
namespace X265_NS {<br>
// private namespace<br>
#define X265_INPUT_QUEUE_SIZE 250<br>
@@ -150,8 +94,10 @@<br>
m_inputPicBuffer[pass] = X265_MALLOC(x265_picture*, m_queueSize);<br>
for (uint32_t idx = 0; idx < m_queueSize; idx++)<br>
{<br>
- m_inputPicBuffer[pass][idx] = NULL;<br>
+ m_inputPicBuffer[pass][idx] = x265_picture_alloc();<br>
+ x265_picture_init(m_passEnc[pass]->m_param, m_inputPicBuffer[pass][idx]);<br>
}<br>
+<br>
m_analysisBuffer[pass] = X265_MALLOC(x265_analysis_data, m_queueSize);<br>
m_picIdxReadCnt[pass] = new ThreadSafeInteger[m_queueSize];<br>
m_analysisWrite[pass] = new ThreadSafeInteger[m_queueSize];<br>
@@ -161,32 +107,25 @@<br>
return true;<br>
}<br>
<br>
- void AbrEncoder::closeEncoder()<br>
- {<br>
- for (uint8_t pidx = 0; pidx < m_numEncodes; pidx++)<br>
- {<br>
- PassEncoder *passWorker = m_passEnc[pidx];<br>
- if (passWorker)<br>
- passWorker->close();<br>
- }<br>
- }<br>
-<br>
void AbrEncoder::destroy()<br>
{<br>
- closeEncoder();<br>
x265_cleanup(); /* Free library singletons */<br>
for (uint8_t pass = 0; pass < m_numEncodes; pass++)<br>
{<br>
for (uint32_t index = 0; index < m_queueSize; index++)<br>
{<br>
+ X265_FREE(m_inputPicBuffer[pass][index]->planes[0]);<br>
x265_picture_free(m_inputPicBuffer[pass][index]);<br>
}<br>
+<br>
X265_FREE(m_inputPicBuffer[pass]);<br>
X265_FREE(m_analysisBuffer[pass]);<br>
+ X265_FREE(m_readFlag[pass]);<br>
delete[] m_picIdxReadCnt[pass];<br>
delete[] m_analysisWrite[pass];<br>
delete[] m_analysisRead[pass];<br>
m_passEnc[pass]->destroy();<br>
+ delete m_passEnc[pass];<br>
}<br>
X265_FREE(m_inputPicBuffer);<br>
X265_FREE(m_analysisBuffer);<br>
@@ -211,13 +150,13 @@<br>
m_parent = parent;<br>
if(!(m_cliopt.enableScaler && m_id))<br>
m_input = m_cliopt.input;<br>
- m_param = x265_param_alloc();<br>
- x265_copy_params(m_param, cliopt.param);<br>
+ m_param = cliopt.param;<br>
m_inputOver = false;<br>
m_lastIdx = -1;<br>
m_encoder = NULL;<br>
m_scaler = NULL;<br>
m_reader = NULL;<br>
+ m_ret = 0;<br>
}<br>
<br>
int PassEncoder::init(int &result)<br>
@@ -244,25 +183,6 @@<br>
}<br>
}<br>
}<br>
-<br>
- if (m_cliopt.zoneFile)<br>
- {<br>
- if (!m_cliopt.parseZoneFile())<br>
- {<br>
- x265_log(NULL, X265_LOG_ERROR, "Unable to parse zonefile\n");<br>
- fclose(m_cliopt.zoneFile);<br>
- m_cliopt.zoneFile = NULL;<br>
- }<br>
- }<br>
-<br>
- if (m_param)<br>
- m_encoder = m_cliopt.api->encoder_open(m_param);<br>
- if (!m_encoder)<br>
- {<br>
- x265_log(NULL, X265_LOG_ERROR, "x265_encoder_open() failed for Enc, \n");<br>
- return -1;<br>
- }<br>
- m_cliopt.api->encoder_parameters(m_encoder, m_param);<br>
return 1;<br>
}<br>
<br>
@@ -272,15 +192,13 @@<br>
<br>
m_param->confWinBottomOffset = m_param->confWinRightOffset = 0;<br>
<br>
- m_isAnalysisSave = m_cliopt.saveLevel ? true : false;<br>
- m_isAnalysisLoad = m_cliopt.loadLevel ? true : false;<br>
m_param->analysisLoadReuseLevel = m_cliopt.loadLevel;<br>
m_param->analysisSaveReuseLevel = m_cliopt.saveLevel;<br>
- m_param->analysisSave = m_isAnalysisSave ? "save.dat" : NULL;<br>
- m_param->analysisLoad = m_isAnalysisLoad ? "load.dat" : NULL;<br>
+ m_param->analysisSave = m_cliopt.saveLevel ? "save.dat" : NULL;<br>
+ m_param->analysisLoad = m_cliopt.loadLevel ? "load.dat" : NULL;<br>
m_param->bUseAnalysisFile = 0;<br>
<br>
- if (m_isAnalysisLoad)<br>
+ if (m_cliopt.loadLevel)<br>
{<br>
x265_param *refParam = m_parent->m_passEnc[m_cliopt.refId]->m_param;<br>
<br>
@@ -460,7 +378,7 @@<br>
int ipread = m_parent->m_picReadCnt[m_id].get();<br>
int ipwrite = m_parent->m_picWriteCnt[m_id].get();<br>
<br>
- bool isAbrLoad = m_isAnalysisLoad && (m_parent->m_numEncodes > 1);<br>
+ bool isAbrLoad = m_cliopt.loadLevel && (m_parent->m_numEncodes > 1);<br>
while (!m_inputOver && (ipread == ipwrite))<br>
{<br>
ipwrite = m_parent->m_picWriteCnt[m_id].waitForChange(ipwrite);<br>
@@ -561,215 +479,289 @@<br>
<br>
void PassEncoder::threadMain()<br>
{<br>
+ THREAD_NAME("PassEncoder", m_id);<br>
+<br>
+ while (m_threadActive)<br>
+ {<br>
<br>
#if ENABLE_LIBVMAF<br>
- x265_vmaf_data* vmafdata = cliopt.vmafData;<br>
+ x265_vmaf_data* vmafdata = m_cliopt.vmafData;<br>
#endif<br>
- /* This allows muxers to modify bitstream format */<br>
- m_cliopt.output->setParam(m_param);<br>
- const x265_api* api = m_cliopt.api;<br>
- ReconPlay* reconPlay = NULL;<br>
- if (m_cliopt.reconPlayCmd)<br>
- reconPlay = new ReconPlay(m_cliopt.reconPlayCmd, *m_param);<br>
-<br>
- if (signal(SIGINT, sigint_handler) == SIG_ERR)<br>
- x265_log(m_param, X265_LOG_ERROR, "Unable to register CTRL+C handler: %s\n", strerror(errno));<br>
+ /* This allows muxers to modify bitstream format */<br>
+ m_cliopt.output->setParam(m_param);<br>
+ const x265_api* api = m_cliopt.api;<br>
+ ReconPlay* reconPlay = NULL;<br>
+ if (m_cliopt.reconPlayCmd)<br>
+ reconPlay = new ReconPlay(m_cliopt.reconPlayCmd, *m_param);<br>
+ char* profileName = m_cliopt.encName ? m_cliopt.encName : (char *)"x265";<br>
<br>
- x265_picture pic_orig, pic_out;<br>
- x265_picture *pic_in = &pic_orig;<br>
- /* Allocate recon picture if analysis save/load is enabled */<br>
- std::priority_queue<int64_t>* pts_queue = m_cliopt.output->needPTS() ? new std::priority_queue<int64_t>() : NULL;<br>
- x265_picture *pic_recon = (m_cliopt.recon || m_param->analysisSave || m_param->analysisLoad || pts_queue || reconPlay || m_param->csvLogLevel) ? &pic_out : NULL;<br>
- uint32_t inFrameCount = 0;<br>
- uint32_t outFrameCount = 0;<br>
- x265_nal *p_nal;<br>
- x265_stats stats;<br>
- uint32_t nal;<br>
- int16_t *errorBuf = NULL;<br>
- bool bDolbyVisionRPU = false;<br>
- uint8_t *rpuPayload = NULL;<br>
- int inputPicNum = 1;<br>
- x265_picture picField1, picField2;<br>
- x265_analysis_data* analysisInfo = (x265_analysis_data*)(&pic_out.analysisData);<br>
- bool isAbrSave = m_isAnalysisSave && (m_parent->m_numEncodes > 1);<br>
-<br>
- if (!m_param->bRepeatHeaders && !m_param->bEnableSvtHevc)<br>
- {<br>
- if (api->encoder_headers(m_encoder, &p_nal, &nal) < 0)<br>
+ if (m_cliopt.zoneFile)<br>
{<br>
- x265_log(m_param, X265_LOG_ERROR, "Failure generating stream headers %d\n", m_id);<br>
- goto fail;<br>
- }<br>
- else<br>
- m_cliopt.totalbytes += m_cliopt.output->writeHeaders(p_nal, nal);<br>
- }<br>
-<br>
- if (m_param->bField && m_param->interlaceMode)<br>
- {<br>
- api->picture_init(m_param, &picField1);<br>
- api->picture_init(m_param, &picField2);<br>
- // return back the original height of input<br>
- m_param->sourceHeight *= 2;<br>
- api->picture_init(m_param, &pic_orig);<br>
- }<br>
- else<br>
- api->picture_init(m_param, &pic_orig);<br>
-<br>
- if (m_param->dolbyProfile && m_cliopt.dolbyVisionRpu)<br>
- {<br>
- rpuPayload = X265_MALLOC(uint8_t, 1024);<br>
- pic_in->rpu.payload = rpuPayload;<br>
- if (pic_in->rpu.payload)<br>
- bDolbyVisionRPU = true;<br>
- }<br>
-<br>
- if (m_cliopt.bDither)<br>
- {<br>
- errorBuf = X265_MALLOC(int16_t, m_param->sourceWidth + 1);<br>
- if (errorBuf)<br>
- memset(errorBuf, 0, (m_param->sourceWidth + 1) * sizeof(int16_t));<br>
- else<br>
- m_cliopt.bDither = false;<br>
- }<br>
-<br>
- // main encoder loop<br>
- while (pic_in && !b_ctrl_c)<br>
- {<br>
- pic_orig.poc = (m_param->bField && m_param->interlaceMode) ? inFrameCount * 2 : inFrameCount;<br>
- if (m_cliopt.qpfile)<br>
- {<br>
- if (!m_cliopt.parseQPFile(pic_orig))<br>
+ if (!m_cliopt.parseZoneFile())<br>
{<br>
- x265_log(NULL, X265_LOG_ERROR, "can't parse qpfile for frame %d\n", pic_in->poc);<br>
- fclose(m_cliopt.qpfile);<br>
- m_cliopt.qpfile = NULL;<br>
+ x265_log(NULL, X265_LOG_ERROR, "Unable to parse zonefile in %s\n", profileName);<br>
+ fclose(m_cliopt.zoneFile);<br>
+ m_cliopt.zoneFile = NULL;<br>
}<br>
}<br>
<br>
- if (m_cliopt.framesToBeEncoded && inFrameCount >= m_cliopt.framesToBeEncoded)<br>
+ /* note: we could try to acquire a different libx265 API here based on<br>
+ * the profile found during option parsing, but it must be done before<br>
+ * opening an encoder */<br>
+<br>
+ m_encoder = api->encoder_open(m_param);<br>
+ if (!m_encoder)<br>
{<br>
- pic_in = NULL;<br>
+ x265_log(NULL, X265_LOG_ERROR, "failed to open encoder in %s\n", profileName);<br>
+ api->param_free(m_param);<br>
+ m_ret = 2;<br>
+ break;<br>
}<br>
- else if (readPicture(pic_in))<br>
- inFrameCount++;<br>
- else<br>
- pic_in = NULL;<br>
+<br>
+ /* get the encoder parameters post-initialization */<br>
+ api->encoder_parameters(m_encoder, m_param);<br>
+<br>
+ if (signal(SIGINT, sigint_handler) == SIG_ERR)<br>
+ x265_log(m_param, X265_LOG_ERROR, "Unable to register CTRL+C handler: %s in %s\n",<br>
+ strerror(errno), profileName);<br>
<br>
- if (pic_in)<br>
+ x265_picture pic_orig, pic_out;<br>
+ x265_picture *pic_in = &pic_orig;<br>
+ /* Allocate recon picture if analysis save/load is enabled */<br>
+ std::priority_queue<int64_t>* pts_queue = m_cliopt.output->needPTS() ? new std::priority_queue<int64_t>() : NULL;<br>
+ x265_picture *pic_recon = (m_cliopt.recon || m_param->analysisSave || m_param->analysisLoad || pts_queue || reconPlay || m_param->csvLogLevel) ? &pic_out : NULL;<br>
+ uint32_t inFrameCount = 0;<br>
+ uint32_t outFrameCount = 0;<br>
+ x265_nal *p_nal;<br>
+ x265_stats stats;<br>
+ uint32_t nal;<br>
+ int16_t *errorBuf = NULL;<br>
+ bool bDolbyVisionRPU = false;<br>
+ uint8_t *rpuPayload = NULL;<br>
+ int inputPicNum = 1;<br>
+ x265_picture picField1, picField2;<br>
+ x265_analysis_data* analysisInfo = (x265_analysis_data*)(&pic_out.analysisData);<br>
+ bool isAbrSave = m_cliopt.saveLevel && (m_parent->m_numEncodes > 1);<br>
+<br>
+ if (!m_param->bRepeatHeaders && !m_param->bEnableSvtHevc)<br>
{<br>
- if (pic_in->bitDepth > m_param->internalBitDepth && m_cliopt.bDither)<br>
+ if (api->encoder_headers(m_encoder, &p_nal, &nal) < 0)<br>
{<br>
- x265_dither_image(pic_in, m_cliopt.input->getWidth(), m_cliopt.input->getHeight(), errorBuf, m_param->internalBitDepth);<br>
- pic_in->bitDepth = m_param->internalBitDepth;<br>
+ x265_log(m_param, X265_LOG_ERROR, "Failure generating stream headers in %s\n", profileName);<br>
+ m_ret = 3;<br>
+ goto fail;<br>
}<br>
- /* Overwrite PTS */<br>
- pic_in->pts = pic_in->poc;<br>
+ else<br>
+ m_cliopt.totalbytes += m_cliopt.output->writeHeaders(p_nal, nal);<br>
+ }<br>
+<br>
+ if (m_param->bField && m_param->interlaceMode)<br>
+ {<br>
+ api->picture_init(m_param, &picField1);<br>
+ api->picture_init(m_param, &picField2);<br>
+ // return back the original height of input<br>
+ m_param->sourceHeight *= 2;<br>
+ api->picture_init(m_param, &pic_orig);<br>
+ }<br>
+ else<br>
+ api->picture_init(m_param, &pic_orig);<br>
<br>
- // convert to field<br>
- if (m_param->bField && m_param->interlaceMode)<br>
+ if (m_param->dolbyProfile && m_cliopt.dolbyVisionRpu)<br>
+ {<br>
+ rpuPayload = X265_MALLOC(uint8_t, 1024);<br>
+ pic_in->rpu.payload = rpuPayload;<br>
+ if (pic_in->rpu.payload)<br>
+ bDolbyVisionRPU = true;<br>
+ }<br>
+<br>
+ if (m_cliopt.bDither)<br>
+ {<br>
+ errorBuf = X265_MALLOC(int16_t, m_param->sourceWidth + 1);<br>
+ if (errorBuf)<br>
+ memset(errorBuf, 0, (m_param->sourceWidth + 1) * sizeof(int16_t));<br>
+ else<br>
+ m_cliopt.bDither = false;<br>
+ }<br>
+<br>
+ // main encoder loop<br>
+ while (pic_in && !b_ctrl_c)<br>
+ {<br>
+ pic_orig.poc = (m_param->bField && m_param->interlaceMode) ? inFrameCount * 2 : inFrameCount;<br>
+ if (m_cliopt.qpfile)<br>
{<br>
- int height = pic_in->height >> 1;<br>
-<br>
- int static bCreated = 0;<br>
- if (bCreated == 0)<br>
+ if (!m_cliopt.parseQPFile(pic_orig))<br>
{<br>
- bCreated = 1;<br>
- inputPicNum = 2;<br>
- picField1.fieldNum = 1;<br>
- picField2.fieldNum = 2;<br>
+ x265_log(NULL, X265_LOG_ERROR, "can't parse qpfile for frame %d in %s\n",<br>
+ pic_in->poc, profileName);<br>
+ fclose(m_cliopt.qpfile);<br>
+ m_cliopt.qpfile = NULL;<br>
+ }<br>
+ }<br>
+<br>
+ if (m_cliopt.framesToBeEncoded && inFrameCount >= m_cliopt.framesToBeEncoded)<br>
+ pic_in = NULL;<br>
+ else if (readPicture(pic_in))<br>
+ inFrameCount++;<br>
+ else<br>
+ pic_in = NULL;<br>
<br>
- picField1.bitDepth = picField2.bitDepth = pic_in->bitDepth;<br>
- picField1.colorSpace = picField2.colorSpace = pic_in->colorSpace;<br>
- picField1.height = picField2.height = pic_in->height >> 1;<br>
- picField1.framesize = picField2.framesize = pic_in->framesize >> 1;<br>
+ if (pic_in)<br>
+ {<br>
+ if (pic_in->bitDepth > m_param->internalBitDepth && m_cliopt.bDither)<br>
+ {<br>
+ x265_dither_image(pic_in, m_cliopt.input->getWidth(), m_cliopt.input->getHeight(), errorBuf, m_param->internalBitDepth);<br>
+ pic_in->bitDepth = m_param->internalBitDepth;<br>
+ }<br>
+ /* Overwrite PTS */<br>
+ pic_in->pts = pic_in->poc;<br>
+<br>
+ // convert to field<br>
+ if (m_param->bField && m_param->interlaceMode)<br>
+ {<br>
+ int height = pic_in->height >> 1;<br>
<br>
- size_t fieldFrameSize = (size_t)pic_in->framesize >> 1;<br>
- char* field1Buf = X265_MALLOC(char, fieldFrameSize);<br>
- char* field2Buf = X265_MALLOC(char, fieldFrameSize);<br>
+ int static bCreated = 0;<br>
+ if (bCreated == 0)<br>
+ {<br>
+ bCreated = 1;<br>
+ inputPicNum = 2;<br>
+ picField1.fieldNum = 1;<br>
+ picField2.fieldNum = 2;<br>
+<br>
+ picField1.bitDepth = picField2.bitDepth = pic_in->bitDepth;<br>
+ picField1.colorSpace = picField2.colorSpace = pic_in->colorSpace;<br>
+ picField1.height = picField2.height = pic_in->height >> 1;<br>
+ picField1.framesize = picField2.framesize = pic_in->framesize >> 1;<br>
+<br>
+ size_t fieldFrameSize = (size_t)pic_in->framesize >> 1;<br>
+ char* field1Buf = X265_MALLOC(char, fieldFrameSize);<br>
+ char* field2Buf = X265_MALLOC(char, fieldFrameSize);<br>
<br>
- int stride = picField1.stride[0] = picField2.stride[0] = pic_in->stride[0];<br>
- uint64_t framesize = stride * (height >> x265_cli_csps[pic_in->colorSpace].height[0]);<br>
- picField1.planes[0] = field1Buf;<br>
- picField2.planes[0] = field2Buf;<br>
- for (int i = 1; i < x265_cli_csps[pic_in->colorSpace].planes; i++)<br>
+ int stride = picField1.stride[0] = picField2.stride[0] = pic_in->stride[0];<br>
+ uint64_t framesize = stride * (height >> x265_cli_csps[pic_in->colorSpace].height[0]);<br>
+ picField1.planes[0] = field1Buf;<br>
+ picField2.planes[0] = field2Buf;<br>
+ for (int i = 1; i < x265_cli_csps[pic_in->colorSpace].planes; i++)<br>
+ {<br>
+ picField1.planes[i] = field1Buf + framesize;<br>
+ picField2.planes[i] = field2Buf + framesize;<br>
+<br>
+ stride = picField1.stride[i] = picField2.stride[i] = pic_in->stride[i];<br>
+ framesize += (stride * (height >> x265_cli_csps[pic_in->colorSpace].height[i]));<br>
+ }<br>
+ assert(framesize == picField1.framesize);<br>
+ }<br>
+<br>
+ picField1.pts = picField1.poc = pic_in->poc;<br>
+ picField2.pts = picField2.poc = pic_in->poc + 1;<br>
+<br>
+ picField1.userSEI = picField2.userSEI = pic_in->userSEI;<br>
+<br>
+ //if (pic_in->userData)<br>
+ //{<br>
+ // // Have to handle userData here<br>
+ //}<br>
+<br>
+ if (pic_in->framesize)<br>
{<br>
- picField1.planes[i] = field1Buf + framesize;<br>
- picField2.planes[i] = field2Buf + framesize;<br>
+ for (int i = 0; i < x265_cli_csps[pic_in->colorSpace].planes; i++)<br>
+ {<br>
+ char* srcP1 = (char*)pic_in->planes[i];<br>
+ char* srcP2 = (char*)pic_in->planes[i] + pic_in->stride[i];<br>
+ char* p1 = (char*)picField1.planes[i];<br>
+ char* p2 = (char*)picField2.planes[i];<br>
+<br>
+ int stride = picField1.stride[i];<br>
<br>
- stride = picField1.stride[i] = picField2.stride[i] = pic_in->stride[i];<br>
- framesize += (stride * (height >> x265_cli_csps[pic_in->colorSpace].height[i]));<br>
+ for (int y = 0; y < (height >> x265_cli_csps[pic_in->colorSpace].height[i]); y++)<br>
+ {<br>
+ memcpy(p1, srcP1, stride);<br>
+ memcpy(p2, srcP2, stride);<br>
+ srcP1 += 2 * stride;<br>
+ srcP2 += 2 * stride;<br>
+ p1 += stride;<br>
+ p2 += stride;<br>
+ }<br>
+ }<br>
}<br>
- assert(framesize == picField1.framesize);<br>
}<br>
<br>
- picField1.pts = picField1.poc = pic_in->poc;<br>
- picField2.pts = picField2.poc = pic_in->poc + 1;<br>
-<br>
- picField1.userSEI = picField2.userSEI = pic_in->userSEI;<br>
-<br>
- if (pic_in->framesize)<br>
+ if (bDolbyVisionRPU)<br>
{<br>
- for (int i = 0; i < x265_cli_csps[pic_in->colorSpace].planes; i++)<br>
+ if (m_param->bField && m_param->interlaceMode)<br>
{<br>
- char* srcP1 = (char*)pic_in->planes[i];<br>
- char* srcP2 = (char*)pic_in->planes[i] + pic_in->stride[i];<br>
- char* p1 = (char*)picField1.planes[i];<br>
- char* p2 = (char*)picField2.planes[i];<br>
-<br>
- int stride = picField1.stride[i];<br>
-<br>
- for (int y = 0; y < (height >> x265_cli_csps[pic_in->colorSpace].height[i]); y++)<br>
- {<br>
- memcpy(p1, srcP1, stride);<br>
- memcpy(p2, srcP2, stride);<br>
- srcP1 += 2 * stride;<br>
- srcP2 += 2 * stride;<br>
- p1 += stride;<br>
- p2 += stride;<br>
- }<br>
+ if (m_cliopt.rpuParser(&picField1) > 0)<br>
+ goto fail;<br>
+ if (m_cliopt.rpuParser(&picField2) > 0)<br>
+ goto fail;<br>
+ }<br>
+ else<br>
+ {<br>
+ if (m_cliopt.rpuParser(pic_in) > 0)<br>
+ goto fail;<br>
}<br>
}<br>
}<br>
<br>
- if (bDolbyVisionRPU)<br>
+ for (int inputNum = 0; inputNum < inputPicNum; inputNum++)<br>
{<br>
- if (m_param->bField && m_param->interlaceMode)<br>
+ x265_picture *picInput = NULL;<br>
+ if (inputPicNum == 2)<br>
+ picInput = pic_in ? (inputNum ? &picField2 : &picField1) : NULL;<br>
+ else<br>
+ picInput = pic_in;<br>
+<br>
+ int numEncoded = api->encoder_encode(m_encoder, &p_nal, &nal, picInput, pic_recon);<br>
+<br>
+ int idx = (inFrameCount - 1) % m_parent->m_queueSize;<br>
+ m_parent->m_picIdxReadCnt[m_id][idx].incr();<br>
+ m_parent->m_picReadCnt[m_id].incr();<br>
+ if (m_cliopt.loadLevel && picInput)<br>
+ {<br>
+ m_parent->m_analysisReadCnt[m_cliopt.refId].incr();<br>
+ m_parent->m_analysisRead[m_cliopt.refId][m_lastIdx].incr();<br>
+ }<br>
+<br>
+ if (numEncoded < 0)<br>
{<br>
- if (rpuParser(&picField1, m_cliopt.dolbyVisionRpu) > 0)<br>
- goto fail;<br>
- if (rpuParser(&picField2, m_cliopt.dolbyVisionRpu) > 0)<br>
- goto fail;<br>
+ b_ctrl_c = 1;<br>
+ m_ret = 4;<br>
+ break;<br>
+ }<br>
+<br>
+ if (reconPlay && numEncoded)<br>
+ reconPlay->writePicture(*pic_recon);<br>
+<br>
+ outFrameCount += numEncoded;<br>
+<br>
+ if (isAbrSave && numEncoded)<br>
+ {<br>
+ copyInfo(analysisInfo);<br>
}<br>
- else<br>
+<br>
+ if (numEncoded && pic_recon && m_cliopt.recon)<br>
+ m_cliopt.recon->writePicture(pic_out);<br>
+ if (nal)<br>
{<br>
- if (rpuParser(pic_in, m_cliopt.dolbyVisionRpu) > 0)<br>
- goto fail;<br>
+ m_cliopt.totalbytes += m_cliopt.output->writeFrame(p_nal, nal, pic_out);<br>
+ if (pts_queue)<br>
+ {<br>
+ pts_queue->push(-pic_out.pts);<br>
+ if (pts_queue->size() > 2)<br>
+ pts_queue->pop();<br>
+ }<br>
}<br>
+ m_cliopt.printStatus(outFrameCount);<br>
}<br>
}<br>
<br>
- for (int inputNum = 0; inputNum < inputPicNum; inputNum++)<br>
+ /* Flush the encoder */<br>
+ while (!b_ctrl_c)<br>
{<br>
- x265_picture *picInput = NULL;<br>
- if (inputPicNum == 2)<br>
- picInput = pic_in ? (inputNum ? &picField2 : &picField1) : NULL;<br>
- else<br>
- picInput = pic_in;<br>
-<br>
- int numEncoded = api->encoder_encode(m_encoder, &p_nal, &nal, picInput, pic_recon);<br>
-<br>
- int idx = (inFrameCount - 1) % m_parent->m_queueSize;<br>
- m_parent->m_picIdxReadCnt[m_id][idx].incr();<br>
- m_parent->m_picReadCnt[m_id].incr();<br>
- if (m_cliopt.loadLevel && picInput)<br>
- {<br>
- m_parent->m_analysisReadCnt[m_cliopt.refId].incr();<br>
- m_parent->m_analysisRead[m_cliopt.refId][m_lastIdx].incr();<br>
- }<br>
-<br>
+ int numEncoded = api->encoder_encode(m_encoder, &p_nal, &nal, NULL, pic_recon);<br>
if (numEncoded < 0)<br>
{<br>
- b_ctrl_c = 1;<br>
+ m_ret = 4;<br>
break;<br>
}<br>
<br>
@@ -777,7 +769,6 @@<br>
reconPlay->writePicture(*pic_recon);<br>
<br>
outFrameCount += numEncoded;<br>
-<br>
if (isAbrSave && numEncoded)<br>
{<br>
copyInfo(analysisInfo);<br>
@@ -795,106 +786,77 @@<br>
pts_queue->pop();<br>
}<br>
}<br>
+<br>
m_cliopt.printStatus(outFrameCount);<br>
- }<br>
- }<br>
<br>
- /* Flush the encoder */<br>
- while (!b_ctrl_c)<br>
- {<br>
- int numEncoded = api->encoder_encode(m_encoder, &p_nal, &nal, NULL, pic_recon);<br>
- if (numEncoded < 0)<br>
- break;<br>
- <br>
- if (reconPlay && numEncoded)<br>
- reconPlay->writePicture(*pic_recon);<br>
-<br>
- outFrameCount += numEncoded;<br>
- if (isAbrSave && numEncoded)<br>
- {<br>
- copyInfo(analysisInfo);<br>
+ if (!numEncoded)<br>
+ break;<br>
}<br>
<br>
- if (numEncoded && pic_recon && m_cliopt.recon)<br>
- m_cliopt.recon->writePicture(pic_out);<br>
- if (nal)<br>
+ if (bDolbyVisionRPU)<br>
{<br>
- m_cliopt.totalbytes += m_cliopt.output->writeFrame(p_nal, nal, pic_out);<br>
- if (pts_queue)<br>
- {<br>
- pts_queue->push(-pic_out.pts);<br>
- if (pts_queue->size() > 2)<br>
- pts_queue->pop();<br>
- }<br>
+ if (fgetc(m_cliopt.dolbyVisionRpu) != EOF)<br>
+ x265_log(NULL, X265_LOG_WARNING, "Dolby Vision RPU count is greater than frame count in %s\n",<br>
+ profileName);<br>
+ x265_log(NULL, X265_LOG_INFO, "VES muxing with Dolby Vision RPU file successful in %s\n",<br>
+ profileName);<br>
}<br>
<br>
- m_cliopt.printStatus(outFrameCount);<br>
-<br>
- if (!numEncoded)<br>
- break;<br>
- }<br>
+ /* clear progress report */<br>
+ if (m_cliopt.bProgress)<br>
+ fprintf(stderr, "%*s\r", 80, " ");<br>
<br>
- if (bDolbyVisionRPU)<br>
- {<br>
- if (fgetc(m_cliopt.dolbyVisionRpu) != EOF)<br>
- x265_log(NULL, X265_LOG_WARNING, "Dolby Vision RPU count is greater than frame count\n");<br>
- x265_log(NULL, X265_LOG_INFO, "VES muxing with Dolby Vision RPU file successful\n");<br>
- }<br>
+ fail:<br>
+<br>
+ delete reconPlay;<br>
<br>
- if (bDolbyVisionRPU)<br>
- {<br>
- if (fgetc(m_cliopt.dolbyVisionRpu) != EOF)<br>
- x265_log(NULL, X265_LOG_WARNING, "Dolby Vision RPU count is greater than frame count\n");<br>
- x265_log(NULL, X265_LOG_INFO, "VES muxing with Dolby Vision RPU file successful\n");<br>
- }<br>
-<br>
- /* clear progress report */<br>
- if (m_cliopt.bProgress)<br>
- fprintf(stderr, "%*s\r", 80, " ");<br>
-<br>
- fail:<br>
-<br>
- delete reconPlay;<br>
+ api->encoder_get_stats(m_encoder, &stats, sizeof(stats));<br>
+ if (m_param->csvfn && !b_ctrl_c)<br>
+#if ENABLE_LIBVMAF<br>
+ api->vmaf_encoder_log(m_encoder, m_cliopt.argCount, m_cliopt.argString, m_cliopt.param, vmafdata);<br>
+#else<br>
+ api->encoder_log(m_encoder, m_cliopt.argCnt, m_cliopt.argString);<br>
+#endif<br>
+ api->encoder_close(m_encoder);<br>
<br>
- api->encoder_get_stats(m_encoder, &stats, sizeof(stats));<br>
- if (m_param->csvfn && !b_ctrl_c)<br>
-#if ENABLE_LIBVMAF<br>
- api->vmaf_encoder_log(encoder, argc, argv, param, vmafdata);<br>
-#else<br>
- api->encoder_log(m_encoder, 0, NULL);<br>
-#endif<br>
-<br>
- int64_t second_largest_pts = 0;<br>
- int64_t largest_pts = 0;<br>
-<br>
- m_cliopt.output->closeFile(largest_pts, second_largest_pts);<br>
+ int64_t second_largest_pts = 0;<br>
+ int64_t largest_pts = 0;<br>
+ if (pts_queue && pts_queue->size() >= 2)<br>
+ {<br>
+ second_largest_pts = -pts_queue->top();<br>
+ pts_queue->pop();<br>
+ largest_pts = -pts_queue->top();<br>
+ pts_queue->pop();<br>
+ delete pts_queue;<br>
+ pts_queue = NULL;<br>
+ }<br>
+ m_cliopt.output->closeFile(largest_pts, second_largest_pts);<br>
<br>
- if (b_ctrl_c)<br>
- general_log(m_param, NULL, X265_LOG_INFO, "aborted at input frame %d, output frame %d\n",<br>
- m_cliopt.seek + inFrameCount, stats.encodedPictureCount);<br>
+ if (b_ctrl_c)<br>
+ general_log(m_param, NULL, X265_LOG_INFO, "aborted at input frame %d, output frame %d in %s\n",<br>
+ m_cliopt.seek + inFrameCount, stats.encodedPictureCount, profileName);<br>
<br>
- X265_FREE(errorBuf);<br>
- X265_FREE(rpuPayload);<br>
+ api->param_free(m_param);<br>
<br>
- m_threadActive = false;<br>
- m_parent->m_numActiveEncodes.decr();<br>
- }<br>
+ X265_FREE(errorBuf);<br>
+ X265_FREE(rpuPayload);<br>
<br>
- void PassEncoder::close()<br>
- {<br>
- const x265_api* api = m_cliopt.api;<br>
- api->param_free(m_param);<br>
- api->encoder_close(m_encoder);<br>
+ m_threadActive = false;<br>
+ m_parent->m_numActiveEncodes.decr();<br>
+ }<br>
}<br>
<br>
void PassEncoder::destroy()<br>
{<br>
+ stop();<br>
if (m_reader)<br>
{<br>
+ m_reader->stop();<br>
delete m_reader;<br>
}<br>
else<br>
{<br>
+ m_scaler->stop();<br>
m_scaler->destroy();<br>
delete m_scaler;<br>
}<br>
@@ -1107,12 +1069,6 @@<br>
read = m_parentEnc->m_parent->m_picIdxReadCnt[m_id][writeIdx].waitForChange(read);<br>
}<br>
<br>
- if (!m_parentEnc->m_parent->m_inputPicBuffer[m_id][writeIdx])<br>
- {<br>
- m_parentEnc->m_parent->m_inputPicBuffer[m_id][writeIdx] = x265_picture_alloc();<br>
- x265_picture_init(m_parentEnc->m_param, m_parentEnc->m_parent->m_inputPicBuffer[m_id][writeIdx]);<br>
- }<br>
-<br>
x265_picture* dest = m_parentEnc->m_parent->m_inputPicBuffer[m_id][writeIdx];<br>
if (m_input->readPicture(*src))<br>
{<br>
diff -r 94bfe7f2c0c1 -r 23da64aedc8e source/abrEncApp.h<br>
--- a/source/abrEncApp.h Thu Apr 16 18:48:56 2020 +0530<br>
+++ b/source/abrEncApp.h Wed Apr 15 18:44:54 2020 +0530<br>
@@ -60,7 +60,6 @@<br>
<br>
AbrEncoder(CLIOptions cliopt[], uint8_t numEncodes, int& ret);<br>
bool allocBuffers();<br>
- void closeEncoder();<br>
void destroy();<br>
<br>
};<br>
@@ -75,11 +74,6 @@<br>
x265_encoder *m_encoder;<br>
Reader *m_reader;<br>
Scaler *m_scaler;<br>
-<br>
- bool m_reqScale;<br>
- bool m_isScaled;<br>
- bool m_isAnalysisSave;<br>
- bool m_isAnalysisLoad;<br>
bool m_inputOver;<br>
<br>
int m_threadActive;<br>
@@ -98,7 +92,7 @@<br>
FILE* m_zoneFile;<br>
FILE* m_dolbyVisionRpu;/* File containing Dolby Vision BL RPU metadata */<br>
<br>
-<br>
+ int m_ret;<br>
<br>
PassEncoder(uint32_t id, CLIOptions cliopt, AbrEncoder *parent);<br>
int init(int &result);<br>
@@ -108,7 +102,6 @@<br>
void copyInfo(x265_analysis_data *src);<br>
<br>
bool readPicture(x265_picture*);<br>
- void close();<br>
void destroy();<br>
<br>
private:<br>
diff -r 94bfe7f2c0c1 -r 23da64aedc8e source/x265.cpp<br>
--- a/source/x265.cpp Thu Apr 16 18:48:56 2020 +0530<br>
+++ b/source/x265.cpp Wed Apr 15 18:44:54 2020 +0530<br>
@@ -29,11 +29,6 @@<br>
#include "x265cli.h"<br>
#include "abrEncApp.h"<br>
<br>
-#include "input/input.h"<br>
-#include "output/output.h"<br>
-#include "output/reconplay.h"<br>
-#include "svt.h"<br>
-<br>
#if HAVE_VLD<br>
/* Visual Leak Detector */<br>
#include <vld.h><br>
@@ -50,16 +45,12 @@<br>
<br>
using namespace X265_NS;<br>
<br>
+#define X265_HEAD_ENTRIES 3<br>
+<br>
#ifdef _WIN32<br>
#define strdup _strdup<br>
#endif<br>
<br>
-/* Ctrl-C handler */<br>
-static volatile sig_atomic_t b_ctrl_c /* = 0 */;<br>
-<br>
-#define START_CODE 0x00000001<br>
-#define START_CODE_BYTES 4<br>
-<br>
#ifdef _WIN32<br>
/* Copy of x264 code, which allows for Unicode characters in the command line.<br>
* Retrieve command line arguments as UTF-8. */<br>
@@ -97,7 +88,7 @@<br>
* Returns true if abr-config file is present. Returns <br>
* false otherwise */<br>
<br>
-static bool IsAbrLadder(int argc, char **argv, FILE **abrConfig)<br>
+static bool checkAbrLadder(int argc, char **argv, FILE **abrConfig)<br>
{<br>
for (optind = 0;;)<br>
{<br>
@@ -156,20 +147,10 @@<br>
return numEncodes;<br>
}<br>
<br>
-#define X265_HEAD_ENTRIES 3<br>
-<br>
-static bool parseAbrConfig(FILE* abrConfig, CLIOptions cliopt[])<br>
+static bool parseAbrConfig(FILE* abrConfig, CLIOptions cliopt[], uint8_t numEncodes)<br>
{<br>
char line[1024];<br>
char* argLine;<br>
- uint32_t numEncodes = 0;<br>
-<br>
- while (fgets(line, sizeof(line), abrConfig))<br>
- {<br>
- if (!((*line == '#') || (strcmp(line, "\r\n") == 0)))<br>
- numEncodes++;<br>
- }<br>
- rewind(abrConfig);<br>
<br>
for (uint32_t i = 0; i < numEncodes; i++)<br>
{<br>
@@ -182,10 +163,10 @@<br>
argLine = line;<br>
char* start = strchr(argLine, ' ');<br>
while (isspace((unsigned char)*start)) start++;<br>
- int argCount = 0;<br>
- char **args = (char**)malloc(256 * sizeof(char *));<br>
+ int argc = 0;<br>
+ char **argv = (char**)malloc(256 * sizeof(char *));<br>
// Adding a dummy string to avoid file parsing error<br>
- args[argCount++] = (char *)"x265";<br>
+ argv[argc++] = (char *)"x265";<br>
<br>
/* Parse CLI header to identify the ID of the load encode and the reuse level */<br>
char *header = strtok(argLine, "[]");<br>
@@ -215,11 +196,11 @@<br>
char* token = strtok(start, " ");<br>
while (token)<br>
{<br>
- args[argCount++] = token;<br>
+ argv[argc++] = token;<br>
token = strtok(NULL, " ");<br>
}<br>
- args[argCount] = NULL;<br>
- if (cliopt[i].parse(argCount, args))<br>
+ argv[argc++] = NULL;<br>
+ if (cliopt[i].parse(argc++, argv))<br>
{<br>
cliopt[i].destroy();<br>
if (cliopt[i].api)<br>
@@ -291,7 +272,7 @@<br>
<br>
uint8_t numEncodes = 1;<br>
FILE *abrConfig = NULL;<br>
- bool isAbrLadder = IsAbrLadder(argc, argv, &abrConfig);<br>
+ bool isAbrLadder = checkAbrLadder(argc, argv, &abrConfig);<br>
<br>
if (isAbrLadder)<br>
numEncodes = getNumAbrEncodes(abrConfig);<br>
@@ -300,12 +281,12 @@<br>
<br>
if (isAbrLadder)<br>
{<br>
- if(!parseAbrConfig(abrConfig, cliopt))<br>
+ if (!parseAbrConfig(abrConfig, cliopt, numEncodes))<br>
exit(1);<br>
- if(!setRefContext(cliopt, numEncodes))<br>
+ if (!setRefContext(cliopt, numEncodes))<br>
exit(1);<br>
}<br>
- else if(cliopt[0].parse(argc, argv))<br>
+ else if (cliopt[0].parse(argc, argv))<br>
{<br>
cliopt[0].destroy();<br>
if (cliopt[0].api)<br>
@@ -320,12 +301,27 @@<br>
while (threadsActive)<br>
{<br>
threadsActive = abrEnc->m_numActiveEncodes.waitForChange(threadsActive);<br>
+ for (uint8_t idx = 0; idx < numEncodes; idx++)<br>
+ {<br>
+ if (abrEnc->m_passEnc[idx]->m_ret)<br>
+ {<br>
+ if (isAbrLadder)<br>
+ x265_log(NULL, X265_LOG_INFO, "Error generating ABR-ladder \n");<br>
+ ret = abrEnc->m_passEnc[idx]->m_ret;<br>
+ threadsActive = 0;<br>
+ break;<br>
+ }<br>
+ }<br>
}<br>
<br>
abrEnc->destroy();<br>
+ delete abrEnc;<br>
+<br>
for (uint8_t idx = 0; idx < numEncodes; idx++)<br>
cliopt[idx].destroy();<br>
<br>
+ delete[] cliopt;<br>
+<br>
SetConsoleTitle(orgConsoleTitle);<br>
SetThreadExecutionState(ES_CONTINUOUS);<br>
<br>
diff -r 94bfe7f2c0c1 -r 23da64aedc8e source/x265cli.cpp<br>
--- a/source/x265cli.cpp Thu Apr 16 18:48:56 2020 +0530<br>
+++ b/source/x265cli.cpp Wed Apr 15 18:44:54 2020 +0530<br>
@@ -27,6 +27,9 @@<br>
<br>
#include "x265cli.h"<br>
<br>
+#define START_CODE 0x00000001<br>
+#define START_CODE_BYTES 4<br>
+<br>
#ifdef __cplusplus<br>
namespace X265_NS {<br>
#endif<br>
@@ -532,6 +535,8 @@<br>
const char *tune = NULL;<br>
const char *profile = NULL;<br>
int svtEnabled = 0;<br>
+ argCnt = argc;<br>
+ argString = argv;<br>
<br>
if (argc <= 1)<br>
{<br>
@@ -992,6 +997,58 @@<br>
return 1;<br>
}<br>
<br>
+ /* Parse the RPU file and extract the RPU corresponding to the current picture<br>
+ * and fill the rpu field of the input picture */<br>
+ int CLIOptions::rpuParser(x265_picture * pic)<br>
+ {<br>
+ uint8_t byteVal;<br>
+ uint32_t code = 0;<br>
+ int bytesRead = 0;<br>
+ pic->rpu.payloadSize = 0;<br>
+<br>
+ if (!pic->pts)<br>
+ {<br>
+ while (bytesRead++ < 4 && fread(&byteVal, sizeof(uint8_t), 1, dolbyVisionRpu))<br>
+ code = (code << 8) | byteVal;<br>
+<br>
+ if (code != START_CODE)<br>
+ {<br>
+ x265_log(NULL, X265_LOG_ERROR, "Invalid Dolby Vision RPU startcode in POC %d\n", pic->pts);<br>
+ return 1;<br>
+ }<br>
+ }<br>
+<br>
+ bytesRead = 0;<br>
+ while (fread(&byteVal, sizeof(uint8_t), 1, dolbyVisionRpu))<br>
+ {<br>
+ code = (code << 8) | byteVal;<br>
+ if (bytesRead++ < 3)<br>
+ continue;<br>
+ if (bytesRead >= 1024)<br>
+ {<br>
+ x265_log(NULL, X265_LOG_ERROR, "Invalid Dolby Vision RPU size in POC %d\n", pic->pts);<br>
+ return 1;<br>
+ }<br>
+<br>
+ if (code != START_CODE)<br>
+ pic->rpu.payload[pic->rpu.payloadSize++] = (code >> (3 * 8)) & 0xFF;<br>
+ else<br>
+ return 0;<br>
+ }<br>
+<br>
+ int ShiftBytes = START_CODE_BYTES - (bytesRead - pic->rpu.payloadSize);<br>
+ int bytesLeft = bytesRead - pic->rpu.payloadSize;<br>
+ code = (code << ShiftBytes * 8);<br>
+ for (int i = 0; i < bytesLeft; i++)<br>
+ {<br>
+ pic->rpu.payload[pic->rpu.payloadSize++] = (code >> (3 * 8)) & 0xFF;<br>
+ code = (code << 8);<br>
+ }<br>
+ if (!pic->rpu.payloadSize)<br>
+ x265_log(NULL, X265_LOG_WARNING, "Dolby Vision RPU not found for POC %d\n", pic->pts);<br>
+ return 0;<br>
+ }<br>
+<br>
#ifdef __cplusplus<br>
}<br>
#endif<br>
\ No newline at end of file<br>
diff -r 94bfe7f2c0c1 -r 23da64aedc8e source/x265cli.h<br>
--- a/source/x265cli.h Thu Apr 16 18:48:56 2020 +0530<br>
+++ b/source/x265cli.h Wed Apr 15 18:44:54 2020 +0530<br>
@@ -378,7 +378,7 @@<br>
{ 0, 0, 0, 0 },<br>
{ 0, 0, 0, 0 },<br>
{ 0, 0, 0, 0 }<br>
- };<br>
+};<br>
<br>
struct CLIOptions<br>
{<br>
@@ -401,6 +401,9 @@<br>
int64_t startTime;<br>
int64_t prevUpdateTime;<br>
<br>
+ int argCnt;<br>
+ char** argString;<br>
+<br>
/* ABR ladder settings */<br>
bool enableScaler;<br>
char* encName;<br>
@@ -411,7 +414,6 @@<br>
uint32_t saveLevel;<br>
uint32_t numRefs;<br>
<br>
-<br>
/* in microseconds */<br>
static const int UPDATE_INTERVAL = 250000;<br>
CLIOptions()<br>
@@ -434,11 +436,14 @@<br>
prevUpdateTime = 0;<br>
bDither = false;<br>
enableScaler = false;<br>
+ encName = NULL;<br>
+ reuseName = NULL;<br>
encId = 0;<br>
refId = -1;<br>
loadLevel = 0;<br>
saveLevel = 0;<br>
numRefs = 0;<br>
+ argCnt = 0;<br>
}<br>
<br>
void destroy();<br>
@@ -447,6 +452,7 @@<br>
bool parseZoneParam(int argc, char **argv, x265_param* globalParam, int zonefileCount);<br>
bool parseQPFile(x265_picture &pic_org);<br>
bool parseZoneFile();<br>
+ int rpuParser(x265_picture * pic);<br>
};<br>
#ifdef __cplusplus<br>
}<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><span style="color:rgb(0,0,0)">Regards,<br>Kavitha</span></div></div></div></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div>