-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathmain.cpp
More file actions
102 lines (90 loc) · 3.26 KB
/
main.cpp
File metadata and controls
102 lines (90 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define PYBIND11_DETAILED_ERROR_MESSAGES
#include <nvimgcodec.h>
#include <nvimgcodec_version.h>
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "backend.h"
#include "backend_kind.h"
#include "load_hint_policy.h"
#include "chroma_subsampling.h"
#include "code_stream.h"
#include "code_stream_view.h"
#include "color_spec.h"
#include "sample_format.h"
#include "decode_params.h"
#include "decoder.h"
#include "encode_params.h"
#include "encoder.h"
#include "image.h"
#include "image_buffer_kind.h"
#include "jpeg2k_bitstream_type.h"
#include "jpeg2k_encode_params.h"
#include "jpeg2k_prog_order.h"
#include "jpeg_encode_params.h"
#include "module.h"
#include "quality_type.h"
#include "region.h"
#include "metadata_format.h"
#include "metadata_kind.h"
#include "metadata_type.h"
#include "metadata.h"
#include <iostream>
namespace py = pybind11;
using namespace py::literals;
PYBIND11_MODULE(nvimgcodec_impl, m, py::mod_gil_not_used())
{
using namespace nvimgcodec;
static Module module;
m.doc() = R"pbdoc(
nvImageCodec Python API reference
This is the Python API reference for the NVIDIA® nvImageCodec library.
)pbdoc";
nvimgcodecProperties_t properties{NVIMGCODEC_STRUCTURE_TYPE_PROPERTIES, sizeof(nvimgcodecProperties_t), 0};
nvimgcodecGetProperties(&properties);
std::stringstream ver_ss{};
ver_ss << NVIMGCODEC_STREAM_VER(properties.version);
m.attr("__version__") = ver_ss.str();
m.attr("__cuda_version__") = properties.cudart_version;
BackendKind::exportToPython(m);
LoadHintPolicy::exportToPython(m);
Backend::exportToPython(m);
ColorSpec::exportToPython(m);
SampleFormat::exportToPython(m);
ChromaSubsampling::exportToPython(m);
ImageBufferKind::exportToPython(m);
Jpeg2kBitstreamType::exportToPython(m);
Jpeg2kProgOrder::exportToPython(m);
DecodeParams::exportToPython(m);
JpegEncodeParams::exportToPython(m);
Jpeg2kEncodeParams::exportToPython(m);
QualityType::exportToPython(m);
EncodeParams::exportToPython(m);
Region::exportToPython(m);
MetadataFormat::exportToPython(m);
MetadataKind::exportToPython(m);
MetadataType::exportToPython(m);
Metadata::exportToPython(m);
CodeStreamView::exportToPython(m);
CodeStream::exportToPython(m, module.instance_, module.logger_.get());
Image::exportToPython(m);
Decoder::exportToPython(m, module.instance_, module.logger_.get());
Encoder::exportToPython(m, module.instance_, module.logger_.get());
Module::exportToPython(m, module.instance_, module.logger_.get());
}