Upgrade libwebm to libwebm-1.0.0.30 am: f81005e742 am: 5d97098820 am: 232b5fcb45 am: f9b5f833d2 am: 9af670f424

Original change: https://android-review.googlesource.com/c/platform/external/libwebm/+/2652407

Change-Id: I0ad12339a18b013b60db2559565969241465cd27
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/.cmake-format.py b/.cmake-format.py
new file mode 100644
index 0000000..f1db75d
--- /dev/null
+++ b/.cmake-format.py
@@ -0,0 +1,240 @@
+# ----------------------------------
+# Options affecting listfile parsing
+# ----------------------------------
+with section("parse"):
+
+  # Specify structure for custom cmake functions
+  additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'],
+             'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}}
+
+  # Override configurations per-command where available
+  override_spec = {}
+
+  # Specify variable tags.
+  vartags = []
+
+  # Specify property tags.
+  proptags = []
+
+# -----------------------------
+# Options affecting formatting.
+# -----------------------------
+with section("format"):
+
+  # Disable formatting entirely, making cmake-format a no-op
+  disable = False
+
+  # How wide to allow formatted cmake files
+  line_width = 80
+
+  # How many spaces to tab for indent
+  tab_size = 2
+
+  # If true, lines are indented using tab characters (utf-8 0x09) instead of
+  # <tab_size> space characters (utf-8 0x20). In cases where the layout would
+  # require a fractional tab character, the behavior of the  fractional
+  # indentation is governed by <fractional_tab_policy>
+  use_tabchars = False
+
+  # If <use_tabchars> is True, then the value of this variable indicates how
+  # fractional indentions are handled during whitespace replacement. If set to
+  # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
+  # to `round-up` fractional indentation is replaced with a single tab character
+  # (utf-8 0x09) effectively shifting the column to the next tabstop
+  fractional_tab_policy = 'use-space'
+
+  # If an argument group contains more than this many sub-groups (parg or kwarg
+  # groups) then force it to a vertical layout.
+  max_subgroups_hwrap = 2
+
+  # If a positional argument group contains more than this many arguments, then
+  # force it to a vertical layout.
+  max_pargs_hwrap = 6
+
+  # If a cmdline positional group consumes more than this many lines without
+  # nesting, then invalidate the layout (and nest)
+  max_rows_cmdline = 2
+
+  # If true, separate flow control names from their parentheses with a space
+  separate_ctrl_name_with_space = False
+
+  # If true, separate function names from parentheses with a space
+  separate_fn_name_with_space = False
+
+  # If a statement is wrapped to more than one line, than dangle the closing
+  # parenthesis on its own line.
+  dangle_parens = False
+
+  # If the trailing parenthesis must be 'dangled' on its on line, then align it
+  # to this reference: `prefix`: the start of the statement,  `prefix-indent`:
+  # the start of the statement, plus one indentation  level, `child`: align to
+  # the column of the arguments
+  dangle_align = 'prefix'
+
+  # If the statement spelling length (including space and parenthesis) is
+  # smaller than this amount, then force reject nested layouts.
+  min_prefix_chars = 4
+
+  # If the statement spelling length (including space and parenthesis) is larger
+  # than the tab width by more than this amount, then force reject un-nested
+  # layouts.
+  max_prefix_chars = 10
+
+  # If a candidate layout is wrapped horizontally but it exceeds this many
+  # lines, then reject the layout.
+  max_lines_hwrap = 2
+
+  # What style line endings to use in the output.
+  line_ending = 'unix'
+
+  # Format command names consistently as 'lower' or 'upper' case
+  command_case = 'canonical'
+
+  # Format keywords consistently as 'lower' or 'upper' case
+  keyword_case = 'unchanged'
+
+  # A list of command names which should always be wrapped
+  always_wrap = []
+
+  # If true, the argument lists which are known to be sortable will be sorted
+  # lexicographicall
+  enable_sort = True
+
+  # If true, the parsers may infer whether or not an argument list is sortable
+  # (without annotation).
+  autosort = False
+
+  # By default, if cmake-format cannot successfully fit everything into the
+  # desired linewidth it will apply the last, most agressive attempt that it
+  # made. If this flag is True, however, cmake-format will print error, exit
+  # with non-zero status code, and write-out nothing
+  require_valid_layout = False
+
+  # A dictionary mapping layout nodes to a list of wrap decisions. See the
+  # documentation for more information.
+  layout_passes = {}
+
+# ------------------------------------------------
+# Options affecting comment reflow and formatting.
+# ------------------------------------------------
+with section("markup"):
+
+  # What character to use for bulleted lists
+  bullet_char = '*'
+
+  # What character to use as punctuation after numerals in an enumerated list
+  enum_char = '.'
+
+  # If comment markup is enabled, don't reflow the first comment block in each
+  # listfile. Use this to preserve formatting of your copyright/license
+  # statements.
+  first_comment_is_literal = True
+
+  # If comment markup is enabled, don't reflow any comment block which matches
+  # this (regex) pattern. Default is `None` (disabled).
+  literal_comment_pattern = None
+
+  # Regular expression to match preformat fences in comments default=
+  # ``r'^\s*([`~]{3}[`~]*)(.*)$'``
+  fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
+
+  # Regular expression to match rulers in comments default=
+  # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
+  ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
+
+  # If a comment line matches starts with this pattern then it is explicitly a
+  # trailing comment for the preceeding argument. Default is '#<'
+  explicit_trailing_pattern = '#<'
+
+  # If a comment line starts with at least this many consecutive hash
+  # characters, then don't lstrip() them off. This allows for lazy hash rulers
+  # where the first hash char is not separated by space
+  hashruler_min_length = 10
+
+  # If true, then insert a space between the first hash char and remaining hash
+  # chars in a hash ruler, and normalize its length to fill the column
+  canonicalize_hashrulers = True
+
+  # enable comment markup parsing and reflow
+  enable_markup = True
+
+# ----------------------------
+# Options affecting the linter
+# ----------------------------
+with section("lint"):
+
+  # a list of lint codes to disable
+  disabled_codes = []
+
+  # regular expression pattern describing valid function names
+  function_pattern = '[0-9a-z_]+'
+
+  # regular expression pattern describing valid macro names
+  macro_pattern = '[0-9A-Z_]+'
+
+  # regular expression pattern describing valid names for variables with global
+  # (cache) scope
+  global_var_pattern = '[A-Z][0-9A-Z_]+'
+
+  # regular expression pattern describing valid names for variables with global
+  # scope (but internal semantic)
+  internal_var_pattern = '_[A-Z][0-9A-Z_]+'
+
+  # regular expression pattern describing valid names for variables with local
+  # scope
+  local_var_pattern = '[a-z][a-z0-9_]+'
+
+  # regular expression pattern describing valid names for privatedirectory
+  # variables
+  private_var_pattern = '_[0-9a-z_]+'
+
+  # regular expression pattern describing valid names for public directory
+  # variables
+  public_var_pattern = '[A-Z][0-9A-Z_]+'
+
+  # regular expression pattern describing valid names for function/macro
+  # arguments and loop variables.
+  argument_var_pattern = '[a-z][a-z0-9_]+'
+
+  # regular expression pattern describing valid names for keywords used in
+  # functions or macros
+  keyword_pattern = '[A-Z][0-9A-Z_]+'
+
+  # In the heuristic for C0201, how many conditionals to match within a loop in
+  # before considering the loop a parser.
+  max_conditionals_custom_parser = 2
+
+  # Require at least this many newlines between statements
+  min_statement_spacing = 1
+
+  # Require no more than this many newlines between statements
+  max_statement_spacing = 2
+  max_returns = 6
+  max_branches = 12
+  max_arguments = 5
+  max_localvars = 15
+  max_statements = 50
+
+# -------------------------------
+# Options affecting file encoding
+# -------------------------------
+with section("encode"):
+
+  # If true, emit the unicode byte-order mark (BOM) at the start of the file
+  emit_byteorder_mark = False
+
+  # Specify the encoding of the input file. Defaults to utf-8
+  input_encoding = 'utf-8'
+
+  # Specify the encoding of the output file. Defaults to utf-8. Note that cmake
+  # only claims to support utf-8 so be careful when using anything else
+  output_encoding = 'utf-8'
+
+# -------------------------------------
+# Miscellaneous configurations options.
+# -------------------------------------
+with section("misc"):
+
+  # A dictionary containing any per-command configuration overrides. Currently
+  # only `command_case` is supported.
+  per_command = {}
diff --git a/.gitignore b/.gitignore
index 2abbaa6..ad6fba1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,35 +1,36 @@
-*.mkv
 *.MKV
-core
 *.a
+*.cmake
 *.d
-*.so*
-*.o
-*~
-*.swp
-*.ncb
-*.user
-*.suo
 *.exe
-/*.webm
-Debug
-Release
-*.sdf
+*.mkv
+*.ncb
+*.o
 *.opensdf
-ipch
+*.sdf
+*.so*
+*.suo
+*.swp
+*.user
+*~
+.vscode
+/*.webm
+CMakeCache.txt
+CMakeFiles
+Debug
+Makefile
+Release
+core
 dumpvtt
+ipch
 mkvmuxer_sample
-mkvparser_sample
-vttdemux
 mkvmuxer_tests
+mkvparser_sample
 mkvparser_tests
-webm_info
+vp9_header_parser_tests
+vp9_level_stats_tests
+vttdemux
 webm2pes
 webm2pes_tests
 webm2ts
-vp9_header_parser_tests
-vp9_level_stats_tests
-Makefile
-CMakeFiles
-CMakeCache.txt
-*.cmake
+webm_info
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..63683a0
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,6 @@
+Hui Su <huisu@google.com>
+Matthew Heaney <matthewjheaney@google.com>
+Neil Birkbeck <birkbeck@google.com>
+Patrik Carlsson <patrik2.carlsson@sonymobile.com>
+Roberto Alanis Baez <alanisbaez@google.com>
+Tom Finegan <tomfinegan@google.com> <tomfinegan@chromium.org>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 99e904f..5a35f34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,19 +1,21 @@
-##  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
-##
-##  Use of this source code is governed by a BSD-style license
-##  that can be found in the LICENSE file in the root of the source
-##  tree. An additional intellectual property rights grant can be found
-##  in the file PATENTS.  All contributing project authors may
-##  be found in the AUTHORS file in the root of the source tree.
+#  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
+#
+#  Use of this source code is governed by a BSD-style license
+#  that can be found in the LICENSE file in the root of the source
+#  tree. An additional intellectual property rights grant can be found
+#  in the file PATENTS.  All contributing project authors may
+#  be found in the AUTHORS file in the root of the source tree.
 cmake_minimum_required(VERSION 3.2)
 project(LIBWEBM CXX)
 
 include(GNUInstallDirs)
 include("${CMAKE_CURRENT_SOURCE_DIR}/build/cxx_flags.cmake")
 
-if (NOT BUILD_SHARED_LIBS)
+if(BUILD_SHARED_LIBS)
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+else()
   include("${CMAKE_CURRENT_SOURCE_DIR}/build/msvc_runtime.cmake")
-endif ()
+endif()
 
 set(LIBWEBM_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
 
@@ -24,8 +26,11 @@
 option(ENABLE_IWYU "Enables include-what-you-use support." OFF)
 option(ENABLE_WERROR "Enable warnings as errors." OFF)
 option(ENABLE_WEBM_PARSER "Enables new parser API." OFF)
+option(ENABLE_SAMPLE_PROGRAMS "Enables building sample programs." ON)
 
-if(WIN32 OR CYGWIN OR MSYS)
+if(WIN32
+   OR CYGWIN
+   OR MSYS)
   # Allow use of rand_r() / fdopen() and other POSIX functions.
   require_cxx_flag_nomsvc("-std=gnu++11")
 else()
@@ -39,14 +44,15 @@
 # Set up compiler flags and build properties.
 include_directories("${LIBWEBM_SRC_DIR}")
 
-if (MSVC)
+if(MSVC)
+  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
   add_cxx_flag_if_supported("/W4")
   # Disable MSVC warnings that suggest making code non-portable.
   add_cxx_flag_if_supported("/wd4996")
-  if (ENABLE_WERROR)
+  if(ENABLE_WERROR)
     add_cxx_flag_if_supported("/WX")
-  endif ()
-else ()
+  endif()
+else()
   add_cxx_flag_if_supported("-Wall")
   add_cxx_flag_if_supported("-Wc++14-compat")
   add_cxx_flag_if_supported("-Wc++17-compat")
@@ -55,29 +61,34 @@
   add_cxx_flag_if_supported("-Wnarrowing")
   add_cxx_flag_if_supported("-Wno-deprecated")
   add_cxx_flag_if_supported("-Wshorten-64-to-32")
-  if (ENABLE_WERROR)
+  if(ENABLE_WERROR)
     add_cxx_flag_if_supported("-Werror")
-  endif ()
-endif ()
+  endif()
+endif()
 
 # Source list variables.
 set(dumpvtt_sources "${LIBWEBM_SRC_DIR}/dumpvtt.cc")
 
+set(libwebm_common_public_headers "${LIBWEBM_SRC_DIR}/common/webmids.h")
+
 set(libwebm_common_sources
+    ${libwebm_common_public_headers}
     "${LIBWEBM_SRC_DIR}/common/file_util.cc"
     "${LIBWEBM_SRC_DIR}/common/file_util.h"
     "${LIBWEBM_SRC_DIR}/common/hdr_util.cc"
-    "${LIBWEBM_SRC_DIR}/common/hdr_util.h"
-    "${LIBWEBM_SRC_DIR}/common/webmids.h")
+    "${LIBWEBM_SRC_DIR}/common/hdr_util.h")
 
-set(mkvmuxer_sources
-    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxer.cc"
+set(mkvmuxer_public_headers
     "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxer.h"
     "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxertypes.h"
-    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxerutil.cc"
     "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxerutil.h"
+    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvwriter.h")
+
+set(mkvmuxer_sources
+    ${mkvmuxer_public_headers}
+    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxer.cc"
+    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxerutil.cc"
     "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvwriter.cc"
-    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvwriter.h"
     "${LIBWEBM_SRC_DIR}/common/webmids.h")
 
 set(mkvmuxer_sample_sources
@@ -90,11 +101,12 @@
     "${LIBWEBM_SRC_DIR}/testing/test_util.cc"
     "${LIBWEBM_SRC_DIR}/testing/test_util.h")
 
+set(mkvparser_public_headers "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.h"
+                             "${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.h")
+
 set(mkvparser_sources
-    "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.cc"
-    "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.h"
+    ${mkvparser_public_headers} "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.cc"
     "${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.cc"
-    "${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.h"
     "${LIBWEBM_SRC_DIR}/common/webmids.h")
 
 set(mkvparser_sample_sources "${LIBWEBM_SRC_DIR}/mkvparser_sample.cc")
@@ -119,11 +131,6 @@
     "${LIBWEBM_SRC_DIR}/testing/test_util.cc"
     "${LIBWEBM_SRC_DIR}/testing/test_util.h")
 
-set(vttdemux_sources
-    "${LIBWEBM_SRC_DIR}/vttdemux.cc"
-    "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.cc"
-    "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.h")
-
 set(webm_parser_public_headers
     "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/buffer_reader.h"
     "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/callback.h"
@@ -318,64 +325,58 @@
     "${LIBWEBM_SRC_DIR}/m2ts/tests/webm2pes_tests.cc")
 set(webm2ts_sources "${LIBWEBM_SRC_DIR}/m2ts/vpxpes2ts_main.cc")
 
+set(webvtt_common_headers "${LIBWEBM_SRC_DIR}/webvtt/vttreader.h"
+                          "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.h")
+
 set(webvtt_common_sources
-    "${LIBWEBM_SRC_DIR}/webvtt/vttreader.cc"
-    "${LIBWEBM_SRC_DIR}/webvtt/vttreader.h"
-    "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.cc"
-    "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.h")
+    ${webvtt_common_headers} "${LIBWEBM_SRC_DIR}/webvtt/vttreader.cc"
+    "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.cc")
+
+set(vttdemux_sources ${webvtt_common_sources} "${LIBWEBM_SRC_DIR}/vttdemux.cc")
+
+# Public headers that will be installed with the library.
+set(webm_public_headers ${mkvmuxer_public_headers} ${mkvparser_public_headers})
 
 # Targets.
 add_library(mkvmuxer OBJECT ${mkvmuxer_sources})
 add_library(mkvparser OBJECT ${mkvparser_sources})
 add_library(webvtt_common OBJECT ${webvtt_common_sources})
 
-add_library(webm ${libwebm_common_sources}
-            $<TARGET_OBJECTS:mkvmuxer>
-            $<TARGET_OBJECTS:mkvparser>)
+add_library(webm ${libwebm_common_sources} $<TARGET_OBJECTS:mkvmuxer>
+                 $<TARGET_OBJECTS:mkvparser>)
 
-if (WIN32)
-  # Use libwebm and libwebm.lib for project and library name on Windows (instead
-  # webm and webm.lib).
-  set_target_properties(webm PROPERTIES PROJECT_LABEL libwebm)
-  set_target_properties(webm PROPERTIES PREFIX lib)
-endif ()
+if(ENABLE_SAMPLE_PROGRAMS)
+  add_executable(mkvparser_sample ${mkvparser_sample_sources})
+  target_link_libraries(mkvparser_sample LINK_PUBLIC webm)
 
-add_executable(mkvparser_sample ${mkvparser_sample_sources})
-target_link_libraries(mkvparser_sample LINK_PUBLIC webm)
+  add_executable(mkvmuxer_sample ${mkvmuxer_sample_sources}
+                                 $<TARGET_OBJECTS:webvtt_common>)
+  target_link_libraries(mkvmuxer_sample LINK_PUBLIC webm)
 
-add_executable(mkvmuxer_sample ${mkvmuxer_sample_sources}
-               $<TARGET_OBJECTS:webvtt_common>)
-target_link_libraries(mkvmuxer_sample LINK_PUBLIC webm)
+  add_executable(dumpvtt ${dumpvtt_sources} $<TARGET_OBJECTS:webvtt_common>)
+  target_link_libraries(dumpvtt LINK_PUBLIC webm)
 
-add_executable(dumpvtt ${dumpvtt_sources} $<TARGET_OBJECTS:webvtt_common>)
-target_link_libraries(dumpvtt LINK_PUBLIC webm)
+  add_executable(vttdemux ${vttdemux_sources})
+  target_link_libraries(vttdemux LINK_PUBLIC webm)
+endif()
 
-add_executable(vttdemux ${vttdemux_sources})
-target_link_libraries(vttdemux LINK_PUBLIC webm)
-
-if (ENABLE_WEBMINFO)
+if(ENABLE_WEBMINFO)
   add_executable(webm_info ${webm_info_sources})
   target_link_libraries(webm_info LINK_PUBLIC webm)
-endif ()
+endif()
 
-if (ENABLE_WEBM_PARSER)
+if(ENABLE_WEBM_PARSER)
   include_directories(webm_parser webm_parser/include)
   add_library(webm_parser OBJECT ${webm_parser_sources})
   target_sources(webm PUBLIC $<TARGET_OBJECTS:webm_parser>)
-  set_target_properties(webm PROPERTIES PUBLIC_HEADER
-                        "${webm_parser_public_headers}")
 
   add_executable(webm_parser_demo ${webm_parser_demo_sources})
   target_link_libraries(webm_parser_demo LINK_PUBLIC webm)
 
-  install(TARGETS webm
-          ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-          PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm)
-endif ()
+  list(APPEND webm_public_headers ${webm_parser_public_headers})
+endif()
 
-if (ENABLE_WEBMTS)
+if(ENABLE_WEBMTS)
   add_library(webmts OBJECT ${webmts_sources})
 
   add_executable(webm2pes ${webm2pes_sources} $<TARGET_OBJECTS:webmts>)
@@ -383,20 +384,21 @@
 
   add_executable(webm2ts ${webm2ts_sources} $<TARGET_OBJECTS:webmts>)
   target_link_libraries(webm2ts LINK_PUBLIC webm)
-endif ()
+endif()
 
-if (ENABLE_TESTS)
-  set(GTEST_SRC_DIR "${LIBWEBM_SRC_DIR}/../googletest" CACHE PATH
-      "Path to Googletest git repository.")
+if(ENABLE_TESTS)
+  set(GTEST_SRC_DIR
+      "${LIBWEBM_SRC_DIR}/../googletest"
+      CACHE PATH "Path to Googletest git repository.")
   # This directory is where libwebm will build googletest dependencies.
   set(GTEST_BUILD_DIR "${CMAKE_BINARY_DIR}/googletest_build")
 
-  if (LIBWEBM_DISABLE_GTEST_CMAKE)
+  if(LIBWEBM_DISABLE_GTEST_CMAKE)
     add_library(gtest STATIC "${GTEST_SRC_DIR}/googletest/src/gtest-all.cc")
     include_directories("${GTEST_SRC_DIR}/googletest")
-  else ()
+  else()
     add_subdirectory("${GTEST_SRC_DIR}" "${GTEST_BUILD_DIR}")
-  endif ()
+  endif()
   include_directories("${GTEST_SRC_DIR}/googletest/include")
 
   add_executable(mkvmuxer_tests ${mkvmuxer_tests_sources})
@@ -411,21 +413,21 @@
   add_executable(vp9_level_stats_tests ${vp9_level_stats_tests_sources})
   target_link_libraries(vp9_level_stats_tests LINK_PUBLIC gtest webm)
 
-  if (ENABLE_WEBMTS)
+  if(ENABLE_WEBMTS)
     add_executable(webm2pes_tests ${webm2pes_tests_sources}
-                   $<TARGET_OBJECTS:webmts>)
+                                  $<TARGET_OBJECTS:webmts>)
     target_link_libraries(webm2pes_tests LINK_PUBLIC gtest webm)
-  endif ()
+  endif()
 
-  if (ENABLE_WEBM_PARSER)
+  if(ENABLE_WEBM_PARSER)
     include_directories("${GTEST_SRC_DIR}/googlemock/include")
     add_executable(webm_parser_tests ${webm_parser_tests_sources})
     target_link_libraries(webm_parser_tests LINK_PUBLIC gmock gtest webm)
-  endif ()
-endif ()
+  endif()
+endif()
 
 # Include-what-you-use.
-if (ENABLE_IWYU)
+if(ENABLE_IWYU)
   # Make sure all the tools necessary for IWYU are present.
   find_program(iwyu_path NAMES include-what-you-use)
   find_program(iwyu_tool_path NAMES iwyu_tool.py)
@@ -435,22 +437,36 @@
   # PYTHONINTERP_FOUND is empty without explicitly looking for it.
   find_package(PythonInterp)
 
-  if (iwyu_path AND iwyu_tool_path AND PYTHONINTERP_FOUND)
+  if(iwyu_path
+     AND iwyu_tool_path
+     AND PYTHONINTERP_FOUND)
     # Enable compilation command export (needed for iwyu_tool.py)
     set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
     # Add a custom target to run iwyu across all targets.
-    add_custom_target(iwyu
-                      ALL
-                      COMMAND "${PYTHON_EXECUTABLE}" "${iwyu_tool_path}" -p
-                          "${CMAKE_BINARY_DIR}"
-                      COMMENT "Running include-what-you-use..."
-                      VERBATIM)
-  else ()
+    add_custom_target(
+      iwyu ALL
+      COMMAND "${PYTHON_EXECUTABLE}" "${iwyu_tool_path}" -p
+              "${CMAKE_BINARY_DIR}"
+      COMMENT "Running include-what-you-use..."
+      VERBATIM)
+  else()
     message(STATUS "Ignoring ENABLE_IWYU because reasons:")
     message(STATUS "  iwyu_path=" ${iwyu_path})
     message(STATUS "  iwyu_tool_path=" ${iwyu_tool_path})
     message(STATUS "  PYTHONINTERP_FOUND=" ${PYTHONINTERP_FOUND})
     message(STATUS "  See README.libwebm for more information.")
-  endif ()
-endif ()
+  endif()
+endif()
+
+set_target_properties(webm PROPERTIES PUBLIC_HEADER "${webm_public_headers}")
+install(
+  TARGETS webm
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm)
+
+# Install common headers into a subdirectory to avoid breaking nested includes.
+install(FILES ${libwebm_common_public_headers}
+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm/common)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7a73a30..a30c512 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -23,6 +23,18 @@
 [WebM Project page](https://www.webmproject.org/code/contribute/submitting-patches/)
 for additional details.
 
+## Code Style
+
+The C++ code style is based on the
+[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) and
+`clang-format --style=Google`. `clang-format -i --style=file` can be used to
+format individual files, it will use the settings from `.clang-format`.
+
+CMake files are formatted with
+[cmake-format](https://cmake-format.readthedocs.io/en/latest/). `cmake-format
+-i` can be used to format individual files, it will use the settings from
+`.cmake-format.py`.
+
 ## Community Guidelines
 
 This project follows
diff --git a/METADATA b/METADATA
index f2b0e26..71479f7 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update libwebm
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
+
 name: "libwebm"
 description: "libwebm is a library to read and write Matroska (MKV) and WebM files."
 third_party {
@@ -9,11 +13,11 @@
     type: GIT
     value: "https://chromium.googlesource.com/webm/libwebm"
   }
-  version: "1930e3ca23b007f3ff11d98a570077be6201957e"
+  version: "libwebm-1.0.0.30"
   license_type: NOTICE
   last_upgrade_date {
     year: 2023
-    month: 3
-    day: 20
+    month: 7
+    day: 11
   }
 }
diff --git a/build/cxx_flags.cmake b/build/cxx_flags.cmake
index 1aa6a86..e67137e 100644
--- a/build/cxx_flags.cmake
+++ b/build/cxx_flags.cmake
@@ -1,10 +1,10 @@
-##  Copyright (c) 2016 The WebM project authors. All Rights Reserved.
-##
-##  Use of this source code is governed by a BSD-style license
-##  that can be found in the LICENSE file in the root of the source
-##  tree. An additional intellectual property rights grant can be found
-##  in the file PATENTS.  All contributing project authors may
-##  be found in the AUTHORS file in the root of the source tree.
+#  Copyright (c) 2016 The WebM project authors. All Rights Reserved.
+#
+#  Use of this source code is governed by a BSD-style license
+#  that can be found in the LICENSE file in the root of the source
+#  tree. An additional intellectual property rights grant can be found
+#  in the file PATENTS.  All contributing project authors may
+#  be found in the AUTHORS file in the root of the source tree.
 
 include(CheckCXXCompilerFlag)
 
@@ -14,59 +14,65 @@
 # Checks C++ compiler for support of $cxx_flag. Adds $cxx_flag to
 # $CMAKE_CXX_FLAGS when the compile test passes. Caches $c_flag in
 # $LIBWEBM_FAILED_CXX_FLAGS when the test fails.
-function (add_cxx_flag_if_supported cxx_flag)
+function(add_cxx_flag_if_supported cxx_flag)
   unset(CXX_FLAG_FOUND CACHE)
   string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
   unset(CXX_FLAG_FAILED CACHE)
   string(FIND "${LIBWEBM_FAILED_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FAILED)
 
-  if (${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1)
+  if(${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1)
     unset(CXX_FLAG_SUPPORTED CACHE)
     message("Checking CXX compiler flag support for: " ${cxx_flag})
     check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED)
-    if (CXX_FLAG_SUPPORTED)
-      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flag}" CACHE STRING ""
-          FORCE)
-    else ()
-      set(LIBWEBM_FAILED_CXX_FLAGS "${LIBWEBM_FAILED_CXX_FLAGS} ${cxx_flag}"
+    if(CXX_FLAG_SUPPORTED)
+      set(CMAKE_CXX_FLAGS
+          "${CMAKE_CXX_FLAGS} ${cxx_flag}"
           CACHE STRING "" FORCE)
-    endif ()
-  endif ()
-endfunction ()
+    else()
+      set(LIBWEBM_FAILED_CXX_FLAGS
+          "${LIBWEBM_FAILED_CXX_FLAGS} ${cxx_flag}"
+          CACHE STRING "" FORCE)
+    endif()
+  endif()
+endfunction()
 
 # Checks CXX compiler for support of $cxx_flag and terminates generation when
 # support is not present.
-function (require_cxx_flag cxx_flag)
+function(require_cxx_flag cxx_flag)
   unset(CXX_FLAG_FOUND CACHE)
   string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND)
 
-  if (${CXX_FLAG_FOUND} EQUAL -1)
+  if(${CXX_FLAG_FOUND} EQUAL -1)
     unset(LIBWEBM_HAVE_CXX_FLAG CACHE)
     message("Checking CXX compiler flag support for: " ${cxx_flag})
     check_cxx_compiler_flag("${cxx_flag}" LIBWEBM_HAVE_CXX_FLAG)
-    if (NOT LIBWEBM_HAVE_CXX_FLAG)
-      message(FATAL_ERROR
-              "${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
-    endif ()
-    set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
-  endif ()
-endfunction ()
+    if(NOT LIBWEBM_HAVE_CXX_FLAG)
+      message(
+        FATAL_ERROR
+          "${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
+    endif()
+    set(CMAKE_CXX_FLAGS
+        "${cxx_flag} ${CMAKE_CXX_FLAGS}"
+        CACHE STRING "" FORCE)
+  endif()
+endfunction()
 
 # Checks only non-MSVC targets for support of $cxx_flag.
-function (require_cxx_flag_nomsvc cxx_flag)
-  if (NOT MSVC)
+function(require_cxx_flag_nomsvc cxx_flag)
+  if(NOT MSVC)
     require_cxx_flag(${cxx_flag})
-  endif ()
-endfunction ()
+  endif()
+endfunction()
 
 # Adds $preproc_def to CXX compiler command line (as -D$preproc_def) if not
 # already present.
-function (add_cxx_preproc_definition preproc_def)
+function(add_cxx_preproc_definition preproc_def)
   unset(PREPROC_DEF_FOUND CACHE)
   string(FIND "${CMAKE_CXX_FLAGS}" "${preproc_def}" PREPROC_DEF_FOUND)
 
-  if (${PREPROC_DEF_FOUND} EQUAL -1)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${preproc_def}" CACHE STRING ""
-        FORCE)
-  endif ()
-endfunction ()
+  if(${PREPROC_DEF_FOUND} EQUAL -1)
+    set(CMAKE_CXX_FLAGS
+        "${CMAKE_CXX_FLAGS} -D${preproc_def}"
+        CACHE STRING "" FORCE)
+  endif()
+endfunction()
diff --git a/build/msvc_runtime.cmake b/build/msvc_runtime.cmake
index 4f53a36..7058577 100644
--- a/build/msvc_runtime.cmake
+++ b/build/msvc_runtime.cmake
@@ -1,22 +1,22 @@
-##  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
-##
-##  Use of this source code is governed by a BSD-style license
-##  that can be found in the LICENSE file in the root of the source
-##  tree. An additional intellectual property rights grant can be found
-##  in the file PATENTS.  All contributing project authors may
-##  be found in the AUTHORS file in the root of the source tree.
+#  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
+#
+#  Use of this source code is governed by a BSD-style license
+#  that can be found in the LICENSE file in the root of the source
+#  tree. An additional intellectual property rights grant can be found
+#  in the file PATENTS.  All contributing project authors may
+#  be found in the AUTHORS file in the root of the source tree.
 
-if (MSVC)
+if(MSVC)
   # CMake defaults to producing code linked to the DLL MSVC runtime. In libwebm
   # static is typically desired. Force static code generation unless the user
   # running CMake set MSVC_RUNTIME to dll.
-  if (NOT "${MSVC_RUNTIME}" STREQUAL "dll")
-    foreach (flag_var
-             CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
-             CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
-      if (${flag_var} MATCHES "/MD")
+  if(NOT "${MSVC_RUNTIME}" STREQUAL "dll")
+    foreach(flag_var
+            CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+            CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+      if(${flag_var} MATCHES "/MD")
         string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
-      endif (${flag_var} MATCHES "/MD")
-    endforeach (flag_var)
-  endif ()
-endif ()
+      endif(${flag_var} MATCHES "/MD")
+    endforeach(flag_var)
+  endif()
+endif()
diff --git a/build/x86-mingw-gcc.cmake b/build/x86-mingw-gcc.cmake
index 8416eaf..3469df2 100644
--- a/build/x86-mingw-gcc.cmake
+++ b/build/x86-mingw-gcc.cmake
@@ -1,26 +1,26 @@
-##  Copyright (c) 2017 The WebM project authors. All Rights Reserved.
-##
-##  Use of this source code is governed by a BSD-style license
-##  that can be found in the LICENSE file in the root of the source
-##  tree. An additional intellectual property rights grant can be found
-##  in the file PATENTS.  All contributing project authors may
-##  be found in the AUTHORS file in the root of the source tree.
-if (NOT LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_)
-set(LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_ 1)
+#  Copyright (c) 2017 The WebM project authors. All Rights Reserved.
+#
+#  Use of this source code is governed by a BSD-style license
+#  that can be found in the LICENSE file in the root of the source
+#  tree. An additional intellectual property rights grant can be found
+#  in the file PATENTS.  All contributing project authors may
+#  be found in the AUTHORS file in the root of the source tree.
+if(NOT LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_)
+  set(LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_ 1)
 
-set(CMAKE_SYSTEM_PROCESSOR "x86")
-set(CMAKE_SYSTEM_NAME "Windows")
-set(CMAKE_C_COMPILER_ARG1 "-m32")
-set(CMAKE_CXX_COMPILER_ARG1 "-m32")
+  set(CMAKE_SYSTEM_PROCESSOR "x86")
+  set(CMAKE_SYSTEM_NAME "Windows")
+  set(CMAKE_C_COMPILER_ARG1 "-m32")
+  set(CMAKE_CXX_COMPILER_ARG1 "-m32")
 
-if ("${CROSS}" STREQUAL "")
-  set(CROSS i686-w64-mingw32-)
-endif ()
+  if("${CROSS}" STREQUAL "")
+    set(CROSS i686-w64-mingw32-)
+  endif()
 
-set(CMAKE_C_COMPILER ${CROSS}gcc)
-set(CMAKE_CXX_COMPILER ${CROSS}g++)
+  set(CMAKE_C_COMPILER ${CROSS}gcc)
+  set(CMAKE_CXX_COMPILER ${CROSS}g++)
 
-# Disable googletest CMake usage for mingw cross compiles.
-set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
+  # Disable googletest CMake usage for mingw cross compiles.
+  set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
 
-endif ()  # LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_
+endif() # LIBWEBM_BUILD_X86_MINGW_GCC_CMAKE_
diff --git a/build/x86_64-mingw-gcc.cmake b/build/x86_64-mingw-gcc.cmake
index 9db28b7..c8d8fe4 100644
--- a/build/x86_64-mingw-gcc.cmake
+++ b/build/x86_64-mingw-gcc.cmake
@@ -1,24 +1,24 @@
-##  Copyright (c) 2017 The WebM project authors. All Rights Reserved.
-##
-##  Use of this source code is governed by a BSD-style license
-##  that can be found in the LICENSE file in the root of the source
-##  tree. An additional intellectual property rights grant can be found
-##  in the file PATENTS.  All contributing project authors may
-##  be found in the AUTHORS file in the root of the source tree.
-if (NOT LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_)
-set(LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_ 1)
+#  Copyright (c) 2017 The WebM project authors. All Rights Reserved.
+#
+#  Use of this source code is governed by a BSD-style license
+#  that can be found in the LICENSE file in the root of the source
+#  tree. An additional intellectual property rights grant can be found
+#  in the file PATENTS.  All contributing project authors may
+#  be found in the AUTHORS file in the root of the source tree.
+if(NOT LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_)
+  set(LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_ 1)
 
-set(CMAKE_SYSTEM_PROCESSOR "x86_64")
-set(CMAKE_SYSTEM_NAME "Windows")
+  set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+  set(CMAKE_SYSTEM_NAME "Windows")
 
-if ("${CROSS}" STREQUAL "")
-  set(CROSS x86_64-w64-mingw32-)
-endif ()
+  if("${CROSS}" STREQUAL "")
+    set(CROSS x86_64-w64-mingw32-)
+  endif()
 
-set(CMAKE_C_COMPILER ${CROSS}gcc)
-set(CMAKE_CXX_COMPILER ${CROSS}g++)
+  set(CMAKE_C_COMPILER ${CROSS}gcc)
+  set(CMAKE_CXX_COMPILER ${CROSS}g++)
 
-# Disable googletest CMake usage for mingw cross compiles.
-set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
+  # Disable googletest CMake usage for mingw cross compiles.
+  set(LIBWEBM_DISABLE_GTEST_CMAKE 1)
 
-endif ()  # LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_
+endif() # LIBWEBM_BUILD_X86_64_MINGW_GCC_CMAKE_
diff --git a/mkvmuxer/mkvmuxer.cc b/mkvmuxer/mkvmuxer.cc
index faaf016..21e51be 100644
--- a/mkvmuxer/mkvmuxer.cc
+++ b/mkvmuxer/mkvmuxer.cc
@@ -65,7 +65,8 @@
   if (dst == NULL)
     return false;
 
-  strcpy(dst, src);  // NOLINT
+  memcpy(dst, src, size - 1);
+  dst[size - 1] = '\0';
   return true;
 }
 
@@ -919,11 +920,8 @@
     const size_t length = strlen(codec_id) + 1;
     codec_id_ = new (std::nothrow) char[length];  // NOLINT
     if (codec_id_) {
-#ifdef _MSC_VER
-      strcpy_s(codec_id_, length, codec_id);
-#else
-      strcpy(codec_id_, codec_id);
-#endif
+      memcpy(codec_id_, codec_id, length - 1);
+      codec_id_[length - 1] = '\0';
     }
   }
 }
@@ -936,11 +934,8 @@
     const size_t length = strlen(language) + 1;
     language_ = new (std::nothrow) char[length];  // NOLINT
     if (language_) {
-#ifdef _MSC_VER
-      strcpy_s(language_, length, language);
-#else
-      strcpy(language_, language);
-#endif
+      memcpy(language_, language, length - 1);
+      language_[length - 1] = '\0';
     }
   }
 }
@@ -952,11 +947,8 @@
     const size_t length = strlen(name) + 1;
     name_ = new (std::nothrow) char[length];  // NOLINT
     if (name_) {
-#ifdef _MSC_VER
-      strcpy_s(name_, length, name);
-#else
-      strcpy(name_, name);
-#endif
+      memcpy(name_, name, length - 1);
+      name_[length - 1] = '\0';
     }
   }
 }
@@ -1559,11 +1551,8 @@
     const size_t length = strlen(colour_space) + 1;
     colour_space_ = new (std::nothrow) char[length];  // NOLINT
     if (colour_space_) {
-#ifdef _MSC_VER
-      strcpy_s(colour_space_, length, colour_space);
-#else
-      strcpy(colour_space_, colour_space);
-#endif
+      memcpy(colour_space_, colour_space, length - 1);
+      colour_space_[length - 1] = '\0';
     }
   }
 }
@@ -2856,13 +2845,13 @@
 
 uint32_t SeekHead::GetId(int index) const {
   if (index < 0 || index >= kSeekEntryCount)
-    return UINT_MAX;
+    return UINT32_MAX;
   return seek_entry_id_[index];
 }
 
 uint64_t SeekHead::GetPosition(int index) const {
   if (index < 0 || index >= kSeekEntryCount)
-    return ULLONG_MAX;
+    return UINT64_MAX;
   return seek_entry_pos_[index];
 }
 
@@ -2896,7 +2885,7 @@
       muxing_app_(NULL),
       timecode_scale_(1000000ULL),
       writing_app_(NULL),
-      date_utc_(LLONG_MIN),
+      date_utc_(INT64_MIN),
       duration_pos_(-1) {}
 
 SegmentInfo::~SegmentInfo() {
@@ -2927,11 +2916,8 @@
   if (!muxing_app_)
     return false;
 
-#ifdef _MSC_VER
-  strcpy_s(muxing_app_, app_len, temp);
-#else
-  strcpy(muxing_app_, temp);
-#endif
+  memcpy(muxing_app_, temp, app_len - 1);
+  muxing_app_[app_len - 1] = '\0';
 
   set_writing_app(temp);
   if (!writing_app_)
@@ -2974,7 +2960,7 @@
   if (duration_ > 0.0)
     size +=
         EbmlElementSize(libwebm::kMkvDuration, static_cast<float>(duration_));
-  if (date_utc_ != LLONG_MIN)
+  if (date_utc_ != INT64_MIN)
     size += EbmlDateElementSize(libwebm::kMkvDateUTC);
   size += EbmlElementSize(libwebm::kMkvMuxingApp, muxing_app_);
   size += EbmlElementSize(libwebm::kMkvWritingApp, writing_app_);
@@ -2999,7 +2985,7 @@
       return false;
   }
 
-  if (date_utc_ != LLONG_MIN)
+  if (date_utc_ != INT64_MIN)
     WriteEbmlDateElement(writer, libwebm::kMkvDateUTC, date_utc_);
 
   if (!WriteEbmlElement(writer, libwebm::kMkvMuxingApp, muxing_app_))
@@ -3022,11 +3008,8 @@
     if (!temp_str)
       return;
 
-#ifdef _MSC_VER
-    strcpy_s(temp_str, length, app);
-#else
-    strcpy(temp_str, app);
-#endif
+    memcpy(temp_str, app, length - 1);
+    temp_str[length - 1] = '\0';
 
     delete[] muxing_app_;
     muxing_app_ = temp_str;
@@ -3040,11 +3023,8 @@
     if (!temp_str)
       return;
 
-#ifdef _MSC_VER
-    strcpy_s(temp_str, length, app);
-#else
-    strcpy(temp_str, app);
-#endif
+    memcpy(temp_str, app, length - 1);
+    temp_str[length - 1] = '\0';
 
     delete[] writing_app_;
     writing_app_ = temp_str;
@@ -3628,19 +3608,17 @@
     if (chunking_ && !strcmp(filename, chunking_base_name_))
       return true;
 
-    const size_t name_length = strlen(filename) + 1;
-    char* const temp = new (std::nothrow) char[name_length];  // NOLINT
+    const size_t filename_length = strlen(filename);
+    char* const temp = new (std::nothrow) char[filename_length + 1];  // NOLINT
     if (!temp)
       return false;
 
-#ifdef _MSC_VER
-    strcpy_s(temp, name_length, filename);
-#else
-    strcpy(temp, filename);
-#endif
+    memcpy(temp, filename, filename_length);
+    temp[filename_length] = '\0';
 
     delete[] chunking_base_name_;
     chunking_base_name_ = temp;
+    // From this point, strlen(chunking_base_name_) == filename_length
 
     if (!UpdateChunkName("chk", &chunk_name_))
       return false;
@@ -3666,18 +3644,16 @@
     if (!chunk_writer_cluster_->Open(chunk_name_))
       return false;
 
-    const size_t header_length = strlen(filename) + strlen(".hdr") + 1;
+    const size_t hdr_length = strlen(".hdr");
+    const size_t header_length = filename_length + hdr_length + 1;
     char* const header = new (std::nothrow) char[header_length];  // NOLINT
     if (!header)
       return false;
 
-#ifdef _MSC_VER
-    strcpy_s(header, header_length - strlen(".hdr"), chunking_base_name_);
-    strcat_s(header, header_length, ".hdr");
-#else
-    strcpy(header, chunking_base_name_);
-    strcat(header, ".hdr");
-#endif
+    memcpy(header, chunking_base_name_, filename_length);
+    memcpy(&header[filename_length], ".hdr", hdr_length);
+    header[filename_length + hdr_length] = '\0';
+
     if (!chunk_writer_header_->Open(header)) {
       delete[] header;
       return false;
@@ -4022,18 +3998,16 @@
   snprintf(ext_chk, sizeof(ext_chk), "_%06d.%s", chunk_count_, ext);
 #endif
 
-  const size_t length = strlen(chunking_base_name_) + strlen(ext_chk) + 1;
+  const size_t chunking_base_name_length = strlen(chunking_base_name_);
+  const size_t ext_chk_length = strlen(ext_chk);
+  const size_t length = chunking_base_name_length + ext_chk_length + 1;
   char* const str = new (std::nothrow) char[length];  // NOLINT
   if (!str)
     return false;
 
-#ifdef _MSC_VER
-  strcpy_s(str, length - strlen(ext_chk), chunking_base_name_);
-  strcat_s(str, length, ext_chk);
-#else
-  strcpy(str, chunking_base_name_);
-  strcat(str, ext_chk);
-#endif
+  memcpy(str, chunking_base_name_, chunking_base_name_length);
+  memcpy(&str[chunking_base_name_length], ext_chk, ext_chk_length);
+  str[chunking_base_name_length + ext_chk_length] = '\0';
 
   delete[] * name;
   *name = str;
diff --git a/mkvmuxer/mkvmuxer.h b/mkvmuxer/mkvmuxer.h
index 8602d82..2c4bb9e 100644
--- a/mkvmuxer/mkvmuxer.h
+++ b/mkvmuxer/mkvmuxer.h
@@ -1481,7 +1481,7 @@
   uint64_t timecode_scale_;
   // Initially set to libwebm-%d.%d.%d.%d, major, minor, build, revision.
   char* writing_app_;
-  // LLONG_MIN when DateUTC is not set.
+  // INT64_MIN when DateUTC is not set.
   int64_t date_utc_;
 
   // The file position of the duration element.
diff --git a/mkvmuxer/mkvmuxerutil.cc b/mkvmuxer/mkvmuxerutil.cc
index 300b155..4d7952f 100644
--- a/mkvmuxer/mkvmuxerutil.cc
+++ b/mkvmuxer/mkvmuxerutil.cc
@@ -607,7 +607,7 @@
 void GetVersion(int32* major, int32* minor, int32* build, int32* revision) {
   *major = 0;
   *minor = 3;
-  *build = 1;
+  *build = 2;
   *revision = 0;
 }
 
diff --git a/mkvparser/mkvparser.cc b/mkvparser/mkvparser.cc
index 868afcb..de0fafc 100644
--- a/mkvparser/mkvparser.cc
+++ b/mkvparser/mkvparser.cc
@@ -55,7 +55,7 @@
 void GetVersion(int& major, int& minor, int& build, int& revision) {
   major = 1;
   minor = 1;
-  build = 1;
+  build = 2;
   revision = 0;
 }
 
@@ -4569,7 +4569,8 @@
   if (dst == NULL)
     return -1;
 
-  strcpy(dst, src);
+  memcpy(dst, src, len);
+  dst[len] = '\0';
 
   return 0;
 }