]> granicus.if.org Git - libvpx/blobdiff - webmenc.cc
third_party: Roll libwebm snapshot.
[libvpx] / webmenc.cc
index a0e542b17cfdd4bca8622ebc067d839e0270b3a5..caf439157cb4ac85fc9e83a17ffdd42df98728e5 100644 (file)
@@ -11,9 +11,9 @@
 
 #include <string>
 
-#include "third_party/libwebm/mkvmuxer.hpp"
-#include "third_party/libwebm/mkvmuxerutil.hpp"
-#include "third_party/libwebm/mkvwriter.hpp"
+#include "third_party/libwebm/mkvmuxer/mkvmuxer.h"
+#include "third_party/libwebm/mkvmuxer/mkvmuxerutil.h"
+#include "third_party/libwebm/mkvmuxer/mkvwriter.h"
 
 namespace {
 const uint64_t kDebugTrackUid = 0xDEADBEEF;
@@ -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);
@@ -48,7 +49,31 @@ void write_webm_file_header(struct EbmlGlobal *glob,
       static_cast<mkvmuxer::VideoTrack*>(
           segment->GetTrackByNumber(video_track_id));
   video_track->SetStereoMode(stereo_fmt);
-  video_track->set_codec_id(fourcc == VP8_FOURCC ? "V_VP8" : "V_VP9");
+  const char *codec_id;
+  switch (fourcc) {
+  case VP8_FOURCC:
+    codec_id = "V_VP8";
+    break;
+  case VP9_FOURCC:
+    codec_id = "V_VP9";
+    break;
+  case VP10_FOURCC:
+    codec_id = "V_VP10";
+    break;
+  default:
+    codec_id = "V_VP10";
+    break;
+  }
+  video_track->set_codec_id(codec_id);
+  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);
   }