s/EbmlGlobal/WebmOutputContext/

Manually cherry-picked from libvpx/nextgenv2
9441f10b516cbce29890f0413e1fb469048fe818

Change-Id: I51c20902770938f456ce0b68b42ca5ed2f821896
diff --git a/aomenc.c b/aomenc.c
index 35ee925..a8877d1 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -751,7 +751,7 @@
 
 #if !CONFIG_WEBM_IO
 typedef int stereo_format_t;
-struct EbmlGlobal {
+struct WebmOutputContext {
   int debug;
 };
 #endif
@@ -781,7 +781,7 @@
   struct stream_config config;
   FILE *file;
   struct rate_hist *rate_hist;
-  struct EbmlGlobal ebml;
+  struct WebmOutputContext webm_ctx;
   uint64_t psnr_sse_total;
   uint64_t psnr_samples_total;
   double psnr_totals[4];
@@ -1012,13 +1012,13 @@
     stream->config.write_webm = 1;
 #if CONFIG_WEBM_IO
     stream->config.stereo_fmt = STEREO_FORMAT_MONO;
-    stream->ebml.last_pts_ns = -1;
-    stream->ebml.writer = NULL;
-    stream->ebml.segment = NULL;
+    stream->webm_ctx.last_pts_ns = -1;
+    stream->webm_ctx.writer = NULL;
+    stream->webm_ctx.segment = NULL;
 #endif
 
     /* Allows removal of the application version from the EBML tags */
-    stream->ebml.debug = global->debug;
+    stream->webm_ctx.debug = global->debug;
 
     /* Default lag_in_frames is 0 in realtime mode */
     if (global->deadline == AOM_DL_REALTIME)
@@ -1393,9 +1393,10 @@
 
 #if CONFIG_WEBM_IO
   if (stream->config.write_webm) {
-    stream->ebml.stream = stream->file;
-    write_webm_file_header(&stream->ebml, cfg, stream->config.stereo_fmt,
-                           global->codec->fourcc, pixel_aspect_ratio);
+    stream->webm_ctx.stream = stream->file;
+    write_webm_file_header(&stream->webm_ctx, cfg, &global->framerate,
+                           stream->config.stereo_fmt, global->codec->fourcc,
+                           pixel_aspect_ratio);
   }
 #else
   (void)pixel_aspect_ratio;
@@ -1414,7 +1415,7 @@
 
 #if CONFIG_WEBM_IO
   if (stream->config.write_webm) {
-    write_webm_file_footer(&stream->ebml);
+    write_webm_file_footer(&stream->webm_ctx);
   }
 #endif
 
@@ -1622,7 +1623,7 @@
         update_rate_histogram(stream->rate_hist, cfg, pkt);
 #if CONFIG_WEBM_IO
         if (stream->config.write_webm) {
-          write_webm_block(&stream->ebml, cfg, pkt);
+          write_webm_block(&stream->webm_ctx, cfg, pkt);
         }
 #endif
         if (!stream->config.write_webm) {
diff --git a/webmenc.cc b/webmenc.cc
index e9e6cd0..f78f027 100644
--- a/webmenc.cc
+++ b/webmenc.cc
@@ -22,11 +22,12 @@
 const int kVideoTrackNumber = 1;
 }  // namespace
 
-void write_webm_file_header(struct EbmlGlobal *glob,
+void write_webm_file_header(struct WebmOutputContext *webm_ctx,
                             const aom_codec_enc_cfg_t *cfg,
+                            const struct aom_rational *fps,
                             stereo_format_t stereo_fmt, unsigned int fourcc,
                             const struct AvxRational *par) {
-  mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(glob->stream);
+  mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(webm_ctx->stream);
   mkvmuxer::Segment *const segment = new mkvmuxer::Segment();
   segment->Init(writer);
   segment->set_mode(mkvmuxer::Segment::kFile);
@@ -36,7 +37,7 @@
   const uint64_t kTimecodeScale = 1000000;
   info->set_timecode_scale(kTimecodeScale);
   std::string version = "aomenc";
-  if (!glob->debug) {
+  if (!webm_ctx->debug) {
     version.append(std::string(" ") + aom_codec_version_str());
   }
   info->set_writing_app(version.c_str());
@@ -61,35 +62,36 @@
     video_track->set_display_width(display_width);
     video_track->set_display_height(cfg->g_h);
   }
-  if (glob->debug) {
+  if (webm_ctx->debug) {
     video_track->set_uid(kDebugTrackUid);
   }
-  glob->writer = writer;
-  glob->segment = segment;
+  webm_ctx->writer = writer;
+  webm_ctx->segment = segment;
 }
 
-void write_webm_block(struct EbmlGlobal *glob, const aom_codec_enc_cfg_t *cfg,
+void write_webm_block(struct WebmOutputContext *webm_ctx,
+                      const aom_codec_enc_cfg_t *cfg,
                       const aom_codec_cx_pkt_t *pkt) {
   mkvmuxer::Segment *const segment =
-      reinterpret_cast<mkvmuxer::Segment *>(glob->segment);
+      reinterpret_cast<mkvmuxer::Segment *>(webm_ctx->segment);
   int64_t pts_ns = pkt->data.frame.pts * 1000000000ll * cfg->g_timebase.num /
                    cfg->g_timebase.den;
-  if (pts_ns <= glob->last_pts_ns) pts_ns = glob->last_pts_ns + 1000000;
-  glob->last_pts_ns = pts_ns;
+  if (pts_ns <= webm_ctx->last_pts_ns) pts_ns = webm_ctx->last_pts_ns + 1000000;
+  webm_ctx->last_pts_ns = pts_ns;
 
   segment->AddFrame(static_cast<uint8_t *>(pkt->data.frame.buf),
                     pkt->data.frame.sz, kVideoTrackNumber, pts_ns,
                     pkt->data.frame.flags & AOM_FRAME_IS_KEY);
 }
 
-void write_webm_file_footer(struct EbmlGlobal *glob) {
+void write_webm_file_footer(struct WebmOutputContext *webm_ctx) {
   mkvmuxer::MkvWriter *const writer =
-      reinterpret_cast<mkvmuxer::MkvWriter *>(glob->writer);
+      reinterpret_cast<mkvmuxer::MkvWriter *>(webm_ctx->writer);
   mkvmuxer::Segment *const segment =
-      reinterpret_cast<mkvmuxer::Segment *>(glob->segment);
+      reinterpret_cast<mkvmuxer::Segment *>(webm_ctx->segment);
   segment->Finalize();
   delete segment;
   delete writer;
-  glob->writer = NULL;
-  glob->segment = NULL;
+  webm_ctx->writer = NULL;
+  webm_ctx->segment = NULL;
 }
diff --git a/webmenc.h b/webmenc.h
index c86e2af..90211ff 100644
--- a/webmenc.h
+++ b/webmenc.h
@@ -21,8 +21,7 @@
 extern "C" {
 #endif
 
-/* TODO(vigneshv): Rename this struct */
-struct EbmlGlobal {
+struct WebmOutputContext {
   int debug;
   FILE *stream;
   int64_t last_pts_ns;
@@ -39,15 +38,17 @@
   STEREO_FORMAT_RIGHT_LEFT = 11
 } stereo_format_t;
 
-void write_webm_file_header(struct EbmlGlobal *glob,
+void write_webm_file_header(struct WebmOutputContext *webm_ctx,
                             const aom_codec_enc_cfg_t *cfg,
+                            const struct aom_rational *fps,
                             stereo_format_t stereo_fmt, unsigned int fourcc,
                             const struct AvxRational *par);
 
-void write_webm_block(struct EbmlGlobal *glob, const aom_codec_enc_cfg_t *cfg,
+void write_webm_block(struct WebmOutputContext *webm_ctx,
+                      const aom_codec_enc_cfg_t *cfg,
                       const aom_codec_cx_pkt_t *pkt);
 
-void write_webm_file_footer(struct EbmlGlobal *glob);
+void write_webm_file_footer(struct WebmOutputContext *webm_ctx);
 
 #ifdef __cplusplus
 }  // extern "C"