Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Fix B-frame without positive reference frames as P-frame. #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luofalei
Copy link
Contributor

The B frame in the key position only have negative reference frames in the ramdom access prediction structure. For example the frames whose pictureNumber is 8 (POC 8) could only reference frame POC 0.
Using B_SLICE for this picture would bring in more header bits in the bit-stream and may bring in more computation.

So I suggest to fix their type as P-frame.

@lijing0010
Copy link
Contributor

Hi Falei, if changing it from B to P, then there'll be no Bidir latter, this will affect the quality.

@luofalei
Copy link
Contributor Author

@lijing0010 Thank you very much, Does this have noteworthy quality loss?
Furthermore, I want to confirm whether this commit is a complete fix (since the RPS derivation process appears in many files). Thanks.

@luofalei
Copy link
Contributor Author

luofalei commented May 9, 2019

I found this patch could cause deadlock problem with 1B configuration by setting HierarchicalLevels to 1. The following is my configuration file. I tried 5 sequences with the same resoltution, all of them stopped after 139 frames had been coded.
I'm not clear how to fix this bug in the patch, can you give some suggestions or help me solve this? Thanks a lot.

# Copyright(c) 2018 Intel Corporation 
# SPDX-License-Identifier: BSD-2-Clause-Patent

#====================== File I/O ===============================
InputFile                       : D:\Seq\BasketballPass_416x240_50.yuv      # input yuv 420 file path
StreamFile                      : test.hevc           # Output bit stream file path
ReconFile                       : rec.yuv
ErrorFile                       : SvtLog.txt          # Error log displaying configuration or encode errors
UseQpFile                       : 0                   # When set to 1, overwrite the encoder picture qp assignment using qp values in QpFile (0: OFF, 1: ON)
QpFile                          : SvtQp.txt           # File with rows of QP values corresponding to QP values for each frame


#====================== Encoding Presets ===============================
EncoderMode                     : 9             # Encoder Preset [0,12] 0 = highest quality, 12 = highest speed, 9 = default (not all resolutions support all 13 presets, please refer to section 3.4 in the users guide for more info)
LatencyMode                     : 0             # Low Latency Mode (0: OFF, 1: ON)
SpeedControlFlag                : 0             # Enable the speed control (0: OFF, 1: ON), encoder will do the best effort to run in real-time mode at the best quality using all resources available. 
                                                # The target speed is set to FrameRate. 
                                                # Injector will be set to 1 FrameRateNumerator is set to FrameRate

#====================== Bit-depth ===============================
EncoderBitDepth                 : 8             # Input and output bit-depth along with the encoder operating bit-depth (8: 8-bit , 10: 10-bit)	 
CompressedTenBitFormat          : 0             # Off-line packing of the 2bits: requires a compressed 10bit input (0: OFF, 1: ON)

#====================== Source Definitions ===================
SourceWidth                     : 416          # [64 - 8192]
SourceHeight                    : 240          # [64 - 4320]
FrameToBeEncoded                : 200             # Number of frames to be coded (0 for all frames in file)
BufferedInput                   : -1            # Buffers N-frames to avoid reading from disk. Use -1 to not buffer. 

#====================== Annex A definitions ======================
Profile                         : 2             # 1: Main, 2: Main 10
Tier                            : 0             # 0: Main, 1: High 
Level                           : 0             # 0: Level determined by the encoder, [1, 2, 2.1,3, 3.1, 4, 4.1, 5, 5.1, 6, 6.1, 6.2]: Level configurable  

#====================== Frame Rate ===============================
FrameRate                       : 50            # Frame Rate per second
FrameRateNumerator              : 50             # Frame Rate Numerator
FrameRateDenominator            : 1             # Frame Rate Denominator
Injector                        : 0             # Enable injection of input frames at the specified frame rate (0: OFF, 1: ON)
InjectorFrameRate               : 50            # Frame Rate used for the injector. Recommended to match the encoder speed 

#====================== Interlaced Video ===============================
InterlacedVideo                 : 0             # SEI messages for interlaced video (0: OFF, 1: ON)
SeparateFields                  : 0             # Separate the Top and Bottom fields of the input video (0: OFF, 1: ON)

#====================== Coding Structure ===============================
HierarchicalLevels              : 1             # Minigop Size = (2^HierarchicalLevels) (e.g. 3 == > 7B pyramid, 2 == > 3B Pyramid) [0-3]
BaseLayerSwitchMode             : 0             # 0 : Use B-frames in the base layer pointing to the same past picture
                                                # 1 : Use P-frames in the base layer
PredStructure                   : 2             # 0: Low Delay P
                                                # 1: Low Delay B
                                                # 2: Random Access

IntraPeriod                     : -2            # Period of I-Frame (-1 = only first, -2 = auto) [-2 - 255]
IntraRefreshType                : 1             # Random Accesss 1:CRA, 2:IDR (when IntraPeriod > 0) - [1-2]

#====================== Quantization ===============================
QP                              : 32            # Quantization parameter - [0-51]

#====================== Deblock Filter ===============================
LoopFilterDisable               : 0             # Disable loop filter (0=Filter, 1=No Filter)

#====================== Sample Adaptive Offset ===============================
SAO                             : 0             # Enable SAO  (0: OFF, 1: ON)

#====================== ME Tools ===============================
UseDefaultMeHme                 : 1             # Use Default ME HME Params (0: Overwrite , 1: Default)
HME                             : 1             # Enable HME (0: OFF, 1: ON)
HMELevel0                       : 1             # Enable HME Level 0 (0: OFF, 1: ON)
HMELevel1                       : 0             # Enable HME Level 0 + Level 1 (0: OFF, 1: ON)
HMELevel2                       : 0             # Enable HME Level 0 + Level 1 + Level 2 (0: OFF, 1: ON)

#======================ME Parameters ===============================
SearchAreaWidth                 : 16            # Number of search positions in the horizontal direction - [1-256]

SearchAreaHeight                : 7             # Number of search positions in the vertical direction - [1-256]

#====================== HME Parameters ===============================
NumberHmeSearchRegionInWidth    : 2             # Number of HME search regions in the horizontal direction - [1-2]
NumberHmeSearchRegionInHeight   : 2             # Number of HME search regions in the vertical direction - [1-2]

HmeLevel0TotalSearchAreaWidth   : 64            # Total search area width for HME level 0
HmeLevel0TotalSearchAreaHeight  : 25            # Total search area height for HME level 0

HmeLevel0SearchAreaInWidth      : 32 32         # Array containing search area width values for HME level 0 - [1 - SourceWidth /4]
HmeLevel0SearchAreaInHeight     : 12 13         # Array containing search area height values for HME level 0 - [1 - SourceHeight /4]
HmeLevel1SearchAreaInWidth      : 1  1          # Array containing search area width values for HME level 1 - [1 - SourceWidth /2]
HmeLevel1SearchAreaInHeight     : 1  1          # Array containing search area height values for HME level 1 - [1 - SourceHeight /2]
HmeLevel2SearchAreaInWidth      : 1  1          # Array containing search area width values for HME level 2 - [1 - SourceWidth]
HmeLevel2SearchAreaInHeight     : 1  1          # Array containing search area height values for HME level 2 - [1 - SourceHeight]

#====================== Rate Control ===============================
RateControlMode                 : 0             # Rate control mode (0: OFF(CQP), 1: VBR)
TargetBitRate                   : 7000000       # Target Bit Rate (in bits per second)
MaxQpAllowed                    : 48            # maximum allowed QP when rate control is on - [0-51]
MinQpAllowed                    : 10            # minimum allowed QP when rate control is on - [0-51]
LookAheadDistance               : 17            # Enable Look Ahead [0-256]
SceneChangeDetection            : 1             # Enable Scene Change Detection (0: OFF, 1: ON)

#====================== Tune ===============================
Tune                            : 0             # Tune (0=SQ - subjective quality mode, 1=OQ - objective quality mode [Default: 1]) 

#====================== Adaptive QP Params ===============================
BitRateReduction                : 1             # BitRate Reduction (only applicable when Tune is set to 0) (0= OFF, 1=ON )
ImproveSharpness                : 1             # Improve sharpness (only applicable when Tune is set to 0) (0= OFF, 1=ON )

# ====================== Optional Features ===============================
VideoUsabilityInfo              : 0             # Extra Information to enhance the use of video for display purposes..etc (0= OFF, 1=ON )
HighDynamicRangeInput           : 0             # Signals that the input yuv is HDR BT2020 using SMPTE ST2048 (requires VideoUsabilityInfo to be set to 1) (Only applicable for 10bit input) (0= OFF, 1=ON )
AccessUnitDelimiter             : 0             # Used to simplify the detection of boundary between access units (0= OFF, 1=ON )
BufferingPeriod                 : 0             # SEI message (0= OFF, 1=ON )
PictureTiming                   : 0             # SEI message (0= OFF, 1=ON ). If 1, VideoUsabilityInfo should be also set to 1.
RegisteredUserData              : 0             # SEI message (0= OFF, 1=ON )
UnregisteredUserData            : 0             # SEI message (0= OFF, 1=ON )
RecoveryPoint                   : 0             # SEI message (0= OFF, 1=ON )
TemporalId                      : 1             # 0: OFF, 1: Insert temporal ID in NAL units 

====================== Platform Specific Flags ===============================
AsmType                         : 1             # Assembly instruction set (0: non-AVX2, 1: up to AVX512 (Default: set based on platform capabilities) )
UseRoundRobinThreadAssignment   : 0             # For dual socket systems running Windows OS only on systems with > 32 physical processors. When enabled, allows the encoder to run on both sockets  (0= OFF, 1=ON )
TargetSocket                    : 0             # For Windows based dual socket systems only, this can specify which socket the encoder should start / run on (depending on whether UseRoundRobinThreadAssignment is set to 1 or 0) 0= Socket 0, 1=Socket 1 )

@kelvinhu325
Copy link

@lijing0010 Thank you very much, Does this have noteworthy quality loss?
Furthermore, I want to confirm whether this commit is a complete fix (since the RPS derivation process appears in many files). Thanks.

@kelvinhu325 kelvinhu325 reopened this May 13, 2019
@kelvinhu325
Copy link

When getting the same quality, the B frame can gets higher compressing rate than the P frame for Bidirect mode is enabled

@Austin-Hu
Copy link
Contributor

Hi @luofalei ,

Agree with @kelvinhu325 that B frame could get higher compression rate. And the picture type has been assigned in PictureDecisionKernel() function with some conditions, such as GOP info, IDR, CRA, etc., but not depends on whether it has positive ref frame or not (in random access). Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants