OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_ | 5 #ifndef MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_ |
6 #define MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_ | 6 #define MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_ |
7 | 7 |
8 #include <stack> | 8 #include <stack> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
13 #include "media/webm/chromeos/ebml_writer.h" | 13 #include "media/webm/chromeos/ebml_writer.h" |
14 | 14 |
15 extern "C" { | 15 extern "C" { |
16 #define VPX_CODEC_DISABLE_COMPAT 1 | 16 #define VPX_CODEC_DISABLE_COMPAT 1 |
17 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" | 17 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" |
18 #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" | 18 #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" |
19 } | 19 } |
20 | 20 |
| 21 class SkBitmap; |
| 22 |
| 23 namespace base { |
21 class FilePath; | 24 class FilePath; |
22 class SkBitmap; | 25 } |
23 | 26 |
24 namespace media { | 27 namespace media { |
25 | 28 |
26 namespace chromeos { | 29 namespace chromeos { |
27 | 30 |
28 // WebM encoder using libvpx. Currently only supports one-pass, constant bitrate | 31 // WebM encoder using libvpx. Currently only supports one-pass, constant bitrate |
29 // encoding of short files consisting of a single video track. Seek info and | 32 // encoding of short files consisting of a single video track. Seek info and |
30 // cues are not supported, so generated .webm file does not strictly adhere to | 33 // cues are not supported, so generated .webm file does not strictly adhere to |
31 // WebM standard (http://www.webmproject.org/code/specs/container/). | 34 // WebM standard (http://www.webmproject.org/code/specs/container/). |
32 class MEDIA_EXPORT WebmEncoder { | 35 class MEDIA_EXPORT WebmEncoder { |
33 public: | 36 public: |
34 // Create new instance for writing to |output_path|. If |realtime| is |true|, | 37 // Create new instance for writing to |output_path|. If |realtime| is |true|, |
35 // uses realtime deadline, otherwise - "good quality" deadline. | 38 // uses realtime deadline, otherwise - "good quality" deadline. |
36 WebmEncoder(const FilePath& output_path, int bitrate, bool realtime); | 39 WebmEncoder(const base::FilePath& output_path, int bitrate, bool realtime); |
37 ~WebmEncoder(); | 40 ~WebmEncoder(); |
38 | 41 |
39 // Encodes video from a Nx(N*M) sprite, having M frames of size NxN with FPS | 42 // Encodes video from a Nx(N*M) sprite, having M frames of size NxN with FPS |
40 // |fps_n/fps_d|. Must be called on a thread that allows disk IO. | 43 // |fps_n/fps_d|. Must be called on a thread that allows disk IO. |
41 // Returns |true| iff encoding and writing to file is successful. | 44 // Returns |true| iff encoding and writing to file is successful. |
42 bool EncodeFromSprite(const SkBitmap& sprite, int fps_n, int fps_d); | 45 bool EncodeFromSprite(const SkBitmap& sprite, int fps_n, int fps_d); |
43 | 46 |
44 private: | 47 private: |
45 // Writes global WebM header and starts a single video track. Returns |false| | 48 // Writes global WebM header and starts a single video track. Returns |false| |
46 // if there was an error opening file for writing. | 49 // if there was an error opening file for writing. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // VPX parameters. | 83 // VPX parameters. |
81 int bitrate_; | 84 int bitrate_; |
82 unsigned long deadline_; | 85 unsigned long deadline_; |
83 | 86 |
84 // EbmlWriter context. | 87 // EbmlWriter context. |
85 EbmlGlobal ebml_writer_; | 88 EbmlGlobal ebml_writer_; |
86 | 89 |
87 // Stack with start offsets of currently open sub-elements. | 90 // Stack with start offsets of currently open sub-elements. |
88 std::stack<long int> ebml_sub_elements_; | 91 std::stack<long int> ebml_sub_elements_; |
89 | 92 |
90 FilePath output_path_; | 93 base::FilePath output_path_; |
91 FILE* output_; | 94 FILE* output_; |
92 | 95 |
93 // True if an error occured while encoding/writing to file. | 96 // True if an error occured while encoding/writing to file. |
94 bool has_errors_; | 97 bool has_errors_; |
95 | 98 |
96 DISALLOW_COPY_AND_ASSIGN(WebmEncoder); | 99 DISALLOW_COPY_AND_ASSIGN(WebmEncoder); |
97 }; | 100 }; |
98 | 101 |
99 } // namespace chromeos | 102 } // namespace chromeos |
100 | 103 |
101 } // namespace media | 104 } // namespace media |
102 | 105 |
103 #endif // MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_ | 106 #endif // MEDIA_WEBM_CHROMEOS_WEBM_ENCODER_H_ |
OLD | NEW |