react-native-skia-webgpu-video 0.1.0-beta.1 → 0.1.0-beta.3

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 (47) hide show
  1. package/LICENSE +0 -1
  2. package/README.md +32 -11
  3. package/android/BUILD_VALIDATION.md +1 -1
  4. package/android/cpp/VideoComposition.cpp +12 -0
  5. package/android/cpp/VideoCompositionFramesExtractor.cpp +6 -0
  6. package/android/cpp/VideoCompositionFramesExtractor.h +1 -0
  7. package/android/cpp/VideoCompositionFramesExtractorHostObject.cpp +1 -1
  8. package/android/src/main/java/com/azzapp/rnskv/PreviewFrameRateVote.java +104 -0
  9. package/android/src/main/java/com/azzapp/rnskv/VideoComposition.java +4 -0
  10. package/android/src/main/java/com/azzapp/rnskv/VideoCompositionDecoder.java +4 -2
  11. package/android/src/main/java/com/azzapp/rnskv/VideoCompositionFramesExtractor.java +42 -4
  12. package/docs/FRAME_PIXEL_FORMAT.md +124 -0
  13. package/docs/UPSTREAM_NOTES.md +2 -0
  14. package/docs/VERIFICATION_0.1.0-beta.3.md +147 -0
  15. package/ios/NativeResourceStats.h +9 -0
  16. package/ios/RNSVColorSpace.h +35 -4
  17. package/ios/ReactNativeSkiaVideo.mm +4 -0
  18. package/ios/VideoComposition.h +20 -0
  19. package/ios/VideoCompositionFramesExtractorHostObject.h +5 -0
  20. package/ios/VideoCompositionFramesExtractorHostObject.mm +31 -2
  21. package/ios/VideoCompositionItemDecoder.mm +21 -8
  22. package/ios/VideoFrame.mm +6 -0
  23. package/lib/module/exportFrames.js +25 -18
  24. package/lib/module/exportFrames.js.map +1 -1
  25. package/lib/module/frameInterop.js +7 -1
  26. package/lib/module/frameInterop.js.map +1 -1
  27. package/lib/module/videoCompositionPlayer.js +13 -5
  28. package/lib/module/videoCompositionPlayer.js.map +1 -1
  29. package/lib/module/yuvBlit.js +70 -0
  30. package/lib/module/yuvBlit.js.map +1 -1
  31. package/lib/typescript/src/exportFrames.d.ts +8 -8
  32. package/lib/typescript/src/exportFrames.d.ts.map +1 -1
  33. package/lib/typescript/src/frameInterop.d.ts.map +1 -1
  34. package/lib/typescript/src/types.d.ts +26 -0
  35. package/lib/typescript/src/types.d.ts.map +1 -1
  36. package/lib/typescript/src/videoCompositionPlayer.d.ts +5 -3
  37. package/lib/typescript/src/videoCompositionPlayer.d.ts.map +1 -1
  38. package/lib/typescript/src/yuvBlit.d.ts +10 -0
  39. package/lib/typescript/src/yuvBlit.d.ts.map +1 -1
  40. package/package.json +7 -5
  41. package/scripts/skia-canvas-patch.json +1 -1
  42. package/src/exportFrames.ts +52 -34
  43. package/src/frameInterop.ts +18 -1
  44. package/src/types.ts +27 -0
  45. package/src/videoCompositionPlayer.ts +19 -7
  46. package/src/yuvBlit.ts +66 -0
  47. /package/patches/{react-native-skia+3.7.0.patch → react-native-skia+3.7.1.patch} +0 -0
@@ -0,0 +1,147 @@
1
+ # Vérification de la 0.1.0-beta.3 — 21 octobre 2026
2
+
3
+ Ce document liste ce qui a **réellement** été exécuté pour cette version :
4
+ - sur l'hôte ;
5
+ - sur **iPhone 15 Pro** (iOS 27.0.1) ;
6
+ - sur **Pixel 8a** (Android 17).
7
+
8
+ Tous les builds sont en Release, sur Skia 3.7.1 / WebGPU 0.17.0, inchangés depuis la beta.2. L'analyse du format des frames est dans [FRAME_PIXEL_FORMAT.md](FRAME_PIXEL_FORMAT.md).
9
+
10
+ ## Ce qui change
11
+
12
+ - **Horloge de `drawFrame`** (iOS, Android) : `currentTime` vaut l'heure à laquelle les frames dessinées ont été choisies. Lue plus tard, elle avançait jusqu'à une frame sur la vidéo à 60 fps, et les overlays calculés d'après elle étaient décalés d'autant.
13
+ - **`splitImportAndDraw`** ne perd plus une frame sur deux quand une nouvelle frame arrive à chaque vsync.
14
+ - **Android 15+** : une preview en lecture demande à l'écran sa fréquence maximale. Le Pixel ne descend plus à 30 Hz, et monte à 120 Hz quand le réglage de l'utilisateur le permet.
15
+ - **iOS** : la file de décodage de la preview tourne en priorité *user-interactive* au lieu d'*utility*.
16
+ - **`framePixelFormat`** (`'auto' | 'yuv' | 'rgba'`) : `auto` vaut `yuv` sur les deux plateformes. Sur iOS, le décodeur sort désormais du NV12 (12,4 Mo par frame 4K au lieu de 33,2 Mo de BGRA). `rgba` reste disponible.
17
+ - **Diagnostic** : `getResourceStats()` donne sur iOS les refus de l'anneau de frames, les files de décodage vides et les ticks de décodage lents.
18
+ - **App de test** : profil `sync` (exactitude des frames, seeks, exports, couleurs, rendu de vrais médias), option `--frame-pixel-format` des lanceurs, `--case` pour iOS, clé `CADisableMinimumFrameDurationOnPhone` (120 Hz sur ProMotion).
19
+
20
+ ## Hôte
21
+
22
+ | Contrôle | Résultat |
23
+ | --- | --- |
24
+ | Jest | **237/237 tests, 11 suites** (dont les chemins NV12 de la preview et de l'export) |
25
+ | `tsc --noEmit`, `test:package`, `benchmark:test` | OK, 5/5, 122/122 |
26
+ | `test:native` (C++ hôte, validation native, syntaxe des 50 assertions iOS historiques) | OK |
27
+ | Tests JVM | 27/27 |
28
+ | `test-skia-patch-syntax.mjs`, `test-skia-provider-ownership.mjs` | OK |
29
+ | `npm run build`, `check-package` (publint strict) | OK |
30
+
31
+ ## Exactitude de la lecture (profil `sync`)
32
+
33
+ Chaque frame des fixtures porte son numéro en code-barres, lu à chaque vsync dans `drawFrame` et comparé à l'horloge du player. « Exact » : part des vsyncs qui montrent la frame due. « Irr » : part des changements de frame décalés de plus de 3/4 de vsync. Écran à 60 Hz.
34
+
35
+ | Cas | Pixel, avant | Pixel, beta.3 | iPhone, avant | iPhone, beta.3 |
36
+ | --- | --- | --- | --- | --- |
37
+ | 30 fps | 93 % · irr 1,8 % | **99,4 %** · irr 1,8 % | 100 % | 100 % |
38
+ | 30 fps, `splitImportAndDraw` | 79 % · irr 81 % · 75 frames sautées | **99 %** · irr 0 % · 2 | 100 % | 100 % |
39
+ | 24 fps | 85 % · irr 21 % | **100 %** · irr 4,6 % | 100 % | 100 % |
40
+ | 60 fps | 51 % · 166 sautées | **99,4 %** · 2 | 80 % · 9 sautées | **100 %** |
41
+ | HEVC 1080p 60 fps | 66 % | **98,8 %** | 99,7 % (0,3 % au premier run) | **100 %** |
42
+
43
+ « Avant » : le code de `main` avec le seul profil `sync` ajouté. Les 2 à 9 frames sautées restantes tombent au démarrage d'une lecture.
44
+
45
+ **4K, `yuv` (défaut) contre `rgba`** :
46
+
47
+ | Cas | Pixel `rgba` | Pixel `yuv` | iPhone `rgba` | iPhone `yuv` |
48
+ | --- | --- | --- | --- | --- |
49
+ | HEVC 4K 60 fps | 18 % · irr 65 % · 205 sautées | **97 % · irr 0,3 %** · 9 | 66 % · irr 6,5 % · 64 | **97 % · irr 1,3 %** · 9 |
50
+ | HEVC 4K 30 fps | 38 % · irr 52 % | **100 %** · irr 0 % | 97 % · irr 1,9 % | **100 %** · irr 0 % |
51
+ | H.264 4K 30 fps | 38 % · irr 48 % | **99 %** · irr 0,6 % | 96 % · irr 6,9 % | **100 %** · irr 1,2 % |
52
+ | Vraie vidéo 4K 60 fps, 60 Mbit/s (frames distinctes) | 145/360 | **335/360** | 268/360 | 267/360 |
53
+
54
+ Le Pixel est resté à l'état thermique *nominal*. Les deux runs iPhone de ce tableau ont tourné téléphone chaud, *fair* pour `rgba` et *serious* pour `yuv`. Quatre runs alternés `rgba` / `yuv` / `rgba` / `yuv`, tous en *serious*, confirment l'avantage du `yuv` en 4K : en HEVC 4K 60 fps, 294–311 frames sur 360 contre 241–261, et 77–90 % d'exact contre 46–48 % en lisant une frame sur quatre. En 1080p et en 30 fps, les écarts restent dans la dispersion entre runs (73 à 95 % d'exact dans les deux formats). Détail dans [FRAME_PIXEL_FORMAT.md](FRAME_PIXEL_FORMAT.md#preview).
55
+
56
+ Les **seeks** tombent juste sur les deux plateformes : 22/22 sur chaque téléphone, y compris à ±0,5 ms d'une limite de frame. Sur Android, un seek en pause montre les frames intermédiaires décodées depuis la keyframe avant la bonne ; l'iPhone garde l'image précédente. Ce comportement n'a pas changé.
57
+
58
+ ## Exports
59
+
60
+ Chaque frame exportée porte son numéro de sortie sous le code-barres source, et est relue après l'export. **Tous les exports sont exacts sur les deux téléphones et dans les deux formats** (30→30, 60→30, 30→60, 24→30, HEVC 60→60, coupe, 4K→4K en 30 et 60 fps, 4K→1080p) : la bonne frame source, aucune frame perdue ou dupliquée, et le décodeur du système compte le bon nombre de frames dans chaque fichier.
61
+
62
+ | Pixel 8a | `yuv` | `rgba` |
63
+ | --- | --- | --- |
64
+ | 4K 60 → 4K 60 | **5,0 s** | 15,6 s |
65
+ | 4K 30 → 4K 30 | **3,2 s** | 8,7 s |
66
+ | 4K 60 → 1080p 30 | **2,4–2,9 s** | 8,0–8,2 s |
67
+
68
+ | iPhone 15 Pro, runs alternés en *serious* | `yuv` | `rgba` |
69
+ | --- | --- | --- |
70
+ | 4K 60 → 4K 60 | 4,2–4,3 s | 4,1–4,5 s |
71
+ | 4K 30 → 4K 30 | 2,3 s | 2,4–2,7 s |
72
+ | HEVC 1080p 60 → 640×360 | 0,9–1,4 s | **0,5 s** |
73
+ | Montage de 120 clips (suite `full`) | 18,1 s | **14,0 s** |
74
+
75
+ Sur iOS, l'export `yuv` importe et convertit chaque frame NV12 au lieu de lire le BGRA en place : environ 2 à 4 ms de plus par frame, sensibles sur les exports longs ou à petite sortie.
76
+
77
+ ## Rendu et couleurs
78
+
79
+ - **Mire SMPTE** (H.264 et HEVC 1080p, Rec.709) comparée à ffmpeg : écart maximal de 0 niveau en `yuv`, 1 en `rgba`, sur les deux téléphones.
80
+ - **Vraie vidéo** (trois clips tirés de photos d'appareil, étiquetés Rec.709) comparée à ffmpeg sur 24 points à trois instants : écart moyen de 0,07 à 0,16 en `yuv` sur les deux téléphones (max 1). En `rgba` : 0,15 à 0,48 sur le Pixel, 0,5 à 0,8 sur l'iPhone (max 5).
81
+ - **Clip étiqueté Display P3** : `yuv` reste à 0,2 de ffmpeg ; `rgba` convertit le gamut (iPhone : moyenne 5,8, max 26 ; Pixel : 1,3, max 16).
82
+ - **Fixtures du benchmark** (rotations, HDR HLG, portrait, SD, slow motion), `yuv` contre `rgba` : écart moyen de 0 à 0,8 niveau. Les maxima ponctuels de 5 à 17 sont sur des bords nets.
83
+ - **Pixel, `interop`** : décodage GPU contre CPU **10/10**, écarts maximaux 1,1,0,0,1,1,0,0,1,1, identiques à la 3.7.0. Export GPU contre readback : écart 0 sur la mire et sur la vidéo.
84
+
85
+ Correction faite pendant la vérification : en NV12, VideoToolbox réétiquetait en BT.709 une vidéo SD codée en BT.601 sans convertir ses échantillons (le bleu d'un jaune décalé de 11 niveaux). Seules les pistes HDR ou BT.2020 reçoivent désormais les propriétés de conversion. Voir [FRAME_PIXEL_FORMAT.md](FRAME_PIXEL_FORMAT.md#pièges-trouvés).
86
+
87
+ ## Suite `full` (65 cas, 1 répétition par format)
88
+
89
+ | | Réussis | Échecs | Arrêtés par le budget | Non exécutés |
90
+ | --- | --- | --- | --- | --- |
91
+ | Pixel `rgba` (26 min, nominal) | 57 | 4 | — | 4 |
92
+ | Pixel `yuv` (24 min, nominal) | **58** | 3 | — | 4 |
93
+ | iPhone `rgba` (17 min, *fair* puis *serious*) | 58 | — | 3 | 4 |
94
+ | iPhone `yuv` (20 min, *nominal* à *serious*) | **61** | — | — | 4 |
95
+
96
+ Les 4 cas non exécutés sont les extensions LUT, compute, Three.js et Core ML, non branchées dans l'app.
97
+
98
+ **Pixel.** Les trois échecs communs aux deux formats existaient déjà dans la beta.2 : le build de `main` (`1eeaa3b`) échoue aux mêmes cas, 2 répétitions sur 2, avec les mêmes symptômes.
99
+
100
+ | Cas | Symptôme, `main` comme beta.3 |
101
+ | --- | --- |
102
+ | `seek-while-playing` | Après un seek en lecture dans une séquence 4K, l'horloge reste vers 4,0 s pendant 4 s |
103
+ | `long-montage-120-clips` | Après un seek en pause dans un montage paresseux de 120 clips, la frame du clip 83 n'arrive pas |
104
+ | `missing-file` | Android 17 répond « Failed to instantiate extractor », que le harness ne reconnaît pas comme une erreur de fichier manquant |
105
+
106
+ Le quatrième échec en `rgba`, `4k-x8-eager`, dépasse le budget mémoire ; il passe en `yuv`.
107
+
108
+ | Pixel, `rgba` → `yuv` | Export | Mémoire max (PSS) |
109
+ | --- | --- | --- |
110
+ | 8 clips 4K, paresseux | 29,0 → **12,9 s** | 1 020 → **766 Mio** |
111
+ | Montage en fondu, eager | 27,3 → **14,4 s** | 1 468 → **1 029 Mio** |
112
+ | 3 clips 4K simultanés | 23,2 → **7,3 s** | 1 314 → 1 507 Mio |
113
+ | Exports simples (`encode-*`) | 2,4–2,6 → **1,7–1,9 s** | ≈ égal |
114
+ | Lecture continue 4K | — | 554–602 → **438–458 Mio** |
115
+
116
+ **iPhone.** En `rgba`, trois cas s'arrêtent sur le budget de la file du décodeur : `montage-all-crossfade-eager`, `4k-x8-eager` et `4k-x3-simultaneous` (problème connu des versions précédentes). **En `yuv`, les trois passent**, et aucun cas n'échoue.
117
+
118
+ | iPhone, `rgba` → `yuv` | Mémoire physique max | Export |
119
+ | --- | --- | --- |
120
+ | Lecture continue 4K | 400–405 → **336–343 Mio** | — |
121
+ | 8 clips 4K, paresseux | 670–683 → **571–573 Mio** | 4,4–4,5 → 4,5–4,9 s |
122
+ | 3 clips 4K simultanés | budget dépassé → **734 Mio, passe** | — |
123
+ | Montage en fondu, paresseux | 650 → **585 Mio** | 4,3 → 3,6 s |
124
+ | 20 clips courts | ≈ | 3,3 → **2,5 s** |
125
+ | Montage de 120 clips | ≈ | **14,0** → 18,1 s |
126
+
127
+ ## Tests natifs
128
+
129
+ - **iPhone, XCTest** : **56/58**, les deux autres étant des diagnostics qui ne tournent qu'à la demande. Six nouveaux tests : chaque frame d'un clip et d'un montage lues en NV12, le format annoncé par chaque frame, et la lecture de `framePixelFormat` (`auto` et `yuv` en NV12, `rgba` en BGRA, valeur inconnue refusée). Les deux diagnostics ont été lancés à part (débit du décodeur par format, étiquettes de couleur des clips sans étiquette).
130
+ - **Pixel, tests instrumentés** : **126/127** dans la suite complète. L'échec, `BigMontageTest.aLazyPreviewOfEight4KClipsPlaysThrough`, figure dans la référence connue (il échouait déjà sur `main` dans la suite complète). Lancée seule juste après, sur un Pixel aux cœurs à 85 °C après des heures de 4K, la classe échoue 2 fois sur 5 : le seuil de 150 frames à l'heure en 4K, et un `OutOfMemoryError` du tas Java après l'export eager de 8 clips 4K. Ces tests pilotent le décodeur Java sans `Looper`, chemin que cette version ne modifie pas. Ils n'ont pas été relancés à froid avant la release : l'attribution à la chaleur n'est pas confirmée.
131
+
132
+ ## Runs écartés
133
+
134
+ - `iphone-full-rgba-interrupted-call` : appel téléphonique pendant le run.
135
+ - `iphone-full-yuv-interrupted-phone-in-use` : téléphone utilisé pendant le run.
136
+ - Les runs `sync` iPhone antérieurs à la correction des couleurs SD et à l'étiquetage forcé des clips photo ne servent pas pour le rendu.
137
+
138
+ Les résultats sont dans `benchmark/results/*.local.json`, fichiers locaux non versionnés.
139
+
140
+ ## Toujours non qualifié
141
+
142
+ - Mémoire sur de longues sessions (dernière mesure en 3.0.6).
143
+ - HDR au-delà de la conversion HLG → SDR, son audible et synchronisation audio/vidéo.
144
+ - Les trois bugs Android de la suite `full` ci-dessus, et le seek dans une composition 4K paresseuse sur Pixel.
145
+ - Vraie vidéo 4K 60 fps à 60 Mbit/s sur iPhone chaud : 65 à 91 % des frames affichées selon les runs.
146
+ - Export iOS en `yuv` : environ 2 à 4 ms de plus par frame qu'en `rgba` (à optimiser).
147
+ - Aucune mesure iPhone à l'état thermique *nominal* pour la comparaison des formats : le téléphone est resté chaud toute la journée.
@@ -24,6 +24,15 @@ struct NativeResourceStats {
24
24
  inline static ResourceCounter encoderSubmittingBuffers;
25
25
  inline static ResourceCounter encoderSubmittingBytes;
26
26
  };
27
+ // Composition preview diagnostics, counted since launch: an acquire refused
28
+ // while the frame ring is full, an acquire that found no decoded frame queued
29
+ // (the decoder not ahead), the decode ticks run, and those over 16 ms.
30
+ struct PreviewStats {
31
+ inline static std::atomic<uint64_t> ringRefusals{0};
32
+ inline static std::atomic<uint64_t> emptyQueues{0};
33
+ inline static std::atomic<uint64_t> decodeTicks{0};
34
+ inline static std::atomic<uint64_t> slowDecodeTicks{0};
35
+ };
27
36
  inline size_t pixelBufferBytes(CVPixelBufferRef buffer) {
28
37
  size_t bytes = CVPixelBufferGetDataSize(buffer);
29
38
  return bytes ? bytes : CVPixelBufferGetBytesPerRow(buffer) *
@@ -16,10 +16,10 @@ namespace RNSkiaVideo {
16
16
  * contrast. Asking AVFoundation for these properties makes it tone-map to
17
17
  * SDR on the way out, on its own fast path.
18
18
  *
19
- * Applied unconditionally rather than only to HDR sources: a source already
20
- * in Rec.709 costs nothing, and a BT.601 one gets the conversion it always
21
- * needed. It also spares the decoders an inspection of the track's transfer
22
- * function before its format descriptions are even loaded.
19
+ * Applied to every BGRA output rather than only to HDR sources: a source
20
+ * already in Rec.709 costs nothing, and a BT.601 one gets the conversion it
21
+ * always needed. NV12 output takes them only for HDR, see
22
+ * TrackNeedsSDRConversion.
23
23
  */
24
24
  static inline NSDictionary* SDRColorProperties() {
25
25
  return @{
@@ -29,6 +29,37 @@ static inline NSDictionary* SDRColorProperties() {
29
29
  };
30
30
  }
31
31
 
32
+ /**
33
+ * Whether a track needs AVFoundation's conversion to Rec.709 even when its
34
+ * frames are decoded to NV12: an HDR transfer function (HLG, PQ) or BT.2020
35
+ * primaries, which only a tone mapping brings to SDR.
36
+ *
37
+ * An SDR track decoded to NV12 is left as it is: its buffers carry their own
38
+ * YCbCr matrix, which the GPU applies when it converts them. Asked for Rec.709
39
+ * properties, VideoToolbox relabels an SD clip's BT.601 samples as BT.709
40
+ * without converting them, and its saturated colors shift (a yellow's blue
41
+ * by 11 levels), where its BGRA output does convert.
42
+ */
43
+ static inline bool TrackNeedsSDRConversion(AVAssetTrack* track) {
44
+ #pragma clang diagnostic push
45
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
46
+ NSArray* descriptions = track.formatDescriptions;
47
+ #pragma clang diagnostic pop
48
+ for (id description in descriptions) {
49
+ auto format = (__bridge CMFormatDescriptionRef)description;
50
+ CFTypeRef transfer = CMFormatDescriptionGetExtension(
51
+ format, kCMFormatDescriptionExtension_TransferFunction);
52
+ CFTypeRef primaries = CMFormatDescriptionGetExtension(
53
+ format, kCMFormatDescriptionExtension_ColorPrimaries);
54
+ if (transfer && (CFEqual(transfer, kCVImageBufferTransferFunction_ITU_R_2100_HLG) ||
55
+ CFEqual(transfer, kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ)))
56
+ return true;
57
+ if (primaries && CFEqual(primaries, kCVImageBufferColorPrimaries_ITU_R_2020))
58
+ return true;
59
+ }
60
+ return false;
61
+ }
62
+
32
63
  /**
33
64
  * Stamps Rec.709 onto a buffer handed to AVAssetWriter. The writer's own
34
65
  * output settings already declare it, but a buffer carrying no color
@@ -276,6 +276,10 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
276
276
  add("encoders", NativeResourceStats::encoders);
277
277
  add("encoderSubmittingBuffers", NativeResourceStats::encoderSubmittingBuffers);
278
278
  add("encoderSubmittingBytes", NativeResourceStats::encoderSubmittingBytes);
279
+ result.setProperty(rt, "previewRingRefusals", static_cast<double>(PreviewStats::ringRefusals.load()));
280
+ result.setProperty(rt, "previewEmptyQueues", static_cast<double>(PreviewStats::emptyQueues.load()));
281
+ result.setProperty(rt, "previewDecodeTicks", static_cast<double>(PreviewStats::decodeTicks.load()));
282
+ result.setProperty(rt, "previewSlowDecodeTicks", static_cast<double>(PreviewStats::slowDecodeTicks.load()));
279
283
  return jsi::Value(std::move(result));
280
284
  }));
281
285
  RNSVModule.setProperty(runtime, "getBackendInfo",
@@ -31,6 +31,11 @@ public:
31
31
  * default) does. iOS only.
32
32
  */
33
33
  bool directTexture = false;
34
+ /**
35
+ * The composition's `framePixelFormat: 'yuv'`: frames decoded to NV12, the
36
+ * decoder's own format, rather than BGRA. See setupReader.
37
+ */
38
+ bool yuvFrames = false;
34
39
  bool isVideo = true;
35
40
  bool audioEnabled = false;
36
41
  double audioVolume = 1.0;
@@ -61,6 +66,20 @@ public:
61
66
  auto lazyProp = jsComposition.getProperty(runtime, "lazyDecoders");
62
67
  composition->lazyDecoders = lazyProp.isBool() && lazyProp.getBool();
63
68
  }
69
+ // 'auto' is NV12 on iOS, as on Android: a third of BGRA's memory, and the
70
+ // same picture for camera footage (docs/FRAME_PIXEL_FORMAT.md).
71
+ bool yuvFrames = true;
72
+ if (jsComposition.hasProperty(runtime, "framePixelFormat")) {
73
+ auto formatProp = jsComposition.getProperty(runtime, "framePixelFormat");
74
+ if (formatProp.isString()) {
75
+ auto format = formatProp.asString(runtime).utf8(runtime);
76
+ if (format != "auto" && format != "yuv" && format != "rgba")
77
+ throw jsi::JSError(runtime, "framePixelFormat must be 'auto', 'yuv' or 'rgba'");
78
+ yuvFrames = format != "rgba";
79
+ } else if (!formatProp.isUndefined()) {
80
+ throw jsi::JSError(runtime, "framePixelFormat must be 'auto', 'yuv' or 'rgba'");
81
+ }
82
+ }
64
83
  auto jsItems = jsComposition.getProperty(runtime, "items")
65
84
  .asObject(runtime)
66
85
  .asArray(runtime);
@@ -81,6 +100,7 @@ public:
81
100
  item->duration = checkedMediaSeconds(jsItem.getProperty(runtime, "duration").asNumber());
82
101
  checkedMediaSeconds(item->startTime + item->duration);
83
102
  checkedMediaSeconds(item->compositionStartTime + item->duration);
103
+ item->yuvFrames = yuvFrames;
84
104
  item->resolution = CGSize();
85
105
  if (jsItem.hasProperty(runtime, "resolution")) {
86
106
  auto resProp = jsItem.getProperty(runtime, "resolution");
@@ -71,6 +71,10 @@ private:
71
71
  RNSVDisplayLinkWrapper* displayLink;
72
72
  NSDate* startDate;
73
73
  CMTime pausePosition = kCMTimeZero;
74
+ // The clock decodeCompositionFrames last picked the frames at, and when
75
+ // (CACurrentMediaTime); invalid once play, pause or a seek moves the clock.
76
+ CMTime framesTime = kCMTimeInvalid;
77
+ CFTimeInterval framesTimeHost = 0;
74
78
  bool playWhenReady = false;
75
79
  bool isPlaying = false;
76
80
  bool isLooping = false;
@@ -91,6 +95,7 @@ private:
91
95
  void pause();
92
96
  void seekTo(CMTime time);
93
97
  CMTime getCurrentTime();
98
+ CMTime getPresentedTime();
94
99
  void release();
95
100
  bool opensAt(const std::shared_ptr<VideoCompositionItem>& item,
96
101
  double position) const;
@@ -1,6 +1,7 @@
1
1
  #include "VideoCompositionFramesExtractorHostObject.h"
2
2
 
3
3
  #import "AVAssetTrackUtils.h"
4
+ #import "NativeResourceStats.h"
4
5
  #import "AudioCompositionUtils.h"
5
6
  #import "RNSVJSIUtils.h"
6
7
  #include "RNSVCheckedSizes.h"
@@ -117,6 +118,8 @@ jsi::Value VideoCompositionFramesExtractorHostObject::get(
117
118
  }
118
119
  if (initialized && lastAppliedSeekGeneration == seekGeneration) {
119
120
  auto currentTime = getCurrentTime();
121
+ framesTime = currentTime;
122
+ framesTimeHost = CACurrentMediaTime();
120
123
  bool changed = false;
121
124
  for (const auto& entry : itemDecoders) {
122
125
  auto itemId = entry.first;
@@ -189,7 +192,7 @@ jsi::Value VideoCompositionFramesExtractorHostObject::get(
189
192
  return jsi::Value::undefined();
190
193
  });
191
194
  } else if (propName == "currentTime") {
192
- return jsi::Value(released.test() ? 0 : CMTimeGetSeconds(getCurrentTime()));
195
+ return jsi::Value(released.test() ? 0 : CMTimeGetSeconds(getPresentedTime()));
193
196
  } else if (propName == "framesVersion") {
194
197
  return jsi::Value(released.test() ? 0 : (double)framesVersion);
195
198
  } else if (propName == "isLooping") {
@@ -218,8 +221,12 @@ void VideoCompositionFramesExtractorHostObject::set(
218
221
  void VideoCompositionFramesExtractorHostObject::prepare() {
219
222
  @synchronized(lock) {
220
223
  if (released.test() || decoderQueue) return;
224
+ // User-interactive: the queue feeds the display at every vsync. At utility,
225
+ // a warm iPhone parked it on the efficiency cores: 60 fps clips froze for
226
+ // 300-500 ms at a time while the decoder caught up, and a 4K 60 fps preview
227
+ // showed one frame in six.
221
228
  dispatch_queue_attr_t attr = dispatch_queue_attr_make_with_qos_class(
222
- DISPATCH_QUEUE_SERIAL, QOS_CLASS_UTILITY, 0);
229
+ DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INTERACTIVE, 0);
223
230
  decoderQueue = dispatch_queue_create("ReactNativeVideoCompositionItemDecoder", attr);
224
231
  dispatch_queue_set_specific(decoderQueue, this, this, NULL);
225
232
  std::weak_ptr<VideoCompositionFramesExtractorHostObject> weak =
@@ -252,7 +259,10 @@ void VideoCompositionFramesExtractorHostObject::scheduleDecode() {
252
259
  std::atomic<bool>& flag;
253
260
  ~PendingGuard() { flag.store(false); }
254
261
  } pendingGuard{owner->decoderTickPending};
262
+ CFTimeInterval tickStart = CACurrentMediaTime();
255
263
  owner->decodeTick();
264
+ PreviewStats::decodeTicks++;
265
+ if (CACurrentMediaTime() - tickStart > 0.016) PreviewStats::slowDecodeTicks++;
256
266
  }
257
267
  // A seek arriving during decoding was coalesced into this task. Queue
258
268
  // its latest position after releasing the pending flag, so it cannot
@@ -453,6 +463,7 @@ void VideoCompositionFramesExtractorHostObject::init() {
453
463
  void VideoCompositionFramesExtractorHostObject::play() {
454
464
  @synchronized(lock) {
455
465
  if (released.test() || isPlaying) return;
466
+ framesTime = kCMTimeInvalid;
456
467
  // A completed paused clock stays at the end until play explicitly restarts
457
468
  // it. Rewind the readers through the same serial seek generation as seekTo.
458
469
  if (CMTimeGetSeconds(pausePosition) >= composition->duration) {
@@ -480,6 +491,7 @@ void VideoCompositionFramesExtractorHostObject::pause() {
480
491
  }
481
492
  pausePosition = getCurrentTime();
482
493
  isPlaying = false;
494
+ framesTime = kCMTimeInvalid;
483
495
  if (audioPlayer) {
484
496
  [audioPlayer pause];
485
497
  }
@@ -490,6 +502,7 @@ void VideoCompositionFramesExtractorHostObject::seekTo(CMTime time) {
490
502
  @synchronized(lock) {
491
503
  if (released.test()) return;
492
504
  seekPending = true;
505
+ framesTime = kCMTimeInvalid;
493
506
  if (isPlaying) {
494
507
  startDate = [NSDate dateWithTimeIntervalSinceNow:-CMTimeGetSeconds(time)];
495
508
  } else {
@@ -594,6 +607,22 @@ void VideoCompositionFramesExtractorHostObject::openDecoders(
594
607
  }
595
608
  }
596
609
 
610
+ // The time drawFrame draws at: the clock the frames it gets were picked at,
611
+ // rather than the clock when it reads the time, after the frames' import (a
612
+ // few milliseconds of GPU work). Read later, the time ran ahead of the frames,
613
+ // and at 60 fps a frame's start could fall in between on every frame: the
614
+ // time said frame n while the frames held n - 1. The live clock once play,
615
+ // pause or a seek has moved it, or without a recent pick (no preview).
616
+ CMTime VideoCompositionFramesExtractorHostObject::getPresentedTime() {
617
+ @synchronized(lock) {
618
+ if (isPlaying && CMTIME_IS_VALID(framesTime) &&
619
+ CACurrentMediaTime() - framesTimeHost < 0.1) {
620
+ return framesTime;
621
+ }
622
+ return getCurrentTime();
623
+ }
624
+ }
625
+
597
626
  CMTime VideoCompositionFramesExtractorHostObject::getCurrentTime() {
598
627
  @synchronized(lock) {
599
628
  if (isPlaying) {
@@ -123,13 +123,24 @@ void VideoCompositionItemDecoder::setupReader(CMTime initialTime) {
123
123
  // AVAssetReaderTrackOutput takes pixel buffer attributes and video settings
124
124
  // in the same dictionary, so the color properties travel with them: an HDR
125
125
  // track is tone-mapped to Rec.709 by AVFoundation before we ever see it
126
- // (see RNSVColorSpace.h).
127
- NSDictionary* pixBuffAttributes = @{
128
- (id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA),
126
+ // (see RNSVColorSpace.h), in either format.
127
+ //
128
+ // NV12 is the decoder's own format, 1.5 bytes a pixel against BGRA's 4: the
129
+ // queue's byte budget then holds five 4K frames ahead rather than one or
130
+ // two. The GPU converts it to RGB when the frame is drawn (yuvBlit.ts),
131
+ // with the matrix each buffer carries; only HDR needs AVFoundation's
132
+ // conversion first (see TrackNeedsSDRConversion). BGRA is converted by
133
+ // VideoToolbox, and a GPU export samples it in place.
134
+ NSMutableDictionary* pixBuffAttributes = [@{
135
+ (id)kCVPixelBufferPixelFormatTypeKey :
136
+ @(item->yuvFrames ? kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
137
+ : kCVPixelFormatType_32BGRA),
129
138
  (id)kCVPixelBufferIOSurfacePropertiesKey : @{},
130
139
  (id)kCVPixelBufferMetalCompatibilityKey : @YES,
131
- AVVideoColorPropertiesKey : SDRColorProperties(),
132
- };
140
+ } mutableCopy];
141
+ if (!item->yuvFrames || TrackNeedsSDRConversion(videoTrack)) {
142
+ pixBuffAttributes[AVVideoColorPropertiesKey] = SDRColorProperties();
143
+ }
133
144
  CGSize resolution = item->resolution;
134
145
  /*
135
146
  * No explicit size asked for, but a cap on the longest side: scale the
@@ -156,8 +167,6 @@ void VideoCompositionItemDecoder::setupReader(CMTime initialTime) {
156
167
  }
157
168
  }
158
169
  if (resolution.width > 0 && resolution.height > 0) {
159
- pixBuffAttributes =
160
- [NSMutableDictionary dictionaryWithDictionary:pixBuffAttributes];
161
170
  [pixBuffAttributes setValue:@(resolution.width)
162
171
  forKey:(id)kCVPixelBufferWidthKey];
163
172
  [pixBuffAttributes setValue:@(resolution.height)
@@ -333,7 +342,10 @@ void VideoCompositionItemDecoder::advanceDecoder(CMTime currentTime) {
333
342
  std::shared_ptr<VideoFrame>
334
343
  VideoCompositionItemDecoder::acquireFrameForTime(CMTime currentTime,
335
344
  bool force) {
336
- if (!frameRing.canAcquire()) return nullptr;
345
+ if (!frameRing.canAcquire()) {
346
+ PreviewStats::ringRefusals++;
347
+ return nullptr;
348
+ }
337
349
  CMSampleBufferRef nextFrame = nil;
338
350
  // advanceDecoder appends to the frame lists from a decoding thread while
339
351
  // this runs on the UI thread: every access to the lists goes through the
@@ -377,6 +389,7 @@ VideoCompositionItemDecoder::acquireFrameForTime(CMTime currentTime,
377
389
  break;
378
390
  }
379
391
  }
392
+ if (!nextFrame && decodedFrames.empty()) PreviewStats::emptyQueues++;
380
393
  }
381
394
  if (nextFrame) {
382
395
  CVPixelBufferRef buffer = CMSampleBufferGetImageBuffer(nextFrame);
package/ios/VideoFrame.mm CHANGED
@@ -101,6 +101,12 @@ jsi::Value VideoFrame::get(jsi::Runtime& runtime,
101
101
  descriptor.setProperty(runtime, "kind",
102
102
  jsi::String::createFromAscii(runtime, "native-buffer"));
103
103
  descriptor.setProperty(runtime, "nativeBuffer", pointer);
104
+ // Read without importing the buffer: NV12 frames are converted to RGB on
105
+ // the GPU, BGRA ones sampled as they are.
106
+ bool nv12 = CVPixelBufferGetPixelFormatType(pixelBuffer) ==
107
+ kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
108
+ descriptor.setProperty(runtime, "format",
109
+ jsi::String::createFromAscii(runtime, nv12 ? "nv12" : "bgra8"));
104
110
  return descriptor;
105
111
  }
106
112
  return jsi::Value::undefined();
@@ -5,14 +5,14 @@ import { Platform } from "react-native";
5
5
  import { BlendMode, Skia } from "react-native-skia";
6
6
  import { createNativeVideoGpuFrame, getVideoGpuDevice, nativeVideoTextureUsage } from "./gpuDevice.js";
7
7
  import { frameByteSize, releaseVideoMemory, reserveVideoMemory } from "./memory.js";
8
- import { blitYuvFrame, releaseYuvImports, yuvFrameOrigin } from "./yuvBlit.js";
8
+ import { blitNv12Frame, blitYuvFrame, releaseYuvImports, yuvFrameOrigin } from "./yuvBlit.js";
9
9
 
10
- /** A decoded frame sampled in place, without an owned snapshot: on iOS its
11
- * IOSurface, on Android its producer's RGBA texture, which the decoder
12
- * buffer was just converted into. The decoder lease stays open while the
13
- * image is in use. */
10
+ /** A decoded frame sampled in place, without an owned snapshot: a BGRA
11
+ * frame's IOSurface on iOS, or for a YUV frame (Android, iOS NV12) its
12
+ * producer's RGBA texture, which the decoder buffer was just converted into.
13
+ * The decoder lease stays open while the image is in use. */
14
14
 
15
- /** Android: the texture a producer's decoded frames are converted into. */
15
+ /** The texture a producer's YUV frames are converted into. */
16
16
 
17
17
  /** Per export session, keyed by producer. `enabled` turns off after a first
18
18
  * failed import, before any frame was sampled in place. */
@@ -65,8 +65,8 @@ export const releaseExportFrame = entry => {
65
65
  entry.frame.dispose?.();
66
66
  };
67
67
 
68
- /** Android: releases a producer's texture and decoder buffer imports. Call
69
- * only once its last frame's GPU work has completed. */
68
+ /** Releases a producer's texture and decoder buffer imports. Call only once
69
+ * its last frame's GPU work has completed. */
70
70
  const releaseProducerTexture = (imports, producer) => {
71
71
  "worklet";
72
72
 
@@ -79,10 +79,11 @@ const releaseProducerTexture = (imports, producer) => {
79
79
  }
80
80
  };
81
81
 
82
- /** Android: converts a decoded ImageReader frame into its producer's RGBA
83
- * texture, wrapped as a Skia image. The conversion is submitted ahead of the
84
- * frame's drawing, on the same queue; the export's checked flush waits for
85
- * both before the lease or the texture is reused. */
82
+ /** Converts a decoded YUV frame (an Android ImageReader buffer, or an iOS
83
+ * NV12 one) into its producer's RGBA texture, wrapped as a Skia image. The
84
+ * conversion is submitted ahead of the frame's drawing, on the same queue;
85
+ * the export's checked flush waits for both before the lease or the texture
86
+ * is reused. */
86
87
  const importYuvExportFrame = (imports, frame) => {
87
88
  "worklet";
88
89
 
@@ -102,7 +103,13 @@ const importYuvExportFrame = (imports, frame) => {
102
103
  try {
103
104
  entry.nativeFrame = createNativeVideoGpuFrame(source.nativeBuffer);
104
105
  const rotation = source.rotation ?? 0;
105
- const origin = yuvFrameOrigin(source.region, rotation, entry.nativeFrame, frame);
106
+ // iOS NV12: the whole buffer, in decoded orientation.
107
+ const nv12 = source.format === "nv12";
108
+ if (nv12 && (entry.nativeFrame.width !== frame.width || entry.nativeFrame.height !== frame.height)) throw new Error("Native video buffer dimensions mismatch");
109
+ const origin = nv12 ? {
110
+ x: 0,
111
+ y: 0
112
+ } : yuvFrameOrigin(source.region, rotation, entry.nativeFrame, frame);
106
113
  const device = getVideoGpuDevice();
107
114
  target = imports.textures.get(producer);
108
115
  if (target && (target.texture.width !== frame.width || target.texture.height !== frame.height)) {
@@ -134,7 +141,7 @@ const importYuvExportFrame = (imports, frame) => {
134
141
  }
135
142
  // Can throw after submitting: drain below before giving the lease back.
136
143
  submitted = true;
137
- blitYuvFrame(device, imports.yuv, producer, entry.nativeFrame, rotation, origin, frame.width, frame.height, target.texture);
144
+ if (nv12) blitNv12Frame(device, entry.nativeFrame, target.texture);else blitYuvFrame(device, imports.yuv, producer, entry.nativeFrame, rotation, origin, frame.width, frame.height, target.texture);
138
145
  entry.image = Skia.Image.MakeImageFromGPUTexture(target.texture);
139
146
  if (!entry.image) throw new Error("Cannot wrap the decoded frame");
140
147
  return entry;
@@ -158,13 +165,13 @@ const importYuvExportFrame = (imports, frame) => {
158
165
  };
159
166
 
160
167
  /** Wraps a decoded BGRA CVPixelBuffer's IOSurface as a Skia image, read-only.
161
- * The decoder already finished writing it; no producer fence is needed. On
162
- * Android, converts the decoded YUV frame instead (see importYuvExportFrame). */
168
+ * The decoder already finished writing it; no producer fence is needed. A
169
+ * YUV frame (Android, iOS NV12) is converted instead (see importYuvExportFrame). */
163
170
  export const importExportFrame = (frame, imports) => {
164
171
  "worklet";
165
172
 
166
- if (convertsYuv) {
167
- if (!imports) throw new Error("Android in-place frames need their imports");
173
+ if (convertsYuv || frame.texture.format === "nv12") {
174
+ if (!imports) throw new Error("YUV in-place frames need their imports");
168
175
  return importYuvExportFrame(imports, frame);
169
176
  }
170
177
  const entry = {
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","BlendMode","Skia","createNativeVideoGpuFrame","getVideoGpuDevice","nativeVideoTextureUsage","frameByteSize","releaseVideoMemory","reserveVideoMemory","blitYuvFrame","releaseYuvImports","yuvFrameOrigin","convertsYuv","OS","createExportFrameImports","entries","Map","producers","Set","enabled","imported","textures","yuv","canImportInPlace","frame","texture","kind","id","undefined","region","releaseExportFrame","entry","image","dispose","accessing","memory","ended","endAccess","state","fences","fence","destroy","nativeFrame","release","releaseProducerTexture","imports","producer","target","get","reservation","delete","importYuvExportFrame","producerId","source","submitted","nativeBuffer","rotation","origin","device","width","height","createTexture","size","format","usage","label","error","set","Image","MakeImageFromGPUTexture","Error","drain","Surface","MakeFromGPUTexture","getCanvas","drawColor","Color","Clear","flush","importExportFrame","pixelFormat","importSharedTextureMemory","handle","beginAccess","releaseExportFrames","keys","ownExportFrames","decoded","fallback","owned","held","current","key","Object","seen","next","console","warn","String","add","aliases","WeakSet","has","crop","values","rest","copying"],"sourceRoot":"../../src","sources":["exportFrames.ts"],"mappings":";;AAAA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,SAAS,EAAEC,IAAI,QAAQ,mBAAmB;AAOnD,SACEC,yBAAyB,EACzBC,iBAAiB,EACjBC,uBAAuB,QAClB,gBAAa;AACpB,SACEC,aAAa,EACbC,kBAAkB,EAClBC,kBAAkB,QACb,aAAU;AAEjB,SAASC,YAAY,EAAEC,iBAAiB,EAAEC,cAAc,QAAQ,cAAW;;AAG3E;AACA;AACA;AACA;;AAaA;;AAGA;AACA;;AA0BA;AACA;AACA,MAAMC,WAAW,GAAGZ,QAAQ,CAACa,EAAE,KAAK,SAAS;AAE7C,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAA0B;EAChE,SAAS;;EACT,OAAO;IACLC,OAAO,EAAE,IAAIC,GAAG,CAAC,CAAC;IAClBC,SAAS,EAAE,IAAIC,GAAG,CAAC,CAAC;IACpBC,OAAO,EAAE,IAAI;IACbC,QAAQ,EAAE,KAAK;IACfC,QAAQ,EAAE,IAAIL,GAAG,CAAC,CAAC;IACnBM,GAAG,EAAE,IAAIN,GAAG,CAAC;EACf,CAAC;AACH,CAAC;;AAED;AACA,OAAO,MAAMO,gBAAgB,GAAIC,KAAiB,IAAc;EAC9D,SAAS;;EACT,MAAMC,OAAO,GAAGD,KAAK,CAACC,OAAiD;EACvE,OACEA,OAAO,EAAEC,IAAI,KAAK,eAAe,IACjCF,KAAK,CAACG,EAAE,KAAKC,SAAS,KACrB,CAAChB,WAAW,IAAIa,OAAO,CAACI,MAAM,KAAKD,SAAS,CAAC;AAElD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAME,kBAAkB,GAAIC,KAAwB,IAAW;EACpE,SAAS;;EACTA,KAA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AO,CAACiC,GAAG,CAACF,QAAQ,CAAC;MACpE,IAAIf,KAAK,IAAIA,KAAK,CAACJ,EAAE,KAAKH,KAAK,CAACG,EAAE,EAAE;MACpC,IAAI;QACFH,KAAK,CAACS,OAAO,GAAG,CAAC;MACnB,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;IACA,MAAMiC,KAAK;EACb;EACA;EACA,MAAMuC,IAAgC,GAAG,CAAC,CAAC;EAC3C,IAAIC,OAAO,GAAG,KAAK;EACnB,KAAK,MAAM,CAACd,GAAG,EAAEpE,KAAK,CAAC,IAAIqE,MAAM,CAAC9E,OAAO,CAACwE,OAAO,CAAC,EAAE;IAClD,IAAIG,IAAI,CAACY,GAAG,CAAC9E,KAAK,CAAC,EAAE;IACrBiF,IAAI,CAACb,GAAG,CAAC,GAAGpE,KAAK;IACjBkF,OAAO,GAAG,IAAI;EAChB;EACA,OAAOA,OAAO,GAAG;IAAE,GAAGjB,KAAK;IAAE,GAAGD,QAAQ,CAACiB,IAAI;EAAE,CAAC,GAAGhB,KAAK;AAC1D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Platform","BlendMode","Skia","createNativeVideoGpuFrame","getVideoGpuDevice","nativeVideoTextureUsage","frameByteSize","releaseVideoMemory","reserveVideoMemory","blitNv12Frame","blitYuvFrame","releaseYuvImports","yuvFrameOrigin","convertsYuv","OS","createExportFrameImports","entries","Map","producers","Set","enabled","imported","textures","yuv","canImportInPlace","frame","texture","kind","id","undefined","region","releaseExportFrame","entry","image","dispose","accessing","memory","ended","endAccess","state","fences","fence","destroy","nativeFrame","release","releaseProducerTexture","imports","producer","target","get","reservation","delete","importYuvExportFrame","producerId","source","submitted","nativeBuffer","rotation","nv12","format","width","height","Error","origin","x","y","device","createTexture","size","usage","label","error","set","Image","MakeImageFromGPUTexture","drain","Surface","MakeFromGPUTexture","getCanvas","drawColor","Color","Clear","flush","importExportFrame","pixelFormat","importSharedTextureMemory","handle","beginAccess","releaseExportFrames","keys","ownExportFrames","decoded","fallback","owned","held","current","key","Object","seen","next","console","warn","String","add","aliases","WeakSet","has","crop","values","rest","copying"],"sourceRoot":"../../src","sources":["exportFrames.ts"],"mappings":";;AAAA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,SAAS,EAAEC,IAAI,QAAQ,mBAAmB;AAOnD,SACEC,yBAAyB,EACzBC,iBAAiB,EACjBC,uBAAuB,QAClB,gBAAa;AACpB,SACEC,aAAa,EACbC,kBAAkB,EAClBC,kBAAkB,QACb,aAAU;AAEjB,SACEC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,cAAc,QACT,cAAW;;AAGlB;AACA;AACA;AACA;;AAaA;;AAGA;AACA;;AA4BA;AACA;AACA,MAAMC,WAAW,GAAGb,QAAQ,CAACc,EAAE,KAAK,SAAS;AAE7C,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAA0B;EAChE,SAAS;;EACT,OAAO;IACLC,OAAO,EAAE,IAAIC,GAAG,CAAC,CAAC;IAClBC,SAAS,EAAE,IAAIC,GAAG,CAAC,CAAC;IACpBC,OAAO,EAAE,IAAI;IACbC,QAAQ,EAAE,KAAK;IACfC,QAAQ,EAAE,IAAIL,GAAG,CAAC,CAAC;IACnBM,GAAG,EAAE,IAAIN,GAAG,CAAC;EACf,CAAC;AACH,CAAC;;AAED;AACA,OAAO,MAAMO,gBAAgB,GAAIC,KAAiB,IAAc;EAC9D,SAAS;;EACT,MAAMC,OAAO,GAAGD,KAAK,CAACC,OAAiD;EACvE,OACEA,OAAO,EAAEC,IAAI,KAAK,eAAe,IACjCF,KAAK,CAACG,EAAE,KAAKC,SAAS,KACrB,CAAChB,WAAW,IAAIa,OAAO,CAACI,MAAM,KAAKD,SAAS,CAAC;AAElD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAME,kBAAkB,GAAIC,KAAwB,IAAW;EACpE,SAAS;;EACTA,KAAK,CAACC,KAAK,EAAEC,OAAO,CAAC,CAAC;EACtBF,KAAK,CA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