Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: chrome/browser/chromeos/webm_encoder.h

Issue 10784037: [cros] Implement WebM encoder/muxer for animated avatar capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/ebml_writer.cc ('k') | chrome/browser/chromeos/webm_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_WEBM_ENCODER_H_
6 #define CHROME_BROWSER_CHROMEOS_WEBM_ENCODER_H_
7
8 #include <stack>
9 #include <stdio.h>
10
11 #include "base/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/chromeos/ebml_writer.h"
14
15 extern "C" {
16 #define VPX_CODEC_DISABLE_COMPAT 1
17 #include "third_party/libvpx/libvpx.h"
18 }
19
20 class FilePath;
21 class SkBitmap;
22
23 namespace chromeos {
24
25 // WebM encoder using libvpx. Currently only supports one-pass, constant bitrate
26 // encoding of short files consisting of a single video track. Seek info and
27 // cues are not supported, so generated .webm file does not strictly adhere to
28 // WebM standard (http://www.webmproject.org/code/specs/container/).
29 class WebmEncoder {
30 public:
31 // Create new instance for writing to |output_path|. If |realtime| is |true|,
32 // uses realtime deadline, otherwise - "good quality" deadline.
33 WebmEncoder(const FilePath& output_path, unsigned bitrate, bool realtime);
34
35 // Encodes video from a Nx(N*M) sprite, having M frames of size NxN with FPS
36 // |fps_n/fps_d|. Must be called on a thread that allows IO.
Nikita (slow) 2012/07/18 16:23:05 nit: allows disk IO
Ivan Korotkov 2012/07/20 09:09:29 Done.
37 void EncodeFromSprite(const SkBitmap& sprite, int fps_n, int fps_d);
38
39 private:
40 // Write global WebM header and starts a single video track.
Nikita (slow) 2012/07/18 16:23:05 nit: Writes
Ivan Korotkov 2012/07/20 09:09:29 Done.
41 void WriteWebmHeader();
42 // Writes VPX packet to output file.
Nikita (slow) 2012/07/18 16:23:05 nit: insert empty line
Ivan Korotkov 2012/07/20 09:09:29 Done.
43 void WriteWebmBlock(const vpx_codec_cx_pkt_t* packet);
44 // Finished video track and closes output file.
Nikita (slow) 2012/07/18 16:23:05 nit: insert empty line nit: Finishes
Ivan Korotkov 2012/07/20 09:09:29 Done.
45 void WriteWebmFooter();
46
47 // Starts a new WebM sub-element of given type. Those can be nested.
48 void StartSubElement(unsigned long class_id);
49 // Closes current top-level sub-element.
Nikita (slow) 2012/07/18 16:23:05 nit: insert empty line
Ivan Korotkov 2012/07/20 09:09:29 Done.
50 void EndSubElement();
51
52 // libmkv callbacks.
53 void EbmlWrite(const void* buffer, unsigned long len);
54 void EbmlSerialize(const void* buffer, int buffer_size, unsigned long len);
55
56 template <typename T>
57 void EbmlSerializeHelper(const T* buffer, unsigned long len);
58
59 // Video dimensions and FPS.
60 size_t width_;
61 size_t height_;
62 vpx_rational_t fps_;
63
64 // Single I420 frame data.
65 scoped_array<uint8> yuv_frame_;
66
67 // VPX config in use.
68 vpx_codec_enc_cfg_t config_;
69
70 // VPX parameters.
71 unsigned bitrate_;
72 unsigned long deadline_;
73
74 // EbmlWriter context.
75 EbmlGlobal ebml_writer_;
76
77 // Stack with start offsets of currently open sub-elements.
78 std::stack<long int> ebml_sub_elements_;
79
80 FilePath output_path_;
81 FILE* output_;
82 };
83
84 } // namespace chromeos
85
86 #endif // CHROME_BROWSER_CHROMEOS_WEBM_ENCODER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ebml_writer.cc ('k') | chrome/browser/chromeos/webm_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698