diff --git a/args.h b/args.h
index ea909cb46fc53efbf46b9038e48da2f00c4b2a74..04e0acdf1b811fc4af2123f15760a1f3415438b9 100644
--- a/args.h
+++ b/args.h
@@ -13,6 +13,10 @@
 #define ARGS_H_
 #include <stdio.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct arg {
   char                 **argv;
   const char            *name;
@@ -48,4 +52,8 @@ unsigned int arg_parse_uint(const struct arg *arg);
 int arg_parse_int(const struct arg *arg);
 struct vpx_rational arg_parse_rational(const struct arg *arg);
 int arg_parse_enum_or_int(const struct arg *arg);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // ARGS_H_
diff --git a/md5_utils.h b/md5_utils.h
index 9935eae6d2efd2e10fb732d829b1913d7a1f7564..bd4991b3ad96aa64c88e4ab85dcd40ae0bc03df3 100644
--- a/md5_utils.h
+++ b/md5_utils.h
@@ -23,6 +23,10 @@
 #ifndef MD5_UTILS_H_
 #define MD5_UTILS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define md5byte unsigned char
 #define UWORD32 unsigned int
 
@@ -38,4 +42,8 @@ void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len);
 void MD5Final(unsigned char digest[16], struct MD5Context *context);
 void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // MD5_UTILS_H_
diff --git a/test/clear_system_state.h b/test/clear_system_state.h
index 8f08a4cdb583801812ca024ae7bc406171deb4c9..5e767974431a130173a001f7087ac90453575f7c 100644
--- a/test/clear_system_state.h
+++ b/test/clear_system_state.h
@@ -11,11 +11,9 @@
 #define TEST_CLEAR_SYSTEM_STATE_H_
 
 #include "./vpx_config.h"
-extern "C" {
 #if ARCH_X86 || ARCH_X86_64
 # include "vpx_ports/x86.h"
 #endif
-}
 
 namespace libvpx_test {
 
diff --git a/test/convolve_test.cc b/test/convolve_test.cc
index 9ab60b1c3552f0ea82c9b5354a374c2e839dfa33..e920de874167dfb3752b93c43591ed2e85c0c4d8 100644
--- a/test/convolve_test.cc
+++ b/test/convolve_test.cc
@@ -14,13 +14,11 @@
 #include "test/util.h"
 #include "third_party/googletest/src/include/gtest/gtest.h"
 
-extern "C" {
 #include "./vpx_config.h"
 #include "./vp9_rtcd.h"
 #include "vp9/common/vp9_filter.h"
 #include "vpx_mem/vpx_mem.h"
 #include "vpx_ports/mem.h"
-}
 
 namespace {
 typedef void (*convolve_fn_t)(const uint8_t *src, ptrdiff_t src_stride,
diff --git a/test/dct16x16_test.cc b/test/dct16x16_test.cc
index 5496d0b62676fec4b895fb6d23d2484fa6ab4ab2..ce0431860c2da67e9658e596098eb3c58d3808d1 100644
--- a/test/dct16x16_test.cc
+++ b/test/dct16x16_test.cc
@@ -18,12 +18,13 @@
 #include "test/register_state_check.h"
 #include "test/util.h"
 
-extern "C" {
-#include "vp9/common/vp9_entropy.h"
 #include "./vp9_rtcd.h"
+#include "vp9/common/vp9_entropy.h"
+#include "vpx/vpx_integer.h"
+
+extern "C" {
 void vp9_idct16x16_256_add_c(const int16_t *input, uint8_t *output, int pitch);
 }
-#include "vpx/vpx_integer.h"
 
 using libvpx_test::ACMRandom;
 
diff --git a/test/dct32x32_test.cc b/test/dct32x32_test.cc
index a1e472a0aeae13b8bfc34300fcdc3a565d1fff0f..a2608acb53e250ed50830b349157e8ddf30d855b 100644
--- a/test/dct32x32_test.cc
+++ b/test/dct32x32_test.cc
@@ -18,12 +18,9 @@
 #include "test/register_state_check.h"
 #include "test/util.h"
 
-extern "C" {
 #include "./vpx_config.h"
-#include "vp9/common/vp9_entropy.h"
 #include "./vp9_rtcd.h"
-}
-
+#include "vp9/common/vp9_entropy.h"
 #include "vpx/vpx_integer.h"
 
 using libvpx_test::ACMRandom;
diff --git a/test/fdct4x4_test.cc b/test/fdct4x4_test.cc
index 67426eb74702ea15c1d326a4efb782ec2c97e563..5db5f5caeda8302f065d606144606e4133f0912a 100644
--- a/test/fdct4x4_test.cc
+++ b/test/fdct4x4_test.cc
@@ -18,12 +18,13 @@
 #include "test/register_state_check.h"
 #include "test/util.h"
 
-extern "C" {
-#include "vp9/common/vp9_entropy.h"
 #include "./vp9_rtcd.h"
+#include "vp9/common/vp9_entropy.h"
+#include "vpx/vpx_integer.h"
+
+extern "C" {
 void vp9_idct4x4_16_add_c(const int16_t *input, uint8_t *output, int pitch);
 }
-#include "vpx/vpx_integer.h"
 
 using libvpx_test::ACMRandom;
 
diff --git a/test/fdct8x8_test.cc b/test/fdct8x8_test.cc
index 19ffe26aa2a14b72f2f873d49bdf42e65d31485c..beef980557a928294bd1ed238fa349d24d130fb2 100644
--- a/test/fdct8x8_test.cc
+++ b/test/fdct8x8_test.cc
@@ -18,12 +18,13 @@
 #include "test/register_state_check.h"
 #include "test/util.h"
 
-extern "C" {
-#include "vp9/common/vp9_entropy.h"
 #include "./vp9_rtcd.h"
+#include "vp9/common/vp9_entropy.h"
+#include "vpx/vpx_integer.h"
+
+extern "C" {
 void vp9_idct8x8_64_add_c(const int16_t *input, uint8_t *output, int pitch);
 }
-#include "vpx/vpx_integer.h"
 
 using libvpx_test::ACMRandom;
 
diff --git a/test/intrapred_test.cc b/test/intrapred_test.cc
index 5fba70025081ae7f7365b184c883076e7b53047d..b28f5fbe6c6e2ab2ebacf52ca7ab4242e1d1ebcc 100644
--- a/test/intrapred_test.cc
+++ b/test/intrapred_test.cc
@@ -14,12 +14,11 @@
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
 #include "third_party/googletest/src/include/gtest/gtest.h"
-extern "C" {
+
 #include "./vpx_config.h"
 #include "./vp8_rtcd.h"
 #include "vp8/common/blockd.h"
 #include "vpx_mem/vpx_mem.h"
-}
 
 namespace {
 
diff --git a/test/md5_helper.h b/test/md5_helper.h
index 289f6089b17d829483440ad924ca24803234d180..dd446f4f6d05f2a98f28881c0bfaed46428ae5a6 100644
--- a/test/md5_helper.h
+++ b/test/md5_helper.h
@@ -11,10 +11,8 @@
 #ifndef TEST_MD5_HELPER_H_
 #define TEST_MD5_HELPER_H_
 
-extern "C" {
 #include "./md5_utils.h"
 #include "vpx/vpx_decoder.h"
-}
 
 namespace libvpx_test {
 class MD5 {
diff --git a/test/partial_idct_test.cc b/test/partial_idct_test.cc
index a6569c0c323b14a65cd5cb7436073044b1074fd2..2a32410f3dc79ad29a7518bfa50638eea529ed75 100644
--- a/test/partial_idct_test.cc
+++ b/test/partial_idct_test.cc
@@ -18,12 +18,9 @@
 #include "test/register_state_check.h"
 #include "test/util.h"
 
-extern "C" {
 #include "./vp9_rtcd.h"
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_scan.h"
-}
-
 #include "vpx/vpx_integer.h"
 
 using libvpx_test::ACMRandom;
diff --git a/test/set_roi.cc b/test/set_roi.cc
index 9d2e7715f292d369fb1bdecdd0d52ae153bf8a88..e28f511be6ec69e2da5132ace58ce68285216c0f 100644
--- a/test/set_roi.cc
+++ b/test/set_roi.cc
@@ -18,11 +18,9 @@
 
 #include "third_party/googletest/src/include/gtest/gtest.h"
 #include "test/acm_random.h"
+#include "vp8/encoder/onyx_int.h"
 #include "vpx/vpx_integer.h"
 #include "vpx_mem/vpx_mem.h"
-extern "C" {
-#include "vp8/encoder/onyx_int.h"
-}
 
 using libvpx_test::ACMRandom;
 
diff --git a/test/subtract_test.cc b/test/subtract_test.cc
index d1f2729720792593c7206e90e19dc399965f3cf1..3211c5c8ab436bcdef3c1f95cf36eab4e38c31dd 100644
--- a/test/subtract_test.cc
+++ b/test/subtract_test.cc
@@ -12,13 +12,11 @@
 #include "test/acm_random.h"
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
-extern "C" {
 #include "./vpx_config.h"
 #include "./vp8_rtcd.h"
 #include "vp8/common/blockd.h"
 #include "vp8/encoder/block.h"
 #include "vpx_mem/vpx_mem.h"
-}
 
 typedef void (*subtract_b_fn_t)(BLOCK *be, BLOCKD *bd, int pitch);
 
diff --git a/test/test_libvpx.cc b/test/test_libvpx.cc
index bbcbcf9bcaca482b693a0fe20d4051a1b36bb46a..fc035af8f38e04c2ac73d6e9fffa44a1d4c9523d 100644
--- a/test/test_libvpx.cc
+++ b/test/test_libvpx.cc
@@ -9,10 +9,10 @@
  */
 #include <string>
 #include "./vpx_config.h"
-extern "C" {
 #if ARCH_X86 || ARCH_X86_64
 #include "vpx_ports/x86.h"
 #endif
+extern "C" {
 #if CONFIG_VP8
 extern void vp8_rtcd();
 #endif
diff --git a/test/variance_test.cc b/test/variance_test.cc
index 3f5560170007981143cedb19f52e1386d391526d..b9144ffabcc54ea60e3af94708e8ee8aa157e54b 100644
--- a/test/variance_test.cc
+++ b/test/variance_test.cc
@@ -17,17 +17,15 @@
 
 #include "vpx/vpx_integer.h"
 #include "./vpx_config.h"
-extern "C" {
 #include "vpx_mem/vpx_mem.h"
 #if CONFIG_VP8_ENCODER
-# include "vp8/common/variance.h"
 # include "./vp8_rtcd.h"
+# include "vp8/common/variance.h"
 #endif
 #if CONFIG_VP9_ENCODER
-# include "vp9/encoder/vp9_variance.h"
 # include "./vp9_rtcd.h"
+# include "vp9/encoder/vp9_variance.h"
 #endif
-}
 #include "test/acm_random.h"
 
 namespace {
diff --git a/test/vp8_boolcoder_test.cc b/test/vp8_boolcoder_test.cc
index 0383af20730b10082dd9055ef18d631576a960bf..fa7ee6e8c1f3ff04b600f6c47e95a2c2d1cf478b 100644
--- a/test/vp8_boolcoder_test.cc
+++ b/test/vp8_boolcoder_test.cc
@@ -20,10 +20,8 @@
 #include "third_party/googletest/src/include/gtest/gtest.h"
 #include "vpx/vpx_integer.h"
 
-extern "C" {
 #include "vp8/encoder/boolhuff.h"
 #include "vp8/decoder/dboolhuff.h"
-}
 
 namespace {
 const int num_tests = 10;
diff --git a/test/vp9_boolcoder_test.cc b/test/vp9_boolcoder_test.cc
index 1593c026738ad459b0fad32c5fbb4fcdf7775f0a..c579adeacdbe70328be7689c3fa7a0dfcbe2f287 100644
--- a/test/vp9_boolcoder_test.cc
+++ b/test/vp9_boolcoder_test.cc
@@ -14,10 +14,8 @@
 
 #include "third_party/googletest/src/include/gtest/gtest.h"
 
-extern "C" {
 #include "vp9/decoder/vp9_reader.h"
 #include "vp9/encoder/vp9_writer.h"
-}
 
 #include "test/acm_random.h"
 #include "vpx/vpx_integer.h"
diff --git a/test/vp9_subtract_test.cc b/test/vp9_subtract_test.cc
index e4c4cfeffd279d1c09424691f84d8c219e3b8601..d7df2867d0733d3a537bf00585882bf99cd02e49 100644
--- a/test/vp9_subtract_test.cc
+++ b/test/vp9_subtract_test.cc
@@ -12,12 +12,10 @@
 #include "test/acm_random.h"
 #include "test/clear_system_state.h"
 #include "test/register_state_check.h"
-extern "C" {
 #include "./vpx_config.h"
 #include "./vp9_rtcd.h"
 #include "vp9/common/vp9_blockd.h"
 #include "vpx_mem/vpx_mem.h"
-}
 
 typedef void (*subtract_fn_t)(int rows, int cols,
                               int16_t *diff_ptr, ptrdiff_t diff_stride,
diff --git a/test/y4m_video_source.h b/test/y4m_video_source.h
index bd86c2c042bec6a181540ea35cfd57f6df032e15..20d2be02b06ecd249cc807f0e96260a12edbf59c 100644
--- a/test/y4m_video_source.h
+++ b/test/y4m_video_source.h
@@ -12,9 +12,7 @@
 #include <string>
 
 #include "test/video_source.h"
-extern "C" {
 #include "./y4minput.h"
-}
 
 namespace libvpx_test {
 
diff --git a/vp8/common/alloccommon.h b/vp8/common/alloccommon.h
index 38f89a0f1243cd7c708d5e1123fa5334f24e3ee0..93e99d76b1d76d0a57ff7d3cf9b7be7470c79e4d 100644
--- a/vp8/common/alloccommon.h
+++ b/vp8/common/alloccommon.h
@@ -14,10 +14,18 @@
 
 #include "onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_create_common(VP8_COMMON *oci);
 void vp8_remove_common(VP8_COMMON *oci);
 void vp8_de_alloc_frame_buffers(VP8_COMMON *oci);
 int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height);
 void vp8_setup_version(VP8_COMMON *oci);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_ALLOCCOMMON_H_
diff --git a/vp8/common/arm/bilinearfilter_arm.h b/vp8/common/arm/bilinearfilter_arm.h
index dd3ff14fbde9f8890d0b1787911b959a937f96f5..6b84e6f3b55e95659ca20044df69d76db834bf3a 100644
--- a/vp8/common/arm/bilinearfilter_arm.h
+++ b/vp8/common/arm/bilinearfilter_arm.h
@@ -12,6 +12,10 @@
 #ifndef VP8_COMMON_ARM_BILINEARFILTER_ARM_H_
 #define VP8_COMMON_ARM_BILINEARFILTER_ARM_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void vp8_filter_block2d_bil_first_pass_armv6
 (
     const unsigned char  *src_ptr,
@@ -32,4 +36,8 @@ extern void vp8_filter_block2d_bil_second_pass_armv6
     const short         *vp8_filter
 );
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_ARM_BILINEARFILTER_ARM_H_
diff --git a/vp8/common/blockd.h b/vp8/common/blockd.h
index c3caee10e2abee76afead9c4253d9dc13cf23c62..ea1a6a4adfdedb717e588d7b4911a9d341b8b7b8 100644
--- a/vp8/common/blockd.h
+++ b/vp8/common/blockd.h
@@ -20,6 +20,10 @@ void vpx_log(const char *format, ...);
 #include "treecoder.h"
 #include "vpx_ports/mem.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*#define DCPRED 1*/
 #define DCPREDSIMTHRESH 0
 #define DCPREDCNTTHRESH 3
@@ -297,4 +301,8 @@ typedef struct macroblockd
 extern void vp8_build_block_doffsets(MACROBLOCKD *x);
 extern void vp8_setup_block_dptrs(MACROBLOCKD *x);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_BLOCKD_H_
diff --git a/vp8/common/coefupdateprobs.h b/vp8/common/coefupdateprobs.h
index 90d290d6e7c3e6474f68a736cb4fbd0d279ffcc3..d96a19e7478c01cc346d439be8cb4a6f2ad359ec 100644
--- a/vp8/common/coefupdateprobs.h
+++ b/vp8/common/coefupdateprobs.h
@@ -11,6 +11,10 @@
 #ifndef VP8_COMMON_COEFUPDATEPROBS_H_
 #define VP8_COMMON_COEFUPDATEPROBS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Update probabilities for the nodes in the token entropy tree.
    Generated file included by entropy.c */
 
@@ -186,4 +190,8 @@ const vp8_prob vp8_coef_update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTE
     },
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_COEFUPDATEPROBS_H_
diff --git a/vp8/common/common.h b/vp8/common/common.h
index 9671da00f17c59338f40fa7d035ad621020984aa..ee5b58c75d81e10d4ffbe19b58be0a4f056af6c2 100644
--- a/vp8/common/common.h
+++ b/vp8/common/common.h
@@ -18,6 +18,10 @@
 
 #include "vpx_mem/vpx_mem.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Only need this for fixed-size arrays, for structs just assign. */
 
 #define vp8_copy( Dest, Src) { \
@@ -37,4 +41,8 @@
 #define vp8_zero_array( Dest, N)  vpx_memset( Dest, 0, N * sizeof( *Dest));
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_COMMON_H_
diff --git a/vp8/common/default_coef_probs.h b/vp8/common/default_coef_probs.h
index 8368545943d22006b7167f57aa0e1af73653b374..4d69e4be6645e2ec7cc6f47fa29363a8140673d2 100644
--- a/vp8/common/default_coef_probs.h
+++ b/vp8/common/default_coef_probs.h
@@ -11,6 +11,10 @@
 #ifndef VP8_COMMON_DEFAULT_COEF_PROBS_H_
 #define VP8_COMMON_DEFAULT_COEF_PROBS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*Generated file, included by entropy.c*/
 
 
@@ -189,4 +193,8 @@ static const vp8_prob default_coef_probs [BLOCK_TYPES]
     }
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_DEFAULT_COEF_PROBS_H_
diff --git a/vp8/common/entropy.h b/vp8/common/entropy.h
index 175fa9f61d315e726ca48fbd0e07a5eead140480..a90bab4bac2e2000c409861b7e020fc76dac10d0 100644
--- a/vp8/common/entropy.h
+++ b/vp8/common/entropy.h
@@ -15,6 +15,10 @@
 #include "treecoder.h"
 #include "blockd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Coefficient token alphabet */
 
 #define ZERO_TOKEN              0       /* 0         Extra Bits 0+0 */
@@ -98,4 +102,8 @@ extern DECLARE_ALIGNED(16, const short, vp8_default_zig_zag_mask[16]);
 extern const int vp8_mb_feature_data_bits[MB_LVL_MAX];
 
 void vp8_coef_tree_initialize(void);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_ENTROPY_H_
diff --git a/vp8/common/entropymode.h b/vp8/common/entropymode.h
index 18af8c0b88b466ff576fcafe4fb2ba5e26ab0384..81bdfc4b8bdd196ea20a9ace24479f246f026af6 100644
--- a/vp8/common/entropymode.h
+++ b/vp8/common/entropymode.h
@@ -15,6 +15,10 @@
 #include "onyxc_int.h"
 #include "treecoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef enum
 {
     SUBMVREF_NORMAL,
@@ -77,4 +81,8 @@ void vp8_init_mbmode_probs(VP8_COMMON *x);
 void vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES-1]);
 void vp8_kf_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_ENTROPYMODE_H_
diff --git a/vp8/common/entropymv.h b/vp8/common/entropymv.h
index 7d16b988f6ffdb036339ad1b93728adaf516d2f2..42840d58ad26c65ff7e2406758c6845cb56aa724 100644
--- a/vp8/common/entropymv.h
+++ b/vp8/common/entropymv.h
@@ -14,6 +14,10 @@
 
 #include "treecoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum
 {
     mv_max  = 1023,              /* max absolute value of a MV component */
@@ -41,4 +45,8 @@ typedef struct mv_context
 
 extern const MV_CONTEXT vp8_mv_update_probs[2], vp8_default_mv_context[2];
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_ENTROPYMV_H_
diff --git a/vp8/common/extend.h b/vp8/common/extend.h
index b7e70407992a867c59482763668e9c86323b7836..068f4ac5236ffdd3d20c00367aec6aa166fb0b91 100644
--- a/vp8/common/extend.h
+++ b/vp8/common/extend.h
@@ -14,6 +14,10 @@
 
 #include "vpx_scale/yv12config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf, unsigned char *YPtr, unsigned char *UPtr, unsigned char *VPtr);
 void vp8_copy_and_extend_frame(YV12_BUFFER_CONFIG *src,
                                YV12_BUFFER_CONFIG *dst);
@@ -22,4 +26,8 @@ void vp8_copy_and_extend_frame_with_rect(YV12_BUFFER_CONFIG *src,
                                          int srcy, int srcx,
                                          int srch, int srcw);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_EXTEND_H_
diff --git a/vp8/common/filter.h b/vp8/common/filter.h
index c2048ee135f1be71c848cea2fe29453823a61a08..cfba775fce47c93287932e82b605930163a1f628 100644
--- a/vp8/common/filter.h
+++ b/vp8/common/filter.h
@@ -14,6 +14,10 @@
 
 #include "vpx_ports/mem.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define BLOCK_HEIGHT_WIDTH 4
 #define VP8_FILTER_WEIGHT 128
 #define VP8_FILTER_SHIFT  7
@@ -21,4 +25,8 @@
 extern DECLARE_ALIGNED(16, const short, vp8_bilinear_filters[8][2]);
 extern DECLARE_ALIGNED(16, const short, vp8_sub_pel_filters[8][6]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_FILTER_H_
diff --git a/vp8/common/findnearmv.h b/vp8/common/findnearmv.h
index 1525db24fd122fe835c88f0a051979b9f23255a5..3c8c0506f67501aeacb929f271e833a2716431ae 100644
--- a/vp8/common/findnearmv.h
+++ b/vp8/common/findnearmv.h
@@ -17,6 +17,10 @@
 #include "modecont.h"
 #include "treecoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp,
                     const int *ref_frame_sign_bias)
@@ -179,4 +183,8 @@ static B_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb, int b, int mi
     return (cur_mb->bmi + b - 4)->as_mode;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_FINDNEARMV_H_
diff --git a/vp8/common/header.h b/vp8/common/header.h
index 61a8f49bcf0cbcda82c0af3ae9de49968255a0a7..e27bca16bd73642a16728ff2ce67fab941e00155 100644
--- a/vp8/common/header.h
+++ b/vp8/common/header.h
@@ -12,6 +12,10 @@
 #ifndef VP8_COMMON_HEADER_H_
 #define VP8_COMMON_HEADER_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* 24 bits total */
 typedef struct
 {
@@ -40,4 +44,8 @@ typedef struct
 #endif
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_HEADER_H_
diff --git a/vp8/common/invtrans.h b/vp8/common/invtrans.h
index 0186e6b3b56f4f55321603eab7901ab128d7f207..affe57e3d6e28121e9b67e6947984993e81c87ef 100644
--- a/vp8/common/invtrans.h
+++ b/vp8/common/invtrans.h
@@ -21,6 +21,10 @@
 #include "vpx_mem/vpx_mem.h"
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 static void eob_adjust(char *eobs, short *diff)
 {
     /* eob adjust.... the idct can only skip if both the dc and eob are zero */
@@ -59,4 +63,8 @@ static void vp8_inverse_transform_mby(MACROBLOCKD *xd)
                      xd->dst.y_buffer,
                      xd->dst.y_stride, xd->eobs);
 }
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_INVTRANS_H_
diff --git a/vp8/common/loopfilter.h b/vp8/common/loopfilter.h
index 51825efc195059bafc5b3b26fcc911921e1ac034..20a6bd375b600799fe887d60443f199319360777 100644
--- a/vp8/common/loopfilter.h
+++ b/vp8/common/loopfilter.h
@@ -16,6 +16,10 @@
 #include "vpx_config.h"
 #include "vp8_rtcd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_LOOP_FILTER             63
 /* fraction of total macroblock rows to be used in fast filter level picking */
 /* has to be > 2 */
@@ -102,4 +106,8 @@ void vp8_loop_filter_row_simple(struct VP8Common *cm,
                                 int mb_row, int post_ystride, int post_uvstride,
                                 unsigned char *y_ptr, unsigned char *u_ptr,
                                 unsigned char *v_ptr);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_LOOPFILTER_H_
diff --git a/vp8/common/modecont.h b/vp8/common/modecont.h
index 875bc2754a8bd16a1f0296fcee5355a159dcf021..ff34c33c557cfe623200044b05f3260371030eba 100644
--- a/vp8/common/modecont.h
+++ b/vp8/common/modecont.h
@@ -12,6 +12,14 @@
 #ifndef VP8_COMMON_MODECONT_H_
 #define VP8_COMMON_MODECONT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern const int vp8_mode_contexts[6][4];
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_MODECONT_H_
diff --git a/vp8/common/mv.h b/vp8/common/mv.h
index 1e4b206a2a037d4cc437e6798267be187276824c..111ccd63c7226f15cec8452458354718a089cf9d 100644
--- a/vp8/common/mv.h
+++ b/vp8/common/mv.h
@@ -13,6 +13,10 @@
 #define VP8_COMMON_MV_H_
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct
 {
     short row;
@@ -25,4 +29,8 @@ typedef union int_mv
     MV        as_mv;
 } int_mv;        /* facilitates faster equality tests and copies */
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_MV_H_
diff --git a/vp8/common/onyxc_int.h b/vp8/common/onyxc_int.h
index 92eb7f99a50fb615ae49eb55a7dd1e913d861ed2..6d89865c600ab510446ac1adfa38569f0c3bbe77 100644
--- a/vp8/common/onyxc_int.h
+++ b/vp8/common/onyxc_int.h
@@ -26,6 +26,10 @@
 #include "header.h"
 /*#endif*/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MINQ 0
 #define MAXQ 127
 #define QINDEX_RANGE (MAXQ + 1)
@@ -174,4 +178,8 @@ typedef struct VP8Common
     int cpu_caps;
 } VP8_COMMON;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_ONYXC_INT_H_
diff --git a/vp8/common/postproc.h b/vp8/common/postproc.h
index 10baf6ccfb6d202c9eb97c1a511151f1d7b1323b..33d0a7f025bef122edb6bb5daf5effc90712cc2f 100644
--- a/vp8/common/postproc.h
+++ b/vp8/common/postproc.h
@@ -26,6 +26,10 @@ struct postproc_state
 };
 #include "onyxc_int.h"
 #include "ppflags.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 int vp8_post_proc_frame(struct VP8Common *oci, YV12_BUFFER_CONFIG *dest,
                         vp8_ppflags_t *flags);
 
@@ -47,4 +51,8 @@ void vp8_deblock(struct VP8Common           *oci,
 #define MFQE_PRECISION 4
 
 void vp8_multiframe_quality_enhance(struct VP8Common *cm);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_POSTPROC_H_
diff --git a/vp8/common/ppflags.h b/vp8/common/ppflags.h
index 1fb37e17a3d62da58f2b49ad5fecd8cd8722505d..768224aad5e6d21727a81bcc1c1bf33432755aa7 100644
--- a/vp8/common/ppflags.h
+++ b/vp8/common/ppflags.h
@@ -11,6 +11,10 @@
 
 #ifndef VP8_COMMON_PPFLAGS_H_
 #define VP8_COMMON_PPFLAGS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 enum
 {
     VP8D_NOFILTERING            = 0,
@@ -38,4 +42,8 @@ typedef struct
     int display_mv_flag;
 } vp8_ppflags_t;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_PPFLAGS_H_
diff --git a/vp8/common/pragmas.h b/vp8/common/pragmas.h
index be10452d241fad14fbdf1d08b175e8758292152e..329cc8275c2f14fd04aa4c7dc746b099ce971b94 100644
--- a/vp8/common/pragmas.h
+++ b/vp8/common/pragmas.h
@@ -11,6 +11,10 @@
 #ifndef VP8_COMMON_PRAGMAS_H_
 #define VP8_COMMON_PRAGMAS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:997 1011 170)
 #endif
@@ -18,4 +22,8 @@
 #pragma warning(disable:4799)
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_PRAGMAS_H_
diff --git a/vp8/common/quant_common.h b/vp8/common/quant_common.h
index 4c7457f8dc3276ad4ba1b73d6a3315a35554b62e..700b5e6d726c7d2278c90392b230df303ecccbb1 100644
--- a/vp8/common/quant_common.h
+++ b/vp8/common/quant_common.h
@@ -16,6 +16,10 @@
 #include "blockd.h"
 #include "onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern int vp8_ac_yquant(int QIndex);
 extern int vp8_dc_quant(int QIndex, int Delta);
 extern int vp8_dc2quant(int QIndex, int Delta);
@@ -23,4 +27,8 @@ extern int vp8_ac2quant(int QIndex, int Delta);
 extern int vp8_dc_uv_quant(int QIndex, int Delta);
 extern int vp8_ac_uv_quant(int QIndex, int Delta);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_QUANT_COMMON_H_
diff --git a/vp8/common/reconinter.h b/vp8/common/reconinter.h
index 50ebedc0094341f00028473f0710b150beee81b9..ba979b9664af56cf5ac1a01831782ab555439152 100644
--- a/vp8/common/reconinter.h
+++ b/vp8/common/reconinter.h
@@ -12,6 +12,10 @@
 #ifndef VP8_COMMON_RECONINTER_H_
 #define VP8_COMMON_RECONINTER_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void vp8_build_inter_predictors_mb(MACROBLOCKD *x);
 extern void vp8_build_inter16x16_predictors_mb(MACROBLOCKD *x,
                                                unsigned char *dst_y,
@@ -32,4 +36,8 @@ extern void vp8_build_inter_predictors_b(BLOCKD *d, int pitch,
 extern void vp8_build_inter16x16_predictors_mbuv(MACROBLOCKD *x);
 extern void vp8_build_inter4x4_predictors_mbuv(MACROBLOCKD *x);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_RECONINTER_H_
diff --git a/vp8/common/reconintra4x4.h b/vp8/common/reconintra4x4.h
index cbb06ce789b11ef72ed88d58ef12a46b53b34a53..ed59c9edd4cd29fdba6ec1e2c72a03ca8beb10cb 100644
--- a/vp8/common/reconintra4x4.h
+++ b/vp8/common/reconintra4x4.h
@@ -13,6 +13,10 @@
 #define VP8_COMMON_RECONINTRA4X4_H_
 #include "vp8/common/blockd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 static void intra_prediction_down_copy(MACROBLOCKD *xd,
                                              unsigned char *above_right_src)
 {
@@ -29,4 +33,8 @@ static void intra_prediction_down_copy(MACROBLOCKD *xd,
     *dst_ptr2 = *src_ptr;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_RECONINTRA4X4_H_
diff --git a/vp8/common/setupintrarecon.h b/vp8/common/setupintrarecon.h
index 3db507b88ecc7a0f06cffc9a22a5cc7c433fd35a..608f4a9ac25566e9d85378086ac0d2f916f42a08 100644
--- a/vp8/common/setupintrarecon.h
+++ b/vp8/common/setupintrarecon.h
@@ -12,6 +12,10 @@
 #define VP8_COMMON_SETUPINTRARECON_H_
 
 #include "vpx_scale/yv12config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 extern void vp8_setup_intra_recon(YV12_BUFFER_CONFIG *ybf);
 extern void vp8_setup_intra_recon_top_line(YV12_BUFFER_CONFIG *ybf);
 
@@ -34,4 +38,8 @@ void setup_intra_recon_left(unsigned char *y_buffer,
         v_buffer[uv_stride *i] = (unsigned char) 129;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_SETUPINTRARECON_H_
diff --git a/vp8/common/swapyv12buffer.h b/vp8/common/swapyv12buffer.h
index ea8977b10013b4096f97c43e1554a16b27337640..1d66cd3d62e61e6e19db5e8ef389b46d1159c63f 100644
--- a/vp8/common/swapyv12buffer.h
+++ b/vp8/common/swapyv12buffer.h
@@ -14,6 +14,14 @@
 
 #include "vpx_scale/yv12config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_swap_yv12_buffer(YV12_BUFFER_CONFIG *new_frame, YV12_BUFFER_CONFIG *last_frame);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_SWAPYV12BUFFER_H_
diff --git a/vp8/common/systemdependent.h b/vp8/common/systemdependent.h
index 966cc5d8b9a6c5a981e326498212ebbbc45ca052..3d44e37cf24964551dc675dd4cad8ef8e1013c58 100644
--- a/vp8/common/systemdependent.h
+++ b/vp8/common/systemdependent.h
@@ -13,7 +13,15 @@
 
 #include "vpx_config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct VP8Common;
 void vp8_machine_specific_config(struct VP8Common *);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_SYSTEMDEPENDENT_H_
diff --git a/vp8/common/threading.h b/vp8/common/threading.h
index 8cf6d26bc46f742a89378199e91a65fffd039ebd..01c82dbb805b8fff75636bcb9ff8a464f4c95088 100644
--- a/vp8/common/threading.h
+++ b/vp8/common/threading.h
@@ -12,6 +12,10 @@
 #ifndef VP8_COMMON_THREADING_H_
 #define VP8_COMMON_THREADING_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD
 
 /* Thread management macros */
@@ -183,4 +187,8 @@ static inline int sem_destroy(sem_t * sem)
 
 #endif /* CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD */
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_THREADING_H_
diff --git a/vp8/common/treecoder.h b/vp8/common/treecoder.h
index edb4b57754934a5a754bbca5fc7c11eeb59a4f3d..d22b7c570cbea1549211a550433f923aa92f5cc0 100644
--- a/vp8/common/treecoder.h
+++ b/vp8/common/treecoder.h
@@ -12,6 +12,10 @@
 #ifndef VP8_COMMON_TREECODER_H_
 #define VP8_COMMON_TREECODER_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef unsigned char vp8bc_index_t; /* probability index */
 
 
@@ -87,4 +91,8 @@ void vp8bc_tree_probs_from_distribution(
 );
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_TREECODER_H_
diff --git a/vp8/common/variance.h b/vp8/common/variance.h
index 12a03d0fb0ae173ff552843721f1e3b2278943b4..89a32a72268cabb2ae92746dde1e81dd948ba912 100644
--- a/vp8/common/variance.h
+++ b/vp8/common/variance.h
@@ -14,6 +14,10 @@
 
 #include "vpx_config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef unsigned int(*vp8_sad_fn_t)(
     const unsigned char *src_ptr,
     int source_stride,
@@ -112,4 +116,8 @@ typedef struct variance_vtable
 #endif
 } vp8_variance_fn_ptr_t;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_VARIANCE_H_
diff --git a/vp8/common/vp8_entropymodedata.h b/vp8/common/vp8_entropymodedata.h
index 988114804f579b58de839f6cfb94dcd2f496f217..c4aed4989705cf4c101130c5ced03795df8a631f 100644
--- a/vp8/common/vp8_entropymodedata.h
+++ b/vp8/common/vp8_entropymodedata.h
@@ -11,6 +11,10 @@
 #ifndef VP8_COMMON_VP8_ENTROPYMODEDATA_H_
 #define VP8_COMMON_VP8_ENTROPYMODEDATA_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*Generated file, included by entropymode.c*/
 
 
@@ -243,4 +247,8 @@ const vp8_prob vp8_kf_bmode_prob
     }
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_VP8_ENTROPYMODEDATA_H_
diff --git a/vp8/common/x86/filter_x86.h b/vp8/common/x86/filter_x86.h
index 0d537d9df445a46d82013e3e63864ffd82df6647..d282841bee4d98a9696ad4eb198f60b155c8cb9d 100644
--- a/vp8/common/x86/filter_x86.h
+++ b/vp8/common/x86/filter_x86.h
@@ -13,6 +13,10 @@
 
 #include "vpx_ports/mem.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* x86 assembly specific copy of vp8/common/filter.c:vp8_bilinear_filters with
  * duplicated values */
 
@@ -22,4 +26,8 @@ extern DECLARE_ALIGNED(16, const short, vp8_bilinear_filters_x86_4[8][8]);
 /* duplicated 8x */
 extern DECLARE_ALIGNED(16, const short, vp8_bilinear_filters_x86_8[8][16]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_X86_FILTER_X86_H_
diff --git a/vp8/decoder/dboolhuff.h b/vp8/decoder/dboolhuff.h
index 82de6b8c8ab044598a61c3f66bd815a830ddf487..36af7eed5926a82c4f4776b35db2423b379395df 100644
--- a/vp8/decoder/dboolhuff.h
+++ b/vp8/decoder/dboolhuff.h
@@ -19,6 +19,10 @@
 #include "vpx_ports/mem.h"
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef size_t VP8_BD_VALUE;
 
 #define VP8_BD_VALUE_SIZE ((int)sizeof(VP8_BD_VALUE)*CHAR_BIT)
@@ -135,4 +139,8 @@ static int vp8dx_bool_error(BOOL_DECODER *br)
     return 0;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_DBOOLHUFF_H_
diff --git a/vp8/decoder/decodemv.h b/vp8/decoder/decodemv.h
index b5d750ce4eb8222dd1f16f6267bc97832f3e1b92..f33b07351d3c1cc3a0f033097b9146a5c0856480 100644
--- a/vp8/decoder/decodemv.h
+++ b/vp8/decoder/decodemv.h
@@ -13,6 +13,14 @@
 
 #include "onyxd_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_decode_mode_mvs(VP8D_COMP *);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_DECODEMV_H_
diff --git a/vp8/decoder/decoderthreading.h b/vp8/decoder/decoderthreading.h
index 3a8277f4e625d3e0eec9e30f9fbdb31955b2556a..c563cf6e93aa3d739fd2c049ccfc38a11b60adbc 100644
--- a/vp8/decoder/decoderthreading.h
+++ b/vp8/decoder/decoderthreading.h
@@ -11,6 +11,10 @@
 #ifndef VP8_DECODER_DECODERTHREADING_H_
 #define VP8_DECODER_DECODERTHREADING_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if CONFIG_MULTITHREAD
 void vp8mt_decode_mb_rows(VP8D_COMP *pbi, MACROBLOCKD *xd);
 void vp8_decoder_remove_threads(VP8D_COMP *pbi);
@@ -19,4 +23,8 @@ void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows);
 void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows);
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_DECODERTHREADING_H_
diff --git a/vp8/decoder/detokenize.h b/vp8/decoder/detokenize.h
index f134df86907d5ed7e65cceaaac9276e237183799..f0b125444f033c7b06941765b6c2beb9faa5f496 100644
--- a/vp8/decoder/detokenize.h
+++ b/vp8/decoder/detokenize.h
@@ -13,7 +13,15 @@
 
 #include "onyxd_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_reset_mb_tokens_context(MACROBLOCKD *x);
 int vp8_decode_mb_tokens(VP8D_COMP *, MACROBLOCKD *);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_DETOKENIZE_H_
diff --git a/vp8/decoder/ec_types.h b/vp8/decoder/ec_types.h
index 0a3123a65cd629e437ef507fa9fbdeca7a24271b..3af5ca86b4b99e32a68d2a5a0cb6cecddcd4eb2d 100644
--- a/vp8/decoder/ec_types.h
+++ b/vp8/decoder/ec_types.h
@@ -11,6 +11,10 @@
 #ifndef VP8_DECODER_EC_TYPES_H_
 #define VP8_DECODER_EC_TYPES_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_OVERLAPS 16
 
 
@@ -47,4 +51,8 @@ typedef struct
     MV_REFERENCE_FRAME ref_frame;
 } EC_BLOCK;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_EC_TYPES_H_
diff --git a/vp8/decoder/error_concealment.h b/vp8/decoder/error_concealment.h
index 10bf870b703c56fde48eb43a1a1b180dcf753f09..9a1e024865d99c69aa4c04eb05d6a96f2fab6187 100644
--- a/vp8/decoder/error_concealment.h
+++ b/vp8/decoder/error_concealment.h
@@ -15,6 +15,10 @@
 #include "onyxd_int.h"
 #include "ec_types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Allocate memory for the overlap lists */
 int vp8_alloc_overlap_lists(VP8D_COMP *pbi);
 
@@ -38,4 +42,8 @@ void vp8_interpolate_motion(MACROBLOCKD *mb,
  */
 void vp8_conceal_corrupt_mb(MACROBLOCKD *xd);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_ERROR_CONCEALMENT_H_
diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h
index 3728152b0cd429813bfe7a0d104f261471c638f9..8ef489403c1c1f74222f38cd8ec040222bb90c75 100644
--- a/vp8/decoder/onyxd_int.h
+++ b/vp8/decoder/onyxd_int.h
@@ -22,6 +22,10 @@
 #include "ec_types.h"
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct
 {
     int ithread;
@@ -148,4 +152,8 @@ int vp8_remove_decoder_instances(struct frame_buffers *fb);
     } while(0)
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_ONYXD_INT_H_
diff --git a/vp8/decoder/treereader.h b/vp8/decoder/treereader.h
index 1d3f6720771fb3894dd7e072b2e638ad6ee4c822..35ee696000d93440af8f519f19f8f58d455dd323 100644
--- a/vp8/decoder/treereader.h
+++ b/vp8/decoder/treereader.h
@@ -15,6 +15,10 @@
 #include "vp8/common/treecoder.h"
 #include "dboolhuff.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef BOOL_DECODER vp8_reader;
 
 #define vp8_read vp8dx_decode_bool
@@ -37,4 +41,8 @@ static int vp8_treed_read(
     return -i;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_DECODER_TREEREADER_H_
diff --git a/vp8/encoder/bitstream.h b/vp8/encoder/bitstream.h
index 01aa808d092906fae1bf8cf308d857c93bc03fa3..eef2d79e087118f4f8fcf570e13285adc8eba4cf 100644
--- a/vp8/encoder/bitstream.h
+++ b/vp8/encoder/bitstream.h
@@ -12,6 +12,10 @@
 #ifndef VP8_ENCODER_BITSTREAM_H_
 #define VP8_ENCODER_BITSTREAM_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if HAVE_EDSP
 void vp8cx_pack_tokens_armv5(vp8_writer *w, const TOKENEXTRA *p, int xcount,
                              const vp8_token *,
@@ -43,4 +47,8 @@ void vp8_pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount);
 # define pack_mb_row_tokens(a,b)               pack_mb_row_tokens_c(a,b)
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_BITSTREAM_H_
diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h
index 0dc0d86008134a881fb00dbfefad9adcd44fb328..dd733e55a9d14a4de6666042106459a719ccbad9 100644
--- a/vp8/encoder/block.h
+++ b/vp8/encoder/block.h
@@ -18,6 +18,10 @@
 #include "vp8/common/entropy.h"
 #include "vpx_ports/mem.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_MODES 20
 #define MAX_ERROR_BINS 1024
 
@@ -160,4 +164,8 @@ typedef struct macroblock
 } MACROBLOCK;
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_BLOCK_H_
diff --git a/vp8/encoder/boolhuff.h b/vp8/encoder/boolhuff.h
index 8f451b7f0fc1fb05c7db3b0a1f38e777f6089556..61142157593e3aa0ee5171d5ac4212ac8af00d5c 100644
--- a/vp8/encoder/boolhuff.h
+++ b/vp8/encoder/boolhuff.h
@@ -22,6 +22,10 @@
 #include "vpx_ports/mem.h"
 #include "vpx/internal/vpx_codec_internal.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct
 {
     unsigned int lowvalue;
@@ -125,4 +129,8 @@ static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability)
     br->range = range;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_BOOLHUFF_H_
diff --git a/vp8/encoder/dct_value_cost.h b/vp8/encoder/dct_value_cost.h
index f754e974ea06b2682922cde5765c2644c61e68f4..1cd3eec84ac37bf8dedc193a016073f7ee21f473 100644
--- a/vp8/encoder/dct_value_cost.h
+++ b/vp8/encoder/dct_value_cost.h
@@ -11,6 +11,10 @@
 #ifndef VP8_ENCODER_DCT_VALUE_COST_H_
 #define VP8_ENCODER_DCT_VALUE_COST_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Generated file, included by tokenize.c  */
 /* Values generated by fill_value_tokens() */
 
@@ -360,4 +364,8 @@ static const short dct_value_cost[2048*2] =
     8251, 8257, 8265, 8275
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_DCT_VALUE_COST_H_
diff --git a/vp8/encoder/dct_value_tokens.h b/vp8/encoder/dct_value_tokens.h
index e4132c62b7430dcd451e961b7017dff0681bfd1b..c2aadefca79c957344e29b6c3debeb0d2036b68d 100644
--- a/vp8/encoder/dct_value_tokens.h
+++ b/vp8/encoder/dct_value_tokens.h
@@ -11,6 +11,10 @@
 #ifndef VP8_ENCODER_DCT_VALUE_TOKENS_H_
 #define VP8_ENCODER_DCT_VALUE_TOKENS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Generated file, included by tokenize.c  */
 /* Values generated by fill_value_tokens() */
 
@@ -701,4 +705,8 @@ static const TOKENVALUE dct_value_tokens[2048*2] =
     {10, 3954}, {10, 3956}, {10, 3958}, {10, 3960}
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_DCT_VALUE_TOKENS_H_
diff --git a/vp8/encoder/defaultcoefcounts.h b/vp8/encoder/defaultcoefcounts.h
index 3015a585ed744cd2da7084d5ede9d1481e64eed7..1e8e80484ae25c80f407a0d7ba6a9a4bd555256d 100644
--- a/vp8/encoder/defaultcoefcounts.h
+++ b/vp8/encoder/defaultcoefcounts.h
@@ -11,6 +11,10 @@
 #ifndef VP8_ENCODER_DEFAULTCOEFCOUNTS_H_
 #define VP8_ENCODER_DEFAULTCOEFCOUNTS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Generated file, included by entropy.c */
 
 static const unsigned int default_coef_counts[BLOCK_TYPES]
@@ -225,4 +229,8 @@ static const unsigned int default_coef_counts[BLOCK_TYPES]
     },
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_DEFAULTCOEFCOUNTS_H_
diff --git a/vp8/encoder/denoising.h b/vp8/encoder/denoising.h
index 83fb93a143904ca15039f0202b20b9a53e6bf5e4..cc9913afa2b456e2433ee3e9b61dc3c3c7cdc3cd 100644
--- a/vp8/encoder/denoising.h
+++ b/vp8/encoder/denoising.h
@@ -13,6 +13,10 @@
 
 #include "block.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define SUM_DIFF_THRESHOLD (16 * 16 * 2)
 #define MOTION_MAGNITUDE_THRESHOLD (8*3)
 
@@ -39,4 +43,8 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
                              int recon_yoffset,
                              int recon_uvoffset);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_DENOISING_H_
diff --git a/vp8/encoder/encodeframe.h b/vp8/encoder/encodeframe.h
index 180596bf17179f04b123ecc35ba117cacff8cd0f..e185c1035c09a7579ad317e849aac2839502d419 100644
--- a/vp8/encoder/encodeframe.h
+++ b/vp8/encoder/encodeframe.h
@@ -9,6 +9,10 @@
  */
 #ifndef VP8_ENCODER_ENCODEFRAME_H_
 #define VP8_ENCODER_ENCODEFRAME_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 extern void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x);
 
 extern void vp8_build_block_offsets(MACROBLOCK *x);
@@ -24,4 +28,8 @@ extern int vp8cx_encode_inter_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
 
 extern int vp8cx_encode_intra_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
         TOKENEXTRA **t);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_ENCODEFRAME_H_
diff --git a/vp8/encoder/encodeintra.h b/vp8/encoder/encodeintra.h
index c6da43b8f8d1b84bc9a3673ca048cbce35ae6c8a..a8d0284d29b56350a135ffc9a931db83faccf2e9 100644
--- a/vp8/encoder/encodeintra.h
+++ b/vp8/encoder/encodeintra.h
@@ -13,9 +13,17 @@
 #define VP8_ENCODER_ENCODEINTRA_H_
 #include "onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int vp8_encode_intra(VP8_COMP *cpi, MACROBLOCK *x, int use_dc_pred);
 void vp8_encode_intra16x16mby(MACROBLOCK *x);
 void vp8_encode_intra16x16mbuv(MACROBLOCK *x);
 void vp8_encode_intra4x4mby(MACROBLOCK *mb);
 void vp8_encode_intra4x4block(MACROBLOCK *x, int ib);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_ENCODEINTRA_H_
diff --git a/vp8/encoder/encodemb.h b/vp8/encoder/encodemb.h
index cbe62e9e5ec2fbe9e9353a8c9571c156166862cb..0b3ec875e7a4b1e94b589eb03e8617d3484df19c 100644
--- a/vp8/encoder/encodemb.h
+++ b/vp8/encoder/encodemb.h
@@ -13,6 +13,10 @@
 #define VP8_ENCODER_ENCODEMB_H_
 
 #include "onyx_int.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 void vp8_encode_inter16x16(MACROBLOCK *x);
 
 void vp8_build_dcblock(MACROBLOCK *b);
@@ -23,4 +27,8 @@ void vp8_transform_intra_mby(MACROBLOCK *x);
 void vp8_optimize_mby(MACROBLOCK *x);
 void vp8_optimize_mbuv(MACROBLOCK *x);
 void vp8_encode_inter16x16y(MACROBLOCK *x);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_ENCODEMB_H_
diff --git a/vp8/encoder/encodemv.h b/vp8/encoder/encodemv.h
index 65e7ac21a907861755f7335e5a0ec67b66183c57..722162ba212e3931c55e6a06b88aa12c3b6410ad 100644
--- a/vp8/encoder/encodemv.h
+++ b/vp8/encoder/encodemv.h
@@ -14,8 +14,16 @@
 
 #include "onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_write_mvprobs(VP8_COMP *);
 void vp8_encode_motion_vector(vp8_writer *, const MV *, const MV_CONTEXT *);
 void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int mvc_flag[2]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_ENCODEMV_H_
diff --git a/vp8/encoder/firstpass.h b/vp8/encoder/firstpass.h
index cf686793c37626e4ff8f8817a72b5ccc05112e02..c409ebca8f1bf1d357ed120b7b80e160a285881a 100644
--- a/vp8/encoder/firstpass.h
+++ b/vp8/encoder/firstpass.h
@@ -12,6 +12,10 @@
 #ifndef VP8_ENCODER_FIRSTPASS_H_
 #define VP8_ENCODER_FIRSTPASS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void vp8_init_first_pass(VP8_COMP *cpi);
 extern void vp8_first_pass(VP8_COMP *cpi);
 extern void vp8_end_first_pass(VP8_COMP *cpi);
@@ -21,4 +25,8 @@ extern void vp8_second_pass(VP8_COMP *cpi);
 extern void vp8_end_second_pass(VP8_COMP *cpi);
 
 extern size_t vp8_firstpass_stats_sz(unsigned int mb_count);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_FIRSTPASS_H_
diff --git a/vp8/encoder/lookahead.h b/vp8/encoder/lookahead.h
index d1904fa904cb6421f5aca9d00388de47fb749916..cad68e639fbfb36aaab28cee7e92045c0de8c921 100644
--- a/vp8/encoder/lookahead.h
+++ b/vp8/encoder/lookahead.h
@@ -12,6 +12,10 @@
 #include "vpx_scale/yv12config.h"
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct lookahead_entry
 {
     YV12_BUFFER_CONFIG  img;
@@ -106,4 +110,8 @@ unsigned int
 vp8_lookahead_depth(struct lookahead_ctx *ctx);
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_LOOKAHEAD_H_
diff --git a/vp8/encoder/mcomp.h b/vp8/encoder/mcomp.h
index 85bc7add80b125c55c28510bf79caab400f05225..f284f7c38075fa7713514ab0bc65dedefbd4b220 100644
--- a/vp8/encoder/mcomp.h
+++ b/vp8/encoder/mcomp.h
@@ -15,6 +15,10 @@
 #include "block.h"
 #include "vp8/common/variance.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef VP8_ENTROPY_STATS
 extern void init_mv_ref_counts();
 extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]);
@@ -104,4 +108,8 @@ typedef int (*vp8_diamond_search_fn_t)
      int_mv *center_mv
     );
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_MCOMP_H_
diff --git a/vp8/encoder/modecosts.h b/vp8/encoder/modecosts.h
index 2df944643ea13f5d6ec71f3b35679fc605ab69ca..9281551c8d5f6a4fb55e368de97b37a4562b75cf 100644
--- a/vp8/encoder/modecosts.h
+++ b/vp8/encoder/modecosts.h
@@ -12,6 +12,14 @@
 #ifndef VP8_ENCODER_MODECOSTS_H_
 #define VP8_ENCODER_MODECOSTS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_init_mode_costs(VP8_COMP *x);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_MODECOSTS_H_
diff --git a/vp8/encoder/mr_dissim.h b/vp8/encoder/mr_dissim.h
index 8b22566bbaa4fb730293982d3e5559f7c54a343c..5a59ce62a61a2adb0133163af4d389cb73cbd24f 100644
--- a/vp8/encoder/mr_dissim.h
+++ b/vp8/encoder/mr_dissim.h
@@ -13,8 +13,16 @@
 #define VP8_ENCODER_MR_DISSIM_H_
 #include "vpx_config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void vp8_cal_low_res_mb_cols(VP8_COMP *cpi);
 extern void vp8_cal_dissimilarity(VP8_COMP *cpi);
 extern void vp8_store_drop_frame_info(VP8_COMP *cpi);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_MR_DISSIM_H_
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index 2fa6a93370a38f90ce06438adfea1841b4727994..6b371671d4c22733b26cce63fcc48600bfa47e34 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -33,6 +33,10 @@
 #include "vp8/encoder/denoising.h"
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MIN_GF_INTERVAL             4
 #define DEFAULT_GF_INTERVAL         7
 
@@ -721,4 +725,8 @@ void vp8_set_speed_features(VP8_COMP *cpi);
                                "Failed to allocate "#lval);\
     } while(0)
 #endif
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_ONYX_INT_H_
diff --git a/vp8/encoder/pickinter.h b/vp8/encoder/pickinter.h
index f74cf3df1d0d4e1050f679a41d37b61cd372f465..cf3b1f8d49cd58f0fd954ed62c18206a046d32f2 100644
--- a/vp8/encoder/pickinter.h
+++ b/vp8/encoder/pickinter.h
@@ -14,6 +14,10 @@
 #include "vpx_config.h"
 #include "vp8/common/onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
                                 int recon_uvoffset, int *returnrate,
                                 int *returndistortion, int *returnintra,
@@ -24,4 +28,8 @@ extern int vp8_get_inter_mbpred_error(MACROBLOCK *mb,
                                       const vp8_variance_fn_ptr_t *vfp,
                                       unsigned int *sse,
                                       int_mv this_mv);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_PICKINTER_H_
diff --git a/vp8/encoder/psnr.h b/vp8/encoder/psnr.h
index b2106151b8ba7b1bcbe292ff537c3aeb5b3e0e94..0c6c088c4f8a45e6f661fcc6956b494d757be592 100644
--- a/vp8/encoder/psnr.h
+++ b/vp8/encoder/psnr.h
@@ -12,6 +12,14 @@
 #ifndef VP8_ENCODER_PSNR_H_
 #define VP8_ENCODER_PSNR_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern double vp8_mse2psnr(double Samples, double Peak, double Mse);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_PSNR_H_
diff --git a/vp8/encoder/quantize.h b/vp8/encoder/quantize.h
index bbad8c7c3dba661237745546cf9c55eba6f84038..c739b2627b61d7c878af334d76f7f9aa88289743 100644
--- a/vp8/encoder/quantize.h
+++ b/vp8/encoder/quantize.h
@@ -12,6 +12,10 @@
 #ifndef VP8_ENCODER_QUANTIZE_H_
 #define VP8_ENCODER_QUANTIZE_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct VP8_COMP;
 struct macroblock;
 extern void vp8_set_quantizer(struct VP8_COMP *cpi, int Q);
@@ -20,4 +24,8 @@ extern void vp8_update_zbin_extra(struct VP8_COMP *cpi, struct macroblock *x);
 extern void vp8cx_mb_init_quantizer(struct VP8_COMP *cpi, struct macroblock *x, int ok_to_skip);
 extern void vp8cx_init_quantizer(struct VP8_COMP *cpi);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_QUANTIZE_H_
diff --git a/vp8/encoder/ratectrl.h b/vp8/encoder/ratectrl.h
index 88fe67899d0ab64a98e8a44d33044d24d3ae11ef..829697f391f606042a419ffe6953a11b8af4a93f 100644
--- a/vp8/encoder/ratectrl.h
+++ b/vp8/encoder/ratectrl.h
@@ -14,6 +14,10 @@
 
 #include "onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void vp8_save_coding_context(VP8_COMP *cpi);
 extern void vp8_restore_coding_context(VP8_COMP *cpi);
 
@@ -26,4 +30,8 @@ extern void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_
 /* return of 0 means drop frame */
 extern int vp8_pick_frame_size(VP8_COMP *cpi);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_RATECTRL_H_
diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h
index c28c37369b9eb47a5ef34e8b22845936a93d221f..fe21b8e283e5cf269676a7947e701873c1573e49 100644
--- a/vp8/encoder/rdopt.h
+++ b/vp8/encoder/rdopt.h
@@ -12,6 +12,10 @@
 #ifndef VP8_ENCODER_RDOPT_H_
 #define VP8_ENCODER_RDOPT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define RDCOST(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) )
 
 static void insertsortmv(int arr[], int len)
@@ -130,4 +134,8 @@ extern void vp8_mv_pred
 );
 void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffset, int near_sadidx[]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_RDOPT_H_
diff --git a/vp8/encoder/segmentation.h b/vp8/encoder/segmentation.h
index 8811a8b628775ae36ada589948d6eae463409bfe..6b5500594e6ec47af973e253c49ca810e5cc9af8 100644
--- a/vp8/encoder/segmentation.h
+++ b/vp8/encoder/segmentation.h
@@ -15,6 +15,14 @@
 #include "vp8/common/blockd.h"
 #include "onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_SEGMENTATION_H_
diff --git a/vp8/encoder/tokenize.h b/vp8/encoder/tokenize.h
index f85f3c9b1f3cb808f1915909b3c1fcecb589c642..b73a9ee1c896892f5e2947c9446f9691caeb7101 100644
--- a/vp8/encoder/tokenize.h
+++ b/vp8/encoder/tokenize.h
@@ -15,6 +15,10 @@
 #include "vp8/common/entropy.h"
 #include "block.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp8_tokenize_initialize();
 
 typedef struct
@@ -47,4 +51,8 @@ extern const short *const vp8_dct_value_cost_ptr;
  */
 extern const TOKENVALUE *const vp8_dct_value_tokens_ptr;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_TOKENIZE_H_
diff --git a/vp8/encoder/treewriter.h b/vp8/encoder/treewriter.h
index ba03f07e365ca28fa7e4b731abbd8f05b3e43c76..cfb2730ab3b20e5baed681b3443ef8a2114e79cb 100644
--- a/vp8/encoder/treewriter.h
+++ b/vp8/encoder/treewriter.h
@@ -19,6 +19,10 @@
 
 #include "boolhuff.h"       /* for now */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef BOOL_CODER vp8_writer;
 
 #define vp8_write vp8_encode_bool
@@ -123,4 +127,8 @@ void vp8_cost_tokens2(
     int *Costs, const vp8_prob *, vp8_tree, int
 );
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_TREEWRITER_H_
diff --git a/vp9/common/mips/dspr2/vp9_common_dspr2.h b/vp9/common/mips/dspr2/vp9_common_dspr2.h
index e9c698119acdb232e2bfc4ce6e24eae759d90cb7..991d3c2b3128a1964b934f8465f44edc38f1db9c 100644
--- a/vp9/common/mips/dspr2/vp9_common_dspr2.h
+++ b/vp9/common/mips/dspr2/vp9_common_dspr2.h
@@ -17,6 +17,10 @@
 #include "vpx/vpx_integer.h"
 #include "vp9/common/vp9_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if HAVE_DSPR2
 #define CROP_WIDTH 512
 extern uint8_t *vp9_ff_cropTbl;
@@ -114,4 +118,8 @@ void vp9_convolve2_vert_dspr2(const uint8_t *src, ptrdiff_t src_stride,
                               int w, int h);
 
 #endif  // #if HAVE_DSPR2
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_MIPS_DSPR2_VP9_COMMON_DSPR2_H_
diff --git a/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h b/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h
index 98bfcfaf24673557ef3f7331b15dd25d481ead2b..008cf8cacd99f87e4ea396654c73b4e63da64fec 100644
--- a/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h
+++ b/vp9/common/mips/dspr2/vp9_loopfilter_filters_dspr2.h
@@ -17,6 +17,10 @@
 #include "vp9/common/vp9_common.h"
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if HAVE_DSPR2
 /* inputs & outputs are quad-byte vectors */
 static INLINE void vp9_filter_dspr2(uint32_t mask, uint32_t hev,
@@ -752,4 +756,8 @@ static INLINE void vp9_wide_mbfilter_dspr2(uint32_t *op7, uint32_t *op6,
   *oq6 = res_oq6;
 }
 #endif  // #if HAVE_DSPR2
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_MIPS_DSPR2_VP9_LOOPFILTER_FILTERS_DSPR2_H_
diff --git a/vp9/common/mips/dspr2/vp9_loopfilter_macros_dspr2.h b/vp9/common/mips/dspr2/vp9_loopfilter_macros_dspr2.h
index 4cb2ebb46816e052d9a80b06baa2cecccc16b7d3..ca01a6a10308b4a49fcc023d5d25dfc91012b45a 100644
--- a/vp9/common/mips/dspr2/vp9_loopfilter_macros_dspr2.h
+++ b/vp9/common/mips/dspr2/vp9_loopfilter_macros_dspr2.h
@@ -17,6 +17,10 @@
 #include "vp9/common/vp9_common.h"
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if HAVE_DSPR2
 #define STORE_F0() {                                                    \
     __asm__ __volatile__ (                                              \
@@ -467,4 +471,8 @@
 }
 
 #endif  // #if HAVE_DSPR2
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_MIPS_DSPR2_VP9_LOOPFILTER_MACROS_DSPR2_H_
diff --git a/vp9/common/mips/dspr2/vp9_loopfilter_masks_dspr2.h b/vp9/common/mips/dspr2/vp9_loopfilter_masks_dspr2.h
index b9e0aca90edca7a6ed9535d9e913fabad9f9ba9b..5b0d9cc9b9458989f0505763cccf09a62dfb45e3 100644
--- a/vp9/common/mips/dspr2/vp9_loopfilter_masks_dspr2.h
+++ b/vp9/common/mips/dspr2/vp9_loopfilter_masks_dspr2.h
@@ -17,6 +17,10 @@
 #include "vp9/common/vp9_common.h"
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if HAVE_DSPR2
 /* processing 4 pixels at the same time
  * compute hev and mask in the same function */
@@ -362,4 +366,8 @@ static INLINE void vp9_flatmask5(uint32_t p4, uint32_t p3,
   *flat2 = flat1;
 }
 #endif  // #if HAVE_DSPR2
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_MIPS_DSPR2_VP9_LOOPFILTER_MASKS_DSPR2_H_
diff --git a/vp9/common/vp9_alloccommon.h b/vp9/common/vp9_alloccommon.h
index cf8dca5732008a9a63c6eb9eb5640e886fc27328..e3b5b95d89ba8f6a04446606b145556bc1204f04 100644
--- a/vp9/common/vp9_alloccommon.h
+++ b/vp9/common/vp9_alloccommon.h
@@ -14,6 +14,10 @@
 
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_initialize_common();
 
 void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi);
@@ -28,4 +32,8 @@ void vp9_free_frame_buffers(VP9_COMMON *cm);
 
 void vp9_update_frame_size(VP9_COMMON *cm);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_ALLOCCOMMON_H_
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index ad78b0dc4cfdc7f597c6d28bc3b91cd0a7b0b2c9..ad35c7ae02c309f6e1eed41ee84b9ad109ec88f1 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -25,6 +25,10 @@
 #include "vp9/common/vp9_scale.h"
 #include "vp9/common/vp9_seg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define BLOCK_SIZE_GROUPS 4
 #define MBSKIP_CONTEXTS 3
 #define INTER_MODE_CONTEXTS 7
@@ -463,4 +467,8 @@ static int get_tx_eob(const struct segmentation *seg, int segment_id,
   return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_BLOCKD_H_
diff --git a/vp9/common/vp9_common.h b/vp9/common/vp9_common.h
index 36d1cdf146335016a48af74804596cc7e44d571e..69964dae88e34c2496a159159ee13d2f6df0d37f 100644
--- a/vp9/common/vp9_common.h
+++ b/vp9/common/vp9_common.h
@@ -19,6 +19,10 @@
 #include "vpx_mem/vpx_mem.h"
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
 
@@ -91,4 +95,8 @@ static int get_unsigned_bits(unsigned int num_values) {
 #define VP9_FRAME_MARKER 0x2
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_COMMON_H_
diff --git a/vp9/common/vp9_common_data.h b/vp9/common/vp9_common_data.h
index 5222d29c170fd7ecf292fde218e60e5f17d4b014..f41962747221a13cb1073cec20b996e67954c947 100644
--- a/vp9/common/vp9_common_data.h
+++ b/vp9/common/vp9_common_data.h
@@ -13,6 +13,10 @@
 
 #include "vp9/common/vp9_enums.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern const int b_width_log2_lookup[BLOCK_SIZES];
 extern const int b_height_log2_lookup[BLOCK_SIZES];
 extern const int mi_width_log2_lookup[BLOCK_SIZES];
@@ -28,4 +32,8 @@ extern const TX_SIZE max_txsize_lookup[BLOCK_SIZES];
 extern const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES];
 extern const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2];
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_COMMON_DATA_H_
diff --git a/vp9/common/vp9_convolve.h b/vp9/common/vp9_convolve.h
index 29d499063c6dea55be119b70f92fcade4c7199d2..6bf71fc7943013b0ec4b5107069bc764018c8c90 100644
--- a/vp9/common/vp9_convolve.h
+++ b/vp9/common/vp9_convolve.h
@@ -13,10 +13,18 @@
 #include "./vpx_config.h"
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void (*convolve_fn_t)(const uint8_t *src, ptrdiff_t src_stride,
                               uint8_t *dst, ptrdiff_t dst_stride,
                               const int16_t *filter_x, int x_step_q4,
                               const int16_t *filter_y, int y_step_q4,
                               int w, int h);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_CONVOLVE_H_
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index ba162fd204155a2a9cf236d50cc8595cb4ddf0d9..e030d92ec94793c5503184f79069184ea755f840 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -18,6 +18,10 @@
 #include "vp9/common/vp9_scan.h"
 #include "vp9/common/vp9_entropymode.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define DIFF_UPDATE_PROB 252
 
 // Coefficient token alphabet
@@ -184,4 +188,8 @@ static const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size,
   }
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_ENTROPY_H_
diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h
index 5312553c70c026cce9f7afac486377ca11c236fe..edb03961c7b88b65938a55150ca938f3d7e1ce8b 100644
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -13,6 +13,10 @@
 
 #include "vp9/common/vp9_blockd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define TX_SIZE_CONTEXTS 2
 #define SWITCHABLE_FILTERS 3   // number of switchable filters
 #define SWITCHABLE_FILTER_CONTEXTS (SWITCHABLE_FILTERS + 1)
@@ -57,4 +61,8 @@ void tx_counts_to_branch_counts_16x16(const unsigned int *tx_count_16x16p,
 void tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p,
                                     unsigned int (*ct_8x8p)[2]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_ENTROPYMODE_H_
diff --git a/vp9/common/vp9_entropymv.h b/vp9/common/vp9_entropymv.h
index 48cb82db12915c607e209b94705c844510c0c6ca..7e1f1479b74652003c599e1d2d139155b6780418 100644
--- a/vp9/common/vp9_entropymv.h
+++ b/vp9/common/vp9_entropymv.h
@@ -15,6 +15,10 @@
 #include "./vpx_config.h"
 #include "vp9/common/vp9_blockd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct VP9Common;
 
 void vp9_init_mv_probs(struct VP9Common *cm);
@@ -121,4 +125,8 @@ typedef struct {
 
 void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_ENTROPYMV_H_
diff --git a/vp9/common/vp9_enums.h b/vp9/common/vp9_enums.h
index 34411a34f870bc67c2107370c76670e546f9f094..e96e769474a2723a6d7ed64a64f3deb8927eb1cc 100644
--- a/vp9/common/vp9_enums.h
+++ b/vp9/common/vp9_enums.h
@@ -13,6 +13,10 @@
 
 #include "./vpx_config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MI_SIZE_LOG2 3
 #define MI_BLOCK_SIZE_LOG2 (6 - MI_SIZE_LOG2)  // 64 = 2^6
 
@@ -90,4 +94,8 @@ typedef enum {
   SRGB       = 7   // RGB
 } COLOR_SPACE;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_ENUMS_H_
diff --git a/vp9/common/vp9_filter.h b/vp9/common/vp9_filter.h
index b1e7e6499e43542a015577f8bdd00f13650eb2fa..b02aaed9ef7879d4cd095dbbd876883912f93cb5 100644
--- a/vp9/common/vp9_filter.h
+++ b/vp9/common/vp9_filter.h
@@ -14,6 +14,10 @@
 #include "./vpx_config.h"
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define FILTER_BITS 7
 
 #define SUBPEL_BITS 4
@@ -48,4 +52,8 @@ extern const subpel_kernel vp9_sub_pel_filters_8lp[SUBPEL_SHIFTS];
 #define BILINEAR_FILTERS_2TAP(x) \
   (vp9_bilinear_filters[(x)] + SUBPEL_TAPS/2 - 1)
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_FILTER_H_
diff --git a/vp9/common/vp9_idct.h b/vp9/common/vp9_idct.h
index 183c50abfe08a806e0a278f473c7756d8b9aed6d..ceca7951b10ac446f82462f21474ba1b2a751145 100644
--- a/vp9/common/vp9_idct.h
+++ b/vp9/common/vp9_idct.h
@@ -18,6 +18,10 @@
 #include "vp9/common/vp9_common.h"
 #include "vp9/common/vp9_enums.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 // Constants and Macros used by all idct/dct functions
 #define DCT_CONST_BITS 14
@@ -103,4 +107,8 @@ void vp9_iht16x16_add(TX_TYPE tx_type, const int16_t *input, uint8_t *dest,
                       int stride, int eob);
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_IDCT_H_
diff --git a/vp9/common/vp9_loopfilter.h b/vp9/common/vp9_loopfilter.h
index 98fac96ffe5685722a0c4f22e8c47e22d0dea333..43373f4b18b4e967d7dbf01f48a9463a20364cd5 100644
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -17,6 +17,10 @@
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_seg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_LOOP_FILTER 63
 #define MAX_SHARPNESS 7
 
@@ -90,4 +94,8 @@ typedef struct LoopFilterWorkerData {
 
 // Operates on the rows described by LFWorkerData passed as 'arg1'.
 int vp9_loop_filter_worker(void *arg1, void *arg2);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_LOOPFILTER_H_
diff --git a/vp9/common/vp9_mv.h b/vp9/common/vp9_mv.h
index 155c3f12eede54b6a1821fd6ace625c8ef06db16..98fd1d82f298acab07d610b8346f880823b6074d 100644
--- a/vp9/common/vp9_mv.h
+++ b/vp9/common/vp9_mv.h
@@ -15,6 +15,10 @@
 
 #include "vp9/common/vp9_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct mv {
   int16_t row;
   int16_t col;
@@ -36,4 +40,8 @@ static void clamp_mv(MV *mv, int min_col, int max_col,
   mv->row = clamp(mv->row, min_row, max_row);
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_MV_H_
diff --git a/vp9/common/vp9_mvref_common.h b/vp9/common/vp9_mvref_common.h
index cd89390d587114e81dc683d13961e181752ab743..0936abfcd1a4a7ff10f6477f85157cfccb39f6c6 100644
--- a/vp9/common/vp9_mvref_common.h
+++ b/vp9/common/vp9_mvref_common.h
@@ -7,12 +7,16 @@
  *  in the file PATENTS.  All contributing project authors may
  *  be found in the AUTHORS file in the root of the source tree.
  */
+#ifndef VP9_COMMON_VP9_MVREF_COMMON_H_
+#define VP9_COMMON_VP9_MVREF_COMMON_H_
 
 #include "vp9/common/vp9_onyxc_int.h"
 #include "vp9/common/vp9_blockd.h"
 
-#ifndef VP9_COMMON_VP9_MVREF_COMMON_H_
-#define VP9_COMMON_VP9_MVREF_COMMON_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
                           const TileInfo *const tile,
@@ -56,4 +60,8 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
                                    int block, int ref, int mi_row, int mi_col,
                                    int_mv *nearest, int_mv *near);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_MVREF_COMMON_H_
diff --git a/vp9/common/vp9_onyx.h b/vp9/common/vp9_onyx.h
index 45d79848295a40d9a1c39f5d078cde245cb05ec9..9df76ded3c4a12af6fa27e0bebfd34594d1811c1 100644
--- a/vp9/common/vp9_onyx.h
+++ b/vp9/common/vp9_onyx.h
@@ -11,17 +11,16 @@
 #ifndef VP9_COMMON_VP9_ONYX_H_
 #define VP9_COMMON_VP9_ONYX_H_
 
-#ifdef __cplusplus
-extern "C"
-{ // NOLINT
-#endif
-
 #include "./vpx_config.h"
 #include "vpx/internal/vpx_codec_internal.h"
 #include "vpx/vp8cx.h"
 #include "vpx_scale/yv12config.h"
 #include "vp9/common/vp9_ppflags.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_SEGMENTS 8
 
   typedef int *VP9_PTR;
@@ -237,7 +236,7 @@ extern "C"
   int vp9_get_quantizer(VP9_PTR c);
 
 #ifdef __cplusplus
-}
+}  // extern "C"
 #endif
 
 #endif  // VP9_COMMON_VP9_ONYX_H_
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index f6fe4d3f1871e2398c06f7e843f4e70b92d18b28..364c2a93dae91b56cebfce843e6eb91b3182c1fd 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -25,6 +25,10 @@
 #include "vp9/common/vp9_postproc.h"
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define REFS_PER_FRAME 3
 
 #define REF_FRAMES_LOG2 3
@@ -359,4 +363,8 @@ static INLINE int partition_plane_context(
   return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_ONYXC_INT_H_
diff --git a/vp9/common/vp9_postproc.h b/vp9/common/vp9_postproc.h
index b8a456fdb5e0ddc638f4dff37f5ed8db4e10799f..b07d5d045ed8f85bc33e5bae912717ab18e2aa88 100644
--- a/vp9/common/vp9_postproc.h
+++ b/vp9/common/vp9_postproc.h
@@ -15,6 +15,10 @@
 #include "vpx_ports/mem.h"
 #include "vp9/common/vp9_ppflags.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct postproc_state {
   int last_q;
   int last_noise;
@@ -33,4 +37,8 @@ void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q);
 
 void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_POSTPROC_H_
diff --git a/vp9/common/vp9_ppflags.h b/vp9/common/vp9_ppflags.h
index 561c93028a4d5096ebef075a56d77f3492af29d7..8168935fcc160e3f821cd02b69bc7a9acd30ca10 100644
--- a/vp9/common/vp9_ppflags.h
+++ b/vp9/common/vp9_ppflags.h
@@ -11,6 +11,10 @@
 #ifndef VP9_COMMON_VP9_PPFLAGS_H_
 #define VP9_COMMON_VP9_PPFLAGS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum {
   VP9D_NOFILTERING            = 0,
   VP9D_DEBLOCK                = 1 << 0,
@@ -35,4 +39,8 @@ typedef struct {
   int display_mv_flag;
 } vp9_ppflags_t;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_PPFLAGS_H_
diff --git a/vp9/common/vp9_pragmas.h b/vp9/common/vp9_pragmas.h
index f079161d6b43a548d03b110a7a2f11431eb055db..0efc713caaf5b9638118f2542b7185983710855b 100644
--- a/vp9/common/vp9_pragmas.h
+++ b/vp9/common/vp9_pragmas.h
@@ -11,6 +11,10 @@
 #ifndef VP9_COMMON_VP9_PRAGMAS_H_
 #define VP9_COMMON_VP9_PRAGMAS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __INTEL_COMPILER
 #pragma warning(disable:997 1011 170)
 #endif
@@ -19,4 +23,8 @@
 #pragma warning(disable:4799)
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_PRAGMAS_H_
diff --git a/vp9/common/vp9_pred_common.h b/vp9/common/vp9_pred_common.h
index 23722ba72d78d9879acd5d6697519a172a14d9ba..26edf7810fcb5dd36cff70d53418e035460318cb 100644
--- a/vp9/common/vp9_pred_common.h
+++ b/vp9/common/vp9_pred_common.h
@@ -14,6 +14,10 @@
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 static INLINE const MODE_INFO *get_above_mi(const MACROBLOCKD *const xd) {
   return xd->up_available ? xd->mi_8x8[-xd->mode_info_stride] : NULL;
 }
@@ -129,4 +133,8 @@ static unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx,
   }
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_PRED_COMMON_H_
diff --git a/vp9/common/vp9_prob.h b/vp9/common/vp9_prob.h
index 7a790c542ad6618f012df01bbf1995782764018b..cc8d8ab3847986088a36b4b2f90075a740837b01 100644
--- a/vp9/common/vp9_prob.h
+++ b/vp9/common/vp9_prob.h
@@ -18,6 +18,10 @@
 
 #include "vp9/common/vp9_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef uint8_t vp9_prob;
 
 #define MAX_PROB 255
@@ -109,4 +113,8 @@ static void tree_merge_probs(const vp9_tree_index *tree,
 
 DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_PROB_H_
diff --git a/vp9/common/vp9_quant_common.h b/vp9/common/vp9_quant_common.h
index 83f2fb65530851b6e554bc95b5d1ddd4107eed95..af50e23cd8feeb5cd39d9b4dc41eaf2e57fa365d 100644
--- a/vp9/common/vp9_quant_common.h
+++ b/vp9/common/vp9_quant_common.h
@@ -13,6 +13,10 @@
 
 #include "vp9/common/vp9_blockd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MINQ 0
 #define MAXQ 255
 #define QINDEX_RANGE (MAXQ - MINQ + 1)
@@ -25,4 +29,8 @@ int16_t vp9_ac_quant(int qindex, int delta);
 
 int vp9_get_qindex(struct segmentation *seg, int segment_id, int base_qindex);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_QUANT_COMMON_H_
diff --git a/vp9/common/vp9_reconinter.h b/vp9/common/vp9_reconinter.h
index de26b424924beeeb04f277d9d1096ebc70b9dfa6..58f4b417e3c9fc0f348a7acc97771849391c5ad8 100644
--- a/vp9/common/vp9_reconinter.h
+++ b/vp9/common/vp9_reconinter.h
@@ -14,6 +14,10 @@
 #include "vpx/vpx_integer.h"
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct subpix_fn_table;
 void vp9_build_inter_predictors_sby(MACROBLOCKD *xd, int mi_row, int mi_col,
                                     BLOCK_SIZE bsize);
@@ -95,4 +99,8 @@ static void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd, int ref0, int ref1) {
   xd->block_refs[1] = &cm->frame_refs[ref1 >= 0 ? ref1 : 0];
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_RECONINTER_H_
diff --git a/vp9/common/vp9_reconintra.h b/vp9/common/vp9_reconintra.h
index fc916fcf3f70245b9942afffe27d69b11ac7c47d..800736d30a18b90e75341819ae8fa1bf4e3f43cb 100644
--- a/vp9/common/vp9_reconintra.h
+++ b/vp9/common/vp9_reconintra.h
@@ -14,9 +14,17 @@
 #include "vpx/vpx_integer.h"
 #include "vp9/common/vp9_blockd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_predict_intra_block(const MACROBLOCKD *xd, int block_idx, int bwl_in,
                              TX_SIZE tx_size, int mode,
                              const uint8_t *ref, int ref_stride,
                              uint8_t *dst, int dst_stride,
                              int aoff, int loff, int plane);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_RECONINTRA_H_
diff --git a/vp9/common/vp9_scale.h b/vp9/common/vp9_scale.h
index 55b4d88887ab2ec2c27c9a2be4342ca1010685d2..90b0d0bf9dd7a5e4dee0df731f934745c5357343 100644
--- a/vp9/common/vp9_scale.h
+++ b/vp9/common/vp9_scale.h
@@ -14,6 +14,10 @@
 #include "vp9/common/vp9_mv.h"
 #include "vp9/common/vp9_convolve.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define REF_SCALE_SHIFT 14
 #define REF_NO_SCALE (1 << REF_SCALE_SHIFT)
 #define REF_INVALID_SCALE -1
@@ -46,4 +50,8 @@ static int vp9_is_scaled(const struct scale_factors *sf) {
          sf->y_scale_fp != REF_NO_SCALE;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_SCALE_H_
diff --git a/vp9/common/vp9_scan.h b/vp9/common/vp9_scan.h
index efab48bfcbbe4d5e87ce3e95da59b9e5b3c69509..9613b675c2e72b47284eafc0d8601aba673ae93c 100644
--- a/vp9/common/vp9_scan.h
+++ b/vp9/common/vp9_scan.h
@@ -17,6 +17,10 @@
 #include "vp9/common/vp9_enums.h"
 #include "vp9/common/vp9_blockd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_NEIGHBORS 2
 
 void vp9_init_neighbors();
@@ -36,4 +40,8 @@ static INLINE int get_coef_context(const int16_t *neighbors,
           token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >> 1;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_SCAN_H_
diff --git a/vp9/common/vp9_seg_common.h b/vp9/common/vp9_seg_common.h
index 8ff54fb73dc9859f4e4a11316bdcb87efec6c2db..ff2d66a36582c19727069e6d98a06b7cc41f61ee 100644
--- a/vp9/common/vp9_seg_common.h
+++ b/vp9/common/vp9_seg_common.h
@@ -13,6 +13,10 @@
 
 #include "vp9/common/vp9_prob.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define SEGMENT_DELTADATA   0
 #define SEGMENT_ABSDATA     1
 
@@ -70,5 +74,9 @@ int vp9_get_segdata(const struct segmentation *seg,
 
 extern const vp9_tree_index vp9_segment_tree[TREE_SIZE(MAX_SEGMENTS)];
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_SEG_COMMON_H_
 
diff --git a/vp9/common/vp9_systemdependent.h b/vp9/common/vp9_systemdependent.h
index 6f955ab56ed7f8b45591b5aa99b3a3aebf3fe76a..ee9a4823b3c8e97f5c0d02a23a93ffaa63b2dfe8 100644
--- a/vp9/common/vp9_systemdependent.h
+++ b/vp9/common/vp9_systemdependent.h
@@ -11,6 +11,10 @@
 #ifndef VP9_COMMON_VP9_SYSTEMDEPENDENT_H_
 #define VP9_COMMON_VP9_SYSTEMDEPENDENT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef _MSC_VER
 #include <math.h>
 #define snprintf _snprintf
@@ -72,4 +76,8 @@ static INLINE int get_msb(unsigned int n) {
 struct VP9Common;
 void vp9_machine_specific_config(struct VP9Common *cm);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_SYSTEMDEPENDENT_H_
diff --git a/vp9/common/vp9_textblit.h b/vp9/common/vp9_textblit.h
index c968628fe42402631b9646805098d12c03a44646..158ec1b37edadf027cc563fb5da169f32134c5ec 100644
--- a/vp9/common/vp9_textblit.h
+++ b/vp9/common/vp9_textblit.h
@@ -11,9 +11,17 @@
 #ifndef VP9_COMMON_VP9_TEXTBLIT_H_
 #define VP9_COMMON_VP9_TEXTBLIT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_blit_text(const char *msg, unsigned char *address, int pitch);
 
 void vp9_blit_line(int x0, int x1, int y0, int y1, unsigned char *image,
                    int pitch);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_TEXTBLIT_H_
diff --git a/vp9/common/vp9_tile_common.h b/vp9/common/vp9_tile_common.h
index a09876e4b0c90844e5f9cbe6ad08cdda093ef067..a97719e2947bfa8e1f3cef8ca2fe9bcb332b7291 100644
--- a/vp9/common/vp9_tile_common.h
+++ b/vp9/common/vp9_tile_common.h
@@ -11,6 +11,10 @@
 #ifndef VP9_COMMON_VP9_TILE_COMMON_H_
 #define VP9_COMMON_VP9_TILE_COMMON_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct VP9Common;
 
 typedef struct TileInfo {
@@ -26,4 +30,8 @@ void vp9_tile_init(TileInfo *tile, const struct VP9Common *cm,
 void vp9_get_tile_n_bits(int mi_cols,
                          int *min_log2_tile_cols, int *max_log2_tile_cols);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_VP9_TILE_COMMON_H_
diff --git a/vp9/common/x86/vp9_postproc_x86.h b/vp9/common/x86/vp9_postproc_x86.h
index 8870215a27b7640066857fd71d1a7c07c4f8c07a..cab9d34f259947ca10d6e52426d96d27544fd035 100644
--- a/vp9/common/x86/vp9_postproc_x86.h
+++ b/vp9/common/x86/vp9_postproc_x86.h
@@ -12,6 +12,10 @@
 #ifndef VP9_COMMON_X86_VP9_POSTPROC_X86_H_
 #define VP9_COMMON_X86_VP9_POSTPROC_X86_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Note:
  *
  * This platform is commonly built for runtime CPU detection. If you modify
@@ -61,4 +65,8 @@ extern prototype_postproc_addnoise(vp9_plane_add_noise_wmt);
 #endif
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_X86_VP9_POSTPROC_X86_H_
diff --git a/vp9/decoder/vp9_decodeframe.h b/vp9/decoder/vp9_decodeframe.h
index 7245a98454f9f36bd518da07c3f8755aa962faad..4537bc82484298b50350c7238b93c224eb523b7a 100644
--- a/vp9/decoder/vp9_decodeframe.h
+++ b/vp9/decoder/vp9_decodeframe.h
@@ -12,10 +12,18 @@
 #ifndef VP9_DECODER_VP9_DECODEFRAME_H_
 #define VP9_DECODER_VP9_DECODEFRAME_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct VP9Common;
 struct VP9Decompressor;
 
 void vp9_init_dequantizer(struct VP9Common *cm);
 int vp9_decode_frame(struct VP9Decompressor *cpi, const uint8_t **p_data_end);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_DECODER_VP9_DECODEFRAME_H_
diff --git a/vp9/decoder/vp9_decodemv.h b/vp9/decoder/vp9_decodemv.h
index 95272bfb3b8f6438042a7b6d4e891fb5078a06e5..539c9840e906604107a6037798423a2548fd6474 100644
--- a/vp9/decoder/vp9_decodemv.h
+++ b/vp9/decoder/vp9_decodemv.h
@@ -14,10 +14,18 @@
 #include "vp9/decoder/vp9_onyxd_int.h"
 #include "vp9/decoder/vp9_reader.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct TileInfo;
 
 void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
                         const struct TileInfo *const tile,
                         int mi_row, int mi_col, vp9_reader *r);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_DECODER_VP9_DECODEMV_H_
diff --git a/vp9/decoder/vp9_detokenize.h b/vp9/decoder/vp9_detokenize.h
index 1780a0fb5fe726d4eff7bbb723cc05af0b1f3cd6..ce3d7653dfec44a594cc6bd3fd8a32584fa719d9 100644
--- a/vp9/decoder/vp9_detokenize.h
+++ b/vp9/decoder/vp9_detokenize.h
@@ -15,8 +15,16 @@
 #include "vp9/decoder/vp9_onyxd_int.h"
 #include "vp9/decoder/vp9_reader.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd,
                             int plane, int block, BLOCK_SIZE plane_bsize,
                             int x, int y, TX_SIZE tx_size, vp9_reader *r);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_DECODER_VP9_DETOKENIZE_H_
diff --git a/vp9/decoder/vp9_dsubexp.h b/vp9/decoder/vp9_dsubexp.h
index 137f546b84aebcdf2173e01f9098a775ef40ae2a..436f434fb18b3e4372ec89df82772899b17271c8 100644
--- a/vp9/decoder/vp9_dsubexp.h
+++ b/vp9/decoder/vp9_dsubexp.h
@@ -14,6 +14,14 @@
 
 #include "vp9/decoder/vp9_reader.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_diff_update_prob(vp9_reader *r, vp9_prob* p);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_DECODER_VP9_DSUBEXP_H_
diff --git a/vp9/decoder/vp9_onyxd.h b/vp9/decoder/vp9_onyxd.h
index a4b9c24fc9b29772f13fcf1a6bf37d5a68adc894..0fc9d578b6926fe99360d03709d9f34b489379a7 100644
--- a/vp9/decoder/vp9_onyxd.h
+++ b/vp9/decoder/vp9_onyxd.h
@@ -11,14 +11,14 @@
 #ifndef VP9_DECODER_VP9_ONYXD_H_
 #define VP9_DECODER_VP9_ONYXD_H_
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "vpx_scale/yv12config.h"
 #include "vp9/common/vp9_ppflags.h"
 #include "vpx/vpx_codec.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void *VP9D_PTR;
 
 typedef struct {
@@ -63,7 +63,7 @@ VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf);
 void vp9_remove_decompressor(VP9D_PTR comp);
 
 #ifdef __cplusplus
-}
+}  // extern "C"
 #endif
 
 #endif  // VP9_DECODER_VP9_ONYXD_H_
diff --git a/vp9/decoder/vp9_onyxd_int.h b/vp9/decoder/vp9_onyxd_int.h
index e90f8923c9d035991652a4d67040458dba63f7e7..242c600ccd1d102e9e7b49fcb72141e9a6639136 100644
--- a/vp9/decoder/vp9_onyxd_int.h
+++ b/vp9/decoder/vp9_onyxd_int.h
@@ -17,6 +17,10 @@
 #include "vp9/decoder/vp9_onyxd.h"
 #include "vp9/decoder/vp9_thread.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct VP9Decompressor {
   DECLARE_ALIGNED(16, MACROBLOCKD, mb);
 
@@ -53,4 +57,8 @@ typedef struct VP9Decompressor {
   PARTITION_CONTEXT *above_seg_context;
 } VP9D_COMP;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_DECODER_VP9_ONYXD_INT_H_
diff --git a/vp9/decoder/vp9_read_bit_buffer.h b/vp9/decoder/vp9_read_bit_buffer.h
index 41a686837242251bf66e42daef247854ee04c816..619e39f1ee202baf54c4833413a57ec9a7f9b9b5 100644
--- a/vp9/decoder/vp9_read_bit_buffer.h
+++ b/vp9/decoder/vp9_read_bit_buffer.h
@@ -15,6 +15,10 @@
 
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void (*vp9_rb_error_handler)(void *data, size_t bit_offset);
 
 struct vp9_read_bit_buffer {
@@ -57,4 +61,8 @@ static int vp9_rb_read_signed_literal(struct vp9_read_bit_buffer *rb,
   return vp9_rb_read_bit(rb) ? -value : value;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_DECODER_VP9_READ_BIT_BUFFER_H_
diff --git a/vp9/decoder/vp9_reader.h b/vp9/decoder/vp9_reader.h
index 38cf0f62120f7081a753d47f57dd23bc1a0a8fd6..8fe6acbc28bfcad7f95889634cbc4df0f6ca9006 100644
--- a/vp9/decoder/vp9_reader.h
+++ b/vp9/decoder/vp9_reader.h
@@ -20,6 +20,10 @@
 
 #include "vp9/common/vp9_prob.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef size_t BD_VALUE;
 
 #define BD_VALUE_SIZE ((int)sizeof(BD_VALUE) * CHAR_BIT)
@@ -100,4 +104,8 @@ static int vp9_read_tree(vp9_reader *r, const vp9_tree_index *tree,
   return -i;
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_DECODER_VP9_READER_H_
diff --git a/vp9/decoder/vp9_thread.h b/vp9/decoder/vp9_thread.h
index a624f3c2ab78fe3ea83c08f6132fe2d24444dcef..bc69cfa1f5fb5ef51aebbc04c5d3d74e98691451 100644
--- a/vp9/decoder/vp9_thread.h
+++ b/vp9/decoder/vp9_thread.h
@@ -19,7 +19,7 @@
 
 #include "./vpx_config.h"
 
-#if defined(__cplusplus) || defined(c_plusplus)
+#ifdef __cplusplus
 extern "C" {
 #endif
 
@@ -91,7 +91,7 @@ void vp9_worker_end(VP9Worker* const worker);
 
 //------------------------------------------------------------------------------
 
-#if defined(__cplusplus) || defined(c_plusplus)
+#ifdef __cplusplus
 }    // extern "C"
 #endif
 
diff --git a/vp9/encoder/vp9_bitstream.h b/vp9/encoder/vp9_bitstream.h
index 52be50272f9b174ea5080ddb91a188121f34cd62..94bec8a439a4ae3c2d6288d6e5418ae363756d7d 100644
--- a/vp9/encoder/vp9_bitstream.h
+++ b/vp9/encoder/vp9_bitstream.h
@@ -12,6 +12,14 @@
 #ifndef VP9_ENCODER_VP9_BITSTREAM_H_
 #define VP9_ENCODER_VP9_BITSTREAM_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_update_skip_probs(VP9_COMMON *cm, vp9_writer *bc);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_BITSTREAM_H_
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h
index c1b95817fcbcdf2f0d8d8f7b69cbd7ad8d0b7045..29e68b1d71c33966634ff675f0bf7d721d11a72c 100644
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -17,6 +17,10 @@
 #include "vpx_ports/mem.h"
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // motion search site
 typedef struct {
   MV mv;
@@ -254,4 +258,8 @@ struct rdcost_block_args {
   const int16_t *scan, *nb;
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_BLOCK_H_
diff --git a/vp9/encoder/vp9_dct.h b/vp9/encoder/vp9_dct.h
index aaf976d93c5abfb00c94e8bbb953f7334841d58f..cf5f001a9d81bf3e4c3112751d872a9fe04b85d1 100644
--- a/vp9/encoder/vp9_dct.h
+++ b/vp9/encoder/vp9_dct.h
@@ -12,6 +12,10 @@
 #ifndef VP9_ENCODER_VP9_DCT_H_
 #define VP9_ENCODER_VP9_DCT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_fht4x4(TX_TYPE tx_type, const int16_t *input, int16_t *output,
                 int stride);
 
@@ -21,4 +25,8 @@ void vp9_fht8x8(TX_TYPE tx_type, const int16_t *input, int16_t *output,
 void vp9_fht16x16(TX_TYPE tx_type, const int16_t *input, int16_t *output,
                   int stride);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_DCT_H_
diff --git a/vp9/encoder/vp9_encodeframe.h b/vp9/encoder/vp9_encodeframe.h
index 3e9f5381c06ae66b0cc61cb6bca8891a168965ab..f7d17c301fa59acc17bd4a0fc2587bb298b5b5fb 100644
--- a/vp9/encoder/vp9_encodeframe.h
+++ b/vp9/encoder/vp9_encodeframe.h
@@ -12,6 +12,10 @@
 #ifndef VP9_ENCODER_VP9_ENCODEFRAME_H_
 #define VP9_ENCODER_VP9_ENCODEFRAME_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct macroblock;
 struct yv12_buffer_config;
 
@@ -19,4 +23,8 @@ void vp9_setup_src_planes(struct macroblock *x,
                           const struct yv12_buffer_config *src,
                           int mi_row, int mi_col);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_ENCODEFRAME_H_
diff --git a/vp9/encoder/vp9_encodemb.h b/vp9/encoder/vp9_encodemb.h
index 207d573a5f9c0bc9854aab79f1dbba349cf8eead..6a06f0ae430e6545df24fa13a26ac4962ab7f5b0 100644
--- a/vp9/encoder/vp9_encodemb.h
+++ b/vp9/encoder/vp9_encodemb.h
@@ -16,6 +16,10 @@
 #include "vp9/encoder/vp9_onyx_int.h"
 #include "vp9/common/vp9_onyxc_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct optimize_ctx {
   ENTROPY_CONTEXT ta[MAX_MB_PLANE][16];
   ENTROPY_CONTEXT tl[MAX_MB_PLANE][16];
@@ -47,4 +51,8 @@ int vp9_encode_intra(MACROBLOCK *x, int use_16x16_pred);
 void vp9_setup_interp_filters(MACROBLOCKD *xd,
                               INTERPOLATION_TYPE mcomp_filter_type,
                               VP9_COMMON *cm);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_ENCODEMB_H_
diff --git a/vp9/encoder/vp9_encodemv.h b/vp9/encoder/vp9_encodemv.h
index 761278fd1a8910685d364dac75610bf899926fb5..c57b01db47f3a55e174119daaf4c0e3454389c8a 100644
--- a/vp9/encoder/vp9_encodemv.h
+++ b/vp9/encoder/vp9_encodemv.h
@@ -14,6 +14,10 @@
 
 #include "vp9/encoder/vp9_onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_entropy_mv_init();
 
 void vp9_write_nmv_probs(VP9_COMMON *cm, int usehp, vp9_writer* const);
@@ -30,4 +34,8 @@ void vp9_build_nmv_cost_table(int *mvjoint,
 
 void vp9_update_mv_count(VP9_COMP *cpi, MACROBLOCK *x, int_mv best_ref_mv[2]);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_ENCODEMV_H_
diff --git a/vp9/encoder/vp9_extend.h b/vp9/encoder/vp9_extend.h
index 9b95ee43725e84b2740566eabd823e35c9f14a34..058fe09cf983d67870217d31f34d813ce1fe12b3 100644
--- a/vp9/encoder/vp9_extend.h
+++ b/vp9/encoder/vp9_extend.h
@@ -14,6 +14,10 @@
 #include "vpx_scale/yv12config.h"
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 void vp9_copy_and_extend_frame(const YV12_BUFFER_CONFIG *src,
                                YV12_BUFFER_CONFIG *dst);
@@ -22,4 +26,8 @@ void vp9_copy_and_extend_frame_with_rect(const YV12_BUFFER_CONFIG *src,
                                          YV12_BUFFER_CONFIG *dst,
                                          int srcy, int srcx,
                                          int srch, int srcw);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_EXTEND_H_
diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h
index f89e4cb1c3ff1145bdc498cce77318df66095cf1..ca5b10080baa0b80b54e8c9e32f8775f3113a504 100644
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -12,6 +12,10 @@
 #define VP9_ENCODER_VP9_FIRSTPASS_H_
 #include "vp9/encoder/vp9_onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_init_first_pass(VP9_COMP *cpi);
 void vp9_first_pass(VP9_COMP *cpi);
 void vp9_end_first_pass(VP9_COMP *cpi);
@@ -25,4 +29,8 @@ void vp9_get_one_pass_params(VP9_COMP *cpi);
 void vp9_get_one_pass_cbr_params(VP9_COMP *cpi);
 void vp9_get_svc_params(VP9_COMP *cpi);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_FIRSTPASS_H_
diff --git a/vp9/encoder/vp9_lookahead.h b/vp9/encoder/vp9_lookahead.h
index c773f8fcc6d64cc39f197f88e4fc7b291b8f1e16..1c00c462d2485f3a5d9db2003b04f86b091b5360 100644
--- a/vp9/encoder/vp9_lookahead.h
+++ b/vp9/encoder/vp9_lookahead.h
@@ -14,6 +14,10 @@
 #include "vpx_scale/yv12config.h"
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_LAG_BUFFERS 25
 
 struct lookahead_entry {
@@ -94,4 +98,8 @@ struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx,
  */
 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_LOOKAHEAD_H_
diff --git a/vp9/encoder/vp9_mbgraph.h b/vp9/encoder/vp9_mbgraph.h
index c5bca4d01f53c8ad3b156e6437cdaf0f72fe6858..79dd2bc958d2d8a1f370e3d73dc33a8d34f4ca37 100644
--- a/vp9/encoder/vp9_mbgraph.h
+++ b/vp9/encoder/vp9_mbgraph.h
@@ -11,6 +11,14 @@
 #ifndef VP9_ENCODER_VP9_MBGRAPH_H_
 #define VP9_ENCODER_VP9_MBGRAPH_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_update_mbgraph_stats(VP9_COMP *cpi);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_MBGRAPH_H_
diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h
index 74035842fe7e6c1dfd15ea74d304f6bfd3b94f24..5cd9fd1703b82beaf19212dc8c4880efa06340e7 100644
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -15,6 +15,10 @@
 #include "vp9/encoder/vp9_block.h"
 #include "vp9/encoder/vp9_variance.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // The maximum number of steps in a step search given the largest
 // allowed initial step
 #define MAX_MVSEARCH_STEPS 11
@@ -129,4 +133,8 @@ int vp9_refining_search_8p_c(const MACROBLOCK *x,
                              int *mvjcost, int *mvcost[2],
                              const MV *center_mv, const uint8_t *second_pred,
                              int w, int h);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_MCOMP_H_
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 6f4c9a40f1a59be56966cd3259f986c335b10ad2..35f8fac699cf41bdd21a301035021609e3036f2c 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -28,6 +28,10 @@
 #include "vp9/encoder/vp9_mcomp.h"
 #include "vp9/encoder/vp9_lookahead.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define DISABLE_RC_LONG_TERM_MEM 0
 // #define MODE_TEST_HIT_STATS
 
@@ -815,4 +819,8 @@ static int get_token_alloc(int mb_rows, int mb_cols) {
   return mb_rows * mb_cols * (48 * 16 + 4);
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_ONYX_INT_H_
diff --git a/vp9/encoder/vp9_picklpf.h b/vp9/encoder/vp9_picklpf.h
index 9de4cf849cc55e9d60fdb6139b0d559f17462d8d..f9cb14c2780e116e7c8e0a347f85b2f8a6d765c9 100644
--- a/vp9/encoder/vp9_picklpf.h
+++ b/vp9/encoder/vp9_picklpf.h
@@ -12,6 +12,10 @@
 #ifndef VP9_ENCODER_VP9_PICKLPF_H_
 #define VP9_ENCODER_VP9_PICKLPF_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct yv12_buffer_config;
 struct VP9_COMP;
 
@@ -19,4 +23,8 @@ void vp9_set_alt_lf_level(struct VP9_COMP *cpi, int filt_val);
 
 void vp9_pick_filter_level(struct yv12_buffer_config *sd,
                            struct VP9_COMP *cpi, int partial);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_PICKLPF_H_
diff --git a/vp9/encoder/vp9_pickmode.h b/vp9/encoder/vp9_pickmode.h
index 32750fa69f2ed1e237425e49cd1dafdb20061a6e..82904ae8ac13cd9a023f68053f16868f0f8df93b 100644
--- a/vp9/encoder/vp9_pickmode.h
+++ b/vp9/encoder/vp9_pickmode.h
@@ -8,8 +8,15 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#ifndef VP9_ENCODER_VP9_PICKMODE_H_
+#define VP9_ENCODER_VP9_PICKMODE_H_
+
 #include "vp9/encoder/vp9_onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
                             const struct TileInfo *const tile,
                             int mi_row, int mi_col,
@@ -17,3 +24,9 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
                             int64_t *returndistortion,
                             BLOCK_SIZE bsize,
                             PICK_MODE_CONTEXT *ctx);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // VP9_ENCODER_VP9_PICKMODE_H_
diff --git a/vp9/encoder/vp9_psnr.h b/vp9/encoder/vp9_psnr.h
index 15dd8366bd830c16eb28b7be47e95861752bf577..ffe00ed2c41313585882f830faafec6ea38884d3 100644
--- a/vp9/encoder/vp9_psnr.h
+++ b/vp9/encoder/vp9_psnr.h
@@ -12,6 +12,14 @@
 #ifndef VP9_ENCODER_VP9_PSNR_H_
 #define VP9_ENCODER_VP9_PSNR_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 double vp9_mse2psnr(double samples, double peak, double mse);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_PSNR_H_
diff --git a/vp9/encoder/vp9_quantize.h b/vp9/encoder/vp9_quantize.h
index 41cfa5283639741ebec34f8d9cdf512bb53944ea..680cf4aec638c11a26784a4aeaff5d67d55bb098 100644
--- a/vp9/encoder/vp9_quantize.h
+++ b/vp9/encoder/vp9_quantize.h
@@ -13,6 +13,10 @@
 
 #include "vp9/encoder/vp9_block.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_regular_quantize_b_4x4(MACROBLOCK *x, int plane, int block,
                                 const int16_t *scan, const int16_t *iscan);
 
@@ -28,4 +32,8 @@ void vp9_mb_init_quantizer(struct VP9_COMP *cpi, MACROBLOCK *x);
 
 void vp9_init_quantizer(struct VP9_COMP *cpi);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_QUANTIZE_H_
diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h
index 086755af8d008fe12a972d6478753dfe610f1546..65ddead119978179d8d3030ee5d1253631e0798a 100644
--- a/vp9/encoder/vp9_ratectrl.h
+++ b/vp9/encoder/vp9_ratectrl.h
@@ -14,6 +14,10 @@
 
 #include "vp9/encoder/vp9_onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define FRAME_OVERHEAD_BITS 200
 
 void vp9_save_coding_context(VP9_COMP *cpi);
@@ -69,4 +73,8 @@ int vp9_drop_frame(VP9_COMP *cpi);
 // Update the buffer level.
 void vp9_update_buffer_level(VP9_COMP *cpi, int encoded_frame_size);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_RATECTRL_H_
diff --git a/vp9/encoder/vp9_rdopt.h b/vp9/encoder/vp9_rdopt.h
index 604236462b9789cce428f0277b4f14af307145ef..96cea421683438d2d7cb959a1388ae11b9498911 100644
--- a/vp9/encoder/vp9_rdopt.h
+++ b/vp9/encoder/vp9_rdopt.h
@@ -13,6 +13,10 @@
 
 #include "vp9/encoder/vp9_onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define RDDIV_BITS          7
 
 #define RDCOST(RM, DM, R, D) \
@@ -81,4 +85,8 @@ void vp9_get_entropy_contexts(TX_SIZE tx_size,
     const ENTROPY_CONTEXT *above, const ENTROPY_CONTEXT *left,
     int num_4x4_w, int num_4x4_h);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_RDOPT_H_
diff --git a/vp9/encoder/vp9_segmentation.h b/vp9/encoder/vp9_segmentation.h
index 3c6eb7038e0e470f8b7d92243e37b79371b95224..8238892e23f3f540fccc431eaf6c789721ba390b 100644
--- a/vp9/encoder/vp9_segmentation.h
+++ b/vp9/encoder/vp9_segmentation.h
@@ -15,6 +15,10 @@
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/encoder/vp9_onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_enable_segmentation(VP9_PTR ptr);
 void vp9_disable_segmentation(VP9_PTR ptr);
 
@@ -45,4 +49,8 @@ void vp9_choose_segmap_coding_method(VP9_COMP *cpi);
 
 void vp9_reset_segment_features(struct segmentation *seg);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_SEGMENTATION_H_
diff --git a/vp9/encoder/vp9_subexp.h b/vp9/encoder/vp9_subexp.h
index 1cafd8775557398e4a710d1d44847cc537e27143..ab5659bf783f214b4ef2d74ada95bf06829f1fb3 100644
--- a/vp9/encoder/vp9_subexp.h
+++ b/vp9/encoder/vp9_subexp.h
@@ -12,6 +12,10 @@
 #ifndef VP9_ENCODER_VP9_SUBEXP_H_
 #define VP9_ENCODER_VP9_SUBEXP_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_compute_update_table();
 
 
@@ -32,4 +36,8 @@ int vp9_prob_diff_update_savings_search_model(const unsigned int *ct,
                                               vp9_prob upd,
                                               int b, int r);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_SUBEXP_H_
diff --git a/vp9/encoder/vp9_temporal_filter.h b/vp9/encoder/vp9_temporal_filter.h
index c5f3b467e5403a09d983eaf2c126147b1c6bb22d..eea2f1018577d48cc14f8a73f7f59a6c2fcf2697 100644
--- a/vp9/encoder/vp9_temporal_filter.h
+++ b/vp9/encoder/vp9_temporal_filter.h
@@ -11,8 +11,16 @@
 #ifndef VP9_ENCODER_VP9_TEMPORAL_FILTER_H_
 #define VP9_ENCODER_VP9_TEMPORAL_FILTER_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance);
 void configure_arnr_filter(VP9_COMP *cpi, const unsigned int this_frame,
                            const int group_boost);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_TEMPORAL_FILTER_H_
diff --git a/vp9/encoder/vp9_tokenize.h b/vp9/encoder/vp9_tokenize.h
index 67e6c9d3daae1bb934e89c5b6df0dfb1ee4479ed..ea86240beee2ac5d14042e650552b1d7f03f331e 100644
--- a/vp9/encoder/vp9_tokenize.h
+++ b/vp9/encoder/vp9_tokenize.h
@@ -16,6 +16,10 @@
 #include "vp9/encoder/vp9_block.h"
 #include "vp9/encoder/vp9_treewriter.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void vp9_tokenize_initialize();
 
 #define EOSB_TOKEN 127     // Not signalled, encoder only
@@ -50,4 +54,8 @@ extern const int *vp9_dct_value_cost_ptr;
  */
 extern const TOKENVALUE *vp9_dct_value_tokens_ptr;
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_TOKENIZE_H_
diff --git a/vp9/encoder/vp9_treewriter.h b/vp9/encoder/vp9_treewriter.h
index 09f80b0bad567ccb1212a47d97676d88aaf8aab3..fedfbe937afab9f480121f97cf15822e75d06cee 100644
--- a/vp9/encoder/vp9_treewriter.h
+++ b/vp9/encoder/vp9_treewriter.h
@@ -13,6 +13,10 @@
 
 #include "vp9/encoder/vp9_writer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define vp9_cost_zero(prob) (vp9_prob_cost[prob])
 
 #define vp9_cost_one(prob) vp9_cost_zero(vp9_complement(prob))
@@ -69,4 +73,8 @@ static INLINE void vp9_write_token(vp9_writer *w, const vp9_tree_index *tree,
   vp9_write_tree(w, tree, probs, token->value, token->len, 0);
 }
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_TREEWRITER_H_
diff --git a/vp9/encoder/vp9_vaq.h b/vp9/encoder/vp9_vaq.h
index c45c479de022087c65d0aa11f889eb7352316568..c73114aebb6dc6b487d84f16c70b03d46ce76d0f 100644
--- a/vp9/encoder/vp9_vaq.h
+++ b/vp9/encoder/vp9_vaq.h
@@ -14,6 +14,10 @@
 
 #include "vp9/encoder/vp9_onyx_int.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 unsigned int vp9_vaq_segment_id(int energy);
 double vp9_vaq_rdmult_ratio(int energy);
 double vp9_vaq_inv_q_ratio(int energy);
@@ -23,4 +27,8 @@ void vp9_vaq_frame_setup(VP9_COMP *cpi);
 
 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_VAQ_H_
diff --git a/vp9/encoder/vp9_variance.h b/vp9/encoder/vp9_variance.h
index 2ded97c559e82adcea2ddaee3c40f5415ad4760b..3bc2091f8e96e4623ee945ea0c315a6920dc37c6 100644
--- a/vp9/encoder/vp9_variance.h
+++ b/vp9/encoder/vp9_variance.h
@@ -12,7 +12,10 @@
 #define VP9_ENCODER_VP9_VARIANCE_H_
 
 #include "vpx/vpx_integer.h"
-// #include "./vpx_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 void variance(const uint8_t *src_ptr,
               int  source_stride,
@@ -112,4 +115,8 @@ static void comp_avg_pred(uint8_t *comp_pred, const uint8_t *pred, int width,
     ref += ref_stride;
   }
 }
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_VARIANCE_H_
diff --git a/vp9/encoder/vp9_write_bit_buffer.h b/vp9/encoder/vp9_write_bit_buffer.h
index dfed903702402d9caa835a09944917c47edf5c54..5958b48067c59b91c430da0200708b3d81eeebb9 100644
--- a/vp9/encoder/vp9_write_bit_buffer.h
+++ b/vp9/encoder/vp9_write_bit_buffer.h
@@ -15,6 +15,10 @@
 
 #include "vpx/vpx_integer.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct vp9_write_bit_buffer {
   uint8_t *bit_buffer;
   size_t bit_offset;
@@ -45,4 +49,8 @@ static void vp9_wb_write_literal(struct vp9_write_bit_buffer *wb,
 }
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_WRITE_BIT_BUFFER_H_
diff --git a/vp9/encoder/vp9_writer.h b/vp9/encoder/vp9_writer.h
index 9cac7a84f4802589523c4eb9cf2fc1761ae49391..62f555c99e20759051a52b710211fba57e1cd5ff 100644
--- a/vp9/encoder/vp9_writer.h
+++ b/vp9/encoder/vp9_writer.h
@@ -15,6 +15,10 @@
 
 #include "vp9/common/vp9_prob.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct {
   unsigned int lowvalue;
   unsigned int range;
@@ -105,4 +109,8 @@ static void vp9_write_literal(vp9_writer *w, int data, int bits) {
 
 #define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8)
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_WRITER_H_
diff --git a/vp9/encoder/x86/vp9_mcomp_x86.h b/vp9/encoder/x86/vp9_mcomp_x86.h
index e1fcf40f24b1ae04940a56442732bca69d40f059..c15039ad819f7e274c717544e4e6cde903376157 100644
--- a/vp9/encoder/x86/vp9_mcomp_x86.h
+++ b/vp9/encoder/x86/vp9_mcomp_x86.h
@@ -12,6 +12,10 @@
 #ifndef VP9_ENCODER_X86_VP9_MCOMP_X86_H_
 #define VP9_ENCODER_X86_VP9_MCOMP_X86_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if HAVE_SSE3
 #if !CONFIG_RUNTIME_CPU_DETECT
 
@@ -36,5 +40,9 @@
 #endif
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_X86_VP9_MCOMP_X86_H_
 
diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h
index 6c644f045ed274d0fed758b71d1e3e792f41ce07..9f9da5c2891cf7c853279da763c790b865c7ed86 100644
--- a/vpx/internal/vpx_codec_internal.h
+++ b/vpx/internal/vpx_codec_internal.h
@@ -47,6 +47,9 @@
 #include "../vpx_encoder.h"
 #include <stdarg.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*!\brief Current ABI version number
  *
@@ -476,6 +479,7 @@ vpx_codec_pkt_list_get(struct vpx_codec_pkt_list *list,
 
 #include <stdio.h>
 #include <setjmp.h>
+
 struct vpx_internal_error_info {
   vpx_codec_err_t  error_code;
   int              has_detail;
@@ -532,4 +536,8 @@ vpx_codec_err_t vpx_validate_mmaps(const vpx_codec_stream_info_t *si,
                                    const vpx_codec_mmap_t *mmaps,
                                    const mem_req_t *mem_reqs, int nreqs,
                                    vpx_codec_flags_t init_flags);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VPX_INTERNAL_VPX_CODEC_INTERNAL_H_
diff --git a/vpx/vpx_image.h b/vpx/vpx_image.h
index 79e11aa0108b3e972c51cb9cd0e36e3ac331c715..d27325cad72bf82310b3c05dc828e4c118f16532 100644
--- a/vpx/vpx_image.h
+++ b/vpx/vpx_image.h
@@ -13,13 +13,13 @@
  * \brief Describes the vpx image descriptor and associated operations
  *
  */
+#ifndef VPX_VPX_IMAGE_H_
+#define VPX_VPX_IMAGE_H_
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#ifndef VPX_VPX_IMAGE_H_
-#define VPX_VPX_IMAGE_H_
-
   /*!\brief Current ABI version number
    *
    * \internal
@@ -237,7 +237,8 @@ extern "C" {
    */
   void vpx_img_free(vpx_image_t *img);
 
-#endif
 #ifdef __cplusplus
-}
+}  // extern "C"
+#endif
+
 #endif  // VPX_VPX_IMAGE_H_
diff --git a/vpx_ports/arm.h b/vpx_ports/arm.h
index 2562d9c1d85629a823825333373811a14e522f26..1e4a8e28873e571b96ccbfdd3c0c53082be36893 100644
--- a/vpx_ports/arm.h
+++ b/vpx_ports/arm.h
@@ -14,6 +14,10 @@
 #include <stdlib.h>
 #include "vpx_config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*ARMv5TE "Enhanced DSP" instructions.*/
 #define HAS_EDSP  0x01
 /*ARMv6 "Parallel" or "Media" instructions.*/
@@ -23,5 +27,9 @@
 
 int arm_cpu_caps(void);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VPX_PORTS_ARM_H_
 
diff --git a/vpx_ports/x86.h b/vpx_ports/x86.h
index a9d51a3bc90f480dd0ecb14ee2da17e6769c5eab..603e2b66c6e5e413a6377b87cacb563a030afa87 100644
--- a/vpx_ports/x86.h
+++ b/vpx_ports/x86.h
@@ -14,6 +14,10 @@
 #include <stdlib.h>
 #include "vpx_config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef enum {
   VPX_CPU_UNKNOWN = -1,
   VPX_CPU_AMD,
@@ -256,5 +260,9 @@ x87_set_double_precision(void) {
 
 
 extern void vpx_reset_mmx_state(void);
-#endif  // VPX_PORTS_X86_H_
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // VPX_PORTS_X86_H_
diff --git a/vpxenc.h b/vpxenc.h
index 5cb3f853ac4925be30d38399ab17700472ea75a1..5103ee65aea29324467a356962088ae4248b162c 100644
--- a/vpxenc.h
+++ b/vpxenc.h
@@ -12,6 +12,10 @@
 
 #include "vpx/vpx_encoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum TestDecodeFatality {
   TEST_DECODE_OFF,
   TEST_DECODE_FATAL,
@@ -42,4 +46,8 @@ struct VpxEncoderConfig {
   int disable_warning_prompt;
 };
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VPXENC_H_
diff --git a/vpxstats.h b/vpxstats.h
index 18b3acdc0705b9bba2a2f530431fc9963c37c727..9ce9c532094d4414dd5b16efa1ddc8f86a8487a1 100644
--- a/vpxstats.h
+++ b/vpxstats.h
@@ -15,6 +15,10 @@
 
 #include "vpx/vpx_encoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* This structure is used to abstract the different ways of handling
  * first pass statistics
  */
@@ -34,4 +38,8 @@ vpx_fixed_buf_t stats_get(stats_io_t *stats);
 
 double vp8_mse2psnr(double samples, double peak, double mse);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VPXSTATS_H_
diff --git a/warnings.h b/warnings.h
index ac3a4b63e6dedce874218f6e77fa11c40ca19376..6b8ae6796f37cbc76904850f0e4cd9e1c99c1c41 100644
--- a/warnings.h
+++ b/warnings.h
@@ -10,6 +10,10 @@
 #ifndef WARNINGS_H_
 #define WARNINGS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct vpx_codec_enc_cfg;
 struct VpxEncoderConfig;
 
@@ -22,4 +26,8 @@ void check_encoder_config(int disable_prompt,
                           const struct VpxEncoderConfig *global_config,
                           const struct vpx_codec_enc_cfg *stream_config);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // WARNINGS_H_
diff --git a/webmdec.h b/webmdec.h
index 002fbe645a3e862002109eab2e90b01ddfa9e356..fa5a52eaf10930fa3c19b39d667a95714ff64f50 100644
--- a/webmdec.h
+++ b/webmdec.h
@@ -12,6 +12,10 @@
 
 #include "./tools_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct nestegg;
 struct nestegg_packet;
 struct VpxInputContext;
@@ -37,4 +41,8 @@ int webm_guess_framerate(struct WebmInputContext *webm_ctx,
 
 void webm_free(struct WebmInputContext *webm_ctx);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // WEBMDEC_H_
diff --git a/webmenc.h b/webmenc.h
index f3bc3ecd212ad882e56775657becec8861c5862c..362aa895fb03cdfbf0f5fd4fb6283aef2fba1b1f 100644
--- a/webmenc.h
+++ b/webmenc.h
@@ -23,6 +23,10 @@ typedef __int64 off_t;
 #include "tools_common.h"
 #include "vpx/vpx_encoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef off_t EbmlLoc;
 
 struct cue_entry {
@@ -84,4 +88,8 @@ void write_webm_block(struct EbmlGlobal *glob,
 
 void write_webm_file_footer(struct EbmlGlobal *glob, int hash);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // WEBMENC_H_
diff --git a/y4menc.h b/y4menc.h
index e5f7978a73f0482a0421a79ea456265d47ba99cb..95f7909b1e5dd234535b882be75f75aaa10fe26f 100644
--- a/y4menc.h
+++ b/y4menc.h
@@ -17,6 +17,10 @@
 
 #include "vpx/vpx_decoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void y4m_write_file_header(FILE *file, int width, int height,
                            const struct VpxRational *framerate,
                            vpx_img_fmt_t fmt);
@@ -24,4 +28,8 @@ void y4m_write_file_header(FILE *file, int width, int height,
 void y4m_write_frame_header(FILE *file);
 
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // Y4MENC_H_
diff --git a/y4minput.h b/y4minput.h
index 615debe61382d19b337e330bd478a852aa0dbbae..d53eb651b9419998b251bc81efeb21a5ae26e1bf 100644
--- a/y4minput.h
+++ b/y4minput.h
@@ -17,6 +17,10 @@
 # include <stdio.h>
 # include "vpx/vpx_image.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 
 typedef struct y4m_input y4m_input;
@@ -62,4 +66,8 @@ int y4m_input_open(y4m_input *_y4m, FILE *_fin, char *_skip, int _nskip,
 void y4m_input_close(y4m_input *_y4m);
 int y4m_input_fetch_frame(y4m_input *_y4m, FILE *_fin, vpx_image_t *img);
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // Y4MINPUT_H_