diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h index ba17577216..d27250a93e 100644 --- a/common_video/libyuv/include/webrtc_libyuv.h +++ b/common_video/libyuv/include/webrtc_libyuv.h @@ -58,16 +58,6 @@ const double kPerfectPSNR = 48.0f; // video frame. 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 // planes, no stride) // Input: diff --git a/common_video/libyuv/libyuv_unittest.cc b/common_video/libyuv/libyuv_unittest.cc index 2a7992865a..62d9e87fa6 100644 --- a/common_video/libyuv/libyuv_unittest.cc +++ b/common_video/libyuv/libyuv_unittest.cc @@ -31,6 +31,38 @@ void Calc16ByteAlignedStride(int width, int* stride_y, int* stride_uv) { *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(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 class TestLibYuv : public ::testing::Test { diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc index 833001cf1c..c7613cefd8 100644 --- a/common_video/libyuv/webrtc_libyuv.cc +++ b/common_video/libyuv/webrtc_libyuv.cc @@ -56,43 +56,6 @@ size_t CalcBufferSize(VideoType type, int width, int height) { 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(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& input_frame, size_t size, uint8_t* buffer) {