summaryrefslogtreecommitdiff
path: root/webmenc.cc
diff options
context:
space:
mode:
authorFrank Galligan <fgalligan@google.com>2015-06-01 10:20:58 -0700
committerFrank Galligan <fgalligan@google.com>2015-06-05 09:56:50 -0700
commit09acd267bc3ad6ece4bc350fde32b266949fd833 (patch)
treefdb0ac2cc4dd4a204343bcbf75a79c36b2668a86 /webmenc.cc
parent8710cceb45ad64a50287a555e8803df1df5e72ad (diff)
downloadlibvpx-09acd267bc3ad6ece4bc350fde32b266949fd833.tar.gz
libvpx-09acd267bc3ad6ece4bc350fde32b266949fd833.tar.bz2
libvpx-09acd267bc3ad6ece4bc350fde32b266949fd833.zip
vpxenc: Add support for pixel aspect ratio.
WebM files will adjust the display width and height according to the input pixel aspect ratio. The default pixel aspect ratio is 1:1. BUG=https://code.google.com/p/webm/issues/detail?id=1005 Change-Id: I23e0a601b7259fa9513cb86110c41b8437769808
Diffstat (limited to 'webmenc.cc')
-rw-r--r--webmenc.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/webmenc.cc b/webmenc.cc
index a0e542b17..8212ee36c 100644
--- a/webmenc.cc
+++ b/webmenc.cc
@@ -24,7 +24,8 @@ void write_webm_file_header(struct EbmlGlobal *glob,
const vpx_codec_enc_cfg_t *cfg,
const struct vpx_rational *fps,
stereo_format_t stereo_fmt,
- unsigned int fourcc) {
+ unsigned int fourcc,
+ const struct VpxRational *par) {
mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(glob->stream);
mkvmuxer::Segment *const segment = new mkvmuxer::Segment();
segment->Init(writer);
@@ -49,6 +50,15 @@ void write_webm_file_header(struct EbmlGlobal *glob,
segment->GetTrackByNumber(video_track_id));
video_track->SetStereoMode(stereo_fmt);
video_track->set_codec_id(fourcc == VP8_FOURCC ? "V_VP8" : "V_VP9");
+ if (par->numerator > 1 || par->denominator > 1) {
+ // TODO(fgalligan): Add support of DisplayUnit, Display Aspect Ratio type
+ // to WebM format.
+ const uint64_t display_width =
+ static_cast<uint64_t>(((cfg->g_w * par->numerator * 1.0) /
+ par->denominator) + .5);
+ video_track->set_display_width(display_width);
+ video_track->set_display_height(cfg->g_h);
+ }
if (glob->debug) {
video_track->set_uid(kDebugTrackUid);
}