Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions doc/reST/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2536,14 +2536,26 @@ VUI fields must be manually specified.

Set the picture structure and emits it in the picture timing SEI message.
Values in the range 0..12. See D.3.3 of the HEVC spec. for a detailed explanation.
Required for HLG (Hybrid Log Gamma) signaling. Not signaled by default.

.. option:: --psfile <filename>

Specify a text file which contains the picture structure for some or all frames.
Allows for dynamic pulldown (VFR in CFR containers). The format of each line is

framenumber framefieldcoding picstruct

Framefieldcoding shall be 0, 1, 2 (progressive, bottom-first or top-first, resp.),
It shall not change for an encoded sequence and match the encoder configuration.

Picstruct is the structure to specify in the framenumber's Picture Timing SEI.
It shall be compatible with the encoder configuration for the given sequence.

.. option:: --video-signal-type-preset <string>

Specify combinations of color primaries, transfer characteristics, color matrix,
range of luma and chroma signals, and chroma sample location.
String format: <system-id>[:<color-volume>]

This has higher precedence than individual VUI parameters. If any individual VUI option
is specified together with this, which changes the values set corresponding to the system-id
or color-volume, it will be discarded.
Expand Down Expand Up @@ -2657,7 +2669,7 @@ Bitstream options
Picture Timing SEI messages providing timing information to the
decoder. Default disabled


.. option:: --hrd-concat, --no-hrd-concat

Set concatenation flag for the first keyframe in the HRD buffering period SEI. This
Expand Down
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ option(NATIVE_BUILD "Target the build CPU" OFF)
option(STATIC_LINK_CRT "Statically link C and C++ runtimes for release builds" OFF)
mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
# X265_BUILD must be incremented each time the public API is changed
set(X265_BUILD 217)
set(X265_BUILD 218)
configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
"${PROJECT_BINARY_DIR}/x265.def")
configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
Expand Down
10 changes: 10 additions & 0 deletions source/abrEncApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,16 @@ namespace X265_NS {
}
}

if (m_cliopt.psfile)
{
if (!m_cliopt.parsePSFile(pic_orig[view], m_param->interlaceMode, m_param->bField))
{
x265_log(NULL, X265_LOG_ERROR, "can't parse psfile for frame %d in %s\n",
pic_in[view]->poc, profileName);
fclose(m_cliopt.psfile);
m_cliopt.psfile = NULL;
}
}
if (m_cliopt.framesToBeEncoded && inFrameCount >= m_cliopt.framesToBeEncoded)
pic_in[view] = NULL;
else if (readPicture(pic_in[view], view)){
Expand Down
1 change: 1 addition & 0 deletions source/abrEncApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ namespace X265_NS {
CLIOptions m_cliopt;
InputFile* m_input[MAX_VIEWS];
const char* m_reconPlayCmd;
FILE* m_psfile;
FILE* m_qpfile;
FILE* m_zoneFile;
FILE* m_dolbyVisionRpu;/* File containing Dolby Vision BL RPU metadata */
Expand Down
8 changes: 7 additions & 1 deletion source/common/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Frame::Frame()
m_addOnPrevChange = NULL;
m_classifyFrame = false;
m_fieldNum = 0;
m_picStruct = 0;
m_picStruct = PIC_STRUCT_AUTO;
m_edgePic = NULL;
m_gaussianPic = NULL;
m_thetaPic = NULL;
Expand All @@ -85,6 +85,12 @@ Frame::Frame()
m_targetBitrate = 0;
m_targetCrf = 0;
m_targetQp = 0;

/* HRD */
m_duration = m_cpbDuration = 0;
m_cpbDelay = m_dpbDelay = 0;
m_displayPicCount = m_codedPicCount = 0;
m_timebase = 0.;
}

bool Frame::create(x265_param *param, float* quantOffsets)
Expand Down
9 changes: 9 additions & 0 deletions source/common/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ class Frame
/* target QP for this picture.*/
int m_targetQp;

/* HRD timing for this frame */
uint32_t m_duration; /* display duration [clock ticks] */
uint32_t m_cpbDuration; /* lifetime in the CPB [clock ticks] */
uint32_t m_cpbDelay; /* CPB removal delay [clock ticks] */
uint32_t m_dpbDelay; /* DPB output delay [clock ticks] */
int64_t m_displayPicCount; /* PTS in clock ticks */
int64_t m_codedPicCount; /* DTS in clock ticks */
double m_timebase; /* timebase for this picture [seconds] */

Frame();

bool create(x265_param *param, float* quantOffsets);
Expand Down
12 changes: 11 additions & 1 deletion source/common/lowres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ void Lowres::init(PicYuv* origPic, int poc, bool bEnableTemporalFilter)
frameNum = poc;
leadingBframes = 0;
indB = 0;

cpbDurationSecs = 0.;
dispDurationSecs = 0.;
dispPicCount = durationPicCount = 0;

memset(costEst, -1, sizeof(costEst));
memset(weightedCostDelta, 0, sizeof(weightedCostDelta));

Expand All @@ -372,8 +377,13 @@ void Lowres::init(PicYuv* origPic, int poc, bool bEnableTemporalFilter)
for (int i = 0; i < bframes + 2; i++)
intraMbs[i] = 0;
if (origPic->m_param->rc.vbvBufferSize)
{
for (int i = 0; i < X265_LOOKAHEAD_MAX + 1; i++)
{
plannedType[i] = X265_TYPE_AUTO;
plannedCpbDuration[i] = origPic->m_param->fpsDenom / (double)origPic->m_param->fpsNum;
}
}

/* downscale and generate 4 hpel planes for lookahead */
if (bEnableTemporalFilter)
Expand All @@ -386,7 +396,7 @@ void Lowres::init(PicYuv* origPic, int poc, bool bEnableTemporalFilter)
extendPicBorder(lowresPlane[1], lumaStride, width, lines, origPic->m_lumaMarginX, origPic->m_lumaMarginY);
extendPicBorder(lowresPlane[2], lumaStride, width, lines, origPic->m_lumaMarginX, origPic->m_lumaMarginY);
extendPicBorder(lowresPlane[3], lumaStride, width, lines, origPic->m_lumaMarginX, origPic->m_lumaMarginY);

if (origPic->m_param->bEnableHME || origPic->m_param->bEnableTemporalFilter)
{
if (bEnableTemporalFilter)
Expand Down
6 changes: 6 additions & 0 deletions source/common/lowres.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ struct Lowres : public ReferencePlanes
/* used for vbvLookahead */
int plannedType[X265_LOOKAHEAD_MAX + 1];
int64_t plannedSatd[X265_LOOKAHEAD_MAX + 1];
double plannedCpbDuration[X265_LOOKAHEAD_MAX + 1];
int indB;
int bframes;

Expand All @@ -222,6 +223,11 @@ struct Lowres : public ReferencePlanes
double frameVariance;
int* edgeInclined;

/* Vbv Lookahead & cuTree durations */
double cpbDurationSecs;
double dispDurationSecs;
int64_t dispPicCount;
uint32_t durationPicCount;

/* cutree intermediate data */
PicQPAdaptationLayer* pAQLayer;
Expand Down
2 changes: 1 addition & 1 deletion source/common/param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ int x265_param_parse(x265_param* p, const char* name, const char* value)
else
{
float fps = (float)atof(value);
if (fps > 0 && fps <= INT_MAX / 1000)
if (fps > 0 && fps <= INT_MAX / 1000 && ceilf(fps) != floorf(fps))
{
p->fpsNum = (int)(fps * 1000 + .5);
p->fpsDenom = 1000;
Expand Down
2 changes: 1 addition & 1 deletion source/encoder/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ void x265_picture_init(x265_param *param, x265_picture *pic)
pic->userSEI.numPayloads = 0;
pic->rpu.payloadSize = 0;
pic->rpu.payload = NULL;
pic->picStruct = 0;
pic->picStruct = PIC_STRUCT_AUTO;
pic->vbvEndFlag = 0;

if ((strlen(param->analysisSave) || strlen(param->analysisLoad)) || (param->bAnalysisType == AVC_INFO))
Expand Down
Loading
Loading