diff --git a/examples/decode_to_md5.c b/examples/decode_to_md5.c
index 1ae7a4b57f50292a9d369f60892a14d05ae0f7f2..51959f37df764adbcd01c5180e1445a9e1dbb594 100644
--- a/examples/decode_to_md5.c
+++ b/examples/decode_to_md5.c
@@ -65,8 +65,7 @@ static void get_image_md5(const vpx_image_t *img, unsigned char digest[16]) {
 static void print_md5(FILE *stream, unsigned char digest[16]) {
   int i;
 
-  for (i = 0; i < 16; ++i)
-    fprintf(stream, "%02x", digest[i]);
+  for (i = 0; i < 16; ++i) fprintf(stream, "%02x", digest[i]);
 }
 
 static const char *exec_name;
@@ -86,12 +85,10 @@ int main(int argc, char **argv) {
 
   exec_name = argv[0];
 
-  if (argc != 3)
-    die("Invalid number of arguments.");
+  if (argc != 3) die("Invalid number of arguments.");
 
   reader = vpx_video_reader_open(argv[1]);
-  if (!reader)
-    die("Failed to open %s for reading.", argv[1]);
+  if (!reader) die("Failed to open %s for reading.", argv[1]);
 
   if (!(outfile = fopen(argv[2], "wb")))
     die("Failed to open %s for writing.", argv[2]);
@@ -99,8 +96,7 @@ int main(int argc, char **argv) {
   info = vpx_video_reader_get_info(reader);
 
   decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
-  if (!decoder)
-    die("Unknown input codec.");
+  if (!decoder) die("Unknown input codec.");
 
   printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
 
@@ -111,8 +107,8 @@ int main(int argc, char **argv) {
     vpx_codec_iter_t iter = NULL;
     vpx_image_t *img = NULL;
     size_t frame_size = 0;
-    const unsigned char *frame = vpx_video_reader_get_frame(reader,
-                                                            &frame_size);
+    const unsigned char *frame =
+        vpx_video_reader_get_frame(reader, &frame_size);
     if (vpx_codec_decode(&codec, frame, (unsigned int)frame_size, NULL, 0))
       die_codec(&codec, "Failed to decode frame");
 
@@ -121,14 +117,13 @@ int main(int argc, char **argv) {
 
       get_image_md5(img, digest);
       print_md5(outfile, digest);
-      fprintf(outfile, "  img-%dx%d-%04d.i420\n",
-              img->d_w, img->d_h, ++frame_cnt);
+      fprintf(outfile, "  img-%dx%d-%04d.i420\n", img->d_w, img->d_h,
+              ++frame_cnt);
     }
   }
 
   printf("Processed %d frames.\n", frame_cnt);
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec.");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
 
   vpx_video_reader_close(reader);
 
diff --git a/examples/decode_with_drops.c b/examples/decode_with_drops.c
index 2233e473d364c39cf5c104d828b5ae53787f027e..29b8be94131cd59fb8ab9729e9d9f5d6154ead8c 100644
--- a/examples/decode_with_drops.c
+++ b/examples/decode_with_drops.c
@@ -84,12 +84,10 @@ int main(int argc, char **argv) {
 
   exec_name = argv[0];
 
-  if (argc != 4)
-    die("Invalid number of arguments.");
+  if (argc != 4) die("Invalid number of arguments.");
 
   reader = vpx_video_reader_open(argv[1]);
-  if (!reader)
-    die("Failed to open %s for reading.", argv[1]);
+  if (!reader) die("Failed to open %s for reading.", argv[1]);
 
   if (!(outfile = fopen(argv[2], "wb")))
     die("Failed to open %s for writing.", argv[2]);
@@ -103,8 +101,7 @@ int main(int argc, char **argv) {
   info = vpx_video_reader_get_info(reader);
 
   decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
-  if (!decoder)
-    die("Unknown input codec.");
+  if (!decoder) die("Unknown input codec.");
 
   printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
 
@@ -116,8 +113,8 @@ int main(int argc, char **argv) {
     vpx_image_t *img = NULL;
     size_t frame_size = 0;
     int skip;
-    const unsigned char *frame = vpx_video_reader_get_frame(reader,
-                                                            &frame_size);
+    const unsigned char *frame =
+        vpx_video_reader_get_frame(reader, &frame_size);
     if (vpx_codec_decode(&codec, frame, (unsigned int)frame_size, NULL, 0))
       die_codec(&codec, "Failed to decode frame.");
 
@@ -139,8 +136,7 @@ int main(int argc, char **argv) {
   }
 
   printf("Processed %d frames.\n", frame_cnt);
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec.");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
 
   printf("Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
          info->frame_width, info->frame_height, argv[2]);
diff --git a/examples/set_maps.c b/examples/set_maps.c
index 1dc3ac0c98f8e1b75e6eff2372b64cd1c399f9af..d128e7d9a0d7822ef25be53510e8856a476db177 100644
--- a/examples/set_maps.c
+++ b/examples/set_maps.c
@@ -8,7 +8,6 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-
 // VP8 Set Active and ROI Maps
 // ===========================
 //
@@ -86,8 +85,7 @@ static void set_roi_map(const vpx_codec_enc_cfg_t *cfg,
   roi.static_threshold[3] = 0;
 
   roi.roi_map = (uint8_t *)malloc(roi.rows * roi.cols);
-  for (i = 0; i < roi.rows * roi.cols; ++i)
-    roi.roi_map[i] = i % 4;
+  for (i = 0; i < roi.rows * roi.cols; ++i) roi.roi_map[i] = i % 4;
 
   if (vpx_codec_control(codec, VP8E_SET_ROI_MAP, &roi))
     die_codec(codec, "Failed to set ROI map");
@@ -98,14 +96,13 @@ static void set_roi_map(const vpx_codec_enc_cfg_t *cfg,
 static void set_active_map(const vpx_codec_enc_cfg_t *cfg,
                            vpx_codec_ctx_t *codec) {
   unsigned int i;
-  vpx_active_map_t map = {0, 0, 0};
+  vpx_active_map_t map = { 0, 0, 0 };
 
   map.rows = (cfg->g_h + 15) / 16;
   map.cols = (cfg->g_w + 15) / 16;
 
   map.active_map = (uint8_t *)malloc(map.rows * map.cols);
-  for (i = 0; i < map.rows * map.cols; ++i)
-    map.active_map[i] = i % 2;
+  for (i = 0; i < map.rows * map.cols; ++i) map.active_map[i] = i % 2;
 
   if (vpx_codec_control(codec, VP8E_SET_ACTIVEMAP, &map))
     die_codec(codec, "Failed to set active map");
@@ -115,7 +112,7 @@ static void set_active_map(const vpx_codec_enc_cfg_t *cfg,
 
 static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,
                              vpx_codec_ctx_t *codec) {
-  vpx_active_map_t map = {0, 0, 0};
+  vpx_active_map_t map = { 0, 0, 0 };
 
   map.rows = (cfg->g_h + 15) / 16;
   map.cols = (cfg->g_w + 15) / 16;
@@ -125,25 +122,21 @@ static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,
     die_codec(codec, "Failed to set active map");
 }
 
-static int encode_frame(vpx_codec_ctx_t *codec,
-                        vpx_image_t *img,
-                        int frame_index,
-                        VpxVideoWriter *writer) {
+static int encode_frame(vpx_codec_ctx_t *codec, vpx_image_t *img,
+                        int frame_index, VpxVideoWriter *writer) {
   int got_pkts = 0;
   vpx_codec_iter_t iter = NULL;
   const vpx_codec_cx_pkt_t *pkt = NULL;
-  const vpx_codec_err_t res = vpx_codec_encode(codec, img, frame_index, 1, 0,
-                                               VPX_DL_GOOD_QUALITY);
-  if (res != VPX_CODEC_OK)
-    die_codec(codec, "Failed to encode frame");
+  const vpx_codec_err_t res =
+      vpx_codec_encode(codec, img, frame_index, 1, 0, VPX_DL_GOOD_QUALITY);
+  if (res != VPX_CODEC_OK) die_codec(codec, "Failed to encode frame");
 
   while ((pkt = vpx_codec_get_cx_data(codec, &iter)) != NULL) {
     got_pkts = 1;
 
     if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
       const int keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
-      if (!vpx_video_writer_write_frame(writer,
-                                        pkt->data.frame.buf,
+      if (!vpx_video_writer_write_frame(writer, pkt->data.frame.buf,
                                         pkt->data.frame.sz,
                                         pkt->data.frame.pts)) {
         die_codec(codec, "Failed to write compressed frame");
@@ -167,12 +160,11 @@ int main(int argc, char **argv) {
   VpxVideoInfo info;
   VpxVideoWriter *writer = NULL;
   const VpxInterface *encoder = NULL;
-  const int fps = 2;        // TODO(dkovalev) add command line argument
+  const int fps = 2;  // TODO(dkovalev) add command line argument
   const double bits_per_pixel_per_frame = 0.067;
 
   exec_name = argv[0];
-  if (argc != 6)
-    die("Invalid number of arguments");
+  if (argc != 6) die("Invalid number of arguments");
 
   memset(&info, 0, sizeof(info));
 
@@ -187,35 +179,31 @@ int main(int argc, char **argv) {
   info.time_base.numerator = 1;
   info.time_base.denominator = fps;
 
-  if (info.frame_width <= 0 ||
-      info.frame_height <= 0 ||
-      (info.frame_width % 2) != 0 ||
-      (info.frame_height % 2) != 0) {
+  if (info.frame_width <= 0 || info.frame_height <= 0 ||
+      (info.frame_width % 2) != 0 || (info.frame_height % 2) != 0) {
     die("Invalid frame size: %dx%d", info.frame_width, info.frame_height);
   }
 
   if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,
-                                             info.frame_height, 1)) {
+                     info.frame_height, 1)) {
     die("Failed to allocate image.");
   }
 
   printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
 
   res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
-  if (res)
-    die_codec(&codec, "Failed to get default codec config.");
+  if (res) die_codec(&codec, "Failed to get default codec config.");
 
   cfg.g_w = info.frame_width;
   cfg.g_h = info.frame_height;
   cfg.g_timebase.num = info.time_base.numerator;
   cfg.g_timebase.den = info.time_base.denominator;
-  cfg.rc_target_bitrate = (unsigned int)(bits_per_pixel_per_frame * cfg.g_w *
-                                         cfg.g_h * fps / 1000);
+  cfg.rc_target_bitrate =
+      (unsigned int)(bits_per_pixel_per_frame * cfg.g_w * cfg.g_h * fps / 1000);
   cfg.g_lag_in_frames = 0;
 
   writer = vpx_video_writer_open(argv[5], kContainerIVF, &info);
-  if (!writer)
-    die("Failed to open %s for writing.", argv[5]);
+  if (!writer) die("Failed to open %s for writing.", argv[5]);
 
   if (!(infile = fopen(argv[4], "rb")))
     die("Failed to open %s for reading.", argv[4]);
@@ -239,15 +227,15 @@ int main(int argc, char **argv) {
   }
 
   // Flush encoder.
-  while (encode_frame(&codec, NULL, -1, writer)) {}
+  while (encode_frame(&codec, NULL, -1, writer)) {
+  }
 
   printf("\n");
   fclose(infile);
   printf("Processed %d frames.\n", frame_count);
 
   vpx_img_free(&raw);
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec.");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
 
   vpx_video_writer_close(writer);
 
diff --git a/examples/simple_decoder.c b/examples/simple_decoder.c
index 8ccc81035e3ba649ca0e6eb216ebbf0896c6a0bc..2bb1a05245bd3abe27fa2e46cc061ba822b0a7eb 100644
--- a/examples/simple_decoder.c
+++ b/examples/simple_decoder.c
@@ -8,7 +8,6 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-
 // Simple Decoder
 // ==============
 //
@@ -103,12 +102,10 @@ int main(int argc, char **argv) {
 
   exec_name = argv[0];
 
-  if (argc != 3)
-    die("Invalid number of arguments.");
+  if (argc != 3) die("Invalid number of arguments.");
 
   reader = vpx_video_reader_open(argv[1]);
-  if (!reader)
-    die("Failed to open %s for reading.", argv[1]);
+  if (!reader) die("Failed to open %s for reading.", argv[1]);
 
   if (!(outfile = fopen(argv[2], "wb")))
     die("Failed to open %s for writing.", argv[2]);
@@ -116,8 +113,7 @@ int main(int argc, char **argv) {
   info = vpx_video_reader_get_info(reader);
 
   decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
-  if (!decoder)
-    die("Unknown input codec.");
+  if (!decoder) die("Unknown input codec.");
 
   printf("Using %s\n", vpx_codec_iface_name(decoder->codec_interface()));
 
@@ -128,8 +124,8 @@ int main(int argc, char **argv) {
     vpx_codec_iter_t iter = NULL;
     vpx_image_t *img = NULL;
     size_t frame_size = 0;
-    const unsigned char *frame = vpx_video_reader_get_frame(reader,
-                                                            &frame_size);
+    const unsigned char *frame =
+        vpx_video_reader_get_frame(reader, &frame_size);
     if (vpx_codec_decode(&codec, frame, (unsigned int)frame_size, NULL, 0))
       die_codec(&codec, "Failed to decode frame.");
 
@@ -140,8 +136,7 @@ int main(int argc, char **argv) {
   }
 
   printf("Processed %d frames.\n", frame_cnt);
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec");
 
   printf("Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
          info->frame_width, info->frame_height, argv[2]);
diff --git a/examples/simple_encoder.c b/examples/simple_encoder.c
index a30772973180a460323b284d8235285429c5d23e..ae0c6601245d2b41c07b81b74234a12cd39e2f59 100644
--- a/examples/simple_encoder.c
+++ b/examples/simple_encoder.c
@@ -109,32 +109,27 @@ static const char *exec_name;
 void usage_exit(void) {
   fprintf(stderr,
           "Usage: %s <codec> <width> <height> <infile> <outfile> "
-              "<keyframe-interval> [<error-resilient>]\nSee comments in "
-              "simple_encoder.c for more information.\n",
+          "<keyframe-interval> [<error-resilient>]\nSee comments in "
+          "simple_encoder.c for more information.\n",
           exec_name);
   exit(EXIT_FAILURE);
 }
 
-static int encode_frame(vpx_codec_ctx_t *codec,
-                        vpx_image_t *img,
-                        int frame_index,
-                        int flags,
-                        VpxVideoWriter *writer) {
+static int encode_frame(vpx_codec_ctx_t *codec, vpx_image_t *img,
+                        int frame_index, int flags, VpxVideoWriter *writer) {
   int got_pkts = 0;
   vpx_codec_iter_t iter = NULL;
   const vpx_codec_cx_pkt_t *pkt = NULL;
-  const vpx_codec_err_t res = vpx_codec_encode(codec, img, frame_index, 1,
-                                               flags, VPX_DL_GOOD_QUALITY);
-  if (res != VPX_CODEC_OK)
-    die_codec(codec, "Failed to encode frame");
+  const vpx_codec_err_t res =
+      vpx_codec_encode(codec, img, frame_index, 1, flags, VPX_DL_GOOD_QUALITY);
+  if (res != VPX_CODEC_OK) die_codec(codec, "Failed to encode frame");
 
   while ((pkt = vpx_codec_get_cx_data(codec, &iter)) != NULL) {
     got_pkts = 1;
 
     if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
       const int keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
-      if (!vpx_video_writer_write_frame(writer,
-                                        pkt->data.frame.buf,
+      if (!vpx_video_writer_write_frame(writer, pkt->data.frame.buf,
                                         pkt->data.frame.sz,
                                         pkt->data.frame.pts)) {
         die_codec(codec, "Failed to write compressed frame");
@@ -154,11 +149,11 @@ int main(int argc, char **argv) {
   int frame_count = 0;
   vpx_image_t raw;
   vpx_codec_err_t res;
-  VpxVideoInfo info = {0};
+  VpxVideoInfo info = { 0 };
   VpxVideoWriter *writer = NULL;
   const VpxInterface *encoder = NULL;
-  const int fps = 30;        // TODO(dkovalev) add command line argument
-  const int bitrate = 200;   // kbit/s TODO(dkovalev) add command line argument
+  const int fps = 30;       // TODO(dkovalev) add command line argument
+  const int bitrate = 200;  // kbit/s TODO(dkovalev) add command line argument
   int keyframe_interval = 0;
 
   // TODO(dkovalev): Add some simple command line parsing code to make the
@@ -172,8 +167,7 @@ int main(int argc, char **argv) {
 
   exec_name = argv[0];
 
-  if (argc < 7)
-    die("Invalid number of arguments");
+  if (argc < 7) die("Invalid number of arguments");
 
   codec_arg = argv[1];
   width_arg = argv[2];
@@ -183,8 +177,7 @@ int main(int argc, char **argv) {
   keyframe_interval_arg = argv[6];
 
   encoder = get_vpx_encoder_by_name(codec_arg);
-  if (!encoder)
-     die("Unsupported codec.");
+  if (!encoder) die("Unsupported codec.");
 
   info.codec_fourcc = encoder->fourcc;
   info.frame_width = strtol(width_arg, NULL, 0);
@@ -192,27 +185,23 @@ int main(int argc, char **argv) {
   info.time_base.numerator = 1;
   info.time_base.denominator = fps;
 
-  if (info.frame_width <= 0 ||
-      info.frame_height <= 0 ||
-      (info.frame_width % 2) != 0 ||
-      (info.frame_height % 2) != 0) {
+  if (info.frame_width <= 0 || info.frame_height <= 0 ||
+      (info.frame_width % 2) != 0 || (info.frame_height % 2) != 0) {
     die("Invalid frame size: %dx%d", info.frame_width, info.frame_height);
   }
 
   if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,
-                                             info.frame_height, 1)) {
+                     info.frame_height, 1)) {
     die("Failed to allocate image.");
   }
 
   keyframe_interval = strtol(keyframe_interval_arg, NULL, 0);
-  if (keyframe_interval < 0)
-    die("Invalid keyframe interval value.");
+  if (keyframe_interval < 0) die("Invalid keyframe interval value.");
 
   printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
 
   res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
-  if (res)
-    die_codec(&codec, "Failed to get default codec config.");
+  if (res) die_codec(&codec, "Failed to get default codec config.");
 
   cfg.g_w = info.frame_width;
   cfg.g_h = info.frame_height;
@@ -222,8 +211,7 @@ int main(int argc, char **argv) {
   cfg.g_error_resilient = argc > 7 ? strtol(argv[7], NULL, 0) : 0;
 
   writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);
-  if (!writer)
-    die("Failed to open %s for writing.", outfile_arg);
+  if (!writer) die("Failed to open %s for writing.", outfile_arg);
 
   if (!(infile = fopen(infile_arg, "rb")))
     die("Failed to open %s for reading.", infile_arg);
@@ -240,15 +228,14 @@ int main(int argc, char **argv) {
   }
 
   // Flush encoder.
-  while (encode_frame(&codec, NULL, -1, 0, writer)) {};
+  while (encode_frame(&codec, NULL, -1, 0, writer)) continue;
 
   printf("\n");
   fclose(infile);
   printf("Processed %d frames.\n", frame_count);
 
   vpx_img_free(&raw);
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec.");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
 
   vpx_video_writer_close(writer);
 
diff --git a/examples/twopass_encoder.c b/examples/twopass_encoder.c
index aecc11d3f4e575500c67047bd99fae0e232ab25a..41d17d0ae740479fa9239408d67813ca6b7f09c1 100644
--- a/examples/twopass_encoder.c
+++ b/examples/twopass_encoder.c
@@ -64,20 +64,16 @@ void usage_exit(void) {
   exit(EXIT_FAILURE);
 }
 
-static int get_frame_stats(vpx_codec_ctx_t *ctx,
-                           const vpx_image_t *img,
-                           vpx_codec_pts_t pts,
-                           unsigned int duration,
-                           vpx_enc_frame_flags_t flags,
-                           unsigned int deadline,
+static int get_frame_stats(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
+                           vpx_codec_pts_t pts, unsigned int duration,
+                           vpx_enc_frame_flags_t flags, unsigned int deadline,
                            vpx_fixed_buf_t *stats) {
   int got_pkts = 0;
   vpx_codec_iter_t iter = NULL;
   const vpx_codec_cx_pkt_t *pkt = NULL;
-  const vpx_codec_err_t res = vpx_codec_encode(ctx, img, pts, duration, flags,
-                                               deadline);
-  if (res != VPX_CODEC_OK)
-    die_codec(ctx, "Failed to get frame stats.");
+  const vpx_codec_err_t res =
+      vpx_codec_encode(ctx, img, pts, duration, flags, deadline);
+  if (res != VPX_CODEC_OK) die_codec(ctx, "Failed to get frame stats.");
 
   while ((pkt = vpx_codec_get_cx_data(ctx, &iter)) != NULL) {
     got_pkts = 1;
@@ -94,20 +90,16 @@ static int get_frame_stats(vpx_codec_ctx_t *ctx,
   return got_pkts;
 }
 
-static int encode_frame(vpx_codec_ctx_t *ctx,
-                        const vpx_image_t *img,
-                        vpx_codec_pts_t pts,
-                        unsigned int duration,
-                        vpx_enc_frame_flags_t flags,
-                        unsigned int deadline,
+static int encode_frame(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
+                        vpx_codec_pts_t pts, unsigned int duration,
+                        vpx_enc_frame_flags_t flags, unsigned int deadline,
                         VpxVideoWriter *writer) {
   int got_pkts = 0;
   vpx_codec_iter_t iter = NULL;
   const vpx_codec_cx_pkt_t *pkt = NULL;
-  const vpx_codec_err_t res = vpx_codec_encode(ctx, img, pts, duration, flags,
-                                               deadline);
-  if (res != VPX_CODEC_OK)
-    die_codec(ctx, "Failed to encode frame.");
+  const vpx_codec_err_t res =
+      vpx_codec_encode(ctx, img, pts, duration, flags, deadline);
+  if (res != VPX_CODEC_OK) die_codec(ctx, "Failed to encode frame.");
 
   while ((pkt = vpx_codec_get_cx_data(ctx, &iter)) != NULL) {
     got_pkts = 1;
@@ -115,8 +107,8 @@ static int encode_frame(vpx_codec_ctx_t *ctx,
       const int keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
 
       if (!vpx_video_writer_write_frame(writer, pkt->data.frame.buf,
-                                                pkt->data.frame.sz,
-                                                pkt->data.frame.pts))
+                                        pkt->data.frame.sz,
+                                        pkt->data.frame.pts))
         die_codec(ctx, "Failed to write compressed frame.");
       printf(keyframe ? "K" : ".");
       fflush(stdout);
@@ -126,13 +118,12 @@ static int encode_frame(vpx_codec_ctx_t *ctx,
   return got_pkts;
 }
 
-static vpx_fixed_buf_t pass0(vpx_image_t *raw,
-                             FILE *infile,
+static vpx_fixed_buf_t pass0(vpx_image_t *raw, FILE *infile,
                              const VpxInterface *encoder,
                              const vpx_codec_enc_cfg_t *cfg) {
   vpx_codec_ctx_t codec;
   int frame_count = 0;
-  vpx_fixed_buf_t stats = {NULL, 0};
+  vpx_fixed_buf_t stats = { NULL, 0 };
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))
     die_codec(&codec, "Failed to initialize encoder");
@@ -145,34 +136,28 @@ static vpx_fixed_buf_t pass0(vpx_image_t *raw,
   }
 
   // Flush encoder.
-  while (get_frame_stats(&codec, NULL, frame_count, 1, 0,
-                         VPX_DL_GOOD_QUALITY, &stats)) {}
+  while (get_frame_stats(&codec, NULL, frame_count, 1, 0, VPX_DL_GOOD_QUALITY,
+                         &stats)) {
+  }
 
   printf("Pass 0 complete. Processed %d frames.\n", frame_count);
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec.");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
 
   return stats;
 }
 
-static void pass1(vpx_image_t *raw,
-                  FILE *infile,
-                  const char *outfile_name,
-                  const VpxInterface *encoder,
-                  const vpx_codec_enc_cfg_t *cfg) {
-  VpxVideoInfo info = {
-    encoder->fourcc,
-    cfg->g_w,
-    cfg->g_h,
-    {cfg->g_timebase.num, cfg->g_timebase.den}
-  };
+static void pass1(vpx_image_t *raw, FILE *infile, const char *outfile_name,
+                  const VpxInterface *encoder, const vpx_codec_enc_cfg_t *cfg) {
+  VpxVideoInfo info = { encoder->fourcc,
+                        cfg->g_w,
+                        cfg->g_h,
+                        { cfg->g_timebase.num, cfg->g_timebase.den } };
   VpxVideoWriter *writer = NULL;
   vpx_codec_ctx_t codec;
   int frame_count = 0;
 
   writer = vpx_video_writer_open(outfile_name, kContainerIVF, &info);
-  if (!writer)
-    die("Failed to open %s for writing", outfile_name);
+  if (!writer) die("Failed to open %s for writing", outfile_name);
 
   if (vpx_codec_enc_init(&codec, encoder->codec_interface(), cfg, 0))
     die_codec(&codec, "Failed to initialize encoder");
@@ -184,12 +169,12 @@ static void pass1(vpx_image_t *raw,
   }
 
   // Flush encoder.
-  while (encode_frame(&codec, NULL, -1, 1, 0, VPX_DL_GOOD_QUALITY, writer)) {}
+  while (encode_frame(&codec, NULL, -1, 1, 0, VPX_DL_GOOD_QUALITY, writer)) {
+  }
 
   printf("\n");
 
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec.");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec.");
 
   vpx_video_writer_close(writer);
 
@@ -206,8 +191,8 @@ int main(int argc, char **argv) {
   vpx_fixed_buf_t stats;
 
   const VpxInterface *encoder = NULL;
-  const int fps = 30;        // TODO(dkovalev) add command line argument
-  const int bitrate = 200;   // kbit/s TODO(dkovalev) add command line argument
+  const int fps = 30;       // TODO(dkovalev) add command line argument
+  const int bitrate = 200;  // kbit/s TODO(dkovalev) add command line argument
   const char *const codec_arg = argv[1];
   const char *const width_arg = argv[2];
   const char *const height_arg = argv[3];
@@ -215,17 +200,15 @@ int main(int argc, char **argv) {
   const char *const outfile_arg = argv[5];
   exec_name = argv[0];
 
-  if (argc != 6)
-    die("Invalid number of arguments.");
+  if (argc != 6) die("Invalid number of arguments.");
 
   encoder = get_vpx_encoder_by_name(codec_arg);
-  if (!encoder)
-    die("Unsupported codec.");
+  if (!encoder) die("Unsupported codec.");
 
   w = strtol(width_arg, NULL, 0);
   h = strtol(height_arg, NULL, 0);
 
-  if (w  <= 0 || h <= 0 || (w % 2) != 0 || (h  % 2) != 0)
+  if (w <= 0 || h <= 0 || (w % 2) != 0 || (h % 2) != 0)
     die("Invalid frame size: %dx%d", w, h);
 
   if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, w, h, 1))
@@ -235,8 +218,7 @@ int main(int argc, char **argv) {
 
   // Configuration
   res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
-  if (res)
-    die_codec(&codec, "Failed to get default codec config.");
+  if (res) die_codec(&codec, "Failed to get default codec config.");
 
   cfg.g_w = w;
   cfg.g_h = h;
diff --git a/examples/vpx_temporal_svc_encoder.c b/examples/vpx_temporal_svc_encoder.c
index 33b0038cff0d6371cd7369efb10788a548552730..68b2f713b414b44cee5f74e357cbcfa124716a4d 100644
--- a/examples/vpx_temporal_svc_encoder.c
+++ b/examples/vpx_temporal_svc_encoder.c
@@ -28,9 +28,7 @@
 
 static const char *exec_name;
 
-void usage_exit(void) {
-  exit(EXIT_FAILURE);
-}
+void usage_exit(void) { exit(EXIT_FAILURE); }
 
 // Denoiser states, for temporal denoising.
 enum denoiserState {
@@ -41,7 +39,7 @@ enum denoiserState {
   kDenoiserOnAdaptive
 };
 
-static int mode_to_num_layers[12] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3};
+static int mode_to_num_layers[12] = { 1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3 };
 
 // For rate control encoding stats.
 struct RateControlMetrics {
@@ -86,14 +84,14 @@ static void set_rate_control_metrics(struct RateControlMetrics *rc,
   // per-frame-bandwidth, for the rate control encoding stats below.
   const double framerate = cfg->g_timebase.den / cfg->g_timebase.num;
   rc->layer_framerate[0] = framerate / cfg->ts_rate_decimator[0];
-  rc->layer_pfb[0] = 1000.0 * rc->layer_target_bitrate[0] /
-      rc->layer_framerate[0];
+  rc->layer_pfb[0] =
+      1000.0 * rc->layer_target_bitrate[0] / rc->layer_framerate[0];
   for (i = 0; i < cfg->ts_number_layers; ++i) {
     if (i > 0) {
       rc->layer_framerate[i] = framerate / cfg->ts_rate_decimator[i];
-      rc->layer_pfb[i] = 1000.0 *
-          (rc->layer_target_bitrate[i] - rc->layer_target_bitrate[i - 1]) /
-          (rc->layer_framerate[i] - rc->layer_framerate[i - 1]);
+      rc->layer_pfb[i] = 1000.0 * (rc->layer_target_bitrate[i] -
+                                   rc->layer_target_bitrate[i - 1]) /
+                         (rc->layer_framerate[i] - rc->layer_framerate[i - 1]);
     }
     rc->layer_input_frames[i] = 0;
     rc->layer_enc_frames[i] = 0;
@@ -114,29 +112,31 @@ static void printout_rate_control_summary(struct RateControlMetrics *rc,
   unsigned int i = 0;
   int tot_num_frames = 0;
   double perc_fluctuation = 0.0;
-  printf("Total number of processed frames: %d\n\n", frame_cnt -1);
+  printf("Total number of processed frames: %d\n\n", frame_cnt - 1);
   printf("Rate control layer stats for %d layer(s):\n\n",
-      cfg->ts_number_layers);
+         cfg->ts_number_layers);
   for (i = 0; i < cfg->ts_number_layers; ++i) {
-    const int num_dropped = (i > 0) ?
-        (rc->layer_input_frames[i] - rc->layer_enc_frames[i]) :
-        (rc->layer_input_frames[i] - rc->layer_enc_frames[i] - 1);
+    const int num_dropped =
+        (i > 0) ? (rc->layer_input_frames[i] - rc->layer_enc_frames[i])
+                : (rc->layer_input_frames[i] - rc->layer_enc_frames[i] - 1);
     tot_num_frames += rc->layer_input_frames[i];
     rc->layer_encoding_bitrate[i] = 0.001 * rc->layer_framerate[i] *
-        rc->layer_encoding_bitrate[i] / tot_num_frames;
-    rc->layer_avg_frame_size[i] = rc->layer_avg_frame_size[i] /
-        rc->layer_enc_frames[i];
-    rc->layer_avg_rate_mismatch[i] = 100.0 * rc->layer_avg_rate_mismatch[i] /
-        rc->layer_enc_frames[i];
+                                    rc->layer_encoding_bitrate[i] /
+                                    tot_num_frames;
+    rc->layer_avg_frame_size[i] =
+        rc->layer_avg_frame_size[i] / rc->layer_enc_frames[i];
+    rc->layer_avg_rate_mismatch[i] =
+        100.0 * rc->layer_avg_rate_mismatch[i] / rc->layer_enc_frames[i];
     printf("For layer#: %d \n", i);
     printf("Bitrate (target vs actual): %d %f \n", rc->layer_target_bitrate[i],
            rc->layer_encoding_bitrate[i]);
     printf("Average frame size (target vs actual): %f %f \n", rc->layer_pfb[i],
            rc->layer_avg_frame_size[i]);
     printf("Average rate_mismatch: %f \n", rc->layer_avg_rate_mismatch[i]);
-    printf("Number of input frames, encoded (non-key) frames, "
-        "and perc dropped frames: %d %d %f \n", rc->layer_input_frames[i],
-        rc->layer_enc_frames[i],
+    printf(
+        "Number of input frames, encoded (non-key) frames, "
+        "and perc dropped frames: %d %d %f \n",
+        rc->layer_input_frames[i], rc->layer_enc_frames[i],
         100.0 * num_dropped / rc->layer_input_frames[i]);
     printf("\n");
   }
@@ -145,11 +145,10 @@ static void printout_rate_control_summary(struct RateControlMetrics *rc,
       rc->variance_st_encoding_bitrate / rc->window_count -
       (rc->avg_st_encoding_bitrate * rc->avg_st_encoding_bitrate);
   perc_fluctuation = 100.0 * sqrt(rc->variance_st_encoding_bitrate) /
-      rc->avg_st_encoding_bitrate;
-  printf("Short-time stats, for window of %d frames: \n",rc->window_size);
+                     rc->avg_st_encoding_bitrate;
+  printf("Short-time stats, for window of %d frames: \n", rc->window_size);
   printf("Average, rms-variance, and percent-fluct: %f %f %f \n",
-         rc->avg_st_encoding_bitrate,
-         sqrt(rc->variance_st_encoding_bitrate),
+         rc->avg_st_encoding_bitrate, sqrt(rc->variance_st_encoding_bitrate),
          perc_fluctuation);
   if ((frame_cnt - 1) != tot_num_frames)
     die("Error: Number of input frames not equal to output! \n");
@@ -167,20 +166,20 @@ static void set_temporal_layer_pattern(int layering_mode,
   switch (layering_mode) {
     case 0: {
       // 1-layer.
-      int ids[1] = {0};
+      int ids[1] = { 0 };
       cfg->ts_periodicity = 1;
       *flag_periodicity = 1;
       cfg->ts_number_layers = 1;
       cfg->ts_rate_decimator[0] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // Update L only.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_UPD_GF |
-          VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[0] =
+          VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
       break;
     }
     case 1: {
       // 2-layers, 2-frame period.
-      int ids[2] = {0, 1};
+      int ids[2] = { 0, 1 };
       cfg->ts_periodicity = 2;
       *flag_periodicity = 2;
       cfg->ts_number_layers = 2;
@@ -189,22 +188,24 @@ static void set_temporal_layer_pattern(int layering_mode,
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
 #if 1
       // 0=L, 1=GF, Intra-layer prediction enabled.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_UPD_GF |
-          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
-      layer_flags[1] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_REF_ARF;
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF;
+      layer_flags[1] =
+          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_REF_ARF;
 #else
-       // 0=L, 1=GF, Intra-layer prediction disabled.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_UPD_GF |
-          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
+      // 0=L, 1=GF, Intra-layer prediction disabled.
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF;
       layer_flags[1] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_LAST;
+                       VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_LAST;
 #endif
       break;
     }
     case 2: {
       // 2-layers, 3-frame period.
-      int ids[3] = {0, 1, 1};
+      int ids[3] = { 0, 1, 1 };
       cfg->ts_periodicity = 3;
       *flag_periodicity = 3;
       cfg->ts_number_layers = 2;
@@ -212,16 +213,17 @@ static void set_temporal_layer_pattern(int layering_mode,
       cfg->ts_rate_decimator[1] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, Intra-layer prediction enabled.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_REF_GF |
-          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[1] =
-      layer_flags[2] = VP8_EFLAG_NO_REF_GF  | VP8_EFLAG_NO_REF_ARF |
-          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[1] = layer_flags[2] =
+          VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF |
+          VP8_EFLAG_NO_UPD_LAST;
       break;
     }
     case 3: {
       // 3-layers, 6-frame period.
-      int ids[6] = {0, 2, 2, 1, 2, 2};
+      int ids[6] = { 0, 2, 2, 1, 2, 2 };
       cfg->ts_periodicity = 6;
       *flag_periodicity = 6;
       cfg->ts_number_layers = 3;
@@ -230,19 +232,18 @@ static void set_temporal_layer_pattern(int layering_mode,
       cfg->ts_rate_decimator[2] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_REF_GF |
-          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[3] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF |
-          VP8_EFLAG_NO_UPD_LAST;
-      layer_flags[1] =
-      layer_flags[2] =
-      layer_flags[4] =
-      layer_flags[5] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST;
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[3] =
+          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
+      layer_flags[1] = layer_flags[2] = layer_flags[4] = layer_flags[5] =
+          VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST;
       break;
     }
     case 4: {
       // 3-layers, 4-frame period.
-      int ids[4] = {0, 2, 1, 2};
+      int ids[4] = { 0, 2, 1, 2 };
       cfg->ts_periodicity = 4;
       *flag_periodicity = 4;
       cfg->ts_number_layers = 3;
@@ -251,39 +252,41 @@ static void set_temporal_layer_pattern(int layering_mode,
       cfg->ts_rate_decimator[2] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, 2=ARF, Intra-layer prediction disabled.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_REF_GF |
-          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF;
       layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
-          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
-      layer_flags[1] =
-      layer_flags[3] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
+                       VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
+      layer_flags[1] = layer_flags[3] =
+          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
+          VP8_EFLAG_NO_UPD_ARF;
       break;
     }
     case 5: {
       // 3-layers, 4-frame period.
-      int ids[4] = {0, 2, 1, 2};
+      int ids[4] = { 0, 2, 1, 2 };
       cfg->ts_periodicity = 4;
       *flag_periodicity = 4;
-      cfg->ts_number_layers     = 3;
+      cfg->ts_number_layers = 3;
       cfg->ts_rate_decimator[0] = 4;
       cfg->ts_rate_decimator[1] = 2;
       cfg->ts_rate_decimator[2] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled in layer 1, disabled
       // in layer 2.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_REF_GF |
-          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[2] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[2] =
+          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[1] = layer_flags[3] =
+          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
           VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[1] =
-      layer_flags[3] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
       break;
     }
     case 6: {
       // 3-layers, 4-frame period.
-      int ids[4] = {0, 2, 1, 2};
+      int ids[4] = { 0, 2, 1, 2 };
       cfg->ts_periodicity = 4;
       *flag_periodicity = 4;
       cfg->ts_number_layers = 3;
@@ -292,18 +295,19 @@ static void set_temporal_layer_pattern(int layering_mode,
       cfg->ts_rate_decimator[2] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_REF_GF |
-          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[2] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[1] =
-      layer_flags[3] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[2] =
+          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[1] = layer_flags[3] =
+          VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
       break;
     }
     case 7: {
       // NOTE: Probably of academic interest only.
       // 5-layers, 16-frame period.
-      int ids[16] = {0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4};
+      int ids[16] = { 0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4 };
       cfg->ts_periodicity = 16;
       *flag_periodicity = 16;
       cfg->ts_number_layers = 5;
@@ -313,28 +317,21 @@ static void set_temporal_layer_pattern(int layering_mode,
       cfg->ts_rate_decimator[3] = 2;
       cfg->ts_rate_decimator[4] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
-      layer_flags[0]  = VPX_EFLAG_FORCE_KF;
-      layer_flags[1]  =
-      layer_flags[3]  =
-      layer_flags[5]  =
-      layer_flags[7]  =
-      layer_flags[9]  =
-      layer_flags[11] =
-      layer_flags[13] =
-      layer_flags[15] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
-          VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[2]  =
-      layer_flags[6]  =
-      layer_flags[10] =
-      layer_flags[14] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF;
-      layer_flags[4] =
-      layer_flags[12] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[8]  = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF;
+      layer_flags[0] = VPX_EFLAG_FORCE_KF;
+      layer_flags[1] = layer_flags[3] = layer_flags[5] = layer_flags[7] =
+          layer_flags[9] = layer_flags[11] = layer_flags[13] = layer_flags[15] =
+              VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
+              VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[2] = layer_flags[6] = layer_flags[10] = layer_flags[14] =
+          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF;
+      layer_flags[4] = layer_flags[12] =
+          VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[8] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF;
       break;
     }
     case 8: {
       // 2-layers, with sync point at first frame of layer 1.
-      int ids[2] = {0, 1};
+      int ids[2] = { 0, 1 };
       cfg->ts_periodicity = 2;
       *flag_periodicity = 8;
       cfg->ts_number_layers = 2;
@@ -346,17 +343,17 @@ static void set_temporal_layer_pattern(int layering_mode,
       // key frame. Sync point every 8 frames.
 
       // Layer 0: predict from L and ARF, update L and G.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_REF_GF |
-          VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[0] =
+          VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_ARF;
       // Layer 1: sync point: predict from L and ARF, and update G.
-      layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[1] =
+          VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ARF;
       // Layer 0, predict from L and ARF, update L.
-      layer_flags[2] = VP8_EFLAG_NO_REF_GF  | VP8_EFLAG_NO_UPD_GF |
-          VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[2] =
+          VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
       // Layer 1: predict from L, G and ARF, and update G.
       layer_flags[3] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_UPD_ENTROPY;
+                       VP8_EFLAG_NO_UPD_ENTROPY;
       // Layer 0.
       layer_flags[4] = layer_flags[2];
       // Layer 1.
@@ -365,11 +362,11 @@ static void set_temporal_layer_pattern(int layering_mode,
       layer_flags[6] = layer_flags[4];
       // Layer 1.
       layer_flags[7] = layer_flags[5];
-     break;
+      break;
     }
     case 9: {
       // 3-layers: Sync points for layer 1 and 2 every 8 frames.
-      int ids[4] = {0, 2, 1, 2};
+      int ids[4] = { 0, 2, 1, 2 };
       cfg->ts_periodicity = 4;
       *flag_periodicity = 8;
       cfg->ts_number_layers = 3;
@@ -378,20 +375,21 @@ static void set_temporal_layer_pattern(int layering_mode,
       cfg->ts_rate_decimator[2] = 1;
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, 2=ARF.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF  | VP8_EFLAG_NO_REF_GF |
-          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
+                       VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF |
+                       VP8_EFLAG_NO_UPD_ARF;
       layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
+                       VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
+      layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
+                       VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[3] = layer_flags[5] =
           VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
-      layer_flags[2] = VP8_EFLAG_NO_REF_GF   | VP8_EFLAG_NO_REF_ARF |
-          VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[3] =
-      layer_flags[5] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
       layer_flags[4] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
-          VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
-      layer_flags[6] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_UPD_ARF;
+                       VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
+      layer_flags[6] =
+          VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ARF;
       layer_flags[7] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
-          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_ENTROPY;
+                       VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_ENTROPY;
       break;
     }
     case 10: {
@@ -399,7 +397,7 @@ static void set_temporal_layer_pattern(int layering_mode,
       // and is only updated on key frame.
       // Sync points for layer 1 and 2 every 8 frames.
 
-      int ids[4] = {0, 2, 1, 2};
+      int ids[4] = { 0, 2, 1, 2 };
       cfg->ts_periodicity = 4;
       *flag_periodicity = 8;
       cfg->ts_number_layers = 3;
@@ -409,21 +407,21 @@ static void set_temporal_layer_pattern(int layering_mode,
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, 2=ARF.
       // Layer 0: predict from L and ARF; update L and G.
-      layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_ARF |
-          VP8_EFLAG_NO_REF_GF;
+      layer_flags[0] =
+          VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF;
       // Layer 2: sync point: predict from L and ARF; update none.
       layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
-          VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
-          VP8_EFLAG_NO_UPD_ENTROPY;
+                       VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
+                       VP8_EFLAG_NO_UPD_ENTROPY;
       // Layer 1: sync point: predict from L and ARF; update G.
-      layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_ARF |
-          VP8_EFLAG_NO_UPD_LAST;
+      layer_flags[2] =
+          VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
       // Layer 2: predict from L, G, ARF; update none.
       layer_flags[3] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
-          VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ENTROPY;
+                       VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ENTROPY;
       // Layer 0: predict from L and ARF; update L.
-      layer_flags[4] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
-          VP8_EFLAG_NO_REF_GF;
+      layer_flags[4] =
+          VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF;
       // Layer 2: predict from L, G, ARF; update none.
       layer_flags[5] = layer_flags[3];
       // Layer 1: predict from L, G, ARF; update G.
@@ -436,7 +434,7 @@ static void set_temporal_layer_pattern(int layering_mode,
     default: {
       // 3-layers structure as in case 10, but no sync/refresh points for
       // layer 1 and 2.
-      int ids[4] = {0, 2, 1, 2};
+      int ids[4] = { 0, 2, 1, 2 };
       cfg->ts_periodicity = 4;
       *flag_periodicity = 8;
       cfg->ts_number_layers = 3;
@@ -446,15 +444,15 @@ static void set_temporal_layer_pattern(int layering_mode,
       memcpy(cfg->ts_layer_id, ids, sizeof(ids));
       // 0=L, 1=GF, 2=ARF.
       // Layer 0: predict from L and ARF; update L.
-      layer_flags[0] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
-          VP8_EFLAG_NO_REF_GF;
+      layer_flags[0] =
+          VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF;
       layer_flags[4] = layer_flags[0];
       // Layer 1: predict from L, G, ARF; update G.
       layer_flags[2] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
       layer_flags[6] = layer_flags[2];
       // Layer 2: predict from L, G, ARF; update none.
       layer_flags[1] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
-          VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ENTROPY;
+                       VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ENTROPY;
       layer_flags[3] = layer_flags[1];
       layer_flags[5] = layer_flags[1];
       layer_flags[7] = layer_flags[1];
@@ -464,7 +462,7 @@ static void set_temporal_layer_pattern(int layering_mode,
 }
 
 int main(int argc, char **argv) {
-  VpxVideoWriter *outfile[VPX_TS_MAX_LAYERS] = {NULL};
+  VpxVideoWriter *outfile[VPX_TS_MAX_LAYERS] = { NULL };
   vpx_codec_ctx_t codec;
   vpx_codec_enc_cfg_t cfg;
   int frame_cnt = 0;
@@ -477,15 +475,15 @@ int main(int argc, char **argv) {
   int got_data;
   int flags = 0;
   unsigned int i;
-  int pts = 0;  // PTS starts at 0.
+  int pts = 0;             // PTS starts at 0.
   int frame_duration = 1;  // 1 timebase tick per frame.
   int layering_mode = 0;
-  int layer_flags[VPX_TS_MAX_PERIODICITY] = {0};
+  int layer_flags[VPX_TS_MAX_PERIODICITY] = { 0 };
   int flag_periodicity = 1;
 #if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
-  vpx_svc_layer_id_t layer_id = {0, 0};
+  vpx_svc_layer_id_t layer_id = { 0, 0 };
 #else
-  vpx_svc_layer_id_t layer_id = {0};
+  vpx_svc_layer_id_t layer_id = { 0 };
 #endif
   const VpxInterface *encoder = NULL;
   FILE *infile = NULL;
@@ -501,25 +499,28 @@ int main(int argc, char **argv) {
 #endif  // CONFIG_VPX_HIGHBITDEPTH
   double sum_bitrate = 0.0;
   double sum_bitrate2 = 0.0;
-  double framerate  = 30.0;
+  double framerate = 30.0;
 
   exec_name = argv[0];
   // Check usage and arguments.
   if (argc < min_args) {
 #if CONFIG_VPX_HIGHBITDEPTH
-    die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
+    die(
+        "Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
         "<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> "
-        "<Rate_0> ... <Rate_nlayers-1> <bit-depth> \n", argv[0]);
+        "<Rate_0> ... <Rate_nlayers-1> <bit-depth> \n",
+        argv[0]);
 #else
-    die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
+    die(
+        "Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
         "<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> "
-        "<Rate_0> ... <Rate_nlayers-1> \n", argv[0]);
+        "<Rate_0> ... <Rate_nlayers-1> \n",
+        argv[0]);
 #endif  // CONFIG_VPX_HIGHBITDEPTH
   }
 
   encoder = get_vpx_encoder_by_name(argv[3]);
-  if (!encoder)
-    die("Unsupported codec.");
+  if (!encoder) die("Unsupported codec.");
 
   printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
 
@@ -539,7 +540,7 @@ int main(int argc, char **argv) {
   }
 
 #if CONFIG_VPX_HIGHBITDEPTH
-  switch (strtol(argv[argc-1], NULL, 0)) {
+  switch (strtol(argv[argc - 1], NULL, 0)) {
     case 8:
       bit_depth = VPX_BITS_8;
       input_bit_depth = 8;
@@ -552,13 +553,11 @@ int main(int argc, char **argv) {
       bit_depth = VPX_BITS_12;
       input_bit_depth = 12;
       break;
-    default:
-      die("Invalid bit depth (8, 10, 12) %s", argv[argc-1]);
+    default: die("Invalid bit depth (8, 10, 12) %s", argv[argc - 1]);
   }
-  if (!vpx_img_alloc(&raw,
-                     bit_depth == VPX_BITS_8 ? VPX_IMG_FMT_I420 :
-                                               VPX_IMG_FMT_I42016,
-                     width, height, 32)) {
+  if (!vpx_img_alloc(
+          &raw, bit_depth == VPX_BITS_8 ? VPX_IMG_FMT_I420 : VPX_IMG_FMT_I42016,
+          width, height, 32)) {
     die("Failed to allocate image", width, height);
   }
 #else
@@ -596,8 +595,7 @@ int main(int argc, char **argv) {
   }
 
   for (i = min_args_base;
-       (int)i < min_args_base + mode_to_num_layers[layering_mode];
-       ++i) {
+       (int)i < min_args_base + mode_to_num_layers[layering_mode]; ++i) {
     rc.layer_target_bitrate[i - 11] = strtol(argv[i], NULL, 0);
     if (strncmp(encoder->name, "vp8", 3) == 0)
       cfg.ts_target_bitrate[i - 11] = rc.layer_target_bitrate[i - 11];
@@ -610,8 +608,7 @@ int main(int argc, char **argv) {
   cfg.rc_end_usage = VPX_CBR;
   cfg.rc_min_quantizer = 2;
   cfg.rc_max_quantizer = 56;
-  if (strncmp(encoder->name, "vp9", 3) == 0)
-    cfg.rc_max_quantizer = 52;
+  if (strncmp(encoder->name, "vp9", 3) == 0) cfg.rc_max_quantizer = 52;
   cfg.rc_undershoot_pct = 50;
   cfg.rc_overshoot_pct = 50;
   cfg.rc_buf_initial_sz = 500;
@@ -626,7 +623,7 @@ int main(int argc, char **argv) {
 
   // Enable error resilient mode.
   cfg.g_error_resilient = 1;
-  cfg.g_lag_in_frames   = 0;
+  cfg.g_lag_in_frames = 0;
   cfg.kf_mode = VPX_KF_AUTO;
 
   // Disable automatic keyframe placement.
@@ -634,9 +631,7 @@ int main(int argc, char **argv) {
 
   cfg.temporal_layering_mode = VP9E_TEMPORAL_LAYERING_MODE_BYPASS;
 
-  set_temporal_layer_pattern(layering_mode,
-                             &cfg,
-                             layer_flags,
+  set_temporal_layer_pattern(layering_mode, &cfg, layer_flags,
                              &flag_periodicity);
 
   set_rate_control_metrics(&rc, &cfg);
@@ -663,15 +658,14 @@ int main(int argc, char **argv) {
 
     snprintf(file_name, sizeof(file_name), "%s_%d.ivf", argv[2], i);
     outfile[i] = vpx_video_writer_open(file_name, kContainerIVF, &info);
-    if (!outfile[i])
-      die("Failed to open %s for writing", file_name);
+    if (!outfile[i]) die("Failed to open %s for writing", file_name);
 
     assert(outfile[i] != NULL);
   }
   // No spatial layers in this encoder.
   cfg.ss_number_layers = 1;
 
-  // Initialize codec.
+// Initialize codec.
 #if CONFIG_VPX_HIGHBITDEPTH
   if (vpx_codec_enc_init(
           &codec, encoder->codec_interface(), &cfg,
@@ -694,7 +688,7 @@ int main(int argc, char **argv) {
     vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 1);
     vpx_codec_control(&codec, VP9E_SET_TUNE_CONTENT, 0);
     vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, (cfg.g_threads >> 1));
-    if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1: 0))
+    if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1 : 0))
       die_codec(&codec, "Failed to set SVC");
     for (i = 0; i < cfg.ts_number_layers; ++i) {
       svc_params.max_quantizers[i] = cfg.rc_max_quantizer;
@@ -735,14 +729,12 @@ int main(int argc, char **argv) {
                         layer_id.temporal_layer_id);
     }
     flags = layer_flags[frame_cnt % flag_periodicity];
-    if (layering_mode == 0)
-      flags = 0;
+    if (layering_mode == 0) flags = 0;
     frame_avail = vpx_img_read(&raw, infile);
-    if (frame_avail)
-      ++rc.layer_input_frames[layer_id.temporal_layer_id];
+    if (frame_avail) ++rc.layer_input_frames[layer_id.temporal_layer_id];
     vpx_usec_timer_start(&timer);
-    if (vpx_codec_encode(&codec, frame_avail? &raw : NULL, pts, 1, flags,
-        VPX_DL_REALTIME)) {
+    if (vpx_codec_encode(&codec, frame_avail ? &raw : NULL, pts, 1, flags,
+                         VPX_DL_REALTIME)) {
       die_codec(&codec, "Failed to encode frame");
     }
     vpx_usec_timer_mark(&timer);
@@ -752,12 +744,12 @@ int main(int argc, char **argv) {
       layer_flags[0] &= ~VPX_EFLAG_FORCE_KF;
     }
     got_data = 0;
-    while ( (pkt = vpx_codec_get_cx_data(&codec, &iter)) ) {
+    while ((pkt = vpx_codec_get_cx_data(&codec, &iter))) {
       got_data = 1;
       switch (pkt->kind) {
         case VPX_CODEC_CX_FRAME_PKT:
           for (i = cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity];
-              i < cfg.ts_number_layers; ++i) {
+               i < cfg.ts_number_layers; ++i) {
             vpx_video_writer_write_frame(outfile[i], pkt->data.frame.buf,
                                          pkt->data.frame.sz, pts);
             ++rc.layer_tot_enc_frames[i];
@@ -800,8 +792,7 @@ int main(int argc, char **argv) {
             }
           }
           break;
-          default:
-            break;
+        default: break;
       }
     }
     ++frame_cnt;
@@ -811,16 +802,13 @@ int main(int argc, char **argv) {
   printout_rate_control_summary(&rc, &cfg, frame_cnt);
   printf("\n");
   printf("Frame cnt and encoding time/FPS stats for encoding: %d %f %f \n",
-          frame_cnt,
-          1000 * (float)cx_time / (double)(frame_cnt * 1000000),
-          1000000 * (double)frame_cnt / (double)cx_time);
+         frame_cnt, 1000 * (float)cx_time / (double)(frame_cnt * 1000000),
+         1000000 * (double)frame_cnt / (double)cx_time);
 
-  if (vpx_codec_destroy(&codec))
-    die_codec(&codec, "Failed to destroy codec");
+  if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec");
 
   // Try to rewrite the output file headers with the actual frame count.
-  for (i = 0; i < cfg.ts_number_layers; ++i)
-    vpx_video_writer_close(outfile[i]);
+  for (i = 0; i < cfg.ts_number_layers; ++i) vpx_video_writer_close(outfile[i]);
 
   vpx_img_free(&raw);
   return EXIT_SUCCESS;