[x265] [PATCH] Add consistent VBV support for --tune grain
# HG changeset patch # User Aruna Matheswaran# Date 1496833155 -19800 # Wed Jun 07 16:29:15 2017 +0530 # Branch stable # Node ID 5e516bd4316c535d7f67b3542cfc2acafb4fa4a9 # Parent dccf02340c7538e81a940ca53322762d5d284654 Add consistent VBV support for --tune grain diff -r dccf02340c75 -r 5e516bd4316c doc/reST/cli.rst --- a/doc/reST/cli.rst Thu May 25 10:31:58 2017 +0530 +++ b/doc/reST/cli.rst Wed Jun 07 16:29:15 2017 +0530 @@ -1573,6 +1573,11 @@ that this option is used through the tune grain feature where a combination of param options are used to improve visual quality. + .. option:: --const-vbv, --no-const-vbv + + Enables VBV algorithm to be consistent across runs. Default disabled. + Enabled when :option:'--tune' grain is applied. + .. option:: --qblur Temporally blur quants. Default 0.5 diff -r dccf02340c75 -r 5e516bd4316c source/common/param.cpp --- a/source/common/param.cpp Thu May 25 10:31:58 2017 +0530 +++ b/source/common/param.cpp Wed Jun 07 16:29:15 2017 +0530 @@ -236,6 +236,7 @@ param->rc.bEnableGrain = 0; param->rc.qpMin = 0; param->rc.qpMax = QP_MAX_MAX; +param->rc.bEnableConstVbv = 0; /* Video Usability Information (VUI) */ param->vui.aspectRatioIdc = 0; @@ -494,6 +495,7 @@ param->psyRd = 4.0; param->psyRdoq = 10.0; param->bEnableSAO = 0; +param->rc.bEnableConstVbv = 1; } else return -1; @@ -954,6 +956,7 @@ OPT("limit-sao") p->bLimitSAO = atobool(value); OPT("dhdr10-info") p->toneMapFile = strdup(value); OPT("dhdr10-opt") p->bDhdr10opt = atobool(value); +OPT("const-vbv") p->rc.bEnableConstVbv = atobool(value); else return X265_PARAM_BAD_NAME; } @@ -1630,6 +1633,7 @@ s += sprintf(s, " qg-size=%d", p->rc.qgSize); BOOL(p->rc.bEnableGrain, "rc-grain"); s += sprintf(s, " qpmax=%d qpmin=%d", p->rc.qpMax, p->rc.qpMin); +BOOL(p->rc.bEnableConstVbv, "const-vbv"); s += sprintf(s, " sar=%d", p->vui.aspectRatioIdc); if (p->vui.aspectRatioIdc == X265_EXTENDED_SAR) s += sprintf(s, " sar-width : sar-height=%d:%d", p->vui.sarWidth, p->vui.sarHeight); diff -r dccf02340c75 -r 5e516bd4316c source/encoder/encoder.cpp --- a/source/encoder/encoder.cppThu May 25 10:31:58 2017 +0530 +++ b/source/encoder/encoder.cppWed Jun 07 16:29:15 2017 +0530 @@ -518,7 +518,7 @@ FrameEncoder *encoder = m_frameEncoder[i]; if (encoder->m_rce.isActive && encoder->m_rce.poc != rc->m_curSlice->m_poc) { -int64_t bits = (int64_t) X265_MAX(encoder->m_rce.frameSizeEstimated, encoder->m_rce.frameSizePlanned); +int64_t bits = m_param->rc.bEnableConstVbv ? (int64_t)encoder->m_rce.frameSizePlanned : (int64_t)X265_MAX(encoder->m_rce.frameSizeEstimated, encoder->m_rce.frameSizePlanned); rc->m_bufferFill -= bits; rc->m_bufferFill = X265_MAX(rc->m_bufferFill, 0); rc->m_bufferFill += encoder->m_rce.bufferRate; diff -r dccf02340c75 -r 5e516bd4316c source/encoder/frameencoder.cpp --- a/source/encoder/frameencoder.cpp Thu May 25 10:31:58 2017 +0530 +++ b/source/encoder/frameencoder.cpp Wed Jun 07 16:29:15 2017 +0530 @@ -1510,14 +1510,17 @@ x265_emms(); if (bIsVbv) -{ -// Update encoded bits, satdCost, baseQP for each CU -curEncData.m_rowStat[row].rowSatd += curEncData.m_cuStat[cuAddr].vbvCost; -curEncData.m_rowStat[row].rowIntraSatd += curEncData.m_cuStat[cuAddr].intraVbvCost; -curEncData.m_rowStat[row].encodedBits += curEncData.m_cuStat[cuAddr].totalBits; -curEncData.m_rowStat[row].sumQpRc += curEncData.m_cuStat[cuAddr].baseQp; -curEncData.m_rowStat[row].numEncodedCUs = cuAddr; - +{ +// Update encoded bits, satdCost, baseQP for each CU if tune grain is disabled +if ((m_param->bEnableWavefront && (!cuAddr || !m_param->rc.bEnableConstVbv)) || !m_param->bEnableWavefront) +{ +curEncData.m_rowStat[row].rowSatd += curEncData.m_cuStat[cuAddr].vbvCost; +curEncData.m_rowStat[row].rowIntraSatd += curEncData.m_cuStat[cuAddr].intraVbvCost; +curEncData.m_rowStat[row].encodedBits += curEncData.m_cuStat[cuAddr].totalBits; +curEncData.m_rowStat[row].sumQpRc += curEncData.m_cuStat[cuAddr].baseQp; +curEncData.m_rowStat[row].numEncodedCUs = cuAddr; +} + // If current block is at row end checkpoint, call vbv ratecontrol. if (!m_param->bEnableWavefront && col == numCols - 1) @@ -1553,6 +1556,24 @@ else if (m_param->bEnableWavefront && row == col && row) { +if (m_param->rc.bEnableConstVbv) +{ +
[x265] [PATCH 1 of 2] Support high payload size
# HG changeset patch # User Bhavna Hariharan# Date 1495523574 -19800 # Tue May 23 12:42:54 2017 +0530 # Branch stable # Node ID f4de3ccf989164ed89cc48e49e55d627a8414522 # Parent dccf02340c7538e81a940ca53322762d5d284654 Support high payload size diff -r dccf02340c75 -r f4de3ccf9891 source/dynamicHDR10/metadataFromJson.cpp --- a/source/dynamicHDR10/metadataFromJson.cpp Thu May 25 10:31:58 2017 +0530 +++ b/source/dynamicHDR10/metadataFromJson.cpp Tue May 23 12:42:54 2017 +0530 @@ -168,7 +168,7 @@ { int payloadBytes = 1; -for(;payload > 0xFF; payload -= 0xFF, ++payloadBytes); +for(;payload >= 0xFF; payload -= 0xFF, ++payloadBytes); if(payloadBytes > 1) { diff -r dccf02340c75 -r f4de3ccf9891 source/encoder/encoder.cpp --- a/source/encoder/encoder.cppThu May 25 10:31:58 2017 +0530 +++ b/source/encoder/encoder.cppTue May 23 12:42:54 2017 +0530 @@ -607,8 +607,13 @@ uint8_t *cim = NULL; if (m_hdr10plus_api->hdr10plus_json_to_frame_cim(m_param->toneMapFile, pic_in->poc, cim)) { -toneMap.payload = (uint8_t*)x265_malloc(sizeof(uint8_t) * cim[0]); -toneMap.payloadSize = cim[0]; +int32_t i = 0; +toneMap.payloadSize = 0; +while (cim[i] == 0xFF) +toneMap.payloadSize += cim[i++] + 1; +toneMap.payloadSize += cim[i] + 1; + +toneMap.payload = (uint8_t*)x265_malloc(sizeof(uint8_t) * toneMap.payloadSize); toneMap.payloadType = USER_DATA_REGISTERED_ITU_T_T35; memcpy(toneMap.payload, cim, toneMap.payloadSize); } diff -r dccf02340c75 -r f4de3ccf9891 source/encoder/sei.h --- a/source/encoder/sei.h Thu May 25 10:31:58 2017 +0530 +++ b/source/encoder/sei.h Tue May 23 12:42:54 2017 +0530 @@ -289,12 +289,10 @@ while (cim[i] == 0xFF) { i++; -payloadSize += cim[i]; WRITE_CODE(0xFF, 8, "payload_size"); } -WRITE_CODE(payloadSize, 8, "payload_size"); +WRITE_CODE(cim[i], 8, "payload_size"); i++; -payloadSize += i; for (; i < payloadSize; ++i) WRITE_CODE(cim[i], 8, "creative_intent_metadata"); } ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel
[x265] [PATCH 2 of 2] remove redundant file reads
# HG changeset patch # User Bhavna Hariharan# Date 1497957678 -19800 # Tue Jun 20 16:51:18 2017 +0530 # Branch stable # Node ID 12efe46f4872d4e7e2e6bbc197b5a7dce0064642 # Parent f4de3ccf989164ed89cc48e49e55d627a8414522 remove redundant file reads diff -r f4de3ccf9891 -r 12efe46f4872 source/encoder/encoder.cpp --- a/source/encoder/encoder.cppTue May 23 12:42:54 2017 +0530 +++ b/source/encoder/encoder.cppTue Jun 20 16:51:18 2017 +0530 @@ -88,6 +88,8 @@ #if ENABLE_DYNAMIC_HDR10 m_hdr10plus_api = hdr10plus_api_get(); +numCimInfo = 0; +cim = NULL; #endif m_prevTonemapPayload.payload = NULL; @@ -431,6 +433,10 @@ void Encoder::destroy() { +#if ENABLE_DYNAMIC_HDR10 +m_hdr10plus_api->hdr10plus_clear_movie(cim, numCimInfo); +#endif + if (m_exportedPic) { ATOMIC_DEC(_exportedPic->m_countRefEncoders); @@ -604,18 +610,19 @@ #if ENABLE_DYNAMIC_HDR10 if (m_bToneMap) { -uint8_t *cim = NULL; -if (m_hdr10plus_api->hdr10plus_json_to_frame_cim(m_param->toneMapFile, pic_in->poc, cim)) +if (pic_in->poc == 0) +numCimInfo = m_hdr10plus_api->hdr10plus_json_to_movie_cim(m_param->toneMapFile, cim); +if (pic_in->poc < numCimInfo) { int32_t i = 0; toneMap.payloadSize = 0; -while (cim[i] == 0xFF) -toneMap.payloadSize += cim[i++] + 1; -toneMap.payloadSize += cim[i] + 1; +while (cim[i][pic_in->poc] == 0xFF) +toneMap.payloadSize += cim[pic_in->poc][i++] + 1; +toneMap.payloadSize += cim[pic_in->poc][i] + 1; toneMap.payload = (uint8_t*)x265_malloc(sizeof(uint8_t) * toneMap.payloadSize); toneMap.payloadType = USER_DATA_REGISTERED_ITU_T_T35; -memcpy(toneMap.payload, cim, toneMap.payloadSize); +memcpy(toneMap.payload, cim[pic_in->poc], toneMap.payloadSize); } } #endif diff -r f4de3ccf9891 -r 12efe46f4872 source/encoder/encoder.h --- a/source/encoder/encoder.h Tue May 23 12:42:54 2017 +0530 +++ b/source/encoder/encoder.h Tue Jun 20 16:51:18 2017 +0530 @@ -178,6 +178,8 @@ #ifdef ENABLE_DYNAMIC_HDR10 const hdr10plus_api *m_hdr10plus_api; +uint8_t **cim; +int numCimInfo; #endif x265_sei_payloadm_prevTonemapPayload; ___ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel