From aa7bd4b616e44ea50cbe618b71f8edee83cbf6fb Mon Sep 17 00:00:00 2001 From: Akilan Sivakumar Date: Tue, 6 Oct 2026 15:59:09 +0530 Subject: [PATCH 1/3] Fix --field CLI skipping every other frame and hanging --- source/abrEncApp.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/abrEncApp.cpp b/source/abrEncApp.cpp index d9b2cedec..f30ada0bd 100644 --- a/source/abrEncApp.cpp +++ b/source/abrEncApp.cpp @@ -970,8 +970,11 @@ namespace X265_NS { int numEncoded = api->encoder_encode(m_encoder, &p_nal, &nal, picInput, pic_recon); int idx = (inFrameCount - 1) % m_parent->m_queueSize; - m_parent->m_picIdxReadCnt[m_id][idx].incr(); - m_parent->m_picReadCnt[m_id].incr(); + if (inputNum == inputPicNum - 1) + { + m_parent->m_picIdxReadCnt[m_id][idx].incr(); + m_parent->m_picReadCnt[m_id].incr(); + } if (m_cliopt.loadLevel && picInput) { m_parent->m_analysisReadCnt[m_cliopt.refId].incr(); From cf9bae940fb462002b7e16e92b21ad348e8e3785 Mon Sep 17 00:00:00 2001 From: Akilan Sivakumar Date: Tue, 6 Oct 2026 17:37:20 +0530 Subject: [PATCH 2/3] Fix pic_struct for --field to signal top/bottom field --- source/encoder/frameencoder.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/encoder/frameencoder.cpp b/source/encoder/frameencoder.cpp index a3bf77183..fe2f3dbbd 100644 --- a/source/encoder/frameencoder.cpp +++ b/source/encoder/frameencoder.cpp @@ -804,19 +804,18 @@ void FrameEncoder::compressFrame(int layer) { if (m_param->interlaceMode > 0) { + // field_seq_flag is 1, so each picture is a single field: 1 = top field, 2 = bottom field if( m_param->interlaceMode == 2 ) - { - // m_picStruct should be set to 3 or 4 when field feature is enabled + { if (m_param->bField) - // 3: Top field, bottom field, in that order; 4: Bottom field, top field, in that order - sei->m_picStruct = (slice->m_fieldNum == 1) ? 4 : 3; + sei->m_picStruct = (slice->m_fieldNum == 1) ? 2 /* bottom */ : 1 /* top */; else sei->m_picStruct = (poc & 1) ? 1 /* top */ : 2 /* bottom */; } else if (m_param->interlaceMode == 1) { if (m_param->bField) - sei->m_picStruct = (slice->m_fieldNum == 1) ? 3: 4; + sei->m_picStruct = (slice->m_fieldNum == 1) ? 1 /* top */ : 2 /* bottom */; else sei->m_picStruct = (poc & 1) ? 2 /* bottom */ : 1 /* top */; } From 6d3fd07a65f988dc60167c2e82d11f936d9f6b4c Mon Sep 17 00:00:00 2001 From: Akilan Sivakumar Date: Wed, 7 Oct 2026 08:23:12 +0530 Subject: [PATCH 3/3] Fix --field bff to use the bottom field as the first field --- source/abrEncApp.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/abrEncApp.cpp b/source/abrEncApp.cpp index f30ada0bd..146b28dff 100644 --- a/source/abrEncApp.cpp +++ b/source/abrEncApp.cpp @@ -830,12 +830,13 @@ namespace X265_NS { if (pic_in[view]->framesize) { + bool bBff = m_param->interlaceMode == 2; for (int i = 0; i < x265_cli_csps[pic_in[view]->colorSpace].planes; i++) { - char* srcP1 = (char*)pic_in[view]->planes[i]; - char* srcP2 = (char*)pic_in[view]->planes[i] + pic_in[view]->stride[i]; - char* p1 = (char*)picField1.planes[i]; - char* p2 = (char*)picField2.planes[i]; + char* srcP1 = static_cast(pic_in[view]->planes[i]) + (bBff ? pic_in[view]->stride[i] : 0); + char* srcP2 = static_cast(pic_in[view]->planes[i]) + (bBff ? 0 : pic_in[view]->stride[i]); + char* p1 = static_cast(picField1.planes[i]); + char* p2 = static_cast(picField2.planes[i]); int stride = picField1.stride[i];