Preview image versions before sending, and repair unheard chunks
Send sheet: opens on what recipients will see (the encoded photo decoded on this device) instead of the original. "Try another version" encodes the whole photo again with a near-invisible zoom/shift; the generative decoder reconstructs each version differently, and on Kodak the best of three raised CLIP agreement from 0.828 to 0.853. The user picks the version to send; packet count and airtime follow the selection. Version 1 is byte-identical to the previous encode, so the wire format is unchanged. The sender's bubble shows the chosen version and carries the AI-reconstructed label. Repeater echoes: the raw RX log handler now decrypts GRP_DATA as well as GRP_TXT and counts repeaters re-flooding each chunk of our own images. The bubble shows the repeat count like channel text, and Packet info lists each packet. About 15 s after sending, chunks no repeater echoed are resent once, but only when another chunk of the same image was echoed, so senders with no repeater in earshot do not double their airtime. Outgoing entries now record their payload size.
This commit is contained in:
1 parent
aafd541b0f
commit
53e4e457ca
36 files changed
+2366
-150
No files matched your search
@@ -197,13 +197,30 @@ class ReceivedImageEntry {
|
||||
/// One chunk was rebuilt from the XOR parity chunk.
|
||||
final bool recoveredWithParity;
|
||||
|
||||
/// This is the local user's own send. Its PNG is their real 512x512 crop, so
|
||||
/// [synthesized] is false and the R6 label must NOT be shown.
|
||||
/// This is the local user's own send.
|
||||
final bool isOutgoing;
|
||||
|
||||
/// Whether the pixels are generative-model output. Derived, never supplied:
|
||||
/// `synthesized == !isOutgoing`.
|
||||
bool get synthesized => !isOutgoing;
|
||||
/// Whether the pixels are generative-model output, so the R6 label must be
|
||||
/// shown. Always true for received images. For the user's own send it is
|
||||
/// true when the PNG is the version they picked, decoded as recipients see
|
||||
/// it, and false only when it is the stretched original (a device that
|
||||
/// could not decode).
|
||||
final bool synthesized;
|
||||
|
||||
/// Our own image only: repeater echoes heard for each chunk, data chunks
|
||||
/// first and the parity chunk last. Null when not tracked.
|
||||
final List<int>? chunkEchoes;
|
||||
|
||||
/// The fewest echoes any data chunk got: every data chunk was heard
|
||||
/// repeated at least this many times. Null when not tracked.
|
||||
int? get minDataChunkEchoes {
|
||||
final echoes = chunkEchoes;
|
||||
if (echoes == null || echoes.isEmpty) return null;
|
||||
final data = echoes.length > totalChunks
|
||||
? echoes.sublist(0, totalChunks)
|
||||
: echoes;
|
||||
return data.reduce((a, b) => a < b ? a : b);
|
||||
}
|
||||
|
||||
final int? decodeMs;
|
||||
final String? error;
|
||||
@@ -237,6 +254,8 @@ class ReceivedImageEntry {
|
||||
this.metadataAssumed = true,
|
||||
this.recoveredWithParity = false,
|
||||
this.isOutgoing = false,
|
||||
bool? synthesized,
|
||||
this.chunkEchoes,
|
||||
this.decodeMs,
|
||||
this.error,
|
||||
this.needsManualDecode = false,
|
||||
@@ -245,7 +264,7 @@ class ReceivedImageEntry {
|
||||
this.bitstreamByteCount = 0,
|
||||
this.pngByteCount = 0,
|
||||
this.pngBytes,
|
||||
});
|
||||
}) : synthesized = synthesized ?? !isOutgoing;
|
||||
|
||||
ImageStreamKey get key => ImageStreamKey(
|
||||
senderPrefix: senderPrefix,
|
||||
@@ -282,6 +301,7 @@ class ReceivedImageEntry {
|
||||
int? bitstreamByteCount,
|
||||
int? pngByteCount,
|
||||
Object? pngBytes = _unset,
|
||||
List<int>? chunkEchoes,
|
||||
}) {
|
||||
return ReceivedImageEntry(
|
||||
streamId: streamId,
|
||||
@@ -299,6 +319,8 @@ class ReceivedImageEntry {
|
||||
metadataAssumed: metadataAssumed ?? this.metadataAssumed,
|
||||
recoveredWithParity: recoveredWithParity ?? this.recoveredWithParity,
|
||||
isOutgoing: isOutgoing,
|
||||
synthesized: synthesized,
|
||||
chunkEchoes: chunkEchoes ?? this.chunkEchoes,
|
||||
decodeMs: identical(decodeMs, _unset) ? this.decodeMs : decodeMs as int?,
|
||||
error: identical(error, _unset) ? this.error : error as String?,
|
||||
needsManualDecode: needsManualDecode ?? this.needsManualDecode,
|
||||
@@ -329,6 +351,7 @@ class ReceivedImageEntry {
|
||||
'recoveredWithParity': recoveredWithParity,
|
||||
'isOutgoing': isOutgoing,
|
||||
'synthesized': synthesized,
|
||||
if (chunkEchoes != null) 'chunkEchoes': chunkEchoes,
|
||||
'needsManualDecode': needsManualDecode,
|
||||
'bitstreamStored': bitstreamStored,
|
||||
'pngStored': pngStored,
|
||||
@@ -357,6 +380,10 @@ class ReceivedImageEntry {
|
||||
metadataAssumed: json['metadataAssumed'] as bool? ?? true,
|
||||
recoveredWithParity: json['recoveredWithParity'] as bool? ?? false,
|
||||
isOutgoing: json['isOutgoing'] as bool? ?? false,
|
||||
synthesized: json['synthesized'] as bool?,
|
||||
chunkEchoes: (json['chunkEchoes'] as List<dynamic>?)
|
||||
?.whereType<int>()
|
||||
.toList(),
|
||||
decodeMs: json['decodeMs'] as int?,
|
||||
error: json['error'] as String?,
|
||||
needsManualDecode: json['needsManualDecode'] as bool? ?? false,
|
||||
@@ -1041,6 +1068,9 @@ class ReceivedImageStore extends ChangeNotifier {
|
||||
required AeicRatePoint rate,
|
||||
required int chunkCount,
|
||||
int aspectCode = 0,
|
||||
bool synthesized = false,
|
||||
List<int>? chunkEchoes,
|
||||
int payloadBytes = 0,
|
||||
DateTime? at,
|
||||
}) async {
|
||||
final now = at ?? _clock();
|
||||
@@ -1069,6 +1099,11 @@ class ReceivedImageStore extends ChangeNotifier {
|
||||
aspectCode: aspectCode,
|
||||
metadataAssumed: false,
|
||||
isOutgoing: true,
|
||||
synthesized: synthesized,
|
||||
chunkEchoes: chunkEchoes,
|
||||
// The size of what was sent, for the caption and packet info. The
|
||||
// bitstream itself is not kept, so bitstreamStored stays false.
|
||||
bitstreamByteCount: payloadBytes,
|
||||
pngStored: pngWritten,
|
||||
pngByteCount: pngWritten ? previewPng.length : 0,
|
||||
pngBytes: previewPng,
|
||||
@@ -1078,6 +1113,31 @@ class ReceivedImageStore extends ChangeNotifier {
|
||||
return stored;
|
||||
}
|
||||
|
||||
/// Records repeater echoes of the user's own image (see
|
||||
/// `MeshCoreConnector.ownImageEchoes`). Echoes that land before the image is
|
||||
/// registered are passed to [registerOutgoing] instead.
|
||||
Future<void> setOutgoingEchoes({
|
||||
required int channelIndex,
|
||||
required int senderPrefix,
|
||||
required int imgId,
|
||||
required List<int> echoes,
|
||||
}) async {
|
||||
ReceivedImageEntry? match;
|
||||
for (final entry in _entries.values) {
|
||||
if (!entry.isOutgoing ||
|
||||
entry.imgId != imgId ||
|
||||
entry.channelIndex != channelIndex ||
|
||||
entry.senderPrefix != senderPrefix) {
|
||||
continue;
|
||||
}
|
||||
if (match == null || entry.firstSeen.isAfter(match.firstSeen)) {
|
||||
match = entry;
|
||||
}
|
||||
}
|
||||
if (match == null) return;
|
||||
await _store(match.copyWith(chunkEchoes: List<int>.unmodifiable(echoes)));
|
||||
}
|
||||
|
||||
// ---- decode scheduling ---------------------------------------------------
|
||||
|
||||
/// App lifecycle gate. Backgrounding cancels an in-flight decode and returns
|
||||
|
||||
Reference in new issue
Block a user