qtsq 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qtsq-1.0.0/LICENSE +128 -0
- qtsq-1.0.0/MANIFEST.in +7 -0
- qtsq-1.0.0/PKG-INFO +16 -0
- qtsq-1.0.0/include/qtsq.h +261 -0
- qtsq-1.0.0/include/qtsq_format.h +263 -0
- qtsq-1.0.0/include/qtsq_metal.h +150 -0
- qtsq-1.0.0/include/qtsq_splat2d.h +110 -0
- qtsq-1.0.0/include/qtsq_splat_only.h +85 -0
- qtsq-1.0.0/include/qtsq_triangle_only.h +47 -0
- qtsq-1.0.0/include/qtsq_turbo.h +178 -0
- qtsq-1.0.0/include/qtsq_types.h +19 -0
- qtsq-1.0.0/include/stb_image.h +7988 -0
- qtsq-1.0.0/include/stb_image_write.h +1724 -0
- qtsq-1.0.0/pyproject.toml +27 -0
- qtsq-1.0.0/qtsq/README.md +38 -0
- qtsq-1.0.0/qtsq/__init__.py +373 -0
- qtsq-1.0.0/qtsq/_metal_stubs.c +105 -0
- qtsq-1.0.0/qtsq/_native.c +400 -0
- qtsq-1.0.0/qtsq.egg-info/PKG-INFO +16 -0
- qtsq-1.0.0/qtsq.egg-info/SOURCES.txt +52 -0
- qtsq-1.0.0/qtsq.egg-info/dependency_links.txt +1 -0
- qtsq-1.0.0/qtsq.egg-info/requires.txt +9 -0
- qtsq-1.0.0/qtsq.egg-info/top_level.txt +1 -0
- qtsq-1.0.0/setup.cfg +4 -0
- qtsq-1.0.0/setup.py +45 -0
- qtsq-1.0.0/src/qtsq_accretion.c +1860 -0
- qtsq-1.0.0/src/qtsq_audio_decode.c +198 -0
- qtsq-1.0.0/src/qtsq_audio_encode.c +360 -0
- qtsq-1.0.0/src/qtsq_censorship.c +385 -0
- qtsq-1.0.0/src/qtsq_chandrasekhar.c +40 -0
- qtsq-1.0.0/src/qtsq_container.c +507 -0
- qtsq-1.0.0/src/qtsq_format.c +203 -0
- qtsq-1.0.0/src/qtsq_gravitational.c +3321 -0
- qtsq-1.0.0/src/qtsq_horizon.c +706 -0
- qtsq-1.0.0/src/qtsq_lensing.c +842 -0
- qtsq-1.0.0/src/qtsq_metal.mm +797 -0
- qtsq-1.0.0/src/qtsq_mf_merge.c +244 -0
- qtsq-1.0.0/src/qtsq_multi_frame.h +41 -0
- qtsq-1.0.0/src/qtsq_paradox.c +240 -0
- qtsq-1.0.0/src/qtsq_parallel.h +45 -0
- qtsq-1.0.0/src/qtsq_radiation.c +297 -0
- qtsq-1.0.0/src/qtsq_redshift.c +161 -0
- qtsq-1.0.0/src/qtsq_singularity.c +335 -0
- qtsq-1.0.0/src/qtsq_splat2d.c +906 -0
- qtsq-1.0.0/src/qtsq_splat_only.c +1112 -0
- qtsq-1.0.0/src/qtsq_triangle.c +525 -0
- qtsq-1.0.0/src/qtsq_triangle_only.c +536 -0
- qtsq-1.0.0/src/qtsq_turbo.c +946 -0
- qtsq-1.0.0/src/qtsq_types.c +168 -0
- qtsq-1.0.0/src/qtsq_utils.c +215 -0
- qtsq-1.0.0/src/qtsq_video_decode.c +698 -0
- qtsq-1.0.0/src/qtsq_video_encode.c +882 -0
- qtsq-1.0.0/src/qtsq_waves.c +255 -0
- qtsq-1.0.0/src/qtsq_wormhole.c +185 -0
qtsq-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Quantum Tensor Sequence Proprietary License (QTSPL) v1.0
|
|
2
|
+
|
|
3
|
+
**Copyright (c) 2026 Haruhito. All Rights Reserved.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Definitions
|
|
8
|
+
|
|
9
|
+
- **"Software"** refers to the Quantum Tensor Sequence (.qtsq) file format specification, all associated source code, libraries, tools, documentation, algorithms, and data structures contained in this repository.
|
|
10
|
+
- **"Author"** refers to Haruhito, the sole copyright holder.
|
|
11
|
+
- **"Format"** refers to the .qtsq (Quantum Tensor Sequence) and .qtsw (Event Wave) binary file formats.
|
|
12
|
+
- **"Marks"** refers to the names "Quantum Tensor Sequence", ".qtsq", ".qtsw", "Spaghettification Engine", "Cosmic Censorship", "Hawking Radiation", "Gravitational Waves", and all associated branding, logos, and terminology.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 2. Grant of Rights
|
|
17
|
+
|
|
18
|
+
You are granted a limited, non-exclusive, non-transferable, revocable license to use the Software strictly for **free non-commercial personal, educational (school), and academic research purposes**, subject to the conditions set forth in this license.
|
|
19
|
+
|
|
20
|
+
All other rights, including commercial use, distribution, and modification, are strictly reserved by the Author.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 3. Restrictions
|
|
25
|
+
|
|
26
|
+
Except for the permitted uses expressly granted in Section 2, you may **NOT**, without prior written authorization from the Author:
|
|
27
|
+
|
|
28
|
+
### 3.1 Commercial and Unauthorized Use
|
|
29
|
+
- Use the Software, in whole or in part, for any commercial, corporate, or for-profit purpose.
|
|
30
|
+
- Incorporate any portion of the Software into any commercial software, product, or service.
|
|
31
|
+
- Use the Format to read, write, create, or process .qtsq or .qtsw files for any commercial purpose.
|
|
32
|
+
|
|
33
|
+
### 3.2 Modify
|
|
34
|
+
- Modify, adapt, translate, reverse engineer, decompile, disassemble, or create derivative works based on the Software.
|
|
35
|
+
- Alter the Format specification in any way.
|
|
36
|
+
|
|
37
|
+
### 3.3 Distribute
|
|
38
|
+
- Copy, distribute, publish, sublicense, sell, lease, rent, or otherwise transfer the Software or any portion thereof.
|
|
39
|
+
- Share, upload, or make the Software available through any medium, including but not limited to code repositories, file sharing services, or electronic communication.
|
|
40
|
+
|
|
41
|
+
### 3.4 Compete
|
|
42
|
+
- Develop, produce, market, or distribute any software, tool, library, or service that reads, writes, processes, or is compatible with the .qtsq or .qtsw file formats.
|
|
43
|
+
- Create any file format, specification, or standard that is substantially similar to or derived from the Format.
|
|
44
|
+
|
|
45
|
+
### 3.5 Brand
|
|
46
|
+
- Use any of the Marks in any product name, service name, domain name, social media account, marketing material, or any other context.
|
|
47
|
+
- Register any trademark, domain name, or intellectual property that contains or is confusingly similar to any of the Marks.
|
|
48
|
+
- Imply any endorsement, affiliation, or association with the Author without written consent.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 4. Attribution and Credits
|
|
53
|
+
|
|
54
|
+
For the permitted free uses defined in Section 2, the following attribution rules apply:
|
|
55
|
+
|
|
56
|
+
- **Academic & Research Use:** If the Software or Format is used in any published academic, scientific, or institutional research, you **MUST** provide appropriate credit and citation to the Author (Haruhito) and the Quantum Tensor Sequence project.
|
|
57
|
+
- **Personal & Educational (School) Use:** Adding credits is **optional but highly appreciated**. If you use this for a school project or personal hobby, mentioning the Quantum Tensor Sequence project is a great way to show support.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 5. Research Paper
|
|
62
|
+
|
|
63
|
+
The research paper titled "Quantum Tensor Sequence: A Universal Data Compression Format with Physics-Inspired Architecture, Zero-Knowledge Verification, and Self-Healing Recovery" is published for informational and academic reference purposes only. Publication of the paper does **not** constitute a grant of any license, right, or permission to use, implement, or reproduce the Software, Format, or any techniques described therein.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 6. Licensing Inquiries
|
|
68
|
+
|
|
69
|
+
To obtain a license for commercial use or any use outside the scope of Section 2, contact the Author directly. Licensing terms, fees, and conditions are determined solely at the Author's discretion.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 7. Intellectual Property
|
|
74
|
+
|
|
75
|
+
The Software, Format, Marks, and all associated intellectual property are the exclusive property of the Author. This includes but is not limited to:
|
|
76
|
+
|
|
77
|
+
- The .qtsq and .qtsw binary file format specifications
|
|
78
|
+
- The five-layer gravitational compression architecture
|
|
79
|
+
- The Spaghettification Engine (automatic data type detection and strategy selection)
|
|
80
|
+
- The Cosmic Censorship dual-layer security system (AES-256-GCM + Schnorr ZKP)
|
|
81
|
+
- The Wormhole inter-file linking system
|
|
82
|
+
- The Gravitational Wave differential update system
|
|
83
|
+
- The Redshift/Blueshift multi-resolution quality scaling system
|
|
84
|
+
- The Chandrasekhar Limit adaptive threshold system
|
|
85
|
+
- The Information Paradox error correction and recovery system
|
|
86
|
+
- All source code, documentation, and related materials
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 8. No Warranty
|
|
91
|
+
|
|
92
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 9. Limitation of Liability
|
|
97
|
+
|
|
98
|
+
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 10. Termination
|
|
103
|
+
|
|
104
|
+
Any unauthorized use of the Software, Format, or Marks automatically terminates the permissions granted herein and may result in legal action. The Author reserves the right to pursue all available legal remedies for any violation of this license.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 11. Governing Law
|
|
109
|
+
|
|
110
|
+
This license shall be governed by and construed in accordance with the laws of India. Any disputes arising under this license shall be subject to the exclusive jurisdiction of the courts in India.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 12. Severability
|
|
115
|
+
|
|
116
|
+
If any provision of this license is held to be unenforceable or invalid, that provision shall be modified to the minimum extent necessary to make it enforceable, and all remaining provisions shall continue in full force and effect.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 13. Entire Agreement
|
|
121
|
+
|
|
122
|
+
This license constitutes the entire agreement between the parties regarding the Software and supersedes all prior agreements, understandings, and communications, whether written or oral.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
**Quantum Tensor Sequence Proprietary License (QTSPL) v1.0**
|
|
127
|
+
**Effective Date: March 2026**
|
|
128
|
+
**Copyright (c) 2026 Haruhito. All Rights Reserved.**
|
qtsq-1.0.0/MANIFEST.in
ADDED
qtsq-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qtsq
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Read and extract data from .qtsq (Quantum Tensor Sequence) image files
|
|
5
|
+
Author: haruhito
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: numpy>=1.20.0
|
|
10
|
+
Requires-Dist: scipy>=1.7.0
|
|
11
|
+
Provides-Extra: ml
|
|
12
|
+
Requires-Dist: torch>=2.0.0; extra == "ml"
|
|
13
|
+
Requires-Dist: torch-geometric>=2.4.0; extra == "ml"
|
|
14
|
+
Provides-Extra: images
|
|
15
|
+
Requires-Dist: Pillow>=9.0.0; extra == "images"
|
|
16
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Quantum Tensor Sequence — Universal Public API
|
|
3
|
+
* File Extension: .qtsq (Quantum Tensor Sequence)
|
|
4
|
+
* Author: Haruhito
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef QTSQ_H
|
|
8
|
+
#define QTSQ_H
|
|
9
|
+
|
|
10
|
+
#include "qtsq_format.h"
|
|
11
|
+
#include "qtsq_types.h"
|
|
12
|
+
#include "qtsq_turbo.h"
|
|
13
|
+
#include "qtsq_triangle_only.h"
|
|
14
|
+
|
|
15
|
+
int qtsq_init(qtsq_context_t *ctx);
|
|
16
|
+
void qtsq_free(qtsq_context_t *ctx);
|
|
17
|
+
|
|
18
|
+
int qtsq_compress(qtsq_context_t *ctx,
|
|
19
|
+
const uint8_t *data, size_t size,
|
|
20
|
+
qtsq_data_type_t type_hint);
|
|
21
|
+
|
|
22
|
+
int qtsq_compress_image(qtsq_context_t *ctx,
|
|
23
|
+
const uint8_t *pixels,
|
|
24
|
+
uint32_t width, uint32_t height,
|
|
25
|
+
uint8_t channels);
|
|
26
|
+
|
|
27
|
+
int qtsq_compress_gravitational(qtsq_context_t *ctx,
|
|
28
|
+
const uint8_t *pixels,
|
|
29
|
+
uint32_t width, uint32_t height,
|
|
30
|
+
uint8_t channels,
|
|
31
|
+
size_t source_size);
|
|
32
|
+
|
|
33
|
+
int qtsq_compress_gravitational_hd(qtsq_context_t *ctx,
|
|
34
|
+
const uint8_t *pixels,
|
|
35
|
+
uint32_t width, uint32_t height,
|
|
36
|
+
uint8_t channels,
|
|
37
|
+
size_t source_size);
|
|
38
|
+
|
|
39
|
+
/* Mathematical upscaler for lossy inputs (JPEG/WebP).
|
|
40
|
+
* Uses dense triangle mesh + splats to reconstruct clean edges
|
|
41
|
+
* from compression artifacts. Output is LARGER but HIGHER QUALITY. */
|
|
42
|
+
int qtsq_compress_gravitational_upscale(qtsq_context_t *ctx,
|
|
43
|
+
const uint8_t *pixels,
|
|
44
|
+
uint32_t width, uint32_t height,
|
|
45
|
+
uint8_t channels,
|
|
46
|
+
size_t source_size);
|
|
47
|
+
|
|
48
|
+
/* Lossless HD mode — maximum fidelity with 6M vertices.
|
|
49
|
+
* Output caps: <5MB input → ≤10MB output, ≥5MB input → ≤30MB output. */
|
|
50
|
+
int qtsq_compress_gravitational_lossless(qtsq_context_t *ctx,
|
|
51
|
+
const uint8_t *pixels,
|
|
52
|
+
uint32_t width, uint32_t height,
|
|
53
|
+
uint8_t channels,
|
|
54
|
+
size_t source_size);
|
|
55
|
+
|
|
56
|
+
/* Pure 2D Gaussian Splat compression (no triangle mesh). */
|
|
57
|
+
int qtsq_compress_splat_compact(qtsq_context_t *ctx,
|
|
58
|
+
const uint8_t *pixels,
|
|
59
|
+
uint32_t width, uint32_t height,
|
|
60
|
+
uint8_t channels, size_t source_size);
|
|
61
|
+
int qtsq_compress_splat_hd(qtsq_context_t *ctx,
|
|
62
|
+
const uint8_t *pixels,
|
|
63
|
+
uint32_t width, uint32_t height,
|
|
64
|
+
uint8_t channels, size_t source_size);
|
|
65
|
+
int qtsq_compress_splat_lossless(qtsq_context_t *ctx,
|
|
66
|
+
const uint8_t *pixels,
|
|
67
|
+
uint32_t width, uint32_t height,
|
|
68
|
+
uint8_t channels, size_t source_size);
|
|
69
|
+
int qtsq_decompress_splat_only(qtsq_context_t *ctx,
|
|
70
|
+
uint8_t **out_data, size_t *out_size);
|
|
71
|
+
|
|
72
|
+
int qtsq_decompress_gravitational(qtsq_context_t *ctx,
|
|
73
|
+
uint8_t **out_data, size_t *out_size);
|
|
74
|
+
|
|
75
|
+
int qtsq_optimize_mesh(qtsq_context_t *ctx, const uint8_t *rgb_target,
|
|
76
|
+
uint32_t width, uint32_t height);
|
|
77
|
+
|
|
78
|
+
/* ══════════════════════════════════════════════════════════════
|
|
79
|
+
* Gravitational AI Direct Render API
|
|
80
|
+
* Bypasses redundant Delaunay triangulation during optimizations
|
|
81
|
+
* ══════════════════════════════════════════════════════════════ */
|
|
82
|
+
typedef struct {
|
|
83
|
+
float x, y;
|
|
84
|
+
uint8_t r, g, b;
|
|
85
|
+
} tri_vertex_t;
|
|
86
|
+
|
|
87
|
+
typedef struct {
|
|
88
|
+
uint32_t v0, v1, v2;
|
|
89
|
+
} tri_face_t;
|
|
90
|
+
|
|
91
|
+
int qtsq_render_mesh(const tri_vertex_t *verts, uint32_t nv,
|
|
92
|
+
const tri_face_t *faces, uint32_t nf,
|
|
93
|
+
uint32_t orig_w, uint32_t orig_h, uint8_t ch,
|
|
94
|
+
uint8_t *output);
|
|
95
|
+
|
|
96
|
+
/* AI Hooks for MeshNet V3 */
|
|
97
|
+
int qtsq_extract_vertices(const qtsq_context_t *ctx, float *flat_verts, uint32_t max_verts);
|
|
98
|
+
int qtsq_apply_vertices(qtsq_context_t *ctx, const float *new_verts, uint32_t num_verts);
|
|
99
|
+
|
|
100
|
+
/* Mesh Editor: Splat extract/apply — works with splat2d_t arrays directly */
|
|
101
|
+
int qtsq_extract_splats(const qtsq_context_t *ctx, void *out_splats, uint32_t max_splats,
|
|
102
|
+
uint32_t *out_width, uint32_t *out_height);
|
|
103
|
+
int qtsq_apply_splats(qtsq_context_t *ctx, const void *splats, uint32_t count,
|
|
104
|
+
uint32_t width, uint32_t height);
|
|
105
|
+
|
|
106
|
+
int qtsq_compress_gravitational_audio(qtsq_context_t *ctx,
|
|
107
|
+
const int16_t *pcm,
|
|
108
|
+
uint32_t total_samples,
|
|
109
|
+
uint8_t channels,
|
|
110
|
+
uint32_t sample_rate);
|
|
111
|
+
|
|
112
|
+
int qtsq_decompress_gravitational_audio(const qtsq_context_t *ctx,
|
|
113
|
+
uint8_t **out_data, size_t *out_size);
|
|
114
|
+
|
|
115
|
+
int qtsq_compress_audio(qtsq_context_t *ctx,
|
|
116
|
+
const int16_t *samples,
|
|
117
|
+
size_t num_samples,
|
|
118
|
+
uint32_t sample_rate,
|
|
119
|
+
uint8_t channels);
|
|
120
|
+
|
|
121
|
+
/* Photon Audio — HQ Spatial Gabor atom codec */
|
|
122
|
+
int qtsq_compress_audio_hq(qtsq_context_t *ctx,
|
|
123
|
+
const float *samples, /* 32-bit float */
|
|
124
|
+
size_t num_samples,
|
|
125
|
+
uint32_t sample_rate,
|
|
126
|
+
uint8_t channels);
|
|
127
|
+
|
|
128
|
+
int qtsq_decompress_audio_hq(const qtsq_context_t *ctx,
|
|
129
|
+
float **out_pcm, /* outputs 32-bit float interleaved */
|
|
130
|
+
size_t *out_total_samples,
|
|
131
|
+
photon_atom_t **out_atoms, /* outputs spatial atoms array */
|
|
132
|
+
size_t *out_atom_count);
|
|
133
|
+
|
|
134
|
+
int qtsq_compress_text(qtsq_context_t *ctx,
|
|
135
|
+
const char *text, size_t length);
|
|
136
|
+
|
|
137
|
+
int qtsq_compress_csv(qtsq_context_t *ctx,
|
|
138
|
+
const char *csv_data, size_t length);
|
|
139
|
+
|
|
140
|
+
int qtsq_compress_json(qtsq_context_t *ctx,
|
|
141
|
+
const char *json, size_t length);
|
|
142
|
+
|
|
143
|
+
int qtsq_compress_signal(qtsq_context_t *ctx,
|
|
144
|
+
const double *signal, size_t num_samples);
|
|
145
|
+
|
|
146
|
+
typedef struct qtsq_video_encoder qtsq_video_encoder_t;
|
|
147
|
+
|
|
148
|
+
/* Initialize a video encoder session */
|
|
149
|
+
qtsq_video_encoder_t* qtsq_video_encoder_create(qtsq_context_t *ctx,
|
|
150
|
+
uint32_t width, uint32_t height,
|
|
151
|
+
uint8_t channels, uint32_t fps,
|
|
152
|
+
int strategy_flags,
|
|
153
|
+
size_t target_payload_per_frame);
|
|
154
|
+
|
|
155
|
+
/* Append a single uncompressed frame to the video sequence. */
|
|
156
|
+
int qtsq_video_encoder_add_frame(qtsq_video_encoder_t *enc, const uint8_t *pixels);
|
|
157
|
+
|
|
158
|
+
/* Finish encoding and flush all buffers to context. */
|
|
159
|
+
int qtsq_video_encoder_finish(qtsq_video_encoder_t *enc);
|
|
160
|
+
|
|
161
|
+
/* Get the underlying context */
|
|
162
|
+
qtsq_context_t* qtsq_video_encoder_get_context(qtsq_video_encoder_t *enc);
|
|
163
|
+
|
|
164
|
+
/* Cleanup encoder resources */
|
|
165
|
+
void qtsq_video_encoder_free(qtsq_video_encoder_t *enc);
|
|
166
|
+
|
|
167
|
+
typedef struct qtsq_video_decoder qtsq_video_decoder_t;
|
|
168
|
+
|
|
169
|
+
/* Open a video for decoding */
|
|
170
|
+
qtsq_video_decoder_t* qtsq_video_decoder_open(const qtsq_context_t *ctx);
|
|
171
|
+
|
|
172
|
+
/* Decode a specific frame. Returns malloc'd RGB buffer. */
|
|
173
|
+
int qtsq_video_decoder_get_frame(qtsq_video_decoder_t *dec, uint32_t frame_index, uint8_t **out_pixels, uint32_t *width, uint32_t *height);
|
|
174
|
+
|
|
175
|
+
/* Get total number of frames */
|
|
176
|
+
uint32_t qtsq_video_decoder_get_frame_count(qtsq_video_decoder_t *dec);
|
|
177
|
+
|
|
178
|
+
/* Get the underlying context */
|
|
179
|
+
const qtsq_context_t* qtsq_video_decoder_get_context(qtsq_video_decoder_t *dec);
|
|
180
|
+
|
|
181
|
+
/* Cleanup decoder resources */
|
|
182
|
+
void qtsq_video_decoder_free(qtsq_video_decoder_t *dec);
|
|
183
|
+
|
|
184
|
+
int qtsq_compress_raw(qtsq_context_t *ctx,
|
|
185
|
+
const uint8_t *data, size_t size, uint64_t seed);
|
|
186
|
+
|
|
187
|
+
int qtsq_write(const qtsq_context_t *ctx, const char *filename);
|
|
188
|
+
int qtsq_read(qtsq_context_t *ctx, const char *filename);
|
|
189
|
+
|
|
190
|
+
int qtsq_decompress(qtsq_context_t *ctx,
|
|
191
|
+
uint8_t **out_data, size_t *out_size);
|
|
192
|
+
|
|
193
|
+
int qtsq_decompress_redshift(const qtsq_context_t *ctx,
|
|
194
|
+
double redshift,
|
|
195
|
+
uint8_t **out_data, size_t *out_size);
|
|
196
|
+
|
|
197
|
+
int qtsq_radiate(const qtsq_context_t *ctx,
|
|
198
|
+
uint64_t offset, uint32_t size,
|
|
199
|
+
uint8_t **out_data);
|
|
200
|
+
int qtsq_radiate_time(const qtsq_context_t *ctx,
|
|
201
|
+
double start_sec, double duration_sec,
|
|
202
|
+
int16_t **out_samples, size_t *out_count);
|
|
203
|
+
int qtsq_radiate_region(const qtsq_context_t *ctx,
|
|
204
|
+
uint32_t x, uint32_t y, uint32_t w, uint32_t h,
|
|
205
|
+
uint8_t **out_pixels);
|
|
206
|
+
int qtsq_radiate_frame(const qtsq_context_t *ctx,
|
|
207
|
+
uint32_t frame_index, uint8_t **out_pixels);
|
|
208
|
+
|
|
209
|
+
int qtsq_add_wormhole(qtsq_context_t *ctx,
|
|
210
|
+
const char *target_path,
|
|
211
|
+
uint32_t target_offset, uint32_t target_size);
|
|
212
|
+
int qtsq_resolve_wormholes(qtsq_context_t *ctx);
|
|
213
|
+
|
|
214
|
+
int qtsq_encrypt(qtsq_context_t *ctx, const char *password);
|
|
215
|
+
int qtsq_decrypt(qtsq_context_t *ctx, const char *password);
|
|
216
|
+
int qtsq_is_encrypted(const qtsq_context_t *ctx);
|
|
217
|
+
|
|
218
|
+
int qtsq_emit_wave(const qtsq_context_t *old_ctx,
|
|
219
|
+
const qtsq_context_t *new_ctx,
|
|
220
|
+
const char *wave_filename);
|
|
221
|
+
int qtsq_apply_wave(qtsq_context_t *ctx,
|
|
222
|
+
const char *wave_filename);
|
|
223
|
+
|
|
224
|
+
int qtsq_add_recovery(qtsq_context_t *ctx);
|
|
225
|
+
int qtsq_health_check(const qtsq_context_t *ctx);
|
|
226
|
+
int qtsq_recover(qtsq_context_t *ctx);
|
|
227
|
+
|
|
228
|
+
void qtsq_print_info(const qtsq_context_t *ctx);
|
|
229
|
+
double qtsq_compression_ratio(const qtsq_context_t *ctx);
|
|
230
|
+
const char* qtsq_error_string(int error_code);
|
|
231
|
+
|
|
232
|
+
/* ══════ Utility ══════ */
|
|
233
|
+
void qtsq_sha256(const uint8_t *data, size_t size, uint8_t *hash);
|
|
234
|
+
double qtsq_entropy(const uint8_t *data, size_t size);
|
|
235
|
+
uint32_t qtsq_crc32(const uint8_t *data, size_t size);
|
|
236
|
+
|
|
237
|
+
/* ══════ Engine-specific decompression ══════ */
|
|
238
|
+
int qtsq_decompress_singularity(const qtsq_context_t *ctx,
|
|
239
|
+
uint8_t **out_data, size_t *out_size);
|
|
240
|
+
int qtsq_decompress_horizon(const qtsq_context_t *ctx,
|
|
241
|
+
uint8_t **out_data, size_t *out_size);
|
|
242
|
+
int qtsq_decompress_lensing(const qtsq_context_t *ctx,
|
|
243
|
+
uint8_t **out_data, size_t *out_size);
|
|
244
|
+
int qtsq_decompress_accretion(const qtsq_context_t *ctx,
|
|
245
|
+
uint8_t **out_data, size_t *out_size);
|
|
246
|
+
|
|
247
|
+
/* ══════ Container (Multi-Data) ══════ */
|
|
248
|
+
int qtsq_container_create(qtsq_context_t *ctx);
|
|
249
|
+
int qtsq_container_add_file(qtsq_context_t *ctx, const char *path,
|
|
250
|
+
const char *stream_name);
|
|
251
|
+
int qtsq_container_add_stream(qtsq_context_t *ctx,
|
|
252
|
+
const qtsq_context_t *sub_ctx,
|
|
253
|
+
const char *stream_name);
|
|
254
|
+
int qtsq_container_add_folder(qtsq_context_t *ctx, const char *folder_path);
|
|
255
|
+
int qtsq_container_pack(qtsq_context_t *ctx);
|
|
256
|
+
int qtsq_container_get_count(const qtsq_context_t *ctx, uint32_t *out_count);
|
|
257
|
+
int qtsq_container_get_stream(const qtsq_context_t *ctx, uint32_t index,
|
|
258
|
+
qtsq_context_t *out_ctx,
|
|
259
|
+
char *name_buf, size_t name_buf_size);
|
|
260
|
+
|
|
261
|
+
#endif /* QTSQ_H */
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Quantum Tensor Sequence — File Format Structures & Constants
|
|
3
|
+
* File Extension: .qtsq (Quantum Tensor Sequence)
|
|
4
|
+
*
|
|
5
|
+
* Author: Haruhito
|
|
6
|
+
* License: MIT
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef QTSQ_FORMAT_H
|
|
10
|
+
#define QTSQ_FORMAT_H
|
|
11
|
+
|
|
12
|
+
#include <stdint.h>
|
|
13
|
+
#include <stddef.h>
|
|
14
|
+
/* Magic bytes: "QTS\x01" */
|
|
15
|
+
#define QTSQ_MAGIC_0 'Q'
|
|
16
|
+
#define QTSQ_MAGIC_1 'T'
|
|
17
|
+
#define QTSQ_MAGIC_2 'S'
|
|
18
|
+
#define QTSQ_MAGIC_3 '\x01'
|
|
19
|
+
#define QTSQ_VERSION_1 1
|
|
20
|
+
#define QTSQ_VERSION_2 2
|
|
21
|
+
#define QTSQ_VERSION 2 /* current version */
|
|
22
|
+
|
|
23
|
+
/* gravitational wave diff (.qtsw): "QTW\x01" */
|
|
24
|
+
#define QTW_MAGIC_0 'Q'
|
|
25
|
+
#define QTW_MAGIC_1 'T'
|
|
26
|
+
#define QTW_MAGIC_2 'W'
|
|
27
|
+
#define QTW_MAGIC_3 '\x01'
|
|
28
|
+
|
|
29
|
+
/* Chandrasekhara limit*/
|
|
30
|
+
#define QTSQ_CHANDRASEKHAR_LIMIT 4096
|
|
31
|
+
|
|
32
|
+
/* Compression Strategy*/
|
|
33
|
+
typedef enum {
|
|
34
|
+
QTSQ_STRATEGY_NONE = 0x00,
|
|
35
|
+
QTSQ_STRATEGY_PROCEDURAL = 0x01,
|
|
36
|
+
QTSQ_STRATEGY_FRACTAL = 0x02,
|
|
37
|
+
QTSQ_STRATEGY_FOURIER = 0x03,
|
|
38
|
+
QTSQ_STRATEGY_DELTA_SEED = 0x04,
|
|
39
|
+
QTSQ_STRATEGY_DICTIONARY = 0x05,
|
|
40
|
+
QTSQ_STRATEGY_TEMPORAL = 0x06,
|
|
41
|
+
QTSQ_STRATEGY_TRIANGLE = 0x07,
|
|
42
|
+
QTSQ_STRATEGY_PHOTON = 0x08, /* HQ Gabor atom audio (Photon Audio) */
|
|
43
|
+
QTSQ_STRATEGY_SPLAT = 0x09, /* Pure 2D Gaussian Splat image (no triangles) */
|
|
44
|
+
QTSQ_STRATEGY_LAYERED = 0xFF,
|
|
45
|
+
} qtsq_strategy_t;
|
|
46
|
+
|
|
47
|
+
/* data type*/
|
|
48
|
+
typedef enum {
|
|
49
|
+
QTSQ_TYPE_RAW = 0x00,
|
|
50
|
+
QTSQ_TYPE_IMAGE_GRAY = 0x10,
|
|
51
|
+
QTSQ_TYPE_IMAGE_RGB = 0x11,
|
|
52
|
+
QTSQ_TYPE_IMAGE_RGBA = 0x12,
|
|
53
|
+
QTSQ_TYPE_AUDIO_MONO = 0x20,
|
|
54
|
+
QTSQ_TYPE_AUDIO_STEREO = 0x21,
|
|
55
|
+
QTSQ_TYPE_AUDIO_MULTI = 0x22,
|
|
56
|
+
QTSQ_TYPE_VIDEO_FRAMES = 0x30,
|
|
57
|
+
QTSQ_TYPE_TEXT_ASCII = 0x40,
|
|
58
|
+
QTSQ_TYPE_TEXT_UTF8 = 0x41,
|
|
59
|
+
QTSQ_TYPE_TABLE_INT = 0x50,
|
|
60
|
+
QTSQ_TYPE_TABLE_FLOAT = 0x51,
|
|
61
|
+
QTSQ_TYPE_JSON = 0x52,
|
|
62
|
+
QTSQ_TYPE_CSV = 0x53,
|
|
63
|
+
QTSQ_TYPE_SIGNAL_1D = 0x60,
|
|
64
|
+
QTSQ_TYPE_SIGNAL_2D = 0x61,
|
|
65
|
+
QTSQ_TYPE_CONTAINER = 0xF0,
|
|
66
|
+
} qtsq_data_type_t;
|
|
67
|
+
|
|
68
|
+
/* Flags */
|
|
69
|
+
#define QTSQ_FLAG_LAZY_DECOMP 0x0001
|
|
70
|
+
#define QTSQ_FLAG_LOSSY 0x0002
|
|
71
|
+
#define QTSQ_FLAG_CHECKSUMMED 0x0004
|
|
72
|
+
#define QTSQ_FLAG_SEEKABLE 0x0008
|
|
73
|
+
#define QTSQ_FLAG_ENCRYPTED 0x0010
|
|
74
|
+
#define QTSQ_FLAG_MULTI_STREAM 0x0020
|
|
75
|
+
#define QTSQ_FLAG_AUTO_DETECTED 0x0040
|
|
76
|
+
#define QTSQ_FLAG_HAS_WORMHOLES 0x0080
|
|
77
|
+
#define QTSQ_FLAG_HAS_ECC 0x0100
|
|
78
|
+
#define QTSQ_FLAG_REDSHIFTABLE 0x0200
|
|
79
|
+
#define QTSQ_FLAG_HD 0x0400 /* High-quality triangle mesh (QTSQ HD) */
|
|
80
|
+
#define QTSQ_FLAG_3D 0x0800 /* 3D Depth encoded (Parallax/Volumetric) */
|
|
81
|
+
#define QTSQ_FLAG_UPSCALE 0x1000 /* Upscale mathematical enhancement for lossy frames */
|
|
82
|
+
#define QTSQ_FLAG_SPATIAL 0x2000 /* Spatial audio via atoms or object positioning */
|
|
83
|
+
#define QTSQ_FLAG_ZLIB 0x4000 /* Singularity payload is ZLib-compressed */
|
|
84
|
+
#define QTSQ_FLAG_SPLAT_ONLY 0x8000 /* Pure 2D Gaussian Splat image (no triangles) */
|
|
85
|
+
|
|
86
|
+
/* error codes */
|
|
87
|
+
#define QTSQ_OK 0
|
|
88
|
+
#define QTSQ_ERR_NULL -1
|
|
89
|
+
#define QTSQ_ERR_ALLOC -2
|
|
90
|
+
#define QTSQ_ERR_IO -3
|
|
91
|
+
#define QTSQ_ERR_FORMAT -4
|
|
92
|
+
#define QTSQ_ERR_CHECKSUM -5
|
|
93
|
+
#define QTSQ_ERR_STRATEGY -6
|
|
94
|
+
#define QTSQ_ERR_TYPE -7
|
|
95
|
+
#define QTSQ_ERR_ENCRYPTED -8
|
|
96
|
+
#define QTSQ_ERR_DECRYPT -9
|
|
97
|
+
#define QTSQ_ERR_WORMHOLE -10
|
|
98
|
+
#define QTSQ_ERR_WORMHOLE_HASH -11
|
|
99
|
+
#define QTSQ_ERR_CORRUPT -12
|
|
100
|
+
#define QTSQ_ERR_RECOVERY_FAIL -13
|
|
101
|
+
#define QTSQ_ERR_TOO_SMALL -14
|
|
102
|
+
|
|
103
|
+
/* file header v2 — 96 bytes packed
|
|
104
|
+
* v1 was 80 bytes with uint32_t sizes (4 GB limit)
|
|
105
|
+
* v2 uses uint64_t sizes (18.4 EB limit) */
|
|
106
|
+
typedef struct {
|
|
107
|
+
uint8_t magic[4];
|
|
108
|
+
uint8_t version;
|
|
109
|
+
uint8_t strategy;
|
|
110
|
+
uint16_t flags;
|
|
111
|
+
uint8_t data_type;
|
|
112
|
+
uint8_t num_channels;
|
|
113
|
+
uint16_t sample_depth;
|
|
114
|
+
uint32_t reserved;
|
|
115
|
+
uint64_t original_size;
|
|
116
|
+
uint64_t timestamp;
|
|
117
|
+
uint8_t checksum[32];
|
|
118
|
+
uint64_t horizon_size; /* v2: was uint32_t */
|
|
119
|
+
uint64_t accretion_size; /* v2: was uint32_t */
|
|
120
|
+
uint64_t singularity_size; /* v2: was uint32_t */
|
|
121
|
+
uint64_t radiation_size; /* v2: was uint32_t */
|
|
122
|
+
} __attribute__((packed)) qtsq_header_t;
|
|
123
|
+
|
|
124
|
+
_Static_assert(sizeof(qtsq_header_t) == 96, "header must be 96 bytes");
|
|
125
|
+
|
|
126
|
+
/* v1 header for backward compatibility (reading old files) */
|
|
127
|
+
typedef struct {
|
|
128
|
+
uint8_t magic[4];
|
|
129
|
+
uint8_t version;
|
|
130
|
+
uint8_t strategy;
|
|
131
|
+
uint16_t flags;
|
|
132
|
+
uint8_t data_type;
|
|
133
|
+
uint8_t num_channels;
|
|
134
|
+
uint16_t sample_depth;
|
|
135
|
+
uint32_t reserved;
|
|
136
|
+
uint64_t original_size;
|
|
137
|
+
uint64_t timestamp;
|
|
138
|
+
uint8_t checksum[32];
|
|
139
|
+
uint32_t horizon_size;
|
|
140
|
+
uint32_t accretion_size;
|
|
141
|
+
uint32_t singularity_size;
|
|
142
|
+
uint32_t radiation_size;
|
|
143
|
+
} __attribute__((packed)) qtsq_header_v1_t;
|
|
144
|
+
|
|
145
|
+
_Static_assert(sizeof(qtsq_header_v1_t) == 80, "v1 header must be 80 bytes");
|
|
146
|
+
|
|
147
|
+
/* schema */
|
|
148
|
+
typedef struct {
|
|
149
|
+
char name[64];
|
|
150
|
+
uint8_t data_type;
|
|
151
|
+
uint32_t dimensions[8];
|
|
152
|
+
uint8_t num_dims;
|
|
153
|
+
uint32_t sample_rate;
|
|
154
|
+
uint32_t frame_rate;
|
|
155
|
+
char encoding[64];
|
|
156
|
+
} qtsq_schema_t;
|
|
157
|
+
|
|
158
|
+
/* transform */
|
|
159
|
+
typedef struct {
|
|
160
|
+
uint8_t type;
|
|
161
|
+
uint32_t param_size;
|
|
162
|
+
void *params;
|
|
163
|
+
} qtsq_transform_t;
|
|
164
|
+
|
|
165
|
+
/* Photon Audio Spatial Atom */
|
|
166
|
+
typedef struct {
|
|
167
|
+
float freq_hz;
|
|
168
|
+
float magnitude;
|
|
169
|
+
float phase;
|
|
170
|
+
float x; /* Spatial X (pan): -1 (left) to 1 (right) */
|
|
171
|
+
float y; /* Spatial Y (height): -1 (low) to 1 (high) */
|
|
172
|
+
float z; /* Spatial Z (depth): 0 (far) to 1 (near) */
|
|
173
|
+
float spread; /* Spatial Spread (width): 0 (point) to 1 (diffuse) */
|
|
174
|
+
uint32_t frame_index;
|
|
175
|
+
} photon_atom_t;
|
|
176
|
+
|
|
177
|
+
/* transform */
|
|
178
|
+
typedef struct {
|
|
179
|
+
uint64_t logical_offset;
|
|
180
|
+
uint32_t chunk_size;
|
|
181
|
+
uint32_t singularity_offset;
|
|
182
|
+
uint8_t priority;
|
|
183
|
+
} __attribute__((packed)) qtsq_index_t;
|
|
184
|
+
|
|
185
|
+
/* wormhole */
|
|
186
|
+
#define QTSQ_WORMHOLE_LOCAL 0x01
|
|
187
|
+
#define QTSQ_WORMHOLE_LAN 0x02
|
|
188
|
+
#define QTSQ_WORMHOLE_CLOUD 0x03
|
|
189
|
+
#define QTSQ_WORMHOLE_MARKER 0xEE
|
|
190
|
+
|
|
191
|
+
typedef struct {
|
|
192
|
+
uint8_t type;
|
|
193
|
+
uint8_t target_hash[32];
|
|
194
|
+
char target_path[256];
|
|
195
|
+
uint32_t target_offset;
|
|
196
|
+
uint32_t target_size;
|
|
197
|
+
} qtsq_wormhole_t;
|
|
198
|
+
|
|
199
|
+
/* censorship */
|
|
200
|
+
typedef struct {
|
|
201
|
+
uint8_t iv[16];
|
|
202
|
+
uint8_t salt[16];
|
|
203
|
+
uint8_t auth_tag[16];
|
|
204
|
+
uint32_t iterations;
|
|
205
|
+
} qtsq_censorship_t;
|
|
206
|
+
|
|
207
|
+
/* recovery */
|
|
208
|
+
typedef struct {
|
|
209
|
+
uint32_t num_chunks;
|
|
210
|
+
uint32_t *chunk_checksums;
|
|
211
|
+
uint8_t *reed_solomon_parity;
|
|
212
|
+
uint32_t parity_size;
|
|
213
|
+
} qtsq_recovery_t;
|
|
214
|
+
|
|
215
|
+
/* wave header (.qtsw) */
|
|
216
|
+
typedef struct {
|
|
217
|
+
uint8_t magic[4];
|
|
218
|
+
uint8_t source_hash[32];
|
|
219
|
+
uint8_t result_hash[32];
|
|
220
|
+
uint64_t timestamp;
|
|
221
|
+
uint32_t num_patches;
|
|
222
|
+
} __attribute__((packed)) qtsq_wave_header_t;
|
|
223
|
+
|
|
224
|
+
typedef struct {
|
|
225
|
+
uint32_t offset;
|
|
226
|
+
uint32_t old_size;
|
|
227
|
+
uint32_t new_size;
|
|
228
|
+
uint8_t *new_data;
|
|
229
|
+
} qtsq_patch_t;
|
|
230
|
+
|
|
231
|
+
/* main context */
|
|
232
|
+
typedef struct {
|
|
233
|
+
qtsq_header_t header;
|
|
234
|
+
qtsq_schema_t schema;
|
|
235
|
+
qtsq_transform_t *transforms;
|
|
236
|
+
uint32_t num_transforms;
|
|
237
|
+
uint8_t *singularity;
|
|
238
|
+
uint64_t singularity_size;
|
|
239
|
+
qtsq_index_t *radiation_index;
|
|
240
|
+
uint32_t num_radiation;
|
|
241
|
+
qtsq_wormhole_t *wormholes;
|
|
242
|
+
uint32_t num_wormholes;
|
|
243
|
+
qtsq_censorship_t censorship;
|
|
244
|
+
int is_encrypted;
|
|
245
|
+
qtsq_recovery_t recovery;
|
|
246
|
+
int has_recovery;
|
|
247
|
+
} qtsq_context_t;
|
|
248
|
+
|
|
249
|
+
/* ── Container (Multi-Stream) ── */
|
|
250
|
+
#define QTSQ_MAX_STREAMS 256
|
|
251
|
+
|
|
252
|
+
typedef struct {
|
|
253
|
+
uint8_t data_type; /* QTSQ_TYPE_* for this stream */
|
|
254
|
+
uint8_t strategy; /* QTSQ_STRATEGY_* used to compress */
|
|
255
|
+
uint16_t flags; /* per-stream flags (ZLIB, LOSSY, etc.) */
|
|
256
|
+
uint32_t data_offset; /* offset from start of stream data block */
|
|
257
|
+
uint32_t data_size; /* compressed size in bytes */
|
|
258
|
+
uint32_t original_size; /* original uncompressed size */
|
|
259
|
+
} __attribute__((packed)) qtsq_stream_entry_t;
|
|
260
|
+
|
|
261
|
+
_Static_assert(sizeof(qtsq_stream_entry_t) == 16, "stream entry must be 16 bytes");
|
|
262
|
+
|
|
263
|
+
#endif
|