Vp8Encoder constructor
Vp8Encoder({
- required int width,
- required int height,
- int qi = 24,
- int keyframeInterval = 30,
- int minKeyframeInterval = 0,
- int searchRange = 4,
- int filterLevel = 0,
- int sharpness = 0,
- int filterType = 1,
- int zeroMvSadBias = 64,
- bool mbNoCoeffSkip = false,
- int probSkipFalse = 240,
- bool refreshGoldenOnInter = true,
- bool refreshAltrefOnInter = true,
- bool subPelRefine = true,
- bool predictorMotionSearch = true,
- bool useDiamondMotionSearch = false,
- int nearestSadBias = 16,
- int nearSadBias = 24,
- int newMvSadBias = 64,
- CbrRateController? rateController,
- int cyclicRefreshPercent = 0,
- TemporalDenoiser? denoiser,
- int log2NumTokenPartitions = 0,
- bool autoLoopFilter = false,
- int autoLoopFilterMin = 0,
- int autoLoopFilterMax = 63,
- int forceKeyAfterConsecutiveDrops = 0,
- double? sceneCutMeanAbsDiff,
- ({int height, int width, int x, int y})? roiRect,
- int roiQiDelta = -16,
- int mvRateBias = 0,
- int goldenRefreshPeriod = 0,
- bool tryGoldenZeroMv = false,
- int goldenSadBias = 32,
- bool tryGoldenNewMv = false,
- int goldenNewMvSadBias = 96,
- bool activityAq = false,
- int aqSmoothVarThreshold = 64,
- int aqTexturedVarThreshold = 1024,
- int aqSmoothQiDelta = -8,
- int aqTexturedQiDelta = 4,
- int staticMbSadThreshold = 0,
- int altrefRefreshPeriod = 0,
- bool tryAltrefZeroMv = false,
- int altrefSadBias = 48,
- bool tryAltrefNewMv = false,
- int altrefNewMvSadBias = 96,
- void onFrameEncoded(
- Vp8FrameStats stats
- void onFrameDropped()?,
- int rollingWindowFrames = 0,
- int minQi = 0,
- int maxQi = 127,
- bool useMvRateCost = false,
- bool useRdInterMode = false,
- 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');
}
}