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

Side by Side Diff: source/libvpx/webmenc.cc

Issue 1169543007: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « source/libvpx/webmenc.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include "./webmenc.h" 10 #include "./webmenc.h"
11 11
12 #include <string> 12 #include <string>
13 13
14 #include "third_party/libwebm/mkvmuxer.hpp" 14 #include "third_party/libwebm/mkvmuxer.hpp"
15 #include "third_party/libwebm/mkvmuxerutil.hpp" 15 #include "third_party/libwebm/mkvmuxerutil.hpp"
16 #include "third_party/libwebm/mkvwriter.hpp" 16 #include "third_party/libwebm/mkvwriter.hpp"
17 17
18 namespace { 18 namespace {
19 const uint64_t kDebugTrackUid = 0xDEADBEEF; 19 const uint64_t kDebugTrackUid = 0xDEADBEEF;
20 const int kVideoTrackNumber = 1; 20 const int kVideoTrackNumber = 1;
21 } // namespace 21 } // namespace
22 22
23 void write_webm_file_header(struct EbmlGlobal *glob, 23 void write_webm_file_header(struct EbmlGlobal *glob,
24 const vpx_codec_enc_cfg_t *cfg, 24 const vpx_codec_enc_cfg_t *cfg,
25 const struct vpx_rational *fps, 25 const struct vpx_rational *fps,
26 stereo_format_t stereo_fmt, 26 stereo_format_t stereo_fmt,
27 unsigned int fourcc) { 27 unsigned int fourcc,
28 const struct VpxRational *par) {
28 mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(glob->stream); 29 mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(glob->stream);
29 mkvmuxer::Segment *const segment = new mkvmuxer::Segment(); 30 mkvmuxer::Segment *const segment = new mkvmuxer::Segment();
30 segment->Init(writer); 31 segment->Init(writer);
31 segment->set_mode(mkvmuxer::Segment::kFile); 32 segment->set_mode(mkvmuxer::Segment::kFile);
32 segment->OutputCues(true); 33 segment->OutputCues(true);
33 34
34 mkvmuxer::SegmentInfo *const info = segment->GetSegmentInfo(); 35 mkvmuxer::SegmentInfo *const info = segment->GetSegmentInfo();
35 const uint64_t kTimecodeScale = 1000000; 36 const uint64_t kTimecodeScale = 1000000;
36 info->set_timecode_scale(kTimecodeScale); 37 info->set_timecode_scale(kTimecodeScale);
37 std::string version = "vpxenc"; 38 std::string version = "vpxenc";
38 if (!glob->debug) { 39 if (!glob->debug) {
39 version.append(std::string(" ") + vpx_codec_version_str()); 40 version.append(std::string(" ") + vpx_codec_version_str());
40 } 41 }
41 info->set_writing_app(version.c_str()); 42 info->set_writing_app(version.c_str());
42 43
43 const uint64_t video_track_id = 44 const uint64_t video_track_id =
44 segment->AddVideoTrack(static_cast<int>(cfg->g_w), 45 segment->AddVideoTrack(static_cast<int>(cfg->g_w),
45 static_cast<int>(cfg->g_h), 46 static_cast<int>(cfg->g_h),
46 kVideoTrackNumber); 47 kVideoTrackNumber);
47 mkvmuxer::VideoTrack* const video_track = 48 mkvmuxer::VideoTrack* const video_track =
48 static_cast<mkvmuxer::VideoTrack*>( 49 static_cast<mkvmuxer::VideoTrack*>(
49 segment->GetTrackByNumber(video_track_id)); 50 segment->GetTrackByNumber(video_track_id));
50 video_track->SetStereoMode(stereo_fmt); 51 video_track->SetStereoMode(stereo_fmt);
51 video_track->set_codec_id(fourcc == VP8_FOURCC ? "V_VP8" : "V_VP9"); 52 video_track->set_codec_id(fourcc == VP8_FOURCC ? "V_VP8" : "V_VP9");
53 if (par->numerator > 1 || par->denominator > 1) {
54 // TODO(fgalligan): Add support of DisplayUnit, Display Aspect Ratio type
55 // to WebM format.
56 const uint64_t display_width =
57 static_cast<uint64_t>(((cfg->g_w * par->numerator * 1.0) /
58 par->denominator) + .5);
59 video_track->set_display_width(display_width);
60 video_track->set_display_height(cfg->g_h);
61 }
52 if (glob->debug) { 62 if (glob->debug) {
53 video_track->set_uid(kDebugTrackUid); 63 video_track->set_uid(kDebugTrackUid);
54 } 64 }
55 glob->writer = writer; 65 glob->writer = writer;
56 glob->segment = segment; 66 glob->segment = segment;
57 } 67 }
58 68
59 void write_webm_block(struct EbmlGlobal *glob, 69 void write_webm_block(struct EbmlGlobal *glob,
60 const vpx_codec_enc_cfg_t *cfg, 70 const vpx_codec_enc_cfg_t *cfg,
61 const vpx_codec_cx_pkt_t *pkt) { 71 const vpx_codec_cx_pkt_t *pkt) {
(...skipping 16 matching lines...) Expand all
78 mkvmuxer::MkvWriter *const writer = 88 mkvmuxer::MkvWriter *const writer =
79 reinterpret_cast<mkvmuxer::MkvWriter*>(glob->writer); 89 reinterpret_cast<mkvmuxer::MkvWriter*>(glob->writer);
80 mkvmuxer::Segment *const segment = 90 mkvmuxer::Segment *const segment =
81 reinterpret_cast<mkvmuxer::Segment*>(glob->segment); 91 reinterpret_cast<mkvmuxer::Segment*>(glob->segment);
82 segment->Finalize(); 92 segment->Finalize();
83 delete segment; 93 delete segment;
84 delete writer; 94 delete writer;
85 glob->writer = NULL; 95 glob->writer = NULL;
86 glob->segment = NULL; 96 glob->segment = NULL;
87 } 97 }
OLDNEW
« no previous file with comments | « source/libvpx/webmenc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698