diff --git a/common/include/crcgenerator.h b/common/include/crcgenerator.h index 84d6556..c2dee83 100644 --- a/common/include/crcgenerator.h +++ b/common/include/crcgenerator.h @@ -17,6 +17,6 @@ #ifndef _CRC_GENERATOR_INCLUDED #define _CRC_GENERATOR_INCLUDED -extern unsigned long Crc32Table[256]; -void getCRC(uint32_t *checksum, const uint8_t *inputBytes, size_t length, unsigned long crcTable[]); +extern uint32_t Crc32Table[256]; +void getCRC(uint32_t *checksum, const uint8_t *inputBytes, size_t length, uint32_t crcTable[]); #endif //_CRC_GENERATOR_INCLUDED diff --git a/common/libs/VkCodecUtils/FrameProcessor.h b/common/libs/VkCodecUtils/FrameProcessor.h index ceeee65..765d787 100644 --- a/common/libs/VkCodecUtils/FrameProcessor.h +++ b/common/libs/VkCodecUtils/FrameProcessor.h @@ -86,7 +86,7 @@ class FrameProcessor : public VkVideoRefCountBase { if (timeDiffNanoseconds) { *timeDiffNanoseconds = diffNanoseconds; } - fps = (float)((double)(m_profileFramesCount * 1000000000) / diffNanoseconds); + fps = (float)((double)(m_profileFramesCount * 1000000000) / (double)diffNanoseconds); m_profileFramesCount = 0; displayTimeNow = true; } else { diff --git a/common/libs/VkCodecUtils/ProgramConfig.h b/common/libs/VkCodecUtils/ProgramConfig.h index 04e0e57..7467696 100644 --- a/common/libs/VkCodecUtils/ProgramConfig.h +++ b/common/libs/VkCodecUtils/ProgramConfig.h @@ -309,7 +309,7 @@ struct ProgramConfig { std::string token; while (std::getline(stream, token, ',')) { char* endPtr = NULL; - uint32_t initValue = strtoul(token.c_str(), &endPtr, 16); + uint32_t initValue = static_cast(strtoul(token.c_str(), &endPtr, 16)); if ((endPtr == NULL) || (*endPtr != 0)) { std::cerr << "Failed to parse the following initial CRC value:" << token << std::endl; diff --git a/common/libs/VkCodecUtils/VulkanFrame.cpp b/common/libs/VkCodecUtils/VulkanFrame.cpp index 6b0c568..6c3cd4c 100644 --- a/common/libs/VkCodecUtils/VulkanFrame.cpp +++ b/common/libs/VkCodecUtils/VulkanFrame.cpp @@ -383,7 +383,7 @@ bool VulkanFrame::OnFrame( int32_t renderIndex, if (gfxRendererIsEnabled == false) { - m_frameDataIndex = (m_frameDataIndex + 1) % m_frameData.size(); + m_frameDataIndex = (uint32_t)((m_frameDataIndex + 1) % m_frameData.size()); return continueLoop; } @@ -670,7 +670,7 @@ VkResult VulkanFrame::DrawFrame( int32_t renderIndex, close(fd); #endif - m_frameDataIndex = (m_frameDataIndex + 1) % m_frameData.size(); + m_frameDataIndex = ((m_frameDataIndex + 1) % (uint32_t)m_frameData.size()); return result; } diff --git a/common/libs/VkCodecUtils/VulkanFrame.h b/common/libs/VkCodecUtils/VulkanFrame.h index 9a67110..39e0221 100644 --- a/common/libs/VkCodecUtils/VulkanFrame.h +++ b/common/libs/VkCodecUtils/VulkanFrame.h @@ -97,7 +97,7 @@ class VulkanFrame : public FrameProcessor { std::vector m_memFlags; std::vector m_frameData; - int m_frameDataIndex; + uint32_t m_frameDataIndex; VkExtent2D m_extent; VkViewport m_viewport; diff --git a/common/libs/VkCodecUtils/VulkanShaderCompiler.cpp b/common/libs/VkCodecUtils/VulkanShaderCompiler.cpp index 20fc073..34effa4 100644 --- a/common/libs/VkCodecUtils/VulkanShaderCompiler.cpp +++ b/common/libs/VkCodecUtils/VulkanShaderCompiler.cpp @@ -42,7 +42,7 @@ static shaderc_shader_kind getShadercShaderType(VkShaderStageFlagBits type) default: std::cerr << "VulkanShaderCompiler: " << "invalid VKShaderStageFlagBits" << "type = " << type; } - return static_cast(-1); + return shaderc_glsl_infer_from_source; } VulkanShaderCompiler::VulkanShaderCompiler() @@ -108,7 +108,7 @@ VkShaderModule VulkanShaderCompiler::BuildShaderFromFile(const char *fileName, if (is.is_open()) { - size_t size = is.tellg(); + size_t size = (size_t)is.tellg(); is.seekg(0, std::ios::beg); char* shaderCode = new char[size]; is.read(shaderCode, size); diff --git a/common/libs/VkCodecUtils/VulkanVideoUtils.cpp b/common/libs/VkCodecUtils/VulkanVideoUtils.cpp index 22150bc..5116ef9 100644 --- a/common/libs/VkCodecUtils/VulkanVideoUtils.cpp +++ b/common/libs/VkCodecUtils/VulkanVideoUtils.cpp @@ -797,11 +797,11 @@ VkResult VulkanPerDrawContext::RecordCommandBuffer(VkCommandBuffer cmdBuffer, vk::TransformPushConstants constants; if (scaleInput) { if (displayWidth && (displayWidth != inputImageToDrawFrom->imageWidth)) { - constants.texMatrix[0] = vk::Vec2((float)displayWidth / inputImageToDrawFrom->imageWidth, 0.0f); + constants.texMatrix[0] = vk::Vec2((float)(double)displayWidth / (float)(double)inputImageToDrawFrom->imageWidth, 0.0f); } if (displayHeight && (displayHeight != inputImageToDrawFrom->imageHeight)) { - constants.texMatrix[1] = vk::Vec2(.0f, (float)displayHeight /inputImageToDrawFrom->imageHeight); + constants.texMatrix[1] = vk::Vec2(.0f, (float)(double)displayHeight / (float)(double)inputImageToDrawFrom->imageHeight); } } diff --git a/common/libs/VkCodecUtils/crcgenerator.cpp b/common/libs/VkCodecUtils/crcgenerator.cpp index e269a8c..8b8a580 100644 --- a/common/libs/VkCodecUtils/crcgenerator.cpp +++ b/common/libs/VkCodecUtils/crcgenerator.cpp @@ -19,7 +19,7 @@ #include "crcgenerator.h" -unsigned long Crc32Table[256] = { +uint32_t Crc32Table[256] = { // CRC32 lookup table // Generated by the following routine // int i, j; @@ -97,7 +97,7 @@ unsigned long Crc32Table[256] = { 0xb40bbe37,0xc30c8ea1,0x5a05df1b,0x2d02ef8d }; -void getCRC(uint32_t *checksum, const uint8_t *inputBytes, size_t length, unsigned long crcTable[]) +void getCRC(uint32_t *checksum, const uint8_t *inputBytes, size_t length, uint32_t crcTable[]) { for (size_t i = 0; i < length; i += 1) { *checksum = crcTable[inputBytes[i] ^ (*checksum & 0xff)] ^ (*checksum >> 8); diff --git a/common/libs/VkShell/ShellXcb.cpp b/common/libs/VkShell/ShellXcb.cpp index 10d53c8..68d20ec 100644 --- a/common/libs/VkShell/ShellXcb.cpp +++ b/common/libs/VkShell/ShellXcb.cpp @@ -28,7 +28,7 @@ namespace { xcb_intern_atom_cookie_t intern_atom_cookie(xcb_connection_t *c, const std::string &s) { - return xcb_intern_atom(c, false, s.size(), s.c_str()); + return xcb_intern_atom(c, false, static_cast(s.size()), s.c_str()); } xcb_atom_t intern_atom(xcb_connection_t *c, xcb_intern_atom_cookie_t cookie) { @@ -118,7 +118,7 @@ void ShellXcb::CreateWindow() { xcb_atom_t utf8_string = intern_atom(m_connection, utf8_string_cookie); xcb_atom_t _net_wm_name = intern_atom(m_connection, _net_wm_name_cookie); xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_window, _net_wm_name, utf8_string, 8, - m_settings.m_windowName.size(), m_settings.m_windowName.c_str()); + static_cast(m_settings.m_windowName.size()), m_settings.m_windowName.c_str()); // advertise WM_DELETE_WINDOW m_wm_protocols = intern_atom(m_connection, wm_protocols_cookie); diff --git a/vk_video_decoder/CMakeLists.txt b/vk_video_decoder/CMakeLists.txt index 55a1a2c..f0bf93c 100644 --- a/vk_video_decoder/CMakeLists.txt +++ b/vk_video_decoder/CMakeLists.txt @@ -247,7 +247,7 @@ set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../scripts") include_directories("${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/../common/include") if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") - # set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-long-long -Wshadow -Wundef -Wconversion -Wno-sign-conversion -Wno-conversion -Wno-sign-compare") + set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wconversion") set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp") # These flags are not supported on Windows and some older version of GCC diff --git a/vk_video_decoder/include/vkvideo_parser/VulkanVideoParserIf.h b/vk_video_decoder/include/vkvideo_parser/VulkanVideoParserIf.h index ccb271c..56302a5 100644 --- a/vk_video_decoder/include/vkvideo_parser/VulkanVideoParserIf.h +++ b/vk_video_decoder/include/vkvideo_parser/VulkanVideoParserIf.h @@ -226,9 +226,9 @@ typedef struct VkParserHevcPictureData { uint8_t seq_parameter_set_id; // SPS ID uint8_t vps_video_parameter_set_id; // VPS ID - uint8_t IrapPicFlag; - uint8_t IdrPicFlag; - uint8_t short_term_ref_pic_set_sps_flag; + uint32_t IrapPicFlag : 1; + uint32_t IdrPicFlag : 1; + uint32_t short_term_ref_pic_set_sps_flag : 1; // RefPicSets int32_t NumBitsForShortTermRPSInSlice; @@ -440,7 +440,7 @@ typedef struct VkParserSequenceInfo { VkVideoCodecOperationFlagBitsKHR eCodec; // Compression Standard bool isSVC; // h.264 SVC FrameRate frameRate; // Frame Rate stored in the bitstream - int32_t bProgSeq; // Progressive Sequence + bool bProgSeq; // Progressive Sequence int32_t nDisplayWidth; // Displayed Horizontal Size int32_t nDisplayHeight; // Displayed Vertical Size int32_t nCodedWidth; // Coded Picture Width @@ -453,7 +453,7 @@ typedef struct VkParserSequenceInfo { uint8_t uVideoFullRange; // 0=16-235, 1=0-255 int32_t lBitrate; // Video bitrate (bps) int32_t lDARWidth, - lDARHeight; // Display Aspect Ratio = lDARWidth : lDARHeight + lDARHeight; // Display Aspect Ratio = lDARWidth : lDARHeight int32_t lVideoFormat; // Video Format (VideoFormatXXX) int32_t lColorPrimaries; // Colour Primaries (ColorPrimariesXXX) int32_t lTransferCharacteristics; // Transfer Characteristics diff --git a/vk_video_decoder/libs/NvVideoParser/include/VulkanAV1Decoder.h b/vk_video_decoder/libs/NvVideoParser/include/VulkanAV1Decoder.h index 4dd29c8..4367390 100644 --- a/vk_video_decoder/libs/NvVideoParser/include/VulkanAV1Decoder.h +++ b/vk_video_decoder/libs/NvVideoParser/include/VulkanAV1Decoder.h @@ -383,7 +383,7 @@ class VulkanAV1Decoder : public VulkanVideoDecoder { size_t le(int n) { size_t t = 0; for (int i = 0; i < n; i++) { - uint8_t byte = u(8); + uint8_t byte = (uint8_t)u(8); t += (byte << (i * 8)); } return t; diff --git a/vk_video_decoder/libs/NvVideoParser/include/VulkanH264Decoder.h b/vk_video_decoder/libs/NvVideoParser/include/VulkanH264Decoder.h index 5eb112d..a83b1f4 100644 --- a/vk_video_decoder/libs/NvVideoParser/include/VulkanH264Decoder.h +++ b/vk_video_decoder/libs/NvVideoParser/include/VulkanH264Decoder.h @@ -22,7 +22,7 @@ #include "VulkanH26xDecoder.h" #include "nvVulkanh264ScalingList.h" -#define VK_H264_SPS_VUI_FIELD(pStdVui, nvSpsIn, name) pStdVui->name = nvSpsIn->vui.name +#define VK_H264_SPS_VUI_FIELD(pStdVui, nvSpsIn, name) pStdVui->name = (uint8_t)(nvSpsIn->vui.name) #define SET_VK_H264_SPS_VUI_FIELD(pStdVui, name, value) pStdVui->name = value #define VK_H264_SPS_VUI_FLAG(pStdVui, nvSpsIn, name) pStdVui->flags.name = nvSpsIn->vui.name @@ -76,19 +76,19 @@ struct vui_parameters_s struct seq_parameter_set_svc_extension_s { - int inter_layer_deblocking_filter_control_present_flag; - int extended_spatial_scalability_idc; - int chroma_phase_x_plus1_flag; - int chroma_phase_y_plus1; - int seq_ref_layer_chroma_phase_x_plus1_flag; - int seq_ref_layer_chroma_phase_y_plus1; - int seq_scaled_ref_layer_left_offset; - int seq_scaled_ref_layer_top_offset; - int seq_scaled_ref_layer_right_offset; - int seq_scaled_ref_layer_bottom_offset; - int seq_tcoeff_level_prediction_flag; - int adaptive_tcoeff_level_prediction_flag; - int slice_header_restriction_flag; + uint32_t inter_layer_deblocking_filter_control_present_flag; + uint32_t extended_spatial_scalability_idc; + uint32_t chroma_phase_x_plus1_flag; + uint32_t chroma_phase_y_plus1; + uint32_t seq_ref_layer_chroma_phase_x_plus1_flag; + uint32_t seq_ref_layer_chroma_phase_y_plus1; + uint32_t seq_scaled_ref_layer_left_offset; + uint32_t seq_scaled_ref_layer_top_offset; + uint32_t seq_scaled_ref_layer_right_offset; + uint32_t seq_scaled_ref_layer_bottom_offset; + uint32_t seq_tcoeff_level_prediction_flag; + uint32_t adaptive_tcoeff_level_prediction_flag; + uint32_t slice_header_restriction_flag; }; struct seq_parameter_set_s : public StdVideoPictureParametersSet, public StdVideoH264SequenceParameterSet @@ -233,8 +233,8 @@ struct seq_parameter_set_s : public StdVideoPictureParametersSet, public StdVide // StdVideoH264HrdParameters hrd_parameters); pStdHrdParameters->cpb_cnt_minus1 = pSps->vui.nal_hrd.cpb_cnt_minus1; - pStdHrdParameters->bit_rate_scale = pSps->vui.nal_hrd.bit_rate; - pStdHrdParameters->cpb_size_scale = pSps->vui.nal_hrd.cbp_size; + pStdHrdParameters->bit_rate_scale = (uint8_t)(pSps->vui.nal_hrd.bit_rate); + pStdHrdParameters->cpb_size_scale =(uint8_t)(pSps->vui.nal_hrd.cbp_size); // stdVui.pHrdParameters->bit_rate_value_minus1[32]; // stdVui.pHrdParameters->cpb_size_value_minus1[32]; // stdVui.pHrdParameters->cbr_flag[32]; @@ -544,7 +544,7 @@ struct slice_header_s int first_mb_in_slice; int slice_type_raw; int slice_type; - int pic_parameter_set_id; + uint8_t pic_parameter_set_id; int colour_plane_id; int frame_num; int idr_pic_id; @@ -737,8 +737,8 @@ typedef bool (*PFNSORTCHECK)(int, int *, const DPBPicNum *, const VkParserPictur class VulkanH264Decoder: public VulkanVideoDecoder { public: - enum { MAX_NUM_SPS = 32 }; - enum { MAX_NUM_PPS = 256 }; + enum { MAX_NUM_SPS = 31 }; + enum { MAX_NUM_PPS = 255 }; public: VulkanH264Decoder(VkVideoCodecOperationFlagBitsKHR std); diff --git a/vk_video_decoder/libs/NvVideoParser/include/VulkanH265Decoder.h b/vk_video_decoder/libs/NvVideoParser/include/VulkanH265Decoder.h index 7ab8e0b..9d83480 100644 --- a/vk_video_decoder/libs/NvVideoParser/include/VulkanH265Decoder.h +++ b/vk_video_decoder/libs/NvVideoParser/include/VulkanH265Decoder.h @@ -563,14 +563,14 @@ struct hevc_video_param_s : public StdVideoPictureParametersSet, public StdVideo uint8_t layer_id_included_flag[MAX_VPS_LAYER_SETS][MAX_NUM_LAYER_IDS]; uint32_t num_layers_in_id_list[MAX_VPS_LAYER_SETS]; uint8_t layer_set_layer_id_list[MAX_VPS_LAYER_SETS][MAX_NUM_LAYER_IDS]; - uint32_t vps_num_hrd_parameters; + uint32_t vps_num_hrd_parameters; // hrdParameters_t hrdParameters[MAX_VPS_LAYER_SETS]; // CMOD variable uint32_t hrd_layer_set_idx[MAX_VPS_LAYER_SETS]; uint8_t cprms_present_flag[MAX_VPS_LAYER_SETS]; /* VPS Extension */ uint8_t scalability_mask_flag[MAX_NUM_SCALABILITY_TYPES]; - uint32_t numScalabilityTypes; + uint32_t numScalabilityTypes; uint8_t dimension_id_len[MAX_NUM_SCALABILITY_TYPES]; uint8_t layer_id_in_nuh[MAX_NUM_LAYER_IDS]; @@ -651,10 +651,10 @@ typedef struct _hevc_slice_header_s uint32_t slice_segment_address; uint8_t colour_plane_id; - uint8_t short_term_ref_pic_set_sps_flag; + uint32_t short_term_ref_pic_set_sps_flag : 1; uint8_t short_term_ref_pic_set_idx; uint8_t num_long_term_sps; - + uint16_t pic_order_cnt_lsb; uint8_t num_long_term_pics; uint8_t reserved1; diff --git a/vk_video_decoder/libs/NvVideoParser/include/nvVulkanh264ScalingList.h b/vk_video_decoder/libs/NvVideoParser/include/nvVulkanh264ScalingList.h index 1ae2c5a..13df03e 100644 --- a/vk_video_decoder/libs/NvVideoParser/include/nvVulkanh264ScalingList.h +++ b/vk_video_decoder/libs/NvVideoParser/include/nvVulkanh264ScalingList.h @@ -34,10 +34,10 @@ enum NvScalingListTypeH264 { struct NvScalingListH264 { - int32_t scaling_matrix_present_flag:1; - uint8_t scaling_list_type[8]; // scaling_list_type_e - uint8_t ScalingList4x4[6][16]; - uint8_t ScalingList8x8[2][64]; + uint32_t scaling_matrix_present_flag:1; + uint8_t scaling_list_type[8]; // scaling_list_type_e + uint8_t ScalingList4x4[6][16]; + uint8_t ScalingList8x8[2][64]; }; NVPARSER_EXPORT diff --git a/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX2.cpp b/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX2.cpp index 8690ef2..0399420 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX2.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX2.cpp @@ -19,7 +19,7 @@ size_t VulkanVideoDecoder::next_start_code(const uint8_t *pdatai { const __m256i v1 = _mm256_set1_epi8(1); __m256i vdata = _mm256_loadu_si256((const __m256i*)pdatain); - __m256i vBfr = _mm256_set1_epi16(((m_BitBfr << 8) & 0xFF00) | ((m_BitBfr >> 8) & 0xFF)); + __m256i vBfr = _mm256_set1_epi16((((int16_t)m_BitBfr << 8) & 0xFF00) | (((short)m_BitBfr >> 8) & 0xFF)); __m256i vdata_alignr16b_init = _mm256_permute2f128_si256(vBfr, vdata, 1 | (2<<4)); __m256i vdata_prev1 = _mm256_alignr_epi8(vdata, vdata_alignr16b_init, 15); __m256i vdata_prev2 = _mm256_alignr_epi8(vdata, vdata_alignr16b_init, 14); diff --git a/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX512.cpp b/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX512.cpp index 1a07927..8e48105 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX512.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX512.cpp @@ -20,7 +20,7 @@ size_t VulkanVideoDecoder::next_start_code(const uint8_t *pdat const __m512i v1 = _mm512_set1_epi8(1); const __m512i v254 = _mm512_set1_epi8(-2); __m512i vdata = _mm512_loadu_si512((const void*)pdatain); - __m512i vBfr = _mm512_set1_epi16(((m_BitBfr << 8) & 0xFF00) | ((m_BitBfr >> 8) & 0xFF)); + __m512i vBfr = _mm512_set1_epi16((((int16_t)m_BitBfr << 8) & 0xFF00) | (((short)m_BitBfr >> 8) & 0xFF)); __m512i vdata_alignr48b_init = _mm512_alignr_epi32(vdata, vBfr, 12); __m512i vdata_prev1 = _mm512_alignr_epi8(vdata, vdata_alignr48b_init, 15); __m512i vdata_prev2 = _mm512_alignr_epi8(vdata, vdata_alignr48b_init, 14); diff --git a/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeSSSE3.cpp b/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeSSSE3.cpp index 92cf4b6..c07d1d5 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeSSSE3.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/NextStartCodeSSSE3.cpp @@ -19,7 +19,7 @@ size_t VulkanVideoDecoder::next_start_code(const uint8_t *pdata { const __m128i v1 = _mm_set1_epi8(1); __m128i vdata = _mm_loadu_si128((const __m128i*)pdatain); - __m128i vBfr = _mm_set1_epi16(((m_BitBfr << 8) & 0xFF00) | ((m_BitBfr >> 8) & 0xFF)); + __m128i vBfr = _mm_set1_epi16((((int16_t)m_BitBfr << 8) & 0xFF00) | (((short)m_BitBfr >> 8) & 0xFF)); __m128i vdata_prev1 = _mm_alignr_epi8(vdata, vBfr, 15); __m128i vdata_prev2 = _mm_alignr_epi8(vdata, vBfr, 14); for ( ; i < datasize32 - 32; i += 32) diff --git a/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1Decoder.cpp b/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1Decoder.cpp index f6328e0..8a1e5c2 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1Decoder.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1Decoder.cpp @@ -311,7 +311,7 @@ bool VulkanAV1Decoder::BeginPicture(VkParserPictureData* pnvpd) av1->setupSlotInfo.OrderHint = m_PicData.std_info.OrderHint; memcpy(&av1->setupSlotInfo.SavedOrderHints, m_PicData.std_info.OrderHints, STD_VIDEO_AV1_NUM_REF_FRAMES); for (size_t av1name = 0; av1name < STD_VIDEO_AV1_NUM_REF_FRAMES; av1name += 1) { - av1->setupSlotInfo.RefFrameSignBias |= (m_pBuffers[0].RefFrameSignBias[av1name] <= 0) << av1name; + av1->setupSlotInfo.RefFrameSignBias |= (uint8_t)((m_pBuffers[0].RefFrameSignBias[av1name] <= 0) << av1name); } av1->setupSlotInfo.flags.disable_frame_end_update_cdf = m_PicData.std_info.flags.disable_frame_end_update_cdf; av1->setupSlotInfo.flags.segmentation_enabled = m_PicData.std_info.flags.segmentation_enabled; @@ -325,7 +325,7 @@ bool VulkanAV1Decoder::BeginPicture(VkParserPictureData* pnvpd) av1->dpbSlotInfos[i].frame_type = m_pBuffers[i].frame_type; av1->dpbSlotInfos[i].OrderHint = m_pBuffers[i].order_hint; for (size_t av1name = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME; av1name < STD_VIDEO_AV1_NUM_REF_FRAMES; av1name += 1) { - av1->dpbSlotInfos[i].RefFrameSignBias |= (m_pBuffers[i].RefFrameSignBias[av1name] <= 0) << av1name; + av1->dpbSlotInfos[i].RefFrameSignBias |= (uint8_t)((m_pBuffers[i].RefFrameSignBias[av1name] <= 0) << av1name); av1->dpbSlotInfos[i].SavedOrderHints[av1name] = m_pBuffers[i].SavedOrderHints[av1name]; } } @@ -340,7 +340,7 @@ bool VulkanAV1Decoder::BeginPicture(VkParserPictureData* pnvpd) } for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) { - av1->ref_frame_idx[i] = ref_frame_idx[i]; + av1->ref_frame_idx[i] = (uint8_t)ref_frame_idx[i]; } return true; @@ -387,7 +387,7 @@ void VulkanAV1Decoder::UpdateFramePointers(VkPicIf* currentPicture) for (uint8_t refName = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME; refName < STD_VIDEO_AV1_NUM_REF_FRAMES; refName ++) { uint8_t ref_order_hint = pStd->OrderHints[refName]; m_pBuffers[ref_index].SavedOrderHints[refName] = ref_order_hint; - m_pBuffers[ref_index].RefFrameSignBias[refName] = GetRelativeDist(pStd->OrderHint, ref_order_hint); + m_pBuffers[ref_index].RefFrameSignBias[refName] = (uint8_t)GetRelativeDist(pStd->OrderHint, ref_order_hint); } // film grain @@ -599,9 +599,9 @@ int VulkanAV1Decoder::ChooseOperatingPoint() memset(&OPInfo, 0, sizeof(OPInfo)); OPInfo.eCodec = (VkVideoCodecOperationFlagBitsKHR)VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR; - OPInfo.av1.operating_points_cnt = m_sps->operating_points_cnt_minus_1 + 1; + OPInfo.av1.operating_points_cnt = (uint8_t)m_sps->operating_points_cnt_minus_1 + 1; for (int i = 0; i < OPInfo.av1.operating_points_cnt; i++) { - OPInfo.av1.operating_points_idc[i] = m_sps->operating_point_idc[i]; + OPInfo.av1.operating_points_idc[i] = (uint16_t)(m_sps->operating_point_idc[i]); } operating_point = 0; // GetOperatingPoint was deprecated because it always returned 0 - m_pClient->GetOperatingPoint(&OPInfo); @@ -643,8 +643,8 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() return false; } - sps->flags.still_picture = u(1); - sps->flags.reduced_still_picture_header = u(1); + sps->flags.still_picture = flag(); + sps->flags.reduced_still_picture_header = flag(); if (!sps->flags.still_picture && sps->flags.reduced_still_picture_header) { // Error: Video must have reduced_still_picture_hdr == 0 @@ -666,7 +666,7 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() op_params[0].decoder_model_param_present = 0; op_params[0].display_model_param_present = 0; } else { - timing_info_present = u(1); + timing_info_present = (uint8_t)u(1); if (timing_info_present) { ReadTimingInfoHeader(); @@ -686,7 +686,7 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() return false; } if (sps->level[i] > STD_VIDEO_AV1_LEVEL_3_3) { - sps->tier[i] = u(1); + sps->tier[i] = (uint8_t)u(1); } else { sps->tier[i] = 0; } @@ -722,29 +722,29 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() } } - sps->frame_width_bits_minus_1 = u(4); - sps->frame_height_bits_minus_1 = u(4); - sps->max_frame_width_minus_1 = u(sps->frame_width_bits_minus_1 + 1); - sps->max_frame_height_minus_1 = u(sps->frame_height_bits_minus_1 + 1); + sps->frame_width_bits_minus_1 = (uint8_t)u(4); + sps->frame_height_bits_minus_1 = (uint8_t)u(4); + sps->max_frame_width_minus_1 = (uint16_t)u(sps->frame_width_bits_minus_1 + 1); + sps->max_frame_height_minus_1 = (uint16_t)u(sps->frame_height_bits_minus_1 + 1); if (sps->flags.reduced_still_picture_header) { sps->flags.frame_id_numbers_present_flag = 0; } else { - sps->flags.frame_id_numbers_present_flag = u(1); + sps->flags.frame_id_numbers_present_flag = flag(); } if (sps->flags.frame_id_numbers_present_flag) { - delta_frame_id_length = u(4) + 2; - frame_id_length = u(3) + delta_frame_id_length + 1; + delta_frame_id_length = (uint8_t)u(4) + 2; + frame_id_length = (uint8_t)(u(3) + delta_frame_id_length + 1); if (frame_id_length > 16) { // Invalid frame_id_length return false; } } - sps->flags.use_128x128_superblock = u(1); - sps->flags.enable_filter_intra = u(1); - sps->flags.enable_intra_edge_filter = u(1); + sps->flags.use_128x128_superblock = flag(); + sps->flags.enable_filter_intra = flag(); + sps->flags.enable_intra_edge_filter = flag(); if (sps->flags.reduced_still_picture_header) { sps->flags.enable_interintra_compound = 0; @@ -758,14 +758,14 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() sps->seq_force_integer_mv = STD_VIDEO_AV1_SELECT_INTEGER_MV; sps->order_hint_bits_minus_1 = 0; } else { - sps->flags.enable_interintra_compound = u(1); - sps->flags.enable_masked_compound = u(1); - sps->flags.enable_warped_motion = u(1); - sps->flags.enable_dual_filter = u(1); - sps->flags.enable_order_hint = u(1); + sps->flags.enable_interintra_compound = flag(); + sps->flags.enable_masked_compound = flag(); + sps->flags.enable_warped_motion = flag(); + sps->flags.enable_dual_filter = flag(); + sps->flags.enable_order_hint = flag(); if (sps->flags.enable_order_hint) { - sps->flags.enable_jnt_comp = u(1); - sps->flags.enable_ref_frame_mvs = u(1); + sps->flags.enable_jnt_comp = flag(); + sps->flags.enable_ref_frame_mvs = flag(); } else { sps->flags.enable_jnt_comp = 0; sps->flags.enable_ref_frame_mvs = 0; @@ -775,23 +775,23 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() sps->seq_force_screen_content_tools = STD_VIDEO_AV1_SELECT_SCREEN_CONTENT_TOOLS; } else - sps->seq_force_screen_content_tools = u(1); + sps->seq_force_screen_content_tools = (uint8_t)u(1); if (sps->seq_force_screen_content_tools > 0) { if (u(1)) { sps->seq_force_integer_mv = STD_VIDEO_AV1_SELECT_INTEGER_MV; } else { - sps->seq_force_integer_mv = u(1); + sps->seq_force_integer_mv = (uint8_t)u(1); } } else { sps->seq_force_integer_mv = STD_VIDEO_AV1_SELECT_INTEGER_MV; } - sps->order_hint_bits_minus_1 = sps->flags.enable_order_hint ? u(3) : 0; + sps->order_hint_bits_minus_1 = sps->flags.enable_order_hint ? (uint8_t)u(3) : 0; } - sps->flags.enable_superres = u(1); - sps->flags.enable_cdef = u(1); - sps->flags.enable_restoration = u(1); + sps->flags.enable_superres = flag(); + sps->flags.enable_cdef = flag(); + sps->flags.enable_restoration = flag(); // color config bool high_bitdepth = u(1); if (sps->seq_profile == STD_VIDEO_AV1_PROFILE_PROFESSIONAL && high_bitdepth) { @@ -809,8 +809,8 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() sps->color_config.subsampling_x = sps->color_config.subsampling_x; sps->color_config.subsampling_y = sps->color_config.subsampling_y; - sps->color_config.flags.mono_chrome = sps->seq_profile != STD_VIDEO_AV1_PROFILE_HIGH ? u(1) : 0; - sps->color_config.flags.color_description_present_flag = u(1); + sps->color_config.flags.mono_chrome = sps->seq_profile != STD_VIDEO_AV1_PROFILE_HIGH ? flag() : 0; + sps->color_config.flags.color_description_present_flag = flag(); if (sps->color_config.flags.color_description_present_flag) { sps->color_config.color_primaries = (StdVideoAV1ColorPrimaries)u(8); sps->color_config.transfer_characteristics = (StdVideoAV1TransferCharacteristics)u(8); @@ -822,7 +822,7 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() } if (sps->color_config.flags.mono_chrome) { - sps->color_config.flags.color_range = u(1); + sps->color_config.flags.color_range = flag(); sps->color_config.subsampling_x = sps->color_config.subsampling_y = 1; sps->color_config.flags.separate_uv_delta_q = 0; } else { @@ -832,16 +832,16 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() sps->color_config.subsampling_y = sps->color_config.subsampling_x = 0; sps->color_config.flags.color_range = 1; // assume full color-range } else { - sps->color_config.flags.color_range = u(1); + sps->color_config.flags.color_range = flag(); if (sps->seq_profile == STD_VIDEO_AV1_PROFILE_MAIN) { sps->color_config.subsampling_x = sps->color_config.subsampling_y = 1;// 420 } else if (sps->seq_profile == STD_VIDEO_AV1_PROFILE_HIGH) { sps->color_config.subsampling_x = sps->color_config.subsampling_y = 0;// 444 } else { if (sps->color_config.BitDepth == 12) { - sps->color_config.subsampling_x = u(1); + sps->color_config.subsampling_x = (uint8_t)u(1); if (sps->color_config.subsampling_x) { - sps->color_config.subsampling_y = u(1); + sps->color_config.subsampling_y = (uint8_t)u(1); } else { sps->color_config.subsampling_y = 0; } @@ -854,9 +854,9 @@ bool VulkanAV1Decoder::ParseObuSequenceHeader() sps->color_config.chroma_sample_position = (StdVideoAV1ChromaSamplePosition)u(2); } } - sps->color_config.flags.separate_uv_delta_q = u(1); + sps->color_config.flags.separate_uv_delta_q = flag(); } - sps->flags.film_grain_params_present = u(1); + sps->flags.film_grain_params_present = flag(); // check_trailing_bits() int bits_before_byte_alignment = 8 - (m_nalu.get_bfroffs % 8); @@ -903,8 +903,8 @@ void VulkanAV1Decoder::SetupFrameSize(int frame_size_override_flag) StdVideoDecodeAV1PictureInfo *const pStd = &m_PicData.std_info; if (frame_size_override_flag) { - frame_width = u(sps->frame_width_bits_minus_1 + 1) + 1; - frame_height = u(sps->frame_height_bits_minus_1 + 1) + 1; + frame_width = (uint16_t)u(sps->frame_width_bits_minus_1 + 1) + 1; + frame_height = (uint16_t)u(sps->frame_height_bits_minus_1 + 1) + 1; if (frame_width > (sps->max_frame_width_minus_1 + 1) || frame_height > (sps->max_frame_height_minus_1 + 1)) { assert(false); } @@ -921,15 +921,15 @@ void VulkanAV1Decoder::SetupFrameSize(int frame_size_override_flag) if (sps->flags.enable_superres){ if (u(1)) { pStd->flags.use_superres = 1; - superres_scale_denominator = u(3); + superres_scale_denominator = (uint8_t)u(3); pStd->coded_denom = superres_scale_denominator; superres_scale_denominator += SUPERRES_DENOM_MIN; - frame_width = (upscaled_width*SUPERRES_NUM + superres_scale_denominator / 2) / superres_scale_denominator; + frame_width = (uint16_t)(upscaled_width*SUPERRES_NUM + superres_scale_denominator / 2) / superres_scale_denominator; } } //render size - pStd->flags.render_and_frame_size_different = u(1); + pStd->flags.render_and_frame_size_different = flag(); if (pStd->flags.render_and_frame_size_different) { render_width = u(16) + 1; render_height = u(16) + 1; @@ -956,9 +956,9 @@ int VulkanAV1Decoder::SetupFrameSizeWithRefs() found = 1; VkPicIf *m_pPic = m_pBuffers[ref_frame_idx[i]].buffer; if (m_pPic) { - upscaled_width = m_pPic->decodeSuperResWidth; - frame_width = m_pPic->decodeWidth; - frame_height = m_pPic->decodeHeight; + upscaled_width = (uint16_t)(m_pPic->decodeSuperResWidth); + frame_width = (uint16_t)(m_pPic->decodeWidth); + frame_height = (uint16_t)(m_pPic->decodeHeight); render_width = m_pPic->decodeWidth; render_height = m_pPic->decodeHeight; } @@ -976,13 +976,13 @@ int VulkanAV1Decoder::SetupFrameSizeWithRefs() if (sps->flags.enable_superres) { if (u(1)) { pStd->flags.use_superres = 1; - superres_scale_denominator = u(SUPERRES_DENOM_BITS); + superres_scale_denominator = (uint8_t)u(SUPERRES_DENOM_BITS); pStd->coded_denom = superres_scale_denominator; superres_scale_denominator += SUPERRES_DENOM_MIN; } } - frame_width = (upscaled_width*SUPERRES_NUM + superres_scale_denominator / 2) / superres_scale_denominator; + frame_width = (uint16_t)(upscaled_width*SUPERRES_NUM + superres_scale_denominator / 2) / superres_scale_denominator; } return 1; @@ -996,18 +996,18 @@ bool VulkanAV1Decoder::ReadFilmGrainParams() StdVideoAV1FilmGrain *const pFilmGrain = &m_PicData.filmGrain; if (sps->flags.film_grain_params_present && (pic_data->showFrame || showable_frame)) { - pStd->flags.apply_grain = u(1); + pStd->flags.apply_grain = flag(); if (!pStd->flags.apply_grain) { memset(pFilmGrain, 0, sizeof(StdVideoAV1FilmGrain)); return 1; } - pFilmGrain->grain_seed = u(16); - pFilmGrain->flags.update_grain = pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_INTER ? u(1) : 1; + pFilmGrain->grain_seed = (uint16_t)u(16); + pFilmGrain->flags.update_grain = pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_INTER ? flag() : 1; if (!pFilmGrain->flags.update_grain) { // Use previous reference frame film grain params - int buf_idx = u(3); + uint8_t buf_idx = (uint8_t)u(3); uint16_t random_seed = pFilmGrain->grain_seed; if (m_pBuffers[buf_idx].buffer) { memcpy(pFilmGrain, &(m_pBuffers[buf_idx].film_grain_params), sizeof(StdVideoAV1FilmGrain)); @@ -1018,55 +1018,55 @@ bool VulkanAV1Decoder::ReadFilmGrainParams() } // Scaling functions parameters - pFilmGrain->num_y_points = u(4); + pFilmGrain->num_y_points = (uint8_t)u(4); if (pFilmGrain->num_y_points > STD_VIDEO_AV1_MAX_NUM_Y_POINTS) { assert("num_y_points exceeds the maximum value\n"); } for (uint32_t i = 0; i < pFilmGrain->num_y_points; i++) { - pFilmGrain->point_y_value[i] = u(8); + pFilmGrain->point_y_value[i] = (uint8_t)u(8); if (i && pFilmGrain->point_y_value[i-1] >= pFilmGrain->point_y_value[i]) { assert(!"Y cordinates should be increasing\n"); } - pFilmGrain->point_y_scaling[i] = u(8); + pFilmGrain->point_y_scaling[i] = (uint8_t)u(8); } - pFilmGrain->flags.chroma_scaling_from_luma = !sps->color_config.flags.mono_chrome ? u(1) : 0; + pFilmGrain->flags.chroma_scaling_from_luma = !sps->color_config.flags.mono_chrome ? flag() : 0; if (sps->color_config.flags.mono_chrome || pFilmGrain->flags.chroma_scaling_from_luma || ((sps->color_config.subsampling_x == 1) && (sps->color_config.subsampling_y == 1) && (pFilmGrain->num_y_points == 0))) { pFilmGrain->num_cb_points = 0; pFilmGrain->num_cr_points = 0; } else { - pFilmGrain->num_cb_points = u(4); + pFilmGrain->num_cb_points = (uint8_t)u(4); if (pFilmGrain->num_cb_points > STD_VIDEO_AV1_MAX_NUM_CR_POINTS) { assert(!"num_cb_points exceeds the maximum value\n"); } for (uint32_t i = 0; i < pFilmGrain->num_cb_points; i++) { - pFilmGrain->point_cb_value[i] = u(8); + pFilmGrain->point_cb_value[i] = (uint8_t)u(8); if (i && pFilmGrain->point_cb_value[i-1] >= pFilmGrain->point_cb_value[i]) { assert(!"cb cordinates should be increasing\n"); } - pFilmGrain->point_cb_scaling[i] = u(8); + pFilmGrain->point_cb_scaling[i] = (uint8_t)u(8); } - pFilmGrain->num_cr_points = u(4); + pFilmGrain->num_cr_points = (uint8_t)u(4); if (pFilmGrain->num_cr_points > STD_VIDEO_AV1_MAX_NUM_CR_POINTS) { assert(!"num_cr_points exceeds the maximum value\n"); } for (uint32_t i = 0; i < pFilmGrain->num_cr_points; i++) { - pFilmGrain->point_cr_value[i] = u(8); + pFilmGrain->point_cr_value[i] = (uint8_t)u(8); if (i && pFilmGrain->point_cr_value[i-1] >= pFilmGrain->point_cr_value[i]) { assert(!"cr cordinates should be increasing\n"); } - pFilmGrain->point_cr_scaling[i] = u(8); + pFilmGrain->point_cr_scaling[i] = (uint8_t)u(8); } } - pFilmGrain->grain_scaling_minus_8 = u(2); - pFilmGrain->ar_coeff_lag = u(2); + pFilmGrain->grain_scaling_minus_8 = (uint8_t)u(2); + pFilmGrain->ar_coeff_lag = (uint8_t)u(2); int numPosLuma = 2 * pFilmGrain->ar_coeff_lag * (pFilmGrain->ar_coeff_lag + 1); assert(numPosLuma <= STD_VIDEO_AV1_MAX_NUM_POS_LUMA); @@ -1078,39 +1078,39 @@ bool VulkanAV1Decoder::ReadFilmGrainParams() if (pFilmGrain->num_y_points) { for (int i = 0; i < numPosLuma; i++) { - pFilmGrain->ar_coeffs_y_plus_128[i] = u(8); + pFilmGrain->ar_coeffs_y_plus_128[i] = (int8_t)u(8); } } if (pFilmGrain->num_cb_points || pFilmGrain->flags.chroma_scaling_from_luma) { for (int i = 0; i < numPosChroma; i++) { - pFilmGrain->ar_coeffs_cb_plus_128[i] = u(8); + pFilmGrain->ar_coeffs_cb_plus_128[i] = (int8_t)u(8); } } if (pFilmGrain->num_cr_points || pFilmGrain->flags.chroma_scaling_from_luma) { for (int i = 0; i < numPosChroma; i++) { - pFilmGrain->ar_coeffs_cr_plus_128[i] = u(8); + pFilmGrain->ar_coeffs_cr_plus_128[i] = (int8_t)u(8); } } - pFilmGrain->ar_coeff_shift_minus_6 = u(2); - pFilmGrain->grain_scale_shift = u(2); + pFilmGrain->ar_coeff_shift_minus_6 = (uint8_t)u(2); + pFilmGrain->grain_scale_shift = (uint8_t)u(2); if (pFilmGrain->num_cb_points) { - pFilmGrain->cb_mult = u(8); - pFilmGrain->cb_luma_mult = u(8); - pFilmGrain->cb_offset = u(9); + pFilmGrain->cb_mult = (uint8_t)u(8); + pFilmGrain->cb_luma_mult = (uint8_t)u(8); + pFilmGrain->cb_offset = (uint16_t)u(9); } if (pFilmGrain->num_cr_points) { - pFilmGrain->cr_mult = u(8); - pFilmGrain->cr_luma_mult = u(8); - pFilmGrain->cr_offset = u(9); + pFilmGrain->cr_mult = (uint8_t)u(8); + pFilmGrain->cr_luma_mult = (uint8_t)u(8); + pFilmGrain->cr_offset = (uint16_t)u(9); } - pFilmGrain->flags.overlap_flag = u(1); - pFilmGrain->flags.clip_to_restricted_range = u(1); + pFilmGrain->flags.overlap_flag = flag(); + pFilmGrain->flags.clip_to_restricted_range = flag(); } else { memset(pFilmGrain, 0, sizeof(StdVideoAV1FilmGrain)); } @@ -1178,7 +1178,7 @@ bool VulkanAV1Decoder::DecodeTileInfo() uint32_t max_log2_tile_rows = tile_log2(1, std::min(sb_rows, (uint32_t)STD_VIDEO_AV1_MAX_TILE_ROWS)); uint32_t min_log2_tiles = std::max(min_log2_tile_cols, tile_log2(max_tile_area_sb, sb_rows * sb_cols)); - pTileInfo->flags.uniform_tile_spacing_flag = u(1); + pTileInfo->flags.uniform_tile_spacing_flag = flag(); memset(&pic_data->MiColStarts[0], 0, sizeof(pic_data->MiColStarts)); memset(&pic_data->MiRowStarts[0], 0, sizeof(pic_data->MiRowStarts)); memset(&pic_data->width_in_sbs_minus_1[0], 0, sizeof(pic_data->width_in_sbs_minus_1)); @@ -1195,9 +1195,9 @@ bool VulkanAV1Decoder::DecodeTileInfo() tile_width_sb = (sb_cols + (1 << log2_tile_cols) - 1) >> log2_tile_cols; for (uint32_t off = 0, i = 0; off < sb_cols; off += tile_width_sb) - pic_data->MiColStarts[i++] = off; + pic_data->MiColStarts[i++] = (uint16_t)off; - pic_data->tileInfo.TileCols = (sb_cols + tile_width_sb - 1) / tile_width_sb; + pic_data->tileInfo.TileCols = (uint8_t)((sb_cols + tile_width_sb - 1) / tile_width_sb); min_log2_tile_rows = std::max(int(min_log2_tiles - log2_tile_cols), 0); log2_tile_rows = min_log2_tile_rows; @@ -1209,34 +1209,34 @@ bool VulkanAV1Decoder::DecodeTileInfo() tile_height_sb = (sb_rows + (1 << log2_tile_rows) - 1) >> log2_tile_rows; for (uint32_t off = 0, i = 0; off < sb_rows; off += tile_height_sb) - pic_data->MiRowStarts[i++] = off; + pic_data->MiRowStarts[i++] = (uint16_t)off; - pic_data->tileInfo.TileRows = (sb_rows + tile_height_sb - 1) / tile_height_sb; + pic_data->tileInfo.TileRows = (uint8_t)((sb_rows + tile_height_sb - 1) / tile_height_sb); // Derive tile_width_in_sbs_minus_1 and tile_height_in_sbs_minus_1 uint32_t tile_col = 0; for ( ; tile_col < pic_data->tileInfo.TileCols - 1u; tile_col++) - pic_data->width_in_sbs_minus_1[tile_col] = tile_width_sb - 1; - pic_data->width_in_sbs_minus_1[tile_col] = sb_cols - (pic_data->tileInfo.TileCols - 1) * tile_width_sb - 1; + pic_data->width_in_sbs_minus_1[tile_col] = (uint16_t)tile_width_sb - 1; + pic_data->width_in_sbs_minus_1[tile_col] = (uint16_t)(sb_cols - (pic_data->tileInfo.TileCols - 1) * tile_width_sb - 1); uint32_t tile_row = 0; for ( ; tile_row < pic_data->tileInfo.TileRows - 1u; tile_row++) - pic_data->height_in_sbs_minus_1[tile_row] = tile_height_sb - 1; - pic_data->height_in_sbs_minus_1[tile_row] = sb_rows - (pic_data->tileInfo.TileRows - 1) * tile_height_sb - 1; + pic_data->height_in_sbs_minus_1[tile_row] = (uint16_t)(tile_height_sb - 1); + pic_data->height_in_sbs_minus_1[tile_row] = (uint16_t)(sb_rows - (pic_data->tileInfo.TileRows - 1) * tile_height_sb - 1); // Derivce superblock column / row start positions uint32_t i, start_sb; for (i = 0, start_sb = 0; start_sb < sb_cols; i++) { - pic_data->MiColStarts[i] = start_sb; + pic_data->MiColStarts[i] = (uint16_t)start_sb; start_sb += tile_width_sb; } - pic_data->MiColStarts[i] = sb_cols; + pic_data->MiColStarts[i] = (uint16_t)sb_cols; for (i = 0, start_sb = 0; start_sb < sb_rows; i++) { - pic_data->MiRowStarts[i] = start_sb; + pic_data->MiRowStarts[i] = (uint16_t)start_sb; start_sb += tile_height_sb; } - pic_data->MiRowStarts[i] = sb_rows; + pic_data->MiRowStarts[i] = (uint16_t)sb_rows; } else { uint32_t i, widest_tile_sb, start_sb, size_sb, max_width, max_height; widest_tile_sb = 0; @@ -1244,15 +1244,15 @@ bool VulkanAV1Decoder::DecodeTileInfo() start_sb = 0; for (i = 0; start_sb < sb_cols && i < STD_VIDEO_AV1_MAX_TILE_COLS; i++) { - pic_data->MiColStarts[i] = start_sb; + pic_data->MiColStarts[i] = (uint16_t)start_sb; max_width = std::min(sb_cols - start_sb, max_tile_width_sb); - pic_data->width_in_sbs_minus_1[i] = (max_width > 1) ? SwGetUniform(max_width) : 0; + pic_data->width_in_sbs_minus_1[i] = (max_width > 1) ? (uint16_t)SwGetUniform(max_width) : 0; size_sb = pic_data->width_in_sbs_minus_1[i] + 1; widest_tile_sb = std::max(size_sb, widest_tile_sb); start_sb += size_sb; } log2_tile_cols = tile_log2(1, i); - pic_data->tileInfo.TileCols = i; + pic_data->tileInfo.TileCols = (uint8_t)i; if (min_log2_tiles > 0) max_tile_area_sb = (numSuperblocks) >> (min_log2_tiles + 1); @@ -1262,23 +1262,23 @@ bool VulkanAV1Decoder::DecodeTileInfo() start_sb = 0; for (i = 0; start_sb < sb_rows && i < STD_VIDEO_AV1_MAX_TILE_ROWS; i++) { - pic_data->MiRowStarts[i] = start_sb; + pic_data->MiRowStarts[i] = (uint16_t)start_sb; max_height = std::min(sb_rows - start_sb, max_tile_height_sb); - pic_data->height_in_sbs_minus_1[i] = (max_height > 1) ? SwGetUniform(max_height) : 0; + pic_data->height_in_sbs_minus_1[i] = (max_height > 1) ? (uint16_t)SwGetUniform(max_height) : 0; size_sb = pic_data->height_in_sbs_minus_1[i] + 1; start_sb += size_sb; } log2_tile_rows = tile_log2(1, i); - pic_data->tileInfo.TileRows = i; + pic_data->tileInfo.TileRows = (uint8_t)i; } pic_data->tileInfo.context_update_tile_id = 0; tile_size_bytes_minus_1 = 3; if (pic_data->tileInfo.TileRows * pic_data->tileInfo.TileCols > 1) { // tile to use for cdf update - pic_data->tileInfo.context_update_tile_id = u(log2_tile_rows + log2_tile_cols); + pic_data->tileInfo.context_update_tile_id = (uint16_t)u(log2_tile_rows + log2_tile_cols); // tile size magnitude - tile_size_bytes_minus_1 = u(2); + tile_size_bytes_minus_1 = (uint8_t)u(2); pic_data->tileInfo.tile_size_bytes_minus_1 = tile_size_bytes_minus_1; } @@ -1287,14 +1287,14 @@ bool VulkanAV1Decoder::DecodeTileInfo() inline int VulkanAV1Decoder::ReadSignedBits(uint32_t bits) { - const int nbits = sizeof(uint32_t) * 8 - bits - 1; + const int nbits = (int)(sizeof(uint32_t) * 8 - bits - 1); uint32_t v = (uint32_t)u(bits + 1) << nbits; return ((int)v) >> nbits; } inline int VulkanAV1Decoder::ReadDeltaQ(uint32_t bits) { - return u(1) ? ReadSignedBits(bits) : 0; + return u(1) ? (uint8_t)ReadSignedBits(bits) : 0; } void VulkanAV1Decoder::DecodeQuantizationData() @@ -1302,17 +1302,17 @@ void VulkanAV1Decoder::DecodeQuantizationData() av1_seq_param_s *const sps = m_sps.Get(); VkParserAv1PictureData *const pic_data = &m_PicData; - pic_data->quantization.base_q_idx = u(8); - pic_data->quantization.DeltaQYDc = ReadDeltaQ(6); + pic_data->quantization.base_q_idx = (uint8_t)u(8); + pic_data->quantization.DeltaQYDc = (uint8_t)ReadDeltaQ(6); if (!sps->color_config.flags.mono_chrome) { int diff_uv_delta = 0; if (sps->color_config.flags.separate_uv_delta_q) diff_uv_delta = u(1); - pic_data->quantization.DeltaQUDc = ReadDeltaQ(6); - pic_data->quantization.DeltaQUAc = ReadDeltaQ(6); + pic_data->quantization.DeltaQUDc = (uint8_t)ReadDeltaQ(6); + pic_data->quantization.DeltaQUAc = (uint8_t)ReadDeltaQ(6); if (diff_uv_delta) { - pic_data->quantization.DeltaQVDc = ReadDeltaQ(6); - pic_data->quantization.DeltaQVAc = ReadDeltaQ(6); + pic_data->quantization.DeltaQVDc = (uint8_t)ReadDeltaQ(6); + pic_data->quantization.DeltaQVAc = (uint8_t)ReadDeltaQ(6); } else { pic_data->quantization.DeltaQVDc = pic_data->quantization.DeltaQUDc; pic_data->quantization.DeltaQVAc = pic_data->quantization.DeltaQUAc; @@ -1324,14 +1324,14 @@ void VulkanAV1Decoder::DecodeQuantizationData() pic_data->quantization.DeltaQVAc = 0; } - pic_data->quantization.flags.using_qmatrix = u(1); + pic_data->quantization.flags.using_qmatrix = flag(); if (pic_data->quantization.flags.using_qmatrix) { - pic_data->quantization.qm_y = u(4); - pic_data->quantization.qm_u = u(4); + pic_data->quantization.qm_y = (uint8_t)u(4); + pic_data->quantization.qm_u = (uint8_t)u(4); if (!sps->color_config.flags.separate_uv_delta_q) { pic_data->quantization.qm_v = pic_data->quantization.qm_u; } else { - pic_data->quantization.qm_v = u(4); + pic_data->quantization.qm_v = (uint8_t)u(4); } } else { pic_data->quantization.qm_y = 0; @@ -1350,7 +1350,7 @@ void VulkanAV1Decoder::DecodeSegmentationData() StdVideoAV1Segmentation* pSegmentation = &m_PicData.segmentation; StdVideoDecodeAV1PictureInfoFlags *const flags = &pStd->flags; - flags->segmentation_enabled = u(1); + flags->segmentation_enabled = flag(); if (!flags->segmentation_enabled) { memset(pSegmentation, 0, sizeof(*pSegmentation)); @@ -1362,15 +1362,15 @@ void VulkanAV1Decoder::DecodeSegmentationData() flags->segmentation_update_data = 1; flags->segmentation_temporal_update = 0; } else { - flags->segmentation_update_map = u(1); + flags->segmentation_update_map = flag(); if (flags->segmentation_update_map) { - flags->segmentation_temporal_update = u(1); + flags->segmentation_temporal_update = flag(); } else { flags->segmentation_temporal_update = 0; } - flags->segmentation_update_data = u(1); + flags->segmentation_update_data = flag(); } if (flags->segmentation_update_data) { @@ -1379,7 +1379,7 @@ void VulkanAV1Decoder::DecodeSegmentationData() for (int j = 0; j < STD_VIDEO_AV1_SEG_LVL_MAX; j++) { int feature_value = 0; int enabled = u(1); - pSegmentation->FeatureEnabled[i] |= enabled << j; + pSegmentation->FeatureEnabled[i] |= (uint8_t)enabled << j; if (enabled) { const int data_max = av1_seg_feature_data_max[j]; if (av1_seg_feature_data_signed[j]) { @@ -1390,7 +1390,7 @@ void VulkanAV1Decoder::DecodeSegmentationData() feature_value = CLAMP(feature_value, 0, data_max); } } - pSegmentation->FeatureData[i][j] = feature_value; + pSegmentation->FeatureData[i][j] = (uint16_t)feature_value; } } } else { @@ -1431,29 +1431,29 @@ void VulkanAV1Decoder::DecodeLoopFilterdata() } } - pLoopFilter->loop_filter_level[0] = u(6); - pLoopFilter->loop_filter_level[1] = u(6); + pLoopFilter->loop_filter_level[0] = (uint8_t)u(6); + pLoopFilter->loop_filter_level[1] = (uint8_t)u(6); if (!sps->color_config.flags.mono_chrome && (pLoopFilter->loop_filter_level[0] || pLoopFilter->loop_filter_level[1])) { - pLoopFilter->loop_filter_level[2] = u(6); // loop_filter_level_u - pLoopFilter->loop_filter_level[3] = u(6); // loop_filter_level_v + pLoopFilter->loop_filter_level[2] = (uint8_t)u(6); // loop_filter_level_u + pLoopFilter->loop_filter_level[3] = (uint8_t)u(6); // loop_filter_level_v } - pLoopFilter->loop_filter_sharpness = u(3); + pLoopFilter->loop_filter_sharpness = (uint8_t)u(3); uint8_t lf_mode_ref_delta_update = 0; - pLoopFilter->flags.loop_filter_delta_enabled = u(1); + pLoopFilter->flags.loop_filter_delta_enabled = flag(); if (pLoopFilter->flags.loop_filter_delta_enabled) { - lf_mode_ref_delta_update = u(1); - pLoopFilter->flags.loop_filter_delta_update = lf_mode_ref_delta_update; + lf_mode_ref_delta_update = (uint8_t)u(1); + pLoopFilter->flags.loop_filter_delta_update = lf_mode_ref_delta_update & 0x1; if (lf_mode_ref_delta_update) { for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++) { if (u(1)) { - pLoopFilter->loop_filter_ref_deltas[i] = ReadSignedBits(6); + pLoopFilter->loop_filter_ref_deltas[i] = (int8_t)ReadSignedBits(6); } } for (int i = 0; i < STD_VIDEO_AV1_LOOP_FILTER_ADJUSTMENTS; i++) { if (u(1)) { - pLoopFilter->loop_filter_mode_deltas[i] = ReadSignedBits(6); + pLoopFilter->loop_filter_mode_deltas[i] = (int8_t)ReadSignedBits(6); } } } @@ -1469,18 +1469,18 @@ void VulkanAV1Decoder::DecodeCDEFdata() if (pStd->flags.allow_intrabc) return; - pCDEF->cdef_damping_minus_3 = u(2); - pCDEF->cdef_bits = u(2); + pCDEF->cdef_damping_minus_3 = (uint8_t)u(2); + pCDEF->cdef_bits = (uint8_t)u(2); for (int i = 0; i < 8; i++) { if (i == (1 << pCDEF->cdef_bits)) { break; } - pCDEF->cdef_y_pri_strength[i] = u(4); - pCDEF->cdef_y_sec_strength[i] = u(2); + pCDEF->cdef_y_pri_strength[i] = (uint8_t)u(4); + pCDEF->cdef_y_sec_strength[i] = (uint8_t)u(2); if (!sps->color_config.flags.mono_chrome) { - pCDEF->cdef_uv_pri_strength[i] = u(4); - pCDEF->cdef_uv_sec_strength[i] = u(2); + pCDEF->cdef_uv_pri_strength[i] = (uint8_t)u(4); + pCDEF->cdef_uv_sec_strength[i] = (uint8_t)u(2); } } } @@ -1500,7 +1500,7 @@ void VulkanAV1Decoder::DecodeLoopRestorationData() StdVideoAV1FrameRestorationType remap_lr_type[4] = { STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE, STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SWITCHABLE, STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_WIENER, STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SGRPROJ }; for (int pl = 0; pl < n_planes; pl++) { - uint8_t lr_type = u(2); + uint8_t lr_type = (uint8_t)u(2); pLoopRestoration->FrameRestorationType[pl] = remap_lr_type[lr_type]; if (pLoopRestoration->FrameRestorationType[pl] != STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE) { @@ -1516,7 +1516,7 @@ void VulkanAV1Decoder::DecodeLoopRestorationData() int sb_size = sps->flags.use_128x128_superblock == 1 /*BLOCK_128X128*/ ? 2 : 1; //128 : 64; for (int pl = 0; pl < n_planes; pl++) { - pLoopRestoration->LoopRestorationSize[pl] = sb_size; // 64 or 128 + pLoopRestoration->LoopRestorationSize[pl] = (uint16_t)sb_size; // 64 or 128 } if (sps->flags.use_128x128_superblock == 1) { lr_unit_shift = 1 + u(1); @@ -1526,7 +1526,7 @@ void VulkanAV1Decoder::DecodeLoopRestorationData() lr_unit_shift += u(1); } } - pLoopRestoration->LoopRestorationSize[0] = 1 + lr_unit_shift; + pLoopRestoration->LoopRestorationSize[0] = 1 + (uint16_t)lr_unit_shift; } else { for (int pl = 0; pl < n_planes; pl++) pLoopRestoration->LoopRestorationSize[pl] = 3; @@ -1535,7 +1535,7 @@ void VulkanAV1Decoder::DecodeLoopRestorationData() if (!sps->color_config.flags.mono_chrome) { if (use_chroma_lr && (sps->color_config.subsampling_x && sps->color_config.subsampling_y)) { - lr_uv_shift = u(1); + lr_uv_shift = (uint8_t)u(1); pLoopRestoration->LoopRestorationSize[1] = pLoopRestoration->LoopRestorationSize[0] - lr_uv_shift; pLoopRestoration->LoopRestorationSize[2] = pLoopRestoration->LoopRestorationSize[1]; } else { @@ -1740,8 +1740,8 @@ int VulkanAV1Decoder::IsSkipModeAllowed() if (ref0 != -1 && ref1 != -1) { // == Bi-directional prediction == - pStd->SkipModeFrame[0] = std::min(ref0, ref1); - pStd->SkipModeFrame[1] = std::max(ref0, ref1); + pStd->SkipModeFrame[0] = (uint8_t)std::min(ref0, ref1); + pStd->SkipModeFrame[1] = (uint8_t)std::max(ref0, ref1); return 1; } else if (ref0 != -1) { // == Forward prediction only == @@ -1759,8 +1759,8 @@ int VulkanAV1Decoder::IsSkipModeAllowed() } } if (ref1 != -1) { - pStd->SkipModeFrame[0] = std::min(ref0, ref1); - pStd->SkipModeFrame[1] = std::max(ref0, ref1); + pStd->SkipModeFrame[0] = (uint8_t)std::min(ref0, ref1); + pStd->SkipModeFrame[1] = (uint8_t)std::max(ref0, ref1); return 1; } } @@ -1779,7 +1779,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() pic_flags->frame_size_override_flag = 0; last_frame_type = pStd->frame_type; - last_intra_only = intra_only; + last_intra_only = (uint8_t)intra_only; if (sps->flags.reduced_still_picture_header) { show_existing_frame = 0; @@ -1832,7 +1832,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() // load segmentation memcpy(pic_info->segmentation.FeatureEnabled, m_pBuffers[show_existing_frame_index].seg.FeatureEnabled, STD_VIDEO_AV1_MAX_SEGMENTS * sizeof(pic_info->segmentation.FeatureEnabled[0])); memcpy(pic_info->segmentation.FeatureData, m_pBuffers[show_existing_frame_index].seg.FeatureData, STD_VIDEO_AV1_MAX_SEGMENTS * STD_VIDEO_AV1_SEG_LVL_MAX * sizeof(pic_info->segmentation.FeatureData[0][0])); - pStd->OrderHint = RefOrderHint[show_existing_frame_index]; + pStd->OrderHint = (uint8_t)RefOrderHint[show_existing_frame_index]; UpdateFramePointers(m_pBuffers[show_existing_frame_index].buffer); } else { pStd->refresh_frame_flags = 0; @@ -1859,7 +1859,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() showable_frame = u(1); } - pic_flags->error_resilient_mode = (pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_SWITCH || (pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_KEY && pic_info->showFrame)) ? 1 : u(1); + pic_flags->error_resilient_mode = (pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_SWITCH || (pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_KEY && pic_info->showFrame)) ? 1 : flag(); } @@ -1870,19 +1870,19 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() } } - pic_flags->disable_cdf_update = u(1); + pic_flags->disable_cdf_update = flag(); if (sps->seq_force_screen_content_tools == STD_VIDEO_AV1_SELECT_SCREEN_CONTENT_TOOLS) { - pic_flags->allow_screen_content_tools = u(1); + pic_flags->allow_screen_content_tools = flag(); } else { - pic_flags->allow_screen_content_tools = sps->seq_force_screen_content_tools; + pic_flags->allow_screen_content_tools = sps->seq_force_screen_content_tools & 0x1; } if (pic_flags->allow_screen_content_tools) { if (sps->seq_force_integer_mv == STD_VIDEO_AV1_SELECT_INTEGER_MV) { - pic_flags->force_integer_mv = u(1); + pic_flags->force_integer_mv = flag(); } else { - pic_flags->force_integer_mv = sps->seq_force_integer_mv; + pic_flags->force_integer_mv = sps->seq_force_integer_mv & 0x1; } } else { pic_flags->force_integer_mv = 0; @@ -1947,17 +1947,17 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() pStd->current_frame_id = 0; } - pic_flags->frame_size_override_flag = pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_SWITCH ? 1 : u(1); + pic_flags->frame_size_override_flag = pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_SWITCH ? 1 : flag(); //order_hint - pStd->OrderHint = sps->flags.enable_order_hint ? u(sps->order_hint_bits_minus_1 + 1) : 0; + pStd->OrderHint = sps->flags.enable_order_hint ? u(sps->order_hint_bits_minus_1 + 1) & 0x1 : 0; if (!pic_flags->error_resilient_mode && !(IsFrameIntra())) { - pStd->primary_ref_frame = u(3); + pStd->primary_ref_frame = (uint8_t)u(3); } } if (sps->decoder_model_info_present) { - pic_flags->buffer_removal_time_present_flag = u(1); + pic_flags->buffer_removal_time_present_flag = flag(); if (pic_flags->buffer_removal_time_present_flag) { for (int opNum = 0; opNum <= sps->operating_points_cnt_minus_1; opNum++) { if (op_params[opNum].decoder_model_param_present) { @@ -1977,7 +1977,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() } if (pStd->frame_type == STD_VIDEO_AV1_FRAME_TYPE_KEY) { if (!pic_info->showFrame) { - pStd->refresh_frame_flags = u(8); + pStd->refresh_frame_flags = (uint8_t)u(8); } else { pStd->refresh_frame_flags = (1 << STD_VIDEO_AV1_NUM_REF_FRAMES) - 1; } @@ -1989,7 +1989,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() // memset(&ref_frame_names, -1, sizeof(ref_frame_names)); } else { if (intra_only || pStd->frame_type != 3) { - pStd->refresh_frame_flags = u(STD_VIDEO_AV1_NUM_REF_FRAMES); + pStd->refresh_frame_flags = (uint8_t)u(STD_VIDEO_AV1_NUM_REF_FRAMES); if (pStd->refresh_frame_flags == 0xFF && intra_only) { assert(!"Intra_only frames cannot have refresh flags 0xFF"); } @@ -2018,7 +2018,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() SetupFrameSize(pic_flags->frame_size_override_flag); if (pic_flags->allow_screen_content_tools && frame_width == upscaled_width) { - pic_flags->allow_intrabc = u(1); + pic_flags->allow_intrabc = flag(); } pic_flags->use_ref_frame_mvs = 0; } else { @@ -2026,7 +2026,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() // if (pbi->need_resync != 1) { if (sps->flags.enable_order_hint) { - pic_flags->frame_refs_short_signaling = u(1); + pic_flags->frame_refs_short_signaling = flag(); } else { pic_flags->frame_refs_short_signaling = 0; } @@ -2077,23 +2077,23 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() if (pic_flags->force_integer_mv) { pic_flags->allow_high_precision_mv = 0; } else { - pic_flags->allow_high_precision_mv = u(1); + pic_flags->allow_high_precision_mv = flag(); } //read_interpolation_filter int tmp = u(1); - pic_flags->is_filter_switchable = tmp; + pic_flags->is_filter_switchable = tmp & 0x1; if (tmp) { pStd->interpolation_filter = STD_VIDEO_AV1_INTERPOLATION_FILTER_SWITCHABLE; } else { pStd->interpolation_filter = (StdVideoAV1InterpolationFilter)u(2); } - pic_flags->is_motion_mode_switchable = u(1); + pic_flags->is_motion_mode_switchable = flag(); } if (!pic_flags->error_resilient_mode && sps->flags.enable_ref_frame_mvs && sps->flags.enable_order_hint && !IsFrameIntra()) { - pic_flags->use_ref_frame_mvs = u(1); + pic_flags->use_ref_frame_mvs = flag(); } else { pic_flags->use_ref_frame_mvs = 0; } @@ -2105,7 +2105,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() assert(false); } - pStd->OrderHints[i + STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME] = RefOrderHint[ref_frame_idx[i]]; + pStd->OrderHints[i + STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME] = (uint8_t)RefOrderHint[ref_frame_idx[i]]; } /* for (int i = 0; i < REFS_PER_FRAME; ++i) @@ -2133,7 +2133,7 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() } if (!(sps->flags.reduced_still_picture_header) && !(pic_flags->disable_cdf_update)) { - pic_flags->disable_frame_end_update_cdf = u(1); + pic_flags->disable_frame_end_update_cdf = flag(); } else { pic_flags->disable_frame_end_update_cdf = 1; } @@ -2147,15 +2147,15 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() pStd->delta_lf_res = 0; pic_flags->delta_lf_present = 0; pic_flags->delta_lf_multi = 0; - pic_flags->delta_q_present = pic_info->quantization.base_q_idx > 0 ? u(1) : 0; + pic_flags->delta_q_present = pic_info->quantization.base_q_idx > 0 ? flag() : 0; if (pic_flags->delta_q_present) { - pStd->delta_q_res = u(2); // 1 << u(2); use log2(). Shift is done at HW + pStd->delta_q_res = (uint8_t)u(2); // 1 << u(2); use log2(). Shift is done at HW if (!pic_flags->allow_intrabc) { - pic_flags->delta_lf_present = u(1); + pic_flags->delta_lf_present = flag(); } if (pic_flags->delta_lf_present) { - pStd->delta_lf_res = u(2); //1 << u(2); - pic_flags->delta_lf_multi = u(1); + pStd->delta_lf_res = (uint8_t)u(2); //1 << u(2); + pic_flags->delta_lf_multi = flag(); // av1_reset_loop_filter_delta(xd, av1_num_planes(cm)); // FIXME } } @@ -2169,10 +2169,10 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() pic_info->quantization.DeltaQVDc == 0 && pic_info->quantization.DeltaQVAc == 0; } - coded_lossless = lossless[0]; + coded_lossless = (uint8_t)lossless[0]; if (pic_flags->segmentation_enabled) { for (int i = 1; i < STD_VIDEO_AV1_MAX_SEGMENTS; i++) { - coded_lossless &= lossless[i]; + coded_lossless &= (uint8_t)lossless[i]; } } @@ -2203,20 +2203,20 @@ bool VulkanAV1Decoder::ParseObuFrameHeader() pStd->TxMode = coded_lossless ? STD_VIDEO_AV1_TX_MODE_ONLY_4X4 : (u(1) ? STD_VIDEO_AV1_TX_MODE_SELECT : STD_VIDEO_AV1_TX_MODE_LARGEST); if (!IsFrameIntra()) { - pic_flags->reference_select = u(1); + pic_flags->reference_select = flag(); } else { pic_flags->reference_select = 0; } - pic_flags->skip_mode_present = IsSkipModeAllowed() ? u(1) : 0; + pic_flags->skip_mode_present = IsSkipModeAllowed() ? flag() : 0; if (!IsFrameIntra() && !pic_flags->error_resilient_mode && sps->flags.enable_warped_motion) { - pic_flags->allow_warped_motion = u(1); + pic_flags->allow_warped_motion = flag(); } else { pic_flags->allow_warped_motion = 0; } - pic_flags->reduced_tx_set = u(1); + pic_flags->reduced_tx_set = flag(); // reset global motions for (int i = 0; i < GM_GLOBAL_MODELS_PER_FRAME; ++i) { @@ -2281,7 +2281,7 @@ bool VulkanAV1Decoder::ParseObuTileGroup(const AV1ObuHeader& hdr) consumedBytes += tile_size_bytes_minus_1 + 1; m_PicData.tileOffsets[m_PicData.khr_info.tileCount] = (uint32_t)m_nalu.start_offset + (uint32_t)consumedBytes; - tileSize = tile_size_minus_1 + 1; + tileSize = (size_t)(tile_size_minus_1 + 1); consumedBytes += (uint32_t)tileSize; skip_bits((uint32_t)(tileSize * 8)); diff --git a/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1GlobalMotionDec.cpp b/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1GlobalMotionDec.cpp index e5a3531..898fd4e 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1GlobalMotionDec.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/VulkanAV1GlobalMotionDec.cpp @@ -110,7 +110,7 @@ static uint16_t inv_recenter_nonneg(uint16_t r, uint16_t v) else if ((v & 1) == 0) return (v >> 1) + r; else - return r - ((v + 1) >> 1); + return r - (uint16_t)((v + 1) >> 1); } // Inverse recenters a non-negative literal v in [0, n-1] around a @@ -120,7 +120,7 @@ static uint16_t inv_recenter_finite_nonneg(uint16_t n, uint16_t r, uint16_t v) if ((r << 1) <= n) { return inv_recenter_nonneg(r, v); } else { - return n - 1 - inv_recenter_nonneg(n - 1 - r, v); + return (uint16_t)(n - 1 - inv_recenter_nonneg((uint16_t)(n - 1 - r), v)); } } @@ -129,25 +129,25 @@ uint16_t VulkanAV1Decoder::Read_primitive_quniform(uint16_t n) if (n <= 1) return 0; const int l = get_msb(n - 1) + 1; const int m = (1 << l) - n; - const int v = u(l - 1); - return v < m ? v : (v << 1) - m + u(1); + const int v = (int)u(l - 1); + return v < m ? (uint16_t)v : (uint16_t)((v << 1) - m + (uint16_t)u(1)); } uint16_t VulkanAV1Decoder::Read_primitive_subexpfin(uint16_t n, uint16_t k) { int i = 0; - int mk = 0; + uint16_t mk = 0; while (1) { int b = (i ? k + i - 1 : k); - int a = (1 << b); + uint16_t a = (1 << b); if (n <= mk + 3 * a) { return Read_primitive_quniform(n - mk) + mk; } if (!u(1)) { - return u(b) + mk; + return (uint16_t)(b + mk); } i = i + 1; @@ -166,9 +166,9 @@ uint16_t VulkanAV1Decoder::Read_primitive_refsubexpfin(uint16_t n, uint16_t k, u int16_t VulkanAV1Decoder::Read_signed_primitive_refsubexpfin(uint16_t n, uint16_t k, int16_t ref) { - ref += n - 1; - const uint16_t scaled_n = (n << 1) - 1; - return Read_primitive_refsubexpfin(scaled_n, k, ref) - n + 1; + ref += (int16_t)(n - 1); + const uint16_t scaled_n = (uint16_t)(n << 1) - 1; + return (int16_t)(Read_primitive_refsubexpfin(scaled_n, k, ref) - n + 1); } int VulkanAV1Decoder::ReadGlobalMotionParams(AV1WarpedMotionParams *params, const AV1WarpedMotionParams *ref_params, int allow_hp) @@ -188,24 +188,24 @@ int VulkanAV1Decoder::ReadGlobalMotionParams(AV1WarpedMotionParams *params, cons if (type >= ROTZOOM) { params->wmmat[2] = Read_signed_primitive_refsubexpfin( GM_ALPHA_MAX + 1, SUBEXPFIN_K, - (ref_params->wmmat[2] >> GM_ALPHA_PREC_DIFF) - + (int16_t)(ref_params->wmmat[2] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS)) * GM_ALPHA_DECODE_FACTOR + (1 << WARPEDMODEL_PREC_BITS); params->wmmat[3] = Read_signed_primitive_refsubexpfin( GM_ALPHA_MAX + 1, SUBEXPFIN_K, - (ref_params->wmmat[3] >> GM_ALPHA_PREC_DIFF)) * + (int16_t)(ref_params->wmmat[3] >> GM_ALPHA_PREC_DIFF)) * GM_ALPHA_DECODE_FACTOR; } if (type >= AFFINE) { params->wmmat[4] = Read_signed_primitive_refsubexpfin( GM_ALPHA_MAX + 1, SUBEXPFIN_K, - (ref_params->wmmat[4] >> GM_ALPHA_PREC_DIFF)) * + (int16_t)(ref_params->wmmat[4] >> GM_ALPHA_PREC_DIFF)) * GM_ALPHA_DECODE_FACTOR; params->wmmat[5] = Read_signed_primitive_refsubexpfin( GM_ALPHA_MAX + 1, SUBEXPFIN_K, - (ref_params->wmmat[5] >> GM_ALPHA_PREC_DIFF) - + (int16_t)(ref_params->wmmat[5] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS)) * GM_ALPHA_DECODE_FACTOR + (1 << WARPEDMODEL_PREC_BITS); @@ -224,12 +224,12 @@ int VulkanAV1Decoder::ReadGlobalMotionParams(AV1WarpedMotionParams *params, cons ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp : GM_TRANS_PREC_DIFF; params->wmmat[0] = Read_signed_primitive_refsubexpfin( - (1 << trans_bits) + 1, SUBEXPFIN_K, - (ref_params->wmmat[0] >> trans_prec_diff)) * + (uint16_t)(1 << trans_bits) + 1, SUBEXPFIN_K, + (int16_t)(ref_params->wmmat[0] >> trans_prec_diff)) * trans_dec_factor; params->wmmat[1] = Read_signed_primitive_refsubexpfin( - (1 << trans_bits) + 1, SUBEXPFIN_K, - (ref_params->wmmat[1] >> trans_prec_diff)) * + (uint16_t)(1 << trans_bits) + 1, SUBEXPFIN_K, + (int16_t)(ref_params->wmmat[1] >> trans_prec_diff)) * trans_dec_factor; } diff --git a/vk_video_decoder/libs/NvVideoParser/src/VulkanH264Parser.cpp b/vk_video_decoder/libs/NvVideoParser/src/VulkanH264Parser.cpp index 59e9698..0ae33f3 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/VulkanH264Parser.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/VulkanH264Parser.cpp @@ -217,7 +217,7 @@ bool VulkanH264Decoder::BeginPicture(VkParserPictureData *pnvpd) pnvpd->PicWidthInMbs = sps->pic_width_in_mbs_minus1 + 1; pnvpd->FrameHeightInMbs = (2 - sps->flags.frame_mbs_only_flag) * (sps->pic_height_in_map_units_minus1 + 1); pnvpd->pCurrPic = dpb[iCur].pPicBuf; - pnvpd->current_dpb_id = iCur; + pnvpd->current_dpb_id = (uint8_t)iCur; pnvpd->field_pic_flag = slh->field_pic_flag; pnvpd->bottom_field_flag = slh->bottom_field_flag; pnvpd->second_field = (slh->field_pic_flag) && (dpb[iCur].complementary_field_pair); @@ -337,7 +337,7 @@ bool VulkanH264Decoder::BeginPicture(VkParserPictureData *pnvpd) assert((dpb[i].state & 1) || (dpb[i].top_field_marking == 0)); assert((dpb[i].state & 2) || (dpb[i].bottom_field_marking == 0)); assert((dpb[i].state != 3) || (dpb[i].top_field_marking == 0) || (dpb[i].bottom_field_marking == 0) || (dpb[i].top_field_marking == dpb[i].bottom_field_marking)); - if (dpb[i].top_field_marking != 0 || dpb[i].bottom_field_marking != 0 || + if (dpb[i].top_field_marking != 0 || dpb[i].bottom_field_marking != 0 || (dpb[i].inter_view_flag && dpb[i].view_id != m_nhe.mvc.view_id)) { h264->dpb[i].pPicBuf = dpb[i].pPicBuf; @@ -351,7 +351,7 @@ bool VulkanH264Decoder::BeginPicture(VkParserPictureData *pnvpd) h264->dpb[i].FieldOrderCnt[1] = dpb[i].BottomFieldOrderCnt; } } - m_idr_found_flag |= (slh->nal_unit_type == 5) || (slh->nal_unit_type == 20 && !(slh->nhe.mvc.non_idr_flag)); + m_idr_found_flag |= (uint32_t)((slh->nal_unit_type == 5) || (slh->nal_unit_type == 20 && !(slh->nhe.mvc.non_idr_flag))) & 0x1; if ((pps->flags.weighted_pred_flag) && (slh->weights_out_of_range > 0) && (slh->slice_type != I) && (m_lErrorThreshold < 30)) { @@ -734,16 +734,16 @@ bool VulkanH264Decoder::BeginPicture_SVC(VkParserPictureData *pnvpd) h264->svcext.inter_layer_slice_alpha_c0_offset_div2 = (unsigned char) slh->inter_layer_slice_alpha_c0_offset_div2; h264->svcext.inter_layer_slice_beta_offset_div2 = (unsigned char) slh->inter_layer_slice_beta_offset_div2; - h264->svcext.f.inter_layer_deblocking_filter_control_present_flag = sps->svc.inter_layer_deblocking_filter_control_present_flag; - h264->svcext.f.extended_spatial_scalability_idc = sps->svc.extended_spatial_scalability_idc; - h264->svcext.f.adaptive_tcoeff_level_prediction_flag = sps->svc.adaptive_tcoeff_level_prediction_flag; - h264->svcext.f.slice_header_restriction_flag = sps->svc.slice_header_restriction_flag; - h264->svcext.f.chroma_phase_x_plus1_flag = sps->svc.chroma_phase_x_plus1_flag; - h264->svcext.f.chroma_phase_y_plus1 = sps->svc.chroma_phase_y_plus1; - h264->svcext.f.tcoeff_level_prediction_flag = slh->tcoeff_level_prediction_flag; - h264->svcext.f.constrained_intra_resampling_flag = slh->constrained_intra_resampling_flag; - h264->svcext.f.ref_layer_chroma_phase_x_plus1_flag = slh->ref_layer_chroma_phase_x_plus1_flag; - h264->svcext.f.store_ref_base_pic_flag = slh->store_ref_base_pic_flag; + h264->svcext.f.inter_layer_deblocking_filter_control_present_flag = sps->svc.inter_layer_deblocking_filter_control_present_flag & 0x1; + h264->svcext.f.extended_spatial_scalability_idc = sps->svc.extended_spatial_scalability_idc & 0x3; + h264->svcext.f.adaptive_tcoeff_level_prediction_flag = sps->svc.adaptive_tcoeff_level_prediction_flag & 0x1; + h264->svcext.f.slice_header_restriction_flag = sps->svc.slice_header_restriction_flag & 0x1; + h264->svcext.f.chroma_phase_x_plus1_flag = sps->svc.chroma_phase_x_plus1_flag & 0x1; + h264->svcext.f.chroma_phase_y_plus1 = sps->svc.chroma_phase_y_plus1 & 0x3; + h264->svcext.f.tcoeff_level_prediction_flag = slh->tcoeff_level_prediction_flag & 0x1; + h264->svcext.f.constrained_intra_resampling_flag = slh->constrained_intra_resampling_flag & 0x1; + h264->svcext.f.ref_layer_chroma_phase_x_plus1_flag = slh->ref_layer_chroma_phase_x_plus1_flag & 0x1; + h264->svcext.f.store_ref_base_pic_flag = slh->store_ref_base_pic_flag & 0x1; h264->svcext.scaled_ref_layer_left_offset = (short) slh->scaled_ref_layer_left_offset; h264->svcext.scaled_ref_layer_top_offset = (short) slh->scaled_ref_layer_top_offset; @@ -994,7 +994,7 @@ uint8_t VulkanH264Decoder::derive_MaxDpbFrames(const seq_parameter_set_s *sps) { if (level == mbs_level_limits[i].level) { - MaxDpbFrames = Min(mbs_level_limits[i].MaxDPBMbs / (PicWidthInMbs * FrameHeightInMbs), 16); + MaxDpbFrames = (uint8_t)Min(mbs_level_limits[i].MaxDPBMbs / (PicWidthInMbs * FrameHeightInMbs), 16); break; } } @@ -1060,7 +1060,7 @@ bool VulkanH264Decoder::IsPictureBoundary(int32_t rbsp_size) u(1); // inter_view_flag f(1, 1); // reserved_one_bit } - } + } if ((nal_unit_type != 1) && (nal_unit_type != 5) && (nal_unit_type != 20) && (nal_unit_type != 21)) return (nal_unit_type == 9); // access_unit_delimiter } @@ -1089,7 +1089,7 @@ bool VulkanH264Decoder::IsPictureBoundary(int32_t rbsp_size) } sps_id = m_ppss[pps_id]->seq_parameter_set_id; spss = base_layer ? &m_spss[0] : &m_spssvcs[0]; - + if ((slhold->pic_parameter_set_id != pps_id) || (!spss[sps_id])) return true; if (spss[sps_id]->flags.separate_colour_plane_flag) @@ -1114,7 +1114,7 @@ bool VulkanH264Decoder::IsPictureBoundary(int32_t rbsp_size) if (svc_extension_flag) { IdrPicFlag = idr_flag; - } + } else { // MVC @@ -1319,7 +1319,7 @@ int32_t VulkanH264Decoder::ParseNalUnit() case NAL_UNIT_CODED_SLICE_PREFIX: if (m_bUseSVC) { - if (m_nhe.svc_extension_flag) + if (m_nhe.svc_extension_flag) { m_prefix_nalu_valid = true; prefix_nal_unit_svc(nal_ref_idc); // prefix NAL unit @@ -1358,7 +1358,7 @@ bool VulkanH264Decoder::prefix_nal_unit_svc(int nal_ref_idc) int additional_prefix_nal_unit_extension_flag, additional_prefix_nal_unit_extension_data_flag = false; memset(&m_prefix_nal_unit_svc, 0, sizeof(m_prefix_nal_unit_svc)); - m_prefix_nal_unit_svc.nalu = m_nhe; + m_prefix_nal_unit_svc.nalu = m_nhe; if (nal_ref_idc != 0) { m_prefix_nal_unit_svc.store_ref_base_pic_flag = u(1); @@ -1390,7 +1390,7 @@ int VulkanH264Decoder::dec_ref_base_pic_marking(memory_management_base_control_o int i = 0; do { - if (i >= MAX_MMCOS) + if (i >= MAX_MMCOS) { nvParserLog("Too many memory_management_base_control_operation\n"); break; @@ -1426,7 +1426,7 @@ void VulkanH264Decoder::output_picture_SVC(VkPicIf *pPicBuf, int) //assert(m_ds == &dependency_state[m_iDQIdMax >> 4]); //if (m_ds != &dependency_state[m_iDQIdMax >> 4]) // nvParserLog("output of picture that is not in target dependency representation\n"); - display_picture(pPicBuf); + display_picture(pPicBuf); } static StdVideoH264LevelIdc levelIdcToVulkanLevelIdcEnum(uint8_t level_idc, bool constraint_set3_flag) @@ -1491,9 +1491,9 @@ static StdVideoH264LevelIdc levelIdcToVulkanLevelIdcEnum(uint8_t level_idc, bool int32_t VulkanH264Decoder::seq_parameter_set_rbsp(SpsNalUnitTarget spsNalUnitTarget, seq_parameter_set_s *spssvc) { - uint8_t profile_idc = u(8); - uint8_t constraint_set_flags = u(8); - uint8_t level_idc = u(8); + uint8_t profile_idc = (uint8_t)u(8); + uint8_t constraint_set_flags = (uint8_t)u(8); + uint8_t level_idc = (uint8_t)u(8); int sps_id = ue(); if ((sps_id < 0) || (sps_id >= MAX_NUM_SPS)) { @@ -1512,7 +1512,7 @@ int32_t VulkanH264Decoder::seq_parameter_set_rbsp(SpsNalUnitTarget spsNalUnitTar } // non-zero defaults - sps->seq_parameter_set_id = sps_id; + sps->seq_parameter_set_id = (uint8_t)sps_id; sps->chroma_format_idc = (StdVideoH264ChromaFormatIdc)1; sps->svc.slice_header_restriction_flag = 1; @@ -1540,12 +1540,12 @@ int32_t VulkanH264Decoder::seq_parameter_set_rbsp(SpsNalUnitTarget spsNalUnitTar return -1; } if (sps->chroma_format_idc == 3) { - sps->flags.separate_colour_plane_flag = u(1); + sps->flags.separate_colour_plane_flag = flag(); } - sps->bit_depth_luma_minus8 = ue(); - sps->bit_depth_chroma_minus8 = ue(); - sps->flags.qpprime_y_zero_transform_bypass_flag = u(1); - sps->seqScalingList.scaling_matrix_present_flag = u(1); + sps->bit_depth_luma_minus8 = (uint8_t)ue(); + sps->bit_depth_chroma_minus8 = (uint8_t)ue(); + sps->flags.qpprime_y_zero_transform_bypass_flag = flag(); + sps->seqScalingList.scaling_matrix_present_flag = flag(); if (sps->seqScalingList.scaling_matrix_present_flag) { for (int i = 0; i < 8; i++) { int scaling_list_type; @@ -1558,7 +1558,7 @@ int32_t VulkanH264Decoder::seq_parameter_set_rbsp(SpsNalUnitTarget spsNalUnitTar } } } - sps->log2_max_frame_num_minus4 = ue(); + sps->log2_max_frame_num_minus4 = (uint8_t)ue(); if ((uint32_t)sps->log2_max_frame_num_minus4 > 12) { nvParserLog("Invalid log2_max_frame_num_minus4 value in SPS (%d)\n", sps->log2_max_frame_num_minus4); return -1; @@ -1569,14 +1569,14 @@ int32_t VulkanH264Decoder::seq_parameter_set_rbsp(SpsNalUnitTarget spsNalUnitTar return -1; } if (sps->pic_order_cnt_type == 0) { - sps->log2_max_pic_order_cnt_lsb_minus4 = ue(); + sps->log2_max_pic_order_cnt_lsb_minus4 = (uint8_t)ue(); if ((uint32_t)sps->log2_max_pic_order_cnt_lsb_minus4 > 12) { nvParserLog("Invalid log2_max_pic_order_cnt_lsb_minus4 value in SPS (%d)\n", sps->log2_max_pic_order_cnt_lsb_minus4); return -1; } } else if (sps->pic_order_cnt_type == 1) { - sps->flags.delta_pic_order_always_zero_flag = u(1); + sps->flags.delta_pic_order_always_zero_flag = flag(); sps->offset_for_non_ref_pic = se(); sps->offset_for_top_to_bottom_field = se(); uint32_t num_ref_frames_in_pic_order_cnt_cycle = ue(); @@ -1590,13 +1590,13 @@ int32_t VulkanH264Decoder::seq_parameter_set_rbsp(SpsNalUnitTarget spsNalUnitTar sps->offset_for_ref_frame[i] = se(); } } - sps->max_num_ref_frames = ue(); + sps->max_num_ref_frames = (uint8_t)ue(); if (sps->max_num_ref_frames > 16) { nvParserLog("SPS: Invalid num_ref_frames value (%d)", sps->max_num_ref_frames); sps->max_num_ref_frames = 2; return -1; } - sps->flags.gaps_in_frame_num_value_allowed_flag = u(1); + sps->flags.gaps_in_frame_num_value_allowed_flag = flag(); sps->pic_width_in_mbs_minus1 = ue(); sps->pic_height_in_map_units_minus1 = ue(); if ((sps->pic_width_in_mbs_minus1 > 511) || (sps->pic_height_in_map_units_minus1 > 511)) { // enable upto 8192x8192 @@ -1604,19 +1604,19 @@ int32_t VulkanH264Decoder::seq_parameter_set_rbsp(SpsNalUnitTarget spsNalUnitTar (sps->pic_width_in_mbs_minus1 + 1) * 16, (sps->pic_height_in_map_units_minus1 + 1) * 16); return -1; } - sps->flags.frame_mbs_only_flag = u(1); + sps->flags.frame_mbs_only_flag = flag(); if (!sps->flags.frame_mbs_only_flag) { - sps->flags.mb_adaptive_frame_field_flag = u(1); + sps->flags.mb_adaptive_frame_field_flag = flag(); } - sps->flags.direct_8x8_inference_flag = u(1); - sps->flags.frame_cropping_flag = u(1); + sps->flags.direct_8x8_inference_flag = flag(); + sps->flags.frame_cropping_flag = flag(); if (sps->flags.frame_cropping_flag) { sps->frame_crop_left_offset = ue(); sps->frame_crop_right_offset = ue(); sps->frame_crop_top_offset = ue(); sps->frame_crop_bottom_offset = ue(); } - sps->flags.vui_parameters_present_flag = u(1); + sps->flags.vui_parameters_present_flag = flag(); sps->vui.initial_cpb_removal_delay_length = 24; if (sps->flags.vui_parameters_present_flag) { @@ -1881,9 +1881,9 @@ void VulkanH264Decoder::nal_unit_header_extension() // VUI parameters (Annex E.1) void VulkanH264Decoder::vui_parameters(vui_parameters_s *vui) { - vui->aspect_ratio_info_present_flag = u(1); + vui->aspect_ratio_info_present_flag = flag(); if (vui->aspect_ratio_info_present_flag) { // aspect_ratio_info_present_flag - vui->aspect_ratio_idc = u(8); + vui->aspect_ratio_idc = (uint8_t)u(8); } else { vui->aspect_ratio_idc = 0; } @@ -1915,18 +1915,18 @@ void VulkanH264Decoder::vui_parameters(vui_parameters_s *vui) vui->sar_height = 1; break; } - vui->overscan_info_present_flag = u(1); + vui->overscan_info_present_flag = flag(); if (vui->overscan_info_present_flag) // overscan_info_present_flag { - vui->overscan_appropriate_flag = u(1); // overscan_appropriate_flag + vui->overscan_appropriate_flag = flag(); // overscan_appropriate_flag } // Default values - vui->video_signal_type_present_flag = u(1); + vui->video_signal_type_present_flag = flag(); if (vui->video_signal_type_present_flag) { vui->video_format = u(3); - vui->video_full_range_flag = u(1); - vui->color_description_present_flag = u(1); + vui->video_full_range_flag = flag(); + vui->color_description_present_flag = flag(); if (vui->color_description_present_flag) // colour_description_present_flag { vui->colour_primaries = u(8); @@ -1935,31 +1935,31 @@ void VulkanH264Decoder::vui_parameters(vui_parameters_s *vui) } } - vui->chroma_loc_info_present_flag = u(1); + vui->chroma_loc_info_present_flag = flag(); if (vui->chroma_loc_info_present_flag) // chroma_loc_info_present_flag { ue(); // chroma_sample_loc_type_top_field ue(); // chroma_sample_loc_type_bottom_field } - vui->timing_info_present_flag = u(1); + vui->timing_info_present_flag = flag(); if (vui->timing_info_present_flag) { vui->num_units_in_tick = u(32); vui->time_scale = u(32); - vui->fixed_frame_rate_flag = u(1); + vui->fixed_frame_rate_flag = flag(); } - vui->nal_hrd_parameters_present_flag = u(1); + vui->nal_hrd_parameters_present_flag = flag(); if (vui->nal_hrd_parameters_present_flag) hrd_parameters(vui, &vui->nal_hrd); - vui->vcl_hrd_parameters_present_flag = u(1); + vui->vcl_hrd_parameters_present_flag = flag(); if (vui->vcl_hrd_parameters_present_flag) hrd_parameters(vui, &vui->vcl_hrd); if (vui->nal_hrd_parameters_present_flag || vui->vcl_hrd_parameters_present_flag) { u(1); // low_delay_hrd_flag; } - vui->pic_struct_present_flag = u(1); - vui->bitstream_restriction_flag = u(1); + vui->pic_struct_present_flag = flag(); + vui->bitstream_restriction_flag = flag(); if (vui->bitstream_restriction_flag) // bitstream_restriction_flag { u(1); // motion_vectors_over_pic_boundaries_flag @@ -1976,9 +1976,9 @@ void VulkanH264Decoder::vui_parameters(vui_parameters_s *vui) // HRD parameters (E.1.2) void VulkanH264Decoder::hrd_parameters(vui_parameters_s *vui, hrd_parameters_s *hrd) { - uint8_t cpb_cnt_minus1 = ue(); // cpb_cnt_minus1 - hrd->bit_rate_scale = u(4) + 6; // bit_rate_scale - hrd->cpb_size_scale = u(4) + 4; // cpb_size_scale + uint8_t cpb_cnt_minus1 = (uint8_t)ue(); // cpb_cnt_minus1 + hrd->bit_rate_scale = (uint8_t)u(4) + 6; // bit_rate_scale + hrd->cpb_size_scale = (uint8_t)u(4) + 4; // cpb_size_scale hrd->cpb_cnt_minus1 = cpb_cnt_minus1; for (int SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) { @@ -2008,7 +2008,7 @@ int VulkanH264Decoder::scaling_list(unsigned char scalingList[], int sizeOfScali for (j = 0; j < sizeOfScalingList; j++) { if (nextScale != 0 ) - { + { delta_scale = se(); nextScale = (lastScale + delta_scale) & 0xff; scaling_list_type = ((j == 0) && (nextScale == 0)) ? SCALING_LIST_USE_DEFAULT : SCALING_LIST_PRESENT; @@ -2041,8 +2041,8 @@ bool VulkanH264Decoder::pic_parameter_set_rbsp() pps->pic_parameter_set_id = (uint8_t)pps_id; pps->seq_parameter_set_id = (uint8_t)sps_id; - pps->flags.entropy_coding_mode_flag = u(1); - pps->flags.bottom_field_pic_order_in_frame_present_flag = u(1); + pps->flags.entropy_coding_mode_flag = flag(); + pps->flags.bottom_field_pic_order_in_frame_present_flag = flag(); // FMO uint8_t num_slice_groups_minus1 = (uint8_t)ue(); if (pps->num_slice_groups_minus1 > 7) @@ -2062,7 +2062,7 @@ bool VulkanH264Decoder::pic_parameter_set_rbsp() } slice_group_map_s *slcgrp = &m_slice_group_map[pps_id]; - slcgrp->slice_group_map_type = ue(); + slcgrp->slice_group_map_type = (uint16_t)ue(); if (slcgrp->slice_group_map_type > 6) { nvParserLog("Invalid slice_group_map_type value in PPS (%d)\n", slcgrp->slice_group_map_type); @@ -2085,7 +2085,7 @@ bool VulkanH264Decoder::pic_parameter_set_rbsp() else if ((slcgrp->slice_group_map_type >= 3) && (slcgrp->slice_group_map_type < 6)) { /* slcgrp->slice_group_change_direction_flag = */ u(1); - slcgrp->slice_group_change_rate_minus1 = ue(); + slcgrp->slice_group_change_rate_minus1 = (uint16_t)ue(); } else if (slcgrp->slice_group_map_type == 6) { @@ -2114,7 +2114,7 @@ bool VulkanH264Decoder::pic_parameter_set_rbsp() } pps->num_ref_idx_l0_default_active_minus1 = (unsigned char)num_ref_idx_l0_active_minus1; pps->num_ref_idx_l1_default_active_minus1 = (unsigned char)num_ref_idx_l1_active_minus1; - pps->flags.weighted_pred_flag = u(1); + pps->flags.weighted_pred_flag = flag(); pps->weighted_bipred_idc = (StdVideoH264WeightedBipredIdc)u(2); if (pps->weighted_bipred_idc > 2) { @@ -2124,13 +2124,13 @@ bool VulkanH264Decoder::pic_parameter_set_rbsp() pps->pic_init_qp_minus26 = (signed char)se(); pps->pic_init_qs_minus26 = (signed char)se(); pps->second_chroma_qp_index_offset = pps->chroma_qp_index_offset = (signed char)se(); - pps->flags.deblocking_filter_control_present_flag = u(1); - pps->flags.constrained_intra_pred_flag = u(1); - pps->flags.redundant_pic_cnt_present_flag = u(1); + pps->flags.deblocking_filter_control_present_flag = flag(); + pps->flags.constrained_intra_pred_flag = flag(); + pps->flags.redundant_pic_cnt_present_flag = flag(); if ((next_bits(8) & 0x7f) != 0) // if (more_rbsp_data()) { - pps->flags.transform_8x8_mode_flag = u(1); - pps->picScalinList.scaling_matrix_present_flag = u(1); + pps->flags.transform_8x8_mode_flag = flag(); + pps->picScalinList.scaling_matrix_present_flag = flag(); if (pps->picScalinList.scaling_matrix_present_flag) { for (uint32_t i = 0; i < (uint32_t)(6 + 2 * pps->flags.transform_8x8_mode_flag); i++) { int scaling_list_type; @@ -2187,7 +2187,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n else { if (m_bUseMVC && !m_prefix_nalu_valid && - (nal_unit_type == NAL_UNIT_CODED_SLICE || + (nal_unit_type == NAL_UNIT_CODED_SLICE || nal_unit_type == NAL_UNIT_CODED_SLICE_IDR)) { // H.7.4.1.1: Defaults for base-view when no prefix: @@ -2200,7 +2200,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n } slh->nal_ref_idc = (unsigned char)nal_ref_idc; slh->nal_unit_type = (unsigned char)nal_unit_type; - + if (slh->nhe.svc_extension_flag) { no_inter_layer_pred_flag = slh->nhe.svc.no_inter_layer_pred_flag; @@ -2225,8 +2225,8 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n //if ((uint32_t)slh->slice_type_raw > 9) // return false; slh->slice_type = slh->slice_type_raw % 5; - slh->pic_parameter_set_id = ue(); - if ((slh->pic_parameter_set_id < 0) || (slh->pic_parameter_set_id >= MAX_NUM_PPS) + slh->pic_parameter_set_id = (uint8_t)ue(); + if ((slh->pic_parameter_set_id >= MAX_NUM_PPS) || (!m_ppss[slh->pic_parameter_set_id])) { nvParserLog("Invalid PPS id in slice header (%d)\n", slh->pic_parameter_set_id); @@ -2248,14 +2248,14 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n } m_pps = pps; m_sps = sps; - + if ((!sps->max_num_ref_frames) && (slh->slice_type != I) && (slh->slice_type != SI)) return false; if (slh->nal_unit_type == 20) { if (slh->nhe.svc_extension_flag) { - slh->IdrPicFlag = m_nhe.svc.idr_flag; + slh->IdrPicFlag = (uint32_t)m_nhe.svc.idr_flag & 0x1; } else { slh->IdrPicFlag = !m_nhe.mvc.non_idr_flag; @@ -2287,7 +2287,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n MbaffFrameFlag = sps->flags.mb_adaptive_frame_field_flag && !slh->field_pic_flag; if ((uint32_t)slh->first_mb_in_slice >= (uint32_t)(PicSizeInMbs >> MbaffFrameFlag)) return false; - + if (slh->IdrPicFlag) slh->idr_pic_id = ue(); if (sps->pic_order_cnt_type == 0) @@ -2309,7 +2309,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n return false; // ignore redundant slices } } - + if (quality_id == 0) { if (slh->slice_type == B) { @@ -2353,7 +2353,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n { slh->store_ref_base_pic_flag = u(1); if ((slh->nhe.svc.use_ref_base_pic_flag || slh->store_ref_base_pic_flag) && !slh->IdrPicFlag) - slh->adaptive_ref_pic_marking_mode_flag = (unsigned char)dec_ref_base_pic_marking(slh->mmbco); + slh->adaptive_ref_pic_marking_mode_flag = (uint32_t)dec_ref_base_pic_marking(slh->mmbco) & 0x1; } } } @@ -2375,7 +2375,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n if(ue() != 1) // disable_deblocking_filter_idc { se(); // slice_alpha_c0_offset_div2 - se(); // slice_beta_offset_div2 + se(); // slice_beta_offset_div2 } } if (pps->num_slice_groups_minus1 > 0) @@ -2430,7 +2430,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n slh->scaled_ref_layer_right_offset = se(); slh->scaled_ref_layer_bottom_offset = se(); } - } + } if (!no_inter_layer_pred_flag) { slh->slice_skip_flag = u(1); @@ -2467,7 +2467,7 @@ bool VulkanH264Decoder::slice_header(slice_header_s *slh, int nal_ref_idc, int n } void VulkanH264Decoder::update_layer_info(seq_parameter_set_s *sps, pic_parameter_set_s *pps, slice_header_s *slh) -{ +{ int dqid = (slh->nhe.svc.dependency_id << 4) + slh->nhe.svc.quality_id; if (!m_layer_data[dqid].available) // first slice of layer { @@ -2486,7 +2486,7 @@ void VulkanH264Decoder::update_layer_info(seq_parameter_set_s *sps, pic_paramete } m_layer_data[dqid].slice_count++; - + m_slh_prev = *slh; m_bLayerFirstSlice = 0; return ; @@ -2679,10 +2679,10 @@ bool VulkanH264Decoder::dpb_sequence_start(slice_header_s *slh) { VkParserSequenceInfo nvsi; int PicWidthInMbs, FrameHeightInMbs, MaxDecFrameBuffering; - + m_PrevViewId = 0; m_PrevRefFrameNum = 0; - + m_slh = *slh; m_slh_prev = *slh; m_sps = m_spss[m_ppss[slh->pic_parameter_set_id]->seq_parameter_set_id]; @@ -2757,7 +2757,7 @@ bool VulkanH264Decoder::dpb_sequence_start(slice_header_s *slh) { uint32_t lNum = sps->vui.time_scale; // lNum/lDenom = field rate in Hz uint32_t lDenom = sps->vui.num_units_in_tick; - + if ((lDenom > 0) && (lNum > lDenom)) // > 1Hz { nvsi.frameRate = PackFrameRate((lNum + 1) >> 1, lDenom); @@ -2797,7 +2797,7 @@ bool VulkanH264Decoder::is_comp_field_pair(dpb_entry_s *dpb_local, slice_header_ // // 3.30 complementary non-reference field pair: // Two non-reference fields that are in consecutive access units in decoding order as - // - two coded fields of opposite parity where + // - two coded fields of opposite parity where // - the first field is not already a paired field. // // 3.31 complementary reference field pair: @@ -2923,7 +2923,7 @@ void VulkanH264Decoder::dpb_picture_start(pic_parameter_set_s *pps, slice_header picture_order_count(m_sps, &m_slh); picture_numbers(&m_slh, 1 << (m_sps->log2_max_frame_num_minus4 + 4)); // (7-1) - + picture_started = true; // WAR for SPS matrix changes at non-idr boundaries (use matrix from most recent SPS) @@ -3157,7 +3157,7 @@ void VulkanH264Decoder::dpb_picture_end() } } } - + // Limit decode->display latency according to max_num_reorder_frames (no optimizations for MVC/SVC to keep things simple) if (!m_bUseMVC && !m_bUseSVC && (m_sps->vui.max_num_reorder_frames < MAX_DPB_SIZE)) { @@ -3354,7 +3354,7 @@ void VulkanH264Decoder::picture_order_count_type_2(const seq_parameter_set_s *sp cur->BottomFieldOrderCnt = tempPicOrderCnt; else cur->TopFieldOrderCnt = tempPicOrderCnt; - + if (slh->mmco5) { prevFrameNumOffset = 0; @@ -3547,7 +3547,7 @@ void VulkanH264Decoder::picture_order_count_type_2_SVC(dependency_data_s *dd, de ds->dpb_entry[16].BottomFieldOrderCnt = tempPicOrderCnt; else ds->dpb_entry[16].TopFieldOrderCnt = tempPicOrderCnt; - + if (dd->slh.mmco5) { ds->prevFrameNumOffset = 0; @@ -3975,7 +3975,7 @@ void VulkanH264Decoder::gaps_in_frame_num() const seq_parameter_set_s* sps = m_sps; int MaxFrameNum, UnusedShortTermFrameNum; int i; - + MaxFrameNum = 1 << (sps->log2_max_frame_num_minus4 + 4); // (7-1) // 7.4.3 @@ -3992,7 +3992,7 @@ void VulkanH264Decoder::gaps_in_frame_num() while (UnusedShortTermFrameNum != m_slh.frame_num) { int bad_edit = false; - + slh->frame_num = UnusedShortTermFrameNum; slh->field_pic_flag = 0; slh->bottom_field_flag = 0; @@ -4143,7 +4143,7 @@ void VulkanH264Decoder::sliding_window_decoded_reference_picture_marking(uint32_ if ((dpb[i].top_field_marking == MARKING_SHORT || dpb[i].bottom_field_marking == MARKING_SHORT) && dpb[i].FrameNumWrap < minFrameNumWrap) { - if ((numShortTermExisting > 1) || (numShortTermExisting == numShortTerm) || + if ((numShortTermExisting > 1) || (numShortTermExisting == numShortTerm) || (dpb[i].not_existing) || (m_sps->flags.gaps_in_frame_num_value_allowed_flag)) { imin = i; @@ -4345,7 +4345,7 @@ void VulkanH264Decoder::adaptive_memory_control_decoded_reference_picture_markin { int numRefs = 0; int oldestIndex = -1, oldestIndexNE = -1; - + for (int i = 0; i < MAX_DPB_SIZE; i++) { if (dpb[i].view_id != slh->view_id) @@ -4353,7 +4353,7 @@ void VulkanH264Decoder::adaptive_memory_control_decoded_reference_picture_markin // Evict all short-term non-existing references, as the non-existing references may never be evicted if // adaptive_ref_pic_marking=1 - if ((dpb[i].not_existing) && (dpb[i].top_field_marking == MARKING_SHORT) && (dpb[i].bottom_field_marking == MARKING_SHORT) && + if ((dpb[i].not_existing) && (dpb[i].top_field_marking == MARKING_SHORT) && (dpb[i].bottom_field_marking == MARKING_SHORT) && (i != iCur) && (!m_sps->flags.gaps_in_frame_num_value_allowed_flag)) { dpb[i].top_field_marking = MARKING_UNUSED; @@ -4512,7 +4512,7 @@ void VulkanH264Decoder::dpb_bumping(int MaxDpbSize) void VulkanH264Decoder::flush_decoded_picture_buffer() { int i; - + // mark all reference pictures as "unused for reference" for (i=0; i<=MAX_DPB_SIZE; i++) { diff --git a/vk_video_decoder/libs/NvVideoParser/src/VulkanH265Parser.cpp b/vk_video_decoder/libs/NvVideoParser/src/VulkanH265Parser.cpp index 3eecbd9..a1c5543 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/VulkanH265Parser.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/VulkanH265Parser.cpp @@ -216,7 +216,7 @@ bool VulkanH265Decoder::BeginPicture(VkParserPictureData *pnvpd) if (m_nuh_layer_id > 0) { hevc->mv_hevc_enable = 1; - hevc->nuh_layer_id = m_nuh_layer_id; + hevc->nuh_layer_id = (uint8_t)m_nuh_layer_id; hevc->default_ref_layers_active_flag = vps->privFlags.default_ref_layers_active_flag; hevc->NumDirectRefLayers = vps->numDirectRefLayers[m_nuh_layer_id]; hevc->max_one_active_ref_layer_flag = vps->privFlags.max_one_active_ref_layer_flag; @@ -279,8 +279,8 @@ int32_t VulkanH265Decoder::ParseNalUnit() return NALU_DISCARD; } // Early exit for the reserved and unknown nal units types - if ((nal_unit_type > NUT_RASL_R && nal_unit_type < NUT_BLA_W_LP) || - (nal_unit_type > NUT_CRA_NUT && nal_unit_type < NUT_VPS_NUT) || + if ((nal_unit_type > NUT_RASL_R && nal_unit_type < NUT_BLA_W_LP) || + (nal_unit_type > NUT_CRA_NUT && nal_unit_type < NUT_VPS_NUT) || (nal_unit_type > NUT_SUFFIX_SEI_NUT)) { nvParserLog("Discarding NAL unit type %d\n", nal_unit_type); @@ -356,7 +356,7 @@ int32_t VulkanH265Decoder::ParseNalUnit() // Therefore set the m_max_dec_pic_buffering to be the max of the vps and sps buffering. uint8_t vps_max_dec_pic_buffering = 1; if (m_active_vps && m_vpss[sps->sps_video_parameter_set_id]) { - vps_max_dec_pic_buffering = (m_active_vps->vps_max_layers_minus1 + 1) * (m_active_vps->stdDecPicBufMgr.max_dec_pic_buffering_minus1[0] + 1); + vps_max_dec_pic_buffering = (uint8_t)((m_active_vps->vps_max_layers_minus1 + 1) * (m_active_vps->stdDecPicBufMgr.max_dec_pic_buffering_minus1[0] + 1)); } m_max_dec_pic_buffering = std::max(sps->max_dec_pic_buffering, vps_max_dec_pic_buffering); @@ -372,7 +372,7 @@ int32_t VulkanH265Decoder::ParseNalUnit() return NALU_DISCARD; } } - m_intra_pic_flag &= (m_slh.slice_type == SLICE_TYPE_I); + m_intra_pic_flag &= (uint32_t)(m_slh.slice_type == SLICE_TYPE_I) & 0x1; retval = NALU_SLICE; } } @@ -423,20 +423,20 @@ void VulkanH265Decoder::seq_parameter_set_rbsp() } if (!MultiLayerExtSpsFlag) { - sps->flags.sps_temporal_id_nesting_flag = u(1); + sps->flags.sps_temporal_id_nesting_flag = flag(); if ((!sps->sps_max_sub_layers_minus1) && (sps->flags.sps_temporal_id_nesting_flag != true)) { return; } sps->pProfileTierLevel = profile_tier_level(&sps->stdProfileTierLevel, sps->sps_max_sub_layers_minus1); } - uint8_t seq_parameter_set_id = ue(); + uint8_t seq_parameter_set_id = (uint8_t)ue(); bool sps_error = false; sps_error |= (seq_parameter_set_id >= MAX_NUM_SPS); sps->sps_seq_parameter_set_id = (uint8_t)seq_parameter_set_id; if (MultiLayerExtSpsFlag) { if (u(1)) { // update_rep_format_flag - sps->sps_rep_format_idx = u(8); + sps->sps_rep_format_idx = (uint8_t)u(8); } else { sps->sps_rep_format_idx = vps->vps_rep_format_idx[vps->LayerIdxInVps[m_nuh_layer_id]]; } @@ -450,14 +450,14 @@ void VulkanH265Decoder::seq_parameter_set_rbsp() sps->conf_win_right_offset = vps->repFormat[sps->sps_rep_format_idx].conf_win_vps_right_offset; sps->conf_win_top_offset = vps->repFormat[sps->sps_rep_format_idx].conf_win_vps_top_offset; sps->conf_win_bottom_offset = vps->repFormat[sps->sps_rep_format_idx].conf_win_vps_bottom_offset; - sps->bit_depth_luma_minus8 = vps->repFormat[sps->sps_rep_format_idx].bit_depth_vps_luma_minus8; - sps->bit_depth_chroma_minus8 = vps->repFormat[sps->sps_rep_format_idx].bit_depth_vps_chroma_minus8; + sps->bit_depth_luma_minus8 = (uint8_t)vps->repFormat[sps->sps_rep_format_idx].bit_depth_vps_luma_minus8; + sps->bit_depth_chroma_minus8 = (uint8_t)vps->repFormat[sps->sps_rep_format_idx].bit_depth_vps_chroma_minus8; } else { uint8_t chroma_format_idc = (uint8_t)ue(); sps_error |= (chroma_format_idc > 3); sps->chroma_format_idc = (StdVideoH265ChromaFormatIdc)chroma_format_idc; if (sps->chroma_format_idc == 3) { - sps->flags.separate_colour_plane_flag = u(1); + sps->flags.separate_colour_plane_flag = flag(); } sps->pic_width_in_luma_samples = ue(); sps->pic_height_in_luma_samples = ue(); @@ -544,32 +544,32 @@ void VulkanH265Decoder::seq_parameter_set_rbsp() sps->log2_diff_max_min_luma_transform_block_size = (uint8_t)ue(); sps->max_transform_hierarchy_depth_inter = (uint8_t)ue(); sps->max_transform_hierarchy_depth_intra = (uint8_t)ue(); - sps->flags.scaling_list_enabled_flag = u(1); + sps->flags.scaling_list_enabled_flag = flag(); if (sps->flags.scaling_list_enabled_flag) { uint32_t sps_infer_scaling_list_flag = 0; if (MultiLayerExtSpsFlag) { - sps_infer_scaling_list_flag = u(1); + sps_infer_scaling_list_flag = flag(); } if (sps_infer_scaling_list_flag) { u(6); // sps_scaling_list_ref_layer_id } else { - sps->flags.sps_scaling_list_data_present_flag = u(1); + sps->flags.sps_scaling_list_data_present_flag = flag(); if (sps->flags.sps_scaling_list_data_present_flag) { if (!scaling_list_data(&sps->sps_scaling_list)) return; } } } - sps->flags.amp_enabled_flag = u(1); - sps->flags.sample_adaptive_offset_enabled_flag = u(1); - sps->flags.pcm_enabled_flag = u(1); + sps->flags.amp_enabled_flag = flag(); + sps->flags.sample_adaptive_offset_enabled_flag = flag(); + sps->flags.pcm_enabled_flag = flag(); if (sps->flags.pcm_enabled_flag) { sps->pcm_sample_bit_depth_luma_minus1 = (uint8_t)u(4); sps->pcm_sample_bit_depth_chroma_minus1 = (uint8_t)u(4); sps->log2_min_pcm_luma_coding_block_size_minus3 = (uint8_t)ue(); sps->log2_diff_max_min_pcm_luma_coding_block_size = (uint8_t)ue(); - sps->flags.pcm_loop_filter_disabled_flag = u(1); + sps->flags.pcm_loop_filter_disabled_flag = flag(); if ((sps->pcm_sample_bit_depth_luma_minus1 + 1 > sps->bit_depth_luma_minus8 + 8) || (sps->pcm_sample_bit_depth_chroma_minus1 + 1 > sps->bit_depth_chroma_minus8 + 8)) { nvParserLog("Invalid pcm_sample_bit_depth_minus1 (y:%d, uv:%d)\n", sps->pcm_sample_bit_depth_luma_minus1, sps->pcm_sample_bit_depth_chroma_minus1); @@ -596,7 +596,7 @@ void VulkanH265Decoder::seq_parameter_set_rbsp() if (num_short_term_ref_pic_sets) { sps->pShortTermRefPicSet = sps->stdShortTermRefPicSet; } - sps->flags.long_term_ref_pics_present_flag = u(1); + sps->flags.long_term_ref_pics_present_flag = flag(); if (sps->flags.long_term_ref_pics_present_flag) { uint32_t num_long_term_ref_pics_sps = ue(); sps->pLongTermRefPicsSps = &sps->stdLongTermRefPicsSps; @@ -615,29 +615,29 @@ void VulkanH265Decoder::seq_parameter_set_rbsp() } } } - sps->flags.sps_temporal_mvp_enabled_flag = u(1); - sps->flags.strong_intra_smoothing_enabled_flag = u(1); - sps->flags.vui_parameters_present_flag = u(1); + sps->flags.sps_temporal_mvp_enabled_flag = flag(); + sps->flags.strong_intra_smoothing_enabled_flag = flag(); + sps->flags.vui_parameters_present_flag = flag(); if (sps->flags.vui_parameters_present_flag) { // vui_parameters_present_flag vui_parameters(sps, sps->sps_max_sub_layers_minus1); } - sps->flags.sps_extension_present_flag = u(1); + sps->flags.sps_extension_present_flag = flag(); if (sps->flags.sps_extension_present_flag) { // sps_extension_present_flag - sps->flags.sps_range_extension_flag = u(1); + sps->flags.sps_range_extension_flag = flag(); bool sps_multilayer_extension_flag = u(1); u(6); // sps_extension_6bits if (sps->flags.sps_range_extension_flag) { - sps->flags.transform_skip_rotation_enabled_flag = u(1); - sps->flags.transform_skip_context_enabled_flag = u(1); - sps->flags.implicit_rdpcm_enabled_flag = u(1); - sps->flags.explicit_rdpcm_enabled_flag = u(1); - sps->flags.extended_precision_processing_flag = u(1); - sps->flags.intra_smoothing_disabled_flag = u(1); - sps->flags.high_precision_offsets_enabled_flag = u(1); - sps->flags.persistent_rice_adaptation_enabled_flag = u(1); - sps->flags.cabac_bypass_alignment_enabled_flag = u(1); + sps->flags.transform_skip_rotation_enabled_flag = flag(); + sps->flags.transform_skip_context_enabled_flag = flag(); + sps->flags.implicit_rdpcm_enabled_flag = flag(); + sps->flags.explicit_rdpcm_enabled_flag = flag(); + sps->flags.extended_precision_processing_flag = flag(); + sps->flags.intra_smoothing_disabled_flag = flag(); + sps->flags.high_precision_offsets_enabled_flag = flag(); + sps->flags.persistent_rice_adaptation_enabled_flag = flag(); + sps->flags.cabac_bypass_alignment_enabled_flag = flag(); } if (sps_multilayer_extension_flag) { u(1); // inter_view_mv_vert_constraint_flag @@ -735,11 +735,11 @@ void VulkanH265Decoder::pic_parameter_set_rbsp() // Setting the sps_video_parameter_set_id as 0 for this case. // This also implies that with h.265 we need to cache the PPS/SPS data before we get a valid VPS at the client side. pps->sps_video_parameter_set_id = sps ? sps->sps_video_parameter_set_id : 0; // FIXME: pick the last SPS, instead. - pps->flags.dependent_slice_segments_enabled_flag = u(1); // name differs from spec - pps->flags.output_flag_present_flag = u(1); + pps->flags.dependent_slice_segments_enabled_flag = flag(); // name differs from spec + pps->flags.output_flag_present_flag = flag(); pps->num_extra_slice_header_bits = (uint8_t)u(3); - pps->flags.sign_data_hiding_enabled_flag = u(1); - pps->flags.cabac_init_present_flag = u(1); + pps->flags.sign_data_hiding_enabled_flag = flag(); + pps->flags.cabac_init_present_flag = flag(); uint32_t num_ref_idx_l0_default_active_minus1 = ue(); uint32_t num_ref_idx_l1_default_active_minus1 = ue(); if ((num_ref_idx_l0_default_active_minus1 > 15) || (num_ref_idx_l1_default_active_minus1 > 15)) { @@ -759,9 +759,9 @@ void VulkanH265Decoder::pic_parameter_set_rbsp() nvParserLog("Invalid init_qp_minus26 (%d)\n", pps->init_qp_minus26); return; } - pps->flags.constrained_intra_pred_flag = u(1); - pps->flags.transform_skip_enabled_flag = u(1); - pps->flags.cu_qp_delta_enabled_flag = u(1); + pps->flags.constrained_intra_pred_flag = flag(); + pps->flags.transform_skip_enabled_flag = flag(); + pps->flags.cu_qp_delta_enabled_flag = flag(); if (pps->flags.cu_qp_delta_enabled_flag) { pps->diff_cu_qp_delta_depth = (uint8_t)ue(); } @@ -773,12 +773,12 @@ void VulkanH265Decoder::pic_parameter_set_rbsp() nvParserLog("Invalid pps_crcb_qp_offset (cb:%d,cr:%d)\n", pps->pps_cb_qp_offset, pps->pps_cr_qp_offset); return; } - pps->flags.pps_slice_chroma_qp_offsets_present_flag = u(1); // name differs from spec - pps->flags.weighted_pred_flag = u(1); - pps->flags.weighted_bipred_flag = u(1); - pps->flags.transquant_bypass_enabled_flag = u(1); - pps->flags.tiles_enabled_flag = u(1); - pps->flags.entropy_coding_sync_enabled_flag = u(1); + pps->flags.pps_slice_chroma_qp_offsets_present_flag = flag(); // name differs from spec + pps->flags.weighted_pred_flag = flag(); + pps->flags.weighted_bipred_flag = flag(); + pps->flags.transquant_bypass_enabled_flag = flag(); + pps->flags.tiles_enabled_flag = flag(); + pps->flags.entropy_coding_sync_enabled_flag = flag(); pps->flags.loop_filter_across_tiles_enabled_flag = 1; // default as per spec, unless explicit if (pps->flags.tiles_enabled_flag) { @@ -792,7 +792,7 @@ void VulkanH265Decoder::pic_parameter_set_rbsp() } pps->num_tile_columns_minus1 = (uint8_t)num_tile_columns_minus1; pps->num_tile_rows_minus1 = (uint8_t)num_tile_rows_minus1; - pps->flags.uniform_spacing_flag = u(1); + pps->flags.uniform_spacing_flag = flag(); if (!pps->flags.uniform_spacing_flag) { assert(pps->num_tile_columns_minus1 < sizeof(pps->column_width_minus1) / sizeof(pps->column_width_minus1[0])); @@ -804,14 +804,14 @@ void VulkanH265Decoder::pic_parameter_set_rbsp() pps->row_height_minus1[i] = (uint16_t)ue(); } } - pps->flags.loop_filter_across_tiles_enabled_flag = u(1); + pps->flags.loop_filter_across_tiles_enabled_flag = flag(); } - pps->flags.pps_loop_filter_across_slices_enabled_flag = u(1); - pps->flags.deblocking_filter_control_present_flag = u(1); + pps->flags.pps_loop_filter_across_slices_enabled_flag = flag(); + pps->flags.deblocking_filter_control_present_flag = flag(); if (pps->flags.deblocking_filter_control_present_flag) { - pps->flags.deblocking_filter_override_enabled_flag = u(1); - pps->flags.pps_deblocking_filter_disabled_flag = u(1); // slice_disable_deblocking_filter_flag LoopFilterDisable + pps->flags.deblocking_filter_override_enabled_flag = flag(); + pps->flags.pps_deblocking_filter_disabled_flag = flag(); // slice_disable_deblocking_filter_flag LoopFilterDisable if (!pps->flags.pps_deblocking_filter_disabled_flag) { int beta_offset_div2 = se(); @@ -826,21 +826,21 @@ void VulkanH265Decoder::pic_parameter_set_rbsp() } } } - pps->flags.pps_scaling_list_data_present_flag = u(1); + pps->flags.pps_scaling_list_data_present_flag = flag(); if (pps->flags.pps_scaling_list_data_present_flag) { scaling_list_data(&pps->pps_scaling_list); } - pps->flags.lists_modification_present_flag = u(1); + pps->flags.lists_modification_present_flag = flag(); pps->log2_parallel_merge_level_minus2 = (uint8_t)ue(); if (pps->log2_parallel_merge_level_minus2 > 12) // TBD: What's supported worst-case without using SPS ? { nvParserLog("Invalid log2_parallel_merge_level_minus2 (%d)\n", pps->log2_parallel_merge_level_minus2); return; } - pps->flags.slice_segment_header_extension_present_flag = u(1); - pps->flags.pps_extension_present_flag = u(1); + pps->flags.slice_segment_header_extension_present_flag = flag(); + pps->flags.pps_extension_present_flag = flag(); if (pps->flags.pps_extension_present_flag) { - pps->flags.pps_range_extension_flag = u(1); + pps->flags.pps_range_extension_flag = flag(); int pps_multilayer_extension_flag = u(1); int pps_extension_6bits = u(6); UNUSED_LOCAL_VAR(pps_extension_6bits); @@ -848,8 +848,8 @@ void VulkanH265Decoder::pic_parameter_set_rbsp() if (pps->flags.transform_skip_enabled_flag) { pps->log2_max_transform_skip_block_size_minus2 = (uint8_t)ue(); } - pps->flags.cross_component_prediction_enabled_flag = u(1); - pps->flags.chroma_qp_offset_list_enabled_flag = u(1); + pps->flags.cross_component_prediction_enabled_flag = flag(); + pps->flags.chroma_qp_offset_list_enabled_flag = flag(); if (pps->flags.chroma_qp_offset_list_enabled_flag) { pps->diff_cu_chroma_qp_offset_depth = (uint8_t)ue(); pps->chroma_qp_offset_list_len_minus1 = (uint8_t)ue(); @@ -920,13 +920,13 @@ void VulkanH265Decoder::video_parameter_set_rbsp() } // vps base - vps->vps_video_parameter_set_id = vps_video_parameter_set_id; - vps->privFlags.vps_base_layer_internal_flag = u(1); - vps->privFlags.vps_base_layer_available_flag = u(1); + vps->vps_video_parameter_set_id = (uint8_t)vps_video_parameter_set_id; + vps->privFlags.vps_base_layer_internal_flag = flag(); + vps->privFlags.vps_base_layer_available_flag = flag(); uint32_t tmp = u(6); vps->vps_max_layers_minus1 = std::min(tmp, (uint32_t)(MAX_NUM_LAYER_IDS - 2)); - vps->vps_max_sub_layers_minus1 = u(3); - vps->flags.vps_temporal_id_nesting_flag = u(1); + vps->vps_max_sub_layers_minus1 = (uint8_t)u(3); + vps->flags.vps_temporal_id_nesting_flag = flag(); tmp = u(16); if (tmp != 0xFFFF) @@ -938,18 +938,18 @@ void VulkanH265Decoder::video_parameter_set_rbsp() vps->pProfileTierLevel = profile_tier_level(&vps->stdProfileTierLevel, vps->vps_max_sub_layers_minus1); - vps->flags.vps_sub_layer_ordering_info_present_flag = u(1); + vps->flags.vps_sub_layer_ordering_info_present_flag = flag(); for (uint32_t i = (vps->flags.vps_sub_layer_ordering_info_present_flag ? 0 : vps->vps_max_sub_layers_minus1); i <= vps->vps_max_sub_layers_minus1; i++) { - vps->stdDecPicBufMgr.max_dec_pic_buffering_minus1[i] = ue(); + vps->stdDecPicBufMgr.max_dec_pic_buffering_minus1[i] = (uint8_t)ue(); if (vps->stdDecPicBufMgr.max_dec_pic_buffering_minus1[i] >= HEVC_DPB_SIZE) { nvParserLog("Invalid vps parameter (vps_max_dec_pic_buffering_minus1=%d)\n", vps->stdDecPicBufMgr.max_dec_pic_buffering_minus1[i]); return; } - vps->stdDecPicBufMgr.max_num_reorder_pics[i] = ue(); + vps->stdDecPicBufMgr.max_num_reorder_pics[i] = (uint8_t)ue(); if (vps->stdDecPicBufMgr.max_num_reorder_pics[i] > vps->stdDecPicBufMgr.max_dec_pic_buffering_minus1[i]) { nvParserLog("Invalid vps parameter (vps_max_num_reorder_pics=%d)\n", vps->stdDecPicBufMgr.max_num_reorder_pics[i]); @@ -973,7 +973,7 @@ void VulkanH265Decoder::video_parameter_set_rbsp() for (uint32_t i = 1; i <= vps->vps_num_layer_sets - 1; i++) { for (uint32_t j = 0; j <= vps->vps_max_layer_id; j++) { - vps->layer_id_included_flag[i][j] = u(1); + vps->layer_id_included_flag[i][j] = (uint8_t)u(1); } } for (uint32_t i = 1; i <= vps->vps_num_layer_sets - 1; i++) @@ -982,13 +982,13 @@ void VulkanH265Decoder::video_parameter_set_rbsp() for (uint32_t m = 0; m <= vps->vps_max_layer_id; m++) { if (vps->layer_id_included_flag[i][m]) - vps->layer_set_layer_id_list[i][n++] = m; + vps->layer_set_layer_id_list[i][n++] = (uint8_t)m; } vps->num_layers_in_id_list[i] = n; } // HRD related - vps->flags.vps_timing_info_present_flag = u(1); + vps->flags.vps_timing_info_present_flag = flag(); if (vps->flags.vps_timing_info_present_flag != 0) { vps->vps_num_units_in_tick = u(16); @@ -998,7 +998,7 @@ void VulkanH265Decoder::video_parameter_set_rbsp() vps->vps_time_scale <<= 16; vps->vps_time_scale += u(16); - vps->flags.vps_poc_proportional_to_timing_flag = u(1); + vps->flags.vps_poc_proportional_to_timing_flag = flag(); if (vps->flags.vps_poc_proportional_to_timing_flag) { vps->vps_num_ticks_poc_diff_one_minus1 = ue(); @@ -1041,7 +1041,7 @@ void VulkanH265Decoder::video_parameter_set_rbsp() } if (i > 0) { - vps->cprms_present_flag[i] = u(1); + vps->cprms_present_flag[i] = (uint8_t)u(1); } hrd_parameters(&pHrdParameters[i], vps->cprms_present_flag[i], @@ -1058,7 +1058,7 @@ void VulkanH265Decoder::video_parameter_set_rbsp() if (hevc_spec_version != 201304) { - vps->privFlags.vps_extension_flag = u(1); + vps->privFlags.vps_extension_flag = flag(); if (vps->privFlags.vps_extension_flag != 0) { // vps_extension_alignment_bit_equal_to_one @@ -1097,7 +1097,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV pVideoParamSet->vps_max_sub_layers_minus1, 0); } - pVideoParamSet->privFlags.splitting_flag = u(1); + pVideoParamSet->privFlags.splitting_flag = flag(); ////////////////////////////////////////////////////// /* Layer and nuh_layer_id info */ @@ -1105,7 +1105,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV pVideoParamSet->numScalabilityTypes = 0; for (i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++) { - pVideoParamSet->scalability_mask_flag[i] = u(1); + pVideoParamSet->scalability_mask_flag[i] = (uint8_t)u(1); pVideoParamSet->numScalabilityTypes += pVideoParamSet->scalability_mask_flag[i]; } @@ -1117,10 +1117,10 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV { /* infer last dimension ID Len */ pVideoParamSet->dimension_id_len[pVideoParamSet->numScalabilityTypes - 1] - = 5 - xGetDimBitOffset(pVideoParamSet, pVideoParamSet->numScalabilityTypes - 1); + = 5 - (uint8_t)xGetDimBitOffset(pVideoParamSet, pVideoParamSet->numScalabilityTypes - 1); } - pVideoParamSet->privFlags.vps_nuh_layer_id_present_flag = u(1); + pVideoParamSet->privFlags.vps_nuh_layer_id_present_flag = flag(); for (i = 1; i <= pVideoParamSet->vps_max_layers_minus1; i++) { @@ -1145,14 +1145,14 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV { for (j = 0; j < pVideoParamSet->numScalabilityTypes; j++) { - pVideoParamSet->dimension_id[i][j] = (pVideoParamSet->layer_id_in_nuh[i] + pVideoParamSet->dimension_id[i][j] = (uint8_t)(pVideoParamSet->layer_id_in_nuh[i] & ( (1 << xGetDimBitOffset(pVideoParamSet, j + 1 ) ) - 1) ) >> xGetDimBitOffset(pVideoParamSet, j ); } } } for (i = 1; i <= pVideoParamSet->vps_max_layers_minus1; i++) { - pVideoParamSet->LayerIdxInVps[pVideoParamSet->layer_id_in_nuh[i]] = i; + pVideoParamSet->LayerIdxInVps[pVideoParamSet->layer_id_in_nuh[i]] = (uint8_t)i; } initNumViews(pVideoParamSet); @@ -1163,7 +1163,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV for (i = 0; i < pVideoParamSet->numViews; i++) { uint32_t codelength = pVideoParamSet->view_id_len; - pVideoParamSet->view_id_val[i] = u(codelength); + pVideoParamSet->view_id_val[i] = (uint8_t)u(codelength); } } @@ -1171,7 +1171,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV { for (j = 0; j < i; j++) { - pVideoParamSet->direct_dependency_flag[i][j] = u(1); + pVideoParamSet->direct_dependency_flag[i][j] = (uint8_t)u(1); } } @@ -1192,7 +1192,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV for (j = 1; j < pVideoParamSet->numIndependentLayers; j++) { uint32_t length = CeilLog2(pVideoParamSet->numLayersInTreePartition[j] + 1); - pVideoParamSet->highest_layer_idx_plus1[i][j] = u(length); + pVideoParamSet->highest_layer_idx_plus1[i][j] = (uint8_t)u(length); } uint32_t layerNum = 0; @@ -1205,12 +1205,12 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV pVideoParamSet->num_layers_in_id_list[lsIdx] = layerNum; } - pVideoParamSet->privFlags.vps_sub_layers_max_minus1_present_flag = u(1); + pVideoParamSet->privFlags.vps_sub_layers_max_minus1_present_flag = flag(); if (pVideoParamSet->privFlags.vps_sub_layers_max_minus1_present_flag) { for (i = 0; i <= pVideoParamSet->vps_max_layers_minus1; i++) - pVideoParamSet->sub_layers_vps_max_minus1[i] = u(3); + pVideoParamSet->sub_layers_vps_max_minus1[i] = (uint8_t)u(3); } else { @@ -1218,7 +1218,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV pVideoParamSet->sub_layers_vps_max_minus1[i] = pVideoParamSet->vps_max_sub_layers_minus1; } - pVideoParamSet->privFlags.max_tid_ref_present_flag = u(1); + pVideoParamSet->privFlags.max_tid_ref_present_flag = flag(); if (pVideoParamSet->privFlags.max_tid_ref_present_flag) { @@ -1227,12 +1227,12 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV for (j = i+1; j <= pVideoParamSet->vps_max_layers_minus1; j++) { if (pVideoParamSet->direct_dependency_flag[j][i]) - pVideoParamSet->max_tid_il_ref_pics_plus1[i][j] = u(3); + pVideoParamSet->max_tid_il_ref_pics_plus1[i][j] = (uint8_t)u(3); } } } - pVideoParamSet->privFlags.default_ref_layers_active_flag = u(1); + pVideoParamSet->privFlags.default_ref_layers_active_flag = flag(); pVideoParamSet->vps_num_profile_tier_level_minus1 = ue(); if (pVideoParamSet->vps_num_profile_tier_level_minus1 > 63 || @@ -1243,7 +1243,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV } for (i = pVideoParamSet->privFlags.vps_base_layer_internal_flag ? 2 : 1; i <= pVideoParamSet->vps_num_profile_tier_level_minus1; i++) { - pVideoParamSet->vps_profile_present_flag[i] = u(1); + pVideoParamSet->vps_profile_present_flag[i] = (uint8_t)u(1); pVideoParamSet->pProfileTierLevel = profile_tier_level(&pVideoParamSet->stdProfileTierLevel, pVideoParamSet->vps_max_sub_layers_minus1, pVideoParamSet->vps_profile_present_flag[i]); } @@ -1288,7 +1288,7 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV if (pVideoParamSet->necessaryLayerFlag[i][j] && pVideoParamSet->vps_num_profile_tier_level_minus1 > 0) { uint32_t codelength = CeilLog2(pVideoParamSet->vps_num_profile_tier_level_minus1 + 1); - pVideoParamSet->profile_tier_level_idx[i][j] = u(codelength); + pVideoParamSet->profile_tier_level_idx[i][j] = (uint8_t)u(codelength); } } @@ -1336,25 +1336,25 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV if(pVideoParamSet->vps_num_rep_formats_minus1 > 0) { - pVideoParamSet->privFlags.rep_format_idx_present_flag = u(1); + pVideoParamSet->privFlags.rep_format_idx_present_flag = flag(); if (pVideoParamSet->privFlags.rep_format_idx_present_flag) { for (i = pVideoParamSet->privFlags.vps_base_layer_internal_flag ? 1 : 0; i <= pVideoParamSet->vps_max_layers_minus1; i++) { uint32_t codelength = CeilLog2(pVideoParamSet->vps_num_rep_formats_minus1 + 1); - pVideoParamSet->vps_rep_format_idx[i] = u(codelength); + pVideoParamSet->vps_rep_format_idx[i] = (uint8_t)u(codelength); } } } - pVideoParamSet->privFlags.max_one_active_ref_layer_flag = u(1); - pVideoParamSet->privFlags.vps_poc_lsb_aligned_flag = u(1); + pVideoParamSet->privFlags.max_one_active_ref_layer_flag = flag(); + pVideoParamSet->privFlags.vps_poc_lsb_aligned_flag = flag(); for (i = 1; i <= pVideoParamSet->vps_max_layers_minus1; i++) { if (pVideoParamSet->numDirectRefLayers[pVideoParamSet->layer_id_in_nuh[i]] == 0) { - pVideoParamSet->poc_lsb_not_present_flag[i] = u(1); + pVideoParamSet->poc_lsb_not_present_flag[i] = (uint8_t)u(1); } } @@ -1362,13 +1362,13 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV for (i = 1; i < pVideoParamSet->numOutputLayerSets; i++) { uint32_t currLsIdx = olsIdxToLsIdx(pVideoParamSet, i); - pVideoParamSet->sub_layer_flag_info_present_flag[i] = u(1); + pVideoParamSet->sub_layer_flag_info_present_flag[i] = (uint8_t)u(1); for (j = 0; j <= pVideoParamSet->sub_layers_vps_max_minus1[currLsIdx]; j++) { if (j > 0 && pVideoParamSet->sub_layer_flag_info_present_flag[i]) { - pVideoParamSet->sub_layer_dpb_info_present_flag[i][j] = u(1); + pVideoParamSet->sub_layer_dpb_info_present_flag[i][j] = (uint8_t)u(1); } else if (j == 0) { @@ -1382,11 +1382,11 @@ void VulkanH265Decoder::video_parameter_set_rbspExtension(hevc_video_param_s *pV if (pVideoParamSet->necessaryLayerFlag[i][k] && (pVideoParamSet->privFlags.vps_base_layer_internal_flag || (pVideoParamSet->layer_set_layer_id_list[currLsIdx][k] != 0) )) { - pVideoParamSet->max_vps_dec_pic_buffering_minus1[i][k][j] = ue(); + pVideoParamSet->max_vps_dec_pic_buffering_minus1[i][k][j] = (uint8_t)ue(); } } - pVideoParamSet->max_vps_num_reorder_pics[i][j] = ue(); - pVideoParamSet->max_vps_latency_increase_plus1[i][j] = ue(); + pVideoParamSet->max_vps_num_reorder_pics[i][j] = (uint8_t)ue(); + pVideoParamSet->max_vps_latency_increase_plus1[i][j] = (uint8_t)ue(); } } } @@ -1427,7 +1427,7 @@ void VulkanH265Decoder::deriveNecessaryLayerFlags(hevc_video_param_s *pVideoPara pVideoParamSet->numOutputLayersInOutputLayerSet[olsIdx] = 0; for (uint32_t j = 0; j < pVideoParamSet->num_layers_in_id_list[olsIdxToLsIdx(pVideoParamSet, olsIdx)]; j++) { - pVideoParamSet->numOutputLayersInOutputLayerSet[olsIdx] += (pVideoParamSet->output_layer_flag[olsIdx][j]); + pVideoParamSet->numOutputLayersInOutputLayerSet[olsIdx] += (uint8_t)(pVideoParamSet->output_layer_flag[olsIdx][j]); if (pVideoParamSet->output_layer_flag[olsIdx][j]) { pVideoParamSet->olsHighestOutputLayerId[olsIdx] = pVideoParamSet->layer_set_layer_id_list[olsIdxToLsIdx(pVideoParamSet, olsIdx)][j]; @@ -1462,7 +1462,7 @@ void VulkanH265Decoder::setRefLayers(hevc_video_param_s *pVideoParamSet) uint32_t iNuhLId = pVideoParamSet->layer_id_in_nuh[i]; for (j = 0, d = 0, r = 0, p = 0; j <= pVideoParamSet->vps_max_layers_minus1; j++) { - uint32_t jNuhLid = pVideoParamSet->layer_id_in_nuh[j]; + uint8_t jNuhLid = pVideoParamSet->layer_id_in_nuh[j]; if (pVideoParamSet->direct_dependency_flag[i][j]) { pVideoParamSet->idDirectRefLayer[iNuhLId][d++] = jNuhLid; @@ -1475,9 +1475,9 @@ void VulkanH265Decoder::setRefLayers(hevc_video_param_s *pVideoParamSet) { pVideoParamSet->idPredictedLayer[iNuhLId][p++] = jNuhLid; } - pVideoParamSet->numDirectRefLayers[iNuhLId] = d; - pVideoParamSet->numRefLayers[iNuhLId] = r; - pVideoParamSet->numPredictedLayers[iNuhLId] = p; + pVideoParamSet->numDirectRefLayers[iNuhLId] = (uint8_t)d; + pVideoParamSet->numRefLayers[iNuhLId] = (uint8_t)r; + pVideoParamSet->numPredictedLayers[iNuhLId] = (uint8_t)p; } } @@ -1487,13 +1487,13 @@ void VulkanH265Decoder::setRefLayers(hevc_video_param_s *pVideoParamSet) } for (i = 0, k = 0; i <= pVideoParamSet->vps_max_layers_minus1; i++ ) { - uint32_t iNuhLId = pVideoParamSet->layer_id_in_nuh[i]; + uint8_t iNuhLId = pVideoParamSet->layer_id_in_nuh[i]; if (pVideoParamSet->numDirectRefLayers[iNuhLId] == 0) { pVideoParamSet->treePartitionLayerIdList[k][0] = iNuhLId; for (j = 0, h = 1; j < pVideoParamSet->numPredictedLayers[iNuhLId]; j++) { - uint32_t predLId = pVideoParamSet->idPredictedLayer[iNuhLId][j]; + uint8_t predLId = pVideoParamSet->idPredictedLayer[iNuhLId][j]; if (!pVideoParamSet->layerIdInListFlag[predLId]) { pVideoParamSet->treePartitionLayerIdList[k][h++] = predLId; @@ -1525,7 +1525,7 @@ void VulkanH265Decoder::initNumViews(hevc_video_param_s *pVideoParamSet) ScalabilityId[i][smIdx] = 0; } } - pVideoParamSet->viewOrderIdx[lId] = ScalabilityId[i][1]; + pVideoParamSet->viewOrderIdx[lId] = (uint8_t)ScalabilityId[i][1]; if (i > 0) { uint32_t newViewFlag = 1; @@ -1641,7 +1641,7 @@ const StdVideoH265ProfileTierLevel* VulkanH265Decoder::profile_tier_level(StdVid u(24); // general source/constraint flags(4), general_reserved_zero_44bits[0..19] u(24); // general_reserved_zero_44bits[20..43] } - uint8_t general_level_idc = u(8); // general_level_idc + uint8_t general_level_idc = (uint8_t)u(8); // general_level_idc // Table A.4 - General tier and level limits pProfileTierLevel->general_level_idc = generalLevelIdcToVulkanLevelIdcEnum(general_level_idc); @@ -1750,9 +1750,9 @@ StdVideoH265ShortTermRefPicSet* VulkanH265Decoder::short_term_ref_pic_set(StdVid int delta_rps_sign = u(1); stdShortTermRefPicSet->flags.delta_rps_sign = (delta_rps_sign != 0) ? 1 : 0; int abs_delta_rps_minus1 = ue(); - stdShortTermRefPicSet->abs_delta_rps_minus1 = (uint32_t)abs_delta_rps_minus1; + stdShortTermRefPicSet->abs_delta_rps_minus1 = (uint16_t)abs_delta_rps_minus1; int DeltaRPS = (1 - 2 * delta_rps_sign) * (abs_delta_rps_minus1 + 1); - int RIdx = idx - (delta_idx_minus1 + 1); + int RIdx = idx - (int)(delta_idx_minus1 + 1); assert(RIdx >= 0); const short_term_ref_pic_set_s *rstrps = &strpss[RIdx]; for (int j = 0; j <= (rstrps->NumNegativePics + rstrps->NumPositivePics); j++) @@ -1812,7 +1812,7 @@ StdVideoH265ShortTermRefPicSet* VulkanH265Decoder::short_term_ref_pic_set(StdVid } } strps->NumNegativePics = (uint8_t)i; - stdShortTermRefPicSet->num_negative_pics = (uint32_t)i; + stdShortTermRefPicSet->num_negative_pics = (uint8_t)i; } { int i = 0; @@ -1823,7 +1823,7 @@ StdVideoH265ShortTermRefPicSet* VulkanH265Decoder::short_term_ref_pic_set(StdVid { assert(i < MAX_NUM_STRPS_ENTRIES); strps->DeltaPocS1[i] = dPoc; - stdShortTermRefPicSet->delta_poc_s1_minus1[i] = dPoc; + stdShortTermRefPicSet->delta_poc_s1_minus1[i] = (uint16_t)dPoc; strps->UsedByCurrPicS1[i] = used_by_curr_pic_flag[j]; if (strps->UsedByCurrPicS1[i] != 0) { stdShortTermRefPicSet->used_by_curr_pic_s1_flag |= (1 << i); @@ -1835,7 +1835,7 @@ StdVideoH265ShortTermRefPicSet* VulkanH265Decoder::short_term_ref_pic_set(StdVid { assert(i < MAX_NUM_STRPS_ENTRIES); strps->DeltaPocS1[i] = DeltaRPS; - stdShortTermRefPicSet->delta_poc_s1_minus1[i] = DeltaRPS; + stdShortTermRefPicSet->delta_poc_s1_minus1[i] = (uint16_t)DeltaRPS; strps->UsedByCurrPicS1[i] = used_by_curr_pic_flag[rstrps->NumNegativePics+rstrps->NumPositivePics]; if (strps->UsedByCurrPicS1[i] != 0) { stdShortTermRefPicSet->used_by_curr_pic_s1_flag |= (1 << i); @@ -1849,7 +1849,7 @@ StdVideoH265ShortTermRefPicSet* VulkanH265Decoder::short_term_ref_pic_set(StdVid { assert(i < MAX_NUM_STRPS_ENTRIES); strps->DeltaPocS1[i] = dPoc; - stdShortTermRefPicSet->delta_poc_s1_minus1[i] = dPoc; + stdShortTermRefPicSet->delta_poc_s1_minus1[i] = (uint16_t)dPoc; strps->UsedByCurrPicS1[i] = used_by_curr_pic_flag[rstrps->NumNegativePics + j]; if (strps->UsedByCurrPicS1[i] != 0) { stdShortTermRefPicSet->used_by_curr_pic_s1_flag |= (1 << i); @@ -1858,7 +1858,7 @@ StdVideoH265ShortTermRefPicSet* VulkanH265Decoder::short_term_ref_pic_set(StdVid } } strps->NumPositivePics = (uint8_t)i; - stdShortTermRefPicSet->num_positive_pics = (uint32_t)i; + stdShortTermRefPicSet->num_positive_pics = (uint8_t)i; } if (strps->NumNegativePics + strps->NumPositivePics > MAX_NUM_STRPS_ENTRIES) { @@ -1891,9 +1891,9 @@ StdVideoH265ShortTermRefPicSet* VulkanH265Decoder::short_term_ref_pic_set(StdVid used_by_curr_pic_s1_flag[i] = (uint8_t)u(1); } strps->NumNegativePics = (uint8_t)num_negative_pics; - stdShortTermRefPicSet->num_negative_pics = num_negative_pics; + stdShortTermRefPicSet->num_negative_pics = (uint8_t)num_negative_pics; strps->NumPositivePics = (uint8_t)num_positive_pics; - stdShortTermRefPicSet->num_positive_pics = num_positive_pics; + stdShortTermRefPicSet->num_positive_pics = (uint8_t)num_positive_pics; for (uint32_t i = 0; i < num_negative_pics; i++) { strps->DeltaPocS0[i] = ((i == 0) ? 0 : strps->DeltaPocS0[i - 1]) - (delta_poc_s0_minus1[i] + 1); @@ -1921,7 +1921,7 @@ void VulkanH265Decoder::vui_parameters(hevc_seq_param_s *sps, int sps_max_sub_la { StdVideoH265SequenceParameterSetVui *vui = &sps->stdVui; vui->aspect_ratio_idc = STD_VIDEO_H265_ASPECT_RATIO_IDC_UNSPECIFIED; - vui->flags.aspect_ratio_info_present_flag = u(1); + vui->flags.aspect_ratio_info_present_flag = flag(); if (vui->flags.aspect_ratio_info_present_flag) { vui->aspect_ratio_idc = (StdVideoH265AspectRatioIdc)u(8); } @@ -1953,16 +1953,16 @@ void VulkanH265Decoder::vui_parameters(hevc_seq_param_s *sps, int sps_max_sub_la vui->sar_height = 1; break; } - vui->flags.overscan_info_present_flag = u(1); + vui->flags.overscan_info_present_flag = flag(); if (vui->flags.overscan_info_present_flag) { - vui->flags.overscan_appropriate_flag = u(1); + vui->flags.overscan_appropriate_flag = flag(); } - vui->flags.video_signal_type_present_flag = (uint8_t)u(1); + vui->flags.video_signal_type_present_flag = flag(); if (vui->flags.video_signal_type_present_flag) { vui->video_format = (uint8_t)u(3); - vui->flags.video_full_range_flag = (uint8_t)u(1); - vui->flags.colour_description_present_flag = (uint8_t)u(1); + vui->flags.video_full_range_flag = flag(); + vui->flags.colour_description_present_flag = flag(); if (vui->flags.colour_description_present_flag) { vui->colour_primaries = (uint8_t)u(8); @@ -1970,46 +1970,46 @@ void VulkanH265Decoder::vui_parameters(hevc_seq_param_s *sps, int sps_max_sub_la vui->matrix_coeffs = (uint8_t)u(8); } } - vui->flags.chroma_loc_info_present_flag = u(1); + vui->flags.chroma_loc_info_present_flag = flag(); if (vui->flags.chroma_loc_info_present_flag) { - vui->chroma_sample_loc_type_top_field = ue(); - vui->chroma_sample_loc_type_bottom_field = ue(); + vui->chroma_sample_loc_type_top_field = (uint8_t)ue(); + vui->chroma_sample_loc_type_bottom_field = (uint8_t)ue(); } - vui->flags.neutral_chroma_indication_flag = u(1); - vui->flags.field_seq_flag = (uint8_t)u(1); - vui->flags.frame_field_info_present_flag = u(1); - vui->flags.default_display_window_flag = u(1); + vui->flags.neutral_chroma_indication_flag = flag(); + vui->flags.field_seq_flag = flag(); + vui->flags.frame_field_info_present_flag = flag(); + vui->flags.default_display_window_flag = flag(); if (vui->flags.default_display_window_flag) { - vui->def_disp_win_left_offset = ue(); - vui->def_disp_win_right_offset = ue(); - vui->def_disp_win_top_offset = ue(); - vui->def_disp_win_bottom_offset = ue(); + vui->def_disp_win_left_offset = (uint16_t)ue(); + vui->def_disp_win_right_offset = (uint16_t)ue(); + vui->def_disp_win_top_offset = (uint16_t)ue(); + vui->def_disp_win_bottom_offset = (uint16_t)ue(); } - vui->flags.vui_timing_info_present_flag = (uint8_t)u(1); + vui->flags.vui_timing_info_present_flag = flag(); if (vui->flags.vui_timing_info_present_flag) { vui->vui_num_units_in_tick = u(32); vui->vui_time_scale = u(32); - vui->flags.vui_poc_proportional_to_timing_flag = u(1); + vui->flags.vui_poc_proportional_to_timing_flag = flag(); if (vui->flags.vui_poc_proportional_to_timing_flag) { vui->vui_num_ticks_poc_diff_one_minus1 = ue(); } - vui->flags.vui_hrd_parameters_present_flag = u(1); + vui->flags.vui_hrd_parameters_present_flag = flag(); if (vui->flags.vui_hrd_parameters_present_flag) { - hrd_parameters(&sps->stdHrdParameters, 1, sps_max_sub_layers_minus1); + hrd_parameters(&sps->stdHrdParameters, 1, (uint8_t)sps_max_sub_layers_minus1); sps->stdVui.pHrdParameters = &sps->stdHrdParameters; } } - vui->flags.bitstream_restriction_flag = u(1); + vui->flags.bitstream_restriction_flag = flag(); if (vui->flags.bitstream_restriction_flag) { - vui->flags.tiles_fixed_structure_flag = u(1); - vui->flags.motion_vectors_over_pic_boundaries_flag = u(1); - vui->flags.restricted_ref_pic_lists_flag = u(1); - vui->min_spatial_segmentation_idc = ue(); - vui->max_bytes_per_pic_denom = ue(); - vui->max_bits_per_min_cu_denom = ue(); - vui->log2_max_mv_length_horizontal = ue(); - vui->log2_max_mv_length_vertical = ue(); + vui->flags.tiles_fixed_structure_flag = flag(); + vui->flags.motion_vectors_over_pic_boundaries_flag = flag(); + vui->flags.restricted_ref_pic_lists_flag = flag(); + vui->min_spatial_segmentation_idc = (uint16_t)ue(); + vui->max_bytes_per_pic_denom = (uint8_t)ue(); + vui->max_bits_per_min_cu_denom = (uint8_t)ue(); + vui->log2_max_mv_length_horizontal = (uint8_t)ue(); + vui->log2_max_mv_length_vertical = (uint8_t)ue(); } } @@ -2039,26 +2039,26 @@ void VulkanH265Decoder::hrd_parameters(hevc_video_hrd_param_s* pStdHrdParameters { if (commonInfPresentFlag) { - pStdHrdParameters->flags.nal_hrd_parameters_present_flag = u(1); - pStdHrdParameters->flags.vcl_hrd_parameters_present_flag = u(1); + pStdHrdParameters->flags.nal_hrd_parameters_present_flag = flag(); + pStdHrdParameters->flags.vcl_hrd_parameters_present_flag = flag(); if (pStdHrdParameters->flags.nal_hrd_parameters_present_flag || pStdHrdParameters->flags.vcl_hrd_parameters_present_flag) { - pStdHrdParameters->flags.sub_pic_hrd_params_present_flag = u(1); + pStdHrdParameters->flags.sub_pic_hrd_params_present_flag = flag(); if (pStdHrdParameters->flags.sub_pic_hrd_params_present_flag) { - pStdHrdParameters->tick_divisor_minus2 = u(8); - pStdHrdParameters->du_cpb_removal_delay_increment_length_minus1 = u(5); - pStdHrdParameters->flags.sub_pic_cpb_params_in_pic_timing_sei_flag = u(1); - pStdHrdParameters->dpb_output_delay_du_length_minus1 = u(5); + pStdHrdParameters->tick_divisor_minus2 = (uint8_t)u(8); + pStdHrdParameters->du_cpb_removal_delay_increment_length_minus1 = (uint8_t)u(5); + pStdHrdParameters->flags.sub_pic_cpb_params_in_pic_timing_sei_flag = flag(); + pStdHrdParameters->dpb_output_delay_du_length_minus1 = (uint8_t)u(5); } - pStdHrdParameters->bit_rate_scale = u(4); - pStdHrdParameters->cpb_size_scale = u(4); + pStdHrdParameters->bit_rate_scale = (uint8_t)u(4); + pStdHrdParameters->cpb_size_scale = (uint8_t)u(4); if (pStdHrdParameters->flags.sub_pic_hrd_params_present_flag) { - pStdHrdParameters->cpb_size_du_scale = u(4); + pStdHrdParameters->cpb_size_du_scale = (uint8_t)u(4); } - pStdHrdParameters->initial_cpb_removal_delay_length_minus1 = u(5); - pStdHrdParameters->au_cpb_removal_delay_length_minus1 = u(5); - pStdHrdParameters->dpb_output_delay_length_minus1 = u(5); + pStdHrdParameters->initial_cpb_removal_delay_length_minus1 = (uint8_t)u(5); + pStdHrdParameters->au_cpb_removal_delay_length_minus1 = (uint8_t)u(5); + pStdHrdParameters->dpb_output_delay_length_minus1 = (uint8_t)u(5); } } assert(maxNumSubLayersMinus1 < STD_VIDEO_H265_SUBLAYERS_LIST_SIZE); @@ -2069,21 +2069,21 @@ void VulkanH265Decoder::hrd_parameters(hevc_video_hrd_param_s* pStdHrdParameters if (!fixed_pic_rate_general_flag) { fixed_pic_rate_within_cvs_flag = u(1); } else { - pStdHrdParameters->flags.fixed_pic_rate_general_flag |= (1 << i); + pStdHrdParameters->flags.fixed_pic_rate_general_flag |= (uint32_t)(1 << i) & 0xFF; fixed_pic_rate_within_cvs_flag = true; } if (fixed_pic_rate_within_cvs_flag) { - pStdHrdParameters->flags.fixed_pic_rate_within_cvs_flag |= (1 << i); + pStdHrdParameters->flags.fixed_pic_rate_within_cvs_flag |= (uint32_t)(1 << i) & 0xFF; } bool low_delay_hrd_flag = false; if (fixed_pic_rate_within_cvs_flag) { pStdHrdParameters->elemental_duration_in_tc_minus1[i] = (uint16_t)ue(); - pStdHrdParameters->flags.low_delay_hrd_flag &= ~(1 << i); + pStdHrdParameters->flags.low_delay_hrd_flag &= ~(uint32_t)(1 << i) & 0xFF; } else { low_delay_hrd_flag = u(1); if (low_delay_hrd_flag) { - pStdHrdParameters->flags.low_delay_hrd_flag |= (1 << i); + pStdHrdParameters->flags.low_delay_hrd_flag |= (uint32_t)(1 << i) & 0xFF; } } if (!low_delay_hrd_flag) { @@ -2218,7 +2218,7 @@ bool VulkanH265Decoder::slice_header(int nal_unit_type, int nuh_temporal_id_plus m_NumPocTotalCurr = 0; if (!IdrPicFlag) { - slh->short_term_ref_pic_set_sps_flag = (uint8_t)u(1); + slh->short_term_ref_pic_set_sps_flag = flag(); if (!slh->short_term_ref_pic_set_sps_flag) { int bitcnt = consumed_bits(); StdVideoH265ShortTermRefPicSet stdShortTermRefPicSet; @@ -2361,7 +2361,7 @@ void VulkanH265Decoder::getNumActiveRefLayerPics(const hevc_video_param_s* vps, } else if (vps->privFlags.default_ref_layers_active_flag) { - pSliceHeader->numActiveRefLayerPics = getNumRefLayerPics(vps, pSliceHeader); + pSliceHeader->numActiveRefLayerPics = (uint8_t)getNumRefLayerPics(vps, pSliceHeader); } else if (!pSliceHeader->inter_layer_pred_enabled_flag) { @@ -2726,7 +2726,7 @@ void VulkanH265Decoder::dpb_picture_start(VkSharedBaseObj& pps } } m_dpb_cur = cur; - m_current_dpb_id = iCur; + m_current_dpb_id = (int8_t)iCur; } @@ -2973,7 +2973,7 @@ void VulkanH265Decoder::reference_picture_set(hevc_slice_header_s *slh, int PicO if (m_RefPicSetStCurrBefore[i] < 0) { nvParserLog("short-term reference picture not available (POC=%d)\n", PocStCurrBefore[i]); - m_RefPicSetStCurrBefore[i] = create_lost_ref_pic(PocStCurrBefore[i], m_nuh_layer_id, 1); + m_RefPicSetStCurrBefore[i] = (int8_t)create_lost_ref_pic(PocStCurrBefore[i], m_nuh_layer_id, 1); } } @@ -2991,7 +2991,7 @@ void VulkanH265Decoder::reference_picture_set(hevc_slice_header_s *slh, int PicO if (m_RefPicSetStCurrAfter[i] < 0) { nvParserLog("short-term reference picture not available (POC=%d)\n", PocStCurrAfter[i]); - m_RefPicSetStCurrAfter[i] = create_lost_ref_pic(PocStCurrAfter[i], m_nuh_layer_id, 1); + m_RefPicSetStCurrAfter[i] = (int8_t)create_lost_ref_pic(PocStCurrAfter[i], m_nuh_layer_id, 1); } } @@ -3143,11 +3143,11 @@ void VulkanH265Decoder::sei_payload() for (uint8_t i = 0; i < 3; i++) { - display->display_primaries_x[i] = u(16); - display->display_primaries_y[i] = u(16); + display->display_primaries_x[i] = (uint16_t)u(16); + display->display_primaries_y[i] = (uint16_t)u(16); } - display->white_point_x = u(16); - display->white_point_y = u(16); + display->white_point_x = (uint16_t)u(16); + display->white_point_y = (uint16_t)u(16); display->max_display_mastering_luminance = u(32); display->min_display_mastering_luminance = u(32); diff --git a/vk_video_decoder/libs/NvVideoParser/src/VulkanVP9Decoder.cpp b/vk_video_decoder/libs/NvVideoParser/src/VulkanVP9Decoder.cpp index c6a9d37..3fcc83b 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/VulkanVP9Decoder.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/VulkanVP9Decoder.cpp @@ -246,9 +246,9 @@ uint32_t VulkanVP9Decoder::UpdateForwardProbability(vp9_prob_update_s *pProbSetu pProbSetup->transform_mode = ONLY_4X4; else { - pProbSetup->transform_mode = vp9_read_literal( 2); + pProbSetup->transform_mode = (char)vp9_read_literal( 2); if (pProbSetup->transform_mode == ALLOW_32X32) - pProbSetup->transform_mode += vp9_read_literal( 1); + pProbSetup->transform_mode += (char)vp9_read_literal( 1); if (pProbSetup->transform_mode == TX_MODE_SELECT) { for (i = 0; i < TX_SIZE_CONTEXTS; ++i) @@ -345,10 +345,10 @@ uint32_t VulkanVP9Decoder::UpdateForwardProbability(vp9_prob_update_s *pProbSetu // Compound prediction mode probabilities if (pProbSetup->allow_comp_inter_inter) { tmp = vp9_read_literal( 1); - pProbSetup->comp_pred_mode = tmp; + pProbSetup->comp_pred_mode = (char)tmp; if(tmp) { tmp = vp9_read_literal( 1); - pProbSetup->comp_pred_mode += tmp; + pProbSetup->comp_pred_mode += (char)tmp; if (pProbSetup->comp_pred_mode == HYBRID_PREDICTION) { for (i = 0; i < COMP_INTER_CONTEXTS; i++) @@ -431,9 +431,9 @@ void VulkanVP9Decoder::update_nmv( vp9_prob *const p, const vp9_prob upd_p) uint32_t tmp = vp9_read( upd_p); if (tmp) { #if 1 //def LOW_PRECISION_MV_UPDATE - *p = (vp9_read_literal( 7) << 1) | 1; + *p = (vp9_prob)(vp9_read_literal( 7) << 1) | 1; #else - *p = vp9_read_literal( 8); + *p = (vp9_prob)vp9_read_literal( 8); #endif } } @@ -611,7 +611,7 @@ int32_t VulkanVP9Decoder::inv_remap_prob(int32_t v, int32_t m) vp9_prob VulkanVP9Decoder::vp9hwdReadProbDiffUpdate( uint8_t oldp) { - int32_t p; + vp9_prob p; int32_t delp = vp9hwdDecodeSubExp( 4, 255 ); p = (vp9_prob)inv_remap_prob(delp, oldp); return p; @@ -623,7 +623,7 @@ vp9_prob VulkanVP9Decoder::vp9hwdReadProbDiffUpdate( uint8_t oldp) // this function assumes prob1 and prob2 are already within [1,255] range vp9_prob VulkanVP9Decoder::weighted_prob(int32_t prob1, int32_t prob2, int32_t factor) { - return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8); + return (vp9_prob)ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8); } vp9_prob VulkanVP9Decoder::clip_prob(uint32_t p) @@ -839,14 +839,14 @@ void VulkanVP9Decoder::adaptModeProbs(vp9_prob_update_s *pProbSetup) uint32_t i, j; for (i = 0; i < INTRA_INTER_CONTEXTS; i++) - pProbSetup->pProbTab->a.intra_inter_prob[i] = update_mode_ct2(m_PrevCtx.intra_inter_prob[i], pProbSetup->pCtxCounters->intra_inter_count[i]); + pProbSetup->pProbTab->a.intra_inter_prob[i] = (uint8_t)update_mode_ct2(m_PrevCtx.intra_inter_prob[i], pProbSetup->pCtxCounters->intra_inter_count[i]); for (i = 0; i < COMP_INTER_CONTEXTS; i++) - pProbSetup->pProbTab->a.comp_inter_prob[i] = update_mode_ct2(m_PrevCtx.comp_inter_prob[i], pProbSetup->pCtxCounters->comp_inter_count[i]); + pProbSetup->pProbTab->a.comp_inter_prob[i] = (uint8_t)update_mode_ct2(m_PrevCtx.comp_inter_prob[i], pProbSetup->pCtxCounters->comp_inter_count[i]); for (i = 0; i < REF_CONTEXTS; i++) - pProbSetup->pProbTab->a.comp_ref_prob[i] = update_mode_ct2(m_PrevCtx.comp_ref_prob[i], pProbSetup->pCtxCounters->comp_ref_count[i]); + pProbSetup->pProbTab->a.comp_ref_prob[i] = (uint8_t)update_mode_ct2(m_PrevCtx.comp_ref_prob[i], pProbSetup->pCtxCounters->comp_ref_count[i]); for (i = 0; i < REF_CONTEXTS; i++) for (j = 0; j < 2; j++) - pProbSetup->pProbTab->a.single_ref_prob[i][j] = update_mode_ct2(m_PrevCtx.single_ref_prob[i][j], pProbSetup->pCtxCounters->single_ref_count[i][j]); + pProbSetup->pProbTab->a.single_ref_prob[i][j] = (uint8_t)update_mode_ct2(m_PrevCtx.single_ref_prob[i][j], pProbSetup->pCtxCounters->single_ref_count[i][j]); for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) { @@ -927,7 +927,7 @@ void VulkanVP9Decoder::adaptModeProbs(vp9_prob_update_s *pProbSetup) } } for (i = 0; i < MBSKIP_CONTEXTS; ++i) - pProbSetup->pProbTab->a.mbskip_probs[i] = update_mode_ct2(m_PrevCtx.mbskip_probs[i],pProbSetup->pCtxCounters->mbskip_count[i]); + pProbSetup->pProbTab->a.mbskip_probs[i] = (uint8_t)update_mode_ct2(m_PrevCtx.mbskip_probs[i],pProbSetup->pCtxCounters->mbskip_count[i]); } void VulkanVP9Decoder::adaptModeContext(vp9_prob_update_s *pProbSetup) diff --git a/vk_video_decoder/libs/NvVideoParser/src/VulkanVideoDecoder.cpp b/vk_video_decoder/libs/NvVideoParser/src/VulkanVideoDecoder.cpp index 3d0f12a..86c7bc0 100644 --- a/vk_video_decoder/libs/NvVideoParser/src/VulkanVideoDecoder.cpp +++ b/vk_video_decoder/libs/NvVideoParser/src/VulkanVideoDecoder.cpp @@ -193,7 +193,7 @@ void VulkanVideoDecoder::skip_bits(uint32_t n) else m_nalu.get_zerocnt += (m_nalu.get_zerocnt < 2); } - m_nalu.get_bfr |= c; + m_nalu.get_bfr |= (uint32_t)c; } else { m_nalu.get_offset++; diff --git a/vk_video_decoder/libs/VkDecoderUtils/FFmpegDemuxer.cpp b/vk_video_decoder/libs/VkDecoderUtils/FFmpegDemuxer.cpp index 37888fc..b7408ff 100644 --- a/vk_video_decoder/libs/VkDecoderUtils/FFmpegDemuxer.cpp +++ b/vk_video_decoder/libs/VkDecoderUtils/FFmpegDemuxer.cpp @@ -502,7 +502,7 @@ class FFmpegDemuxer : public VideoStreamDemuxer { std::cout << "BitDepth: " << codedLumaBitDepth << std::endl; std::cout << "Profile: " << profile << std::endl; std::cout << "Level: " << level << std::endl; - std::cout << "Aspect Ration: " << (float)sample_aspect_ratio.num / sample_aspect_ratio.den << std::endl; + std::cout << "Aspect Ration: " << (float)sample_aspect_ratio.num / (float)sample_aspect_ratio.den << std::endl; static const char* FieldOrder[] = { "UNKNOWN", diff --git a/vk_video_decoder/libs/VkVideoDecoder/VkVideoDecoder.cpp b/vk_video_decoder/libs/VkVideoDecoder/VkVideoDecoder.cpp index 10bc703..5d2e66f 100644 --- a/vk_video_decoder/libs/VkVideoDecoder/VkVideoDecoder.cpp +++ b/vk_video_decoder/libs/VkVideoDecoder/VkVideoDecoder.cpp @@ -763,7 +763,7 @@ int VkVideoDecoder::DecodePictureWithParameters(VkParserPerFrameDecodeParameters VulkanVideoFrameBuffer::PictureResourceInfo dpbSetupPictureResourceInfo = VulkanVideoFrameBuffer::PictureResourceInfo(); int resourceIndexDpb = m_videoFrameBuffer->GetCurrentImageResourceByIndex( - pCurrFrameDecParams->currPicIdx, + (uint8_t)(pCurrFrameDecParams->currPicIdx), m_imageSpecsIndex.decodeDpb, &pCurrFrameDecParams->dpbSetupPictureResource, &dpbSetupPictureResourceInfo, @@ -802,7 +802,7 @@ int VkVideoDecoder::DecodePictureWithParameters(VkParserPerFrameDecodeParameters assert(m_useSeparateOutputImages != VK_FALSE); int resourceIndexOut = m_videoFrameBuffer->GetCurrentImageResourceByIndex( - pCurrFrameDecParams->currPicIdx, + (uint8_t)(pCurrFrameDecParams->currPicIdx), m_imageSpecsIndex.decodeOut, pOutputPictureResource, ¤tOutputPictureResourceInfo, @@ -864,7 +864,7 @@ int VkVideoDecoder::DecodePictureWithParameters(VkParserPerFrameDecodeParameters // FIXME: VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR is incorrect layout for linear or filtered output int resourceIndexFilter = m_videoFrameBuffer->GetCurrentImageResourceByIndex( - pCurrFrameDecParams->currPicIdx, + (uint8_t)(pCurrFrameDecParams->currPicIdx), filterOutImageSpecsIndex, pFrameFilterOutResource, pFrameFilterOutResourceInfo, @@ -1026,7 +1026,7 @@ int VkVideoDecoder::DecodePictureWithParameters(VkParserPerFrameDecodeParameters pCurrFrameDecParams->pStdSps, pCurrFrameDecParams->pStdVps, filterCmdBuffer); - int32_t retVal = m_videoFrameBuffer->QueuePictureForDecode(currPicIdx, pDecodePictureInfo, + int32_t retVal = m_videoFrameBuffer->QueuePictureForDecode((uint8_t)currPicIdx, pDecodePictureInfo, &referencedObjectsInfo, &frameSynchronizationInfo); if (currPicIdx != retVal) { @@ -1319,7 +1319,7 @@ int VkVideoDecoder::DecodePictureWithParameters(VkParserPerFrameDecodeParameters VkSharedBaseObj inputImageView; VkSharedBaseObj outputImageView; assert(m_imageSpecsIndex.filterIn != InvalidImageTypeIdx); - int32_t index = m_videoFrameBuffer->GetCurrentImageResourceByIndex(currPicIdx, m_imageSpecsIndex.filterIn, inputImageView); + int32_t index = m_videoFrameBuffer->GetCurrentImageResourceByIndex((uint8_t)(currPicIdx), m_imageSpecsIndex.filterIn, inputImageView); assert(index == currPicIdx); assert(inputImageView); @@ -1328,7 +1328,7 @@ int VkVideoDecoder::DecodePictureWithParameters(VkParserPerFrameDecodeParameters } assert(m_imageSpecsIndex.filterOut != InvalidImageTypeIdx); - index = m_videoFrameBuffer->GetCurrentImageResourceByIndex(currPicIdx, m_imageSpecsIndex.filterOut, outputImageView); + index = m_videoFrameBuffer->GetCurrentImageResourceByIndex((uint8_t)(currPicIdx), m_imageSpecsIndex.filterOut, outputImageView); assert(index == currPicIdx); assert(outputImageView); diff --git a/vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp b/vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp index be28dae..fba32a3 100644 --- a/vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp +++ b/vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp @@ -217,12 +217,12 @@ class DpbSlot { return oldPic; } - void Reserve() { m_reserved = true; } + void Reserve() { m_reserved = true & 0x1; } void MarkInUse(int32_t age = 0) { m_pictureId = age; - m_inUse = true; + m_inUse = 1; } int32_t getAge() { return m_pictureId; } @@ -230,8 +230,8 @@ class DpbSlot { private: int32_t m_pictureId; // PictureID at map time (age) vkPicBuffBase* m_picBuf; // Associated resource - int32_t m_reserved : 1; - int32_t m_inUse : 1; + uint32_t m_reserved : 1; + uint32_t m_inUse : 1; }; class DpbSlots { @@ -257,7 +257,7 @@ class DpbSlots { return m_dpbMaxSize; } - uint32_t oldDpbMaxSize = reconfigure ? m_dpbMaxSize : 0; + uint8_t oldDpbMaxSize = reconfigure ? (uint8_t)m_dpbMaxSize : 0; m_dpbMaxSize = newDpbMaxSize; m_dpb.resize(m_dpbMaxSize); @@ -334,8 +334,8 @@ class DpbSlots { void MapPictureResource(vkPicBuffBase* pPic, int32_t dpbSlot, int32_t age = 0) { - for (uint32_t slot = 0; slot < m_dpbMaxSize; slot++) { - if ((uint8_t)slot == dpbSlot) { + for (uint8_t slot = 0; slot < (uint8_t)m_dpbMaxSize; slot++) { + if (slot == dpbSlot) { m_dpb[slot].setPictureResource(pPic, age); } else if (pPic) { if (m_dpb[slot].getPictureResource() == pPic) { @@ -395,7 +395,7 @@ class VulkanVideoParser : public VkParserVideoDecodeClient, is_long_term = isLongTerm; is_field_ref = isFieldRef; if (isReference && isFieldRef) { - used_for_reference = (bottomFieldIsReference << bottomFieldShift) | (topFieldIsReference << topFieldShift); + used_for_reference = ((bottomFieldIsReference << bottomFieldShift) | (topFieldIsReference << topFieldShift)) & 0x3; } else { used_for_reference = isReference ? 3 : 0; } @@ -482,7 +482,7 @@ class VulkanVideoParser : public VkParserVideoDecodeClient, assert((dpbSlotIndex == (uint32_t)dpbSlot) || is_non_existing); pReferenceSlots[dpbEntryIdx].sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR; pReferenceSlots[dpbEntryIdx].slotIndex = dpbSlotIndex; - pReferenceSlots[dpbEntryIdx].pNext = pDpbRefList[dpbEntryIdx].Init(dpbSlotIndex); + pReferenceSlots[dpbEntryIdx].pNext = pDpbRefList[dpbEntryIdx].Init((uint8_t)dpbSlotIndex); StdVideoDecodeH264ReferenceInfo* pRefPicInfo = &pDpbRefList[dpbEntryIdx].stdReferenceInfo; pRefPicInfo->FrameNum = FrameIdx; @@ -511,7 +511,7 @@ class VulkanVideoParser : public VkParserVideoDecodeClient, assert((dpbSlotIndex == (uint32_t)dpbSlot) || is_non_existing); pReferenceSlots[dpbEntryIdx].sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR; pReferenceSlots[dpbEntryIdx].slotIndex = dpbSlotIndex; - pReferenceSlots[dpbEntryIdx].pNext = pDpbSlotInfo[dpbEntryIdx].Init(dpbSlotIndex); + pReferenceSlots[dpbEntryIdx].pNext = pDpbSlotInfo[dpbEntryIdx].Init((uint8_t)dpbSlotIndex); StdVideoDecodeH265ReferenceInfo* pRefPicInfo = &pDpbSlotInfo[dpbEntryIdx].stdReferenceInfo; pRefPicInfo->PicOrderCntVal = PicOrderCnt; @@ -541,7 +541,7 @@ class VulkanVideoParser : public VkParserVideoDecodeClient, assert((dpbSlotIndex == (uint32_t)dpbSlot) || is_non_existing); pReferenceSlots[dpbEntryIdx].sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR; pReferenceSlots[dpbEntryIdx].slotIndex = dpbSlotIndex; - pReferenceSlots[dpbEntryIdx].pNext = pDpbSlotInfo[dpbEntryIdx].Init(dpbSlotIndex); + pReferenceSlots[dpbEntryIdx].pNext = pDpbSlotInfo[dpbEntryIdx].Init((uint8_t)dpbSlotIndex); StdVideoDecodeAV1ReferenceInfo* pRefPicInfo = &pDpbSlotInfo[dpbEntryIdx].stdReferenceInfo; (void)pRefPicInfo; @@ -550,9 +550,9 @@ class VulkanVideoParser : public VkParserVideoDecodeClient, // Vulkan Video parser.cpp -- maintains its own indices. // We can use more indices in the parser than the spec. (Ther eis a max of 8 but we can use 16) // Reason for single structure for DPB -- the array is passed in the callback (in the proxy of the processor) - // It checks which references are in use. + // It checks which references are in use. // 2nd Finds which DPB references were assigned before - and reuses indices. - // The local array maintains the + // The local array maintains the pRefPicInfo->flags.disable_frame_end_update_cdf = ; pRefPicInfo->flags.segmentation_enabled = ; pRefPicInfo->base_q_idx = ; @@ -693,7 +693,7 @@ class VulkanVideoParser : public VkParserVideoDecodeClient, int8_t presetDpbSlot); int8_t AllocateDpbSlotForCurrentAV1(vkPicBuffBase* pPic, bool isReference, int8_t presetDpbSlot); - + protected: VkSharedBaseObj m_vkParser; @@ -1081,7 +1081,7 @@ uint32_t VulkanVideoParser::ResetPicDpbSlots(uint32_t picIndexSlotValidMask) if (m_dumpDpbData) { printf(";;; Resetting picIdx %d, was using dpb slot %d\n", picIdx, m_pictureToDpbSlotMap[picIdx]); } - SetPicDpbSlot(picIdx, -1); + SetPicDpbSlot((int8_t)picIdx, -1); } } } @@ -1188,11 +1188,11 @@ int32_t VulkanVideoParser::BeginSequence(const VkParserSequenceInfo* pnvsi) detectedFormat.bitrate = pnvsi->lBitrate; detectedFormat.display_aspect_ratio.x = pnvsi->lDARWidth; detectedFormat.display_aspect_ratio.y = pnvsi->lDARHeight; - detectedFormat.video_signal_description.video_format = pnvsi->lVideoFormat; - detectedFormat.video_signal_description.video_full_range_flag = pnvsi->uVideoFullRange; - detectedFormat.video_signal_description.color_primaries = pnvsi->lColorPrimaries; - detectedFormat.video_signal_description.transfer_characteristics = pnvsi->lTransferCharacteristics; - detectedFormat.video_signal_description.matrix_coefficients = pnvsi->lMatrixCoefficients; + detectedFormat.video_signal_description.video_format = pnvsi->lVideoFormat & 0x3; + detectedFormat.video_signal_description.video_full_range_flag = pnvsi->uVideoFullRange & 0x1; + detectedFormat.video_signal_description.color_primaries = (uint8_t)(pnvsi->lColorPrimaries); + detectedFormat.video_signal_description.transfer_characteristics = (uint8_t)(pnvsi->lTransferCharacteristics); + detectedFormat.video_signal_description.matrix_coefficients = (uint8_t)(pnvsi->lMatrixCoefficients); detectedFormat.seqhdr_data_length = (uint32_t)std::min((size_t)pnvsi->cbSequenceHeader, sizeof(raw_seqhdr_data)); detectedFormat.minNumDecodeSurfaces = pnvsi->nMinNumDecodeSurfaces; detectedFormat.maxNumDpbSlots = configDpbSlots; @@ -1264,7 +1264,7 @@ uint32_t VulkanVideoParser::FillDpbH264State( process for gaps in frame_num */ !!dpbIn[inIdx].is_long_term, isFieldRef, !!(used_for_reference & topFieldMask), - !!(used_for_reference & bottomFieldMask), dpbIn[inIdx].FrameIdx, + !!(used_for_reference & bottomFieldMask), (uint16_t)dpbIn[inIdx].FrameIdx, fieldOrderCntList, GetPic(dpbIn[inIdx].pPicBuf)); if (picIdx >= 0) { refDpbUsedAndValidMask |= (1 << picIdx); @@ -1477,7 +1477,7 @@ uint32_t VulkanVideoParser::FillDpbH265State( uint32_t numUsedRef = 0; if (m_dumpParserData) std::cout << "Ref frames data: " << std::endl; - for (int32_t inIdx = 0; inIdx < HEVC_MAX_DPB_SLOTS; inIdx++) { + for (int8_t inIdx = 0; inIdx < HEVC_MAX_DPB_SLOTS; inIdx++) { // used_for_reference: 0 = unused, 1 = top_field, 2 = bottom_field, 3 = // both_fields int8_t picIdx = GetPicIdx(pin->RefPics[inIdx]); @@ -1527,7 +1527,7 @@ uint32_t VulkanVideoParser::FillDpbH265State( for (int32_t dpbIdx = 0; (uint32_t)dpbIdx < numUsedRef; dpbIdx++) { if (!refOnlyDpbIn[dpbIdx].is_non_existing) { vkPicBuffBase* picBuff = refOnlyDpbIn[dpbIdx].m_picBuff; - int32_t picIdx = GetPicIdx(picBuff); // should always be valid at this point + int8_t picIdx = GetPicIdx(picBuff); // should always be valid at this point assert(picIdx >= 0); // We have up to 17 internal frame buffers, but only HEVC_MAX_DPB_SLOTS // dpb entries, so we need to re-map the index from the @@ -1536,7 +1536,7 @@ uint32_t VulkanVideoParser::FillDpbH265State( if (dpbSlot < 0) { dpbSlot = m_dpb.AllocateSlot(); assert(dpbSlot >= 0); - SetPicDpbSlot(picIdx, dpbSlot); + SetPicDpbSlot((int8_t)picIdx, dpbSlot); m_dpb[dpbSlot].setPictureResource(picBuff, m_nCurrentPictureID); } m_dpb[dpbSlot].MarkInUse(m_nCurrentPictureID); @@ -1718,7 +1718,7 @@ uint32_t VulkanVideoParser::FillDpbAV1State( } printf("\nref_frame_picture: "); for (int32_t inIdx = 0; inIdx < STD_VIDEO_AV1_NUM_REF_FRAMES; inIdx++) { - int8_t picIdx = pin->pic_idx[inIdx]; + int8_t picIdx = (int8_t)(pin->pic_idx[inIdx]); printf("%02d ", picIdx); } printf("\n"); @@ -1730,7 +1730,7 @@ uint32_t VulkanVideoParser::FillDpbAV1State( int8_t activeReferences[32]; memset(activeReferences, 0, sizeof(activeReferences)); for (size_t refName = 0; refName < STD_VIDEO_AV1_REFS_PER_FRAME; refName++) { - int8_t picIdx = isKeyFrame ? -1 : pin->pic_idx[pin->ref_frame_idx[refName]]; + int8_t picIdx = isKeyFrame ? -1 : (int8_t)(pin->pic_idx[pin->ref_frame_idx[refName]]); if (picIdx < 0) { //pKhr->referenceNameSlotIndices[refName] = -1; continue; @@ -1743,7 +1743,7 @@ uint32_t VulkanVideoParser::FillDpbAV1State( } for (int32_t inIdx = 0; inIdx < STD_VIDEO_AV1_NUM_REF_FRAMES; inIdx++) { - int8_t picIdx = isKeyFrame ? -1 : pin->pic_idx[inIdx]; + int8_t picIdx = isKeyFrame ? -1 : (int8_t)pin->pic_idx[inIdx]; int8_t dpbSlot = -1; if ((picIdx >= 0) && !(refDpbUsedAndValidMask & (1 << picIdx))) { dpbSlot = GetPicDpbSlot(picIdx); @@ -1813,7 +1813,7 @@ uint32_t VulkanVideoParser::FillDpbAV1State( uint8_t yellowSquare[] = { 0xf0, 0x9f, 0x9f, 0xa8, 0x00 }; printf("\nSlotsInUse: "); for (int i = 0; i < 9; i++) { - printf("%-2s ", (slotsInUse & (1<= 0); SetPicDpbSlot(currPicIdx, dpbSlot); // Assign the dpbSlot to the current picture index. m_dpb[dpbSlot].setPictureResource(pPic, m_nCurrentPictureID); // m_nCurrentPictureID is our main index. @@ -2001,7 +2001,7 @@ bool VulkanVideoParser::DecodePicture( //pDecodePictureInfo->videoFrameType = 0; // pd->CodecSpecific.h264.slice_type; // FIXME: If mvcext is enabled. - pDecodePictureInfo->viewId = pd->CodecSpecific.h264.mvcext.view_id; + pDecodePictureInfo->viewId = (uint16_t)(pd->CodecSpecific.h264.mvcext.view_id); pPictureInfo->pStdPictureInfo = &h264.stdPictureInfo; @@ -2070,7 +2070,7 @@ bool VulkanVideoParser::DecodePicture( referenceSlots, pCurrFrameDecParams->pGopReferenceImagesIndexes, h264.stdPictureInfo.flags, &setupReferenceSlot.slotIndex); // TODO: Remove it is for debugging only. Reserved fields must be set to "0". - pout->stdPictureInfo.reserved1 = pCurrFrameDecParams->numGopReferenceSlots; + pout->stdPictureInfo.reserved1 = (uint8_t)(pCurrFrameDecParams->numGopReferenceSlots); assert(!pd->ref_pic_flag || (setupReferenceSlot.slotIndex >= 0)); if (setupReferenceSlot.slotIndex >= 0) { setupReferenceSlot.pPictureResource = &pCurrFrameDecParams->dpbSetupPictureResource; @@ -2163,11 +2163,11 @@ bool VulkanVideoParser::DecodePicture( // NumBitsForShortTermRPSInSlice = s->sh.short_term_rps ? // s->sh.short_term_ref_pic_set_size : 0 - pStdPictureInfo->NumBitsForSTRefPicSetInSlice = pin->NumBitsForShortTermRPSInSlice; + pStdPictureInfo->NumBitsForSTRefPicSetInSlice = (uint16_t)(pin->NumBitsForShortTermRPSInSlice); // NumDeltaPocsOfRefRpsIdx = s->sh.short_term_rps ? // s->sh.short_term_rps->rps_idx_num_delta_pocs : 0 - pStdPictureInfo->NumDeltaPocsOfRefRpsIdx = pin->NumDeltaPocsOfRefRpsIdx; + pStdPictureInfo->NumDeltaPocsOfRefRpsIdx = (uint8_t)(pin->NumDeltaPocsOfRefRpsIdx); pStdPictureInfo->PicOrderCntVal = pin->CurrPicOrderCntVal; if (m_dumpParserData) @@ -2244,7 +2244,7 @@ bool VulkanVideoParser::DecodePicture( } nvVideoDecodeAV1DpbSlotInfo* dpbSlotsAv1 = av1.dpbRefList; - pCurrFrameDecParams->numGopReferenceSlots = + pCurrFrameDecParams->numGopReferenceSlots = FillDpbAV1State(pd, pin, dpbSlotsAv1, @@ -2284,7 +2284,7 @@ bool VulkanVideoParser::DecodePicture( bool isKeyFrame = pin->std_info.frame_type == STD_VIDEO_AV1_FRAME_TYPE_KEY; for (size_t i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) { - int8_t picIdx = isKeyFrame ? -1 : pin->pic_idx[pin->ref_frame_idx[i]]; + int8_t picIdx = isKeyFrame ? -1 : (int8_t)pin->pic_idx[pin->ref_frame_idx[i]]; if (picIdx < 0) { pPictureInfo->referenceNameSlotIndices[i] = -1; continue; diff --git a/vk_video_decoder/libs/VulkanVideoFrameBuffer/VulkanVideoFrameBuffer.cpp b/vk_video_decoder/libs/VulkanVideoFrameBuffer/VulkanVideoFrameBuffer.cpp index 4b5e98f..facc8fd 100644 --- a/vk_video_decoder/libs/VulkanVideoFrameBuffer/VulkanVideoFrameBuffer.cpp +++ b/vk_video_decoder/libs/VulkanVideoFrameBuffer/VulkanVideoFrameBuffer.cpp @@ -355,7 +355,7 @@ class VkVideoFrameBuffer : public VulkanVideoFrameBuffer { queueFamilyIndex); if (imageSetCreateResult >= 0) { - m_maxNumImageTypeIdx = maxNumImageTypeIdx; + m_maxNumImageTypeIdx = maxNumImageTypeIdx & 0xF; } m_numberParameterUpdates++; @@ -930,7 +930,7 @@ int32_t NvPerFrameDecodeImageSet::init(const VulkanDeviceContext* vkDevCtx, m_queueFamilyIndex = queueFamilyIndex; - for (uint32_t imageTypeIdx = 0; imageTypeIdx < maxNumImageTypeIdx; imageTypeIdx++) { + for (uint8_t imageTypeIdx = 0; imageTypeIdx < maxNumImageTypeIdx; imageTypeIdx++) { if (!(imageSpecs[imageTypeIdx].imageTypeIdx < DecodeFrameBufferIf::MAX_PER_FRAME_IMAGE_TYPES)) { continue; @@ -1008,11 +1008,11 @@ int32_t NvPerFrameDecodeImageSet::init(const VulkanDeviceContext* vkDevCtx, uint32_t maxNumImages = std::max(m_numImages, numImages); for (uint32_t imageIndex = firstIndex; imageIndex < maxNumImages; imageIndex++) { - bool imageExist = m_perFrameDecodeResources[imageIndex].ImageExist(imageTypeIdx); + bool imageExist = m_perFrameDecodeResources[imageIndex].ImageExist((uint8_t)imageTypeIdx); if (imageExist && reconfigureImages) { - m_perFrameDecodeResources[imageIndex].SetRecreateImage(imageTypeIdx); + m_perFrameDecodeResources[imageIndex].SetRecreateImage((uint8_t)imageTypeIdx); } else if (!imageExist && !m_imageSpecs[imageTypeIdx].deferCreate) { @@ -1035,7 +1035,7 @@ int32_t NvPerFrameDecodeImageSet::init(const VulkanDeviceContext* vkDevCtx, // layout in order for them to be cleared next time before use by transitioning // their layout from undefined to any of the encoder/decode/DPB. for (uint32_t imageIndex = 0; imageIndex < m_numImages; imageIndex++) { - m_perFrameDecodeResources[imageIndex].InvalidateImageLayout(imageTypeIdx); + m_perFrameDecodeResources[imageIndex].InvalidateImageLayout((uint8_t)imageTypeIdx); } } } diff --git a/vk_video_encoder/CMakeLists.txt b/vk_video_encoder/CMakeLists.txt index c869b33..fb6af6a 100644 --- a/vk_video_encoder/CMakeLists.txt +++ b/vk_video_encoder/CMakeLists.txt @@ -283,7 +283,7 @@ set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../scripts") include_directories("${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/../common/include") if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") - set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers") + set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wconversion") set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp") # These flags are not supported on Windows and some older version of GCC