@geastack/targets 0.1.86 → 0.1.88

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.
Files changed (86) hide show
  1. package/package.json +7 -7
  2. package/targets/esp32/app_project.cmake +18 -1
  3. package/targets/esp32/chip_bindings/audio/echo_cancellation.cpp +213 -0
  4. package/targets/esp32/chip_bindings/audio/echo_cancellation.h +12 -0
  5. package/targets/esp32/chip_bindings/audio/es8311.cpp +280 -41
  6. package/targets/esp32/chip_bindings/displays/rgb_panel.cpp +115 -12
  7. package/targets/esp32/chip_bindings/expanders/io_expander.h +2 -0
  8. package/targets/esp32/chip_bindings/expanders/tca9554.cpp +74 -0
  9. package/targets/esp32/chip_bindings/touch/ft3168.cpp +23 -1
  10. package/targets/esp32/chip_bindings/touch/ft3168_controller.h +1 -0
  11. package/targets/esp32/chip_bindings/touch/gt911.cpp +4 -3
  12. package/targets/esp32/components/gea_framework/CMakeLists.txt +8 -1
  13. package/targets/esp32/components/gea_juice/CMakeLists.txt +46 -0
  14. package/targets/esp32/components/gea_juice/README.md +20 -0
  15. package/targets/esp32/components/gea_juice/juice_memory.c +19 -0
  16. package/targets/esp32/components/gea_juice/juice_memory.h +16 -0
  17. package/targets/esp32/components/gea_juice/patch_threads.py +50 -0
  18. package/targets/esp32/components/gea_vp8_peer/CMakeLists.txt +16 -0
  19. package/targets/esp32/components/gea_vp8_peer/README.md +39 -0
  20. package/targets/esp32/components/gea_vp8_peer/gea_vp8_peer.h +21 -0
  21. package/targets/esp32/components/gea_vp8_peer/vp8_peer.cpp +538 -0
  22. package/targets/esp32/components/gea_vpx/CMakeLists.txt +235 -0
  23. package/targets/esp32/components/gea_vpx/README.md +133 -0
  24. package/targets/esp32/components/gea_vpx/i420_rgb565_s3.S +169 -0
  25. package/targets/esp32/components/gea_vpx/vp8_blocks_s3.c +42 -0
  26. package/targets/esp32/components/gea_vpx/vp8_copy_s3.S +39 -0
  27. package/targets/esp32/components/gea_vpx/vp8_entropy_s3.c +76 -0
  28. package/targets/esp32/components/gea_vpx/vp8_filter_s3.S +58 -0
  29. package/targets/esp32/components/gea_vpx/vp8_idct_s3.S +269 -0
  30. package/targets/esp32/components/gea_vpx/vp8_intrapred_s3.S +65 -0
  31. package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.S +333 -0
  32. package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.c +62 -0
  33. package/targets/esp32/components/gea_vpx/vp8_profile_s3.c +22 -0
  34. package/targets/esp32/components/gea_vpx/vp8_profile_s3.h +20 -0
  35. package/targets/esp32/components/gea_vpx/vp8_s3.c +120 -0
  36. package/targets/esp32/components/gea_vpx/vp8_s3.h +58 -0
  37. package/targets/esp32/components/gea_vpx/vp8_workspace_s3.c +14 -0
  38. package/targets/esp32/components/gea_vpx/vpx_memory.c +41 -0
  39. package/targets/esp32/connectivity/diagnostics_transport.cpp +18 -0
  40. package/targets/esp32/connectivity/wifi.cpp +26 -13
  41. package/targets/esp32/crypto/srtp_hmac_psa.c +118 -0
  42. package/targets/esp32/display.cpp +13 -0
  43. package/targets/esp32/gea_framework.cmake +7 -0
  44. package/targets/esp32/host_sources.cmake +2 -0
  45. package/targets/esp32/i2c_completion_order.cmake +57 -0
  46. package/targets/esp32/patch_streaming_dependencies.py +233 -0
  47. package/targets/esp32/services/device_control.cpp +141 -5
  48. package/targets/esp32/services/frame_scheduler.cpp +29 -1
  49. package/targets/esp32/services/opus_benchmark.h +82 -0
  50. package/targets/esp32/services/pcm_simd_check.h +73 -0
  51. package/targets/esp32/services/srtp_benchmark.h +106 -0
  52. package/targets/esp32/services/video_simd_benchmark.h +477 -0
  53. package/targets/esp32/services/vp8_benchmark.h +147 -0
  54. package/targets/esp32/streaming_dependency_patches.cmake +103 -0
  55. package/targets/esp32-m5stack-m5paper/main/idf_component.yml +2 -0
  56. package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +2 -0
  57. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +2 -0
  58. package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +2 -0
  59. package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +2 -0
  60. package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +2 -0
  61. package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +2 -0
  62. package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +2 -0
  63. package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +2 -0
  64. package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +2 -0
  65. package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +110 -2
  66. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +29 -3
  67. package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +6 -3
  68. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +11 -0
  69. package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +9 -1
  70. package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +2 -0
  71. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +171 -8
  72. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +9 -2
  73. package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +10 -3
  74. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +16 -1
  75. package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +3 -0
  76. package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +7 -0
  77. package/targets/esp32-s3-touch-amoled-2.41/dependencies.lock +57 -1
  78. package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +10 -0
  79. package/targets/esp32-s3-touch-lcd-3.5b/dependencies.lock +12 -1
  80. package/targets/esp32-s3-touch-lcd-3.5b/main/CMakeLists.txt +5 -1
  81. package/targets/esp32-s3-touch-lcd-3.5b/main/idf_component.yml +2 -1
  82. package/targets/esp32-s3-touch-lcd-3.5b/main/include/board.h +3 -0
  83. package/targets/esp32-s3-touch-lcd-3.5b/main/platform_stubs.cpp +1 -18
  84. package/targets/esp32-s3-touch-lcd-3.5b/main/speaker_power.cpp +27 -0
  85. package/targets/esp32-s3-waveshare-touch-lcd-4b.json +504 -0
  86. package/targets.json +12 -1
@@ -0,0 +1,333 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Eight parallel VP8 deblocking lanes. data holds p3..q3 as eight aligned
3
+ // vectors of unsigned pixel values widened to int16. mode: 0 block, 1 MB,
4
+ // 2 simple. Returns zero when every lane has zero correction, allowing the
5
+ // wrapper to avoid scattering an unchanged edge back into reference PSRAM.
6
+ .section .rodata.gea_vp8_loop_constants,"a",@progbits
7
+ .balign 16
8
+ .Lloop_constants:
9
+ .short -128, 127, 255, -1, 4, 3, 1, 63, 27, 18, 9
10
+
11
+ .macro loadtap reg, offset
12
+ addi a8, a2, \offset
13
+ ee.vld.128.ip \reg, a8, 0
14
+ .endm
15
+ .macro storetap reg, offset
16
+ addi a8, a2, \offset
17
+ ee.vst.128.ip \reg, a8, 0
18
+ .endm
19
+ .macro constant reg, offset
20
+ addi a8, a7, \offset
21
+ ee.vldbc.16 \reg, a8
22
+ .endm
23
+ .macro absdiff dest, x, y, temp
24
+ ee.vsubs.s16 \dest, \x, \y
25
+ ee.vsubs.s16 \temp, \y, \x
26
+ ee.vmax.s16 \dest, \dest, \temp
27
+ .endm
28
+ .macro signed_clip reg
29
+ ee.vmax.s16 \reg, \reg, q6
30
+ ee.vmin.s16 \reg, \reg, q7
31
+ .endm
32
+ .macro shift_right reg, bits
33
+ movi a9, \bits
34
+ ee.mov.s16.qacc \reg
35
+ ee.srcmb.s16.qacc \reg, a9, 0
36
+ .endm
37
+ .macro update_pixels delta, p, q
38
+ loadtap q5, \p
39
+ ee.vadds.s16 q5, q5, \delta
40
+ ee.vmax.s16 q5, q5, q6
41
+ ee.vmin.s16 q5, q5, q7
42
+ storetap q5, \p
43
+ loadtap q5, \q
44
+ ee.vsubs.s16 q5, q5, \delta
45
+ ee.vmax.s16 q5, q5, q6
46
+ ee.vmin.s16 q5, q5, q7
47
+ storetap q5, \q
48
+ .endm
49
+ .macro wide_delta coefficient
50
+ constant q0, \coefficient
51
+ movi a9, 0
52
+ wsr.sar a9
53
+ ee.vmul.s16 q0, q4, q0
54
+ ee.vadds.s16 q0, q0, q2
55
+ shift_right q0, 7
56
+ .endm
57
+
58
+ .text
59
+ .align 4
60
+ .global gea_vp8_loopfilter8_s3
61
+ .type gea_vp8_loopfilter8_s3,@function
62
+ gea_vp8_loopfilter8_s3:
63
+ // a2 data; a3 limit; a4 blimit; a5 hev threshold; a6 mode
64
+ entry a1, 32
65
+ s16i a3, a1, 0
66
+ s16i a4, a1, 2
67
+ s16i a5, a1, 4
68
+ movi a7, .Lloop_constants
69
+
70
+ // Edge metric: 2*abs(p0-q0) + floor(abs(p1-q1)/2).
71
+ loadtap q0, 48
72
+ loadtap q1, 64
73
+ absdiff q2, q0, q1, q3
74
+ ee.vadds.s16 q2, q2, q2
75
+ loadtap q0, 32
76
+ loadtap q1, 80
77
+ absdiff q4, q0, q1, q3
78
+ shift_right q4, 1
79
+ ee.vadds.s16 q2, q2, q4
80
+ addi a8, a1, 2
81
+ ee.vldbc.16 q4, a8
82
+ ee.vcmp.gt.s16 q2, q2, q4
83
+ beqi a6, 2, .Lloop_simple_mask
84
+
85
+ // Maximum of adjacent differences on either side of the boundary.
86
+ ee.zero.q q3
87
+ mov a10, a2
88
+ movi a11, 2
89
+ .Lloop_side:
90
+ ee.vld.128.ip q0, a10, 16
91
+ movi a12, 3
92
+ .Lloop_adjacent:
93
+ ee.vld.128.ip q1, a10, 16
94
+ absdiff q4, q0, q1, q5
95
+ ee.vmax.s16 q3, q3, q4
96
+ ee.orq q0, q1, q1
97
+ addi a12, a12, -1
98
+ bnez a12, .Lloop_adjacent
99
+ addi a11, a11, -1
100
+ bnez a11, .Lloop_side
101
+ ee.vldbc.16 q4, a1
102
+ ee.vcmp.gt.s16 q3, q3, q4
103
+ ee.orq q2, q2, q3
104
+
105
+ loadtap q0, 32
106
+ loadtap q1, 48
107
+ absdiff q3, q0, q1, q4
108
+ loadtap q0, 64
109
+ loadtap q1, 80
110
+ absdiff q4, q0, q1, q5
111
+ ee.vmax.s16 q3, q3, q4
112
+ addi a8, a1, 4
113
+ ee.vldbc.16 q4, a8
114
+ ee.vcmp.gt.s16 q3, q3, q4
115
+ j .Lloop_mask_ready
116
+ .Lloop_simple_mask:
117
+ constant q3, 6
118
+ .Lloop_mask_ready:
119
+ constant q4, 6
120
+ ee.xorq q2, q2, q4
121
+ constant q6, 0
122
+ constant q7, 2
123
+ loadtap q0, 32
124
+ loadtap q1, 80
125
+ ee.vsubs.s16 q4, q0, q1
126
+ signed_clip q4
127
+ bnez a6, .Lloop_outer_ready
128
+ ee.andq q4, q4, q3
129
+ .Lloop_outer_ready:
130
+ loadtap q0, 64
131
+ loadtap q1, 48
132
+ ee.vsubs.s16 q0, q0, q1
133
+ ee.vadds.s16 q5, q0, q0
134
+ ee.vadds.s16 q0, q0, q5
135
+ ee.vadds.s16 q4, q4, q0
136
+ signed_clip q4
137
+ ee.andq q4, q4, q2
138
+ // Flat areas and rejected edges need no update. Reduce the eight signed
139
+ // 16-bit corrections without storing the vector to the PSRAM stack.
140
+ ee.movi.32.a q4, a10, 0
141
+ ee.movi.32.a q4, a11, 1
142
+ or a10, a10, a11
143
+ ee.movi.32.a q4, a11, 2
144
+ or a10, a10, a11
145
+ ee.movi.32.a q4, a11, 3
146
+ or a10, a10, a11
147
+ beqz a10, .Lloop_unchanged
148
+ ee.orq q5, q4, q4
149
+ bnei a6, 1, .Lloop_narrow_ready
150
+ ee.andq q5, q5, q3
151
+ .Lloop_narrow_ready:
152
+ constant q0, 8
153
+ constant q1, 10
154
+ ee.vadds.s16 q0, q5, q0
155
+ ee.vadds.s16 q1, q5, q1
156
+ signed_clip q0
157
+ signed_clip q1
158
+ shift_right q0, 3
159
+ shift_right q1, 3
160
+ ee.zero.q q6
161
+ constant q7, 4
162
+ loadtap q5, 48
163
+ ee.vadds.s16 q5, q5, q1
164
+ ee.vmax.s16 q5, q5, q6
165
+ ee.vmin.s16 q5, q5, q7
166
+ storetap q5, 48
167
+ loadtap q5, 64
168
+ ee.vsubs.s16 q5, q5, q0
169
+ ee.vmax.s16 q5, q5, q6
170
+ ee.vmin.s16 q5, q5, q7
171
+ storetap q5, 64
172
+ beqi a6, 2, .Lloop_done
173
+ constant q1, 6
174
+ ee.xorq q3, q3, q1
175
+ beqi a6, 1, .Lloop_wide
176
+
177
+ constant q1, 12
178
+ ee.vadds.s16 q0, q0, q1
179
+ shift_right q0, 1
180
+ ee.andq q0, q0, q3
181
+ update_pixels q0, 32, 80
182
+ j .Lloop_done
183
+ .Lloop_wide:
184
+ ee.andq q4, q4, q3
185
+ constant q2, 14
186
+ wide_delta 16
187
+ update_pixels q0, 48, 64
188
+ wide_delta 18
189
+ update_pixels q0, 32, 80
190
+ wide_delta 20
191
+ update_pixels q0, 16, 96
192
+ .Lloop_done:
193
+ movi a2, 1
194
+ retw
195
+ .Lloop_unchanged:
196
+ movi a2, 0
197
+ retw
198
+ .size gea_vp8_loopfilter8_s3, .-gea_vp8_loopfilter8_s3
199
+
200
+ .macro edge_load_row reg
201
+ mov a6, a2
202
+ ee.ld.128.usar.ip q6, a6, 16
203
+ ee.ld.128.usar.ip q7, a6, 16
204
+ ee.src.q.qup \reg, q6, q7
205
+ add a2, a2, a3
206
+ .endm
207
+ .macro edge_load_lanes reg
208
+ ee.vld.128.ip \reg, a4, 16
209
+ ee.zero.q q5
210
+ ee.vunzip.8 \reg, q5
211
+ .endm
212
+ .macro edge_transpose load
213
+ \load q0
214
+ \load q1
215
+ ee.vzip.8 q0, q1
216
+ \load q1
217
+ \load q2
218
+ ee.vzip.8 q1, q2
219
+ \load q2
220
+ \load q3
221
+ ee.vzip.8 q2, q3
222
+ \load q3
223
+ \load q4
224
+ ee.vzip.8 q3, q4
225
+ ee.vzip.16 q0, q1
226
+ ee.vzip.16 q2, q3
227
+ ee.vzip.32 q0, q2
228
+ ee.vzip.32 q1, q3
229
+ .endm
230
+ .macro edge_save_lanes reg
231
+ ee.zero.q q5
232
+ ee.vzip.8 \reg, q5
233
+ ee.vst.128.ip \reg, a4, 16
234
+ ee.vst.128.ip q5, a4, 16
235
+ .endm
236
+ .align 4
237
+ .global gea_vp8_edge_load_s3
238
+ .type gea_vp8_edge_load_s3,@function
239
+ gea_vp8_edge_load_s3:
240
+ // a2 first p3 pixel; a3 image stride; a4 lanes; a5 horizontal
241
+ entry a1, 32
242
+ beqz a5, .Ledge_load_vertical
243
+ movi a7, 8
244
+ .Ledge_load_horizontal:
245
+ // q7 is a vector register and does not alias the a7 loop counter.
246
+ edge_load_row q0
247
+ ee.zero.q q1
248
+ ee.vzip.8 q0, q1
249
+ ee.vst.128.ip q0, a4, 16
250
+ addi a7, a7, -1
251
+ bnez a7, .Ledge_load_horizontal
252
+ retw
253
+ .Ledge_load_vertical:
254
+ edge_transpose edge_load_row
255
+ edge_save_lanes q0
256
+ edge_save_lanes q2
257
+ edge_save_lanes q1
258
+ edge_save_lanes q3
259
+ retw
260
+ .size gea_vp8_edge_load_s3, .-gea_vp8_edge_load_s3
261
+
262
+ .macro edge_store_row reg, lo, hi
263
+ ee.movi.32.a \reg, a6, \lo
264
+ ee.movi.32.a \reg, a7, \hi
265
+ extui a8, a2, 0, 2
266
+ bnez a8, 1f
267
+ s32i a6, a2, 0
268
+ s32i a7, a2, 4
269
+ j 2f
270
+ 1:
271
+ s8i a6, a2, 0
272
+ srli a6, a6, 8
273
+ s8i a6, a2, 1
274
+ srli a6, a6, 8
275
+ s8i a6, a2, 2
276
+ srli a6, a6, 8
277
+ s8i a6, a2, 3
278
+ s8i a7, a2, 4
279
+ srli a7, a7, 8
280
+ s8i a7, a2, 5
281
+ srli a7, a7, 8
282
+ s8i a7, a2, 6
283
+ srli a7, a7, 8
284
+ s8i a7, a2, 7
285
+ 2:
286
+ add a2, a2, a3
287
+ .endm
288
+ .align 4
289
+ .global gea_vp8_edge_store_s3
290
+ .type gea_vp8_edge_store_s3,@function
291
+ gea_vp8_edge_store_s3:
292
+ entry a1, 32
293
+ beqz a5, .Ledge_store_vertical
294
+ // Horizontal edges occupy separate reference-plane rows/cache lines.
295
+ // Write only the rows this filter can modify: p1..q1 normal, p2..q2 MB,
296
+ // p0..q0 simple. Vertical edges retain their aligned packed row stores.
297
+ // a6 mode must be consumed before edge_store_row uses it as scratch.
298
+ beqi a6, 1, .Ledge_store_horizontal_mb
299
+ beqi a6, 2, .Ledge_store_horizontal_simple
300
+ add a2, a2, a3
301
+ add a2, a2, a3
302
+ addi a4, a4, 32
303
+ movi a9, 4
304
+ j .Ledge_store_horizontal
305
+ .Ledge_store_horizontal_mb:
306
+ add a2, a2, a3
307
+ addi a4, a4, 16
308
+ movi a9, 6
309
+ j .Ledge_store_horizontal
310
+ .Ledge_store_horizontal_simple:
311
+ add a2, a2, a3
312
+ add a2, a2, a3
313
+ add a2, a2, a3
314
+ addi a4, a4, 48
315
+ movi a9, 2
316
+ .Ledge_store_horizontal:
317
+ edge_load_lanes q0
318
+ edge_store_row q0, 0, 1
319
+ addi a9, a9, -1
320
+ bnez a9, .Ledge_store_horizontal
321
+ retw
322
+ .Ledge_store_vertical:
323
+ edge_transpose edge_load_lanes
324
+ edge_store_row q0, 0, 1
325
+ edge_store_row q0, 2, 3
326
+ edge_store_row q2, 0, 1
327
+ edge_store_row q2, 2, 3
328
+ edge_store_row q1, 0, 1
329
+ edge_store_row q1, 2, 3
330
+ edge_store_row q3, 0, 1
331
+ edge_store_row q3, 2, 3
332
+ retw
333
+ .size gea_vp8_edge_store_s3, .-gea_vp8_edge_store_s3
@@ -0,0 +1,62 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #include "vp8_s3.h"
3
+ #include "vp8/common/loopfilter.h"
4
+ #include <stdint.h>
5
+ #include <stdalign.h>
6
+
7
+ extern int gea_vp8_loopfilter8_s3(int16_t*, int, int, int, int);
8
+ extern void gea_vp8_edge_load_s3(const uint8_t*, int, int16_t*, int);
9
+ extern void gea_vp8_edge_store_s3(uint8_t*, int, const int16_t*, int, int);
10
+
11
+ static void edge(uint8_t* pixels, int stride, int horizontal, int count,
12
+ int limit, int blimit, int threshold, int mode) {
13
+ alignas(16) int16_t fallback[8][8];
14
+ int16_t (*lanes)[8] = gea_vp8_workspace_s3();
15
+ if (!lanes) lanes = fallback;
16
+ const int along = horizontal ? 1 : stride;
17
+ const int across = horizontal ? stride : 1;
18
+ for (int block = 0; block < count; ++block) {
19
+ gea_vp8_edge_load_s3(pixels - 4*across, stride, &lanes[0][0], horizontal);
20
+ if (gea_vp8_loopfilter8_s3(&lanes[0][0], limit, blimit, threshold, mode))
21
+ gea_vp8_edge_store_s3(pixels - 4*across, stride, &lanes[0][0], horizontal, mode);
22
+ pixels += 8*along;
23
+ }
24
+ }
25
+
26
+ static void filter(uint8_t* y, uint8_t* u, uint8_t* v, int ys, int uvs,
27
+ loop_filter_info* info, int horizontal, int mb) {
28
+ const int limit = info->lim[0], threshold = info->hev_thr[0];
29
+ const int blimit = mb ? info->mblim[0] : info->blim[0];
30
+ const int yStep = horizontal ? ys : 1, uvStep = horizontal ? uvs : 1;
31
+ if (mb) edge(y, ys, horizontal, 2, limit, blimit, threshold, 1);
32
+ else for (int i = 4; i <= 12; i += 4)
33
+ edge(y + i*yStep, ys, horizontal, 2, limit, blimit, threshold, 0);
34
+ if (u) edge(u + (mb ? 0 : 4*uvStep), uvs, horizontal, 1, limit, blimit, threshold, mb);
35
+ if (v) edge(v + (mb ? 0 : 4*uvStep), uvs, horizontal, 1, limit, blimit, threshold, mb);
36
+ }
37
+ #define GEA_LOOP_WRAPPER(name, horizontal, mb) \
38
+ void vp8_loop_filter_##name##_s3(unsigned char* y, unsigned char* u, unsigned char* v, \
39
+ int ys, int uvs, struct loop_filter_info* info) { \
40
+ filter(y, u, v, ys, uvs, info, horizontal, mb); \
41
+ }
42
+ GEA_LOOP_WRAPPER(bh, 1, 0)
43
+ GEA_LOOP_WRAPPER(bv, 0, 0)
44
+ GEA_LOOP_WRAPPER(mbh, 1, 1)
45
+ GEA_LOOP_WRAPPER(mbv, 0, 1)
46
+ #undef GEA_LOOP_WRAPPER
47
+
48
+ static void simple(uint8_t* y, int stride, const uint8_t* blimit, int horizontal, int mb) {
49
+ const int step = horizontal ? stride : 1;
50
+ if (mb) edge(y, stride, horizontal, 2, 0, blimit[0], 0, 2);
51
+ else for (int i = 4; i <= 12; i += 4)
52
+ edge(y + i*step, stride, horizontal, 2, 0, blimit[0], 0, 2);
53
+ }
54
+ #define GEA_SIMPLE_WRAPPER(name, horizontal, mb) \
55
+ void vp8_loop_filter_simple_##name##_s3(unsigned char* y, int stride, const unsigned char* blimit) { \
56
+ simple(y, stride, blimit, horizontal, mb); \
57
+ }
58
+ GEA_SIMPLE_WRAPPER(bh, 1, 0)
59
+ GEA_SIMPLE_WRAPPER(bv, 0, 0)
60
+ GEA_SIMPLE_WRAPPER(mbh, 1, 1)
61
+ GEA_SIMPLE_WRAPPER(mbv, 0, 1)
62
+ #undef GEA_SIMPLE_WRAPPER
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #include "vp8_profile_s3.h"
3
+ #include "esp_timer.h"
4
+ #include <stdatomic.h>
5
+
6
+ // Explicit diagnostic only: disabled on boot, with no timers or extra tasks.
7
+ // Each decoder binds its own counters; stages are never shared across tasks.
8
+ static atomic_int requested;
9
+ static _Thread_local struct gea_vp8_profile_s3* current;
10
+ void gea_vp8_profile_enable_s3(int enabled) { atomic_store_explicit(&requested, !!enabled, memory_order_relaxed); }
11
+ int gea_vp8_profile_requested_s3(void) { return atomic_load_explicit(&requested, memory_order_relaxed); }
12
+ struct gea_vp8_profile_s3* gea_vp8_profile_bind_s3(struct gea_vp8_profile_s3* next) {
13
+ struct gea_vp8_profile_s3* previous = current;
14
+ current = next;
15
+ return previous;
16
+ }
17
+ uint64_t gea_vp8_profile_clock_s3(void) { return current ? esp_timer_get_time() : 0; }
18
+ void gea_vp8_profile_add_s3(unsigned stage, uint64_t started) {
19
+ if (!started || !current || stage >= GEA_VP8_PROFILE_STAGES) return;
20
+ current->us[stage] += esp_timer_get_time() - started;
21
+ ++current->calls[stage];
22
+ }
@@ -0,0 +1,20 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #pragma once
3
+ #include <stdint.h>
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+ enum { GEA_VP8_PROFILE_TOKENS, GEA_VP8_PROFILE_MACROBLOCK,
8
+ GEA_VP8_PROFILE_LOOPFILTER, GEA_VP8_PROFILE_STAGES };
9
+ struct gea_vp8_profile_s3 {
10
+ uint64_t us[GEA_VP8_PROFILE_STAGES];
11
+ uint32_t calls[GEA_VP8_PROFILE_STAGES];
12
+ };
13
+ void gea_vp8_profile_enable_s3(int enabled);
14
+ int gea_vp8_profile_requested_s3(void);
15
+ struct gea_vp8_profile_s3* gea_vp8_profile_bind_s3(struct gea_vp8_profile_s3* next);
16
+ uint64_t gea_vp8_profile_clock_s3(void);
17
+ void gea_vp8_profile_add_s3(unsigned stage, uint64_t started);
18
+ #ifdef __cplusplus
19
+ }
20
+ #endif
@@ -0,0 +1,120 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #include "vp8_s3.h"
3
+ #include <stdint.h>
4
+ #include <stdalign.h>
5
+ #include <string.h>
6
+
7
+ // These are VP8's normative interpolation coefficients. Both passes round and
8
+ // clip separately; combining them would change reference pixels and cause drift.
9
+ static const int16_t six_tap[8][6] = {
10
+ {0, 0, 128, 0, 0, 0}, {0, -6, 123, 12, -1, 0},
11
+ {2, -11, 108, 36, -8, 1}, {0, -9, 93, 50, -6, 0},
12
+ {3, -16, 77, 77, -16, 3}, {0, -6, 50, 93, -9, 0},
13
+ {1, -8, 36, 108, -11, 2}, {0, -1, 12, 123, -6, 0}
14
+ };
15
+ static const int16_t bilinear[8][2] = {
16
+ {128, 0}, {112, 16}, {96, 32}, {80, 48},
17
+ {64, 64}, {48, 80}, {32, 96}, {16, 112}
18
+ };
19
+
20
+ extern void gea_vp8_filter_rows_s3(const uint8_t*, int, const int16_t*, uint8_t*, int, int);
21
+ extern void gea_vp8_copy_rect_s3(const uint8_t*, int, uint8_t*, int, int, int);
22
+
23
+ static void copy_rect(const uint8_t* src, int stride, uint8_t* dst, int pitch,
24
+ int width, int height) {
25
+ // Codec reference planes have padded borders, so both aligned source loads
26
+ // are valid even for fractional-address integer motion. Destination stores
27
+ // write only the requested block, with scalar fallback for odd alignment.
28
+ if (((uintptr_t)dst | (unsigned)pitch) & 3) {
29
+ for (int y = 0; y < height; ++y) memcpy(dst + y*pitch, src + y*stride, width);
30
+ } else {
31
+ gea_vp8_copy_rect_s3(src, stride, dst, pitch, width, height);
32
+ }
33
+ }
34
+
35
+ #define GEA_VP8_COPY(size, width, height) \
36
+ void vp8_copy_mem##size##_s3(unsigned char* src, int stride, unsigned char* dst, int pitch) { \
37
+ copy_rect(src, stride, dst, pitch, width, height); \
38
+ }
39
+ GEA_VP8_COPY(16x16, 16, 16)
40
+ GEA_VP8_COPY(8x8, 8, 8)
41
+ GEA_VP8_COPY(8x4, 8, 4)
42
+ #undef GEA_VP8_COPY
43
+
44
+ static void filter_rows(const uint8_t* src, int stride, const int16_t* coefficients,
45
+ uint8_t* dst, int pitch, int taps, int lanes, int height, int vertical) {
46
+ gea_vp8_filter_rows_s3(src, stride, coefficients, dst, pitch,
47
+ (height << 8) | (vertical << 4) | ((lanes == 8) << 3) | taps);
48
+ }
49
+
50
+ static void predict(uint8_t* src, int stride, int xoffset, int yoffset,
51
+ uint8_t* dst, int pitch, int width, int height, int taps) {
52
+ // 32-byte rows provide safe vector loads at both edges. The original generic
53
+ // path used up to 2016 bytes of int32 intermediates; this uses 672 bytes.
54
+ alignas(16) uint8_t fallback[21][32];
55
+ uint8_t (*intermediate)[32] = gea_vp8_workspace_s3();
56
+ if (!intermediate) intermediate = fallback;
57
+ // Odd six-tap phases have zero outer coefficients. Four taps give exactly
58
+ // the same rounded result without loading/multiplying two unused borders.
59
+ const int horizontal_taps = taps == 6 && (xoffset & 1) ? 4 : taps;
60
+ const int vertical_taps = taps == 6 && (yoffset & 1) ? 4 : taps;
61
+ const int horizontal_first = taps == 6 ? (horizontal_taps == 4 ? 1 : 2) : 0;
62
+ const int vertical_first = taps == 6 ? (vertical_taps == 4 ? 1 : 2) : 0;
63
+ const int16_t* horizontal = taps == 6 ? six_tap[xoffset] : bilinear[xoffset];
64
+ const int16_t* vertical = taps == 6 ? six_tap[yoffset] : bilinear[yoffset];
65
+ horizontal += horizontal_taps == 4;
66
+ vertical += vertical_taps == 4;
67
+ const int lanes = width == 4 ? 4 : 8;
68
+ // An integer-pixel axis is an identity filter. Avoid an entire convolution
69
+ // pass (and its intermediate writes) rather than multiplying by zero taps.
70
+ if (!xoffset && !yoffset) {
71
+ copy_rect(src, stride, dst, pitch, width, height);
72
+ return;
73
+ }
74
+ if (!xoffset || !yoffset) {
75
+ const int step = xoffset ? 1 : stride;
76
+ const int first = xoffset ? horizontal_first : vertical_first;
77
+ const int active_taps = xoffset ? horizontal_taps : vertical_taps;
78
+ const int16_t* coefficients = xoffset ? horizontal : vertical;
79
+ for (int x = 0; x < width; x += 8)
80
+ filter_rows(src + x - first*step, stride, coefficients, dst + x, pitch,
81
+ active_taps, lanes, height, !xoffset);
82
+ return;
83
+ }
84
+ for (int x = 0; x < width; x += 8)
85
+ filter_rows(src - vertical_first * stride + x - horizontal_first, stride,
86
+ horizontal, intermediate[0] + x, 32, horizontal_taps, lanes,
87
+ height + vertical_taps - 1, 0);
88
+ for (int x = 0; x < width; x += 8)
89
+ filter_rows(intermediate[0] + x, 32, vertical, dst + x, pitch,
90
+ vertical_taps, lanes, height, 1);
91
+ }
92
+
93
+ #define GEA_VP8_FILTER(kind, size, w, h, taps) \
94
+ void vp8_##kind##_predict##size##_s3(unsigned char* src, int stride, int x, int y, \
95
+ unsigned char* dst, int pitch) { \
96
+ predict(src, stride, x, y, dst, pitch, w, h, taps); \
97
+ }
98
+ GEA_VP8_FILTER(sixtap, 4x4, 4, 4, 6)
99
+ GEA_VP8_FILTER(sixtap, 8x4, 8, 4, 6)
100
+ GEA_VP8_FILTER(sixtap, 8x8, 8, 8, 6)
101
+ GEA_VP8_FILTER(sixtap, 16x16, 16, 16, 6)
102
+ GEA_VP8_FILTER(bilinear, 4x4, 4, 4, 2)
103
+ GEA_VP8_FILTER(bilinear, 8x4, 8, 4, 2)
104
+ GEA_VP8_FILTER(bilinear, 8x8, 8, 8, 2)
105
+ GEA_VP8_FILTER(bilinear, 16x16, 16, 16, 2)
106
+ #undef GEA_VP8_FILTER
107
+
108
+ extern void gea_vp8_tm_s3(uint8_t*, ptrdiff_t, const uint8_t*, const uint8_t*, int);
109
+ #define GEA_VP8_TM(size) \
110
+ void vpx_tm_predictor_##size##x##size##_s3(uint8_t* dst, ptrdiff_t stride, \
111
+ const uint8_t* above, const uint8_t* left) { \
112
+ alignas(16) uint8_t top[32]; \
113
+ top[15] = above[-1]; \
114
+ memcpy(top + 16, above, size); \
115
+ gea_vp8_tm_s3(dst, stride, top + 16, left, size); \
116
+ }
117
+ GEA_VP8_TM(4)
118
+ GEA_VP8_TM(8)
119
+ GEA_VP8_TM(16)
120
+ #undef GEA_VP8_TM
@@ -0,0 +1,58 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #pragma once
3
+ #include <stddef.h>
4
+ #include <stdint.h>
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+ // Interpolation needs 21 aligned 32-byte rows; deblocking reuses 128 bytes.
9
+ enum { GEA_VP8_WORKSPACE_BYTES = 21 * 32 };
10
+ void* gea_vp8_workspace_s3(void);
11
+ void* gea_vp8_bind_workspace_s3(void*);
12
+ #define GEA_VP8_DECLARE_COPY(size) \
13
+ void vp8_copy_mem##size##_s3(unsigned char*, int, unsigned char*, int);
14
+ GEA_VP8_DECLARE_COPY(16x16)
15
+ GEA_VP8_DECLARE_COPY(8x8)
16
+ GEA_VP8_DECLARE_COPY(8x4)
17
+ #undef GEA_VP8_DECLARE_COPY
18
+ #define GEA_VP8_DECLARE_FILTER(kind, size) \
19
+ void vp8_##kind##_predict##size##_s3(unsigned char*, int, int, int, unsigned char*, int);
20
+ GEA_VP8_DECLARE_FILTER(sixtap, 4x4)
21
+ GEA_VP8_DECLARE_FILTER(sixtap, 8x4)
22
+ GEA_VP8_DECLARE_FILTER(sixtap, 8x8)
23
+ GEA_VP8_DECLARE_FILTER(sixtap, 16x16)
24
+ GEA_VP8_DECLARE_FILTER(bilinear, 4x4)
25
+ GEA_VP8_DECLARE_FILTER(bilinear, 8x4)
26
+ GEA_VP8_DECLARE_FILTER(bilinear, 8x8)
27
+ GEA_VP8_DECLARE_FILTER(bilinear, 16x16)
28
+ #undef GEA_VP8_DECLARE_FILTER
29
+ void vp8_short_idct4x4llm_s3(short*, unsigned char*, int, unsigned char*, int);
30
+ void vp8_dequant_idct_add_s3(short*, short*, unsigned char*, int);
31
+ void vp8_dequant_idct_add_y_block_s3(short*, short*, unsigned char*, int, char*);
32
+ void vp8_dequant_idct_add_uv_block_s3(short*, short*, unsigned char*, unsigned char*, int, char*);
33
+ void vp8_dc_only_idct_add_s3(short, unsigned char*, int, unsigned char*, int);
34
+ void vp8_short_inv_walsh4x4_s3(short*, short*);
35
+ #define GEA_VP8_DECLARE_TM(size) \
36
+ void vpx_tm_predictor_##size##x##size##_s3(uint8_t*, ptrdiff_t, const uint8_t*, const uint8_t*);
37
+ GEA_VP8_DECLARE_TM(4)
38
+ GEA_VP8_DECLARE_TM(8)
39
+ GEA_VP8_DECLARE_TM(16)
40
+ #undef GEA_VP8_DECLARE_TM
41
+ struct loop_filter_info;
42
+ #define GEA_DECLARE_LOOP(name) \
43
+ void vp8_loop_filter_##name##_s3(unsigned char*, unsigned char*, unsigned char*, int, int, struct loop_filter_info*); \
44
+ void vp8_loop_filter_simple_##name##_s3(unsigned char*, int, const unsigned char*);
45
+ GEA_DECLARE_LOOP(bh)
46
+ GEA_DECLARE_LOOP(bv)
47
+ GEA_DECLARE_LOOP(mbh)
48
+ GEA_DECLARE_LOOP(mbv)
49
+ #undef GEA_DECLARE_LOOP
50
+ struct gea_vp8_entropy_result {
51
+ unsigned cases;
52
+ uint64_t scalar_us;
53
+ uint64_t native_us;
54
+ };
55
+ int gea_vp8_entropy_check_s3(struct gea_vp8_entropy_result*);
56
+ #ifdef __cplusplus
57
+ }
58
+ #endif
@@ -0,0 +1,14 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #include "vp8_s3.h"
3
+
4
+ // Bound by the decoder only during vpx_codec_decode. Each task has its own
5
+ // binding; nested decoders restore the previous binding rather than sharing
6
+ // mutable SIMD intermediates across tasks.
7
+ static _Thread_local void* workspace;
8
+
9
+ void* gea_vp8_workspace_s3(void) { return workspace; }
10
+ void* gea_vp8_bind_workspace_s3(void* next) {
11
+ void* previous = workspace;
12
+ workspace = next;
13
+ return previous;
14
+ }
@@ -0,0 +1,41 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // libvpx's allocation API, using external memory for codec state and reference
3
+ // images. Keep internal RAM available for I2S DMA, Wi-Fi and the DTLS stack.
4
+ #include <stddef.h>
5
+ #include <stdint.h>
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+
9
+ #ifdef ESP_PLATFORM
10
+ #include "esp_heap_caps.h"
11
+ #endif
12
+
13
+ void *vpx_memalign(size_t alignment, size_t size) {
14
+ if (!alignment || (alignment & (alignment - 1)) || size > SIZE_MAX - alignment) return NULL;
15
+ if (alignment < sizeof(void *)) alignment = sizeof(void *);
16
+ #ifdef ESP_PLATFORM
17
+ return heap_caps_aligned_alloc(alignment, size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
18
+ #else
19
+ // The standalone build also exercises the same allocation contract on a
20
+ // desktop or cross-compiles the decoder without needing the whole app.
21
+ void *memory = NULL;
22
+ return posix_memalign(&memory, alignment, size) == 0 ? memory : NULL;
23
+ #endif
24
+ }
25
+
26
+ void *vpx_malloc(size_t size) { return vpx_memalign(32, size); }
27
+
28
+ void *vpx_calloc(size_t count, size_t size) {
29
+ if (count && size > SIZE_MAX / count) return NULL;
30
+ void *memory = vpx_malloc(count * size);
31
+ if (memory) memset(memory, 0, count * size);
32
+ return memory;
33
+ }
34
+
35
+ void vpx_free(void *memory) {
36
+ #ifdef ESP_PLATFORM
37
+ heap_caps_free(memory);
38
+ #else
39
+ free(memory);
40
+ #endif
41
+ }