]> granicus.if.org Git - libvpx/commitdiff
Remove duplication on vp8/9_write_yuv_frame.
authorJerome Jiang <jianj@google.com>
Thu, 8 Jun 2017 23:07:02 +0000 (16:07 -0700)
committerJerome Jiang <jianj@google.com>
Sat, 10 Jun 2017 00:08:26 +0000 (17:08 -0700)
Change-Id: Ib3546032a27c715bf509c0e24d26a189bc829da8

vp8/common/skin_detection.c
vp8/common/skin_detection.h
vp8/encoder/onyx_if.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_skin_detection.c
vp9/encoder/vp9_skin_detection.h
vpx_util/vpx_util.mk
vpx_util/vpx_write_yuv_frame.c [new file with mode: 0644]
vpx_util/vpx_write_yuv_frame.h [new file with mode: 0644]

index ed8f983a8a1d3205ce397747576f4935b00be09e..fbf87651eef1f3c54a557aa50d2759e76eee233b 100644 (file)
@@ -12,6 +12,7 @@
 #include "vp8/common/alloccommon.h"
 #include "vpx_dsp/vpx_dsp_common.h"
 #include "vpx_mem/vpx_mem.h"
+#include "vpx_util/vpx_write_yuv_frame.h"
 
 int compute_skin_block(const uint8_t *y, const uint8_t *u, const uint8_t *v,
                        int stride, int strideuv, int consec_zeromv,
@@ -94,7 +95,7 @@ void compute_skin_map(VP8_COMP *const cpi, FILE *yuv_skinmap_file) {
     src_u += (src_uvstride << 3) - (num_bl << 3);
     src_v += (src_uvstride << 3) - (num_bl << 3);
   }
-  vp8_write_yuv_frame(yuv_skinmap_file, &skinmap);
+  vpx_write_yuv_frame(yuv_skinmap_file, &skinmap);
   vpx_free_frame_buffer(&skinmap);
 }
 #endif  // OUTPUT_YUV_SKINMAP
index 1fe233212d1dc2806202957cabfe8b84ddfee0d5..1d72eeb02a3291d8412aae9ed699a4aa483830cd 100644 (file)
@@ -29,7 +29,6 @@ int compute_skin_block(const uint8_t *y, const uint8_t *u, const uint8_t *v,
 #ifdef OUTPUT_YUV_SKINMAP
 // For viewing skin map on input source.
 void compute_skin_map(struct VP8_COMP *const cpi, FILE *yuv_skinmap_file);
-extern void vp8_write_yuv_frame(FILE *f, YV12_BUFFER_CONFIG *s);
 #endif
 
 #ifdef __cplusplus
index 9a9f3d1f8f5c3ab95a81cce8927b20eaab391df9..d5a53494660c6b1c64a71a031104b00baa782edf 100644 (file)
@@ -2484,35 +2484,6 @@ int vp8_update_entropy(VP8_COMP *cpi, int update) {
   return 0;
 }
 
-#if defined(OUTPUT_YUV_SRC) || defined(OUTPUT_YUV_DENOISED) || \
-    defined(OUTPUT_YUV_SKINMAP)
-void vp8_write_yuv_frame(FILE *yuv_file, YV12_BUFFER_CONFIG *s) {
-  unsigned char *src = s->y_buffer;
-  int h = s->y_crop_height;
-
-  do {
-    fwrite(src, s->y_width, 1, yuv_file);
-    src += s->y_stride;
-  } while (--h);
-
-  src = s->u_buffer;
-  h = s->uv_crop_height;
-
-  do {
-    fwrite(src, s->uv_width, 1, yuv_file);
-    src += s->uv_stride;
-  } while (--h);
-
-  src = s->v_buffer;
-  h = s->uv_crop_height;
-
-  do {
-    fwrite(src, s->uv_width, 1, yuv_file);
-    src += s->uv_stride;
-  } while (--h);
-}
-#endif
-
 static void scale_and_extend_source(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) {
   VP8_COMMON *cm = &cpi->common;
 
index c7793488f9fca2a2edd81bcd79b85502d6086e0b..bf33168e748e4420bf97f8d4b767437d927ce290 100644 (file)
@@ -2581,39 +2581,6 @@ int vp9_update_entropy(VP9_COMP *cpi, int update) {
   return 0;
 }
 
-#if defined(OUTPUT_YUV_DENOISED) || defined(OUTPUT_YUV_SKINMAP)
-// The denoiser buffer is allocated as a YUV 440 buffer. This function writes it
-// as YUV 420. We simply use the top-left pixels of the UV buffers, since we do
-// not denoise the UV channels at this time. If ever we implement UV channel
-// denoising we will have to modify this.
-// TODO(jianj): Remove the duplicated one in vp8 and move it to vpx_util.
-void vp9_write_yuv_frame_420(YV12_BUFFER_CONFIG *s, FILE *f) {
-  uint8_t *src = s->y_buffer;
-  int h = s->y_crop_height;
-
-  do {
-    fwrite(src, s->y_width, 1, f);
-    src += s->y_stride;
-  } while (--h);
-
-  src = s->u_buffer;
-  h = s->uv_crop_height;
-
-  do {
-    fwrite(src, s->uv_width, 1, f);
-    src += s->uv_stride;
-  } while (--h);
-
-  src = s->v_buffer;
-  h = s->uv_crop_height;
-
-  do {
-    fwrite(src, s->uv_width, 1, f);
-    src += s->uv_stride;
-  } while (--h);
-}
-#endif
-
 #ifdef OUTPUT_YUV_REC
 void vp9_write_yuv_rec_frame(VP9_COMMON *cm) {
   YV12_BUFFER_CONFIG *s = cm->frame_to_show;
index 4cdac723a123dc461508c4929915e2a280fe14bd..175503ed404cf09d6a3ed6819d5c91f556ccbd52 100644 (file)
@@ -130,7 +130,7 @@ void vp9_compute_skin_map(VP9_COMP *const cpi, FILE *yuv_skinmap_file) {
     src_u += (src_uvstride << shuv) - (num_bl << shuv);
     src_v += (src_uvstride << shuv) - (num_bl << shuv);
   }
-  vp9_write_yuv_frame_420(&skinmap, yuv_skinmap_file);
+  vpx_write_yuv_frame(yuv_skinmap_file, &skinmap);
   vpx_free_frame_buffer(&skinmap);
 }
 #endif
index 1c6a081f4afdcee08843b78391b86080a47138c8..bb7ef87d89489652046a78d818c2ae46195fcbea 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "vp9/common/vp9_blockd.h"
 #include "vpx_dsp/skin_detection.h"
+#include "vpx_util/vpx_write_yuv_frame.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -27,7 +28,6 @@ int vp9_compute_skin_block(const uint8_t *y, const uint8_t *u, const uint8_t *v,
 #ifdef OUTPUT_YUV_SKINMAP
 // For viewing skin map on input source.
 void vp9_compute_skin_map(struct VP9_COMP *const cpi, FILE *yuv_skinmap_file);
-extern void vp9_write_yuv_frame_420(YV12_BUFFER_CONFIG *s, FILE *f);
 #endif
 
 #ifdef __cplusplus
index c0ef8d3362917dd193c97a7e649f874d2e9f0c3f..d48e4cc2f9ec0980cafa7a1e8081bcebc3bccce5 100644 (file)
@@ -12,3 +12,5 @@ UTIL_SRCS-yes += vpx_util.mk
 UTIL_SRCS-yes += vpx_thread.c
 UTIL_SRCS-yes += vpx_thread.h
 UTIL_SRCS-yes += endian_inl.h
+UTIL_SRCS-yes += vpx_write_yuv_frame.h
+UTIL_SRCS-yes += vpx_write_yuv_frame.c
diff --git a/vpx_util/vpx_write_yuv_frame.c b/vpx_util/vpx_write_yuv_frame.c
new file mode 100644 (file)
index 0000000..ab68558
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "vpx_dsp/skin_detection.h"
+#include "vpx_util/vpx_write_yuv_frame.h"
+
+void vpx_write_yuv_frame(FILE *yuv_file, YV12_BUFFER_CONFIG *s) {
+#if defined(OUTPUT_YUV_SRC) || defined(OUTPUT_YUV_DENOISED) || \
+    defined(OUTPUT_YUV_SKINMAP)
+
+  unsigned char *src = s->y_buffer;
+  int h = s->y_crop_height;
+
+  do {
+    fwrite(src, s->y_width, 1, yuv_file);
+    src += s->y_stride;
+  } while (--h);
+
+  src = s->u_buffer;
+  h = s->uv_crop_height;
+
+  do {
+    fwrite(src, s->uv_width, 1, yuv_file);
+    src += s->uv_stride;
+  } while (--h);
+
+  src = s->v_buffer;
+  h = s->uv_crop_height;
+
+  do {
+    fwrite(src, s->uv_width, 1, yuv_file);
+    src += s->uv_stride;
+  } while (--h);
+
+#else
+  (void)yuv_file;
+  (void)s;
+#endif
+}
diff --git a/vpx_util/vpx_write_yuv_frame.h b/vpx_util/vpx_write_yuv_frame.h
new file mode 100644 (file)
index 0000000..1cb7029
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef VPX_UTIL_VPX_WRITE_YUV_FRAME_H_
+#define VPX_UTIL_VPX_WRITE_YUV_FRAME_H_
+
+#include <stdio.h>
+#include "vpx_scale/yv12config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void vpx_write_yuv_frame(FILE *yuv_file, YV12_BUFFER_CONFIG *s);
+
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
+#endif  // VPX_UTIL_VPX_WRITE_YUV_FRAME_H_