From 0a57aae75b4deaeb2cc9a9295eddfdafaaab1c73 Mon Sep 17 00:00:00 2001 From: "kjellander@webrtc.org" Date: Wed, 15 Feb 2012 09:47:55 +0000 Subject: [PATCH] Converted old jpeg_test tool to gtest unit test. Restructured paths to new directory layout. Stefan: common_video/* Magnus: video_engine/* Niklas: Android.mk BUG= TEST=jpeg_unittests on Debug+Release on Linux, Mac, Windows. Valgrind on Linux passes without warnings. Review URL: https://webrtc-codereview.appspot.com/388007 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1691 4adac7df-926f-26a2-2b94-8c16560cd09d --- Android.mk | 4 +- src/common_video/common_video.gyp | 2 +- .../jpeg/{main/source => }/Android.mk | 10 +- .../jpeg/{main/source => }/data_manager.cc | 8 +- .../jpeg/{main/source => }/data_manager.h | 2 +- .../jpeg/{main/interface => include}/jpeg.h | 6 +- .../jpeg/{main/source => }/jpeg.cc | 12 +- .../jpeg/{main/source => }/jpeg.gypi | 24 ++- src/common_video/jpeg/jpeg_unittest.cc | 123 +++++++++++++ .../jpeg/main/test/test_buffer.cc | 161 ------------------ src/common_video/jpeg/main/test/test_buffer.h | 77 --------- src/common_video/jpeg/main/test/test_jpeg.cc | 136 --------------- src/video_engine/vie_file_image.cc | 4 +- src/video_engine/vie_file_impl.cc | 2 +- test/data/common_video/jpeg/webrtc_logo.jpg | Bin 0 -> 9110 bytes 15 files changed, 152 insertions(+), 419 deletions(-) rename src/common_video/jpeg/{main/source => }/Android.mk (76%) rename src/common_video/jpeg/{main/source => }/data_manager.cc (94%) rename src/common_video/jpeg/{main/source => }/data_manager.h (95%) rename src/common_video/jpeg/{main/interface => include}/jpeg.h (95%) rename src/common_video/jpeg/{main/source => }/jpeg.cc (98%) rename src/common_video/jpeg/{main/source => }/jpeg.gypi (81%) create mode 100644 src/common_video/jpeg/jpeg_unittest.cc delete mode 100644 src/common_video/jpeg/main/test/test_buffer.cc delete mode 100644 src/common_video/jpeg/main/test/test_buffer.h delete mode 100644 src/common_video/jpeg/main/test/test_jpeg.cc create mode 100644 test/data/common_video/jpeg/webrtc_logo.jpg diff --git a/Android.mk b/Android.mk index b626394b6..b7c28e6d0 100644 --- a/Android.mk +++ b/Android.mk @@ -1,4 +1,4 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. +# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source @@ -37,7 +37,7 @@ include $(MY_WEBRTC_ROOT_PATH)/src/system_wrappers/source/Android.mk include $(MY_WEBRTC_ROOT_PATH)/src/voice_engine/main/source/Android.mk # video -include $(MY_WEBRTC_ROOT_PATH)/src/common_video/jpeg/main/source/Android.mk +include $(MY_WEBRTC_ROOT_PATH)/src/common_video/jpeg/Android.mk include $(MY_WEBRTC_ROOT_PATH)/src/common_video/libyuv/Android.mk include $(MY_WEBRTC_ROOT_PATH)/src/modules/video_capture/main/source/Android.mk include $(MY_WEBRTC_ROOT_PATH)/src/modules/video_coding/codecs/i420/main/source/Android.mk diff --git a/src/common_video/common_video.gyp b/src/common_video/common_video.gyp index 2319a7a00..5f23cf960 100644 --- a/src/common_video/common_video.gyp +++ b/src/common_video/common_video.gyp @@ -10,6 +10,6 @@ 'includes': [ '../common_settings.gypi', # Common settings 'libyuv/libyuv.gypi', - 'jpeg/main/source/jpeg.gypi', + 'jpeg/jpeg.gypi', ], } diff --git a/src/common_video/jpeg/main/source/Android.mk b/src/common_video/jpeg/Android.mk similarity index 76% rename from src/common_video/jpeg/main/source/Android.mk rename to src/common_video/jpeg/Android.mk index 11808a5b6..3df5c3eca 100644 --- a/src/common_video/jpeg/main/source/Android.mk +++ b/src/common_video/jpeg/Android.mk @@ -1,4 +1,4 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. +# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source @@ -10,7 +10,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -include $(LOCAL_PATH)/../../../../../android-webrtc.mk +include $(LOCAL_PATH)/../../../android-webrtc.mk LOCAL_MODULE_CLASS := STATIC_LIBRARIES LOCAL_MODULE := libwebrtc_jpeg @@ -25,11 +25,9 @@ LOCAL_CFLAGS := \ $(MY_WEBRTC_COMMON_DEFS) LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ $(LOCAL_PATH)/../interface \ - $(LOCAL_PATH)/../../../.. \ - $(LOCAL_PATH)/../../../vplib/main/interface \ - $(LOCAL_PATH)/../../../interface \ - $(LOCAL_PATH)/../../../../../../ \ + $(LOCAL_PATH)/../../../../ \ external/jpeg LOCAL_SHARED_LIBRARIES := \ diff --git a/src/common_video/jpeg/main/source/data_manager.cc b/src/common_video/jpeg/data_manager.cc similarity index 94% rename from src/common_video/jpeg/main/source/data_manager.cc rename to src/common_video/jpeg/data_manager.cc index cf8204d48..a5a7a4882 100644 --- a/src/common_video/jpeg/main/source/data_manager.cc +++ b/src/common_video/jpeg/data_manager.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -8,11 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * data_manager.cc - */ - -#include "data_manager.h" +#include "common_video/jpeg/data_manager.h" namespace webrtc { diff --git a/src/common_video/jpeg/main/source/data_manager.h b/src/common_video/jpeg/data_manager.h similarity index 95% rename from src/common_video/jpeg/main/source/data_manager.h rename to src/common_video/jpeg/data_manager.h index 11a789226..61609ecaa 100644 --- a/src/common_video/jpeg/main/source/data_manager.h +++ b/src/common_video/jpeg/data_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source diff --git a/src/common_video/jpeg/main/interface/jpeg.h b/src/common_video/jpeg/include/jpeg.h similarity index 95% rename from src/common_video/jpeg/main/interface/jpeg.h rename to src/common_video/jpeg/include/jpeg.h index 61f832cd3..7afaa6056 100644 --- a/src/common_video/jpeg/main/interface/jpeg.h +++ b/src/common_video/jpeg/include/jpeg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -8,10 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * JPEG wrapper - */ - #ifndef WEBRTC_COMMON_VIDEO_JPEG #define WEBRTC_COMMON_VIDEO_JPEG diff --git a/src/common_video/jpeg/main/source/jpeg.cc b/src/common_video/jpeg/jpeg.cc similarity index 98% rename from src/common_video/jpeg/main/source/jpeg.cc rename to src/common_video/jpeg/jpeg.cc index b18e03710..756e7c9d3 100644 --- a/src/common_video/jpeg/main/source/jpeg.cc +++ b/src/common_video/jpeg/jpeg.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -8,11 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * jpeg.cc - */ - - #if defined(WIN32) #include #endif @@ -20,8 +15,9 @@ #include #include -#include "jpeg.h" -#include "data_manager.h" +#include "common_video/jpeg/include/jpeg.h" +#include "common_video/jpeg/data_manager.h" + extern "C" { #if defined(USE_SYSTEM_LIBJPEG) #include diff --git a/src/common_video/jpeg/main/source/jpeg.gypi b/src/common_video/jpeg/jpeg.gypi similarity index 81% rename from src/common_video/jpeg/main/source/jpeg.gypi rename to src/common_video/jpeg/jpeg.gypi index 550073d00..1738a3de0 100644 --- a/src/common_video/jpeg/main/source/jpeg.gypi +++ b/src/common_video/jpeg/jpeg.gypi @@ -1,4 +1,4 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. +# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. # # Use of this source code is governed by a BSD-style license # that can be found in the LICENSE file in the root of the source @@ -18,14 +18,14 @@ 'webrtc_libyuv', ], 'include_dirs': [ - '../../../interface', - '../interface', - '../../../../../../', + 'include', + '<(webrtc_root)', + '<(webrtc_root)/common_video/interface', ], 'direct_dependent_settings': { 'include_dirs': [ - '../interface', - '../../../interface', + 'include', + '<(webrtc_root)/common_video/interface', ], }, 'conditions': [ @@ -55,7 +55,7 @@ }], ], 'sources': [ - '../interface/jpeg.h', + 'include/jpeg.h', 'data_manager.cc', 'data_manager.h', 'jpeg.cc', @@ -67,17 +67,15 @@ ['build_with_chromium==0', { 'targets': [ { - 'target_name': 'jpeg_test', + 'target_name': 'jpeg_unittests', 'type': 'executable', 'dependencies': [ 'webrtc_jpeg', - ], - 'include_dirs': [ - '../interface', - '../source', + '<(webrtc_root)/../testing/gtest.gyp:gtest', + '<(webrtc_root)/../test/test.gyp:test_support_main', ], 'sources': [ - '../test/test_jpeg.cc', + 'jpeg_unittest.cc', ], }, ] # targets diff --git a/src/common_video/jpeg/jpeg_unittest.cc b/src/common_video/jpeg/jpeg_unittest.cc new file mode 100644 index 000000000..fdcbe349f --- /dev/null +++ b/src/common_video/jpeg/jpeg_unittest.cc @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include +#include + +#include "common_video/jpeg/include/jpeg.h" +#include "common_video/interface/video_image.h" +#include "gtest/gtest.h" +#include "testsupport/fileutils.h" + +namespace webrtc { + +const unsigned int kImageWidth = 640; +const unsigned int kImageHeight = 480; + +class JpegTest: public testing::Test { + protected: + JpegTest() + : input_filename_(webrtc::test::ProjectRootPath() + + "test/data/common_video/jpeg/webrtc_logo.jpg"), + decoded_filename_(webrtc::test::OutputPath() + "TestJpegDec.yuv"), + encoded_filename_(webrtc::test::OutputPath() + "TestJpegEnc.jpg"), + encoded_buffer_(NULL) {} + virtual ~JpegTest() {} + + void SetUp() { + encoder_ = new JpegEncoder(); + decoder_ = new JpegDecoder(); + } + + void TearDown() { + if (encoded_buffer_ != NULL) { + if (encoded_buffer_->_buffer != NULL) { + delete [] encoded_buffer_->_buffer; + } + delete encoded_buffer_; + } + delete encoder_; + delete decoder_; + } + + // Reads an encoded image. Caller will have to deallocate the memory of this + // object and it's _buffer byte array. + EncodedImage* ReadEncodedImage(std::string input_filename) { + FILE* open_file = fopen(input_filename.c_str(), "rb"); + assert(open_file != NULL); + size_t length = webrtc::test::GetFileSize(input_filename); + EncodedImage* encoded_buffer = new EncodedImage(); + encoded_buffer->_buffer = new WebRtc_UWord8[length]; + encoded_buffer->_size = length; + encoded_buffer->_length = length; + if (fread(encoded_buffer->_buffer, 1, length, open_file) != length) { + ADD_FAILURE() << "Error reading file:" << input_filename; + } + fclose(open_file); + return encoded_buffer; + } + + std::string input_filename_; + std::string decoded_filename_; + std::string encoded_filename_; + EncodedImage* encoded_buffer_; + JpegEncoder* encoder_; + JpegDecoder* decoder_; +}; + +TEST_F(JpegTest, Decode) { + encoded_buffer_ = ReadEncodedImage(input_filename_); + RawImage image_buffer; + EXPECT_EQ(0, decoder_->Decode(*encoded_buffer_, image_buffer)); + EXPECT_GT(image_buffer._length, 0u); + EXPECT_EQ(kImageWidth, image_buffer._width); + EXPECT_EQ(kImageHeight, image_buffer._height); + delete [] image_buffer._buffer; +} + +TEST_F(JpegTest, EncodeInvalidInputs) { + RawImage empty; + empty._width = 164; + empty._height = 164; + EXPECT_EQ(-1, encoder_->SetFileName(0)); + EXPECT_EQ(-1, encoder_->Encode(empty)); + + empty._buffer = new WebRtc_UWord8[10]; + empty._size = 0; + EXPECT_EQ(-1, encoder_->Encode(empty)); + + empty._size = 10; + empty._height = 0; + EXPECT_EQ(-1, encoder_->Encode(empty)); + + empty._height = 164; + empty._width = 0; + EXPECT_EQ(-1, encoder_->Encode(empty)); + delete[] empty._buffer; +} + +TEST_F(JpegTest, Encode) { + // Decode our input image then encode it again to a new file: + encoded_buffer_ = ReadEncodedImage(input_filename_); + RawImage image_buffer; + EXPECT_EQ(0, decoder_->Decode(*encoded_buffer_, image_buffer)); + + EXPECT_EQ(0, encoder_->SetFileName(encoded_filename_.c_str())); + EXPECT_EQ(0, encoder_->Encode(image_buffer)); + + // Save decoded image to file. + FILE* save_file = fopen(decoded_filename_.c_str(), "wb"); + fwrite(image_buffer._buffer, 1, image_buffer._length, save_file); + fclose(save_file); + + delete[] image_buffer._buffer; +} + +} // namespace webrtc diff --git a/src/common_video/jpeg/main/test/test_buffer.cc b/src/common_video/jpeg/main/test/test_buffer.cc deleted file mode 100644 index c97320479..000000000 --- a/src/common_video/jpeg/main/test/test_buffer.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// system includes -#include -#include // memcpy - -#include "test_buffer.h" -#include "common_video/libyuv/include/libyuv.h" - -TestBuffer::TestBuffer(): -_buffer(0), -_bufferSize(0), -_bufferLength(0), -_width(0), -_height(0) -{ - // -} - -TestBuffer::~TestBuffer() -{ - _bufferLength = 0; - _bufferSize = 0; - if(_buffer) - { - delete [] _buffer; - _buffer = 0; - } -} - -TestBuffer::TestBuffer(const TestBuffer& rhs) -: -_bufferLength(rhs._bufferLength), -_bufferSize(rhs._bufferSize), -_height(rhs._height), -_width(rhs._width), -_buffer(0) -{ - // make sure that our buffer is big enough - _buffer = new WebRtc_UWord8[_bufferSize]; - // only copy required length - memcpy(_buffer, rhs._buffer, _bufferLength); -} - -WebRtc_UWord32 -TestBuffer::GetWidth() const -{ - return _width; -} - -WebRtc_UWord32 -TestBuffer::GetHeight() const -{ - return _height; -} - -void -TestBuffer::SetWidth(WebRtc_UWord32 width) -{ - _width = width; -} - -void -TestBuffer::SetHeight(WebRtc_UWord32 height) -{ - _height = height; -} - -void -TestBuffer::Free() -{ - _bufferLength = 0; - _bufferSize = 0; - _height = 0; - _width = 0; - if(_buffer) - { - delete [] _buffer; - _buffer = 0; - } -} - -void -TestBuffer::VerifyAndAllocate(WebRtc_UWord32 minimumSize) -{ - if(minimumSize > _bufferSize) - { - // make sure that our buffer is big enough - WebRtc_UWord8 * newBufferBuffer = new WebRtc_UWord8[minimumSize]; - if(_buffer) - { - // copy the old data - memcpy(newBufferBuffer, _buffer, _bufferSize); - delete [] _buffer; - } - _buffer = newBufferBuffer; - _bufferSize = minimumSize; - } -} - -void -TestBuffer::UpdateLength(WebRtc_UWord32 newLength) -{ - assert(newLength <= _bufferSize); - _bufferLength = newLength; -} - -void -TestBuffer::CopyBuffer(WebRtc_UWord32 length, const WebRtc_UWord8* buffer) -{ - assert(length <= _bufferSize); - memcpy(_buffer, buffer, length); - _bufferLength = length; -} - -void -TestBuffer::CopyBuffer(TestBuffer& fromVideoBuffer) -{ - assert(fromVideoBuffer.GetLength() <= _bufferSize); - assert(fromVideoBuffer.GetSize() <= _bufferSize); - _bufferLength = fromVideoBuffer.GetLength(); - _height = fromVideoBuffer.GetHeight(); - _width = fromVideoBuffer.GetWidth(); - memcpy(_buffer, fromVideoBuffer.GetBuffer(), fromVideoBuffer.GetLength()); -} - -void -TestBuffer::Set(WebRtc_UWord8* tempBuffer,WebRtc_UWord32 tempSize, WebRtc_UWord32 tempLength) -{ - _buffer = tempBuffer; - _bufferSize = tempSize; - _bufferLength = tempLength; - -} - -WebRtc_UWord8* -TestBuffer::GetBuffer() const -{ - return _buffer; -} - -WebRtc_UWord32 -TestBuffer::GetSize() const -{ - return _bufferSize; -} - -WebRtc_UWord32 -TestBuffer::GetLength() const -{ - return _bufferLength; -} - diff --git a/src/common_video/jpeg/main/test/test_buffer.h b/src/common_video/jpeg/main/test/test_buffer.h deleted file mode 100644 index 757fae37b..000000000 --- a/src/common_video/jpeg/main/test/test_buffer.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#ifndef WEBRTC_COMMON_VIDEO_JPEG_TEST_BUFFER_H -#define WEBRTC_COMMON_VIDEO_JPEG_TEST_BUFFER_H - -#include "typedefs.h" - -class TestBuffer -{ -public: - TestBuffer(); - - virtual ~TestBuffer(); - - TestBuffer(const TestBuffer& rhs); - - /** - * Verifies that current allocated buffer size is larger than or equal to the input size. - * If the current buffer size is smaller, a new allocation is made and the old buffer data is copied to the new buffer. - */ - void VerifyAndAllocate(WebRtc_UWord32 minimumSize); - - void UpdateLength(WebRtc_UWord32 newLength); - - - - void CopyBuffer(WebRtc_UWord32 length, const WebRtc_UWord8* fromBuffer); - - void CopyBuffer(TestBuffer& fromBuffer); - - void Free(); // Deletes frame buffer and resets members to zero - - /** - * Gets pointer to frame buffer - */ - WebRtc_UWord8* GetBuffer() const; - - /** - * Gets allocated buffer size - */ - WebRtc_UWord32 GetSize() const; - - /** - * Gets length of frame - */ - WebRtc_UWord32 GetLength() const; - - - WebRtc_UWord32 GetWidth() const; - WebRtc_UWord32 GetHeight() const; - - void SetWidth(WebRtc_UWord32 width); - void SetHeight(WebRtc_UWord32 height); - -private: - // TestBuffer& operator=(const TestBuffer& inBuffer); - -private: - void Set(WebRtc_UWord8* buffer,WebRtc_UWord32 size,WebRtc_UWord32 length); - - WebRtc_UWord8* _buffer; // Pointer to frame buffer - WebRtc_UWord32 _bufferSize; // Allocated buffer size - WebRtc_UWord32 _bufferLength; // Length (in bytes) of frame - WebRtc_UWord32 _width; - WebRtc_UWord32 _height; -}; - -#endif diff --git a/src/common_video/jpeg/main/test/test_jpeg.cc b/src/common_video/jpeg/main/test/test_jpeg.cc deleted file mode 100644 index def5c002c..000000000 --- a/src/common_video/jpeg/main/test/test_jpeg.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * test_jpeg.cc - */ - -#include -#include -#include -#include -#include - - -#include "video_image.h" -#include "jpeg.h" - -using namespace webrtc; - -int -main(int argc, char **argv) -{ - if (argc < 1) - { - return -1; - } - std::string fileName = argv[1]; - const char* fileNameDec = "TestJpegDec.yuv"; - const char* fileNameEnc = "TestJpegEnc.jpg"; - - std::string str; - std::cout << "---------------------" << std::endl; - std::cout << "----- Test JPEG -----" << std::endl; - std::cout << "---------------------" << std::endl; - std::cout << " " << std::endl; - - JpegDecoder* JpgDecPtr = new JpegDecoder( ); - - // Open input file - FILE* openFile = fopen(fileName.c_str(), "rb"); - assert(openFile != NULL); - - // Get file length - fseek(openFile, 0, SEEK_END); - size_t length = ftell(openFile); - fseek(openFile, 0, SEEK_SET); - - - // Read input file to buffer - EncodedImage encodedBuffer; - encodedBuffer._buffer = new WebRtc_UWord8[length]; - encodedBuffer._size = length; - encodedBuffer._length = length; - if (fread(encodedBuffer._buffer, 1, length, openFile) != length) - { - printf("Error reading file %s\n", fileName.c_str()); - return 1; - } - fclose(openFile); - - // ------------------ - // Decode - // ------------------ - - RawImage imageBuffer; - int error = JpgDecPtr->Decode(encodedBuffer, imageBuffer); - - std::cout << error << " = Decode(" << fileName.c_str() << ", " - "(" << imageBuffer._width << - "x" << imageBuffer._height << "))" << std::endl; - - if (error == 0) - { - // Save decoded image to file - FILE* saveFile = fopen(fileNameDec, "wb"); - fwrite(imageBuffer._buffer, 1, imageBuffer._length, saveFile); - fclose(saveFile); - - // ------------------ - // Encode - // ------------------ - - JpegEncoder* JpegEncoderPtr = new JpegEncoder(); - - // Test invalid inputs - RawImage empty; - empty._width = 164; - empty._height = 164; - int error = JpegEncoderPtr->SetFileName(0); - assert(error == -1); - error = JpegEncoderPtr->Encode(empty); - assert(error == -1); - empty._buffer = new WebRtc_UWord8[10]; - empty._size = 0; - error = JpegEncoderPtr->Encode(empty); - assert(error == -1); - empty._size = 10; - empty._height = 0; - error = JpegEncoderPtr->Encode(empty); - assert(error == -1); - empty._height = 164; - empty._width = 0; - error = JpegEncoderPtr->Encode(empty); - assert(error == -1); - - error = JpegEncoderPtr->SetFileName(fileNameEnc); - assert(error == 0); - - delete [] empty._buffer; - - // Actual Encode - error = JpegEncoderPtr->Encode(imageBuffer); - assert(error == 0); - std::cout << error << " = Encode(" << fileNameDec << ")" << std::endl; - delete JpegEncoderPtr; - } - - delete [] imageBuffer._buffer; - delete [] encodedBuffer._buffer; - delete JpgDecPtr; - - std::cout << "Verify that the encoded and decoded images look correct." - << std::endl; - std::cout << "Press enter to quit test..."; - std::getline(std::cin, str); - - return 0; -} - diff --git a/src/video_engine/vie_file_image.cc b/src/video_engine/vie_file_image.cc index 74267edac..2472a3ada 100644 --- a/src/video_engine/vie_file_image.cc +++ b/src/video_engine/vie_file_image.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -18,7 +18,7 @@ #include #include "common_video/interface/video_image.h" -#include "common_video/jpeg/main/interface/jpeg.h" +#include "common_video/jpeg/include/jpeg.h" #include "system_wrappers/interface/trace.h" namespace webrtc { diff --git a/src/video_engine/vie_file_impl.cc b/src/video_engine/vie_file_impl.cc index b46952e91..28f98544a 100644 --- a/src/video_engine/vie_file_impl.cc +++ b/src/video_engine/vie_file_impl.cc @@ -13,7 +13,7 @@ #include "video_engine/vie_file_impl.h" #ifdef WEBRTC_VIDEO_ENGINE_FILE_API -#include "common_video/jpeg/main/interface/jpeg.h" +#include "common_video/jpeg/include/jpeg.h" #include "system_wrappers/interface/condition_variable_wrapper.h" #include "system_wrappers/interface/critical_section_wrapper.h" #include "system_wrappers/interface/trace.h" diff --git a/test/data/common_video/jpeg/webrtc_logo.jpg b/test/data/common_video/jpeg/webrtc_logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ddb6192bc7b38c9778109c8ff0edf728d4914b07 GIT binary patch literal 9110 zcmeHrdsNct)<0=!QSg zj#DD0Oj?j2kfAA{(gh`NnIc|LG&L`%;05r4x7Xg^`&;i?XPtlE|7U;KcYmM#T=w4U zv!3Vs?7epecHRR%`|;cl=Ky>5>;atLeE>T{fbRi1yW*ZbAGyv)+N=AK@7udqcdy<) zJ-z>a^*`CKr~iq*p5Fe0`#(AGk#<|39z5{rN8zKA|F=|UpRVq{1NwUU|2^gZ#CBc) z4EOJOuk)+!9!r3Z;T~PXJv%~xIbaV!M@M(pHNgL;Pj*f3*{83ovv+s={AYUrdvtf( zAAQ|_KzDc29v$7i`}7R;_kVKaE8qd6Z;x6A{%maG^!Jo&R^R>O?!W%x3_25?`cVA& zakuZ!AunUnYpQEs?rJ)*Yhus7|24C#X`ha+p8o!iW*iK62lwvL*}G3i|9|}WXvT1# z-Vyz;fZrM!2mYM0-}1ZYYj+=3kL^eSpX%cI2a@$>nUmXTPDp)_?hs z(842RMvzdlf`TE8#Zy$C4T-dwnYfzWbgGn?k)OOb>sbvd^xZ0u@oE%Tm{dr_=HN9Xa`p8H*v9q#FF$GYGpag%PyB3yM!Ik zB~YWiOd)Wz@R!5yHapQrRp7T7akN}VqGPh`?m|-8-Q+DnQ40BzEPYxgi}v=mw^MTn3R+en_2zirwYa~ME1Pd0 z|4t#UZ~EiCT2O`X>X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