]> granicus.if.org Git - libvpx/blob - tools_common.h
Added placeholder for real time mode
[libvpx] / tools_common.h
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 #ifndef TOOLS_COMMON_H_
11 #define TOOLS_COMMON_H_
12
13 #include <stdio.h>
14
15 #include "./vpx_config.h"
16 #include "vpx/vpx_image.h"
17 #include "vpx/vpx_integer.h"
18
19 #if CONFIG_ENCODERS
20 #include "./y4minput.h"
21 #endif
22
23 #if defined(_MSC_VER)
24 /* MSVS doesn't define off_t, and uses _f{seek,tell}i64. */
25 typedef __int64 off_t;
26 #define fseeko _fseeki64
27 #define ftello _ftelli64
28 #elif defined(_WIN32)
29 /* MinGW defines off_t as long and uses f{seek,tell}o64/off64_t for large
30  * files. */
31 #define fseeko fseeko64
32 #define ftello ftello64
33 #define off_t off64_t
34 #endif  /* _WIN32 */
35
36 #if CONFIG_OS_SUPPORT
37 #if defined(_MSC_VER)
38 #include <io.h>  /* NOLINT */
39 #define snprintf _snprintf
40 #define isatty   _isatty
41 #define fileno   _fileno
42 #else
43 #include <unistd.h>  /* NOLINT */
44 #endif  /* _MSC_VER */
45 #endif  /* CONFIG_OS_SUPPORT */
46
47 /* Use 32-bit file operations in WebM file format when building ARM
48  * executables (.axf) with RVCT. */
49 #if !CONFIG_OS_SUPPORT
50 typedef long off_t;  /* NOLINT */
51 #define fseeko fseek
52 #define ftello ftell
53 #endif  /* CONFIG_OS_SUPPORT */
54
55 #define LITERALU64(hi, lo) ((((uint64_t)hi) << 32) | lo)
56
57 #ifndef PATH_MAX
58 #define PATH_MAX 512
59 #endif
60
61 #define IVF_FRAME_HDR_SZ (4 + 8)  /* 4 byte size + 8 byte timestamp */
62 #define IVF_FILE_HDR_SZ 32
63
64 #define RAW_FRAME_HDR_SZ sizeof(uint32_t)
65
66 #define VP8_FOURCC (0x30385056)
67 #define VP9_FOURCC (0x30395056)
68 #define VP8_FOURCC_MASK (0x00385056)
69 #define VP9_FOURCC_MASK (0x00395056)
70
71 enum VideoFileType {
72   FILE_TYPE_RAW,
73   FILE_TYPE_IVF,
74   FILE_TYPE_Y4M,
75   FILE_TYPE_WEBM
76 };
77
78 struct FileTypeDetectionBuffer {
79   char buf[4];
80   size_t buf_read;
81   size_t position;
82 };
83
84 struct VpxRational {
85   int numerator;
86   int denominator;
87 };
88
89 struct VpxInputContext {
90   const char *filename;
91   FILE *file;
92   off_t length;
93   struct FileTypeDetectionBuffer detect;
94   enum VideoFileType file_type;
95   uint32_t width;
96   uint32_t height;
97   int use_i420;
98   int only_i420;
99   uint32_t fourcc;
100   struct VpxRational framerate;
101 #if CONFIG_ENCODERS
102   y4m_input y4m;
103 #endif
104 };
105
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109
110 /* Sets a stdio stream into binary mode */
111 FILE *set_binary_mode(FILE *stream);
112
113 void die(const char *fmt, ...);
114 void fatal(const char *fmt, ...);
115 void warn(const char *fmt, ...);
116
117 /* The tool including this file must define usage_exit() */
118 void usage_exit();
119
120 uint16_t mem_get_le16(const void *data);
121 uint32_t mem_get_le32(const void *data);
122
123 int read_yuv_frame(struct VpxInputContext *input_ctx, vpx_image_t *yuv_frame);
124
125 #ifdef __cplusplus
126 }  /* extern "C" */
127 #endif
128
129 #endif  // TOOLS_COMMON_H_