MCPcopy Create free account
hub / github.com/NVIDIA/DALI / ImageDecoder

Method ImageDecoder

dali/operators/imgcodec/image_decoder.h:210–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208
209
210 explicit ImageDecoder(const OpSpec &spec) : StatelessOperator<Backend>(spec) {
211 device_id_ = std::is_same<CPUBackend, Backend>::value ? CPU_ONLY_DEVICE_ID :
212 spec.GetArgument<int>("device_id");
213 format_ = spec.GetArgument<DALIImageType>("output_type");
214 dtype_ = spec.GetArgument<DALIDataType>("dtype");
215 use_orientation_ = spec.GetArgument<bool>("adjust_orientation");
216 max_batch_size_ = spec.GetArgument<int>("max_batch_size");
217 num_threads_ = spec.GetArgument<int>("num_threads");
218 GetDecoderSpecificArguments(spec);
219
220 if (std::is_same<MixedBackend, Backend>::value) {
221 thread_pool_ = std::make_unique<OldThreadPool>(num_threads_, device_id_,
222 spec.GetArgument<bool>("affine"), "MixedDecoder");
223 if (spec_.HasArgument("cache_size"))
224 cache_ = std::make_unique<CachedDecoderImpl>(spec_);
225 }
226 EnforceMinimumNvimgcodecVersion();
227
228 // WAR for the nvImageCodec ROI/orientation contract bug: on affected versions, the decoder
229 // validates the ROI against raw codestream dims while interpreting it in output (post-EXIF)
230 // coords, breaking 90/270-rotated samples that carry a ROI. Disable orientation in the
231 // decoder and apply it in the post-decode Convert; ROIs are translated to raw coords.
232 roi_orient_war_ = use_orientation_ && !version_at_least(0, 9, 0);
233
234 nvimgcodecDeviceAllocator_t *dev_alloc_ptr = nullptr;
235 nvimgcodecPinnedAllocator_t *pinned_alloc_ptr = nullptr;
236 if (device_id_ >= 0) {
237 dev_alloc_.struct_type = NVIMGCODEC_STRUCTURE_TYPE_DEVICE_ALLOCATOR;
238 dev_alloc_.struct_size = sizeof(nvimgcodecDeviceAllocator_t);
239 dev_alloc_.struct_next = nullptr;
240 dev_alloc_.device_malloc = static_dali_device_malloc;
241 dev_alloc_.device_free = static_dali_device_free;
242 dev_alloc_.device_ctx = mm::GetDefaultResource<mm::memory_kind::device>();
243 dev_alloc_.device_mem_padding = decoder_params_.count("device_memory_padding") == 0 ?
244 0 :
245 spec.GetArgument<int64_t>("device_memory_padding");
246 dev_alloc_ptr = &dev_alloc_;
247
248 pinned_alloc_.struct_type = NVIMGCODEC_STRUCTURE_TYPE_PINNED_ALLOCATOR;
249 pinned_alloc_.struct_size = sizeof(nvimgcodecPinnedAllocator_t);
250 pinned_alloc_.struct_next = nullptr;
251 pinned_alloc_.pinned_malloc = static_dali_pinned_malloc;
252 pinned_alloc_.pinned_free = static_dali_pinned_free;
253 pinned_alloc_.pinned_ctx = mm::GetDefaultResource<mm::memory_kind::pinned>();
254 pinned_alloc_.pinned_mem_padding = decoder_params_.count("host_memory_padding") == 0 ?
255 0 :
256 spec.GetArgument<int64_t>("host_memory_padding");
257 pinned_alloc_ptr = &pinned_alloc_;
258 }
259
260 nvimgcodecInstanceCreateInfo_t instance_create_info{
261 NVIMGCODEC_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, sizeof(nvimgcodecInstanceCreateInfo_t),
262 nullptr};
263
264 const char *log_lvl_env = std::getenv("DALI_NVIMGCODEC_LOG_LEVEL");
265 int log_lvl = log_lvl_env ? clamp(atoi(log_lvl_env), 1, 5) : 2;
266
267 instance_create_info.load_extension_modules = static_cast<int>(WITH_DYNAMIC_NVIMGCODEC_ENABLED);

Callers

nothing calls this directly

Calls 15

verbosity_to_severityFunction · 0.85
CreateFunction · 0.85
HasArgumentMethod · 0.80
emplace_backMethod · 0.80
add_module_optionMethod · 0.80
clampFunction · 0.50
funcFunction · 0.50
maxFunction · 0.50
push_backMethod · 0.45
backMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected