Commit 129f2869 authored by ivankr@chromium.org's avatar ivankr@chromium.org

Revert 148024 - [cros] Implement WebM encoder/muxer for animated avatar capture.


BUG=132423
TEST=None


Review URL: https://chromiumcodereview.appspot.com/10784037

TBR=ivankr@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10809068

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148027 0039d316-1c4b-4281-b951-d872f2087c98
parent 13d6b3c1
...@@ -351,20 +351,6 @@ ...@@ -351,20 +351,6 @@
], ],
}, },
}], }],
# A simple WebM encoder for animated avatars on ChromeOS.
['chromeos==1', {
'dependencies': [
'../skia/skia.gyp:skia',
'../third_party/libvpx/libvpx.gyp:libvpx',
'../third_party/libyuv/libyuv.gyp:libyuv',
],
'sources': [
'webm/chromeos/ebml_writer.cc',
'webm/chromeos/ebml_writer.h',
'webm/chromeos/webm_encoder.cc',
'webm/chromeos/webm_encoder.h',
],
}],
['OS=="linux" or OS=="freebsd" or OS=="solaris"', { ['OS=="linux" or OS=="freebsd" or OS=="solaris"', {
'link_settings': { 'link_settings': {
'libraries': [ 'libraries': [
......
include_rules = [
"+libyuv",
"+third_party/libvpx",
]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/webm/chromeos/ebml_writer.h"
#include "media/base/media_export.h"
extern "C" {
#include "third_party/libvpx/source/libvpx/libmkv/EbmlWriter.h"
// These functions must be in the global namespace and visible to libmkv.
void MEDIA_EXPORT Ebml_Write(EbmlGlobal* glob,
const void* buffer,
unsigned long len) {
glob->write_cb.Run(buffer, len);
}
void MEDIA_EXPORT Ebml_Serialize(EbmlGlobal* glob,
const void* buffer,
int buffer_size,
unsigned long len) {
glob->serialize_cb.Run(buffer, buffer_size, len);
}
} // extern "C"
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_WEBM_CHROMEOS_EBML_WRITER_H_
#define MEDIA_WEBM_CHROMEOS_EBML_WRITER_H_
#include "base/callback.h"
// This struct serves as a bridge betweeen static libmkv interface and Chrome's
// base::Callback. Must be in the global namespace. See EbmlWriter.h.
struct EbmlGlobal {
base::Callback<void(const void* buffer, unsigned long len)> write_cb;
base::Callback<void(const void* buffer, int buffer_size, unsigned long len)>
serialize_cb;
};
#endif // MEDIA_WEBM_CHROMEOS_EBML_WRITER_H_
This diff is collapsed.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_
#define MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_
#include <stack>
#include <stdio.h>
#include "base/file_path.h"
#include "media/base/media_export.h"
#include "media/webm/chromeos/ebml_writer.h"
extern "C" {
#define VPX_CODEC_DISABLE_COMPAT 1
#include "third_party/libvpx/libvpx.h"
}
class FilePath;
class SkBitmap;
namespace media {
namespace chromeos {
// WebM encoder using libvpx. Currently only supports one-pass, constant bitrate
// encoding of short files consisting of a single video track. Seek info and
// cues are not supported, so generated .webm file does not strictly adhere to
// WebM standard (http://www.webmproject.org/code/specs/container/).
class MEDIA_EXPORT WebmEncoder {
public:
// Create new instance for writing to |output_path|. If |realtime| is |true|,
// uses realtime deadline, otherwise - "good quality" deadline.
WebmEncoder(const FilePath& output_path, int bitrate, bool realtime);
// Encodes video from a Nx(N*M) sprite, having M frames of size NxN with FPS
// |fps_n/fps_d|. Must be called on a thread that allows disk IO.
// Returns |true| iff encoding and writing to file is successful.
bool EncodeFromSprite(const SkBitmap& sprite, int fps_n, int fps_d);
private:
// Writes global WebM header and starts a single video track. Returns |false|
// if there was an error opening file for writing.
bool WriteWebmHeader();
// Writes VPX packet to output file.
void WriteWebmBlock(const vpx_codec_cx_pkt_t* packet);
// Finishes video track and closes output file. Returns |false| if there were
// any error during encoding/writing file.
bool WriteWebmFooter();
// Starts a new WebM sub-element of given type. Those can be nested.
void StartSubElement(unsigned long class_id);
// Closes current top-level sub-element.
void EndSubElement();
// libmkv callbacks.
void EbmlWrite(const void* buffer, unsigned long len);
void EbmlSerialize(const void* buffer, int buffer_size, unsigned long len);
template <typename T>
void EbmlSerializeHelper(const T* buffer, unsigned long len);
// Video dimensions and FPS.
size_t width_;
size_t height_;
vpx_rational_t fps_;
// VPX config in use.
vpx_codec_enc_cfg_t config_;
// VPX parameters.
int bitrate_;
unsigned long deadline_;
// EbmlWriter context.
EbmlGlobal ebml_writer_;
// Stack with start offsets of currently open sub-elements.
std::stack<long int> ebml_sub_elements_;
FilePath output_path_;
FILE* output_;
// True if an error occured while encoding/writing to file.
bool has_errors_;
DISALLOW_COPY_AND_ASSIGN(WebmEncoder);
};
} // namespace chromeos
} // namespace media
#endif // MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment