Fix handling non-tightly packed ByteBuffers in HardwareVideoDecoder.

Before this CL, there would be an out-of-bounds write in the ByteBuffer
copying when a decoded frame had height != sliceHeight.

Bug: webrtc:9194
Change-Id: Ibb80e5555e8f00d9e1fd4cb8a73f5e4ccd5a0b81
Tested: 640x360 loopback with eglContext == null in AppRTCMobile on Pixel.
Reviewed-on: https://webrtc-review.googlesource.com/74120
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23184}
This commit is contained in:
Sami Kalliomäki
2018-05-08 15:22:08 +02:00
committed by Commit Bot
parent c710ac142e
commit ee98be7811
9 changed files with 87 additions and 83 deletions

View File

@ -45,6 +45,12 @@ public final class HardwareVideoDecoderTest {
CLASS_PARAMS.add(new ParameterSet()
.value("VP8" /* codecType */, true /* useEglContext */)
.name("VP8WithEglContext"));
CLASS_PARAMS.add(new ParameterSet()
.value("H264" /* codecType */, false /* useEglContext */)
.name("H264WithoutEglContext"));
CLASS_PARAMS.add(new ParameterSet()
.value("H264" /* codecType */, true /* useEglContext */)
.name("H264WithEglContext"));
}
private final String codecType;
@ -65,12 +71,12 @@ public final class HardwareVideoDecoderTest {
private static final boolean ENABLE_INTEL_VP8_ENCODER = true;
private static final boolean ENABLE_H264_HIGH_PROFILE = true;
private static final VideoEncoder.Settings ENCODER_SETTINGS =
new VideoEncoder.Settings(1 /* core */, 640 /* width */, 480 /* height */, 300 /* kbps */,
new VideoEncoder.Settings(1 /* core */, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT, 300 /* kbps */,
30 /* fps */, true /* automaticResizeOn */);
private static final int DECODE_TIMEOUT_MS = 1000;
private static final VideoDecoder.Settings SETTINGS =
new VideoDecoder.Settings(1 /* core */, 640 /* width */, 480 /* height */);
new VideoDecoder.Settings(1 /* core */, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT);
private static class MockDecodeCallback implements VideoDecoder.Callback {
private BlockingQueue<VideoFrame> frameQueue = new LinkedBlockingQueue<>();

View File

@ -58,6 +58,17 @@ public class YuvHelperTest {
NativeLibrary.initialize(new NativeLibrary.DefaultLoader());
}
@SmallTest
@Test
public void testCopyPlane() {
final int dstStride = TEST_WIDTH;
final ByteBuffer dst = ByteBuffer.allocateDirect(TEST_HEIGHT * dstStride);
YuvHelper.copyPlane(TEST_I420_Y, TEST_I420_STRIDE_Y, dst, dstStride, TEST_WIDTH, TEST_HEIGHT);
assertByteBufferContentEquals(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}, dst);
}
@SmallTest
@Test
public void testI420Copy() {