Removing JPEG as it is not used.

BUG= 2322
R=niklas.enbom@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2138005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4646 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2013-08-30 16:00:08 +00:00
parent 45d2840623
commit cf61bee5a2
8 changed files with 0 additions and 648 deletions

6
DEPS
View File

@ -59,12 +59,6 @@ deps = {
"third_party/junit/":
(Var("googlecode_url") % "webrtc") + "/deps/third_party/junit@3367",
"third_party/libjpeg":
Var("chromium_trunk") + "/src/third_party/libjpeg@" + Var("chromium_revision"),
"third_party/libjpeg_turbo":
From("chromium_deps", "src/third_party/libjpeg_turbo"),
"third_party/libsrtp/":
From("chromium_deps", "src/third_party/libsrtp"),

View File

@ -7,16 +7,6 @@
# be found in the AUTHORS file in the root of the source tree.
{
'variables': {
'use_libjpeg_turbo%': '<(use_libjpeg_turbo)',
'conditions': [
['use_libjpeg_turbo==1', {
'libjpeg_include_dir%': [ '<(DEPTH)/third_party/libjpeg_turbo', ],
}, {
'libjpeg_include_dir%': [ '<(DEPTH)/third_party/libjpeg', ],
}],
],
},
'includes': ['../build/common.gypi'],
'targets': [
{
@ -25,7 +15,6 @@
'include_dirs': [
'<(webrtc_root)/modules/interface/',
'interface',
'jpeg/include',
'libyuv/include',
],
'dependencies': [
@ -34,17 +23,10 @@
'direct_dependent_settings': {
'include_dirs': [
'interface',
'jpeg/include',
'libyuv/include',
],
},
'conditions': [
['build_libjpeg==1', {
'dependencies': ['<(libjpeg_gyp_path):libjpeg',],
}, {
# Need to add a directory normally exported by libjpeg.gyp.
'include_dirs': ['<(libjpeg_include_dir)'],
}],
['build_libyuv==1', {
'dependencies': ['<(DEPTH)/third_party/libyuv/libyuv.gyp:libyuv',],
}, {
@ -57,10 +39,6 @@
'interface/native_handle.h',
'interface/texture_video_frame.h',
'i420_video_frame.cc',
'jpeg/include/jpeg.h',
'jpeg/data_manager.cc',
'jpeg/data_manager.h',
'jpeg/jpeg.cc',
'libyuv/include/webrtc_libyuv.h',
'libyuv/include/scaler.h',
'libyuv/webrtc_libyuv.cc',
@ -69,8 +47,6 @@
'plane.cc',
'texture_video_frame.cc'
],
# Silence jpeg struct padding warnings.
'msvs_disabled_warnings': [ 4324, ],
},
], # targets
'conditions': [
@ -87,7 +63,6 @@
],
'sources': [
'i420_video_frame_unittest.cc',
'jpeg/jpeg_unittest.cc',
'libyuv/libyuv_unittest.cc',
'libyuv/scaler_unittest.cc',
'plane_unittest.cc',

View File

@ -1,42 +0,0 @@
# 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.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../../../android-webrtc.mk
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE := libwebrtc_jpeg
LOCAL_MODULE_TAGS := optional
LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES := \
jpeg.cc \
data_manager.cc
# Flags passed to both C and C++ files.
LOCAL_CFLAGS := \
$(MY_WEBRTC_COMMON_DEFS)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/../../ \
$(LOCAL_PATH)/../interface \
$(LOCAL_PATH)/../../../../ \
external/jpeg
LOCAL_SHARED_LIBRARIES := \
libcutils \
libdl \
libstlport
ifndef NDK_ROOT
include external/stlport/libstlport.mk
endif
include $(BUILD_STATIC_LIBRARY)

View File

@ -1,86 +0,0 @@
/*
* 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 "webrtc/common_video/jpeg/data_manager.h"
namespace webrtc
{
typedef struct
{
jpeg_source_mgr mgr;
JOCTET* next_input_byte;
size_t bytes_in_buffer; /* # of byte spaces remaining in buffer */
} DataSrcMgr;
void
jpegSetSrcBuffer(j_decompress_ptr cinfo, JOCTET* srcBuffer, size_t bufferSize)
{
DataSrcMgr* src;
if (cinfo->src == NULL)
{ /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
JPOOL_PERMANENT, sizeof(DataSrcMgr));
}
// Setting required functionality
src = (DataSrcMgr*) cinfo->src;
src->mgr.init_source = initSrc;;
src->mgr.fill_input_buffer = fillInputBuffer;
src->mgr.skip_input_data = skipInputData;
src->mgr.resync_to_restart = jpeg_resync_to_restart; // use default
src->mgr.term_source = termSource;
// setting buffer/src
src->bytes_in_buffer = bufferSize;
src->next_input_byte = srcBuffer;
}
void
initSrc(j_decompress_ptr cinfo)
{
DataSrcMgr *src = (DataSrcMgr*)cinfo->src;
src->mgr.next_input_byte = src->next_input_byte;
src->mgr.bytes_in_buffer = src->bytes_in_buffer;
}
boolean
fillInputBuffer(j_decompress_ptr cinfo)
{
return false;
}
void
skipInputData(j_decompress_ptr cinfo, long num_bytes)
{
DataSrcMgr* src = (DataSrcMgr*)cinfo->src;
if (num_bytes > 0)
{
if ((unsigned long)num_bytes > src->mgr.bytes_in_buffer)
src->mgr.bytes_in_buffer = 0;
else
{
src->mgr.next_input_byte += num_bytes;
src->mgr.bytes_in_buffer -= num_bytes;
}
}
}
void
termSource (j_decompress_ptr cinfo)
{
//
}
} // namespace webrtc

View File

@ -1,68 +0,0 @@
/*
* 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.
*/
/*
* Jpeg source data manager
*/
#ifndef WEBRTC_COMMON_VIDEO_JPEG_DATA_MANAGER
#define WEBRTC_COMMON_VIDEO_JPEG_DATA_MANAGER
#include <stdio.h>
extern "C" {
#if defined(USE_SYSTEM_LIBJPEG)
#include <jpeglib.h>
#else
#include "jpeglib.h"
#endif
}
namespace webrtc
{
// Source manager:
// a general function that will set these values
void
jpegSetSrcBuffer(j_decompress_ptr cinfo, JOCTET* srcBuffer, size_t bufferSize);
// Initialize source. This is called by jpeg_read_header() before any
// data is actually read.
void
initSrc(j_decompress_ptr cinfo);
// Fill input buffer
// This is called whenever bytes_in_buffer has reached zero and more
// data is wanted.
boolean
fillInputBuffer(j_decompress_ptr cinfo);
// Skip input data
// Skip num_bytes worth of data.
void
skipInputData(j_decompress_ptr cinfo, long num_bytes);
// Terminate source
void
termSource (j_decompress_ptr cinfo);
} // namespace webrtc
#endif /* WEBRTC_COMMON_VIDEO_JPEG_DATA_MANAGER */

View File

@ -1,72 +0,0 @@
/*
* 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.
*/
#ifndef WEBRTC_COMMON_VIDEO_JPEG
#define WEBRTC_COMMON_VIDEO_JPEG
#include "webrtc/common_video/interface/i420_video_frame.h"
#include "webrtc/common_video/interface/video_image.h" // EncodedImage
#include "webrtc/typedefs.h"
// jpeg forward declaration
struct jpeg_compress_struct;
namespace webrtc
{
// TODO(mikhal): Move this to LibYuv wrapper, when LibYuv will have a JPG
// Encode.
class JpegEncoder
{
public:
JpegEncoder();
~JpegEncoder();
// SetFileName
// Input:
// - fileName - Pointer to input vector (should be less than 256) to which the
// compressed file will be written to
// Output:
// - 0 : OK
// - (-1) : Error
int32_t SetFileName(const char* fileName);
// Encode an I420 image. The encoded image is saved to a file
//
// Input:
// - inputImage : Image to be encoded
//
// Output:
// - 0 : OK
// - (-1) : Error
int32_t Encode(const I420VideoFrame& inputImage);
private:
jpeg_compress_struct* _cinfo;
char _fileName[257];
};
// Decodes a JPEG-stream
// Supports 1 image component. 3 interleaved image components,
// YCbCr sub-sampling 4:4:4, 4:2:2, 4:2:0.
//
// Input:
// - input_image : encoded image to be decoded.
// - output_image : VideoFrame to store decoded output.
//
// Output:
// - 0 : OK
// - (-1) : Error
// - (-2) : Unsupported format
int ConvertJpegToI420(const EncodedImage& input_image,
I420VideoFrame* output_image);
}
#endif /* WEBRTC_COMMON_VIDEO_JPEG */

View File

@ -1,234 +0,0 @@
/*
* 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.
*/
#if defined(WIN32)
#include <basetsd.h>
#endif
#include <setjmp.h>
#include <stdio.h>
#include <string.h>
// NOTE(ajm): Path provided by gyp.
#include "libyuv.h" // NOLINT
#include "libyuv/mjpeg_decoder.h" // NOLINT
#include "webrtc/common_video/jpeg/data_manager.h"
#include "webrtc/common_video/jpeg/include/jpeg.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
extern "C" {
#if defined(USE_SYSTEM_LIBJPEG)
#include <jpeglib.h>
#else
#include "jpeglib.h"
#endif
}
namespace webrtc
{
// Error handler
struct myErrorMgr {
struct jpeg_error_mgr pub;
jmp_buf setjmp_buffer;
};
typedef struct myErrorMgr * myErrorPtr;
METHODDEF(void)
MyErrorExit (j_common_ptr cinfo)
{
myErrorPtr myerr = (myErrorPtr) cinfo->err;
// Return control to the setjmp point
longjmp(myerr->setjmp_buffer, 1);
}
JpegEncoder::JpegEncoder()
{
_cinfo = new jpeg_compress_struct;
strcpy(_fileName, "Snapshot.jpg");
}
JpegEncoder::~JpegEncoder()
{
if (_cinfo != NULL)
{
delete _cinfo;
_cinfo = NULL;
}
}
int32_t
JpegEncoder::SetFileName(const char* fileName)
{
if (!fileName)
{
return -1;
}
if (fileName)
{
strncpy(_fileName, fileName, 256);
_fileName[256] = 0;
}
return 0;
}
int32_t
JpegEncoder::Encode(const I420VideoFrame& inputImage)
{
if (inputImage.IsZeroSize())
{
return -1;
}
if (inputImage.width() < 1 || inputImage.height() < 1)
{
return -1;
}
FILE* outFile = NULL;
const int width = inputImage.width();
const int height = inputImage.height();
// Set error handler
myErrorMgr jerr;
_cinfo->err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = MyErrorExit;
// Establish the setjmp return context
if (setjmp(jerr.setjmp_buffer))
{
// If we get here, the JPEG code has signaled an error.
jpeg_destroy_compress(_cinfo);
if (outFile != NULL)
{
fclose(outFile);
}
return -1;
}
if ((outFile = fopen(_fileName, "wb")) == NULL)
{
return -2;
}
// Create a compression object
jpeg_create_compress(_cinfo);
// Setting destination file
jpeg_stdio_dest(_cinfo, outFile);
// Set parameters for compression
_cinfo->in_color_space = JCS_YCbCr;
jpeg_set_defaults(_cinfo);
_cinfo->image_width = width;
_cinfo->image_height = height;
_cinfo->input_components = 3;
_cinfo->comp_info[0].h_samp_factor = 2; // Y
_cinfo->comp_info[0].v_samp_factor = 2;
_cinfo->comp_info[1].h_samp_factor = 1; // U
_cinfo->comp_info[1].v_samp_factor = 1;
_cinfo->comp_info[2].h_samp_factor = 1; // V
_cinfo->comp_info[2].v_samp_factor = 1;
_cinfo->raw_data_in = TRUE;
// Converting to a buffer
// TODO(mikhal): This is a tmp implementation. Will update to use LibYuv
// Encode when that becomes available.
unsigned int length = CalcBufferSize(kI420, width, height);
scoped_array<uint8_t> image_buffer(new uint8_t[length]);
ExtractBuffer(inputImage, length, image_buffer.get());
int height16 = (height + 15) & ~15;
uint8_t* imgPtr = image_buffer.get();
uint8_t* origImagePtr = NULL;
if (height16 != height)
{
// Copy image to an adequate size buffer
uint32_t requiredSize = CalcBufferSize(kI420, width, height16);
origImagePtr = new uint8_t[requiredSize];
memset(origImagePtr, 0, requiredSize);
memcpy(origImagePtr, image_buffer.get(), length);
imgPtr = origImagePtr;
}
jpeg_start_compress(_cinfo, TRUE);
JSAMPROW y[16],u[8],v[8];
JSAMPARRAY data[3];
data[0] = y;
data[1] = u;
data[2] = v;
int i, j;
for (j = 0; j < height; j += 16)
{
for (i = 0; i < 16; i++)
{
y[i] = (JSAMPLE*)imgPtr + width * (i + j);
if (i % 2 == 0)
{
u[i / 2] = (JSAMPLE*) imgPtr + width * height +
width / 2 * ((i + j) / 2);
v[i / 2] = (JSAMPLE*) imgPtr + width * height +
width * height / 4 + width / 2 * ((i + j) / 2);
}
}
jpeg_write_raw_data(_cinfo, data, 16);
}
jpeg_finish_compress(_cinfo);
jpeg_destroy_compress(_cinfo);
fclose(outFile);
if (origImagePtr != NULL)
{
delete [] origImagePtr;
}
return 0;
}
int ConvertJpegToI420(const EncodedImage& input_image,
I420VideoFrame* output_image) {
if (output_image == NULL)
return -1;
// TODO(mikhal): Update to use latest API from LibYuv when that becomes
// available.
libyuv::MJpegDecoder jpeg_decoder;
bool ret = jpeg_decoder.LoadFrame(input_image._buffer, input_image._size);
if (ret == false)
return -1;
if (jpeg_decoder.GetNumComponents() == 4)
return -2; // not supported.
int width = jpeg_decoder.GetWidth();
int height = jpeg_decoder.GetHeight();
output_image->CreateEmptyFrame(width, height, width,
(width + 1) / 2, (width + 1) / 2);
return ConvertToI420(kMJPG,
input_image._buffer,
0, 0, // no cropping
width, height,
input_image._size,
kRotateNone,
output_image);
}
}

View File

@ -1,115 +0,0 @@
/*
* 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 <stdio.h>
#include <string>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_video/interface/video_image.h"
#include "webrtc/common_video/jpeg/include/jpeg.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/test/testsupport/fileutils.h"
namespace webrtc {
const int kImageWidth = 640;
const int kImageHeight = 480;
class JpegTest: public testing::Test {
protected:
JpegTest()
: input_filename_(webrtc::test::ProjectRootPath() +
"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();
}
void TearDown() {
if (encoded_buffer_ != NULL) {
if (encoded_buffer_->_buffer != NULL) {
delete [] encoded_buffer_->_buffer;
}
delete encoded_buffer_;
}
delete encoder_;
}
// 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 uint8_t[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_;
};
TEST_F(JpegTest, Decode) {
encoded_buffer_ = ReadEncodedImage(input_filename_);
I420VideoFrame image_buffer;
EXPECT_EQ(0, ConvertJpegToI420(*encoded_buffer_, &image_buffer));
EXPECT_FALSE(image_buffer.IsZeroSize());
EXPECT_EQ(kImageWidth, image_buffer.width());
EXPECT_EQ(kImageHeight, image_buffer.height());
}
TEST_F(JpegTest, EncodeInvalidInputs) {
I420VideoFrame empty;
empty.set_width(164);
empty.set_height(164);
EXPECT_EQ(-1, encoder_->SetFileName(0));
// Test empty (null) frame.
EXPECT_EQ(-1, encoder_->Encode(empty));
// Create empty frame (allocate memory) - arbitrary dimensions.
empty.CreateEmptyFrame(10, 10, 10, 5, 5);
empty.ResetSize();
EXPECT_EQ(-1, encoder_->Encode(empty));
}
TEST_F(JpegTest, Encode) {
// Decode our input image then encode it again to a new file:
encoded_buffer_ = ReadEncodedImage(input_filename_);
I420VideoFrame image_buffer;
EXPECT_EQ(0, ConvertJpegToI420(*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");
if (PrintI420VideoFrame(image_buffer, save_file)) {
return;
}
fclose(save_file);
}
} // namespace webrtc