118.4dc91e7aa2e252d9.js 2.9 KB

12
  1. (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[118],{6118:function(module){var YUVBuffer={validateDimension:function(dim){if(dim<=0||dim!==(0|dim))throw"YUV plane dimensions must be a positive integer"},validateOffset:function(dim){if(dim<0||dim!==(0|dim))throw"YUV plane offsets must be a non-negative integer"},format:function(fields){var width=fields.width,height=fields.height,chromaWidth=fields.chromaWidth||width,chromaHeight=fields.chromaHeight||height,cropLeft=fields.cropLeft||0,cropTop=fields.cropTop||0,cropWidth=fields.cropWidth||width-cropLeft,cropHeight=fields.cropHeight||height-cropTop,displayWidth=fields.displayWidth||cropWidth,displayHeight=fields.displayHeight||cropHeight;return this.validateDimension(width),this.validateDimension(height),this.validateDimension(chromaWidth),this.validateDimension(chromaHeight),this.validateOffset(cropLeft),this.validateOffset(cropTop),this.validateDimension(cropWidth),this.validateDimension(cropHeight),this.validateDimension(displayWidth),this.validateDimension(displayHeight),{width:width,height:height,chromaWidth:chromaWidth,chromaHeight:chromaHeight,cropLeft:cropLeft,cropTop:cropTop,cropWidth:cropWidth,cropHeight:cropHeight,displayWidth:displayWidth,displayHeight:displayHeight}},allocPlane:function(stride,rows){return YUVBuffer.validateDimension(stride),YUVBuffer.validateDimension(rows),{bytes:new Uint8Array(stride*rows),stride:stride}},suitableStride:function(width){YUVBuffer.validateDimension(width);var remainder=width%4;return 0==remainder?width:width+(4-remainder)},allocPlane:function(width,height,source,stride,offset){var size,bytes;if(this.validateDimension(width),this.validateDimension(height),offset=offset||0,stride=stride||this.suitableStride(width),this.validateDimension(stride),stride<width)throw"Invalid input stride for YUV plane; must be larger than width";if(size=stride*height,source){if(source.length-offset<size)throw"Invalid input buffer for YUV plane; must be large enough for stride times height";bytes=source.slice(offset,offset+size)}else bytes=new Uint8Array(size),stride=stride||this.suitableStride(width);return{bytes:bytes,stride:stride}},lumaPlane:function(format,source,stride,offset){return this.allocPlane(format.width,format.height,source,stride,offset)},chromaPlane:function(format,source,stride,offset){return this.allocPlane(format.chromaWidth,format.chromaHeight,source,stride,offset)},frame:function(format,y,u,v){return y=y||this.lumaPlane(format),u=u||this.chromaPlane(format),v=v||this.chromaPlane(format),{format:format,y:y,u:u,v:v}},copyPlane:function(plane){return{bytes:plane.bytes.slice(),stride:plane.stride}},copyFrame:function(frame){return{format:frame.format,y:this.copyPlane(frame.y),u:this.copyPlane(frame.u),v:this.copyPlane(frame.v)}},transferables:function(frame){return[frame.y.bytes.buffer,frame.u.bytes.buffer,frame.v.bytes.buffer]}};module.exports=YUVBuffer}}]);
  2. //# sourceMappingURL=118.4dc91e7aa2e252d9.js.map