Skip to content

Commit 8cc5230

Browse files
committed
Add imgcodec decoder
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
1 parent 3d014fb commit 8cc5230

File tree

11 files changed

+1238
-5
lines changed

11 files changed

+1238
-5
lines changed

dali/imgcodec/decoders/decoder_impl.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ class DLL_PUBLIC ImageDecoderImpl : public ImageDecoderInstance {
9898

9999
int SetParams(const std::map<std::string, any> &params) override {
100100
int ret = 0;
101-
for (auto &[key, value] : params)
101+
for (auto p : params) {
102+
auto key = p.first;
103+
auto value = p.second;
102104
ret += SetParam(key.c_str(), value);
105+
}
103106
return ret;
104107
}
105108

dali/imgcodec/decoders/nvjpeg/nvjpeg.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ void NvJpegDecoderInstance::DecodeJpegSample(ImageSource& in, uint8_t *out, Deco
206206
auto& decode_event = ctx.resources.decode_event;
207207
auto& device_buffer = ctx.resources.device_buffer;
208208

209+
CUDA_CALL(cudaEventSynchronize(decode_event));
209210
CUDA_CALL(nvjpegStateAttachPinnedBuffer(state, ctx.resources.pinned_buffer));
210211
CUDA_CALL(nvjpegJpegStreamParse(nvjpeg_handle_, in.RawData<unsigned char>(), in.Size(),
211212
false, false, ctx.resources.jpeg_stream));
@@ -217,7 +218,7 @@ void NvJpegDecoderInstance::DecodeJpegSample(ImageSource& in, uint8_t *out, Deco
217218
nvjpeg_image.channel[0] = out;
218219
nvjpeg_image.pitch[0] = ctx.shape[1] * ctx.shape[2];
219220

220-
CUDA_CALL(cudaEventSynchronize(decode_event));
221+
221222
CUDA_CALL(nvjpegStateAttachDeviceBuffer(state, device_buffer));
222223
CUDA_CALL(nvjpegDecodeJpegTransferToDevice(nvjpeg_handle_, decoder, state, jpeg_stream,
223224
stream));

dali/imgcodec/parsers/jpeg.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ImageInfo JpegParser::GetInfo(ImageSource *encoded) const {
7777
stream->Read(exif_block.data(), size - 8);
7878
cv::ExifReader reader;
7979
if (!reader.parseExif(exif_block.data(), exif_block.size()))
80-
DALI_FAIL(make_string("Couldn't parse EXIF data in: ", encoded->SourceInfo()));
80+
continue;
8181
auto entry = reader.getTag(cv::ORIENTATION);
8282
if (entry.tag != cv::INVALID_TAG) {
8383
info.orientation = FromExifOrientation(static_cast<ExifOrientation>(entry.field_u16));

dali/operators/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017-2018, 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# Copyright (c) 2017-2018, 2021-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22

33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ add_subdirectory(debug)
2121
add_subdirectory(decoder)
2222
add_subdirectory(generic)
2323
add_subdirectory(image)
24+
add_subdirectory(imgcodec)
2425
add_subdirectory(math)
2526
add_subdirectory(random)
2627
add_subdirectory(reader)
@@ -84,7 +85,7 @@ adjust_source_file_language_property("${DALI_OPERATOR_SRCS}")
8485
add_library(dali_operators ${LIBTYPE} ${DALI_OPERATOR_SRCS} ${DALI_OPERATOR_OBJ})
8586
set_target_properties(dali_operators PROPERTIES
8687
LIBRARY_OUTPUT_DIRECTORY "${DALI_LIBRARY_OUTPUT_DIR}")
87-
target_link_libraries(dali_operators PUBLIC dali dali_kernels dali_core)
88+
target_link_libraries(dali_operators PUBLIC dali dali_kernels dali_core dali_imgcodec)
8889
target_link_libraries(dali_operators PRIVATE dynlink_cuda ${DALI_LIBS})
8990
if (BUILD_NVML)
9091
target_link_libraries(dali_operators PRIVATE dynlink_nvml)
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
collect_headers(DALI_INST_HDRS PARENT_SCOPE)
16+
collect_sources(DALI_OPERATOR_SRCS PARENT_SCOPE)
17+
collect_test_sources(DALI_OPERATOR_TEST_SRCS PARENT_SCOPE)

0 commit comments

Comments
 (0)