Move function PrintVideoFrame to the test file where it is used.
Bug: webrtc:10198 Change-Id: I57a0d335c7d0dac8cade7a0e2dfa3e8898e7efd4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179370 Reviewed-by: Stefan Holmer <stefan@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31871}
This commit is contained in:
@ -58,16 +58,6 @@ const double kPerfectPSNR = 48.0f;
|
|||||||
// video frame.
|
// video frame.
|
||||||
size_t CalcBufferSize(VideoType type, int width, int height);
|
size_t CalcBufferSize(VideoType type, int width, int height);
|
||||||
|
|
||||||
// TODO(mikhal): Add unit test for these two functions and determine location.
|
|
||||||
// Print VideoFrame to file
|
|
||||||
// Input:
|
|
||||||
// - frame : Reference to video frame.
|
|
||||||
// - file : pointer to file object. It is assumed that the file is
|
|
||||||
// already open for writing.
|
|
||||||
// Return value: 0 if OK, < 0 otherwise.
|
|
||||||
int PrintVideoFrame(const VideoFrame& frame, FILE* file);
|
|
||||||
int PrintVideoFrame(const I420BufferInterface& frame, FILE* file);
|
|
||||||
|
|
||||||
// Extract buffer from VideoFrame or I420BufferInterface (consecutive
|
// Extract buffer from VideoFrame or I420BufferInterface (consecutive
|
||||||
// planes, no stride)
|
// planes, no stride)
|
||||||
// Input:
|
// Input:
|
||||||
|
@ -31,6 +31,38 @@ void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) {
|
|||||||
*stride_uv = 16 * ((width + 31) / 32);
|
*stride_uv = 16 * ((width + 31) / 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PrintPlane(const uint8_t* buf,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
int stride,
|
||||||
|
FILE* file) {
|
||||||
|
for (int i = 0; i < height; i++, buf += stride) {
|
||||||
|
if (fwrite(buf, 1, width, file) != static_cast<unsigned int>(width))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PrintVideoFrame(const I420BufferInterface& frame, FILE* file) {
|
||||||
|
int width = frame.width();
|
||||||
|
int height = frame.height();
|
||||||
|
int chroma_width = frame.ChromaWidth();
|
||||||
|
int chroma_height = frame.ChromaHeight();
|
||||||
|
|
||||||
|
if (PrintPlane(frame.DataY(), width, height, frame.StrideY(), file) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (PrintPlane(frame.DataU(), chroma_width, chroma_height, frame.StrideU(),
|
||||||
|
file) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (PrintPlane(frame.DataV(), chroma_width, chroma_height, frame.StrideV(),
|
||||||
|
file) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
class TestLibYuv : public ::testing::Test {
|
class TestLibYuv : public ::testing::Test {
|
||||||
|
@ -56,43 +56,6 @@ size_t CalcBufferSize(VideoType type, int width, int height) {
|
|||||||
return buffer_size;
|
return buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PrintPlane(const uint8_t* buf,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
int stride,
|
|
||||||
FILE* file) {
|
|
||||||
for (int i = 0; i < height; i++, buf += stride) {
|
|
||||||
if (fwrite(buf, 1, width, file) != static_cast<unsigned int>(width))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(nisse): Belongs with the test code?
|
|
||||||
int PrintVideoFrame(const I420BufferInterface& frame, FILE* file) {
|
|
||||||
int width = frame.width();
|
|
||||||
int height = frame.height();
|
|
||||||
int chroma_width = frame.ChromaWidth();
|
|
||||||
int chroma_height = frame.ChromaHeight();
|
|
||||||
|
|
||||||
if (PrintPlane(frame.DataY(), width, height, frame.StrideY(), file) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (PrintPlane(frame.DataU(), chroma_width, chroma_height, frame.StrideU(),
|
|
||||||
file) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (PrintPlane(frame.DataV(), chroma_width, chroma_height, frame.StrideV(),
|
|
||||||
file) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PrintVideoFrame(const VideoFrame& frame, FILE* file) {
|
|
||||||
return PrintVideoFrame(*frame.video_frame_buffer()->ToI420(), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ExtractBuffer(const rtc::scoped_refptr<I420BufferInterface>& input_frame,
|
int ExtractBuffer(const rtc::scoped_refptr<I420BufferInterface>& input_frame,
|
||||||
size_t size,
|
size_t size,
|
||||||
uint8_t* buffer) {
|
uint8_t* buffer) {
|
||||||
|
Reference in New Issue
Block a user