encodeAvif method

  1. @override
Future<Uint8List> encodeAvif({
  1. required int width,
  2. required int height,
  3. required int speed,
  4. required int maxThreads,
  5. required int timescale,
  6. required int maxQuantizer,
  7. required int minQuantizer,
  8. required int maxQuantizerAlpha,
  9. required int minQuantizerAlpha,
  10. required List<EncodeFrame> imageSequence,
  11. required Uint8List exifData,
})
override

Implementation

@override
Future<Uint8List> encodeAvif({
  required int width,
  required int height,
  required int speed,
  required int maxThreads,
  required int timescale,
  required int maxQuantizer,
  required int minQuantizer,
  required int maxQuantizerAlpha,
  required int minQuantizerAlpha,
  required List<EncodeFrame> imageSequence,
  required Uint8List exifData,
}) {
  final request = EncodeRequest(
    width: width,
    height: height,
    speed: speed,
    maxThreads: maxThreads,
    timescale: timescale,
    maxQuantizer: maxQuantizer,
    minQuantizer: minQuantizer,
    maxQuantizerAlpha: maxQuantizerAlpha,
    minQuantizerAlpha: minQuantizerAlpha,
    imageList: imageSequence,
    exifData: exifData,
  ).writeToBuffer();
  final nativeRequest = toPointer(request);

  final completer = Completer<Uint8List>();
  final port = RawReceivePort();
  port.handler = (response) {
    port.close();

    completer.complete(response);
  };

  flutterAvifFFI.encode_avif(
    port.sendPort.nativePort,
    nativeRequest[0],
    nativeRequest[1],
  );

  malloc.free(nativeRequest[0]);

  return completer.future;
}