summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2010-11-02 17:01:54 -0700
committerCode Review <code-review@webmproject.org>2010-11-02 17:01:54 -0700
commit4b9dc572609f4efb80c155b61dc040344be7d43a (patch)
treeeaf46fd767c979374e70132ded9ac1ae63b444cc
parent0a29bd9793743533f7991994cf8880ee582afe24 (diff)
parentc377bf0eec4ab3862e41f7db534e9d3070b0bed7 (diff)
downloadlibvpx-4b9dc572609f4efb80c155b61dc040344be7d43a.tar
libvpx-4b9dc572609f4efb80c155b61dc040344be7d43a.tar.gz
libvpx-4b9dc572609f4efb80c155b61dc040344be7d43a.tar.bz2
libvpx-4b9dc572609f4efb80c155b61dc040344be7d43a.zip
Merge "fix pipe support on windows"
-rw-r--r--examples.mk2
-rw-r--r--tools_common.c24
-rw-r--r--tools_common.h16
-rw-r--r--vpxdec.c6
-rw-r--r--vpxenc.c7
5 files changed, 51 insertions, 4 deletions
diff --git a/examples.mk b/examples.mk
index 9340e23bb..a30205d31 100644
--- a/examples.mk
+++ b/examples.mk
@@ -17,6 +17,7 @@ vpxdec.SRCS += md5_utils.c md5_utils.h
vpxdec.SRCS += vpx_ports/vpx_timer.h
vpxdec.SRCS += vpx/vpx_integer.h
vpxdec.SRCS += args.c args.h vpx_ports/config.h
+vpxdec.SRCS += tools_common.c tools_common.h
vpxdec.SRCS += nestegg/halloc/halloc.h
vpxdec.SRCS += nestegg/halloc/src/align.h
vpxdec.SRCS += nestegg/halloc/src/halloc.c
@@ -28,6 +29,7 @@ vpxdec.GUID = BA5FE66F-38DD-E034-F542-B1578C5FB950
vpxdec.DESCRIPTION = Full featured decoder
UTILS-$(CONFIG_ENCODERS) += vpxenc.c
vpxenc.SRCS += args.c args.h y4minput.c y4minput.h
+vpxenc.SRCS += tools_common.c tools_common.h
vpxenc.SRCS += vpx_ports/config.h vpx_ports/mem_ops.h
vpxenc.SRCS += vpx_ports/mem_ops_aligned.h
vpxenc.SRCS += libmkv/EbmlIDs.h
diff --git a/tools_common.c b/tools_common.c
new file mode 100644
index 000000000..d188bbe20
--- /dev/null
+++ b/tools_common.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2010 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 <stdio.h>
+#include "tools_common.h"
+#ifdef _WIN32
+#include <io.h>
+#include <fcntl.h>
+#endif
+
+FILE* set_binary_mode(FILE *stream)
+{
+ (void)stream;
+#ifdef _WIN32
+ _setmode(_fileno(stream), _O_BINARY);
+#endif
+ return stream;
+}
diff --git a/tools_common.h b/tools_common.h
new file mode 100644
index 000000000..80c974732
--- /dev/null
+++ b/tools_common.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2010 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 TOOLS_COMMON_H
+#define TOOLS_COMMON_H
+
+/* Sets a stdio stream into binary mode */
+FILE* set_binary_mode(FILE *stream);
+
+#endif
diff --git a/vpxdec.c b/vpxdec.c
index e8e4d5f12..85ab20693 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -35,6 +35,7 @@
#if CONFIG_MD5
#include "md5_utils.h"
#endif
+#include "tools_common.h"
#include "nestegg/include/nestegg/nestegg.h"
#ifndef PATH_MAX
@@ -314,7 +315,8 @@ void *out_open(const char *out_fn, int do_md5)
}
else
{
- FILE *outfile = out = strcmp("-", out_fn) ? fopen(out_fn, "wb") : stdout;
+ FILE *outfile = out = strcmp("-", out_fn) ? fopen(out_fn, "wb")
+ : set_binary_mode(stdout);
if (!outfile)
{
@@ -805,7 +807,7 @@ int main(int argc, const char **argv_)
usage_exit();
/* Open file */
- infile = strcmp(fn, "-") ? fopen(fn, "rb") : stdin;
+ infile = strcmp(fn, "-") ? fopen(fn, "rb") : set_binary_mode(stdin);
if (!infile)
{
diff --git a/vpxenc.c b/vpxenc.c
index 7e0595207..4cdadb614 100644
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -35,6 +35,7 @@
#include "vpx/vp8cx.h"
#include "vpx_ports/mem_ops.h"
#include "vpx_ports/vpx_timer.h"
+#include "tools_common.h"
#include "y4minput.h"
#include "libmkv/EbmlWriter.h"
#include "libmkv/EbmlIDs.h"
@@ -1334,7 +1335,8 @@ int main(int argc, const char **argv_)
struct detect_buffer detect;
/* Parse certain options from the input file, if possible */
- infile = strcmp(in_fn, "-") ? fopen(in_fn, "rb") : stdin;
+ infile = strcmp(in_fn, "-") ? fopen(in_fn, "rb")
+ : set_binary_mode(stdin);
if (!infile)
{
@@ -1449,7 +1451,8 @@ int main(int argc, const char **argv_)
cfg.g_w, cfg.g_h, 1);
}
- outfile = strcmp(out_fn, "-") ? fopen(out_fn, "wb") : stdout;
+ outfile = strcmp(out_fn, "-") ? fopen(out_fn, "wb")
+ : set_binary_mode(stdout);
if (!outfile)
{