Skip to content

Commit 664d280

Browse files
Enable and fix compiler warnings (#136)
1 parent b539a5b commit 664d280

File tree

8 files changed

+65
-79
lines changed

8 files changed

+65
-79
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ if(HIP_FOUND AND Libva_FOUND)
173173
# rocJPEG.so
174174
add_library(${PROJECT_NAME} SHARED ${SOURCES})
175175

176-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
176+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17 -Wall")
177177
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARY_LIST})
178178

179179
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)

src/amd_detail/rocjpeg_api_trace.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,14 @@ template <> struct dispatch_table_info<TYPE> { \
7070
static constexpr auto import_func = &ROCPROFILER_REGISTER_IMPORT_FUNC(NAME); \
7171
};
7272

73-
constexpr auto ComputeTableSize(size_t num_funcs) {
74-
return (num_funcs * sizeof(void*)) + sizeof(uint64_t);
75-
}
76-
7773
ROCJPEG_DEFINE_DISPATCH_TABLE_INFO(RocJpegDispatchTable, rocjpeg)
7874
#endif
7975

8076
template <typename Tp> void ToolInit(Tp* table) {
8177
#if ROCJPEG_ROCPROFILER_REGISTER > 0
8278
auto table_array = std::array<void*, 1>{static_cast<void*>(table)};
8379
auto lib_id = rocprofiler_register_library_indentifier_t{};
84-
auto rocp_reg_status = rocprofiler_register_library_api_table(
80+
rocprofiler_register_library_api_table(
8581
dispatch_table_info<Tp>::name, dispatch_table_info<Tp>::import_func,
8682
dispatch_table_info<Tp>::version, table_array.data(), table_array.size(), &lib_id);
8783
#else

src/rocjpeg_commons.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ THE SOFTWARE.
6464
} \
6565
}
6666

67-
static bool GetEnv(const char *name, char *value, size_t valueSize) {
68-
const char *v = getenv(name);
69-
if (v) {
70-
strncpy(value, v, valueSize);
71-
value[valueSize - 1] = 0;
72-
}
73-
return v ? true : false;
74-
}
75-
7667
static inline int align(int value, int alignment) {
7768
return (value + alignment - 1) & ~(alignment - 1);
7869
}

src/rocjpeg_decoder.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ RocJpegDecoder::RocJpegDecoder(RocJpegBackend backend, int device_id) :
2828
RocJpegDecoder::~RocJpegDecoder() {
2929
if (hip_stream_) {
3030
hipError_t hip_status = hipStreamDestroy(hip_stream_);
31+
if (hip_status != hipSuccess) {
32+
ERR("ERROR: Failed to destroy the HIP stream!");
33+
}
3134
}
3235
}
3336

@@ -44,7 +47,6 @@ RocJpegDecoder::~RocJpegDecoder() {
4447
* - ROCJPEG_STATUS_INVALID_PARAMETER if the requested device_id is not found.
4548
*/
4649
RocJpegStatus RocJpegDecoder::InitHIP(int device_id) {
47-
hipError_t hip_status = hipSuccess;
4850
CHECK_HIP(hipGetDeviceCount(&num_devices_));
4951
if (num_devices_ < 1) {
5052
ERR("ERROR: Failed to find any GPU!");
@@ -80,7 +82,7 @@ RocJpegStatus RocJpegDecoder::InitializeDecoder() {
8082
}
8183
if (backend_ == ROCJPEG_BACKEND_HARDWARE) {
8284
std::string gpu_uuid(hip_dev_prop_.uuid.bytes, sizeof(hip_dev_prop_.uuid.bytes));
83-
rocjpeg_status = jpeg_vaapi_decoder_.InitializeDecoder(hip_dev_prop_.name, hip_dev_prop_.gcnArchName, device_id_, gpu_uuid);
85+
rocjpeg_status = jpeg_vaapi_decoder_.InitializeDecoder(hip_dev_prop_.name, device_id_, gpu_uuid);
8486
if (rocjpeg_status != ROCJPEG_STATUS_SUCCESS) {
8587
ERR("ERROR: Failed to initialize the VA-API JPEG decoder!");
8688
return rocjpeg_status;
@@ -104,7 +106,6 @@ RocJpegStatus RocJpegDecoder::InitializeDecoder() {
104106
*/
105107
RocJpegStatus RocJpegDecoder::Decode(RocJpegStreamHandle jpeg_stream_handle, const RocJpegDecodeParams *decode_params, RocJpegImage *destination) {
106108
std::lock_guard<std::mutex> lock(mutex_);
107-
RocJpegStatus rocjpeg_status = ROCJPEG_STATUS_SUCCESS;
108109
if (jpeg_stream_handle == nullptr || decode_params == nullptr || destination == nullptr) {
109110
return ROCJPEG_STATUS_INVALID_PARAMETER;
110111
}

src/rocjpeg_hip_kernels.cpp

Lines changed: 52 additions & 52 deletions
Large diffs are not rendered by default.

src/rocjpeg_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ THE SOFTWARE.
2222
#include "rocjpeg_parser.h"
2323

2424
RocJpegStreamParser::RocJpegStreamParser() : stream_{nullptr}, stream_end_{nullptr}, stream_length_{0},
25-
jpeg_stream_parameters_{{}} {
25+
jpeg_stream_parameters_{} {
2626
}
2727

2828
RocJpegStreamParser::~RocJpegStreamParser() {
@@ -337,7 +337,7 @@ bool RocJpegStreamParser::ParseSOS() {
337337
jpeg_stream_parameters_.slice_parameter_buffer.num_components = num_components;
338338

339339
stream_ += 3;
340-
for (int32_t i = 0; i < num_components; i++) {
340+
for (uint32_t i = 0; i < num_components; i++) {
341341
component_id = *stream_++;
342342
table = *stream_++;
343343
jpeg_stream_parameters_.slice_parameter_buffer.components[i].component_selector = component_id;

src/rocjpeg_vaapi_decoder.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ bool RocJpegVaapiMemoryPool::SetSurfaceAsIdle(VASurfaceID surface_id) {
294294
*/
295295
RocJpegVappiDecoder::RocJpegVappiDecoder(int device_id) : device_id_{device_id}, drm_fd_{-1}, min_picture_width_{64}, min_picture_height_{64},
296296
max_picture_width_{4096}, max_picture_height_{4096}, supports_modifiers_{false}, va_display_{0}, va_config_attrib_{{}}, va_config_id_{0}, va_profile_{VAProfileJPEGBaseline},
297-
vaapi_mem_pool_(std::make_unique<RocJpegVaapiMemoryPool>()), current_vcn_jpeg_spec_{0}, va_picture_parameter_buf_id_{0}, va_quantization_matrix_buf_id_{0}, va_huffmantable_buf_id_{0},
297+
vaapi_mem_pool_(std::make_unique<RocJpegVaapiMemoryPool>()), current_vcn_jpeg_spec_{}, va_picture_parameter_buf_id_{0}, va_quantization_matrix_buf_id_{0}, va_huffmantable_buf_id_{0},
298298
va_slice_param_buf_id_{0}, va_slice_data_buf_id_{0} {};
299299

300300
/**
@@ -344,12 +344,11 @@ RocJpegVappiDecoder::~RocJpegVappiDecoder() {
344344
* and other necessary parameters. It also sets up the VAAPI display and creates the decoder configuration.
345345
*
346346
* @param device_name The name of the device.
347-
* @param gcn_arch_name The name of the GCN architecture.
348347
* @param device_id The ID of the device.
349348
* @param gpu_uuid The UUID of the GPU.
350349
* @return The status of the initialization process.
351350
*/
352-
RocJpegStatus RocJpegVappiDecoder::InitializeDecoder(std::string device_name, std::string gcn_arch_name, int device_id, std::string& gpu_uuid) {
351+
RocJpegStatus RocJpegVappiDecoder::InitializeDecoder(std::string device_name, int device_id, std::string& gpu_uuid) {
353352
device_id_ = device_id;
354353
std::vector<int> visible_devices;
355354
GetVisibleDevices(visible_devices);
@@ -788,14 +787,14 @@ RocJpegStatus RocJpegVappiDecoder::SubmitDecodeBatched(JpegStreamParameters *jpe
788787
CHECK_VAAPI(vaCreateSurfaces(va_display_, surface_format, key.width, key.height, mem_pool_entry.va_surface_ids.data(), mem_pool_entry.va_surface_ids.size(), surface_attribs.data(), supports_modifiers_ ? 2 : 1));
789788
mem_pool_entry.image_width = key.width;
790789
mem_pool_entry.image_height = key.height;
791-
for (int i = 0; i < mem_pool_entry.va_surface_ids.size(); i++) {
790+
for (size_t i = 0; i < mem_pool_entry.va_surface_ids.size(); i++) {
792791
surface_ids[indices[i]] = mem_pool_entry.va_surface_ids[i];
793792
}
794793
mem_pool_entry.hip_interops.resize(indices.size(), HipInteropDeviceMem());
795794
mem_pool_entry.entry_status = kBusy;
796795
CHECK_ROCJPEG(vaapi_mem_pool_->AddPoolEntry(key.pixel_format, mem_pool_entry));
797796
} else {
798-
for (int i = 0; i < mem_pool_entry.va_surface_ids.size(); i++) {
797+
for (size_t i = 0; i < mem_pool_entry.va_surface_ids.size(); i++) {
799798
surface_ids[indices[i]] = mem_pool_entry.va_surface_ids[i];
800799
}
801800
}

src/rocjpeg_vaapi_decoder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,11 @@ class RocJpegVappiDecoder {
277277
/**
278278
* @brief Initializes the decoder with the specified device, GCN architecture, and device ID.
279279
* @param device_name The name of the device.
280-
* @param gcn_arch_name The name of the GCN architecture.
281280
* @param device_id The ID of the device.
282281
* @param gpu_uuid The UUID of the GPU.
283282
* @return The status of the initialization.
284283
*/
285-
RocJpegStatus InitializeDecoder(std::string device_name, std::string gcn_arch_name, int device_id, std::string& gpu_uuid);
284+
RocJpegStatus InitializeDecoder(std::string device_name, int device_id, std::string& gpu_uuid);
286285

287286
/**
288287
* @brief Submits a JPEG stream for decoding.

0 commit comments

Comments
 (0)