本文整理汇总了Java中org.jcodec.common.model.ColorSpace.YUV420属性的典型用法代码示例。如果您正苦于以下问题:Java ColorSpace.YUV420属性的具体用法?Java ColorSpace.YUV420怎么用?Java ColorSpace.YUV420使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jcodec.common.model.ColorSpace
的用法示例。
在下文中一共展示了ColorSpace.YUV420属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeFrame
private Picture makeFrame(BufferedImage bi) {
DataBuffer imageData = bi.getRaster().getDataBuffer();
int[] yPixel = new int[imageData.getSize()];
int[] uPixel = new int[imageData.getSize() >> 2];
int[] vPixel = new int[imageData.getSize() >> 2];
int ipx = 0, uvOffset = 0;
for (int h = 0; h < bi.getHeight(); h++) {
for (int w = 0; w < bi.getWidth(); w++) {
int elem = imageData.getElem(ipx);
int r = 0x0ff & (elem >>> 16);
int g = 0x0ff & (elem >>> 8);
int b = 0x0ff & elem;
yPixel[ipx] = ((66 * r + 129 * g + 25 * b) >> 8) + 16;
if ((0 != w % 2) && (0 != h % 2)) {
uPixel[uvOffset] = ((-38 * r + -74 * g + 112 * b) >> 8) + 128;
vPixel[uvOffset] = ((112 * r + -94 * g + -18 * b) >> 8) + 128;
uvOffset++;
}
ipx++;
}
}
int[][] pix = {yPixel, uPixel, vPixel, null};
return new Picture(bi.getWidth(), bi.getHeight(), pix, ColorSpace.YUV420);
}
示例2: initSPS
public SeqParameterSet initSPS(Size sz) {
SeqParameterSet sps = new SeqParameterSet();
sps.pic_width_in_mbs_minus1 = ((sz.getWidth() + 15) >> 4) - 1;
sps.pic_height_in_map_units_minus1 = ((sz.getHeight() + 15) >> 4) - 1;
sps.chroma_format_idc = ColorSpace.YUV420;
sps.profile_idc = 66;
sps.level_idc = 40;
sps.frame_mbs_only_flag = true;
int codedWidth = (sps.pic_width_in_mbs_minus1 + 1) << 4;
int codedHeight = (sps.pic_height_in_map_units_minus1 + 1) << 4;
sps.frame_cropping_flag = codedWidth != sz.getWidth() || codedHeight != sz.getHeight();
sps.frame_crop_right_offset = (codedWidth - sz.getWidth() + 1) >> 1;
sps.frame_crop_bottom_offset = (codedHeight - sz.getHeight() + 1) >> 1;
return sps;
}
示例3: createFrame
public static Frame createFrame(SeqParameterSet sps, int[][] buffer, int frame_num, int[][][][] mvs,
Frame[][][] refsUsed, int POC) {
int width = sps.pic_width_in_mbs_minus1 + 1 << 4;
int height = getPicHeightInMbs(sps) << 4;
Rect crop = null;
if (sps.frame_cropping_flag) {
int sX = sps.frame_crop_left_offset << 1;
int sY = sps.frame_crop_top_offset << 1;
int w = width - (sps.frame_crop_right_offset << 1) - sX;
int h = height - (sps.frame_crop_bottom_offset << 1) - sY;
crop = new Rect(sX, sY, w, h);
}
return new Frame(width, height, buffer, ColorSpace.YUV420, crop, frame_num, mvs, refsUsed, POC);
}