From f1ff6a827425a6f9264731ebcabd9b439ea018af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Fri, 31 Jan 2014 14:32:41 +0200 Subject: [PATCH 1/2] encmain: Add rudimentary support for input via stdin --- src/encmain.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/encmain.c b/src/encmain.c index 3c9f9a01..83663e8e 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -29,6 +29,14 @@ * - -n : encode only n frames */ +#ifdef _WIN32 +/* The following two defines must be located before the inclusion of any system header files. */ +#define WINVER 0x0500 +#define _WIN32_WINNT 0x0500 +#include /* _setmode() */ +#include /* _O_BINARY */ +#endif + #include #include #include @@ -65,7 +73,14 @@ int main(int argc, char *argv[]) FILE *recout = fopen("encrec_832x480_60.yuv","wb"); //!< reconstructed YUV output (only on debug mode) #endif encoder_control *encoder = (encoder_control*)malloc(sizeof(encoder_control)); - + + // Windows needs all of the standard in/outputs to be set to _O_BINARY + #ifdef _WIN32 + _setmode( _fileno( stdin ), _O_BINARY ); + _setmode( _fileno( stdout ), _O_BINARY ); + _setmode( _fileno( stderr ), _O_BINARY ); + #endif + // Handle configuration cfg = config_alloc(); @@ -109,8 +124,15 @@ int main(int argc, char *argv[]) printf("Input: %s, output: %s\n", cfg->input, cfg->output); printf(" Video size: %dx%d\n", cfg->width, cfg->height); - // Open input file and check that it was opened correctly - input = fopen(cfg->input, "rb"); + // Check if the input file name is a dash, this means stdin + if (!strcmp(cfg->input, "-")) { + input = stdin; + } else { + // Otherwise we try to open the input file + input = fopen(cfg->input, "rb"); + } + + // Check that input was opened correctly if (input == NULL) { fprintf(stderr, "Could not open input file, shutting down!\n"); config_destroy(cfg); From f9a3d40b485becac4cedf24c70232d1a9da52ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Fri, 31 Jan 2014 14:33:25 +0200 Subject: [PATCH 2/2] gitignore: Add object files to the list of ignored files Running the Makefile outside bin or build leads to creation of these files in a place that does not get ignored. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d19c71a8..1b15a29f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /doxygen # Other files -*.exe \ No newline at end of file +*.exe +*.o