diff --git a/examples.mk b/examples.mk
index 5fcf6a350b9fd6a4617dd58d34c9f9eaf4ba7120..85b84577cacd49504ef524852dc2e6ba14e5d813 100644
--- a/examples.mk
+++ b/examples.mk
@@ -19,6 +19,8 @@ LIBYUV_SRCS +=  third_party/libyuv/include/libyuv/basic_types.h  \
 # while EXAMPLES demonstrate specific portions of the API.
 UTILS-$(CONFIG_DECODERS)    += vpxdec.c
 vpxdec.SRCS                 += md5_utils.c md5_utils.h
+vpxdec.SRCS                 += vpx_ports/mem_ops.h
+vpxdec.SRCS                 += vpx_ports/mem_ops_aligned.h
 vpxdec.SRCS                 += vpx_ports/vpx_timer.h
 vpxdec.SRCS                 += vpx/vpx_integer.h
 vpxdec.SRCS                 += args.c args.h
@@ -85,12 +87,16 @@ simple_decoder.SRCS                += ivfdec.h ivfdec.c
 simple_decoder.SRCS                += tools_common.h tools_common.c
 simple_decoder.SRCS                += video_common.h
 simple_decoder.SRCS                += video_reader.h video_reader.c
+simple_decoder.SRCS                += vpx_ports/mem_ops.h
+simple_decoder.SRCS                += vpx_ports/mem_ops_aligned.h
 simple_decoder.DESCRIPTION          = Simplified decoder loop
 EXAMPLES-$(CONFIG_VP8_DECODER)     += postproc.c
 postproc.SRCS                      += ivfdec.h ivfdec.c
 postproc.SRCS                      += tools_common.h tools_common.c
 postproc.SRCS                      += video_common.h
 postproc.SRCS                      += video_reader.h video_reader.c
+postproc.SRCS                      += vpx_ports/mem_ops.h
+postproc.SRCS                      += vpx_ports/mem_ops_aligned.h
 postproc.GUID                       = 65E33355-F35E-4088-884D-3FD4905881D7
 postproc.DESCRIPTION                = Decoder postprocessor control
 EXAMPLES-$(CONFIG_VP8_DECODER)     += decode_to_md5.c
@@ -99,6 +105,8 @@ decode_to_md5.SRCS                 += ivfdec.h ivfdec.c
 decode_to_md5.SRCS                 += tools_common.h tools_common.c
 decode_to_md5.SRCS                 += video_common.h
 decode_to_md5.SRCS                 += video_reader.h video_reader.c
+decode_to_md5.SRCS                 += vpx_ports/mem_ops.h
+decode_to_md5.SRCS                 += vpx_ports/mem_ops_aligned.h
 decode_to_md5.GUID                  = 59120B9B-2735-4BFE-B022-146CA340FE42
 decode_to_md5.DESCRIPTION           = Frame by frame MD5 checksum
 EXAMPLES-$(CONFIG_VP8_ENCODER)  += simple_encoder.c
@@ -124,6 +132,8 @@ decode_with_drops.SRCS          += ivfdec.h ivfdec.c
 decode_with_drops.SRCS          += tools_common.h tools_common.c
 decode_with_drops.SRCS          += video_common.h
 decode_with_drops.SRCS          += video_reader.h video_reader.c
+decode_with_drops.SRCS          += vpx_ports/mem_ops.h
+decode_with_drops.SRCS          += vpx_ports/mem_ops_aligned.h
 endif
 decode_with_drops.GUID           = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
 decode_with_drops.DESCRIPTION    = Drops frames while decoding
diff --git a/ivfdec.c b/ivfdec.c
index 40394a81abbc5b946299650c2e7936227e69ffc2..6dcd66f734d575ceb48474cf332bc1dde693133c 100644
--- a/ivfdec.c
+++ b/ivfdec.c
@@ -12,6 +12,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "vpx_ports/mem_ops.h"
+
 #include "./ivfdec.h"
 
 static const char *IVF_SIGNATURE = "DKIF";
diff --git a/tools_common.c b/tools_common.c
index f0e160697b25bd20f4ae1b764e210808ea0c5497..667432027f71d23d617a8a39fa8458fc20629f26 100644
--- a/tools_common.c
+++ b/tools_common.c
@@ -77,26 +77,6 @@ void die_codec(vpx_codec_ctx_t *ctx, const char *s) {
   exit(EXIT_FAILURE);
 }
 
-uint16_t mem_get_le16(const void *data) {
-  uint16_t val;
-  const uint8_t *mem = (const uint8_t*)data;
-
-  val = mem[1] << 8;
-  val |= mem[0];
-  return val;
-}
-
-uint32_t mem_get_le32(const void *data) {
-  uint32_t val;
-  const uint8_t *mem = (const uint8_t*)data;
-
-  val = mem[3] << 24;
-  val |= mem[2] << 16;
-  val |= mem[1] << 8;
-  val |= mem[0];
-  return val;
-}
-
 int read_yuv_frame(struct VpxInputContext *input_ctx, vpx_image_t *yuv_frame) {
   FILE *f = input_ctx->file;
   struct FileTypeDetectionBuffer *detect = &input_ctx->detect;
diff --git a/tools_common.h b/tools_common.h
index 2e90259156735e48c8819cf623f944a756fdeae5..b60825cefcc41f8237a6a0470bc3d8d8566f08bc 100644
--- a/tools_common.h
+++ b/tools_common.h
@@ -118,9 +118,6 @@ void die_codec(vpx_codec_ctx_t *ctx, const char *s);
 /* The tool including this file must define usage_exit() */
 void usage_exit();
 
-uint16_t mem_get_le16(const void *data);
-uint32_t mem_get_le32(const void *data);
-
 int read_yuv_frame(struct VpxInputContext *input_ctx, vpx_image_t *yuv_frame);
 
 typedef struct VpxInterface {
diff --git a/video_reader.c b/video_reader.c
index 4be7483d3b8b6b45da119e67b6aa666d1b3e84b4..39c7edba1e3deb5f8d3362deeb26ba581f8a5136 100644
--- a/video_reader.c
+++ b/video_reader.c
@@ -14,6 +14,8 @@
 #include "./ivfdec.h"
 #include "./video_reader.h"
 
+#include "vpx_ports/mem_ops.h"
+
 static const char *const kIVFSignature = "DKIF";
 
 struct VpxVideoReaderStruct {
diff --git a/vpx_ports/mem_ops_aligned.h b/vpx_ports/mem_ops_aligned.h
index da7c65d963f136731a75421c7f42a853cdcabf36..24743c8d6944cbee4a77eff766f6c4dea28cc36a 100644
--- a/vpx_ports/mem_ops_aligned.h
+++ b/vpx_ports/mem_ops_aligned.h
@@ -11,6 +11,8 @@
 #ifndef VPX_PORTS_MEM_OPS_ALIGNED_H_
 #define VPX_PORTS_MEM_OPS_ALIGNED_H_
 
+#include "vpx/vpx_integer.h"
+
 /* \file
  * \brief Provides portable memory access primitives for operating on aligned
  *        data
diff --git a/vpxdec.c b/vpxdec.c
index d99b5aa932ba49e76f3ba913d56c083eff75ce88..b69e55eeb1fa00b314603e365e5aa8bac633af24 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -23,6 +23,7 @@
 #define VPX_CODEC_DISABLE_COMPAT 1
 #include "./vpx_config.h"
 #include "vpx/vpx_decoder.h"
+#include "vpx_ports/mem_ops.h"
 #include "vpx_ports/vpx_timer.h"
 
 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER