Merge "media: switch to using MediaImage2" into nyc-dev
This commit is contained in:
@@ -3339,14 +3339,6 @@ final public class MediaCodec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int readInt(@NonNull ByteBuffer buffer, boolean asLong) {
|
|
||||||
if (asLong) {
|
|
||||||
return (int)buffer.getLong();
|
|
||||||
} else {
|
|
||||||
return buffer.getInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MediaImage(
|
public MediaImage(
|
||||||
@NonNull ByteBuffer buffer, @NonNull ByteBuffer info, boolean readOnly,
|
@NonNull ByteBuffer buffer, @NonNull ByteBuffer info, boolean readOnly,
|
||||||
long timestamp, int xOffset, int yOffset, @Nullable Rect cropRect) {
|
long timestamp, int xOffset, int yOffset, @Nullable Rect cropRect) {
|
||||||
@@ -3361,39 +3353,46 @@ final public class MediaCodec {
|
|||||||
mYOffset = yOffset;
|
mYOffset = yOffset;
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
|
|
||||||
// read media-info. the size of media info can be 80 or 156/160 depending on
|
// read media-info. See MediaImage2
|
||||||
// whether it was created on a 32- or 64-bit process. See MediaImage
|
if (info.remaining() == 104) {
|
||||||
if (info.remaining() == 80 || info.remaining() == 156 || info.remaining() == 160) {
|
int type = info.getInt();
|
||||||
boolean sizeIsLong = info.remaining() != 80;
|
|
||||||
int type = readInt(info, info.remaining() == 160);
|
|
||||||
if (type != TYPE_YUV) {
|
if (type != TYPE_YUV) {
|
||||||
throw new UnsupportedOperationException("unsupported type: " + type);
|
throw new UnsupportedOperationException("unsupported type: " + type);
|
||||||
}
|
}
|
||||||
int numPlanes = readInt(info, sizeIsLong);
|
int numPlanes = info.getInt();
|
||||||
if (numPlanes != 3) {
|
if (numPlanes != 3) {
|
||||||
throw new RuntimeException("unexpected number of planes: " + numPlanes);
|
throw new RuntimeException("unexpected number of planes: " + numPlanes);
|
||||||
}
|
}
|
||||||
mWidth = readInt(info, sizeIsLong);
|
mWidth = info.getInt();
|
||||||
mHeight = readInt(info, sizeIsLong);
|
mHeight = info.getInt();
|
||||||
if (mWidth < 1 || mHeight < 1) {
|
if (mWidth < 1 || mHeight < 1) {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"unsupported size: " + mWidth + "x" + mHeight);
|
"unsupported size: " + mWidth + "x" + mHeight);
|
||||||
}
|
}
|
||||||
int bitDepth = readInt(info, sizeIsLong);
|
int bitDepth = info.getInt();
|
||||||
if (bitDepth != 8) {
|
if (bitDepth != 8) {
|
||||||
throw new UnsupportedOperationException("unsupported bit depth: " + bitDepth);
|
throw new UnsupportedOperationException("unsupported bit depth: " + bitDepth);
|
||||||
}
|
}
|
||||||
|
int bitDepthAllocated = info.getInt();
|
||||||
|
if (bitDepthAllocated != 8) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"unsupported allocated bit depth: " + bitDepthAllocated);
|
||||||
|
}
|
||||||
mPlanes = new MediaPlane[numPlanes];
|
mPlanes = new MediaPlane[numPlanes];
|
||||||
for (int ix = 0; ix < numPlanes; ix++) {
|
for (int ix = 0; ix < numPlanes; ix++) {
|
||||||
int planeOffset = readInt(info, sizeIsLong);
|
int planeOffset = info.getInt();
|
||||||
int colInc = readInt(info, sizeIsLong);
|
int colInc = info.getInt();
|
||||||
int rowInc = readInt(info, sizeIsLong);
|
int rowInc = info.getInt();
|
||||||
int horiz = readInt(info, sizeIsLong);
|
int horiz = info.getInt();
|
||||||
int vert = readInt(info, sizeIsLong);
|
int vert = info.getInt();
|
||||||
if (horiz != vert || horiz != (ix == 0 ? 1 : 2)) {
|
if (horiz != vert || horiz != (ix == 0 ? 1 : 2)) {
|
||||||
throw new UnsupportedOperationException("unexpected subsampling: "
|
throw new UnsupportedOperationException("unexpected subsampling: "
|
||||||
+ horiz + "x" + vert + " on plane " + ix);
|
+ horiz + "x" + vert + " on plane " + ix);
|
||||||
}
|
}
|
||||||
|
if (colInc < 1 || rowInc < 1) {
|
||||||
|
throw new UnsupportedOperationException("unexpected strides: "
|
||||||
|
+ colInc + " pixel, " + rowInc + " row on plane " + ix);
|
||||||
|
}
|
||||||
|
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
buffer.position(mBuffer.position() + planeOffset
|
buffer.position(mBuffer.position() + planeOffset
|
||||||
|
|||||||
Reference in New Issue
Block a user