Skip to content

Commit

Permalink
Removing -irefresh-type option from VP9 encoder (#98)
Browse files Browse the repository at this point in the history
Force idr_flag on (VP9 does not appear to support cra in bitstreams)

Signed-off-by: Mark Feldman <[email protected]>
  • Loading branch information
intelmark authored May 6, 2020
1 parent fee9c46 commit 7ff45ce
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 150 deletions.
1 change: 0 additions & 1 deletion Config/Sample.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ BaseLayerSwitchMode : 0 # 0 : Use B-frames in the base l
PredStructure : 2 # 2: Random Access

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

#====================== Quantization ===============================
QP : 56 # Quantization parameter - [0-63]
Expand Down
6 changes: 3 additions & 3 deletions Docs/svt-vp9_encoder_user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The number of frames of the sequence to encode. e.g. 100. If the input frame co

>-intra-period integer **[Optional]**
The intra period defines the interval of frames after which you insert an Intra refresh. It is strongly recommended to use (multiple of 8) -1 the closest to 1 second (e.g. 55, 47, 31, 23 should be used for 60, 50, 30, (24 or 25) respectively). When using closed gop (-irefresh-type 2) add 1 to the value above (e.g. 56 instead of 55).
The intra period defines the interval of frames after which you insert an Intra refresh. It is strongly recommended to use (multiple of 8) -1 the closest to 1 second (e.g. 55, 47, 31, 23 should be used for 60, 50, 30, (24 or 25) respectively). Because all intra refreshes are closed gop add 1 to the value above (e.g. 56 instead of 55).

>-rc integer **[Optional]**
Expand Down Expand Up @@ -102,7 +102,6 @@ The encoder parameters present in the Sample.cfg file are listed in this table b
| **BaseLayerSwitchMode** | -base-layer-switch-mode | [0 - 1] | 0 | 0 = Use B-frames in the base layer pointing to the same past picture. <br>1 = Use P-frames in the base layer|
| **PredStructure** | -pred-struct | [2] | 2 | 2 = Random Access.|
| **IntraPeriod** | -intra-period | [-2 - 255] | -2 | Distance Between Intra Frame inserted. -1 denotes no intra update. -2 denotes auto. |
| **IntraRefreshType** | -irefresh-type | [1 - 2] | 2 | 1 = CRA (Open GOP) <br>2 = IDR (Closed GOP) |
| **QP** | -q | [0 - 63] | 50 | Initial quantization parameter for the Intra pictures used when RateControlMode 0 (CQP) |
| **LoopFilter** | -loop-filter | [0 - 1] | 1 | Enables or disables the loop filter, <br>0 = OFF, 1 = ON |
| **UseDefaultMeHme** | -use-default-me-hme | [0 - 1] | 1 | 0 = Overwrite Default ME HME parameters. <br>1 = Use default ME HME parameters, dependent on width and height |
Expand All @@ -117,7 +116,8 @@ The encoder parameters present in the Sample.cfg file are listed in this table b
| **MinQpAllowed** | -min-qp | [0 - 63] | 10 | Minimum QP value allowed for rate control use. Only used when RateControlMode is set to 1. Has to be < MaxQpAllowed |
| **AsmType** | -asm | [0 - 1] | 1 | Assembly instruction set (0 = C Only, 1 = Automatically select highest assembly instruction set supported) |
| **LogicalProcessorNumber** | -lp | [0, total number of logical processor] | 0 | The number of logical processor which encoder threads run on.Refer to Appendix A.1 |
| **TargetSocket** | -ss | [-1,1] | -1 | For dual socket systems, this can specify which socket the encoder runs on.Refer to Appendix A.1 || **SwitchThreadsToRtPriority** | -rt | [0 - 1] | 1 | Enables or disables threads to real time priority, 0 = OFF, 1 = ON (only works on Linux) |
| **TargetSocket** | -ss | [-1,1] | -1 | For dual socket systems, this can specify which socket the encoder runs on.Refer to Appendix A.1 |
| **SwitchThreadsToRtPriority** | -rt | [0 - 1] | 1 | Enables or disables threads to real time priority, 0 = OFF, 1 = ON (only works on Linux) |
| **Profile** | -profile | [0] | 0 | 0 = 8-bit 4:2:0 |
| **Level** | -level | [1, 2, 2.1,3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2] | 0 | 0 to 6.2 [0 for auto determine Level] |

Expand Down
6 changes: 0 additions & 6 deletions Source/API/EbSvtVp9Enc.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ typedef struct EbSvtVp9EncConfiguration
* Deault is -2. */
int32_t intra_period;

/* Random access.
* 1 = CRA, open GOP.
* 2 = IDR, closed GOP.
* Default is 1. */
uint32_t intra_refresh_type;

/* Prediction structure used to construct GOP. There are two main structures
* supported, which are: Low Delay (P or B) and Random Access.
*
Expand Down
4 changes: 0 additions & 4 deletions Source/App/EbAppConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#define LEVEL_TOKEN "-level"
#define INTERLACED_VIDEO_TOKEN "-interlaced-video"
#define SEPERATE_FILDS_TOKEN "-separate-fields"
#define INTRA_REFRESH_TYPE_TOKEN "-irefresh-type" // no Eval
#define LOOP_FILTER_TOKEN "-loop-filter"
#define USE_DEFAULT_ME_HME_TOKEN "-use-default-me-hme"
#define HME_ENABLE_TOKEN "-hme" // no Eval
Expand Down Expand Up @@ -145,7 +144,6 @@ static void set_encoder_bit_depth (const char *value, EbCon
static void set_base_layer_switch_mode (const char *value, EbConfig *cfg) {cfg->base_layer_switch_mode = (uint8_t) strtoul(value, NULL, 0);};
static void set_enc_mode (const char *value, EbConfig *cfg) {cfg->enc_mode = (uint8_t)strtoul(value, NULL, 0);};
static void set_cfg_intra_period (const char *value, EbConfig *cfg) {cfg->intra_period = strtol(value, NULL, 0);};
static void set_cfg_intra_refresh_type (const char *value, EbConfig *cfg) {cfg->intra_refresh_type = strtol(value, NULL, 0);};
static void set_cfg_pred_structure (const char *value, EbConfig *cfg) { cfg->pred_structure = strtol(value, NULL, 0); };
static void set_cfg_qp (const char *value, EbConfig *cfg) {cfg->qp = strtoul(value, NULL, 0);};
static void set_cfg_use_qp_file (const char *value, EbConfig *cfg) {cfg->use_qp_file = (uint8_t)strtol(value, NULL, 0); };
Expand Down Expand Up @@ -222,7 +220,6 @@ ConfigEntry config_entry[] = {
{ SINGLE_INPUT, BASE_LAYER_SWITCH_MODE_TOKEN, "BaseLayerSwitchMode", set_base_layer_switch_mode },
{ SINGLE_INPUT, ENCMODE_TOKEN, "EncoderMode", set_enc_mode},
{ SINGLE_INPUT, INTRA_PERIOD_TOKEN, "IntraPeriod", set_cfg_intra_period },
{ SINGLE_INPUT, INTRA_REFRESH_TYPE_TOKEN, "IntraRefreshType", set_cfg_intra_refresh_type },
{ SINGLE_INPUT, FRAME_RATE_TOKEN, "FrameRate", set_frame_rate },
{ SINGLE_INPUT, FRAME_RATE_NUMERATOR_TOKEN, "FrameRateNumerator", set_frame_rate_numerator },
{ SINGLE_INPUT, FRAME_RATE_DENOMINATOR_TOKEN, "FrameRateDenominator", set_frame_rate_denominator },
Expand Down Expand Up @@ -311,7 +308,6 @@ void eb_config_ctor(EbConfig *config_ptr)

config_ptr->enc_mode = 9;
config_ptr->intra_period = -2;
config_ptr->intra_refresh_type = 2;

config_ptr->pred_structure = 2;

Expand Down
1 change: 0 additions & 1 deletion Source/App/EbAppConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ typedef struct EbConfig
uint32_t base_layer_switch_mode;
uint8_t enc_mode;
int32_t intra_period;
uint32_t intra_refresh_type;
uint32_t pred_structure;

/****************************************
Expand Down
1 change: 0 additions & 1 deletion Source/App/EbAppContext.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ EbErrorType copy_configuration_parameters(
callback_data->eb_enc_parameters.source_width = config->source_width;
callback_data->eb_enc_parameters.source_height = config->source_height;
callback_data->eb_enc_parameters.intra_period = config->intra_period;
callback_data->eb_enc_parameters.intra_refresh_type = config->intra_refresh_type;
callback_data->eb_enc_parameters.base_layer_switch_mode = config->base_layer_switch_mode;
callback_data->eb_enc_parameters.enc_mode = (uint8_t)config->enc_mode;
callback_data->eb_enc_parameters.frame_rate = config->frame_rate;
Expand Down
9 changes: 0 additions & 9 deletions Source/Lib/Codec/EbDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,6 @@ typedef struct EbH265DynEncConfiguration {
uint32_t available_target_bitrate;
} EbH265DynEncConfiguration;

/** The EbIntraRefreshType is used to describe the intra refresh type.
*/
typedef enum EbIntraRefreshType
{
NO_REFRESH = 0,
CRA_REFRESH = 1,
IDR_REFRESH = 2
} EbIntraRefreshType;

#ifdef __GNUC__
#define EB_ALIGN(n) __attribute__((__aligned__(n)))
#elif defined(_MSC_VER)
Expand Down
15 changes: 2 additions & 13 deletions Source/Lib/Codec/EbEncHandle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,6 @@ EbErrorType eb_vp9_svt_enc_init_parameter(
config_ptr->base_layer_switch_mode = 0;
config_ptr->enc_mode = 3;
config_ptr->intra_period = 31;
config_ptr->intra_refresh_type = 1;
config_ptr->pred_structure = EB_PRED_RANDOM_ACCESS;
config_ptr->loop_filter = EB_TRUE;
config_ptr->use_default_me_hme = EB_TRUE;
Expand Down Expand Up @@ -1915,9 +1914,6 @@ static int32_t compute_default_intra_period(

intra_period = (ABS((fps - max_ip)) > ABS((fps - min_ip))) ? min_ip : max_ip;

if (config->intra_refresh_type == 1)
intra_period -= 1;

return intra_period;
}

Expand Down Expand Up @@ -1965,14 +1961,12 @@ void copy_api_from_app(

// Coding Structure
sequence_control_set_ptr->static_config.intra_period = ((EbSvtVp9EncConfiguration*)p_component_parameter_structure)->intra_period;
sequence_control_set_ptr->static_config.intra_refresh_type = ((EbSvtVp9EncConfiguration*)p_component_parameter_structure)->intra_refresh_type;
sequence_control_set_ptr->static_config.pred_structure = ((EbSvtVp9EncConfiguration*)p_component_parameter_structure)->pred_structure;
sequence_control_set_ptr->static_config.base_layer_switch_mode = ((EbSvtVp9EncConfiguration*)p_component_parameter_structure)->base_layer_switch_mode;
sequence_control_set_ptr->static_config.tune = ((EbSvtVp9EncConfiguration*)p_component_parameter_structure)->tune;
sequence_control_set_ptr->static_config.enc_mode = ((EbSvtVp9EncConfiguration*)p_component_parameter_structure)->enc_mode;

sequence_control_set_ptr->intra_period = sequence_control_set_ptr->static_config.intra_period;
sequence_control_set_ptr->intra_refresh_type = sequence_control_set_ptr->static_config.intra_refresh_type;
sequence_control_set_ptr->max_ref_count = 1;

// Quantization
Expand Down Expand Up @@ -2279,10 +2273,6 @@ static EbErrorType verify_settings(
return_error = EB_ErrorBadParameter;
}

if (config->intra_refresh_type > 2 || config->intra_refresh_type < 1) {
SVT_LOG("Error Instance %u: Invalid intra Refresh Type [1-2]\n", channel_number + 1);
return_error = EB_ErrorBadParameter;
}
if (config->base_layer_switch_mode > 1) {
SVT_LOG("Error Instance %u: Invalid Base Layer Switch Mode [0-1] \n", channel_number + 1);
return_error = EB_ErrorBadParameter;
Expand Down Expand Up @@ -2475,10 +2465,9 @@ static void print_lib_params(
SVT_LOG("\nSVT [config]: EncoderBitDepth \t\t\t\t\t\t\t: %d ", config->encoder_bit_depth);
SVT_LOG("\nSVT [config]: SourceWidth / SourceHeight\t\t\t\t\t: %d / %d ", config->source_width, config->source_height);
if (config->frame_rate_denominator != 0 && config->frame_rate_numerator != 0)
SVT_LOG("\nSVT [config]: Fps_Numerator / Fps_Denominator / Gop Size / IntraRefreshType \t: %d / %d / %d / %d", config->frame_rate_numerator > (1 << 16) ? config->frame_rate_numerator >> 16 : config->frame_rate_numerator,
SVT_LOG("\nSVT [config]: Fps_Numerator / Fps_Denominator / Gop Size\t\t: %d / %d / %d", config->frame_rate_numerator > (1 << 16) ? config->frame_rate_numerator >> 16 : config->frame_rate_numerator,
config->frame_rate_denominator > (1 << 16) ? config->frame_rate_denominator >> 16 : config->frame_rate_denominator,
config->intra_period + 1,
config->intra_refresh_type);
config->intra_period + 1);
else
SVT_LOG("\nSVT [config]: FrameRate / Gop Size\t\t\t\t\t\t: %d / %d ", config->frame_rate > 1000 ? config->frame_rate >> 16 : config->frame_rate, config->intra_period + 1);
SVT_LOG("\nSVT [config]: HierarchicalLevels / BaseLayerSwitchMode / PredStructure\t\t: %d / %d / %d ", scs->hierarchical_levels, config->base_layer_switch_mode, config->pred_structure);
Expand Down
1 change: 0 additions & 1 deletion Source/Lib/Codec/EbEncodeContext.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ EbErrorType eb_vp9_encode_context_ctor(
encode_context_ptr->pred_struct_position = 0;
encode_context_ptr->current_input_poc = -1;
encode_context_ptr->elapsed_non_idr_count = 0;
encode_context_ptr->elapsed_non_cra_count = 0;
encode_context_ptr->initial_picture = EB_TRUE;

encode_context_ptr->last_idr_picture = 0;
Expand Down
1 change: 0 additions & 1 deletion Source/Lib/Codec/EbEncodeContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ typedef struct EncodeContext
uint32_t pred_struct_position; // Current position within a prediction structure

uint32_t elapsed_non_idr_count;
uint32_t elapsed_non_cra_count;
int64_t current_input_poc;
EB_BOOL initial_picture;

Expand Down
2 changes: 0 additions & 2 deletions Source/Lib/Codec/EbPictureControlSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ typedef struct PictureParentControlSet
EbObjectWrapper *pareference_picture_wrapper_ptr;

EB_BOOL idr_flag;
EB_BOOL cra_flag; // Hsan - to remove
EB_BOOL open_gop_cra_flag;
EB_BOOL scene_change_flag;
EB_BOOL end_of_sequence_flag;

Expand Down
Loading

0 comments on commit 7ff45ce

Please sign in to comment.