shithub: libvpx

Download patch

ref: 26c88ec14ed21dff9dcafd91e9caaeee51887be4
parent: 8b0537f631754c9b06a97ebc3ccc1e3f1dc05eea
parent: 002ad40897cc3308ef3cfb579d3942615230ac0f
author: James Zern <jzern@google.com>
date: Fri Jan 24 05:47:00 EST 2014

Merge changes I826655a7,I5164df72,Iba9b198c,Ide9a6846,I4f51ce85,I0e6aa00f,Ic334da9a,I252f5f8a,I7865db2d,I13b434b1

* changes:
  test/: remove unnecessary extern "C"s
  top-level: add extern "C" to headers
  vpx_ports: add extern "C" to headers
  vpx: add extern "C" to headers
  vp9/encoder: add extern "C" to headers
  vp9/decoder: add extern "C" to headers
  vp9/common: add extern "C" to headers
  vp8/encoder: add extern "C" to headers
  vp8/decoder: add extern "C" to headers
  vp8/common: add extern "C" to headers

--- 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 @@
 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_
--- 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
 
@@ -37,5 +41,9 @@
 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_
--- 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 {
 
--- 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,
--- 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;
 
--- 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;
--- 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;
 
--- 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;
 
--- 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 {
 
--- 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 {
--- 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;
--- 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;
 
--- 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);
 
--- 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
--- 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 {
--- 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;
--- 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"
--- 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,
--- 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 {
 
--- 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_
--- 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,
@@ -31,5 +35,9 @@
     unsigned int          width,
     const short         *vp8_filter
 );
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_ARM_BILINEARFILTER_ARM_H_
--- a/vp8/common/blockd.h
+++ b/vp8/common/blockd.h
@@ -20,6 +20,10 @@
 #include "treecoder.h"
 #include "vpx_ports/mem.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*#define DCPRED 1*/
 #define DCPREDSIMTHRESH 0
 #define DCPREDCNTTHRESH 3
@@ -296,5 +300,9 @@
 
 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_
--- 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 */
 
@@ -185,5 +189,9 @@
         },
     },
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_COEFUPDATEPROBS_H_
--- 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) { \
@@ -36,5 +40,9 @@
 
 #define vp8_zero_array( Dest, N)  vpx_memset( Dest, 0, N * sizeof( *Dest));
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_COMMON_H_
--- 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*/
 
 
@@ -188,5 +192,9 @@
         }
     }
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_DEFAULT_COEF_PROBS_H_
--- 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 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_
--- 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,
@@ -76,5 +80,9 @@
 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_
--- 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 */
@@ -40,5 +44,9 @@
 } 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_
--- 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);
@@ -21,5 +25,9 @@
                                          YV12_BUFFER_CONFIG *dst,
                                          int srcy, int srcx,
                                          int srch, int srcw);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_EXTEND_H_
--- 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
@@ -20,5 +24,9 @@
 
 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_
--- a/vp8/common/findnearmv.h
+++ b/vp8/common/findnearmv.h
@@ -17,7 +17,11 @@
 #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)
 {
@@ -178,5 +182,9 @@
 
     return (cur_mb->bmi + b - 4)->as_mode;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_FINDNEARMV_H_
--- 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
 {
@@ -39,5 +43,9 @@
 #define VP8_HEADER_SIZE 3
 #endif
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_HEADER_H_
--- 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 @@
                      xd->dst.y_buffer,
                      xd->dst.y_stride, xd->eobs);
 }
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_INVTRANS_H_
--- 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 @@
                                 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_
--- 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_
--- 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;
@@ -24,5 +28,9 @@
     uint32_t  as_int;
     MV        as_mv;
 } int_mv;        /* facilitates faster equality tests and copies */
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_MV_H_
--- 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)
@@ -173,5 +177,9 @@
 #endif
     int cpu_caps;
 } VP8_COMMON;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_ONYXC_INT_H_
--- a/vp8/common/postproc.h
+++ b/vp8/common/postproc.h
@@ -26,6 +26,10 @@
 };
 #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 @@
 #define MFQE_PRECISION 4
 
 void vp8_multiframe_quality_enhance(struct VP8Common *cm);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_COMMON_POSTPROC_H_
--- 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,
@@ -37,5 +41,9 @@
     int display_b_modes_flag;
     int display_mv_flag;
 } vp8_ppflags_t;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_PPFLAGS_H_
--- a/vp8/common/pragmas.h
+++ b/vp8/common/pragmas.h
@@ -11,11 +11,19 @@
 #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
 #ifdef _MSC_VER
 #pragma warning(disable:4799)
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
 #endif
 
 #endif  // VP8_COMMON_PRAGMAS_H_
--- 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);
@@ -22,5 +26,9 @@
 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_
--- 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,
@@ -31,5 +35,9 @@
 
 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_
--- 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)
 {
@@ -28,5 +32,9 @@
     *dst_ptr1 = *src_ptr;
     *dst_ptr2 = *src_ptr;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_RECONINTRA4X4_H_
--- 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);
 
@@ -33,5 +37,9 @@
     for (i = 0; i < 8; i++)
         v_buffer[uv_stride *i] = (unsigned char) 129;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_SETUPINTRARECON_H_
--- 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_
--- 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_
--- 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 */
@@ -182,5 +186,9 @@
 #endif
 
 #endif /* CONFIG_OS_SUPPORT && CONFIG_MULTITHREAD */
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_THREADING_H_
--- 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 */
 
 
@@ -86,5 +90,9 @@
     c_bool_coder_spec *s
 );
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_TREECODER_H_
--- 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,
@@ -111,5 +115,9 @@
     vp8_copy32xn_fn_t       copymem;
 #endif
 } vp8_variance_fn_ptr_t;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_VARIANCE_H_
--- 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*/
 
 
@@ -242,5 +246,9 @@
         { 112,  19,  12,  61, 195, 128,  48,   4,  24 }
     }
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_COMMON_VP8_ENTROPYMODEDATA_H_
--- 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 */
 
@@ -21,5 +25,9 @@
 
 /* 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_
--- 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)
@@ -134,5 +138,9 @@
     /* No error. */
     return 0;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_DECODER_DBOOLHUFF_H_
--- 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_
--- 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);
@@ -17,6 +21,10 @@
 void vp8_decoder_create_threads(VP8D_COMP *pbi);
 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_
--- 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_
--- 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
 
 
@@ -46,5 +50,9 @@
     MV mv;
     MV_REFERENCE_FRAME ref_frame;
 } EC_BLOCK;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_DECODER_EC_TYPES_H_
--- 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);
 
@@ -37,5 +41,9 @@
  * Copies the prediction signal to the reconstructed image.
  */
 void vp8_conceal_corrupt_mb(MACROBLOCKD *xd);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_DECODER_ERROR_CONCEALMENT_H_
--- 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;
@@ -146,6 +150,10 @@
             vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
                                "Failed to allocate "#lval);\
     } while(0)
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
 #endif
 
 #endif  // VP8_DECODER_ONYXD_INT_H_
--- 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
@@ -36,5 +40,9 @@
 
     return -i;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_DECODER_TREEREADER_H_
--- 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 *,
@@ -41,6 +45,10 @@
 # define pack_tokens(a,b,c)                    vp8_pack_tokens_c(a,b,c)
 # define pack_tokens_into_partitions(a,b,c,d)  pack_tokens_into_partitions_c(a,b,c,d)
 # 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_
--- 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
 
@@ -159,5 +163,9 @@
 
 } MACROBLOCK;
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_BLOCK_H_
--- 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;
@@ -124,5 +128,9 @@
     br->lowvalue = lowvalue;
     br->range = range;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_BOOLHUFF_H_
--- 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() */
 
@@ -359,5 +363,9 @@
     8134, 8140, 8148, 8170, 8178, 8184, 8192, 8202, 8210, 8216, 8224, 8243,
     8251, 8257, 8265, 8275
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_DCT_VALUE_COST_H_
--- 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() */
 
@@ -700,5 +704,9 @@
     {10, 3942}, {10, 3944}, {10, 3946}, {10, 3948}, {10, 3950}, {10, 3952},
     {10, 3954}, {10, 3956}, {10, 3958}, {10, 3960}
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_DCT_VALUE_TOKENS_H_
--- 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]
@@ -224,5 +228,9 @@
         },
     },
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_DEFAULTCOEFCOUNTS_H_
--- 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)
 
@@ -38,5 +42,9 @@
                              unsigned int zero_mv_sse,
                              int recon_yoffset,
                              int recon_uvoffset);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_DENOISING_H_
--- 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_intra_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
         TOKENEXTRA **t);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_ENCODEFRAME_H_
--- 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_
--- 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_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_
--- 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_
--- 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_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_
--- 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;
@@ -105,5 +109,9 @@
 unsigned int
 vp8_lookahead_depth(struct lookahead_ctx *ctx);
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_LOOKAHEAD_H_
--- 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]);
@@ -103,5 +107,9 @@
      int *mvcost[2],
      int_mv *center_mv
     );
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_MCOMP_H_
--- 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_
--- 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_
--- 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 @@
                                "Failed to allocate "#lval);\
     } while(0)
 #endif
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_ONYX_INT_H_
--- 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 @@
                                       const vp8_variance_fn_ptr_t *vfp,
                                       unsigned int *sse,
                                       int_mv this_mv);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP8_ENCODER_PICKINTER_H_
--- 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_
--- 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);
@@ -19,5 +23,9 @@
 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_
--- 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);
 
@@ -25,5 +29,9 @@
 
 /* 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_
--- 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)
@@ -129,5 +133,9 @@
     int near_sadidx[]
 );
 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_
--- 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_
--- 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
@@ -46,5 +50,9 @@
  *  fields are not.
  */
 extern const TOKENVALUE *const vp8_dct_value_tokens_ptr;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_TOKENIZE_H_
--- 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
@@ -122,5 +126,9 @@
 void vp8_cost_tokens2(
     int *Costs, const vp8_prob *, vp8_tree, int
 );
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP8_ENCODER_TREEWRITER_H_
--- 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 @@
                               int w, int h);
 
 #endif  // #if HAVE_DSPR2
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_MIPS_DSPR2_VP9_COMMON_DSPR2_H_
--- 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 @@
   *oq6 = res_oq6;
 }
 #endif  // #if HAVE_DSPR2
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_MIPS_DSPR2_VP9_LOOPFILTER_FILTERS_DSPR2_H_
--- 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_
--- 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 @@
   *flat2 = flat1;
 }
 #endif  // #if HAVE_DSPR2
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_COMMON_MIPS_DSPR2_VP9_LOOPFILTER_MASKS_DSPR2_H_
--- 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);
@@ -27,5 +31,9 @@
 
 
 void vp9_update_frame_size(VP9_COMMON *cm);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_ALLOCCOMMON_H_
--- 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
@@ -462,5 +466,9 @@
   const int eob_max = 16 << (tx_size << 1);
   return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_BLOCKD_H_
--- 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))
 
@@ -90,5 +94,9 @@
 
 #define VP9_FRAME_MARKER 0x2
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_COMMON_H_
--- 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];
@@ -27,5 +31,9 @@
 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_
--- 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_
--- 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
@@ -183,5 +187,9 @@
     return &vp9_scan_orders[tx_size][mode2txfm_map[mode]];
   }
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_ENTROPY_H_
--- 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)
@@ -56,5 +60,9 @@
                                       unsigned int (*ct_16x16p)[2]);
 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_
--- 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);
@@ -120,5 +124,9 @@
 } nmv_context_counts;
 
 void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_ENTROPYMV_H_
--- 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
 
@@ -89,5 +93,9 @@
   RESERVED_2 = 6,
   SRGB       = 7   // RGB
 } COLOR_SPACE;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_ENUMS_H_
--- 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
@@ -47,5 +51,9 @@
 // filter kernel as a 2 tap filter.
 #define BILINEAR_FILTERS_2TAP(x) \
   (vp9_bilinear_filters[(x)] + SUBPEL_TAPS/2 - 1)
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_FILTER_H_
--- a/vp9/common/vp9_idct.h
+++ b/vp9/common/vp9_idct.h
@@ -18,7 +18,11 @@
 #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
 #define DCT_CONST_ROUNDING  (1 << (DCT_CONST_BITS - 1))
@@ -102,5 +106,9 @@
 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_
--- 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 @@
 
 // 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_
--- 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;
@@ -35,5 +39,9 @@
   mv->col = clamp(mv->col, min_col, max_col);
   mv->row = clamp(mv->row, min_row, max_row);
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_MV_H_
--- a/vp9/common/vp9_mvref_common.h
+++ b/vp9/common/vp9_mvref_common.h
@@ -7,13 +7,17 @@
  *  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,
                           MODE_INFO *mi, const MODE_INFO *prev_mi,
@@ -55,5 +59,9 @@
                                    const TileInfo *const tile,
                                    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_
--- a/vp9/common/vp9_onyx.h
+++ b/vp9/common/vp9_onyx.h
@@ -11,11 +11,6 @@
 #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"
@@ -22,6 +17,10 @@
 #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 @@
   int vp9_get_quantizer(VP9_PTR c);
 
 #ifdef __cplusplus
-}
+}  // extern "C"
 #endif
 
 #endif  // VP9_COMMON_VP9_ONYX_H_
--- 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
@@ -358,5 +362,9 @@
 
   return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_ONYXC_INT_H_
--- 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;
@@ -32,5 +36,9 @@
 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_
--- 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,
@@ -34,5 +38,9 @@
   int display_b_modes_flag;
   int display_mv_flag;
 } vp9_ppflags_t;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_PPFLAGS_H_
--- 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
@@ -17,6 +21,10 @@
 
 #ifdef _MSC_VER
 #pragma warning(disable:4799)
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
 #endif
 
 #endif  // VP9_COMMON_VP9_PRAGMAS_H_
--- 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;
 }
@@ -128,5 +132,9 @@
       return NULL;
   }
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_PRED_COMMON_H_
--- 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
@@ -108,5 +112,9 @@
 }
 
 DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_PROB_H_
--- 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)
@@ -24,5 +28,9 @@
 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_
--- 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);
@@ -94,5 +98,9 @@
   xd->block_refs[0] = &cm->frame_refs[ref0 >= 0 ? ref0 : 0];
   xd->block_refs[1] = &cm->frame_refs[ref1 >= 0 ? ref1 : 0];
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_RECONINTER_H_
--- 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_
--- 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
@@ -45,5 +49,9 @@
   return sf->x_scale_fp != REF_NO_SCALE ||
          sf->y_scale_fp != REF_NO_SCALE;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_SCALE_H_
--- 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();
@@ -35,5 +39,9 @@
   return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] +
           token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >> 1;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_SCAN_H_
--- 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
 
@@ -69,6 +73,10 @@
                     SEG_LVL_FEATURES feature_id);
 
 extern const vp9_tree_index vp9_segment_tree[TREE_SIZE(MAX_SEGMENTS)];
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_SEG_COMMON_H_
 
--- 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
@@ -71,5 +75,9 @@
 
 struct VP9Common;
 void vp9_machine_specific_config(struct VP9Common *cm);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_COMMON_VP9_SYSTEMDEPENDENT_H_
--- 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_
--- 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 {
@@ -25,5 +29,9 @@
 
 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_
--- 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
@@ -59,6 +63,10 @@
 
 
 #endif
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
 #endif
 
 #endif  // VP9_COMMON_X86_VP9_POSTPROC_X86_H_
--- 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_
--- 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_
--- 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_
--- 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_
--- 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 @@
 void vp9_remove_decompressor(VP9D_PTR comp);
 
 #ifdef __cplusplus
-}
+}  // extern "C"
 #endif
 
 #endif  // VP9_DECODER_VP9_ONYXD_H_
--- 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);
 
@@ -52,5 +56,9 @@
   ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
   PARTITION_CONTEXT *above_seg_context;
 } VP9D_COMP;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_DECODER_VP9_ONYXD_INT_H_
--- 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 {
@@ -56,5 +60,9 @@
   const int value = vp9_rb_read_literal(rb, bits);
   return vp9_rb_read_bit(rb) ? -value : value;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_DECODER_VP9_READ_BIT_BUFFER_H_
--- 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)
@@ -99,5 +103,9 @@
 
   return -i;
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_DECODER_VP9_READER_H_
--- 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 @@
 
 //------------------------------------------------------------------------------
 
-#if defined(__cplusplus) || defined(c_plusplus)
+#ifdef __cplusplus
 }    // extern "C"
 #endif
 
--- 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_
--- 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;
@@ -253,5 +257,9 @@
   int skip;
   const int16_t *scan, *nb;
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_ENCODER_VP9_BLOCK_H_
--- 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);
 
@@ -20,5 +24,9 @@
 
 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_
--- 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;
 
@@ -18,5 +22,9 @@
 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_
--- 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 @@
 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_
--- 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);
@@ -29,5 +33,9 @@
                               int mvc_flag_h);
 
 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_
--- a/vp9/encoder/vp9_extend.h
+++ b/vp9/encoder/vp9_extend.h
@@ -14,7 +14,11 @@
 #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 @@
                                          YV12_BUFFER_CONFIG *dst,
                                          int srcy, int srcx,
                                          int srch, int srcw);
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_EXTEND_H_
--- 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);
@@ -24,5 +28,9 @@
 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_
--- 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 {
@@ -93,5 +97,9 @@
  * \param[in] ctx       Pointer to the lookahead context
  */
 unsigned int vp9_lookahead_depth(struct lookahead_ctx *ctx);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_ENCODER_VP9_LOOKAHEAD_H_
--- 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_
--- 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 *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_
--- 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
 
@@ -814,5 +818,9 @@
 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_
--- 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_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_
--- 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 *returndistortion,
                             BLOCK_SIZE bsize,
                             PICK_MODE_CONTEXT *ctx);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // VP9_ENCODER_VP9_PICKMODE_H_
--- 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_
--- 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);
 
@@ -27,5 +31,9 @@
 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_
--- 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);
@@ -68,5 +72,9 @@
 
 // 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_
--- 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) \
@@ -80,5 +84,9 @@
     ENTROPY_CONTEXT t_above[16], ENTROPY_CONTEXT t_left[16],
     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_
--- 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);
 
@@ -44,5 +48,9 @@
 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_
--- 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();
 
 
@@ -31,5 +35,9 @@
                                               vp9_prob *bestp,
                                               vp9_prob upd,
                                               int b, int r);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_ENCODER_VP9_SUBEXP_H_
--- 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_
--- 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
@@ -49,5 +53,9 @@
  *  fields are not.
  */
 extern const TOKENVALUE *vp9_dct_value_tokens_ptr;
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_ENCODER_VP9_TOKENIZE_H_
--- 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))
@@ -68,5 +72,9 @@
                                    const struct vp9_token *token) {
   vp9_write_tree(w, tree, probs, token->value, token->len, 0);
 }
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_ENCODER_VP9_TREEWRITER_H_
--- 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);
@@ -22,5 +26,9 @@
 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_
--- a/vp9/encoder/vp9_variance.h
+++ b/vp9/encoder/vp9_variance.h
@@ -12,8 +12,11 @@
 #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,
               const uint8_t *ref_ptr,
@@ -112,4 +115,8 @@
     ref += ref_stride;
   }
 }
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP9_ENCODER_VP9_VARIANCE_H_
--- 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;
@@ -44,5 +48,9 @@
     vp9_wb_write_bit(wb, (data >> bit) & 1);
 }
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_ENCODER_VP9_WRITE_BIT_BUFFER_H_
--- 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;
@@ -104,5 +108,9 @@
 }
 
 #define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8)
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VP9_ENCODER_VP9_WRITER_H_
--- 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
 
@@ -34,6 +38,10 @@
 #define vp9_search_full_search vp9_full_search_sadx8
 
 #endif
+#endif
+
+#ifdef __cplusplus
+}  // extern "C"
 #endif
 
 #endif  // VP9_ENCODER_X86_VP9_MCOMP_X86_H_
--- 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 @@
 
 #include <stdio.h>
 #include <setjmp.h>
+
 struct vpx_internal_error_info {
   vpx_codec_err_t  error_code;
   int              has_detail;
@@ -532,4 +536,8 @@
                                    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_
--- 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 @@
    */
   void vpx_img_free(vpx_image_t *img);
 
-#endif
 #ifdef __cplusplus
-}
+}  // extern "C"
+#endif
+
 #endif  // VPX_VPX_IMAGE_H_
--- 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.*/
@@ -22,6 +26,10 @@
 #define HAS_NEON  0x04
 
 int arm_cpu_caps(void);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VPX_PORTS_ARM_H_
 
--- 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 @@
 
 
 extern void vpx_reset_mmx_state(void);
-#endif  // VPX_PORTS_X86_H_
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // VPX_PORTS_X86_H_
--- 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,
@@ -41,5 +45,9 @@
   int disable_warnings;
   int disable_warning_prompt;
 };
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // VPXENC_H_
--- 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
  */
@@ -33,5 +37,9 @@
 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_
--- 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;
 
@@ -21,5 +25,9 @@
 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_
--- 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;
@@ -36,5 +40,9 @@
                          struct VpxInputContext *vpx_ctx);
 
 void webm_free(struct WebmInputContext *webm_ctx);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // WEBMDEC_H_
--- a/webmenc.h
+++ b/webmenc.h
@@ -23,6 +23,10 @@
 #include "tools_common.h"
 #include "vpx/vpx_encoder.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef off_t EbmlLoc;
 
 struct cue_entry {
@@ -83,5 +87,9 @@
                       const vpx_codec_cx_pkt_t *pkt);
 
 void write_webm_file_footer(struct EbmlGlobal *glob, int hash);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // WEBMENC_H_
--- 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);
@@ -23,5 +27,9 @@
 
 void y4m_write_frame_header(FILE *file);
 
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
 
 #endif  // Y4MENC_H_
--- a/y4minput.h
+++ b/y4minput.h
@@ -17,8 +17,12 @@
 # include <stdio.h>
 # include "vpx/vpx_image.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 
+
 typedef struct y4m_input y4m_input;
 
 
@@ -61,5 +65,9 @@
                    int only_420);
 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_
--