Fixed display aspect ratio calculation for both AVC and HEVC. (#187)

* * rocDecode: Fixed display aspect ratio calculation.
 - We were assigning sample aspect ration (SAR) from VUI directly to display aspect ratio (DAR). Now we follow the correct procedure.

* * rocDecode: Fixed an error in display aspect ratio calculation. Should include sample aspect ratio in the final step.
Αυτή η υποβολή περιλαμβάνεται σε:
jeffqjiangNew
2024-01-18 14:31:54 -05:00
υποβλήθηκε από GitHub
γονέας 37e2725fec
υποβολή cf82317396
3 αρχεία άλλαξαν με 53 προσθήκες και 14 διαγραφές
+23 -5
Προβολή Αρχείου
@@ -203,15 +203,33 @@ int HevcVideoParser::FillSeqCallbackFn(HevcSeqParamSet* sps_data) {
}
video_format_params_.bitrate = 0;
// Dispaly aspect ratio
// Table E-1.
static const Rational hevc_sar[] = {
{0, 0}, // unspecified
{1, 1}, {12, 11}, {10, 11}, {16, 11}, {40, 33}, {24, 11}, {20, 11}, {32, 11},
{80, 33}, {18, 11}, {15, 11}, {64, 33}, {160, 99}, {4, 3}, {3, 2}, {2, 1},
};
Rational sar;
sar.numerator = 1; // set to square pixel if not present or unspecified
sar.denominator = 1; // set to square pixel if not present or unspecified
if (sps_data->vui_parameters_present_flag) {
if (sps_data->vui_parameters.aspect_ratio_info_present_flag) {
video_format_params_.display_aspect_ratio.x = sps_data->vui_parameters.sar_width;
video_format_params_.display_aspect_ratio.y = sps_data->vui_parameters.sar_height;
} else { // default values
video_format_params_.display_aspect_ratio.x = 0;
video_format_params_.display_aspect_ratio.y = 0;
if (sps_data->vui_parameters.aspect_ratio_idc == 255 /*Extended_SAR*/) {
sar.numerator = sps_data->vui_parameters.sar_width;
sar.denominator = sps_data->vui_parameters.sar_height;
} else if (sps_data->vui_parameters.aspect_ratio_idc > 0 && sps_data->vui_parameters.aspect_ratio_idc < 17) {
sar = hevc_sar[sps_data->vui_parameters.aspect_ratio_idc];
}
}
}
int disp_width = (video_format_params_.display_area.right - video_format_params_.display_area.left) * sar.numerator;
int disp_height = (video_format_params_.display_area.bottom - video_format_params_.display_area.top) * sar.denominator;
int gcd = std::__gcd(disp_width, disp_height); // greatest common divisor
video_format_params_.display_aspect_ratio.x = disp_width / gcd;
video_format_params_.display_aspect_ratio.y = disp_height / gcd;
if (sps_data->vui_parameters_present_flag) {
video_format_params_.video_signal_description.video_format = sps_data->vui_parameters.video_format;
video_format_params_.video_signal_description.video_full_range_flag = sps_data->vui_parameters.video_full_range_flag;