Vp8Encoder constructor

Vp8Encoder({
  1. required int width,
  2. required int height,
  3. int qi = 24,
  4. int keyframeInterval = 30,
  5. int minKeyframeInterval = 0,
  6. int searchRange = 4,
  7. int filterLevel = 0,
  8. int sharpness = 0,
  9. int filterType = 1,
  10. int zeroMvSadBias = 64,
  11. bool mbNoCoeffSkip = false,
  12. int probSkipFalse = 240,
  13. bool refreshGoldenOnInter = true,
  14. bool refreshAltrefOnInter = true,
  15. bool subPelRefine = true,
  16. bool predictorMotionSearch = true,
  17. bool useDiamondMotionSearch = false,
  18. int nearestSadBias = 16,
  19. int nearSadBias = 24,
  20. int newMvSadBias = 64,
  21. CbrRateController? rateController,
  22. int cyclicRefreshPercent = 0,
  23. TemporalDenoiser? denoiser,
  24. int log2NumTokenPartitions = 0,
  25. bool autoLoopFilter = false,
  26. int autoLoopFilterMin = 0,
  27. int autoLoopFilterMax = 63,
  28. int forceKeyAfterConsecutiveDrops = 0,
  29. double? sceneCutMeanAbsDiff,
  30. ({int height, int width, int x, int y})? roiRect,
  31. int roiQiDelta = -16,
  32. int mvRateBias = 0,
  33. int goldenRefreshPeriod = 0,
  34. bool tryGoldenZeroMv = false,
  35. int goldenSadBias = 32,
  36. bool tryGoldenNewMv = false,
  37. int goldenNewMvSadBias = 96,
  38. bool activityAq = false,
  39. int aqSmoothVarThreshold = 64,
  40. int aqTexturedVarThreshold = 1024,
  41. int aqSmoothQiDelta = -8,
  42. int aqTexturedQiDelta = 4,
  43. int staticMbSadThreshold = 0,
  44. int altrefRefreshPeriod = 0,
  45. bool tryAltrefZeroMv = false,
  46. int altrefSadBias = 48,
  47. bool tryAltrefNewMv = false,
  48. int altrefNewMvSadBias = 96,
  49. void onFrameEncoded(
    1. Vp8FrameStats stats
    )?,
  50. void onFrameDropped()?,
  51. int rollingWindowFrames = 0,
  52. int minQi = 0,
  53. int maxQi = 127,
  54. bool useMvRateCost = false,
  55. bool useRdInterMode = false,
  56. bool useRdIntraMode = false,
})

Implementation

Vp8Encoder({
  required this.width,
  required this.height,
  int qi = 24,
  int keyframeInterval = 30,
  int minKeyframeInterval = 0,
  this.searchRange = 4,
  this.filterLevel = 0,
  this.sharpness = 0,
  this.filterType = 1,
  this.zeroMvSadBias = 64,
  this.mbNoCoeffSkip = false,
  this.probSkipFalse = 240,
  bool refreshGoldenOnInter = true,
  bool refreshAltrefOnInter = true,
  this.subPelRefine = true,
  this.predictorMotionSearch = true,
  this.useDiamondMotionSearch = false,
  this.nearestSadBias = 16,
  this.nearSadBias = 24,
  this.newMvSadBias = 64,
  this.rateController,
  int cyclicRefreshPercent = 0,
  this.denoiser,
  this.log2NumTokenPartitions = 0,
  this.autoLoopFilter = false,
  this.autoLoopFilterMin = 0,
  this.autoLoopFilterMax = 63,
  this.forceKeyAfterConsecutiveDrops = 0,
  double? sceneCutMeanAbsDiff,
  this.roiRect,
  this.roiQiDelta = -16,
  this.mvRateBias = 0,
  int goldenRefreshPeriod = 0,
  this.tryGoldenZeroMv = false,
  this.goldenSadBias = 32,
  this.tryGoldenNewMv = false,
  this.goldenNewMvSadBias = 96,
  this.activityAq = false,
  this.aqSmoothVarThreshold = 64,
  this.aqTexturedVarThreshold = 1024,
  this.aqSmoothQiDelta = -8,
  this.aqTexturedQiDelta = 4,
  this.staticMbSadThreshold = 0,
  int altrefRefreshPeriod = 0,
  this.tryAltrefZeroMv = false,
  this.altrefSadBias = 48,
  this.tryAltrefNewMv = false,
  this.altrefNewMvSadBias = 96,
  void Function(Vp8FrameStats stats)? onFrameEncoded,
  void Function()? onFrameDropped,
  this.rollingWindowFrames = 0,
  int minQi = 0,
  int maxQi = 127,
  this.useMvRateCost = false,
  this.useRdInterMode = false,
  this.useRdIntraMode = false,
})  : _qi = qi,
      _minQi = minQi,
      _maxQi = maxQi,
      _keyframeInterval = keyframeInterval,
      _minKeyframeInterval = minKeyframeInterval,
      _sceneCutMeanAbsDiff = sceneCutMeanAbsDiff,
      _onFrameEncoded = onFrameEncoded,
      _onFrameDropped = onFrameDropped,
      _cyclicRefreshPercent = cyclicRefreshPercent,
      _goldenRefreshPeriod = goldenRefreshPeriod,
      _altrefRefreshPeriod = altrefRefreshPeriod,
      _refreshGoldenOnInter = refreshGoldenOnInter,
      _refreshAltrefOnInter = refreshAltrefOnInter {
  if ((width & 15) != 0 || (height & 15) != 0) {
    throw ArgumentError(
        'Vp8Encoder requires width/height multiples of 16 (got $width x $height)');
  }
  if (minQi < 0 || maxQi > 127 || minQi > maxQi) {
    throw ArgumentError(
        'minQi/maxQi must satisfy 0 <= minQi <= maxQi <= 127 (got minQi=$minQi, maxQi=$maxQi)');
  }
  if (keyframeInterval < 1) {
    throw ArgumentError('keyframeInterval must be >= 1');
  }
  if (minKeyframeInterval < 0) {
    throw ArgumentError('minKeyframeInterval must be >= 0');
  }
  if (minKeyframeInterval > keyframeInterval) {
    throw ArgumentError(
        'minKeyframeInterval ($minKeyframeInterval) must be <= keyframeInterval ($keyframeInterval)');
  }
  if (mbNoCoeffSkip && (probSkipFalse < 1 || probSkipFalse > 255)) {
    throw ArgumentError('probSkipFalse must be in [1,255]');
  }
  if (cyclicRefreshPercent < 0 || cyclicRefreshPercent > 100) {
    throw ArgumentError('cyclicRefreshPercent must be in [0,100]');
  }
  if (log2NumTokenPartitions < 0 || log2NumTokenPartitions > 3) {
    throw ArgumentError('log2NumTokenPartitions must be in [0,3]');
  }
  if (autoLoopFilterMin < 0 ||
      autoLoopFilterMax > 63 ||
      autoLoopFilterMin > autoLoopFilterMax) {
    throw ArgumentError(
        'autoLoopFilter range must satisfy 0 <= min <= max <= 63');
  }
  if (forceKeyAfterConsecutiveDrops < 0) {
    throw ArgumentError(
        'forceKeyAfterConsecutiveDrops must be >= 0 (0 disables)');
  }
  if (sceneCutMeanAbsDiff != null && sceneCutMeanAbsDiff! <= 0) {
    throw ArgumentError(
        'sceneCutMeanAbsDiff must be > 0 when non-null (null disables)');
  }
  final r = roiRect;
  if (r != null) {
    if (r.width <= 0 || r.height <= 0) {
      throw ArgumentError('roiRect width/height must be > 0');
    }
    if (r.x < 0 ||
        r.y < 0 ||
        r.x + r.width > width ||
        r.y + r.height > height) {
      throw ArgumentError(
          'roiRect must lie inside frame (got x=${r.x} y=${r.y} w=${r.width} h=${r.height} for ${width}x$height)');
    }
    if (roiQiDelta < -127 || roiQiDelta > 127) {
      throw ArgumentError('roiQiDelta must be in [-127,127]');
    }
  }
  if (mvRateBias < 0) {
    throw ArgumentError('mvRateBias must be >= 0 (0 disables)');
  }
  if (goldenRefreshPeriod < 0) {
    throw ArgumentError(
        'goldenRefreshPeriod must be >= 0 (0 falls back to refreshGoldenOnInter)');
  }
  if (goldenSadBias < 0) {
    throw ArgumentError('goldenSadBias must be >= 0');
  }
  if (goldenNewMvSadBias < 0) {
    throw ArgumentError('goldenNewMvSadBias must be >= 0');
  }
  if (activityAq) {
    if (aqSmoothVarThreshold < 0 || aqTexturedVarThreshold < 0) {
      throw ArgumentError('aq variance thresholds must be >= 0');
    }
    if (aqSmoothVarThreshold > aqTexturedVarThreshold) {
      throw ArgumentError(
          'aqSmoothVarThreshold must be <= aqTexturedVarThreshold');
    }
    if (aqSmoothQiDelta < -127 ||
        aqSmoothQiDelta > 127 ||
        aqTexturedQiDelta < -127 ||
        aqTexturedQiDelta > 127) {
      throw ArgumentError('aq qi deltas must lie in [-127,127]');
    }
  }
  if (staticMbSadThreshold < 0) {
    throw ArgumentError('staticMbSadThreshold must be >= 0 (0 disables)');
  }
  if (altrefRefreshPeriod < 0) {
    throw ArgumentError(
        'altrefRefreshPeriod must be >= 0 (0 disables periodic refresh)');
  }
  if (altrefSadBias < 0) {
    throw ArgumentError('altrefSadBias must be >= 0');
  }
  if (altrefNewMvSadBias < 0) {
    throw ArgumentError('altrefNewMvSadBias must be >= 0');
  }
}