byte[][] imageComponents = new byte[nComponents][];
imageComponents = new byte[nComponents][];
void compress(ImageData image, byte[] dataYComp, byte[] dataCbComp, byte[] dataCrComp) {	int srcWidth = image.width;	int srcHeight = image.height;	int vhFactor = maxV * maxH;	int[] frameComponent;	byte[][] imageComponents = new byte[nComponents][];	for (int i = 0; i < nComponents; i++) {		frameComponent = frameComponents[i];		imageComponents[i] = new byte[frameComponent[CW] * frameComponent[CH]];	}	frameComponent = frameComponents[0];	for (int yPos = 0; yPos < srcHeight; yPos++) {		int srcOfs = yPos * srcWidth;		int dstOfs = yPos * frameComponent[CW];		System.arraycopy(dataYComp, srcOfs, imageComponents[0], dstOfs, srcWidth);	}	frameComponent = frameComponents[1];	for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {		int destRowIndex = yPos * frameComponent[CW];		for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {			int sum = 0;			for (int iv = 0; iv < maxV; iv++) {				int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);				for (int ih = 0; ih < maxH; ih++) {					sum += dataCbComp[srcIndex + ih] & 0xFF;				}			}			imageComponents[1][destRowIndex + xPos] = (byte)(sum / vhFactor);		}	}	frameComponent = frameComponents[2];	for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {		int destRowIndex = yPos * frameComponent[CW];		for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {			int sum = 0;			for (int iv = 0; iv < maxV; iv++) {				int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);				for (int ih = 0; ih < maxH; ih++) {					sum += dataCrComp[srcIndex + ih] & 0xFF;				}			}			imageComponents[2][destRowIndex + xPos] = (byte)(sum / vhFactor);		}	}	for (int iComp = 0; iComp < nComponents; iComp++) {		byte[] imageComponent = imageComponents[iComp];		frameComponent = frameComponents[iComp];		int hFactor = frameComponent[HI];		int vFactor = frameComponent[VI];		int componentWidth = frameComponent[CW];		int componentHeight = frameComponent[CH];		int compressedWidth = srcWidth / (maxH / hFactor);		int compressedHeight = srcHeight / (maxV / vFactor);		if (compressedWidth < componentWidth) {			int delta = componentWidth - compressedWidth;			for (int yPos = 0; yPos < compressedHeight; yPos++) {				int dstOfs = ((yPos + 1) * componentWidth - delta);				int dataValue = imageComponent[dstOfs - 1] & 0xFF;				for (int i = 0; i < delta; i++) {					imageComponent[dstOfs + i] = (byte)dataValue;				}			}		}		if (compressedHeight < componentHeight) {			int srcOfs = (compressedHeight - 1) * componentWidth;			for (int yPos = compressedHeight; yPos <= componentHeight; yPos++) {				int dstOfs = (yPos - 1) * componentWidth;				System.arraycopy(imageComponent, srcOfs, imageComponent, dstOfs, componentWidth);			}		}	}}