1 |
51 |
julius |
diff --exclude=.git --exclude=/gitignore -Naur x264/common/common.c x264-or/common/common.c
|
2 |
|
|
--- x264/common/common.c 2009-10-25 17:41:22.000000000 +0100
|
3 |
|
|
+++ x264-or/common/common.c 2009-10-28 15:05:29.000000000 +0100
|
4 |
|
|
@@ -764,8 +764,10 @@
|
5 |
|
|
align_buf = malloc( i_size );
|
6 |
|
|
#elif defined( HAVE_MALLOC_H )
|
7 |
|
|
align_buf = memalign( 16, i_size );
|
8 |
|
|
+ //fprintf(stderr, "memalign, result addr: 0x%.8x\n", (unsigned int) align_buf);
|
9 |
|
|
#else
|
10 |
|
|
uint8_t *buf = malloc( i_size + 15 + sizeof(void **) + sizeof(int) );
|
11 |
|
|
+ //fprintf(stderr, "malloc, result addr: 0x%.8x\n", (unsigned int) buf);
|
12 |
|
|
if( buf )
|
13 |
|
|
{
|
14 |
|
|
align_buf = buf + 15 + sizeof(void **) + sizeof(int);
|
15 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/common/common.h x264-or/common/common.h
|
16 |
|
|
--- x264/common/common.h 2009-10-25 17:41:22.000000000 +0100
|
17 |
|
|
+++ x264-or/common/common.h 2009-11-10 22:42:24.000000000 +0100
|
18 |
|
|
@@ -51,7 +51,8 @@
|
19 |
|
|
#define X264_BFRAME_MAX 16
|
20 |
|
|
#define X264_THREAD_MAX 128
|
21 |
|
|
#define X264_PCM_COST (386*8)
|
22 |
|
|
-#define X264_LOOKAHEAD_MAX 250
|
23 |
|
|
+//#define X264_LOOKAHEAD_MAX 250
|
24 |
|
|
+#define X264_LOOKAHEAD_MAX 140
|
25 |
|
|
// arbitrary, but low because SATD scores are 1/4 normal
|
26 |
|
|
#define X264_LOOKAHEAD_QP 12
|
27 |
|
|
|
28 |
|
|
@@ -260,7 +261,7 @@
|
29 |
|
|
*/
|
30 |
|
|
#define X264_SCAN8_SIZE (6*8)
|
31 |
|
|
#define X264_SCAN8_0 (4+1*8)
|
32 |
|
|
-
|
33 |
|
|
+/* this array indicates the position in the */
|
34 |
|
|
static const int x264_scan8[16+2*4+3] =
|
35 |
|
|
{
|
36 |
|
|
/* Luma */
|
37 |
|
|
@@ -518,7 +519,9 @@
|
38 |
|
|
/* space for p_fenc and p_fdec */
|
39 |
|
|
#define FENC_STRIDE 16
|
40 |
|
|
#define FDEC_STRIDE 32
|
41 |
|
|
- ALIGNED_16( uint8_t fenc_buf[24*FENC_STRIDE] );
|
42 |
|
|
+ /* comment regarding FDEC_STRIDE: the catch with fdec is that the chroma blocks must be aligned to 8 and the luma blocks must be aligned to 16 but we need to have pixels on the left side for prediction so we have a lot of padding on the left side. so for luma: X X X X X X X X X X X X X X X L _ _ _ _ _ ... where X are junk, L is the left pixel, _ are normal pixels, so 32 wide total */
|
43 |
|
|
+
|
44 |
|
|
+ ALIGNED_16( uint8_t fenc_buf[24*FENC_STRIDE] ); /* FENC stores both Y, U, and V, 16x16 + 8x8 + 8x8 = 24 * 16*/
|
45 |
|
|
ALIGNED_16( uint8_t fdec_buf[27*FDEC_STRIDE] );
|
46 |
|
|
|
47 |
|
|
/* i4x4 and i8x8 backup data, for skipping the encode stage when possible */
|
48 |
|
|
@@ -551,9 +554,29 @@
|
49 |
|
|
|
50 |
|
|
/* pointer over mb of the references */
|
51 |
|
|
int i_fref[2];
|
52 |
|
|
- uint8_t *p_fref[2][32][4+2]; /* last: lN, lH, lV, lHV, cU, cV */
|
53 |
|
|
- uint16_t *p_integral[2][16];
|
54 |
|
|
-
|
55 |
|
|
+ uint8_t *p_fref[2][32][4+2]; /* last: 4hpel pointers, 2 chroma pointers: lN (normal), lH (horizontally interpolated), lV (vertically interpolated), lHV (center position), cU (chroma U), cV (chroma V)
|
56 |
|
|
+ Important!: This is our post-motion compensation frame data, stored in half-pixel (hpel) resolution.
|
57 |
|
|
+ During motion compensation, hpel data is calculated via 6-tap FIR filter (very similar to Lanczos). It is an even filter (even function) so every input pixel corresponds to 4 output pixels
|
58 |
|
|
+ one of those 4 is equal to the input, so the data contains one fullpel pixel, one H, one V, one C (aka HV)
|
59 |
|
|
+ From this data, qpel is calculated via interpolation, which is easy and quick to do.
|
60 |
|
|
+ F 0 H 1 F
|
61 |
|
|
+ 2 3 4 5 6
|
62 |
|
|
+ V 7 C 8 V
|
63 |
|
|
+ 9 A B C D
|
64 |
|
|
+ F _ H _ F
|
65 |
|
|
+ Here 0 is the average of F and H
|
66 |
|
|
+ 2 is the average of F and V
|
67 |
|
|
+ 3 is the average of H and V
|
68 |
|
|
+ 4 is the average of H and C
|
69 |
|
|
+ etc.
|
70 |
|
|
+ So each qpel position is the result of averaging two known hpel positions.*/
|
71 |
|
|
+ uint16_t *p_integral[2][16]; /* pointers to "integral": for each position X,Y, it's the sum of values in an 8x8 block with that point X,Y as the upper left of that block
|
72 |
|
|
+ Discussion on this value:
|
73 |
|
|
+ < pengvado> Dark_Shikari: "sum of values in an 8x8 block" is what I would call "dc". the variable name comes because it used to be an indefinite integral, i.e. the sum of everything above and to the left of that point.
|
74 |
|
|
+ < pengvado> but if you're only interested in 16x16, 16x8, 8x16, and 8x8, then caching 8x8 dcs is strictly faster
|
75 |
|
|
+ */
|
76 |
|
|
+
|
77 |
|
|
+
|
78 |
|
|
/* fref stride */
|
79 |
|
|
int i_stride[3];
|
80 |
|
|
} pic;
|
81 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/common/frame.c x264-or/common/frame.c
|
82 |
|
|
--- x264/common/frame.c 2009-10-25 17:41:10.000000000 +0100
|
83 |
|
|
+++ x264-or/common/frame.c 2009-10-28 15:05:29.000000000 +0100
|
84 |
|
|
@@ -31,6 +31,8 @@
|
85 |
|
|
x264_frame_t *frame;
|
86 |
|
|
int i, j;
|
87 |
|
|
|
88 |
|
|
+ //V(fprintf(stderr, "x264_frame_new\n"));
|
89 |
|
|
+
|
90 |
|
|
int i_mb_count = h->mb.i_mb_count;
|
91 |
|
|
int i_stride, i_width, i_lines;
|
92 |
|
|
int i_padv = PADV << h->param.b_interlaced;
|
93 |
|
|
@@ -981,11 +983,14 @@
|
94 |
|
|
|
95 |
|
|
x264_frame_t *x264_frame_pop_unused( x264_t *h, int b_fdec )
|
96 |
|
|
{
|
97 |
|
|
+ //V(fprintf(stderr, "x264_frame_pop_unused\n"));
|
98 |
|
|
x264_frame_t *frame;
|
99 |
|
|
if( h->frames.unused[b_fdec][0] )
|
100 |
|
|
frame = x264_frame_pop( h->frames.unused[b_fdec] );
|
101 |
|
|
else
|
102 |
|
|
frame = x264_frame_new( h, b_fdec );
|
103 |
|
|
+
|
104 |
|
|
+ //V(fprintf(stderr, "x264_frame_pop_unused: frame ptr = 0x%.8x\n", (unsigned long) frame));
|
105 |
|
|
if( !frame )
|
106 |
|
|
return NULL;
|
107 |
|
|
frame->b_last_minigop_bframe = 0;
|
108 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/common/macroblock.c x264-or/common/macroblock.c
|
109 |
|
|
--- x264/common/macroblock.c 2009-10-25 17:41:22.000000000 +0100
|
110 |
|
|
+++ x264-or/common/macroblock.c 2009-11-09 13:02:31.000000000 +0100
|
111 |
|
|
@@ -118,7 +118,7 @@
|
112 |
|
|
|
113 |
|
|
int i_count = 0;
|
114 |
|
|
|
115 |
|
|
- if( i_refc == -2 )
|
116 |
|
|
+ if( i_refc == -2 )/* -2 = unavailable */
|
117 |
|
|
{
|
118 |
|
|
i_refc = h->mb.cache.ref[i_list][X264_SCAN8_0 - 8 - 1];
|
119 |
|
|
mv_c = h->mb.cache.mv[i_list][X264_SCAN8_0 - 8 - 1];
|
120 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/common/mdate.c x264-or/common/mdate.c
|
121 |
|
|
--- x264/common/mdate.c 2009-10-25 17:41:10.000000000 +0100
|
122 |
|
|
+++ x264-or/common/mdate.c 2009-10-28 15:05:29.000000000 +0100
|
123 |
|
|
@@ -32,9 +32,12 @@
|
124 |
|
|
int64_t x264_mdate( void )
|
125 |
|
|
{
|
126 |
|
|
#ifndef __MINGW32__
|
127 |
|
|
+ /* --jb
|
128 |
|
|
struct timeval tv_date;
|
129 |
|
|
gettimeofday( &tv_date, NULL );
|
130 |
|
|
return( (int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec );
|
131 |
|
|
+ */
|
132 |
|
|
+ return 0;
|
133 |
|
|
#else
|
134 |
|
|
struct _timeb tb;
|
135 |
|
|
_ftime(&tb);
|
136 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/common/or32/or32.h x264-or/common/or32/or32.h
|
137 |
|
|
--- x264/common/or32/or32.h 1970-01-01 01:00:00.000000000 +0100
|
138 |
|
|
+++ x264-or/common/or32/or32.h 2009-11-17 10:20:27.000000000 +0100
|
139 |
|
|
@@ -0,0 +1,22 @@
|
140 |
|
|
+/* Struct for SAD/SSD hardware module */
|
141 |
|
|
+typedef struct {
|
142 |
|
|
+ uint32_t control;
|
143 |
|
|
+ uint32_t result;
|
144 |
|
|
+ uint32_t pix_ptr1;
|
145 |
|
|
+ uint32_t pix_ptr2;
|
146 |
|
|
+ uint32_t stride1;
|
147 |
|
|
+ uint32_t stride2;
|
148 |
|
|
+ uint32_t x;
|
149 |
|
|
+ uint32_t y;
|
150 |
|
|
+} x264_or32_sadssdmod_regs_t;
|
151 |
|
|
+
|
152 |
|
|
+#define OR32_SADSSDMOD_REG_BASE 0x26400000
|
153 |
|
|
+
|
154 |
|
|
+#define OR32_SADSSDMOD_CONTROL_REG_BASE (OR32_SADSSDMOD_REG_BASE+0)
|
155 |
|
|
+#define OR32_SADSSDMOD_CONTROL_REG_BUSY 0x1
|
156 |
|
|
+#define OR32_SADSSDMOD_CONTROL_REG_MODE_MASK 0x2
|
157 |
|
|
+#define OR32_SADSSDMOD_CONTROL_REG_MODE_SAD (OR32_SADSSDMOD_CONTROL_REG_MODE_MASK & 0x0)
|
158 |
|
|
+#define OR32_SADSSDMOD_CONTROL_REG_MODE_SSD (OR32_SADSSDMOD_CONTROL_REG_MODE_MASK & 0xff)
|
159 |
|
|
+
|
160 |
|
|
+
|
161 |
|
|
+#define OR32_SADSSDMOD 1
|
162 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/common/pixel.c x264-or/common/pixel.c
|
163 |
|
|
--- x264/common/pixel.c 2009-10-25 17:41:10.000000000 +0100
|
164 |
|
|
+++ x264-or/common/pixel.c 2009-11-17 10:26:39.000000000 +0100
|
165 |
|
|
@@ -22,6 +22,7 @@
|
166 |
|
|
*****************************************************************************/
|
167 |
|
|
|
168 |
|
|
#include "common.h"
|
169 |
|
|
+#include "x264.h"
|
170 |
|
|
|
171 |
|
|
#ifdef HAVE_MMX
|
172 |
|
|
# include "x86/pixel.h"
|
173 |
|
|
@@ -35,29 +36,51 @@
|
174 |
|
|
#ifdef ARCH_UltraSparc
|
175 |
|
|
# include "sparc/pixel.h"
|
176 |
|
|
#endif
|
177 |
|
|
+#ifdef ARCH_OR32
|
178 |
|
|
+# include "or32/or32.h"
|
179 |
|
|
+#endif
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
/****************************************************************************
|
183 |
|
|
* pixel_sad_WxH
|
184 |
|
|
****************************************************************************/
|
185 |
|
|
-#define PIXEL_SAD_C( name, lx, ly ) \
|
186 |
|
|
-static int name( uint8_t *pix1, int i_stride_pix1, \
|
187 |
|
|
- uint8_t *pix2, int i_stride_pix2 ) \
|
188 |
|
|
-{ \
|
189 |
|
|
- int i_sum = 0; \
|
190 |
|
|
- int x, y; \
|
191 |
|
|
- for( y = 0; y < ly; y++ ) \
|
192 |
|
|
- { \
|
193 |
|
|
- for( x = 0; x < lx; x++ ) \
|
194 |
|
|
- { \
|
195 |
|
|
- i_sum += abs( pix1[x] - pix2[x] ); \
|
196 |
|
|
- } \
|
197 |
|
|
- pix1 += i_stride_pix1; \
|
198 |
|
|
- pix2 += i_stride_pix2; \
|
199 |
|
|
- } \
|
200 |
|
|
- return i_sum; \
|
201 |
|
|
-}
|
202 |
|
|
-
|
203 |
|
|
+#if OR32_SADSSDMOD
|
204 |
|
|
+#define PIXEL_SAD_C( name, lx, ly ) \
|
205 |
|
|
+ static int name( uint8_t *pix1, int i_stride_pix1, \
|
206 |
|
|
+ uint8_t *pix2, int i_stride_pix2 ) \
|
207 |
|
|
+ { /* Configure and set the hardware SAD/SSD module running */ \
|
208 |
|
|
+ volatile x264_or32_sadssdmod_regs_t* sadssdmod_regs; \
|
209 |
|
|
+ sadssdmod_regs = (x264_or32_sadssdmod_regs_t*) OR32_SADSSDMOD_REG_BASE; \
|
210 |
|
|
+ sadssdmod_regs->pix_ptr1 = (uint32_t)pix1; \
|
211 |
|
|
+ sadssdmod_regs->pix_ptr2 = (uint32_t)pix2; \
|
212 |
|
|
+ sadssdmod_regs->stride1 = (uint32_t)i_stride_pix1; \
|
213 |
|
|
+ sadssdmod_regs->stride2 = (uint32_t)i_stride_pix2; \
|
214 |
|
|
+ sadssdmod_regs->x = (uint32_t)lx; \
|
215 |
|
|
+ sadssdmod_regs->y = (uint32_t)ly; \
|
216 |
|
|
+ sadssdmod_regs->control = (uint32_t)(OR32_SADSSDMOD_CONTROL_REG_MODE_SAD | \
|
217 |
|
|
+ OR32_SADSSDMOD_CONTROL_REG_BUSY) ; \
|
218 |
|
|
+ while (sadssdmod_regs->control & OR32_SADSSDMOD_CONTROL_REG_BUSY); \
|
219 |
|
|
+ return (int) sadssdmod_regs->result; \
|
220 |
|
|
+ }
|
221 |
|
|
+#else
|
222 |
|
|
+#define PIXEL_SAD_C( name, lx, ly ) \
|
223 |
|
|
+ static int name( uint8_t *pix1, int i_stride_pix1, \
|
224 |
|
|
+ uint8_t *pix2, int i_stride_pix2 ) \
|
225 |
|
|
+ { \
|
226 |
|
|
+int i_sum = 0; \
|
227 |
|
|
+int x, y; \
|
228 |
|
|
+for( y = 0; y < ly; y++ ) \
|
229 |
|
|
+ { \
|
230 |
|
|
+ for( x = 0; x < lx; x++ ) \
|
231 |
|
|
+ { \
|
232 |
|
|
+ i_sum += abs( pix1[x] - pix2[x] ); \
|
233 |
|
|
+ } \
|
234 |
|
|
+ pix1 += i_stride_pix1; \
|
235 |
|
|
+ pix2 += i_stride_pix2; \
|
236 |
|
|
+ } \
|
237 |
|
|
+return i_sum; \
|
238 |
|
|
+}
|
239 |
|
|
+#endif
|
240 |
|
|
|
241 |
|
|
PIXEL_SAD_C( x264_pixel_sad_16x16, 16, 16 )
|
242 |
|
|
PIXEL_SAD_C( x264_pixel_sad_16x8, 16, 8 )
|
243 |
|
|
@@ -71,10 +94,29 @@
|
244 |
|
|
/****************************************************************************
|
245 |
|
|
* pixel_ssd_WxH
|
246 |
|
|
****************************************************************************/
|
247 |
|
|
+#if OR32_SADSSDMOD
|
248 |
|
|
+#define PIXEL_SSD_C( name, lx, ly ) \
|
249 |
|
|
+static int name( uint8_t *pix1, int i_stride_pix1, \
|
250 |
|
|
+ uint8_t *pix2, int i_stride_pix2 ) \
|
251 |
|
|
+{ /* Configure and set the hardware SAD/SSD module running */ \
|
252 |
|
|
+ volatile x264_or32_sadssdmod_regs_t* sadssdmod_regs; \
|
253 |
|
|
+ sadssdmod_regs = (x264_or32_sadssdmod_regs_t*) OR32_SADSSDMOD_REG_BASE; \
|
254 |
|
|
+ sadssdmod_regs->pix_ptr1 = (uint32_t)pix1; \
|
255 |
|
|
+ sadssdmod_regs->pix_ptr2 = (uint32_t)pix2; \
|
256 |
|
|
+ sadssdmod_regs->stride1 = (uint32_t)i_stride_pix1; \
|
257 |
|
|
+ sadssdmod_regs->stride2 = (uint32_t)i_stride_pix2; \
|
258 |
|
|
+ sadssdmod_regs->x = (uint32_t)lx; \
|
259 |
|
|
+ sadssdmod_regs->y = (uint32_t)ly; \
|
260 |
|
|
+ sadssdmod_regs->control = (uint32_t)(OR32_SADSSDMOD_CONTROL_REG_MODE_SSD | \
|
261 |
|
|
+ OR32_SADSSDMOD_CONTROL_REG_BUSY) ; \
|
262 |
|
|
+ while (sadssdmod_regs->control & OR32_SADSSDMOD_CONTROL_REG_BUSY); \
|
263 |
|
|
+ return (int) sadssdmod_regs->result; \
|
264 |
|
|
+}
|
265 |
|
|
+#else
|
266 |
|
|
#define PIXEL_SSD_C( name, lx, ly ) \
|
267 |
|
|
static int name( uint8_t *pix1, int i_stride_pix1, \
|
268 |
|
|
uint8_t *pix2, int i_stride_pix2 ) \
|
269 |
|
|
-{ \
|
270 |
|
|
+{ \
|
271 |
|
|
int i_sum = 0; \
|
272 |
|
|
int x, y; \
|
273 |
|
|
for( y = 0; y < ly; y++ ) \
|
274 |
|
|
@@ -89,7 +131,7 @@
|
275 |
|
|
} \
|
276 |
|
|
return i_sum; \
|
277 |
|
|
}
|
278 |
|
|
-
|
279 |
|
|
+#endif
|
280 |
|
|
PIXEL_SSD_C( x264_pixel_ssd_16x16, 16, 16 )
|
281 |
|
|
PIXEL_SSD_C( x264_pixel_ssd_16x8, 16, 8 )
|
282 |
|
|
PIXEL_SSD_C( x264_pixel_ssd_8x16, 8, 16 )
|
283 |
|
|
@@ -387,6 +429,7 @@
|
284 |
|
|
|
285 |
|
|
/****************************************************************************
|
286 |
|
|
* pixel_sad_x4
|
287 |
|
|
+ * Debug printf : V(fprintf(stderr, "x264_pixel_sadx4 size : *fenc: 0x%.8x *pix0: 0x%.8x *pix1: 0x%.8x *pix2: 0x%.8x *pix3: 0x%.8x i_stride: %d *scores: 0x%.8x\n", (unsigned long) fenc, (unsigned long) pix0, (unsigned long) pix1, (unsigned long)pix2, (unsigned long)pix3, i_stride, (unsigned long) scores)); \
|
288 |
|
|
****************************************************************************/
|
289 |
|
|
#define SAD_X( size ) \
|
290 |
|
|
static void x264_pixel_sad_x3_##size( uint8_t *fenc, uint8_t *pix0, uint8_t *pix1, uint8_t *pix2, int i_stride, int scores[3] )\
|
291 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/configure x264-or/configure
|
292 |
|
|
--- x264/configure 2009-10-25 17:41:10.000000000 +0100
|
293 |
|
|
+++ x264-or/configure 2009-10-28 15:05:29.000000000 +0100
|
294 |
|
|
@@ -29,7 +29,7 @@
|
295 |
|
|
rm -f conftest.c
|
296 |
|
|
[ -n "$1" ] && echo "#include <$1>" > conftest.c
|
297 |
|
|
echo "int main () { $3 return 0; }" >> conftest.c
|
298 |
|
|
- $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
|
299 |
|
|
+ $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest #2>$DEVNULL
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
as_check() {
|
303 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/encoder/analyse.c x264-or/encoder/analyse.c
|
304 |
|
|
--- x264/encoder/analyse.c 2009-10-25 17:41:10.000000000 +0100
|
305 |
|
|
+++ x264-or/encoder/analyse.c 2009-11-09 13:11:23.000000000 +0100
|
306 |
|
|
@@ -27,6 +27,7 @@
|
307 |
|
|
#include <unistd.h>
|
308 |
|
|
|
309 |
|
|
#include "common/common.h"
|
310 |
|
|
+#include "x264.h"
|
311 |
|
|
#include "common/cpu.h"
|
312 |
|
|
#include "macroblock.h"
|
313 |
|
|
#include "me.h"
|
314 |
|
|
@@ -34,6 +35,7 @@
|
315 |
|
|
#include "analyse.h"
|
316 |
|
|
#include "rdo.c"
|
317 |
|
|
|
318 |
|
|
+
|
319 |
|
|
typedef struct
|
320 |
|
|
{
|
321 |
|
|
/* 16x16 */
|
322 |
|
|
@@ -233,40 +235,75 @@
|
323 |
|
|
5, 3, 3, 1
|
324 |
|
|
};
|
325 |
|
|
|
326 |
|
|
+extern const float x264_analyse_init_log2_array[]; //jb
|
327 |
|
|
+
|
328 |
|
|
static void x264_analyse_update_cache( x264_t *h, x264_mb_analysis_t *a );
|
329 |
|
|
|
330 |
|
|
static uint16_t x264_cost_ref[92][3][33];
|
331 |
|
|
static x264_pthread_mutex_t cost_ref_mutex = X264_PTHREAD_MUTEX_INITIALIZER;
|
332 |
|
|
|
333 |
|
|
+/*
|
334 |
|
|
+float log2f( float n )
|
335 |
|
|
+{
|
336 |
|
|
+// log(n)/log(2) is log2.
|
337 |
|
|
+//return log10( n ) / log10( 2 );
|
338 |
|
|
+ return (float) (log( n ) / _M_LOG2_E);
|
339 |
|
|
+}
|
340 |
|
|
+*/
|
341 |
|
|
int x264_analyse_init_costs( x264_t *h, int qp )
|
342 |
|
|
{
|
343 |
|
|
int i, j;
|
344 |
|
|
int lambda = x264_lambda_tab[qp];
|
345 |
|
|
+ float tmp_f,lambda_f = lambda;
|
346 |
|
|
+
|
347 |
|
|
if( h->cost_mv[lambda] )
|
348 |
|
|
return 0;
|
349 |
|
|
+
|
350 |
|
|
+ fprintf( stderr,
|
351 |
|
|
+ "x264_analyse_init_costs: lambda (= x264_lambda_tab[%d]) = %d\n",
|
352 |
|
|
+ qp, lambda);
|
353 |
|
|
+
|
354 |
|
|
/* factor of 4 from qpel, 2 from sign, and 2 because mv can be opposite from mvp */
|
355 |
|
|
CHECKED_MALLOC( h->cost_mv[lambda], (4*4*2048 + 1) * sizeof(uint16_t) );
|
356 |
|
|
+
|
357 |
|
|
h->cost_mv[lambda] += 2*4*2048;
|
358 |
|
|
+
|
359 |
|
|
+ /* Computationally expensive thing: logs, floating point math, much of -- jb*/
|
360 |
|
|
for( i = 0; i <= 2*4*2048; i++ )
|
361 |
|
|
- {
|
362 |
|
|
- h->cost_mv[lambda][-i] =
|
363 |
|
|
- h->cost_mv[lambda][i] = lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
|
364 |
|
|
- }
|
365 |
|
|
+ {
|
366 |
|
|
+
|
367 |
|
|
+ //h->cost_mv[lambda][i] = lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
|
368 |
|
|
+ //h->cost_mv[lambda][i] = lambda * (log2(i+1)*2 + 0.718f + !!i) + .5f;
|
369 |
|
|
+
|
370 |
|
|
+ // precalulated array, doing the above few calculations for us
|
371 |
|
|
+ tmp_f = lambda_f * x264_analyse_init_log2_array[i];
|
372 |
|
|
+ tmp_f += .5f;
|
373 |
|
|
+ h->cost_mv[lambda][-i] =
|
374 |
|
|
+ h->cost_mv[lambda][i] = tmp_f;
|
375 |
|
|
+
|
376 |
|
|
+
|
377 |
|
|
+ }
|
378 |
|
|
x264_pthread_mutex_lock( &cost_ref_mutex );
|
379 |
|
|
+
|
380 |
|
|
for( i = 0; i < 3; i++ )
|
381 |
|
|
- for( j = 0; j < 33; j++ )
|
382 |
|
|
- x264_cost_ref[lambda][i][j] = i ? lambda * bs_size_te( i, j ) : 0;
|
383 |
|
|
+ for( j = 0; j < 33; j++ )
|
384 |
|
|
+ x264_cost_ref[lambda][i][j] = i ? lambda * bs_size_te( i, j ) : 0;
|
385 |
|
|
+
|
386 |
|
|
x264_pthread_mutex_unlock( &cost_ref_mutex );
|
387 |
|
|
+
|
388 |
|
|
+ /* for now, disable -- jb
|
389 |
|
|
if( h->param.analyse.i_me_method >= X264_ME_ESA && !h->cost_mv_fpel[lambda][0] )
|
390 |
|
|
- {
|
391 |
|
|
+ {
|
392 |
|
|
+ printf("analyse_init_costs: h->param.analyse.i_me_method >= X264_ME_ESA && !h->cost_mv_fpel[lambda][0]\n");
|
393 |
|
|
for( j=0; j<4; j++ )
|
394 |
|
|
- {
|
395 |
|
|
+ {
|
396 |
|
|
CHECKED_MALLOC( h->cost_mv_fpel[lambda][j], (4*2048 + 1) * sizeof(uint16_t) );
|
397 |
|
|
h->cost_mv_fpel[lambda][j] += 2*2048;
|
398 |
|
|
for( i = -2*2048; i < 2*2048; i++ )
|
399 |
|
|
- h->cost_mv_fpel[lambda][j][i] = h->cost_mv[lambda][i*4+j];
|
400 |
|
|
+ h->cost_mv_fpel[lambda][j][i] = h->cost_mv[lambda][i*4+j];
|
401 |
|
|
}
|
402 |
|
|
}
|
403 |
|
|
+ */
|
404 |
|
|
return 0;
|
405 |
|
|
fail:
|
406 |
|
|
return -1;
|
407 |
|
|
@@ -288,6 +325,7 @@
|
408 |
|
|
/* initialize an array of lambda*nbits for all possible mvs */
|
409 |
|
|
static void x264_mb_analyse_load_costs( x264_t *h, x264_mb_analysis_t *a )
|
410 |
|
|
{
|
411 |
|
|
+ //V(fprintf(stderr, "x264_mb_analyse_load_costs() called\n"));
|
412 |
|
|
a->p_cost_mv = h->cost_mv[a->i_lambda];
|
413 |
|
|
a->p_cost_ref0 = x264_cost_ref[a->i_lambda][x264_clip3(h->sh.i_num_ref_idx_l0_active-1,0,2)];
|
414 |
|
|
a->p_cost_ref1 = x264_cost_ref[a->i_lambda][x264_clip3(h->sh.i_num_ref_idx_l1_active-1,0,2)];
|
415 |
|
|
@@ -1161,6 +1199,7 @@
|
416 |
|
|
(m)->p_fenc[1] = &(src)[1][((xoff)>>1)+((yoff)>>1)*FENC_STRIDE]; \
|
417 |
|
|
(m)->p_fenc[2] = &(src)[2][((xoff)>>1)+((yoff)>>1)*FENC_STRIDE];
|
418 |
|
|
|
419 |
|
|
+
|
420 |
|
|
#define LOAD_HPELS(m, src, list, ref, xoff, yoff) \
|
421 |
|
|
(m)->p_fref[0] = &(src)[0][(xoff)+(yoff)*(m)->i_stride[0]]; \
|
422 |
|
|
(m)->p_fref[1] = &(src)[1][(xoff)+(yoff)*(m)->i_stride[0]]; \
|
423 |
|
|
@@ -1183,20 +1222,35 @@
|
424 |
|
|
|
425 |
|
|
/* 16x16 Search on all ref frame */
|
426 |
|
|
m.i_pixel = PIXEL_16x16;
|
427 |
|
|
- m.p_cost_mv = a->p_cost_mv;
|
428 |
|
|
- LOAD_FENC( &m, h->mb.pic.p_fenc, 0, 0 );
|
429 |
|
|
+ m.p_cost_mv = a->p_cost_mv; /* where a->p_cost_mv = h->cost_mv[a->i_lambda] from x264_mb_analyse_init(). a->i_lambda related to qp of MB, and h->cost_mv[] calculated at beginning in x264_mb_analyse_local_costs() */
|
430 |
|
|
+ /* LOAD_FENC(m, src, xoff, yoff) :
|
431 |
|
|
+ h->mb.pic.p_fenc: pointer over mb of the frame to be compressed, i think array of 3 pointers, one each to Y, Cb, Cr data.
|
432 |
|
|
+ x264_me_t m is loaded with appropriate stride variables, and pointers to the appropriate pixels
|
433 |
|
|
+ Essentially loads the me struct with stride and offsets, this is done in a macro because it's convenient
|
434 |
|
|
+ because the many partitions can use the same macro to setup x264_me_t struct
|
435 |
|
|
+ */
|
436 |
|
|
+ LOAD_FENC( &m, h->mb.pic.p_fenc, 0, 0 );
|
437 |
|
|
+ //printf("x264_mb_analyse_inter_p16x16: m.i_stride[0]: %d\n",m.i_stride[0]);
|
438 |
|
|
+ //printf("x264_mb_analyse_inter_p16x16: m.i_stride[1]: %d\n",m.i_stride[1]);
|
439 |
|
|
+ //usually m.i_stride[0] is 416 and m.i_stride[1] is 208 -- jb
|
440 |
|
|
|
441 |
|
|
a->l0.me16x16.cost = INT_MAX;
|
442 |
|
|
+
|
443 |
|
|
+ //printf("x264_mb_analyse_inter_p16x16: h->mb.pic.i_fref[0] = %d\n",h->mb.pic.i_fref[0]);
|
444 |
|
|
+
|
445 |
|
|
+ // Usually just the single reference frame here
|
446 |
|
|
for( i_ref = 0; i_ref < h->mb.pic.i_fref[0]; i_ref++ )
|
447 |
|
|
{
|
448 |
|
|
- const int i_ref_cost = REF_COST( 0, i_ref );
|
449 |
|
|
- i_halfpel_thresh -= i_ref_cost;
|
450 |
|
|
+ const int i_ref_cost = REF_COST( 0, i_ref ); /* looks in a->p_cost_ref0/1[], which is set in x264_mb_analyse_load_costs() */
|
451 |
|
|
+ i_halfpel_thresh -= i_ref_cost;
|
452 |
|
|
m.i_ref_cost = i_ref_cost;
|
453 |
|
|
m.i_ref = i_ref;
|
454 |
|
|
|
455 |
|
|
/* search with ref */
|
456 |
|
|
- LOAD_HPELS( &m, h->mb.pic.p_fref[0][i_ref], 0, i_ref, 0, 0 );
|
457 |
|
|
- x264_mb_predict_mv_16x16( h, 0, i_ref, m.mvp );
|
458 |
|
|
+ /* m, src, list, ref, xoff, yoff */
|
459 |
|
|
+ LOAD_HPELS( &m, h->mb.pic.p_fref[0][i_ref], 0, i_ref, 0 , 0 );
|
460 |
|
|
+ /* h,i_list, i_ref, int16_t mvp[2] */
|
461 |
|
|
+ x264_mb_predict_mv_16x16( h, 0, i_ref, m.mvp );
|
462 |
|
|
x264_mb_predict_mv_ref16x16( h, 0, i_ref, mvc, &i_mvc );
|
463 |
|
|
x264_me_search_ref( h, &m, mvc, i_mvc, p_halfpel_thresh );
|
464 |
|
|
|
465 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/encoder/analyse_gen_init_array.sh x264-or/encoder/analyse_gen_init_array.sh
|
466 |
|
|
--- x264/encoder/analyse_gen_init_array.sh 1970-01-01 01:00:00.000000000 +0100
|
467 |
|
|
+++ x264-or/encoder/analyse_gen_init_array.sh 2009-10-28 15:05:29.000000000 +0100
|
468 |
|
|
@@ -0,0 +1,32 @@
|
469 |
|
|
+#!/bin/bash
|
470 |
|
|
+# Pre-generate an array of numbers according to the algorithm from analyse_init_costs()
|
471 |
|
|
+# to speedup calculation. Here we calculate the stuff in brackets:
|
472 |
|
|
+# lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
|
473 |
|
|
+outfile=analyse_init_log2.c
|
474 |
|
|
+
|
475 |
|
|
+echo; echo "Generating analyse_init_log2_array[] to $outfile"
|
476 |
|
|
+echo "This may take a minute or two..."
|
477 |
|
|
+
|
478 |
|
|
+#Size of the array: 4*2*2048
|
479 |
|
|
+numvals=16384
|
480 |
|
|
+
|
481 |
|
|
+rm -f $outfile
|
482 |
|
|
+
|
483 |
|
|
+echo "const float x264_analyse_init_log2_array[] = {" >> $outfile
|
484 |
|
|
+
|
485 |
|
|
+n=0
|
486 |
|
|
+
|
487 |
|
|
+ for num in `seq 1 $numvals`;
|
488 |
|
|
+ do
|
489 |
|
|
+# Use bc to do the calculation, scale down to the output to one decimal place
|
490 |
|
|
+ newnum=`echo "a=((l($num)/l(2))*2)+1.718; scale=1; a=(a*2)/2; a" | bc -l`
|
491 |
|
|
+ echo -n $newnum >> $outfile
|
492 |
|
|
+ if [ $num -lt $numvals ]; then echo -n ", " >> $outfile; fi;
|
493 |
|
|
+ # Newline every 16 values
|
494 |
|
|
+ let "n = $num % 16"
|
495 |
|
|
+ if [ $n -eq 0 ]; then echo >> $outfile; fi;
|
496 |
|
|
+ done
|
497 |
|
|
+echo "};" >> $outfile
|
498 |
|
|
+
|
499 |
|
|
+echo "finished"
|
500 |
|
|
+echo
|
501 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/encoder/encoder.c x264-or/encoder/encoder.c
|
502 |
|
|
--- x264/encoder/encoder.c 2009-10-25 17:41:22.000000000 +0100
|
503 |
|
|
+++ x264-or/encoder/encoder.c 2009-10-28 15:05:29.000000000 +0100
|
504 |
|
|
@@ -62,6 +62,9 @@
|
505 |
|
|
|
506 |
|
|
static void x264_frame_dump( x264_t *h )
|
507 |
|
|
{
|
508 |
|
|
+ //printf("frame_dump()\n");
|
509 |
|
|
+ return;
|
510 |
|
|
+
|
511 |
|
|
FILE *f = fopen( h->param.psz_dump_yuv, "r+b" );
|
512 |
|
|
int i, y;
|
513 |
|
|
if( !f )
|
514 |
|
|
@@ -301,6 +304,7 @@
|
515 |
|
|
if( ( h->param.b_cabac && (h->cabac.p_end - h->cabac.p < 2500) )
|
516 |
|
|
|| ( h->out.bs.p_end - h->out.bs.p < 2500 ) )
|
517 |
|
|
{
|
518 |
|
|
+ //V(fprintf(stderr, "x264_bitstream_check_buffer: h->out.bs.p = 0x%.8x, h->out.bs.p_end = 0x%.8x\n",h->out.bs.p_end, h->out.bs.p ));
|
519 |
|
|
intptr_t delta;
|
520 |
|
|
int i;
|
521 |
|
|
|
522 |
|
|
@@ -695,6 +699,8 @@
|
523 |
|
|
static void mbcmp_init( x264_t *h )
|
524 |
|
|
{
|
525 |
|
|
int satd = !h->mb.b_lossless && h->param.analyse.i_subpel_refine > 1;
|
526 |
|
|
+ //V(if (satd)fprintf(stderr, "macroblock compare functions. satd enabled\n"));
|
527 |
|
|
+ //V(if (!satd)fprintf(stderr, "macroblock compare functions. satd not enabled\n"));
|
528 |
|
|
memcpy( h->pixf.mbcmp, satd ? h->pixf.satd : h->pixf.sad_aligned, sizeof(h->pixf.mbcmp) );
|
529 |
|
|
memcpy( h->pixf.mbcmp_unaligned, satd ? h->pixf.satd : h->pixf.sad, sizeof(h->pixf.mbcmp_unaligned) );
|
530 |
|
|
h->pixf.intra_mbcmp_x3_16x16 = satd ? h->pixf.intra_satd_x3_16x16 : h->pixf.intra_sad_x3_16x16;
|
531 |
|
|
@@ -750,15 +756,14 @@
|
532 |
|
|
x264_t *h;
|
533 |
|
|
char buf[1000], *p;
|
534 |
|
|
int i, qp, i_slicetype_length;
|
535 |
|
|
-
|
536 |
|
|
+
|
537 |
|
|
CHECKED_MALLOCZERO( h, sizeof(x264_t) );
|
538 |
|
|
-
|
539 |
|
|
+
|
540 |
|
|
/* Create a copy of param */
|
541 |
|
|
memcpy( &h->param, param, sizeof(x264_param_t) );
|
542 |
|
|
-
|
543 |
|
|
if( param->param_free )
|
544 |
|
|
param->param_free( param );
|
545 |
|
|
-
|
546 |
|
|
+
|
547 |
|
|
if( x264_validate_parameters( h ) < 0 )
|
548 |
|
|
goto fail;
|
549 |
|
|
|
550 |
|
|
@@ -772,7 +777,7 @@
|
551 |
|
|
h->param.rc.psz_stat_in = strdup( h->param.rc.psz_stat_in );
|
552 |
|
|
|
553 |
|
|
x264_set_aspect_ratio( h, param, 1 );
|
554 |
|
|
-
|
555 |
|
|
+
|
556 |
|
|
x264_reduce_fraction( &h->param.i_fps_num, &h->param.i_fps_den );
|
557 |
|
|
|
558 |
|
|
/* Init x264_t */
|
559 |
|
|
@@ -831,8 +836,8 @@
|
560 |
|
|
h->i_ref0 = 0;
|
561 |
|
|
h->i_ref1 = 0;
|
562 |
|
|
|
563 |
|
|
- x264_rdo_init();
|
564 |
|
|
-
|
565 |
|
|
+ x264_rdo_init();
|
566 |
|
|
+
|
567 |
|
|
/* init CPU functions */
|
568 |
|
|
x264_predict_16x16_init( h->param.cpu, h->predict_16x16 );
|
569 |
|
|
x264_predict_8x8c_init( h->param.cpu, h->predict_8x8c );
|
570 |
|
|
@@ -870,17 +875,25 @@
|
571 |
|
|
p += sprintf( p, " none!" );
|
572 |
|
|
x264_log( h, X264_LOG_INFO, "%s\n", buf );
|
573 |
|
|
|
574 |
|
|
+ /* // should skip during cycle accurate -- jb */
|
575 |
|
|
+ // Check the different quantisation points and their costs
|
576 |
|
|
for( qp = h->param.rc.i_qp_min; qp <= h->param.rc.i_qp_max; qp++ )
|
577 |
|
|
+ {
|
578 |
|
|
+ //printf("%d\n", qp);
|
579 |
|
|
if( x264_analyse_init_costs( h, qp ) )
|
580 |
|
|
- goto fail;
|
581 |
|
|
+ goto fail;
|
582 |
|
|
+ }
|
583 |
|
|
if( x264_analyse_init_costs( h, X264_LOOKAHEAD_QP ) )
|
584 |
|
|
goto fail;
|
585 |
|
|
if( h->cost_mv[1][2013] != 24 )
|
586 |
|
|
- {
|
587 |
|
|
+ {
|
588 |
|
|
+ //fprintf(stderr, "h->cost_mv[1][2013] = %d\n",h->cost_mv[1][2013]);
|
589 |
|
|
x264_log( h, X264_LOG_ERROR, "MV cost test failed: x264 has been miscompiled!\n" );
|
590 |
|
|
goto fail;
|
591 |
|
|
}
|
592 |
|
|
|
593 |
|
|
+ //exit(0); // jb
|
594 |
|
|
+
|
595 |
|
|
h->out.i_nal = 0;
|
596 |
|
|
h->out.i_bitstream = X264_MAX( 1000000, h->param.i_width * h->param.i_height * 4
|
597 |
|
|
* ( h->param.rc.i_rc_method == X264_RC_ABR ? pow( 0.95, h->param.rc.i_qp_min )
|
598 |
|
|
@@ -908,16 +921,17 @@
|
599 |
|
|
if( x264_macroblock_cache_init( h->thread[i] ) < 0 )
|
600 |
|
|
goto fail;
|
601 |
|
|
}
|
602 |
|
|
-
|
603 |
|
|
+
|
604 |
|
|
if( x264_lookahead_init( h, i_slicetype_length ) )
|
605 |
|
|
goto fail;
|
606 |
|
|
|
607 |
|
|
if( x264_ratecontrol_new( h ) < 0 )
|
608 |
|
|
goto fail;
|
609 |
|
|
-
|
610 |
|
|
+
|
611 |
|
|
+ /* // skip this for now, it's a fopen() call we won't really do, plus it's an option we'll never need --jb
|
612 |
|
|
if( h->param.psz_dump_yuv )
|
613 |
|
|
{
|
614 |
|
|
- /* create or truncate the reconstructed video file */
|
615 |
|
|
+ //create or truncate the reconstructed video file
|
616 |
|
|
FILE *f = fopen( h->param.psz_dump_yuv, "w" );
|
617 |
|
|
if( f )
|
618 |
|
|
fclose( f );
|
619 |
|
|
@@ -927,6 +941,8 @@
|
620 |
|
|
goto fail;
|
621 |
|
|
}
|
622 |
|
|
}
|
623 |
|
|
+ */
|
624 |
|
|
+
|
625 |
|
|
|
626 |
|
|
x264_log( h, X264_LOG_INFO, "profile %s, level %d.%d\n",
|
627 |
|
|
h->sps->i_profile_idc == PROFILE_BASELINE ? "Baseline" :
|
628 |
|
|
@@ -1307,6 +1323,8 @@
|
629 |
|
|
int slice_max_size = h->param.i_slice_max_size > 0 ? (h->param.i_slice_max_size-3-NALU_OVERHEAD)*8 : INT_MAX;
|
630 |
|
|
int starting_bits = bs_pos(&h->out.bs);
|
631 |
|
|
|
632 |
|
|
+ //V(fprintf(stderr, "x264_slice_write\n"));
|
633 |
|
|
+
|
634 |
|
|
/* Slice */
|
635 |
|
|
x264_nal_start( h, h->i_nal_type, h->i_nal_ref_idc );
|
636 |
|
|
|
637 |
|
|
@@ -1320,6 +1338,7 @@
|
638 |
|
|
/* init cabac */
|
639 |
|
|
x264_cabac_context_init( &h->cabac, h->sh.i_type, h->sh.i_qp, h->sh.i_cabac_init_idc );
|
640 |
|
|
x264_cabac_encode_init ( &h->cabac, h->out.bs.p, h->out.bs.p_end );
|
641 |
|
|
+ //V(fprintf(stderr, "\tcabac inited\n"));
|
642 |
|
|
}
|
643 |
|
|
h->mb.i_last_qp = h->sh.i_qp;
|
644 |
|
|
h->mb.i_last_dqp = 0;
|
645 |
|
|
@@ -1362,7 +1381,10 @@
|
646 |
|
|
x264_macroblock_encode( h );
|
647 |
|
|
|
648 |
|
|
if( x264_bitstream_check_buffer( h ) )
|
649 |
|
|
+ {
|
650 |
|
|
+ //V(fprintf(stderr, "\tx264_bitstream_check_buffer failed\n"));
|
651 |
|
|
return -1;
|
652 |
|
|
+ }
|
653 |
|
|
|
654 |
|
|
if( h->param.b_cabac )
|
655 |
|
|
{
|
656 |
|
|
@@ -1522,6 +1544,8 @@
|
657 |
|
|
x264_fdec_filter_row( h, h->sps->i_mb_height );
|
658 |
|
|
}
|
659 |
|
|
|
660 |
|
|
+ //V(fprintf(stderr, "x264_slice_write ok\n"));
|
661 |
|
|
+
|
662 |
|
|
return 0;
|
663 |
|
|
}
|
664 |
|
|
|
665 |
|
|
@@ -1625,8 +1649,8 @@
|
666 |
|
|
int i_nal_type, i;
|
667 |
|
|
int i_nal_ref_idc;
|
668 |
|
|
|
669 |
|
|
- int i_global_qp;
|
670 |
|
|
|
671 |
|
|
+ int i_global_qp;
|
672 |
|
|
if( h->param.i_threads > 1)
|
673 |
|
|
{
|
674 |
|
|
int i = ++h->i_thread_phase;
|
675 |
|
|
@@ -1653,6 +1677,7 @@
|
676 |
|
|
/* no data out */
|
677 |
|
|
*pi_nal = 0;
|
678 |
|
|
*pp_nal = NULL;
|
679 |
|
|
+
|
680 |
|
|
|
681 |
|
|
/* ------------------- Setup new frame from picture -------------------- */
|
682 |
|
|
if( pic_in != NULL )
|
683 |
|
|
@@ -1663,7 +1688,10 @@
|
684 |
|
|
return -1;
|
685 |
|
|
|
686 |
|
|
if( x264_frame_copy_picture( h, fenc, pic_in ) < 0 )
|
687 |
|
|
+ {
|
688 |
|
|
+ //V(fprintf(stderr, "x264_frame_copy_picture returned >0\n"));
|
689 |
|
|
return -1;
|
690 |
|
|
+ }
|
691 |
|
|
|
692 |
|
|
if( h->param.i_width != 16 * h->sps->i_mb_width ||
|
693 |
|
|
h->param.i_height != 16 * h->sps->i_mb_height )
|
694 |
|
|
@@ -1684,13 +1712,15 @@
|
695 |
|
|
|
696 |
|
|
/* 2: Place the frame into the queue for its slice type decision */
|
697 |
|
|
x264_lookahead_put_frame( h, fenc );
|
698 |
|
|
-
|
699 |
|
|
+
|
700 |
|
|
+ //V(fprintf(stderr, "x264_encoder_encode setup new frame from picture\n"));
|
701 |
|
|
+
|
702 |
|
|
if( h->frames.i_input <= h->frames.i_delay + 1 - h->param.i_threads )
|
703 |
|
|
{
|
704 |
|
|
/* Nothing yet to encode, waiting for filling of buffers */
|
705 |
|
|
pic_out->i_type = X264_TYPE_AUTO;
|
706 |
|
|
return 0;
|
707 |
|
|
- }
|
708 |
|
|
+ }
|
709 |
|
|
}
|
710 |
|
|
else
|
711 |
|
|
{
|
712 |
|
|
@@ -1873,7 +1903,10 @@
|
713 |
|
|
}
|
714 |
|
|
else
|
715 |
|
|
if( (intptr_t)x264_slices_write( h ) )
|
716 |
|
|
+ {
|
717 |
|
|
+ //V(fprintf(stderr, "x264_encoder_encode(): x264_slices_write() failed\n"));
|
718 |
|
|
return -1;
|
719 |
|
|
+ }
|
720 |
|
|
|
721 |
|
|
return x264_encoder_frame_end( thread_oldest, thread_current, pp_nal, pi_nal, pic_out );
|
722 |
|
|
}
|
723 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/encoder/me.c x264-or/encoder/me.c
|
724 |
|
|
--- x264/encoder/me.c 2009-10-25 17:41:10.000000000 +0100
|
725 |
|
|
+++ x264-or/encoder/me.c 2009-11-10 13:36:34.000000000 +0100
|
726 |
|
|
@@ -33,17 +33,17 @@
|
727 |
|
|
* the subme=8,9 values are much higher because any amount of satd search makes
|
728 |
|
|
* up its time by reducing the number of qpel-rd iterations. */
|
729 |
|
|
static const int subpel_iterations[][4] =
|
730 |
|
|
- {{0,0,0,0},
|
731 |
|
|
- {1,1,0,0},
|
732 |
|
|
- {0,1,1,0},
|
733 |
|
|
- {0,2,1,0},
|
734 |
|
|
- {0,2,1,1},
|
735 |
|
|
- {0,2,1,2},
|
736 |
|
|
- {0,0,2,2},
|
737 |
|
|
- {0,0,2,2},
|
738 |
|
|
- {0,0,4,10},
|
739 |
|
|
- {0,0,4,10},
|
740 |
|
|
- {0,0,4,10}};
|
741 |
|
|
+ {{0,0,0,0},
|
742 |
|
|
+ {1,1,0,0},
|
743 |
|
|
+ {0,1,1,0},
|
744 |
|
|
+ {0,2,1,0},
|
745 |
|
|
+ {0,2,1,1},
|
746 |
|
|
+ {0,2,1,2},
|
747 |
|
|
+ {0,0,2,2},
|
748 |
|
|
+ {0,0,2,2},
|
749 |
|
|
+ {0,0,4,10},
|
750 |
|
|
+ {0,0,4,10},
|
751 |
|
|
+ {0,0,4,10}};
|
752 |
|
|
|
753 |
|
|
/* (x-1)%6 */
|
754 |
|
|
static const int mod6m1[8] = {5,0,1,2,3,4,5,0};
|
755 |
|
|
@@ -53,1108 +53,1114 @@
|
756 |
|
|
|
757 |
|
|
static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_iters, int *p_halfpel_thresh, int b_refine_qpel );
|
758 |
|
|
|
759 |
|
|
-#define BITS_MVD( mx, my )\
|
760 |
|
|
- (p_cost_mvx[(mx)<<2] + p_cost_mvy[(my)<<2])
|
761 |
|
|
+#define BITS_MVD( mx, my ) \
|
762 |
|
|
+ (p_cost_mvx[(mx)<<2] + p_cost_mvy[(my)<<2])
|
763 |
|
|
|
764 |
|
|
-#define COST_MV( mx, my )\
|
765 |
|
|
-{\
|
766 |
|
|
- int cost = h->pixf.fpelcmp[i_pixel]( p_fenc, FENC_STRIDE,\
|
767 |
|
|
- &p_fref[(my)*stride+(mx)], stride )\
|
768 |
|
|
- + BITS_MVD(mx,my);\
|
769 |
|
|
- COPY3_IF_LT( bcost, cost, bmx, mx, bmy, my );\
|
770 |
|
|
-}
|
771 |
|
|
-
|
772 |
|
|
-#define COST_MV_HPEL( mx, my ) \
|
773 |
|
|
-{ \
|
774 |
|
|
- int stride2 = 16; \
|
775 |
|
|
+#define COST_MV( mx, my ) \
|
776 |
|
|
+ { \
|
777 |
|
|
+ int cost = h->pixf.fpelcmp[i_pixel]( p_fenc, FENC_STRIDE, \
|
778 |
|
|
+ &p_fref[(my)*stride+(mx)], stride ) \
|
779 |
|
|
+ + BITS_MVD(mx,my); \
|
780 |
|
|
+ COPY3_IF_LT( bcost, cost, bmx, mx, bmy, my ); \
|
781 |
|
|
+ }
|
782 |
|
|
+
|
783 |
|
|
+#define COST_MV_HPEL( mx, my ) \
|
784 |
|
|
+ { \
|
785 |
|
|
+ int stride2 = 16; \
|
786 |
|
|
uint8_t *src = h->mc.get_ref( pix, &stride2, m->p_fref, stride, mx, my, bw, bh ); \
|
787 |
|
|
int cost = h->pixf.fpelcmp[i_pixel]( p_fenc, FENC_STRIDE, src, stride2 ) \
|
788 |
|
|
- + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \
|
789 |
|
|
- COPY3_IF_LT( bpred_cost, cost, bpred_mx, mx, bpred_my, my ); \
|
790 |
|
|
-}
|
791 |
|
|
-
|
792 |
|
|
-#define COST_MV_X3_DIR( m0x, m0y, m1x, m1y, m2x, m2y, costs )\
|
793 |
|
|
-{\
|
794 |
|
|
- uint8_t *pix_base = p_fref + bmx + bmy*stride;\
|
795 |
|
|
- h->pixf.fpelcmp_x3[i_pixel]( p_fenc,\
|
796 |
|
|
- pix_base + (m0x) + (m0y)*stride,\
|
797 |
|
|
- pix_base + (m1x) + (m1y)*stride,\
|
798 |
|
|
- pix_base + (m2x) + (m2y)*stride,\
|
799 |
|
|
- stride, costs );\
|
800 |
|
|
- (costs)[0] += BITS_MVD( bmx+(m0x), bmy+(m0y) );\
|
801 |
|
|
- (costs)[1] += BITS_MVD( bmx+(m1x), bmy+(m1y) );\
|
802 |
|
|
- (costs)[2] += BITS_MVD( bmx+(m2x), bmy+(m2y) );\
|
803 |
|
|
-}
|
804 |
|
|
-
|
805 |
|
|
-#define COST_MV_X4_DIR( m0x, m0y, m1x, m1y, m2x, m2y, m3x, m3y, costs )\
|
806 |
|
|
-{\
|
807 |
|
|
- uint8_t *pix_base = p_fref + bmx + bmy*stride;\
|
808 |
|
|
- h->pixf.fpelcmp_x4[i_pixel]( p_fenc,\
|
809 |
|
|
- pix_base + (m0x) + (m0y)*stride,\
|
810 |
|
|
- pix_base + (m1x) + (m1y)*stride,\
|
811 |
|
|
- pix_base + (m2x) + (m2y)*stride,\
|
812 |
|
|
- pix_base + (m3x) + (m3y)*stride,\
|
813 |
|
|
- stride, costs );\
|
814 |
|
|
- (costs)[0] += BITS_MVD( bmx+(m0x), bmy+(m0y) );\
|
815 |
|
|
- (costs)[1] += BITS_MVD( bmx+(m1x), bmy+(m1y) );\
|
816 |
|
|
- (costs)[2] += BITS_MVD( bmx+(m2x), bmy+(m2y) );\
|
817 |
|
|
- (costs)[3] += BITS_MVD( bmx+(m3x), bmy+(m3y) );\
|
818 |
|
|
-}
|
819 |
|
|
-
|
820 |
|
|
-#define COST_MV_X4( m0x, m0y, m1x, m1y, m2x, m2y, m3x, m3y )\
|
821 |
|
|
-{\
|
822 |
|
|
- uint8_t *pix_base = p_fref + omx + omy*stride;\
|
823 |
|
|
- h->pixf.fpelcmp_x4[i_pixel]( p_fenc,\
|
824 |
|
|
- pix_base + (m0x) + (m0y)*stride,\
|
825 |
|
|
- pix_base + (m1x) + (m1y)*stride,\
|
826 |
|
|
- pix_base + (m2x) + (m2y)*stride,\
|
827 |
|
|
- pix_base + (m3x) + (m3y)*stride,\
|
828 |
|
|
- stride, costs );\
|
829 |
|
|
- costs[0] += BITS_MVD( omx+(m0x), omy+(m0y) );\
|
830 |
|
|
- costs[1] += BITS_MVD( omx+(m1x), omy+(m1y) );\
|
831 |
|
|
- costs[2] += BITS_MVD( omx+(m2x), omy+(m2y) );\
|
832 |
|
|
- costs[3] += BITS_MVD( omx+(m3x), omy+(m3y) );\
|
833 |
|
|
- COPY3_IF_LT( bcost, costs[0], bmx, omx+(m0x), bmy, omy+(m0y) );\
|
834 |
|
|
- COPY3_IF_LT( bcost, costs[1], bmx, omx+(m1x), bmy, omy+(m1y) );\
|
835 |
|
|
- COPY3_IF_LT( bcost, costs[2], bmx, omx+(m2x), bmy, omy+(m2y) );\
|
836 |
|
|
- COPY3_IF_LT( bcost, costs[3], bmx, omx+(m3x), bmy, omy+(m3y) );\
|
837 |
|
|
-}
|
838 |
|
|
-
|
839 |
|
|
-#define COST_MV_X3_ABS( m0x, m0y, m1x, m1y, m2x, m2y )\
|
840 |
|
|
-{\
|
841 |
|
|
- h->pixf.fpelcmp_x3[i_pixel]( p_fenc,\
|
842 |
|
|
- p_fref + (m0x) + (m0y)*stride,\
|
843 |
|
|
- p_fref + (m1x) + (m1y)*stride,\
|
844 |
|
|
- p_fref + (m2x) + (m2y)*stride,\
|
845 |
|
|
- stride, costs );\
|
846 |
|
|
- costs[0] += p_cost_mvx[(m0x)<<2]; /* no cost_mvy */\
|
847 |
|
|
- costs[1] += p_cost_mvx[(m1x)<<2];\
|
848 |
|
|
- costs[2] += p_cost_mvx[(m2x)<<2];\
|
849 |
|
|
- COPY3_IF_LT( bcost, costs[0], bmx, m0x, bmy, m0y );\
|
850 |
|
|
- COPY3_IF_LT( bcost, costs[1], bmx, m1x, bmy, m1y );\
|
851 |
|
|
- COPY3_IF_LT( bcost, costs[2], bmx, m2x, bmy, m2y );\
|
852 |
|
|
-}
|
853 |
|
|
+ + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \
|
854 |
|
|
+ COPY3_IF_LT( bpred_cost, cost, bpred_mx, mx, bpred_my, my ); \
|
855 |
|
|
+ }
|
856 |
|
|
+
|
857 |
|
|
+#define COST_MV_X3_DIR( m0x, m0y, m1x, m1y, m2x, m2y, costs ) \
|
858 |
|
|
+ { \
|
859 |
|
|
+ uint8_t *pix_base = p_fref + bmx + bmy*stride; \
|
860 |
|
|
+ h->pixf.fpelcmp_x3[i_pixel]( p_fenc, \
|
861 |
|
|
+ pix_base + (m0x) + (m0y)*stride, \
|
862 |
|
|
+ pix_base + (m1x) + (m1y)*stride, \
|
863 |
|
|
+ pix_base + (m2x) + (m2y)*stride, \
|
864 |
|
|
+ stride, costs ); \
|
865 |
|
|
+ (costs)[0] += BITS_MVD( bmx+(m0x), bmy+(m0y) ); \
|
866 |
|
|
+ (costs)[1] += BITS_MVD( bmx+(m1x), bmy+(m1y) ); \
|
867 |
|
|
+ (costs)[2] += BITS_MVD( bmx+(m2x), bmy+(m2y) ); \
|
868 |
|
|
+ }
|
869 |
|
|
+
|
870 |
|
|
+#define COST_MV_X4_DIR( m0x, m0y, m1x, m1y, m2x, m2y, m3x, m3y, costs ) \
|
871 |
|
|
+ { \
|
872 |
|
|
+ uint8_t *pix_base = p_fref + bmx + bmy*stride; \
|
873 |
|
|
+ h->pixf.fpelcmp_x4[i_pixel]( p_fenc, \
|
874 |
|
|
+ pix_base + (m0x) + (m0y)*stride, \
|
875 |
|
|
+ pix_base + (m1x) + (m1y)*stride, \
|
876 |
|
|
+ pix_base + (m2x) + (m2y)*stride, \
|
877 |
|
|
+ pix_base + (m3x) + (m3y)*stride, \
|
878 |
|
|
+ stride, costs ); \
|
879 |
|
|
+ (costs)[0] += BITS_MVD( bmx+(m0x), bmy+(m0y) ); \
|
880 |
|
|
+ (costs)[1] += BITS_MVD( bmx+(m1x), bmy+(m1y) ); \
|
881 |
|
|
+ (costs)[2] += BITS_MVD( bmx+(m2x), bmy+(m2y) ); \
|
882 |
|
|
+ (costs)[3] += BITS_MVD( bmx+(m3x), bmy+(m3y) ); \
|
883 |
|
|
+ }
|
884 |
|
|
+
|
885 |
|
|
+#define COST_MV_X4( m0x, m0y, m1x, m1y, m2x, m2y, m3x, m3y ) \
|
886 |
|
|
+ { \
|
887 |
|
|
+ uint8_t *pix_base = p_fref + omx + omy*stride; \
|
888 |
|
|
+ h->pixf.fpelcmp_x4[i_pixel]( p_fenc, \
|
889 |
|
|
+ pix_base + (m0x) + (m0y)*stride, \
|
890 |
|
|
+ pix_base + (m1x) + (m1y)*stride, \
|
891 |
|
|
+ pix_base + (m2x) + (m2y)*stride, \
|
892 |
|
|
+ pix_base + (m3x) + (m3y)*stride, \
|
893 |
|
|
+ stride, costs ); \
|
894 |
|
|
+ costs[0] += BITS_MVD( omx+(m0x), omy+(m0y) ); \
|
895 |
|
|
+ costs[1] += BITS_MVD( omx+(m1x), omy+(m1y) ); \
|
896 |
|
|
+ costs[2] += BITS_MVD( omx+(m2x), omy+(m2y) ); \
|
897 |
|
|
+ costs[3] += BITS_MVD( omx+(m3x), omy+(m3y) ); \
|
898 |
|
|
+ COPY3_IF_LT( bcost, costs[0], bmx, omx+(m0x), bmy, omy+(m0y) ); \
|
899 |
|
|
+ COPY3_IF_LT( bcost, costs[1], bmx, omx+(m1x), bmy, omy+(m1y) ); \
|
900 |
|
|
+ COPY3_IF_LT( bcost, costs[2], bmx, omx+(m2x), bmy, omy+(m2y) ); \
|
901 |
|
|
+ COPY3_IF_LT( bcost, costs[3], bmx, omx+(m3x), bmy, omy+(m3y) ); \
|
902 |
|
|
+ }
|
903 |
|
|
+
|
904 |
|
|
+#define COST_MV_X3_ABS( m0x, m0y, m1x, m1y, m2x, m2y ) \
|
905 |
|
|
+ { \
|
906 |
|
|
+ h->pixf.fpelcmp_x3[i_pixel]( p_fenc, \
|
907 |
|
|
+ p_fref + (m0x) + (m0y)*stride, \
|
908 |
|
|
+ p_fref + (m1x) + (m1y)*stride, \
|
909 |
|
|
+ p_fref + (m2x) + (m2y)*stride, \
|
910 |
|
|
+ stride, costs ); \
|
911 |
|
|
+ costs[0] += p_cost_mvx[(m0x)<<2]; /* no cost_mvy */ \
|
912 |
|
|
+ costs[1] += p_cost_mvx[(m1x)<<2]; \
|
913 |
|
|
+ costs[2] += p_cost_mvx[(m2x)<<2]; \
|
914 |
|
|
+ COPY3_IF_LT( bcost, costs[0], bmx, m0x, bmy, m0y ); \
|
915 |
|
|
+ COPY3_IF_LT( bcost, costs[1], bmx, m1x, bmy, m1y ); \
|
916 |
|
|
+ COPY3_IF_LT( bcost, costs[2], bmx, m2x, bmy, m2y ); \
|
917 |
|
|
+ }
|
918 |
|
|
|
919 |
|
|
/* 1 */
|
920 |
|
|
/* 101 */
|
921 |
|
|
/* 1 */
|
922 |
|
|
-#define DIA1_ITER( mx, my )\
|
923 |
|
|
-{\
|
924 |
|
|
- omx = mx; omy = my;\
|
925 |
|
|
- COST_MV_X4( 0,-1, 0,1, -1,0, 1,0 );\
|
926 |
|
|
-}
|
927 |
|
|
-
|
928 |
|
|
-#define CROSS( start, x_max, y_max )\
|
929 |
|
|
-{\
|
930 |
|
|
- i = start;\
|
931 |
|
|
- if( x_max <= X264_MIN(mv_x_max-omx, omx-mv_x_min) )\
|
932 |
|
|
- for( ; i < x_max-2; i+=4 )\
|
933 |
|
|
- COST_MV_X4( i,0, -i,0, i+2,0, -i-2,0 );\
|
934 |
|
|
- for( ; i < x_max; i+=2 )\
|
935 |
|
|
- {\
|
936 |
|
|
- if( omx+i <= mv_x_max )\
|
937 |
|
|
- COST_MV( omx+i, omy );\
|
938 |
|
|
- if( omx-i >= mv_x_min )\
|
939 |
|
|
- COST_MV( omx-i, omy );\
|
940 |
|
|
- }\
|
941 |
|
|
- i = start;\
|
942 |
|
|
- if( y_max <= X264_MIN(mv_y_max-omy, omy-mv_y_min) )\
|
943 |
|
|
- for( ; i < y_max-2; i+=4 )\
|
944 |
|
|
- COST_MV_X4( 0,i, 0,-i, 0,i+2, 0,-i-2 );\
|
945 |
|
|
- for( ; i < y_max; i+=2 )\
|
946 |
|
|
- {\
|
947 |
|
|
- if( omy+i <= mv_y_max )\
|
948 |
|
|
- COST_MV( omx, omy+i );\
|
949 |
|
|
- if( omy-i >= mv_y_min )\
|
950 |
|
|
- COST_MV( omx, omy-i );\
|
951 |
|
|
- }\
|
952 |
|
|
-}
|
953 |
|
|
+#define DIA1_ITER( mx, my ) \
|
954 |
|
|
+ { \
|
955 |
|
|
+ omx = mx; omy = my; \
|
956 |
|
|
+ COST_MV_X4( 0,-1, 0,1, -1,0, 1,0 ); \
|
957 |
|
|
+ }
|
958 |
|
|
+
|
959 |
|
|
+#define CROSS( start, x_max, y_max ) \
|
960 |
|
|
+ { \
|
961 |
|
|
+ i = start; \
|
962 |
|
|
+ if( x_max <= X264_MIN(mv_x_max-omx, omx-mv_x_min) ) \
|
963 |
|
|
+ for( ; i < x_max-2; i+=4 ) \
|
964 |
|
|
+ COST_MV_X4( i,0, -i,0, i+2,0, -i-2,0 ); \
|
965 |
|
|
+ for( ; i < x_max; i+=2 ) \
|
966 |
|
|
+ { \
|
967 |
|
|
+ if( omx+i <= mv_x_max ) \
|
968 |
|
|
+ COST_MV( omx+i, omy ); \
|
969 |
|
|
+ if( omx-i >= mv_x_min ) \
|
970 |
|
|
+ COST_MV( omx-i, omy ); \
|
971 |
|
|
+ } \
|
972 |
|
|
+ i = start; \
|
973 |
|
|
+ if( y_max <= X264_MIN(mv_y_max-omy, omy-mv_y_min) ) \
|
974 |
|
|
+ for( ; i < y_max-2; i+=4 ) \
|
975 |
|
|
+ COST_MV_X4( 0,i, 0,-i, 0,i+2, 0,-i-2 ); \
|
976 |
|
|
+ for( ; i < y_max; i+=2 ) \
|
977 |
|
|
+ { \
|
978 |
|
|
+ if( omy+i <= mv_y_max ) \
|
979 |
|
|
+ COST_MV( omx, omy+i ); \
|
980 |
|
|
+ if( omy-i >= mv_y_min ) \
|
981 |
|
|
+ COST_MV( omx, omy-i ); \
|
982 |
|
|
+ } \
|
983 |
|
|
+ }
|
984 |
|
|
|
985 |
|
|
void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_halfpel_thresh )
|
986 |
|
|
{
|
987 |
|
|
- const int bw = x264_pixel_size[m->i_pixel].w;
|
988 |
|
|
- const int bh = x264_pixel_size[m->i_pixel].h;
|
989 |
|
|
- const int i_pixel = m->i_pixel;
|
990 |
|
|
- const int stride = m->i_stride[0];
|
991 |
|
|
- int i_me_range = h->param.analyse.i_me_range;
|
992 |
|
|
- int bmx, bmy, bcost;
|
993 |
|
|
- int bpred_mx = 0, bpred_my = 0, bpred_cost = COST_MAX;
|
994 |
|
|
- int omx, omy, pmx, pmy;
|
995 |
|
|
- uint8_t *p_fenc = m->p_fenc[0];
|
996 |
|
|
- uint8_t *p_fref = m->p_fref[0];
|
997 |
|
|
- ALIGNED_ARRAY_16( uint8_t, pix,[16*16] );
|
998 |
|
|
-
|
999 |
|
|
- int i, j;
|
1000 |
|
|
- int dir;
|
1001 |
|
|
- int costs[16];
|
1002 |
|
|
-
|
1003 |
|
|
- int mv_x_min = h->mb.mv_min_fpel[0];
|
1004 |
|
|
- int mv_y_min = h->mb.mv_min_fpel[1];
|
1005 |
|
|
- int mv_x_max = h->mb.mv_max_fpel[0];
|
1006 |
|
|
- int mv_y_max = h->mb.mv_max_fpel[1];
|
1007 |
|
|
+ const int bw = x264_pixel_size[m->i_pixel].w; // x264_pixel_size[] in common/pixel.h
|
1008 |
|
|
+ const int bh = x264_pixel_size[m->i_pixel].h;
|
1009 |
|
|
+ const int i_pixel = m->i_pixel; // macroblock pixel size
|
1010 |
|
|
+ const int stride = m->i_stride[0]; // array stride (usually used only in Y direction)
|
1011 |
|
|
+ int i_me_range = h->param.analyse.i_me_range; /* integer pixel motion estimation search range (from predicted mv) */
|
1012 |
|
|
+ int bmx, bmy, bcost;
|
1013 |
|
|
+ int bpred_mx = 0, bpred_my = 0, bpred_cost = COST_MAX;
|
1014 |
|
|
+ int omx, omy, pmx, pmy;
|
1015 |
|
|
+ uint8_t *p_fenc = m->p_fenc[0];
|
1016 |
|
|
+ uint8_t *p_fref = m->p_fref[0];
|
1017 |
|
|
+ //V(fprintf(stderr, "s264_me_search_ref *p_fenc = 0x%.8x *p_fref = 0x%.8x\n", (unsigned long) p_fenc, (unsigned long) p_fref));
|
1018 |
|
|
+ ALIGNED_ARRAY_16( uint8_t, pix,[16*16] );
|
1019 |
|
|
+
|
1020 |
|
|
+ int i, j;
|
1021 |
|
|
+ int dir;
|
1022 |
|
|
+ int costs[16];
|
1023 |
|
|
+
|
1024 |
|
|
+ //fprintf(stderr, "x264_me_search_ref: x264_t *h = 0x%.8x\n", (unsigned int) h);
|
1025 |
|
|
+ /* Ranges for MVs - perhaps we're on/near the frame boarder and can't go beyond it, these ranges indicate that. They're set in x264_mb_analyse_init() */
|
1026 |
|
|
+ int mv_x_min = h->mb.mv_min_fpel[0];
|
1027 |
|
|
+ int mv_y_min = h->mb.mv_min_fpel[1];
|
1028 |
|
|
+ int mv_x_max = h->mb.mv_max_fpel[0];
|
1029 |
|
|
+ int mv_y_max = h->mb.mv_max_fpel[1];
|
1030 |
|
|
|
1031 |
|
|
#define CHECK_MVRANGE(mx,my) ( mx >= mv_x_min && mx <= mv_x_max && my >= mv_y_min && my <= mv_y_max )
|
1032 |
|
|
|
1033 |
|
|
- const uint16_t *p_cost_mvx = m->p_cost_mv - m->mvp[0];
|
1034 |
|
|
- const uint16_t *p_cost_mvy = m->p_cost_mv - m->mvp[1];
|
1035 |
|
|
-
|
1036 |
|
|
- bmx = x264_clip3( m->mvp[0], mv_x_min*4, mv_x_max*4 );
|
1037 |
|
|
- bmy = x264_clip3( m->mvp[1], mv_y_min*4, mv_y_max*4 );
|
1038 |
|
|
- pmx = ( bmx + 2 ) >> 2;
|
1039 |
|
|
- pmy = ( bmy + 2 ) >> 2;
|
1040 |
|
|
- bcost = COST_MAX;
|
1041 |
|
|
+ const uint16_t *p_cost_mvx = m->p_cost_mv - m->mvp[0];
|
1042 |
|
|
+ const uint16_t *p_cost_mvy = m->p_cost_mv - m->mvp[1];
|
1043 |
|
|
+ //V(fprintf(stderr, "p_cost_mvx: 0x%.8x, ( m->p_cost_mv: 0x%.8x m->mvp[0]: 0x%.8x )p_cost_mvy: 0x%.8x (m->p_cost_mv: 0x%.8x m->mvp[1]: 0x%.8x)\n", (unsigned long) p_cost_mvx, (unsigned long) m->p_cost_mv, (unsigned long) m->mvp[0], (unsigned long) p_cost_mvy, (unsigned long) m->p_cost_mv, (unsigned long) m->mvp[1]));
|
1044 |
|
|
+
|
1045 |
|
|
+ /* m->mvp has the media MV (x in [0] and y in [1]) */
|
1046 |
|
|
+ bmx = x264_clip3( m->mvp[0], mv_x_min*4, mv_x_max*4 );
|
1047 |
|
|
+ bmy = x264_clip3( m->mvp[1], mv_y_min*4, mv_y_max*4 );
|
1048 |
|
|
+ pmx = ( bmx + 2 ) >> 2;
|
1049 |
|
|
+ pmy = ( bmy + 2 ) >> 2;
|
1050 |
|
|
+ bcost = COST_MAX;
|
1051 |
|
|
|
1052 |
|
|
- /* try extra predictors if provided */
|
1053 |
|
|
- if( h->mb.i_subpel_refine >= 3 )
|
1054 |
|
|
+ /* try extra predictors if provided */
|
1055 |
|
|
+ if( h->mb.i_subpel_refine >= 3 )
|
1056 |
|
|
{
|
1057 |
|
|
- uint32_t bmv = pack16to32_mask(bmx,bmy);
|
1058 |
|
|
- COST_MV_HPEL( bmx, bmy );
|
1059 |
|
|
- for( i = 0; i < i_mvc; i++ )
|
1060 |
|
|
+ uint32_t bmv = pack16to32_mask(bmx,bmy);
|
1061 |
|
|
+ COST_MV_HPEL( bmx, bmy );
|
1062 |
|
|
+ for( i = 0; i < i_mvc; i++ )
|
1063 |
|
|
{
|
1064 |
|
|
- if( *(uint32_t*)mvc[i] && (bmv - *(uint32_t*)mvc[i]) )
|
1065 |
|
|
+ if( *(uint32_t*)mvc[i] && (bmv - *(uint32_t*)mvc[i]) )
|
1066 |
|
|
{
|
1067 |
|
|
- int mx = x264_clip3( mvc[i][0], mv_x_min*4, mv_x_max*4 );
|
1068 |
|
|
- int my = x264_clip3( mvc[i][1], mv_y_min*4, mv_y_max*4 );
|
1069 |
|
|
- COST_MV_HPEL( mx, my );
|
1070 |
|
|
+ int mx = x264_clip3( mvc[i][0], mv_x_min*4, mv_x_max*4 );
|
1071 |
|
|
+ int my = x264_clip3( mvc[i][1], mv_y_min*4, mv_y_max*4 );
|
1072 |
|
|
+ COST_MV_HPEL( mx, my );
|
1073 |
|
|
}
|
1074 |
|
|
}
|
1075 |
|
|
- bmx = ( bpred_mx + 2 ) >> 2;
|
1076 |
|
|
- bmy = ( bpred_my + 2 ) >> 2;
|
1077 |
|
|
- COST_MV( bmx, bmy );
|
1078 |
|
|
+ bmx = ( bpred_mx + 2 ) >> 2;
|
1079 |
|
|
+ bmy = ( bpred_my + 2 ) >> 2;
|
1080 |
|
|
+ COST_MV( bmx, bmy );
|
1081 |
|
|
}
|
1082 |
|
|
- else
|
1083 |
|
|
+ else
|
1084 |
|
|
{
|
1085 |
|
|
- /* check the MVP */
|
1086 |
|
|
- COST_MV( pmx, pmy );
|
1087 |
|
|
- /* Because we are rounding the predicted motion vector to fullpel, there will be
|
1088 |
|
|
- * an extra MV cost in 15 out of 16 cases. However, when the predicted MV is
|
1089 |
|
|
- * chosen as the best predictor, it is often the case that the subpel search will
|
1090 |
|
|
- * result in a vector at or next to the predicted motion vector. Therefore, it is
|
1091 |
|
|
- * sensible to remove the cost of the MV from the rounded MVP to avoid unfairly
|
1092 |
|
|
- * biasing against use of the predicted motion vector. */
|
1093 |
|
|
- bcost -= BITS_MVD( pmx, pmy );
|
1094 |
|
|
- for( i = 0; i < i_mvc; i++ )
|
1095 |
|
|
+ /* check the MVP */
|
1096 |
|
|
+ COST_MV( pmx, pmy );
|
1097 |
|
|
+ /* Because we are rounding the predicted motion vector to fullpel, there will be
|
1098 |
|
|
+ * an extra MV cost in 15 out of 16 cases. However, when the predicted MV is
|
1099 |
|
|
+ * chosen as the best predictor, it is often the case that the subpel search will
|
1100 |
|
|
+ * result in a vector at or next to the predicted motion vector. Therefore, it is
|
1101 |
|
|
+ * sensible to remove the cost of the MV from the rounded MVP to avoid unfairly
|
1102 |
|
|
+ * biasing against use of the predicted motion vector. */
|
1103 |
|
|
+ bcost -= BITS_MVD( pmx, pmy );
|
1104 |
|
|
+ for( i = 0; i < i_mvc; i++ )
|
1105 |
|
|
{
|
1106 |
|
|
- int mx = (mvc[i][0] + 2) >> 2;
|
1107 |
|
|
- int my = (mvc[i][1] + 2) >> 2;
|
1108 |
|
|
- if( (mx | my) && ((mx-bmx) | (my-bmy)) )
|
1109 |
|
|
+ int mx = (mvc[i][0] + 2) >> 2;
|
1110 |
|
|
+ int my = (mvc[i][1] + 2) >> 2;
|
1111 |
|
|
+ if( (mx | my) && ((mx-bmx) | (my-bmy)) )
|
1112 |
|
|
{
|
1113 |
|
|
- mx = x264_clip3( mx, mv_x_min, mv_x_max );
|
1114 |
|
|
- my = x264_clip3( my, mv_y_min, mv_y_max );
|
1115 |
|
|
- COST_MV( mx, my );
|
1116 |
|
|
+ mx = x264_clip3( mx, mv_x_min, mv_x_max );
|
1117 |
|
|
+ my = x264_clip3( my, mv_y_min, mv_y_max );
|
1118 |
|
|
+ COST_MV( mx, my );
|
1119 |
|
|
}
|
1120 |
|
|
}
|
1121 |
|
|
}
|
1122 |
|
|
- COST_MV( 0, 0 );
|
1123 |
|
|
+ COST_MV( 0, 0 );
|
1124 |
|
|
|
1125 |
|
|
- switch( h->mb.i_me_method )
|
1126 |
|
|
+ switch( h->mb.i_me_method )
|
1127 |
|
|
{
|
1128 |
|
|
case X264_ME_DIA:
|
1129 |
|
|
- /* diamond search, radius 1 */
|
1130 |
|
|
- i = 0;
|
1131 |
|
|
- bcost <<= 4;
|
1132 |
|
|
- do
|
1133 |
|
|
+ /* diamond search, radius 1 */
|
1134 |
|
|
+ //V(fprintf(stderr, "x264_me_search_ref; diamond search. *p_fenc = 0x%.8x *p_fref = 0x%.8x\n", (unsigned long) p_fenc, (unsigned long) p_fref));
|
1135 |
|
|
+ i = 0;
|
1136 |
|
|
+ bcost <<= 4;
|
1137 |
|
|
+ do
|
1138 |
|
|
{
|
1139 |
|
|
- COST_MV_X4_DIR( 0,-1, 0,1, -1,0, 1,0, costs );
|
1140 |
|
|
- COPY1_IF_LT( bcost, (costs[0]<<4)+1 );
|
1141 |
|
|
- COPY1_IF_LT( bcost, (costs[1]<<4)+3 );
|
1142 |
|
|
- COPY1_IF_LT( bcost, (costs[2]<<4)+4 );
|
1143 |
|
|
- COPY1_IF_LT( bcost, (costs[3]<<4)+12 );
|
1144 |
|
|
- if( !(bcost&15) )
|
1145 |
|
|
- break;
|
1146 |
|
|
- bmx -= (bcost<<28)>>30;
|
1147 |
|
|
- bmy -= (bcost<<30)>>30;
|
1148 |
|
|
- bcost &= ~15;
|
1149 |
|
|
- if( !CHECK_MVRANGE(bmx, bmy) )
|
1150 |
|
|
- break;
|
1151 |
|
|
+ COST_MV_X4_DIR( 0,-1, 0,1, -1,0, 1,0, costs );
|
1152 |
|
|
+ COPY1_IF_LT( bcost, (costs[0]<<4)+1 );
|
1153 |
|
|
+ COPY1_IF_LT( bcost, (costs[1]<<4)+3 );
|
1154 |
|
|
+ COPY1_IF_LT( bcost, (costs[2]<<4)+4 );
|
1155 |
|
|
+ COPY1_IF_LT( bcost, (costs[3]<<4)+12 );
|
1156 |
|
|
+ if( !(bcost&15) )
|
1157 |
|
|
+ break;
|
1158 |
|
|
+ bmx -= (bcost<<28)>>30;
|
1159 |
|
|
+ bmy -= (bcost<<30)>>30;
|
1160 |
|
|
+ bcost &= ~15;
|
1161 |
|
|
+ if( !CHECK_MVRANGE(bmx, bmy) )
|
1162 |
|
|
+ break;
|
1163 |
|
|
} while( ++i < i_me_range );
|
1164 |
|
|
- bcost >>= 4;
|
1165 |
|
|
- break;
|
1166 |
|
|
+ bcost >>= 4;
|
1167 |
|
|
+ break;
|
1168 |
|
|
|
1169 |
|
|
case X264_ME_HEX:
|
1170 |
|
|
-me_hex2:
|
1171 |
|
|
- /* hexagon search, radius 2 */
|
1172 |
|
|
+ me_hex2:
|
1173 |
|
|
+ /* hexagon search, radius 2 */
|
1174 |
|
|
#if 0
|
1175 |
|
|
- for( i = 0; i < i_me_range/2; i++ )
|
1176 |
|
|
+ for( i = 0; i < i_me_range/2; i++ )
|
1177 |
|
|
{
|
1178 |
|
|
- omx = bmx; omy = bmy;
|
1179 |
|
|
- COST_MV( omx-2, omy );
|
1180 |
|
|
- COST_MV( omx-1, omy+2 );
|
1181 |
|
|
- COST_MV( omx+1, omy+2 );
|
1182 |
|
|
- COST_MV( omx+2, omy );
|
1183 |
|
|
- COST_MV( omx+1, omy-2 );
|
1184 |
|
|
- COST_MV( omx-1, omy-2 );
|
1185 |
|
|
- if( bmx == omx && bmy == omy )
|
1186 |
|
|
- break;
|
1187 |
|
|
- if( !CHECK_MVRANGE(bmx, bmy) )
|
1188 |
|
|
- break;
|
1189 |
|
|
+ omx = bmx; omy = bmy;
|
1190 |
|
|
+ COST_MV( omx-2, omy );
|
1191 |
|
|
+ COST_MV( omx-1, omy+2 );
|
1192 |
|
|
+ COST_MV( omx+1, omy+2 );
|
1193 |
|
|
+ COST_MV( omx+2, omy );
|
1194 |
|
|
+ COST_MV( omx+1, omy-2 );
|
1195 |
|
|
+ COST_MV( omx-1, omy-2 );
|
1196 |
|
|
+ if( bmx == omx && bmy == omy )
|
1197 |
|
|
+ break;
|
1198 |
|
|
+ if( !CHECK_MVRANGE(bmx, bmy) )
|
1199 |
|
|
+ break;
|
1200 |
|
|
}
|
1201 |
|
|
#else
|
1202 |
|
|
- /* equivalent to the above, but eliminates duplicate candidates */
|
1203 |
|
|
+ /* equivalent to the above, but eliminates duplicate candidates */
|
1204 |
|
|
|
1205 |
|
|
- /* hexagon */
|
1206 |
|
|
- COST_MV_X3_DIR( -2,0, -1, 2, 1, 2, costs );
|
1207 |
|
|
- COST_MV_X3_DIR( 2,0, 1,-2, -1,-2, costs+3 );
|
1208 |
|
|
- bcost <<= 3;
|
1209 |
|
|
- COPY1_IF_LT( bcost, (costs[0]<<3)+2 );
|
1210 |
|
|
- COPY1_IF_LT( bcost, (costs[1]<<3)+3 );
|
1211 |
|
|
- COPY1_IF_LT( bcost, (costs[2]<<3)+4 );
|
1212 |
|
|
- COPY1_IF_LT( bcost, (costs[3]<<3)+5 );
|
1213 |
|
|
- COPY1_IF_LT( bcost, (costs[4]<<3)+6 );
|
1214 |
|
|
- COPY1_IF_LT( bcost, (costs[5]<<3)+7 );
|
1215 |
|
|
+ /* hexagon */
|
1216 |
|
|
+ COST_MV_X3_DIR( -2,0, -1, 2, 1, 2, costs );
|
1217 |
|
|
+ COST_MV_X3_DIR( 2,0, 1,-2, -1,-2, costs+3 );
|
1218 |
|
|
+ bcost <<= 3;
|
1219 |
|
|
+ COPY1_IF_LT( bcost, (costs[0]<<3)+2 );
|
1220 |
|
|
+ COPY1_IF_LT( bcost, (costs[1]<<3)+3 );
|
1221 |
|
|
+ COPY1_IF_LT( bcost, (costs[2]<<3)+4 );
|
1222 |
|
|
+ COPY1_IF_LT( bcost, (costs[3]<<3)+5 );
|
1223 |
|
|
+ COPY1_IF_LT( bcost, (costs[4]<<3)+6 );
|
1224 |
|
|
+ COPY1_IF_LT( bcost, (costs[5]<<3)+7 );
|
1225 |
|
|
|
1226 |
|
|
- if( bcost&7 )
|
1227 |
|
|
+ if( bcost&7 )
|
1228 |
|
|
{
|
1229 |
|
|
- dir = (bcost&7)-2;
|
1230 |
|
|
- bmx += hex2[dir+1][0];
|
1231 |
|
|
- bmy += hex2[dir+1][1];
|
1232 |
|
|
- /* half hexagon, not overlapping the previous iteration */
|
1233 |
|
|
- for( i = 1; i < i_me_range/2 && CHECK_MVRANGE(bmx, bmy); i++ )
|
1234 |
|
|
+ dir = (bcost&7)-2;
|
1235 |
|
|
+ bmx += hex2[dir+1][0];
|
1236 |
|
|
+ bmy += hex2[dir+1][1];
|
1237 |
|
|
+ /* half hexagon, not overlapping the previous iteration */
|
1238 |
|
|
+ for( i = 1; i < i_me_range/2 && CHECK_MVRANGE(bmx, bmy); i++ )
|
1239 |
|
|
{
|
1240 |
|
|
- COST_MV_X3_DIR( hex2[dir+0][0], hex2[dir+0][1],
|
1241 |
|
|
- hex2[dir+1][0], hex2[dir+1][1],
|
1242 |
|
|
- hex2[dir+2][0], hex2[dir+2][1],
|
1243 |
|
|
- costs );
|
1244 |
|
|
- bcost &= ~7;
|
1245 |
|
|
- COPY1_IF_LT( bcost, (costs[0]<<3)+1 );
|
1246 |
|
|
- COPY1_IF_LT( bcost, (costs[1]<<3)+2 );
|
1247 |
|
|
- COPY1_IF_LT( bcost, (costs[2]<<3)+3 );
|
1248 |
|
|
- if( !(bcost&7) )
|
1249 |
|
|
- break;
|
1250 |
|
|
- dir += (bcost&7)-2;
|
1251 |
|
|
- dir = mod6m1[dir+1];
|
1252 |
|
|
- bmx += hex2[dir+1][0];
|
1253 |
|
|
- bmy += hex2[dir+1][1];
|
1254 |
|
|
+ COST_MV_X3_DIR( hex2[dir+0][0], hex2[dir+0][1],
|
1255 |
|
|
+ hex2[dir+1][0], hex2[dir+1][1],
|
1256 |
|
|
+ hex2[dir+2][0], hex2[dir+2][1],
|
1257 |
|
|
+ costs );
|
1258 |
|
|
+ bcost &= ~7;
|
1259 |
|
|
+ COPY1_IF_LT( bcost, (costs[0]<<3)+1 );
|
1260 |
|
|
+ COPY1_IF_LT( bcost, (costs[1]<<3)+2 );
|
1261 |
|
|
+ COPY1_IF_LT( bcost, (costs[2]<<3)+3 );
|
1262 |
|
|
+ if( !(bcost&7) )
|
1263 |
|
|
+ break;
|
1264 |
|
|
+ dir += (bcost&7)-2;
|
1265 |
|
|
+ dir = mod6m1[dir+1];
|
1266 |
|
|
+ bmx += hex2[dir+1][0];
|
1267 |
|
|
+ bmy += hex2[dir+1][1];
|
1268 |
|
|
}
|
1269 |
|
|
}
|
1270 |
|
|
- bcost >>= 3;
|
1271 |
|
|
+ bcost >>= 3;
|
1272 |
|
|
#endif
|
1273 |
|
|
- /* square refine */
|
1274 |
|
|
- dir = 0;
|
1275 |
|
|
- COST_MV_X4_DIR( 0,-1, 0,1, -1,0, 1,0, costs );
|
1276 |
|
|
- COPY2_IF_LT( bcost, costs[0], dir, 1 );
|
1277 |
|
|
- COPY2_IF_LT( bcost, costs[1], dir, 2 );
|
1278 |
|
|
- COPY2_IF_LT( bcost, costs[2], dir, 3 );
|
1279 |
|
|
- COPY2_IF_LT( bcost, costs[3], dir, 4 );
|
1280 |
|
|
- COST_MV_X4_DIR( -1,-1, -1,1, 1,-1, 1,1, costs );
|
1281 |
|
|
- COPY2_IF_LT( bcost, costs[0], dir, 5 );
|
1282 |
|
|
- COPY2_IF_LT( bcost, costs[1], dir, 6 );
|
1283 |
|
|
- COPY2_IF_LT( bcost, costs[2], dir, 7 );
|
1284 |
|
|
- COPY2_IF_LT( bcost, costs[3], dir, 8 );
|
1285 |
|
|
- bmx += square1[dir][0];
|
1286 |
|
|
- bmy += square1[dir][1];
|
1287 |
|
|
- break;
|
1288 |
|
|
+ /* square refine */
|
1289 |
|
|
+ dir = 0;
|
1290 |
|
|
+ COST_MV_X4_DIR( 0,-1, 0,1, -1,0, 1,0, costs );
|
1291 |
|
|
+ COPY2_IF_LT( bcost, costs[0], dir, 1 );
|
1292 |
|
|
+ COPY2_IF_LT( bcost, costs[1], dir, 2 );
|
1293 |
|
|
+ COPY2_IF_LT( bcost, costs[2], dir, 3 );
|
1294 |
|
|
+ COPY2_IF_LT( bcost, costs[3], dir, 4 );
|
1295 |
|
|
+ COST_MV_X4_DIR( -1,-1, -1,1, 1,-1, 1,1, costs );
|
1296 |
|
|
+ COPY2_IF_LT( bcost, costs[0], dir, 5 );
|
1297 |
|
|
+ COPY2_IF_LT( bcost, costs[1], dir, 6 );
|
1298 |
|
|
+ COPY2_IF_LT( bcost, costs[2], dir, 7 );
|
1299 |
|
|
+ COPY2_IF_LT( bcost, costs[3], dir, 8 );
|
1300 |
|
|
+ bmx += square1[dir][0];
|
1301 |
|
|
+ bmy += square1[dir][1];
|
1302 |
|
|
+ break;
|
1303 |
|
|
|
1304 |
|
|
case X264_ME_UMH:
|
1305 |
|
|
- {
|
1306 |
|
|
- /* Uneven-cross Multi-Hexagon-grid Search
|
1307 |
|
|
- * as in JM, except with different early termination */
|
1308 |
|
|
-
|
1309 |
|
|
- static const int x264_pixel_size_shift[7] = { 0, 1, 1, 2, 3, 3, 4 };
|
1310 |
|
|
-
|
1311 |
|
|
- int ucost1, ucost2;
|
1312 |
|
|
- int cross_start = 1;
|
1313 |
|
|
+ {
|
1314 |
|
|
+ /* Uneven-cross Multi-Hexagon-grid Search
|
1315 |
|
|
+ * as in JM, except with different early termination */
|
1316 |
|
|
+
|
1317 |
|
|
+ static const int x264_pixel_size_shift[7] = { 0, 1, 1, 2, 3, 3, 4 };
|
1318 |
|
|
+
|
1319 |
|
|
+ int ucost1, ucost2;
|
1320 |
|
|
+ int cross_start = 1;
|
1321 |
|
|
+
|
1322 |
|
|
+ /* refine predictors */
|
1323 |
|
|
+ ucost1 = bcost;
|
1324 |
|
|
+ DIA1_ITER( pmx, pmy );
|
1325 |
|
|
+ if( pmx | pmy )
|
1326 |
|
|
+ DIA1_ITER( 0, 0 );
|
1327 |
|
|
+
|
1328 |
|
|
+ if(i_pixel == PIXEL_4x4)
|
1329 |
|
|
+ goto me_hex2;
|
1330 |
|
|
+
|
1331 |
|
|
+ ucost2 = bcost;
|
1332 |
|
|
+ if( (bmx | bmy) && ((bmx-pmx) | (bmy-pmy)) )
|
1333 |
|
|
+ DIA1_ITER( bmx, bmy );
|
1334 |
|
|
+ if( bcost == ucost2 )
|
1335 |
|
|
+ cross_start = 3;
|
1336 |
|
|
+ omx = bmx; omy = bmy;
|
1337 |
|
|
|
1338 |
|
|
- /* refine predictors */
|
1339 |
|
|
- ucost1 = bcost;
|
1340 |
|
|
- DIA1_ITER( pmx, pmy );
|
1341 |
|
|
- if( pmx | pmy )
|
1342 |
|
|
- DIA1_ITER( 0, 0 );
|
1343 |
|
|
-
|
1344 |
|
|
- if(i_pixel == PIXEL_4x4)
|
1345 |
|
|
- goto me_hex2;
|
1346 |
|
|
-
|
1347 |
|
|
- ucost2 = bcost;
|
1348 |
|
|
- if( (bmx | bmy) && ((bmx-pmx) | (bmy-pmy)) )
|
1349 |
|
|
- DIA1_ITER( bmx, bmy );
|
1350 |
|
|
- if( bcost == ucost2 )
|
1351 |
|
|
- cross_start = 3;
|
1352 |
|
|
- omx = bmx; omy = bmy;
|
1353 |
|
|
-
|
1354 |
|
|
- /* early termination */
|
1355 |
|
|
+ /* early termination */
|
1356 |
|
|
#define SAD_THRESH(v) ( bcost < ( v >> x264_pixel_size_shift[i_pixel] ) )
|
1357 |
|
|
- if( bcost == ucost2 && SAD_THRESH(2000) )
|
1358 |
|
|
- {
|
1359 |
|
|
- COST_MV_X4( 0,-2, -1,-1, 1,-1, -2,0 );
|
1360 |
|
|
- COST_MV_X4( 2, 0, -1, 1, 1, 1, 0,2 );
|
1361 |
|
|
- if( bcost == ucost1 && SAD_THRESH(500) )
|
1362 |
|
|
- break;
|
1363 |
|
|
- if( bcost == ucost2 )
|
1364 |
|
|
- {
|
1365 |
|
|
- int range = (i_me_range>>1) | 1;
|
1366 |
|
|
- CROSS( 3, range, range );
|
1367 |
|
|
- COST_MV_X4( -1,-2, 1,-2, -2,-1, 2,-1 );
|
1368 |
|
|
- COST_MV_X4( -2, 1, 2, 1, -1, 2, 1, 2 );
|
1369 |
|
|
- if( bcost == ucost2 )
|
1370 |
|
|
- break;
|
1371 |
|
|
- cross_start = range + 2;
|
1372 |
|
|
- }
|
1373 |
|
|
- }
|
1374 |
|
|
-
|
1375 |
|
|
- /* adaptive search range */
|
1376 |
|
|
- if( i_mvc )
|
1377 |
|
|
- {
|
1378 |
|
|
- /* range multipliers based on casual inspection of some statistics of
|
1379 |
|
|
- * average distance between current predictor and final mv found by ESA.
|
1380 |
|
|
- * these have not been tuned much by actual encoding. */
|
1381 |
|
|
- static const int range_mul[4][4] =
|
1382 |
|
|
- {
|
1383 |
|
|
- { 3, 3, 4, 4 },
|
1384 |
|
|
- { 3, 4, 4, 4 },
|
1385 |
|
|
- { 4, 4, 4, 5 },
|
1386 |
|
|
- { 4, 4, 5, 6 },
|
1387 |
|
|
- };
|
1388 |
|
|
- int mvd;
|
1389 |
|
|
- int sad_ctx, mvd_ctx;
|
1390 |
|
|
- int denom = 1;
|
1391 |
|
|
-
|
1392 |
|
|
- if( i_mvc == 1 )
|
1393 |
|
|
- {
|
1394 |
|
|
- if( i_pixel == PIXEL_16x16 )
|
1395 |
|
|
- /* mvc is probably the same as mvp, so the difference isn't meaningful.
|
1396 |
|
|
- * but prediction usually isn't too bad, so just use medium range */
|
1397 |
|
|
- mvd = 25;
|
1398 |
|
|
- else
|
1399 |
|
|
- mvd = abs( m->mvp[0] - mvc[0][0] )
|
1400 |
|
|
- + abs( m->mvp[1] - mvc[0][1] );
|
1401 |
|
|
- }
|
1402 |
|
|
- else
|
1403 |
|
|
- {
|
1404 |
|
|
- /* calculate the degree of agreement between predictors. */
|
1405 |
|
|
- /* in 16x16, mvc includes all the neighbors used to make mvp,
|
1406 |
|
|
- * so don't count mvp separately. */
|
1407 |
|
|
- denom = i_mvc - 1;
|
1408 |
|
|
- mvd = 0;
|
1409 |
|
|
- if( i_pixel != PIXEL_16x16 )
|
1410 |
|
|
- {
|
1411 |
|
|
- mvd = abs( m->mvp[0] - mvc[0][0] )
|
1412 |
|
|
- + abs( m->mvp[1] - mvc[0][1] );
|
1413 |
|
|
- denom++;
|
1414 |
|
|
- }
|
1415 |
|
|
- mvd += x264_predictor_difference( mvc, i_mvc );
|
1416 |
|
|
- }
|
1417 |
|
|
-
|
1418 |
|
|
- sad_ctx = SAD_THRESH(1000) ? 0
|
1419 |
|
|
- : SAD_THRESH(2000) ? 1
|
1420 |
|
|
- : SAD_THRESH(4000) ? 2 : 3;
|
1421 |
|
|
- mvd_ctx = mvd < 10*denom ? 0
|
1422 |
|
|
- : mvd < 20*denom ? 1
|
1423 |
|
|
- : mvd < 40*denom ? 2 : 3;
|
1424 |
|
|
-
|
1425 |
|
|
- i_me_range = i_me_range * range_mul[mvd_ctx][sad_ctx] / 4;
|
1426 |
|
|
- }
|
1427 |
|
|
-
|
1428 |
|
|
- /* FIXME if the above DIA2/OCT2/CROSS found a new mv, it has not updated omx/omy.
|
1429 |
|
|
- * we are still centered on the same place as the DIA2. is this desirable? */
|
1430 |
|
|
- CROSS( cross_start, i_me_range, i_me_range/2 );
|
1431 |
|
|
-
|
1432 |
|
|
- COST_MV_X4( -2,-2, -2,2, 2,-2, 2,2 );
|
1433 |
|
|
-
|
1434 |
|
|
- /* hexagon grid */
|
1435 |
|
|
- omx = bmx; omy = bmy;
|
1436 |
|
|
- const uint16_t *p_cost_omvx = p_cost_mvx + omx*4;
|
1437 |
|
|
- const uint16_t *p_cost_omvy = p_cost_mvy + omy*4;
|
1438 |
|
|
- i = 1;
|
1439 |
|
|
- do
|
1440 |
|
|
- {
|
1441 |
|
|
- static const int hex4[16][2] = {
|
1442 |
|
|
- { 0,-4}, { 0, 4}, {-2,-3}, { 2,-3},
|
1443 |
|
|
- {-4,-2}, { 4,-2}, {-4,-1}, { 4,-1},
|
1444 |
|
|
- {-4, 0}, { 4, 0}, {-4, 1}, { 4, 1},
|
1445 |
|
|
- {-4, 2}, { 4, 2}, {-2, 3}, { 2, 3},
|
1446 |
|
|
- };
|
1447 |
|
|
-
|
1448 |
|
|
- if( 4*i > X264_MIN4( mv_x_max-omx, omx-mv_x_min,
|
1449 |
|
|
- mv_y_max-omy, omy-mv_y_min ) )
|
1450 |
|
|
- {
|
1451 |
|
|
- for( j = 0; j < 16; j++ )
|
1452 |
|
|
- {
|
1453 |
|
|
- int mx = omx + hex4[j][0]*i;
|
1454 |
|
|
- int my = omy + hex4[j][1]*i;
|
1455 |
|
|
- if( CHECK_MVRANGE(mx, my) )
|
1456 |
|
|
- COST_MV( mx, my );
|
1457 |
|
|
- }
|
1458 |
|
|
- }
|
1459 |
|
|
- else
|
1460 |
|
|
- {
|
1461 |
|
|
- int dir = 0;
|
1462 |
|
|
- uint8_t *pix_base = p_fref + omx + (omy-4*i)*stride;
|
1463 |
|
|
- int dy = i*stride;
|
1464 |
|
|
-#define SADS(k,x0,y0,x1,y1,x2,y2,x3,y3)\
|
1465 |
|
|
- h->pixf.fpelcmp_x4[i_pixel]( p_fenc,\
|
1466 |
|
|
- pix_base x0*i+(y0-2*k+4)*dy,\
|
1467 |
|
|
- pix_base x1*i+(y1-2*k+4)*dy,\
|
1468 |
|
|
- pix_base x2*i+(y2-2*k+4)*dy,\
|
1469 |
|
|
- pix_base x3*i+(y3-2*k+4)*dy,\
|
1470 |
|
|
- stride, costs+4*k );\
|
1471 |
|
|
- pix_base += 2*dy;
|
1472 |
|
|
+ if( bcost == ucost2 && SAD_THRESH(2000) )
|
1473 |
|
|
+ {
|
1474 |
|
|
+ COST_MV_X4( 0,-2, -1,-1, 1,-1, -2,0 );
|
1475 |
|
|
+ COST_MV_X4( 2, 0, -1, 1, 1, 1, 0,2 );
|
1476 |
|
|
+ if( bcost == ucost1 && SAD_THRESH(500) )
|
1477 |
|
|
+ break;
|
1478 |
|
|
+ if( bcost == ucost2 )
|
1479 |
|
|
+ {
|
1480 |
|
|
+ int range = (i_me_range>>1) | 1;
|
1481 |
|
|
+ CROSS( 3, range, range );
|
1482 |
|
|
+ COST_MV_X4( -1,-2, 1,-2, -2,-1, 2,-1 );
|
1483 |
|
|
+ COST_MV_X4( -2, 1, 2, 1, -1, 2, 1, 2 );
|
1484 |
|
|
+ if( bcost == ucost2 )
|
1485 |
|
|
+ break;
|
1486 |
|
|
+ cross_start = range + 2;
|
1487 |
|
|
+ }
|
1488 |
|
|
+ }
|
1489 |
|
|
+
|
1490 |
|
|
+ /* adaptive search range */
|
1491 |
|
|
+ if( i_mvc )
|
1492 |
|
|
+ {
|
1493 |
|
|
+ /* range multipliers based on casual inspection of some statistics of
|
1494 |
|
|
+ * average distance between current predictor and final mv found by ESA.
|
1495 |
|
|
+ * these have not been tuned much by actual encoding. */
|
1496 |
|
|
+ static const int range_mul[4][4] =
|
1497 |
|
|
+ {
|
1498 |
|
|
+ { 3, 3, 4, 4 },
|
1499 |
|
|
+ { 3, 4, 4, 4 },
|
1500 |
|
|
+ { 4, 4, 4, 5 },
|
1501 |
|
|
+ { 4, 4, 5, 6 },
|
1502 |
|
|
+ };
|
1503 |
|
|
+ int mvd;
|
1504 |
|
|
+ int sad_ctx, mvd_ctx;
|
1505 |
|
|
+ int denom = 1;
|
1506 |
|
|
+
|
1507 |
|
|
+ if( i_mvc == 1 )
|
1508 |
|
|
+ {
|
1509 |
|
|
+ if( i_pixel == PIXEL_16x16 )
|
1510 |
|
|
+ /* mvc is probably the same as mvp, so the difference isn't meaningful.
|
1511 |
|
|
+ * but prediction usually isn't too bad, so just use medium range */
|
1512 |
|
|
+ mvd = 25;
|
1513 |
|
|
+ else
|
1514 |
|
|
+ mvd = abs( m->mvp[0] - mvc[0][0] )
|
1515 |
|
|
+ + abs( m->mvp[1] - mvc[0][1] );
|
1516 |
|
|
+ }
|
1517 |
|
|
+ else
|
1518 |
|
|
+ {
|
1519 |
|
|
+ /* calculate the degree of agreement between predictors. */
|
1520 |
|
|
+ /* in 16x16, mvc includes all the neighbors used to make mvp,
|
1521 |
|
|
+ * so don't count mvp separately. */
|
1522 |
|
|
+ denom = i_mvc - 1;
|
1523 |
|
|
+ mvd = 0;
|
1524 |
|
|
+ if( i_pixel != PIXEL_16x16 )
|
1525 |
|
|
+ {
|
1526 |
|
|
+ mvd = abs( m->mvp[0] - mvc[0][0] )
|
1527 |
|
|
+ + abs( m->mvp[1] - mvc[0][1] );
|
1528 |
|
|
+ denom++;
|
1529 |
|
|
+ }
|
1530 |
|
|
+ mvd += x264_predictor_difference( mvc, i_mvc );
|
1531 |
|
|
+ }
|
1532 |
|
|
+
|
1533 |
|
|
+ sad_ctx = SAD_THRESH(1000) ? 0
|
1534 |
|
|
+ : SAD_THRESH(2000) ? 1
|
1535 |
|
|
+ : SAD_THRESH(4000) ? 2 : 3;
|
1536 |
|
|
+ mvd_ctx = mvd < 10*denom ? 0
|
1537 |
|
|
+ : mvd < 20*denom ? 1
|
1538 |
|
|
+ : mvd < 40*denom ? 2 : 3;
|
1539 |
|
|
+
|
1540 |
|
|
+ i_me_range = i_me_range * range_mul[mvd_ctx][sad_ctx] / 4;
|
1541 |
|
|
+ }
|
1542 |
|
|
+
|
1543 |
|
|
+ /* FIXME if the above DIA2/OCT2/CROSS found a new mv, it has not updated omx/omy.
|
1544 |
|
|
+ * we are still centered on the same place as the DIA2. is this desirable? */
|
1545 |
|
|
+ CROSS( cross_start, i_me_range, i_me_range/2 );
|
1546 |
|
|
+
|
1547 |
|
|
+ COST_MV_X4( -2,-2, -2,2, 2,-2, 2,2 );
|
1548 |
|
|
+
|
1549 |
|
|
+ /* hexagon grid */
|
1550 |
|
|
+ omx = bmx; omy = bmy;
|
1551 |
|
|
+ const uint16_t *p_cost_omvx = p_cost_mvx + omx*4;
|
1552 |
|
|
+ const uint16_t *p_cost_omvy = p_cost_mvy + omy*4;
|
1553 |
|
|
+ i = 1;
|
1554 |
|
|
+ do
|
1555 |
|
|
+ {
|
1556 |
|
|
+ static const int hex4[16][2] = {
|
1557 |
|
|
+ { 0,-4}, { 0, 4}, {-2,-3}, { 2,-3},
|
1558 |
|
|
+ {-4,-2}, { 4,-2}, {-4,-1}, { 4,-1},
|
1559 |
|
|
+ {-4, 0}, { 4, 0}, {-4, 1}, { 4, 1},
|
1560 |
|
|
+ {-4, 2}, { 4, 2}, {-2, 3}, { 2, 3},
|
1561 |
|
|
+ };
|
1562 |
|
|
+
|
1563 |
|
|
+ if( 4*i > X264_MIN4( mv_x_max-omx, omx-mv_x_min,
|
1564 |
|
|
+ mv_y_max-omy, omy-mv_y_min ) )
|
1565 |
|
|
+ {
|
1566 |
|
|
+ for( j = 0; j < 16; j++ )
|
1567 |
|
|
+ {
|
1568 |
|
|
+ int mx = omx + hex4[j][0]*i;
|
1569 |
|
|
+ int my = omy + hex4[j][1]*i;
|
1570 |
|
|
+ if( CHECK_MVRANGE(mx, my) )
|
1571 |
|
|
+ COST_MV( mx, my );
|
1572 |
|
|
+ }
|
1573 |
|
|
+ }
|
1574 |
|
|
+ else
|
1575 |
|
|
+ {
|
1576 |
|
|
+ int dir = 0;
|
1577 |
|
|
+ uint8_t *pix_base = p_fref + omx + (omy-4*i)*stride;
|
1578 |
|
|
+ int dy = i*stride;
|
1579 |
|
|
+#define SADS(k,x0,y0,x1,y1,x2,y2,x3,y3) \
|
1580 |
|
|
+ h->pixf.fpelcmp_x4[i_pixel]( p_fenc, \
|
1581 |
|
|
+ pix_base x0*i+(y0-2*k+4)*dy, \
|
1582 |
|
|
+ pix_base x1*i+(y1-2*k+4)*dy, \
|
1583 |
|
|
+ pix_base x2*i+(y2-2*k+4)*dy, \
|
1584 |
|
|
+ pix_base x3*i+(y3-2*k+4)*dy, \
|
1585 |
|
|
+ stride, costs+4*k ); \
|
1586 |
|
|
+ pix_base += 2*dy;
|
1587 |
|
|
#define ADD_MVCOST(k,x,y) costs[k] += p_cost_omvx[x*4*i] + p_cost_omvy[y*4*i]
|
1588 |
|
|
#define MIN_MV(k,x,y) COPY2_IF_LT( bcost, costs[k], dir, x*16+(y&15) )
|
1589 |
|
|
- SADS( 0, +0,-4, +0,+4, -2,-3, +2,-3 );
|
1590 |
|
|
- SADS( 1, -4,-2, +4,-2, -4,-1, +4,-1 );
|
1591 |
|
|
- SADS( 2, -4,+0, +4,+0, -4,+1, +4,+1 );
|
1592 |
|
|
- SADS( 3, -4,+2, +4,+2, -2,+3, +2,+3 );
|
1593 |
|
|
- ADD_MVCOST( 0, 0,-4 );
|
1594 |
|
|
- ADD_MVCOST( 1, 0, 4 );
|
1595 |
|
|
- ADD_MVCOST( 2,-2,-3 );
|
1596 |
|
|
- ADD_MVCOST( 3, 2,-3 );
|
1597 |
|
|
- ADD_MVCOST( 4,-4,-2 );
|
1598 |
|
|
- ADD_MVCOST( 5, 4,-2 );
|
1599 |
|
|
- ADD_MVCOST( 6,-4,-1 );
|
1600 |
|
|
- ADD_MVCOST( 7, 4,-1 );
|
1601 |
|
|
- ADD_MVCOST( 8,-4, 0 );
|
1602 |
|
|
- ADD_MVCOST( 9, 4, 0 );
|
1603 |
|
|
- ADD_MVCOST( 10,-4, 1 );
|
1604 |
|
|
- ADD_MVCOST( 11, 4, 1 );
|
1605 |
|
|
- ADD_MVCOST( 12,-4, 2 );
|
1606 |
|
|
- ADD_MVCOST( 13, 4, 2 );
|
1607 |
|
|
- ADD_MVCOST( 14,-2, 3 );
|
1608 |
|
|
- ADD_MVCOST( 15, 2, 3 );
|
1609 |
|
|
- MIN_MV( 0, 0,-4 );
|
1610 |
|
|
- MIN_MV( 1, 0, 4 );
|
1611 |
|
|
- MIN_MV( 2,-2,-3 );
|
1612 |
|
|
- MIN_MV( 3, 2,-3 );
|
1613 |
|
|
- MIN_MV( 4,-4,-2 );
|
1614 |
|
|
- MIN_MV( 5, 4,-2 );
|
1615 |
|
|
- MIN_MV( 6,-4,-1 );
|
1616 |
|
|
- MIN_MV( 7, 4,-1 );
|
1617 |
|
|
- MIN_MV( 8,-4, 0 );
|
1618 |
|
|
- MIN_MV( 9, 4, 0 );
|
1619 |
|
|
- MIN_MV( 10,-4, 1 );
|
1620 |
|
|
- MIN_MV( 11, 4, 1 );
|
1621 |
|
|
- MIN_MV( 12,-4, 2 );
|
1622 |
|
|
- MIN_MV( 13, 4, 2 );
|
1623 |
|
|
- MIN_MV( 14,-2, 3 );
|
1624 |
|
|
- MIN_MV( 15, 2, 3 );
|
1625 |
|
|
+ SADS( 0, +0,-4, +0,+4, -2,-3, +2,-3 );
|
1626 |
|
|
+ SADS( 1, -4,-2, +4,-2, -4,-1, +4,-1 );
|
1627 |
|
|
+ SADS( 2, -4,+0, +4,+0, -4,+1, +4,+1 );
|
1628 |
|
|
+ SADS( 3, -4,+2, +4,+2, -2,+3, +2,+3 );
|
1629 |
|
|
+ ADD_MVCOST( 0, 0,-4 );
|
1630 |
|
|
+ ADD_MVCOST( 1, 0, 4 );
|
1631 |
|
|
+ ADD_MVCOST( 2,-2,-3 );
|
1632 |
|
|
+ ADD_MVCOST( 3, 2,-3 );
|
1633 |
|
|
+ ADD_MVCOST( 4,-4,-2 );
|
1634 |
|
|
+ ADD_MVCOST( 5, 4,-2 );
|
1635 |
|
|
+ ADD_MVCOST( 6,-4,-1 );
|
1636 |
|
|
+ ADD_MVCOST( 7, 4,-1 );
|
1637 |
|
|
+ ADD_MVCOST( 8,-4, 0 );
|
1638 |
|
|
+ ADD_MVCOST( 9, 4, 0 );
|
1639 |
|
|
+ ADD_MVCOST( 10,-4, 1 );
|
1640 |
|
|
+ ADD_MVCOST( 11, 4, 1 );
|
1641 |
|
|
+ ADD_MVCOST( 12,-4, 2 );
|
1642 |
|
|
+ ADD_MVCOST( 13, 4, 2 );
|
1643 |
|
|
+ ADD_MVCOST( 14,-2, 3 );
|
1644 |
|
|
+ ADD_MVCOST( 15, 2, 3 );
|
1645 |
|
|
+ MIN_MV( 0, 0,-4 );
|
1646 |
|
|
+ MIN_MV( 1, 0, 4 );
|
1647 |
|
|
+ MIN_MV( 2,-2,-3 );
|
1648 |
|
|
+ MIN_MV( 3, 2,-3 );
|
1649 |
|
|
+ MIN_MV( 4,-4,-2 );
|
1650 |
|
|
+ MIN_MV( 5, 4,-2 );
|
1651 |
|
|
+ MIN_MV( 6,-4,-1 );
|
1652 |
|
|
+ MIN_MV( 7, 4,-1 );
|
1653 |
|
|
+ MIN_MV( 8,-4, 0 );
|
1654 |
|
|
+ MIN_MV( 9, 4, 0 );
|
1655 |
|
|
+ MIN_MV( 10,-4, 1 );
|
1656 |
|
|
+ MIN_MV( 11, 4, 1 );
|
1657 |
|
|
+ MIN_MV( 12,-4, 2 );
|
1658 |
|
|
+ MIN_MV( 13, 4, 2 );
|
1659 |
|
|
+ MIN_MV( 14,-2, 3 );
|
1660 |
|
|
+ MIN_MV( 15, 2, 3 );
|
1661 |
|
|
#undef SADS
|
1662 |
|
|
#undef ADD_MVCOST
|
1663 |
|
|
#undef MIN_MV
|
1664 |
|
|
- if(dir)
|
1665 |
|
|
- {
|
1666 |
|
|
- bmx = omx + i*(dir>>4);
|
1667 |
|
|
- bmy = omy + i*((dir<<28)>>28);
|
1668 |
|
|
- }
|
1669 |
|
|
- }
|
1670 |
|
|
- } while( ++i <= i_me_range/4 );
|
1671 |
|
|
- if( bmy <= mv_y_max && bmy >= mv_y_min )
|
1672 |
|
|
- goto me_hex2;
|
1673 |
|
|
- break;
|
1674 |
|
|
- }
|
1675 |
|
|
+ if(dir)
|
1676 |
|
|
+ {
|
1677 |
|
|
+ bmx = omx + i*(dir>>4);
|
1678 |
|
|
+ bmy = omy + i*((dir<<28)>>28);
|
1679 |
|
|
+ }
|
1680 |
|
|
+ }
|
1681 |
|
|
+ } while( ++i <= i_me_range/4 );
|
1682 |
|
|
+ if( bmy <= mv_y_max && bmy >= mv_y_min )
|
1683 |
|
|
+ goto me_hex2;
|
1684 |
|
|
+ break;
|
1685 |
|
|
+ }
|
1686 |
|
|
|
1687 |
|
|
case X264_ME_ESA:
|
1688 |
|
|
case X264_ME_TESA:
|
1689 |
|
|
- {
|
1690 |
|
|
- const int min_x = X264_MAX( bmx - i_me_range, mv_x_min );
|
1691 |
|
|
- const int min_y = X264_MAX( bmy - i_me_range, mv_y_min );
|
1692 |
|
|
- const int max_x = X264_MIN( bmx + i_me_range, mv_x_max );
|
1693 |
|
|
- const int max_y = X264_MIN( bmy + i_me_range, mv_y_max );
|
1694 |
|
|
- /* SEA is fastest in multiples of 4 */
|
1695 |
|
|
- const int width = (max_x - min_x + 3) & ~3;
|
1696 |
|
|
- int my;
|
1697 |
|
|
+ {
|
1698 |
|
|
+ const int min_x = X264_MAX( bmx - i_me_range, mv_x_min );
|
1699 |
|
|
+ const int min_y = X264_MAX( bmy - i_me_range, mv_y_min );
|
1700 |
|
|
+ const int max_x = X264_MIN( bmx + i_me_range, mv_x_max );
|
1701 |
|
|
+ const int max_y = X264_MIN( bmy + i_me_range, mv_y_max );
|
1702 |
|
|
+ /* SEA is fastest in multiples of 4 */
|
1703 |
|
|
+ const int width = (max_x - min_x + 3) & ~3;
|
1704 |
|
|
+ int my;
|
1705 |
|
|
#if 0
|
1706 |
|
|
- /* plain old exhaustive search */
|
1707 |
|
|
- int mx;
|
1708 |
|
|
- for( my = min_y; my <= max_y; my++ )
|
1709 |
|
|
- for( mx = min_x; mx <= max_x; mx++ )
|
1710 |
|
|
- COST_MV( mx, my );
|
1711 |
|
|
+ /* plain old exhaustive search */
|
1712 |
|
|
+ int mx;
|
1713 |
|
|
+ for( my = min_y; my <= max_y; my++ )
|
1714 |
|
|
+ for( mx = min_x; mx <= max_x; mx++ )
|
1715 |
|
|
+ COST_MV( mx, my );
|
1716 |
|
|
#else
|
1717 |
|
|
- /* successive elimination by comparing DC before a full SAD,
|
1718 |
|
|
- * because sum(abs(diff)) >= abs(diff(sum)). */
|
1719 |
|
|
- uint16_t *sums_base = m->integral;
|
1720 |
|
|
- /* due to a GCC bug on some platforms (win32?), zero[] may not actually be aligned.
|
1721 |
|
|
- * this is not a problem because it is not used for any SSE instructions. */
|
1722 |
|
|
- ALIGNED_16( static uint8_t zero[8*FENC_STRIDE] );
|
1723 |
|
|
- ALIGNED_ARRAY_16( int, enc_dc,[4] );
|
1724 |
|
|
- int sad_size = i_pixel <= PIXEL_8x8 ? PIXEL_8x8 : PIXEL_4x4;
|
1725 |
|
|
- int delta = x264_pixel_size[sad_size].w;
|
1726 |
|
|
- int16_t *xs = h->scratch_buffer;
|
1727 |
|
|
- int xn;
|
1728 |
|
|
- uint16_t *cost_fpel_mvx = h->cost_mv_fpel[x264_lambda_tab[h->mb.i_qp]][-m->mvp[0]&3] + (-m->mvp[0]>>2);
|
1729 |
|
|
-
|
1730 |
|
|
- h->pixf.sad_x4[sad_size]( zero, p_fenc, p_fenc+delta,
|
1731 |
|
|
- p_fenc+delta*FENC_STRIDE, p_fenc+delta+delta*FENC_STRIDE,
|
1732 |
|
|
- FENC_STRIDE, enc_dc );
|
1733 |
|
|
- if( delta == 4 )
|
1734 |
|
|
- sums_base += stride * (h->fenc->i_lines[0] + PADV*2);
|
1735 |
|
|
- if( i_pixel == PIXEL_16x16 || i_pixel == PIXEL_8x16 || i_pixel == PIXEL_4x8 )
|
1736 |
|
|
- delta *= stride;
|
1737 |
|
|
- if( i_pixel == PIXEL_8x16 || i_pixel == PIXEL_4x8 )
|
1738 |
|
|
- enc_dc[1] = enc_dc[2];
|
1739 |
|
|
-
|
1740 |
|
|
- if( h->mb.i_me_method == X264_ME_TESA )
|
1741 |
|
|
- {
|
1742 |
|
|
- // ADS threshold, then SAD threshold, then keep the best few SADs, then SATD
|
1743 |
|
|
- mvsad_t *mvsads = (mvsad_t *)(xs + ((width+15)&~15));
|
1744 |
|
|
- int nmvsad = 0, limit;
|
1745 |
|
|
- int sad_thresh = i_me_range <= 16 ? 10 : i_me_range <= 24 ? 11 : 12;
|
1746 |
|
|
- int bsad = h->pixf.sad[i_pixel]( p_fenc, FENC_STRIDE, p_fref+bmy*stride+bmx, stride )
|
1747 |
|
|
- + BITS_MVD( bmx, bmy );
|
1748 |
|
|
- for( my = min_y; my <= max_y; my++ )
|
1749 |
|
|
- {
|
1750 |
|
|
- int ycost = p_cost_mvy[my<<2];
|
1751 |
|
|
- if( bsad <= ycost )
|
1752 |
|
|
- continue;
|
1753 |
|
|
- bsad -= ycost;
|
1754 |
|
|
- xn = h->pixf.ads[i_pixel]( enc_dc, sums_base + min_x + my * stride, delta,
|
1755 |
|
|
- cost_fpel_mvx+min_x, xs, width, bsad*17/16 );
|
1756 |
|
|
- for( i=0; i<xn-2; i+=3 )
|
1757 |
|
|
- {
|
1758 |
|
|
- uint8_t *ref = p_fref+min_x+my*stride;
|
1759 |
|
|
- int sads[3];
|
1760 |
|
|
- h->pixf.sad_x3[i_pixel]( p_fenc, ref+xs[i], ref+xs[i+1], ref+xs[i+2], stride, sads );
|
1761 |
|
|
- for( j=0; j<3; j++ )
|
1762 |
|
|
- {
|
1763 |
|
|
- int sad = sads[j] + cost_fpel_mvx[xs[i+j]];
|
1764 |
|
|
- if( sad < bsad*sad_thresh>>3 )
|
1765 |
|
|
- {
|
1766 |
|
|
- COPY1_IF_LT( bsad, sad );
|
1767 |
|
|
- mvsads[nmvsad].sad = sad + ycost;
|
1768 |
|
|
- mvsads[nmvsad].mx = min_x+xs[i+j];
|
1769 |
|
|
- mvsads[nmvsad].my = my;
|
1770 |
|
|
- nmvsad++;
|
1771 |
|
|
- }
|
1772 |
|
|
- }
|
1773 |
|
|
- }
|
1774 |
|
|
- for( ; i<xn; i++ )
|
1775 |
|
|
- {
|
1776 |
|
|
- int mx = min_x+xs[i];
|
1777 |
|
|
- int sad = h->pixf.sad[i_pixel]( p_fenc, FENC_STRIDE, p_fref+mx+my*stride, stride )
|
1778 |
|
|
- + cost_fpel_mvx[xs[i]];
|
1779 |
|
|
- if( sad < bsad*sad_thresh>>3 )
|
1780 |
|
|
- {
|
1781 |
|
|
- COPY1_IF_LT( bsad, sad );
|
1782 |
|
|
- mvsads[nmvsad].sad = sad + ycost;
|
1783 |
|
|
- mvsads[nmvsad].mx = mx;
|
1784 |
|
|
- mvsads[nmvsad].my = my;
|
1785 |
|
|
- nmvsad++;
|
1786 |
|
|
- }
|
1787 |
|
|
- }
|
1788 |
|
|
- bsad += ycost;
|
1789 |
|
|
- }
|
1790 |
|
|
-
|
1791 |
|
|
- limit = i_me_range / 2;
|
1792 |
|
|
- sad_thresh = bsad*sad_thresh>>3;
|
1793 |
|
|
- while( nmvsad > limit*2 && sad_thresh > bsad )
|
1794 |
|
|
- {
|
1795 |
|
|
- // halve the range if the domain is too large... eh, close enough
|
1796 |
|
|
- sad_thresh = (sad_thresh + bsad) >> 1;
|
1797 |
|
|
- for( i=0; i<nmvsad && mvsads[i].sad <= sad_thresh; i++ );
|
1798 |
|
|
- for( j=i; j<nmvsad; j++ )
|
1799 |
|
|
- {
|
1800 |
|
|
- /* mvsad_t is not guaranteed to be 8 bytes on all archs, so check before using explicit write-combining */
|
1801 |
|
|
- if( sizeof( mvsad_t ) == sizeof( uint64_t ) )
|
1802 |
|
|
- *(uint64_t*)&mvsads[i] = *(uint64_t*)&mvsads[j];
|
1803 |
|
|
- else
|
1804 |
|
|
- mvsads[i] = mvsads[j];
|
1805 |
|
|
- i += mvsads[j].sad <= sad_thresh;
|
1806 |
|
|
- }
|
1807 |
|
|
- nmvsad = i;
|
1808 |
|
|
- }
|
1809 |
|
|
- while( nmvsad > limit )
|
1810 |
|
|
- {
|
1811 |
|
|
- int bsad = mvsads[0].sad;
|
1812 |
|
|
- int bi = 0;
|
1813 |
|
|
- for( i=1; i<nmvsad; i++ )
|
1814 |
|
|
- COPY2_IF_GT( bsad, mvsads[i].sad, bi, i );
|
1815 |
|
|
- nmvsad--;
|
1816 |
|
|
- mvsads[bi] = mvsads[nmvsad];
|
1817 |
|
|
- if( sizeof( mvsad_t ) == sizeof( uint64_t ) )
|
1818 |
|
|
- *(uint64_t*)&mvsads[bi] = *(uint64_t*)&mvsads[nmvsad];
|
1819 |
|
|
- else
|
1820 |
|
|
- mvsads[bi] = mvsads[nmvsad];
|
1821 |
|
|
- }
|
1822 |
|
|
- for( i=0; i<nmvsad; i++ )
|
1823 |
|
|
- COST_MV( mvsads[i].mx, mvsads[i].my );
|
1824 |
|
|
- }
|
1825 |
|
|
- else
|
1826 |
|
|
- {
|
1827 |
|
|
- // just ADS and SAD
|
1828 |
|
|
- for( my = min_y; my <= max_y; my++ )
|
1829 |
|
|
- {
|
1830 |
|
|
- int ycost = p_cost_mvy[my<<2];
|
1831 |
|
|
- if( bcost <= ycost )
|
1832 |
|
|
- continue;
|
1833 |
|
|
- bcost -= ycost;
|
1834 |
|
|
- xn = h->pixf.ads[i_pixel]( enc_dc, sums_base + min_x + my * stride, delta,
|
1835 |
|
|
- cost_fpel_mvx+min_x, xs, width, bcost );
|
1836 |
|
|
- for( i=0; i<xn-2; i+=3 )
|
1837 |
|
|
- COST_MV_X3_ABS( min_x+xs[i],my, min_x+xs[i+1],my, min_x+xs[i+2],my );
|
1838 |
|
|
- bcost += ycost;
|
1839 |
|
|
- for( ; i<xn; i++ )
|
1840 |
|
|
- COST_MV( min_x+xs[i], my );
|
1841 |
|
|
- }
|
1842 |
|
|
- }
|
1843 |
|
|
+ /* successive elimination by comparing DC before a full SAD,
|
1844 |
|
|
+ * because sum(abs(diff)) >= abs(diff(sum)). */
|
1845 |
|
|
+ uint16_t *sums_base = m->integral;
|
1846 |
|
|
+ /* due to a GCC bug on some platforms (win32?), zero[] may not actually be aligned.
|
1847 |
|
|
+ * this is not a problem because it is not used for any SSE instructions. */
|
1848 |
|
|
+ ALIGNED_16( static uint8_t zero[8*FENC_STRIDE] );
|
1849 |
|
|
+ ALIGNED_ARRAY_16( int, enc_dc,[4] );
|
1850 |
|
|
+ int sad_size = i_pixel <= PIXEL_8x8 ? PIXEL_8x8 : PIXEL_4x4;
|
1851 |
|
|
+ int delta = x264_pixel_size[sad_size].w;
|
1852 |
|
|
+ int16_t *xs = h->scratch_buffer;
|
1853 |
|
|
+ int xn;
|
1854 |
|
|
+ uint16_t *cost_fpel_mvx = h->cost_mv_fpel[x264_lambda_tab[h->mb.i_qp]][-m->mvp[0]&3] + (-m->mvp[0]>>2);
|
1855 |
|
|
+
|
1856 |
|
|
+ h->pixf.sad_x4[sad_size]( zero, p_fenc, p_fenc+delta,
|
1857 |
|
|
+ p_fenc+delta*FENC_STRIDE, p_fenc+delta+delta*FENC_STRIDE,
|
1858 |
|
|
+ FENC_STRIDE, enc_dc );
|
1859 |
|
|
+ if( delta == 4 )
|
1860 |
|
|
+ sums_base += stride * (h->fenc->i_lines[0] + PADV*2);
|
1861 |
|
|
+ if( i_pixel == PIXEL_16x16 || i_pixel == PIXEL_8x16 || i_pixel == PIXEL_4x8 )
|
1862 |
|
|
+ delta *= stride;
|
1863 |
|
|
+ if( i_pixel == PIXEL_8x16 || i_pixel == PIXEL_4x8 )
|
1864 |
|
|
+ enc_dc[1] = enc_dc[2];
|
1865 |
|
|
+
|
1866 |
|
|
+ if( h->mb.i_me_method == X264_ME_TESA )
|
1867 |
|
|
+ {
|
1868 |
|
|
+ // ADS threshold, then SAD threshold, then keep the best few SADs, then SATD
|
1869 |
|
|
+ mvsad_t *mvsads = (mvsad_t *)(xs + ((width+15)&~15));
|
1870 |
|
|
+ int nmvsad = 0, limit;
|
1871 |
|
|
+ int sad_thresh = i_me_range <= 16 ? 10 : i_me_range <= 24 ? 11 : 12;
|
1872 |
|
|
+ int bsad = h->pixf.sad[i_pixel]( p_fenc, FENC_STRIDE, p_fref+bmy*stride+bmx, stride )
|
1873 |
|
|
+ + BITS_MVD( bmx, bmy );
|
1874 |
|
|
+ for( my = min_y; my <= max_y; my++ )
|
1875 |
|
|
+ {
|
1876 |
|
|
+ int ycost = p_cost_mvy[my<<2];
|
1877 |
|
|
+ if( bsad <= ycost )
|
1878 |
|
|
+ continue;
|
1879 |
|
|
+ bsad -= ycost;
|
1880 |
|
|
+ xn = h->pixf.ads[i_pixel]( enc_dc, sums_base + min_x + my * stride, delta,
|
1881 |
|
|
+ cost_fpel_mvx+min_x, xs, width, bsad*17/16 );
|
1882 |
|
|
+ for( i=0; i<xn-2; i+=3 )
|
1883 |
|
|
+ {
|
1884 |
|
|
+ uint8_t *ref = p_fref+min_x+my*stride;
|
1885 |
|
|
+ int sads[3];
|
1886 |
|
|
+ h->pixf.sad_x3[i_pixel]( p_fenc, ref+xs[i], ref+xs[i+1], ref+xs[i+2], stride, sads );
|
1887 |
|
|
+ for( j=0; j<3; j++ )
|
1888 |
|
|
+ {
|
1889 |
|
|
+ int sad = sads[j] + cost_fpel_mvx[xs[i+j]];
|
1890 |
|
|
+ if( sad < bsad*sad_thresh>>3 )
|
1891 |
|
|
+ {
|
1892 |
|
|
+ COPY1_IF_LT( bsad, sad );
|
1893 |
|
|
+ mvsads[nmvsad].sad = sad + ycost;
|
1894 |
|
|
+ mvsads[nmvsad].mx = min_x+xs[i+j];
|
1895 |
|
|
+ mvsads[nmvsad].my = my;
|
1896 |
|
|
+ nmvsad++;
|
1897 |
|
|
+ }
|
1898 |
|
|
+ }
|
1899 |
|
|
+ }
|
1900 |
|
|
+ for( ; i<xn; i++ )
|
1901 |
|
|
+ {
|
1902 |
|
|
+ int mx = min_x+xs[i];
|
1903 |
|
|
+ int sad = h->pixf.sad[i_pixel]( p_fenc, FENC_STRIDE, p_fref+mx+my*stride, stride )
|
1904 |
|
|
+ + cost_fpel_mvx[xs[i]];
|
1905 |
|
|
+ if( sad < bsad*sad_thresh>>3 )
|
1906 |
|
|
+ {
|
1907 |
|
|
+ COPY1_IF_LT( bsad, sad );
|
1908 |
|
|
+ mvsads[nmvsad].sad = sad + ycost;
|
1909 |
|
|
+ mvsads[nmvsad].mx = mx;
|
1910 |
|
|
+ mvsads[nmvsad].my = my;
|
1911 |
|
|
+ nmvsad++;
|
1912 |
|
|
+ }
|
1913 |
|
|
+ }
|
1914 |
|
|
+ bsad += ycost;
|
1915 |
|
|
+ }
|
1916 |
|
|
+
|
1917 |
|
|
+ limit = i_me_range / 2;
|
1918 |
|
|
+ sad_thresh = bsad*sad_thresh>>3;
|
1919 |
|
|
+ while( nmvsad > limit*2 && sad_thresh > bsad )
|
1920 |
|
|
+ {
|
1921 |
|
|
+ // halve the range if the domain is too large... eh, close enough
|
1922 |
|
|
+ sad_thresh = (sad_thresh + bsad) >> 1;
|
1923 |
|
|
+ for( i=0; i<nmvsad && mvsads[i].sad <= sad_thresh; i++ );
|
1924 |
|
|
+ for( j=i; j<nmvsad; j++ )
|
1925 |
|
|
+ {
|
1926 |
|
|
+ /* mvsad_t is not guaranteed to be 8 bytes on all archs, so check before using explicit write-combining */
|
1927 |
|
|
+ if( sizeof( mvsad_t ) == sizeof( uint64_t ) )
|
1928 |
|
|
+ *(uint64_t*)&mvsads[i] = *(uint64_t*)&mvsads[j];
|
1929 |
|
|
+ else
|
1930 |
|
|
+ mvsads[i] = mvsads[j];
|
1931 |
|
|
+ i += mvsads[j].sad <= sad_thresh;
|
1932 |
|
|
+ }
|
1933 |
|
|
+ nmvsad = i;
|
1934 |
|
|
+ }
|
1935 |
|
|
+ while( nmvsad > limit )
|
1936 |
|
|
+ {
|
1937 |
|
|
+ int bsad = mvsads[0].sad;
|
1938 |
|
|
+ int bi = 0;
|
1939 |
|
|
+ for( i=1; i<nmvsad; i++ )
|
1940 |
|
|
+ COPY2_IF_GT( bsad, mvsads[i].sad, bi, i );
|
1941 |
|
|
+ nmvsad--;
|
1942 |
|
|
+ mvsads[bi] = mvsads[nmvsad];
|
1943 |
|
|
+ if( sizeof( mvsad_t ) == sizeof( uint64_t ) )
|
1944 |
|
|
+ *(uint64_t*)&mvsads[bi] = *(uint64_t*)&mvsads[nmvsad];
|
1945 |
|
|
+ else
|
1946 |
|
|
+ mvsads[bi] = mvsads[nmvsad];
|
1947 |
|
|
+ }
|
1948 |
|
|
+ for( i=0; i<nmvsad; i++ )
|
1949 |
|
|
+ COST_MV( mvsads[i].mx, mvsads[i].my );
|
1950 |
|
|
+ }
|
1951 |
|
|
+ else
|
1952 |
|
|
+ {
|
1953 |
|
|
+ // just ADS and SAD
|
1954 |
|
|
+ for( my = min_y; my <= max_y; my++ )
|
1955 |
|
|
+ {
|
1956 |
|
|
+ int ycost = p_cost_mvy[my<<2];
|
1957 |
|
|
+ if( bcost <= ycost )
|
1958 |
|
|
+ continue;
|
1959 |
|
|
+ bcost -= ycost;
|
1960 |
|
|
+ xn = h->pixf.ads[i_pixel]( enc_dc, sums_base + min_x + my * stride, delta,
|
1961 |
|
|
+ cost_fpel_mvx+min_x, xs, width, bcost );
|
1962 |
|
|
+ for( i=0; i<xn-2; i+=3 )
|
1963 |
|
|
+ COST_MV_X3_ABS( min_x+xs[i],my, min_x+xs[i+1],my, min_x+xs[i+2],my );
|
1964 |
|
|
+ bcost += ycost;
|
1965 |
|
|
+ for( ; i<xn; i++ )
|
1966 |
|
|
+ COST_MV( min_x+xs[i], my );
|
1967 |
|
|
+ }
|
1968 |
|
|
+ }
|
1969 |
|
|
#endif
|
1970 |
|
|
- }
|
1971 |
|
|
- break;
|
1972 |
|
|
+ }
|
1973 |
|
|
+ break;
|
1974 |
|
|
}
|
1975 |
|
|
|
1976 |
|
|
- /* -> qpel mv */
|
1977 |
|
|
- if( bpred_cost < bcost )
|
1978 |
|
|
+ /* -> qpel mv */
|
1979 |
|
|
+ if( bpred_cost < bcost )
|
1980 |
|
|
{
|
1981 |
|
|
- m->mv[0] = bpred_mx;
|
1982 |
|
|
- m->mv[1] = bpred_my;
|
1983 |
|
|
- m->cost = bpred_cost;
|
1984 |
|
|
+ m->mv[0] = bpred_mx;
|
1985 |
|
|
+ m->mv[1] = bpred_my;
|
1986 |
|
|
+ m->cost = bpred_cost;
|
1987 |
|
|
}
|
1988 |
|
|
- else
|
1989 |
|
|
+ else
|
1990 |
|
|
{
|
1991 |
|
|
- m->mv[0] = bmx << 2;
|
1992 |
|
|
- m->mv[1] = bmy << 2;
|
1993 |
|
|
- m->cost = bcost;
|
1994 |
|
|
+ m->mv[0] = bmx << 2;
|
1995 |
|
|
+ m->mv[1] = bmy << 2;
|
1996 |
|
|
+ m->cost = bcost;
|
1997 |
|
|
}
|
1998 |
|
|
|
1999 |
|
|
- /* compute the real cost */
|
2000 |
|
|
- m->cost_mv = p_cost_mvx[ m->mv[0] ] + p_cost_mvy[ m->mv[1] ];
|
2001 |
|
|
- if( bmx == pmx && bmy == pmy && h->mb.i_subpel_refine < 3 )
|
2002 |
|
|
- m->cost += m->cost_mv;
|
2003 |
|
|
+ /* compute the real cost */
|
2004 |
|
|
+ m->cost_mv = p_cost_mvx[ m->mv[0] ] + p_cost_mvy[ m->mv[1] ];
|
2005 |
|
|
+ if( bmx == pmx && bmy == pmy && h->mb.i_subpel_refine < 3 )
|
2006 |
|
|
+ m->cost += m->cost_mv;
|
2007 |
|
|
|
2008 |
|
|
- /* subpel refine */
|
2009 |
|
|
- if( h->mb.i_subpel_refine >= 2 )
|
2010 |
|
|
+ /* subpel refine */
|
2011 |
|
|
+ if( h->mb.i_subpel_refine >= 2 )
|
2012 |
|
|
{
|
2013 |
|
|
- int hpel = subpel_iterations[h->mb.i_subpel_refine][2];
|
2014 |
|
|
- int qpel = subpel_iterations[h->mb.i_subpel_refine][3];
|
2015 |
|
|
- refine_subpel( h, m, hpel, qpel, p_halfpel_thresh, 0 );
|
2016 |
|
|
+ int hpel = subpel_iterations[h->mb.i_subpel_refine][2];
|
2017 |
|
|
+ int qpel = subpel_iterations[h->mb.i_subpel_refine][3];
|
2018 |
|
|
+ refine_subpel( h, m, hpel, qpel, p_halfpel_thresh, 0 );
|
2019 |
|
|
}
|
2020 |
|
|
}
|
2021 |
|
|
#undef COST_MV
|
2022 |
|
|
|
2023 |
|
|
void x264_me_refine_qpel( x264_t *h, x264_me_t *m )
|
2024 |
|
|
{
|
2025 |
|
|
- int hpel = subpel_iterations[h->mb.i_subpel_refine][0];
|
2026 |
|
|
- int qpel = subpel_iterations[h->mb.i_subpel_refine][1];
|
2027 |
|
|
+ int hpel = subpel_iterations[h->mb.i_subpel_refine][0];
|
2028 |
|
|
+ int qpel = subpel_iterations[h->mb.i_subpel_refine][1];
|
2029 |
|
|
|
2030 |
|
|
- if( m->i_pixel <= PIXEL_8x8 && h->sh.i_type == SLICE_TYPE_P )
|
2031 |
|
|
- m->cost -= m->i_ref_cost;
|
2032 |
|
|
+ if( m->i_pixel <= PIXEL_8x8 && h->sh.i_type == SLICE_TYPE_P )
|
2033 |
|
|
+ m->cost -= m->i_ref_cost;
|
2034 |
|
|
|
2035 |
|
|
- refine_subpel( h, m, hpel, qpel, NULL, 1 );
|
2036 |
|
|
+ refine_subpel( h, m, hpel, qpel, NULL, 1 );
|
2037 |
|
|
}
|
2038 |
|
|
|
2039 |
|
|
-#define COST_MV_SAD( mx, my ) \
|
2040 |
|
|
-{ \
|
2041 |
|
|
- int stride = 16; \
|
2042 |
|
|
+#define COST_MV_SAD( mx, my ) \
|
2043 |
|
|
+ { \
|
2044 |
|
|
+ int stride = 16; \
|
2045 |
|
|
uint8_t *src = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], mx, my, bw, bh ); \
|
2046 |
|
|
int cost = h->pixf.fpelcmp[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \
|
2047 |
|
|
- + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \
|
2048 |
|
|
- COPY3_IF_LT( bcost, cost, bmx, mx, bmy, my ); \
|
2049 |
|
|
-}
|
2050 |
|
|
-
|
2051 |
|
|
-#define COST_MV_SATD( mx, my, dir ) \
|
2052 |
|
|
-if( b_refine_qpel || (dir^1) != odir ) \
|
2053 |
|
|
-{ \
|
2054 |
|
|
- int stride = 16; \
|
2055 |
|
|
- uint8_t *src = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], mx, my, bw, bh ); \
|
2056 |
|
|
- int cost = h->pixf.mbcmp_unaligned[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \
|
2057 |
|
|
- + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \
|
2058 |
|
|
- if( b_chroma_me && cost < bcost ) \
|
2059 |
|
|
- { \
|
2060 |
|
|
- h->mc.mc_chroma( pix[0], 8, m->p_fref[4], m->i_stride[1], mx, my, bw/2, bh/2 ); \
|
2061 |
|
|
- cost += h->pixf.mbcmp[i_pixel+3]( m->p_fenc[1], FENC_STRIDE, pix[0], 8 ); \
|
2062 |
|
|
- if( cost < bcost ) \
|
2063 |
|
|
- { \
|
2064 |
|
|
- h->mc.mc_chroma( pix[0], 8, m->p_fref[5], m->i_stride[1], mx, my, bw/2, bh/2 ); \
|
2065 |
|
|
- cost += h->pixf.mbcmp[i_pixel+3]( m->p_fenc[2], FENC_STRIDE, pix[0], 8 ); \
|
2066 |
|
|
- } \
|
2067 |
|
|
- } \
|
2068 |
|
|
- if( cost < bcost ) \
|
2069 |
|
|
- { \
|
2070 |
|
|
- bcost = cost; \
|
2071 |
|
|
- bmx = mx; \
|
2072 |
|
|
- bmy = my; \
|
2073 |
|
|
- bdir = dir; \
|
2074 |
|
|
- } \
|
2075 |
|
|
-}
|
2076 |
|
|
+ + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \
|
2077 |
|
|
+ COPY3_IF_LT( bcost, cost, bmx, mx, bmy, my ); \
|
2078 |
|
|
+ }
|
2079 |
|
|
+
|
2080 |
|
|
+#define COST_MV_SATD( mx, my, dir ) \
|
2081 |
|
|
+ if( b_refine_qpel || (dir^1) != odir ) \
|
2082 |
|
|
+ { \
|
2083 |
|
|
+ int stride = 16; \
|
2084 |
|
|
+ uint8_t *src = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], mx, my, bw, bh ); \
|
2085 |
|
|
+ int cost = h->pixf.mbcmp_unaligned[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \
|
2086 |
|
|
+ + p_cost_mvx[ mx ] + p_cost_mvy[ my ]; \
|
2087 |
|
|
+ if( b_chroma_me && cost < bcost ) \
|
2088 |
|
|
+ { \
|
2089 |
|
|
+ h->mc.mc_chroma( pix[0], 8, m->p_fref[4], m->i_stride[1], mx, my, bw/2, bh/2 ); \
|
2090 |
|
|
+ cost += h->pixf.mbcmp[i_pixel+3]( m->p_fenc[1], FENC_STRIDE, pix[0], 8 ); \
|
2091 |
|
|
+ if( cost < bcost ) \
|
2092 |
|
|
+ { \
|
2093 |
|
|
+ h->mc.mc_chroma( pix[0], 8, m->p_fref[5], m->i_stride[1], mx, my, bw/2, bh/2 ); \
|
2094 |
|
|
+ cost += h->pixf.mbcmp[i_pixel+3]( m->p_fenc[2], FENC_STRIDE, pix[0], 8 ); \
|
2095 |
|
|
+ } \
|
2096 |
|
|
+ } \
|
2097 |
|
|
+ if( cost < bcost ) \
|
2098 |
|
|
+ { \
|
2099 |
|
|
+ bcost = cost; \
|
2100 |
|
|
+ bmx = mx; \
|
2101 |
|
|
+ bmy = my; \
|
2102 |
|
|
+ bdir = dir; \
|
2103 |
|
|
+ } \
|
2104 |
|
|
+ }
|
2105 |
|
|
|
2106 |
|
|
static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_iters, int *p_halfpel_thresh, int b_refine_qpel )
|
2107 |
|
|
{
|
2108 |
|
|
- const int bw = x264_pixel_size[m->i_pixel].w;
|
2109 |
|
|
- const int bh = x264_pixel_size[m->i_pixel].h;
|
2110 |
|
|
- const uint16_t *p_cost_mvx = m->p_cost_mv - m->mvp[0];
|
2111 |
|
|
- const uint16_t *p_cost_mvy = m->p_cost_mv - m->mvp[1];
|
2112 |
|
|
- const int i_pixel = m->i_pixel;
|
2113 |
|
|
- const int b_chroma_me = h->mb.b_chroma_me && i_pixel <= PIXEL_8x8;
|
2114 |
|
|
-
|
2115 |
|
|
- ALIGNED_ARRAY_16( uint8_t, pix,[2],[32*18] ); // really 17x17, but round up for alignment
|
2116 |
|
|
- int omx, omy;
|
2117 |
|
|
- int i;
|
2118 |
|
|
-
|
2119 |
|
|
- int bmx = m->mv[0];
|
2120 |
|
|
- int bmy = m->mv[1];
|
2121 |
|
|
- int bcost = m->cost;
|
2122 |
|
|
- int odir = -1, bdir;
|
2123 |
|
|
+ const int bw = x264_pixel_size[m->i_pixel].w;
|
2124 |
|
|
+ const int bh = x264_pixel_size[m->i_pixel].h;
|
2125 |
|
|
+ const uint16_t *p_cost_mvx = m->p_cost_mv - m->mvp[0];
|
2126 |
|
|
+ const uint16_t *p_cost_mvy = m->p_cost_mv - m->mvp[1];
|
2127 |
|
|
+ const int i_pixel = m->i_pixel;
|
2128 |
|
|
+ const int b_chroma_me = h->mb.b_chroma_me && i_pixel <= PIXEL_8x8;
|
2129 |
|
|
+
|
2130 |
|
|
+ ALIGNED_ARRAY_16( uint8_t, pix,[2],[32*18] ); // really 17x17, but round up for alignment
|
2131 |
|
|
+ int omx, omy;
|
2132 |
|
|
+ int i;
|
2133 |
|
|
+
|
2134 |
|
|
+ int bmx = m->mv[0];
|
2135 |
|
|
+ int bmy = m->mv[1];
|
2136 |
|
|
+ int bcost = m->cost;
|
2137 |
|
|
+ int odir = -1, bdir;
|
2138 |
|
|
|
2139 |
|
|
- /* try the subpel component of the predicted mv */
|
2140 |
|
|
- if( hpel_iters && h->mb.i_subpel_refine < 3 )
|
2141 |
|
|
+ /* try the subpel component of the predicted mv */
|
2142 |
|
|
+ if( hpel_iters && h->mb.i_subpel_refine < 3 )
|
2143 |
|
|
{
|
2144 |
|
|
- int mx = x264_clip3( m->mvp[0], h->mb.mv_min_spel[0]+2, h->mb.mv_max_spel[0]-2 );
|
2145 |
|
|
- int my = x264_clip3( m->mvp[1], h->mb.mv_min_spel[1]+2, h->mb.mv_max_spel[1]-2 );
|
2146 |
|
|
- if( (mx-bmx)|(my-bmy) )
|
2147 |
|
|
- COST_MV_SAD( mx, my );
|
2148 |
|
|
+ int mx = x264_clip3( m->mvp[0], h->mb.mv_min_spel[0]+2, h->mb.mv_max_spel[0]-2 );
|
2149 |
|
|
+ int my = x264_clip3( m->mvp[1], h->mb.mv_min_spel[1]+2, h->mb.mv_max_spel[1]-2 );
|
2150 |
|
|
+ if( (mx-bmx)|(my-bmy) )
|
2151 |
|
|
+ COST_MV_SAD( mx, my );
|
2152 |
|
|
}
|
2153 |
|
|
|
2154 |
|
|
- /* halfpel diamond search */
|
2155 |
|
|
- for( i = hpel_iters; i > 0; i-- )
|
2156 |
|
|
+ /* halfpel diamond search */
|
2157 |
|
|
+ for( i = hpel_iters; i > 0; i-- )
|
2158 |
|
|
{
|
2159 |
|
|
- int omx = bmx, omy = bmy;
|
2160 |
|
|
- int costs[4];
|
2161 |
|
|
- int stride = 32; // candidates are either all hpel or all qpel, so one stride is enough
|
2162 |
|
|
- uint8_t *src0, *src1, *src2, *src3;
|
2163 |
|
|
- src0 = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], omx, omy-2, bw, bh+1 );
|
2164 |
|
|
- src2 = h->mc.get_ref( pix[1], &stride, m->p_fref, m->i_stride[0], omx-2, omy, bw+4, bh );
|
2165 |
|
|
- src1 = src0 + stride;
|
2166 |
|
|
- src3 = src2 + 1;
|
2167 |
|
|
- h->pixf.fpelcmp_x4[i_pixel]( m->p_fenc[0], src0, src1, src2, src3, stride, costs );
|
2168 |
|
|
- COPY2_IF_LT( bcost, costs[0] + p_cost_mvx[omx ] + p_cost_mvy[omy-2], bmy, omy-2 );
|
2169 |
|
|
- COPY2_IF_LT( bcost, costs[1] + p_cost_mvx[omx ] + p_cost_mvy[omy+2], bmy, omy+2 );
|
2170 |
|
|
- COPY3_IF_LT( bcost, costs[2] + p_cost_mvx[omx-2] + p_cost_mvy[omy ], bmx, omx-2, bmy, omy );
|
2171 |
|
|
- COPY3_IF_LT( bcost, costs[3] + p_cost_mvx[omx+2] + p_cost_mvy[omy ], bmx, omx+2, bmy, omy );
|
2172 |
|
|
- if( (bmx == omx) & (bmy == omy) )
|
2173 |
|
|
- break;
|
2174 |
|
|
+ int omx = bmx, omy = bmy;
|
2175 |
|
|
+ int costs[4];
|
2176 |
|
|
+ int stride = 32; // candidates are either all hpel or all qpel, so one stride is enough
|
2177 |
|
|
+ uint8_t *src0, *src1, *src2, *src3;
|
2178 |
|
|
+ src0 = h->mc.get_ref( pix[0], &stride, m->p_fref, m->i_stride[0], omx, omy-2, bw, bh+1 );
|
2179 |
|
|
+ src2 = h->mc.get_ref( pix[1], &stride, m->p_fref, m->i_stride[0], omx-2, omy, bw+4, bh );
|
2180 |
|
|
+ src1 = src0 + stride;
|
2181 |
|
|
+ src3 = src2 + 1;
|
2182 |
|
|
+ h->pixf.fpelcmp_x4[i_pixel]( m->p_fenc[0], src0, src1, src2, src3, stride, costs );
|
2183 |
|
|
+ COPY2_IF_LT( bcost, costs[0] + p_cost_mvx[omx ] + p_cost_mvy[omy-2], bmy, omy-2 );
|
2184 |
|
|
+ COPY2_IF_LT( bcost, costs[1] + p_cost_mvx[omx ] + p_cost_mvy[omy+2], bmy, omy+2 );
|
2185 |
|
|
+ COPY3_IF_LT( bcost, costs[2] + p_cost_mvx[omx-2] + p_cost_mvy[omy ], bmx, omx-2, bmy, omy );
|
2186 |
|
|
+ COPY3_IF_LT( bcost, costs[3] + p_cost_mvx[omx+2] + p_cost_mvy[omy ], bmx, omx+2, bmy, omy );
|
2187 |
|
|
+ if( (bmx == omx) & (bmy == omy) )
|
2188 |
|
|
+ break;
|
2189 |
|
|
}
|
2190 |
|
|
|
2191 |
|
|
- if( !b_refine_qpel )
|
2192 |
|
|
+ if( !b_refine_qpel )
|
2193 |
|
|
{
|
2194 |
|
|
- bcost = COST_MAX;
|
2195 |
|
|
- COST_MV_SATD( bmx, bmy, -1 );
|
2196 |
|
|
+ bcost = COST_MAX;
|
2197 |
|
|
+ COST_MV_SATD( bmx, bmy, -1 );
|
2198 |
|
|
}
|
2199 |
|
|
|
2200 |
|
|
- /* early termination when examining multiple reference frames */
|
2201 |
|
|
- if( p_halfpel_thresh )
|
2202 |
|
|
+ /* early termination when examining multiple reference frames */
|
2203 |
|
|
+ if( p_halfpel_thresh )
|
2204 |
|
|
{
|
2205 |
|
|
- if( (bcost*7)>>3 > *p_halfpel_thresh )
|
2206 |
|
|
+ if( (bcost*7)>>3 > *p_halfpel_thresh )
|
2207 |
|
|
{
|
2208 |
|
|
- m->cost = bcost;
|
2209 |
|
|
- m->mv[0] = bmx;
|
2210 |
|
|
- m->mv[1] = bmy;
|
2211 |
|
|
- // don't need cost_mv
|
2212 |
|
|
- return;
|
2213 |
|
|
+ m->cost = bcost;
|
2214 |
|
|
+ m->mv[0] = bmx;
|
2215 |
|
|
+ m->mv[1] = bmy;
|
2216 |
|
|
+ // don't need cost_mv
|
2217 |
|
|
+ return;
|
2218 |
|
|
}
|
2219 |
|
|
- else if( bcost < *p_halfpel_thresh )
|
2220 |
|
|
- *p_halfpel_thresh = bcost;
|
2221 |
|
|
+ else if( bcost < *p_halfpel_thresh )
|
2222 |
|
|
+ *p_halfpel_thresh = bcost;
|
2223 |
|
|
}
|
2224 |
|
|
|
2225 |
|
|
- /* quarterpel diamond search */
|
2226 |
|
|
- bdir = -1;
|
2227 |
|
|
- for( i = qpel_iters; i > 0; i-- )
|
2228 |
|
|
+ /* quarterpel diamond search */
|
2229 |
|
|
+ bdir = -1;
|
2230 |
|
|
+ for( i = qpel_iters; i > 0; i-- )
|
2231 |
|
|
{
|
2232 |
|
|
- if( bmy <= h->mb.mv_min_spel[1] || bmy >= h->mb.mv_max_spel[1] )
|
2233 |
|
|
- break;
|
2234 |
|
|
- odir = bdir;
|
2235 |
|
|
- omx = bmx;
|
2236 |
|
|
- omy = bmy;
|
2237 |
|
|
- COST_MV_SATD( omx, omy - 1, 0 );
|
2238 |
|
|
- COST_MV_SATD( omx, omy + 1, 1 );
|
2239 |
|
|
- COST_MV_SATD( omx - 1, omy, 2 );
|
2240 |
|
|
- COST_MV_SATD( omx + 1, omy, 3 );
|
2241 |
|
|
- if( bmx == omx && bmy == omy )
|
2242 |
|
|
- break;
|
2243 |
|
|
+ if( bmy <= h->mb.mv_min_spel[1] || bmy >= h->mb.mv_max_spel[1] )
|
2244 |
|
|
+ break;
|
2245 |
|
|
+ odir = bdir;
|
2246 |
|
|
+ omx = bmx;
|
2247 |
|
|
+ omy = bmy;
|
2248 |
|
|
+ COST_MV_SATD( omx, omy - 1, 0 );
|
2249 |
|
|
+ COST_MV_SATD( omx, omy + 1, 1 );
|
2250 |
|
|
+ COST_MV_SATD( omx - 1, omy, 2 );
|
2251 |
|
|
+ COST_MV_SATD( omx + 1, omy, 3 );
|
2252 |
|
|
+ if( bmx == omx && bmy == omy )
|
2253 |
|
|
+ break;
|
2254 |
|
|
}
|
2255 |
|
|
|
2256 |
|
|
- m->cost = bcost;
|
2257 |
|
|
- m->mv[0] = bmx;
|
2258 |
|
|
- m->mv[1] = bmy;
|
2259 |
|
|
- m->cost_mv = p_cost_mvx[ bmx ] + p_cost_mvy[ bmy ];
|
2260 |
|
|
+ m->cost = bcost;
|
2261 |
|
|
+ m->mv[0] = bmx;
|
2262 |
|
|
+ m->mv[1] = bmy;
|
2263 |
|
|
+ m->cost_mv = p_cost_mvx[ bmx ] + p_cost_mvy[ bmy ];
|
2264 |
|
|
}
|
2265 |
|
|
|
2266 |
|
|
-#define BIME_CACHE( dx, dy, list ) \
|
2267 |
|
|
-{ \
|
2268 |
|
|
- x264_me_t *m = m##list;\
|
2269 |
|
|
- int i = 4 + 3*dx + dy; \
|
2270 |
|
|
- int mvx = om##list##x+dx;\
|
2271 |
|
|
- int mvy = om##list##y+dy;\
|
2272 |
|
|
- stride##list[i] = bw;\
|
2273 |
|
|
+#define BIME_CACHE( dx, dy, list ) \
|
2274 |
|
|
+ { \
|
2275 |
|
|
+ x264_me_t *m = m##list; \
|
2276 |
|
|
+ int i = 4 + 3*dx + dy; \
|
2277 |
|
|
+ int mvx = om##list##x+dx; \
|
2278 |
|
|
+ int mvy = om##list##y+dy; \
|
2279 |
|
|
+ stride##list[i] = bw; \
|
2280 |
|
|
src##list[i] = h->mc.get_ref( pixy_buf[list][i], &stride##list[i], m->p_fref, m->i_stride[0], mvx, mvy, bw, bh ); \
|
2281 |
|
|
- if( rd )\
|
2282 |
|
|
- {\
|
2283 |
|
|
- if( h->mb.b_interlaced & ref##list )\
|
2284 |
|
|
- mvy += (h->mb.i_mb_y & 1)*4 - 2;\
|
2285 |
|
|
- h->mc.mc_chroma( pixu_buf[list][i], 8, m->p_fref[4], m->i_stride[1], mvx, mvy, bw>>1, bh>>1 );\
|
2286 |
|
|
- h->mc.mc_chroma( pixv_buf[list][i], 8, m->p_fref[5], m->i_stride[1], mvx, mvy, bw>>1, bh>>1 );\
|
2287 |
|
|
- }\
|
2288 |
|
|
-}
|
2289 |
|
|
-
|
2290 |
|
|
-#define BIME_CACHE2(a,b,list) \
|
2291 |
|
|
- BIME_CACHE(a,b,list) \
|
2292 |
|
|
- BIME_CACHE(-(a),-(b),list)
|
2293 |
|
|
-
|
2294 |
|
|
-#define BIME_CACHE8(list) \
|
2295 |
|
|
-{\
|
2296 |
|
|
- BIME_CACHE2( 1, 0, list );\
|
2297 |
|
|
- BIME_CACHE2( 0, 1, list );\
|
2298 |
|
|
- BIME_CACHE2( 1, 1, list );\
|
2299 |
|
|
- BIME_CACHE2( 1,-1, list );\
|
2300 |
|
|
-}
|
2301 |
|
|
+ if( rd ) \
|
2302 |
|
|
+ { \
|
2303 |
|
|
+ if( h->mb.b_interlaced & ref##list ) \
|
2304 |
|
|
+ mvy += (h->mb.i_mb_y & 1)*4 - 2; \
|
2305 |
|
|
+ h->mc.mc_chroma( pixu_buf[list][i], 8, m->p_fref[4], m->i_stride[1], mvx, mvy, bw>>1, bh>>1 ); \
|
2306 |
|
|
+ h->mc.mc_chroma( pixv_buf[list][i], 8, m->p_fref[5], m->i_stride[1], mvx, mvy, bw>>1, bh>>1 ); \
|
2307 |
|
|
+ } \
|
2308 |
|
|
+ }
|
2309 |
|
|
+
|
2310 |
|
|
+#define BIME_CACHE2(a,b,list) \
|
2311 |
|
|
+ BIME_CACHE(a,b,list) \
|
2312 |
|
|
+ BIME_CACHE(-(a),-(b),list)
|
2313 |
|
|
+
|
2314 |
|
|
+#define BIME_CACHE8(list) \
|
2315 |
|
|
+ { \
|
2316 |
|
|
+ BIME_CACHE2( 1, 0, list ); \
|
2317 |
|
|
+ BIME_CACHE2( 0, 1, list ); \
|
2318 |
|
|
+ BIME_CACHE2( 1, 1, list ); \
|
2319 |
|
|
+ BIME_CACHE2( 1,-1, list ); \
|
2320 |
|
|
+ }
|
2321 |
|
|
|
2322 |
|
|
#define SATD_THRESH 17/16
|
2323 |
|
|
|
2324 |
|
|
-#define COST_BIMV_SATD( m0x, m0y, m1x, m1y ) \
|
2325 |
|
|
-if( pass == 0 || !((visited[(m0x)&7][(m0y)&7][(m1x)&7] & (1<<((m1y)&7)))) ) \
|
2326 |
|
|
-{ \
|
2327 |
|
|
- int cost; \
|
2328 |
|
|
- int i0 = 4 + 3*(m0x-om0x) + (m0y-om0y); \
|
2329 |
|
|
- int i1 = 4 + 3*(m1x-om1x) + (m1y-om1y); \
|
2330 |
|
|
- visited[(m0x)&7][(m0y)&7][(m1x)&7] |= (1<<((m1y)&7));\
|
2331 |
|
|
- h->mc.avg[i_pixel]( pix, FDEC_STRIDE, src0[i0], stride0[i0], src1[i1], stride1[i1], i_weight ); \
|
2332 |
|
|
- cost = h->pixf.mbcmp[i_pixel]( m0->p_fenc[0], FENC_STRIDE, pix, FDEC_STRIDE ) \
|
2333 |
|
|
- + p_cost_m0x[ m0x ] + p_cost_m0y[ m0y ] \
|
2334 |
|
|
- + p_cost_m1x[ m1x ] + p_cost_m1y[ m1y ]; \
|
2335 |
|
|
- if( rd ) \
|
2336 |
|
|
- { \
|
2337 |
|
|
- if( cost < bcost * SATD_THRESH ) \
|
2338 |
|
|
- { \
|
2339 |
|
|
- uint64_t costrd; \
|
2340 |
|
|
- if( cost < bcost ) \
|
2341 |
|
|
- bcost = cost; \
|
2342 |
|
|
- *(uint32_t*)cache0_mv = *(uint32_t*)cache0_mv2 = pack16to32_mask(m0x,m0y); \
|
2343 |
|
|
- *(uint32_t*)cache1_mv = *(uint32_t*)cache1_mv2 = pack16to32_mask(m1x,m1y); \
|
2344 |
|
|
- h->mc.avg[i_pixel+3]( pixu, FDEC_STRIDE, pixu_buf[0][i0], 8, pixu_buf[1][i1], 8, i_weight );\
|
2345 |
|
|
- h->mc.avg[i_pixel+3]( pixv, FDEC_STRIDE, pixv_buf[0][i0], 8, pixv_buf[1][i1], 8, i_weight );\
|
2346 |
|
|
- costrd = x264_rd_cost_part( h, i_lambda2, i8*4, m0->i_pixel ); \
|
2347 |
|
|
- if( costrd < bcostrd ) \
|
2348 |
|
|
- {\
|
2349 |
|
|
- bcostrd = costrd;\
|
2350 |
|
|
- bm0x = m0x; \
|
2351 |
|
|
- bm0y = m0y; \
|
2352 |
|
|
- bm1x = m1x; \
|
2353 |
|
|
- bm1y = m1y; \
|
2354 |
|
|
- }\
|
2355 |
|
|
- } \
|
2356 |
|
|
- } \
|
2357 |
|
|
- else if( cost < bcost ) \
|
2358 |
|
|
- { \
|
2359 |
|
|
- bcost = cost; \
|
2360 |
|
|
- bm0x = m0x; \
|
2361 |
|
|
- bm0y = m0y; \
|
2362 |
|
|
- bm1x = m1x; \
|
2363 |
|
|
- bm1y = m1y; \
|
2364 |
|
|
- } \
|
2365 |
|
|
-}
|
2366 |
|
|
+#define COST_BIMV_SATD( m0x, m0y, m1x, m1y ) \
|
2367 |
|
|
+ if( pass == 0 || !((visited[(m0x)&7][(m0y)&7][(m1x)&7] & (1<<((m1y)&7)))) ) \
|
2368 |
|
|
+ { \
|
2369 |
|
|
+ int cost; \
|
2370 |
|
|
+ int i0 = 4 + 3*(m0x-om0x) + (m0y-om0y); \
|
2371 |
|
|
+ int i1 = 4 + 3*(m1x-om1x) + (m1y-om1y); \
|
2372 |
|
|
+ visited[(m0x)&7][(m0y)&7][(m1x)&7] |= (1<<((m1y)&7)); \
|
2373 |
|
|
+ h->mc.avg[i_pixel]( pix, FDEC_STRIDE, src0[i0], stride0[i0], src1[i1], stride1[i1], i_weight ); \
|
2374 |
|
|
+ cost = h->pixf.mbcmp[i_pixel]( m0->p_fenc[0], FENC_STRIDE, pix, FDEC_STRIDE ) \
|
2375 |
|
|
+ + p_cost_m0x[ m0x ] + p_cost_m0y[ m0y ] \
|
2376 |
|
|
+ + p_cost_m1x[ m1x ] + p_cost_m1y[ m1y ]; \
|
2377 |
|
|
+ if( rd ) \
|
2378 |
|
|
+ { \
|
2379 |
|
|
+ if( cost < bcost * SATD_THRESH ) \
|
2380 |
|
|
+ { \
|
2381 |
|
|
+ uint64_t costrd; \
|
2382 |
|
|
+ if( cost < bcost ) \
|
2383 |
|
|
+ bcost = cost; \
|
2384 |
|
|
+ *(uint32_t*)cache0_mv = *(uint32_t*)cache0_mv2 = pack16to32_mask(m0x,m0y); \
|
2385 |
|
|
+ *(uint32_t*)cache1_mv = *(uint32_t*)cache1_mv2 = pack16to32_mask(m1x,m1y); \
|
2386 |
|
|
+ h->mc.avg[i_pixel+3]( pixu, FDEC_STRIDE, pixu_buf[0][i0], 8, pixu_buf[1][i1], 8, i_weight ); \
|
2387 |
|
|
+ h->mc.avg[i_pixel+3]( pixv, FDEC_STRIDE, pixv_buf[0][i0], 8, pixv_buf[1][i1], 8, i_weight ); \
|
2388 |
|
|
+ costrd = x264_rd_cost_part( h, i_lambda2, i8*4, m0->i_pixel ); \
|
2389 |
|
|
+ if( costrd < bcostrd ) \
|
2390 |
|
|
+ { \
|
2391 |
|
|
+ bcostrd = costrd; \
|
2392 |
|
|
+ bm0x = m0x; \
|
2393 |
|
|
+ bm0y = m0y; \
|
2394 |
|
|
+ bm1x = m1x; \
|
2395 |
|
|
+ bm1y = m1y; \
|
2396 |
|
|
+ } \
|
2397 |
|
|
+ } \
|
2398 |
|
|
+ } \
|
2399 |
|
|
+ else if( cost < bcost ) \
|
2400 |
|
|
+ { \
|
2401 |
|
|
+ bcost = cost; \
|
2402 |
|
|
+ bm0x = m0x; \
|
2403 |
|
|
+ bm0y = m0y; \
|
2404 |
|
|
+ bm1x = m1x; \
|
2405 |
|
|
+ bm1y = m1y; \
|
2406 |
|
|
+ } \
|
2407 |
|
|
+ }
|
2408 |
|
|
|
2409 |
|
|
-#define CHECK_BIDIR(a,b,c,d) \
|
2410 |
|
|
- COST_BIMV_SATD(om0x+a, om0y+b, om1x+c, om1y+d)
|
2411 |
|
|
+#define CHECK_BIDIR(a,b,c,d) \
|
2412 |
|
|
+ COST_BIMV_SATD(om0x+a, om0y+b, om1x+c, om1y+d)
|
2413 |
|
|
|
2414 |
|
|
static void ALWAYS_INLINE x264_me_refine_bidir( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2, int rd )
|
2415 |
|
|
{
|
2416 |
|
|
- static const int pixel_mv_offs[] = { 0, 4, 4*8, 0 };
|
2417 |
|
|
- int16_t *cache0_mv = h->mb.cache.mv[0][x264_scan8[i8*4]];
|
2418 |
|
|
- int16_t *cache0_mv2 = cache0_mv + pixel_mv_offs[m0->i_pixel];
|
2419 |
|
|
- int16_t *cache1_mv = h->mb.cache.mv[1][x264_scan8[i8*4]];
|
2420 |
|
|
- int16_t *cache1_mv2 = cache1_mv + pixel_mv_offs[m0->i_pixel];
|
2421 |
|
|
- const int i_pixel = m0->i_pixel;
|
2422 |
|
|
- const int bw = x264_pixel_size[i_pixel].w;
|
2423 |
|
|
- const int bh = x264_pixel_size[i_pixel].h;
|
2424 |
|
|
- const uint16_t *p_cost_m0x = m0->p_cost_mv - m0->mvp[0];
|
2425 |
|
|
- const uint16_t *p_cost_m0y = m0->p_cost_mv - m0->mvp[1];
|
2426 |
|
|
- const uint16_t *p_cost_m1x = m1->p_cost_mv - m1->mvp[0];
|
2427 |
|
|
- const uint16_t *p_cost_m1y = m1->p_cost_mv - m1->mvp[1];
|
2428 |
|
|
- ALIGNED_ARRAY_16( uint8_t, pixy_buf,[2],[9][16*16] );
|
2429 |
|
|
- ALIGNED_8( uint8_t pixu_buf[2][9][8*8] );
|
2430 |
|
|
- ALIGNED_8( uint8_t pixv_buf[2][9][8*8] );
|
2431 |
|
|
- uint8_t *src0[9];
|
2432 |
|
|
- uint8_t *src1[9];
|
2433 |
|
|
- uint8_t *pix = &h->mb.pic.p_fdec[0][(i8>>1)*8*FDEC_STRIDE+(i8&1)*8];
|
2434 |
|
|
- uint8_t *pixu = &h->mb.pic.p_fdec[1][(i8>>1)*4*FDEC_STRIDE+(i8&1)*4];
|
2435 |
|
|
- uint8_t *pixv = &h->mb.pic.p_fdec[2][(i8>>1)*4*FDEC_STRIDE+(i8&1)*4];
|
2436 |
|
|
- int ref0 = h->mb.cache.ref[0][x264_scan8[i8*4]];
|
2437 |
|
|
- int ref1 = h->mb.cache.ref[1][x264_scan8[i8*4]];
|
2438 |
|
|
- int stride0[9];
|
2439 |
|
|
- int stride1[9];
|
2440 |
|
|
- int bm0x = m0->mv[0], om0x = bm0x;
|
2441 |
|
|
- int bm0y = m0->mv[1], om0y = bm0y;
|
2442 |
|
|
- int bm1x = m1->mv[0], om1x = bm1x;
|
2443 |
|
|
- int bm1y = m1->mv[1], om1y = bm1y;
|
2444 |
|
|
- int bcost = COST_MAX;
|
2445 |
|
|
- int pass = 0;
|
2446 |
|
|
- int j;
|
2447 |
|
|
- int mc_list0 = 1, mc_list1 = 1;
|
2448 |
|
|
- uint64_t bcostrd = COST_MAX64;
|
2449 |
|
|
- /* each byte of visited represents 8 possible m1y positions, so a 4D array isn't needed */
|
2450 |
|
|
- ALIGNED_ARRAY_16( uint8_t, visited,[8],[8][8] );
|
2451 |
|
|
- /* all permutations of an offset in up to 2 of the dimensions */
|
2452 |
|
|
- static const int8_t dia4d[32][4] = {
|
2453 |
|
|
- {0,0,0,1}, {0,0,0,-1}, {0,0,1,0}, {0,0,-1,0},
|
2454 |
|
|
- {0,1,0,0}, {0,-1,0,0}, {1,0,0,0}, {-1,0,0,0},
|
2455 |
|
|
- {0,0,1,1}, {0,0,-1,-1},{0,1,1,0}, {0,-1,-1,0},
|
2456 |
|
|
- {1,1,0,0}, {-1,-1,0,0},{1,0,0,1}, {-1,0,0,-1},
|
2457 |
|
|
- {0,1,0,1}, {0,-1,0,-1},{1,0,1,0}, {-1,0,-1,0},
|
2458 |
|
|
- {0,0,-1,1},{0,0,1,-1}, {0,-1,1,0},{0,1,-1,0},
|
2459 |
|
|
- {-1,1,0,0},{1,-1,0,0}, {1,0,0,-1},{-1,0,0,1},
|
2460 |
|
|
- {0,-1,0,1},{0,1,0,-1}, {-1,0,1,0},{1,0,-1,0},
|
2461 |
|
|
- };
|
2462 |
|
|
-
|
2463 |
|
|
- if( bm0y < h->mb.mv_min_spel[1] + 8 || bm1y < h->mb.mv_min_spel[1] + 8 ||
|
2464 |
|
|
- bm0y > h->mb.mv_max_spel[1] - 8 || bm1y > h->mb.mv_max_spel[1] - 8 )
|
2465 |
|
|
- return;
|
2466 |
|
|
-
|
2467 |
|
|
- h->mc.memzero_aligned( visited, sizeof(uint8_t[8][8][8]) );
|
2468 |
|
|
-
|
2469 |
|
|
- BIME_CACHE( 0, 0, 0 );
|
2470 |
|
|
- BIME_CACHE( 0, 0, 1 );
|
2471 |
|
|
- CHECK_BIDIR( 0, 0, 0, 0 );
|
2472 |
|
|
+ static const int pixel_mv_offs[] = { 0, 4, 4*8, 0 };
|
2473 |
|
|
+ int16_t *cache0_mv = h->mb.cache.mv[0][x264_scan8[i8*4]];
|
2474 |
|
|
+ int16_t *cache0_mv2 = cache0_mv + pixel_mv_offs[m0->i_pixel];
|
2475 |
|
|
+ int16_t *cache1_mv = h->mb.cache.mv[1][x264_scan8[i8*4]];
|
2476 |
|
|
+ int16_t *cache1_mv2 = cache1_mv + pixel_mv_offs[m0->i_pixel];
|
2477 |
|
|
+ const int i_pixel = m0->i_pixel;
|
2478 |
|
|
+ const int bw = x264_pixel_size[i_pixel].w;
|
2479 |
|
|
+ const int bh = x264_pixel_size[i_pixel].h;
|
2480 |
|
|
+ const uint16_t *p_cost_m0x = m0->p_cost_mv - m0->mvp[0];
|
2481 |
|
|
+ const uint16_t *p_cost_m0y = m0->p_cost_mv - m0->mvp[1];
|
2482 |
|
|
+ const uint16_t *p_cost_m1x = m1->p_cost_mv - m1->mvp[0];
|
2483 |
|
|
+ const uint16_t *p_cost_m1y = m1->p_cost_mv - m1->mvp[1];
|
2484 |
|
|
+ ALIGNED_ARRAY_16( uint8_t, pixy_buf,[2],[9][16*16] );
|
2485 |
|
|
+ ALIGNED_8( uint8_t pixu_buf[2][9][8*8] );
|
2486 |
|
|
+ ALIGNED_8( uint8_t pixv_buf[2][9][8*8] );
|
2487 |
|
|
+ uint8_t *src0[9];
|
2488 |
|
|
+ uint8_t *src1[9];
|
2489 |
|
|
+ uint8_t *pix = &h->mb.pic.p_fdec[0][(i8>>1)*8*FDEC_STRIDE+(i8&1)*8];
|
2490 |
|
|
+ uint8_t *pixu = &h->mb.pic.p_fdec[1][(i8>>1)*4*FDEC_STRIDE+(i8&1)*4];
|
2491 |
|
|
+ uint8_t *pixv = &h->mb.pic.p_fdec[2][(i8>>1)*4*FDEC_STRIDE+(i8&1)*4];
|
2492 |
|
|
+ int ref0 = h->mb.cache.ref[0][x264_scan8[i8*4]];
|
2493 |
|
|
+ int ref1 = h->mb.cache.ref[1][x264_scan8[i8*4]];
|
2494 |
|
|
+ int stride0[9];
|
2495 |
|
|
+ int stride1[9];
|
2496 |
|
|
+ int bm0x = m0->mv[0], om0x = bm0x;
|
2497 |
|
|
+ int bm0y = m0->mv[1], om0y = bm0y;
|
2498 |
|
|
+ int bm1x = m1->mv[0], om1x = bm1x;
|
2499 |
|
|
+ int bm1y = m1->mv[1], om1y = bm1y;
|
2500 |
|
|
+ int bcost = COST_MAX;
|
2501 |
|
|
+ int pass = 0;
|
2502 |
|
|
+ int j;
|
2503 |
|
|
+ int mc_list0 = 1, mc_list1 = 1;
|
2504 |
|
|
+ uint64_t bcostrd = COST_MAX64;
|
2505 |
|
|
+ /* each byte of visited represents 8 possible m1y positions, so a 4D array isn't needed */
|
2506 |
|
|
+ ALIGNED_ARRAY_16( uint8_t, visited,[8],[8][8] );
|
2507 |
|
|
+ /* all permutations of an offset in up to 2 of the dimensions */
|
2508 |
|
|
+ static const int8_t dia4d[32][4] = {
|
2509 |
|
|
+ {0,0,0,1}, {0,0,0,-1}, {0,0,1,0}, {0,0,-1,0},
|
2510 |
|
|
+ {0,1,0,0}, {0,-1,0,0}, {1,0,0,0}, {-1,0,0,0},
|
2511 |
|
|
+ {0,0,1,1}, {0,0,-1,-1},{0,1,1,0}, {0,-1,-1,0},
|
2512 |
|
|
+ {1,1,0,0}, {-1,-1,0,0},{1,0,0,1}, {-1,0,0,-1},
|
2513 |
|
|
+ {0,1,0,1}, {0,-1,0,-1},{1,0,1,0}, {-1,0,-1,0},
|
2514 |
|
|
+ {0,0,-1,1},{0,0,1,-1}, {0,-1,1,0},{0,1,-1,0},
|
2515 |
|
|
+ {-1,1,0,0},{1,-1,0,0}, {1,0,0,-1},{-1,0,0,1},
|
2516 |
|
|
+ {0,-1,0,1},{0,1,0,-1}, {-1,0,1,0},{1,0,-1,0},
|
2517 |
|
|
+ };
|
2518 |
|
|
+
|
2519 |
|
|
+ if( bm0y < h->mb.mv_min_spel[1] + 8 || bm1y < h->mb.mv_min_spel[1] + 8 ||
|
2520 |
|
|
+ bm0y > h->mb.mv_max_spel[1] - 8 || bm1y > h->mb.mv_max_spel[1] - 8 )
|
2521 |
|
|
+ return;
|
2522 |
|
|
+
|
2523 |
|
|
+ h->mc.memzero_aligned( visited, sizeof(uint8_t[8][8][8]) );
|
2524 |
|
|
+
|
2525 |
|
|
+ BIME_CACHE( 0, 0, 0 );
|
2526 |
|
|
+ BIME_CACHE( 0, 0, 1 );
|
2527 |
|
|
+ CHECK_BIDIR( 0, 0, 0, 0 );
|
2528 |
|
|
|
2529 |
|
|
- for( pass = 0; pass < 8; pass++ )
|
2530 |
|
|
+ for( pass = 0; pass < 8; pass++ )
|
2531 |
|
|
{
|
2532 |
|
|
- /* check all mv pairs that differ in at most 2 components from the current mvs. */
|
2533 |
|
|
- /* doesn't do chroma ME. this probably doesn't matter, as the gains
|
2534 |
|
|
- * from bidir ME are the same with and without chroma ME. */
|
2535 |
|
|
-
|
2536 |
|
|
- if( mc_list0 )
|
2537 |
|
|
- BIME_CACHE8( 0 );
|
2538 |
|
|
- if( mc_list1 )
|
2539 |
|
|
- BIME_CACHE8( 1 );
|
2540 |
|
|
-
|
2541 |
|
|
- for( j=0; j<32; j++ )
|
2542 |
|
|
- CHECK_BIDIR( dia4d[j][0], dia4d[j][1], dia4d[j][2], dia4d[j][3] );
|
2543 |
|
|
-
|
2544 |
|
|
- mc_list0 = (om0x-bm0x)|(om0y-bm0y);
|
2545 |
|
|
- mc_list1 = (om1x-bm1x)|(om1y-bm1y);
|
2546 |
|
|
- if( !mc_list0 && !mc_list1 )
|
2547 |
|
|
- break;
|
2548 |
|
|
-
|
2549 |
|
|
- om0x = bm0x;
|
2550 |
|
|
- om0y = bm0y;
|
2551 |
|
|
- om1x = bm1x;
|
2552 |
|
|
- om1y = bm1y;
|
2553 |
|
|
-
|
2554 |
|
|
- if( mc_list0 )
|
2555 |
|
|
- BIME_CACHE( 0, 0, 0 );
|
2556 |
|
|
- if( mc_list1 )
|
2557 |
|
|
- BIME_CACHE( 0, 0, 1 );
|
2558 |
|
|
+ /* check all mv pairs that differ in at most 2 components from the current mvs. */
|
2559 |
|
|
+ /* doesn't do chroma ME. this probably doesn't matter, as the gains
|
2560 |
|
|
+ * from bidir ME are the same with and without chroma ME. */
|
2561 |
|
|
+
|
2562 |
|
|
+ if( mc_list0 )
|
2563 |
|
|
+ BIME_CACHE8( 0 );
|
2564 |
|
|
+ if( mc_list1 )
|
2565 |
|
|
+ BIME_CACHE8( 1 );
|
2566 |
|
|
+
|
2567 |
|
|
+ for( j=0; j<32; j++ )
|
2568 |
|
|
+ CHECK_BIDIR( dia4d[j][0], dia4d[j][1], dia4d[j][2], dia4d[j][3] );
|
2569 |
|
|
+
|
2570 |
|
|
+ mc_list0 = (om0x-bm0x)|(om0y-bm0y);
|
2571 |
|
|
+ mc_list1 = (om1x-bm1x)|(om1y-bm1y);
|
2572 |
|
|
+ if( !mc_list0 && !mc_list1 )
|
2573 |
|
|
+ break;
|
2574 |
|
|
+
|
2575 |
|
|
+ om0x = bm0x;
|
2576 |
|
|
+ om0y = bm0y;
|
2577 |
|
|
+ om1x = bm1x;
|
2578 |
|
|
+ om1y = bm1y;
|
2579 |
|
|
+
|
2580 |
|
|
+ if( mc_list0 )
|
2581 |
|
|
+ BIME_CACHE( 0, 0, 0 );
|
2582 |
|
|
+ if( mc_list1 )
|
2583 |
|
|
+ BIME_CACHE( 0, 0, 1 );
|
2584 |
|
|
}
|
2585 |
|
|
|
2586 |
|
|
- m0->mv[0] = bm0x;
|
2587 |
|
|
- m0->mv[1] = bm0y;
|
2588 |
|
|
- m1->mv[0] = bm1x;
|
2589 |
|
|
- m1->mv[1] = bm1y;
|
2590 |
|
|
+ m0->mv[0] = bm0x;
|
2591 |
|
|
+ m0->mv[1] = bm0y;
|
2592 |
|
|
+ m1->mv[0] = bm1x;
|
2593 |
|
|
+ m1->mv[1] = bm1y;
|
2594 |
|
|
}
|
2595 |
|
|
|
2596 |
|
|
void x264_me_refine_bidir_satd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight )
|
2597 |
|
|
{
|
2598 |
|
|
- x264_me_refine_bidir( h, m0, m1, i_weight, 0, 0, 0 );
|
2599 |
|
|
+ x264_me_refine_bidir( h, m0, m1, i_weight, 0, 0, 0 );
|
2600 |
|
|
}
|
2601 |
|
|
|
2602 |
|
|
void x264_me_refine_bidir_rd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2 )
|
2603 |
|
|
{
|
2604 |
|
|
- /* Motion compensation is done as part of bidir_rd; don't repeat
|
2605 |
|
|
- * it in encoding. */
|
2606 |
|
|
- h->mb.b_skip_mc = 1;
|
2607 |
|
|
- x264_me_refine_bidir( h, m0, m1, i_weight, i8, i_lambda2, 1 );
|
2608 |
|
|
- h->mb.b_skip_mc = 0;
|
2609 |
|
|
+ /* Motion compensation is done as part of bidir_rd; don't repeat
|
2610 |
|
|
+ * it in encoding. */
|
2611 |
|
|
+ h->mb.b_skip_mc = 1;
|
2612 |
|
|
+ x264_me_refine_bidir( h, m0, m1, i_weight, i8, i_lambda2, 1 );
|
2613 |
|
|
+ h->mb.b_skip_mc = 0;
|
2614 |
|
|
}
|
2615 |
|
|
|
2616 |
|
|
#undef COST_MV_SATD
|
2617 |
|
|
-#define COST_MV_SATD( mx, my, dst, avoid_mvp ) \
|
2618 |
|
|
-{ \
|
2619 |
|
|
- if( !avoid_mvp || !(mx == pmx && my == pmy) ) \
|
2620 |
|
|
- { \
|
2621 |
|
|
- int stride = 16; \
|
2622 |
|
|
+#define COST_MV_SATD( mx, my, dst, avoid_mvp ) \
|
2623 |
|
|
+ { \
|
2624 |
|
|
+ if( !avoid_mvp || !(mx == pmx && my == pmy) ) \
|
2625 |
|
|
+ { \
|
2626 |
|
|
+ int stride = 16; \
|
2627 |
|
|
uint8_t *src = h->mc.get_ref( pix, &stride, m->p_fref, m->i_stride[0], mx, my, bw*4, bh*4 ); \
|
2628 |
|
|
dst = h->pixf.mbcmp_unaligned[i_pixel]( m->p_fenc[0], FENC_STRIDE, src, stride ) \
|
2629 |
|
|
- + p_cost_mvx[mx] + p_cost_mvy[my]; \
|
2630 |
|
|
- COPY1_IF_LT( bsatd, dst ); \
|
2631 |
|
|
- } \
|
2632 |
|
|
- else \
|
2633 |
|
|
- dst = COST_MAX; \
|
2634 |
|
|
-}
|
2635 |
|
|
-
|
2636 |
|
|
-#define COST_MV_RD( mx, my, satd, do_dir, mdir ) \
|
2637 |
|
|
-{ \
|
2638 |
|
|
- if( satd <= bsatd * SATD_THRESH ) \
|
2639 |
|
|
- { \
|
2640 |
|
|
- uint64_t cost; \
|
2641 |
|
|
+ + p_cost_mvx[mx] + p_cost_mvy[my]; \
|
2642 |
|
|
+ COPY1_IF_LT( bsatd, dst ); \
|
2643 |
|
|
+ } \
|
2644 |
|
|
+ else \
|
2645 |
|
|
+ dst = COST_MAX; \
|
2646 |
|
|
+ }
|
2647 |
|
|
+
|
2648 |
|
|
+#define COST_MV_RD( mx, my, satd, do_dir, mdir ) \
|
2649 |
|
|
+ { \
|
2650 |
|
|
+ if( satd <= bsatd * SATD_THRESH ) \
|
2651 |
|
|
+ { \
|
2652 |
|
|
+ uint64_t cost; \
|
2653 |
|
|
*(uint32_t*)cache_mv = *(uint32_t*)cache_mv2 = pack16to32_mask(mx,my); \
|
2654 |
|
|
- cost = x264_rd_cost_part( h, i_lambda2, i4, m->i_pixel ); \
|
2655 |
|
|
+ cost = x264_rd_cost_part( h, i_lambda2, i4, m->i_pixel ); \
|
2656 |
|
|
COPY4_IF_LT( bcost, cost, bmx, mx, bmy, my, dir, do_dir?mdir:dir ); \
|
2657 |
|
|
- } \
|
2658 |
|
|
-}
|
2659 |
|
|
+ } \
|
2660 |
|
|
+ }
|
2661 |
|
|
|
2662 |
|
|
void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i4, int i_list )
|
2663 |
|
|
{
|
2664 |
|
|
- // don't have to fill the whole mv cache rectangle
|
2665 |
|
|
- static const int pixel_mv_offs[] = { 0, 4, 4*8, 0, 2, 2*8, 0 };
|
2666 |
|
|
- int16_t *cache_mv = h->mb.cache.mv[i_list][x264_scan8[i4]];
|
2667 |
|
|
- int16_t *cache_mv2 = cache_mv + pixel_mv_offs[m->i_pixel];
|
2668 |
|
|
- const uint16_t *p_cost_mvx, *p_cost_mvy;
|
2669 |
|
|
- const int bw = x264_pixel_size[m->i_pixel].w>>2;
|
2670 |
|
|
- const int bh = x264_pixel_size[m->i_pixel].h>>2;
|
2671 |
|
|
- const int i_pixel = m->i_pixel;
|
2672 |
|
|
-
|
2673 |
|
|
- ALIGNED_ARRAY_16( uint8_t, pix,[16*16] );
|
2674 |
|
|
- uint64_t bcost = COST_MAX64;
|
2675 |
|
|
- int bmx = m->mv[0];
|
2676 |
|
|
- int bmy = m->mv[1];
|
2677 |
|
|
- int omx, omy, pmx, pmy, i, j;
|
2678 |
|
|
- unsigned bsatd;
|
2679 |
|
|
- int satd = 0;
|
2680 |
|
|
- int dir = -2;
|
2681 |
|
|
- int satds[8];
|
2682 |
|
|
-
|
2683 |
|
|
- if( m->i_pixel != PIXEL_16x16 && i4 != 0 )
|
2684 |
|
|
- x264_mb_predict_mv( h, i_list, i4, bw, m->mvp );
|
2685 |
|
|
- pmx = m->mvp[0];
|
2686 |
|
|
- pmy = m->mvp[1];
|
2687 |
|
|
- p_cost_mvx = m->p_cost_mv - pmx;
|
2688 |
|
|
- p_cost_mvy = m->p_cost_mv - pmy;
|
2689 |
|
|
- COST_MV_SATD( bmx, bmy, bsatd, 0 );
|
2690 |
|
|
- if( m->i_pixel != PIXEL_16x16 )
|
2691 |
|
|
- COST_MV_RD( bmx, bmy, 0, 0, 0 )
|
2692 |
|
|
+ // don't have to fill the whole mv cache rectangle
|
2693 |
|
|
+ static const int pixel_mv_offs[] = { 0, 4, 4*8, 0, 2, 2*8, 0 };
|
2694 |
|
|
+ int16_t *cache_mv = h->mb.cache.mv[i_list][x264_scan8[i4]];
|
2695 |
|
|
+ int16_t *cache_mv2 = cache_mv + pixel_mv_offs[m->i_pixel];
|
2696 |
|
|
+ const uint16_t *p_cost_mvx, *p_cost_mvy;
|
2697 |
|
|
+ const int bw = x264_pixel_size[m->i_pixel].w>>2;
|
2698 |
|
|
+ const int bh = x264_pixel_size[m->i_pixel].h>>2;
|
2699 |
|
|
+ const int i_pixel = m->i_pixel;
|
2700 |
|
|
+
|
2701 |
|
|
+ ALIGNED_ARRAY_16( uint8_t, pix,[16*16] );
|
2702 |
|
|
+ uint64_t bcost = COST_MAX64;
|
2703 |
|
|
+ int bmx = m->mv[0];
|
2704 |
|
|
+ int bmy = m->mv[1];
|
2705 |
|
|
+ int omx, omy, pmx, pmy, i, j;
|
2706 |
|
|
+ unsigned bsatd;
|
2707 |
|
|
+ int satd = 0;
|
2708 |
|
|
+ int dir = -2;
|
2709 |
|
|
+ int satds[8];
|
2710 |
|
|
+
|
2711 |
|
|
+ if( m->i_pixel != PIXEL_16x16 && i4 != 0 )
|
2712 |
|
|
+ x264_mb_predict_mv( h, i_list, i4, bw, m->mvp );
|
2713 |
|
|
+ pmx = m->mvp[0];
|
2714 |
|
|
+ pmy = m->mvp[1];
|
2715 |
|
|
+ p_cost_mvx = m->p_cost_mv - pmx;
|
2716 |
|
|
+ p_cost_mvy = m->p_cost_mv - pmy;
|
2717 |
|
|
+ COST_MV_SATD( bmx, bmy, bsatd, 0 );
|
2718 |
|
|
+ if( m->i_pixel != PIXEL_16x16 )
|
2719 |
|
|
+ COST_MV_RD( bmx, bmy, 0, 0, 0 )
|
2720 |
|
|
else
|
2721 |
|
|
- bcost = m->cost;
|
2722 |
|
|
+ bcost = m->cost;
|
2723 |
|
|
|
2724 |
|
|
- /* check the predicted mv */
|
2725 |
|
|
- if( (bmx != pmx || bmy != pmy)
|
2726 |
|
|
- && pmx >= h->mb.mv_min_spel[0] && pmx <= h->mb.mv_max_spel[0]
|
2727 |
|
|
- && pmy >= h->mb.mv_min_spel[1] && pmy <= h->mb.mv_max_spel[1] )
|
2728 |
|
|
+ /* check the predicted mv */
|
2729 |
|
|
+ if( (bmx != pmx || bmy != pmy)
|
2730 |
|
|
+ && pmx >= h->mb.mv_min_spel[0] && pmx <= h->mb.mv_max_spel[0]
|
2731 |
|
|
+ && pmy >= h->mb.mv_min_spel[1] && pmy <= h->mb.mv_max_spel[1] )
|
2732 |
|
|
{
|
2733 |
|
|
- COST_MV_SATD( pmx, pmy, satd, 0 );
|
2734 |
|
|
- COST_MV_RD( pmx, pmy, satd, 0,0 );
|
2735 |
|
|
- /* The hex motion search is guaranteed to not repeat the center candidate,
|
2736 |
|
|
- * so if pmv is chosen, set the "MV to avoid checking" to bmv instead. */
|
2737 |
|
|
- if( bmx == pmx && bmy == pmy )
|
2738 |
|
|
+ COST_MV_SATD( pmx, pmy, satd, 0 );
|
2739 |
|
|
+ COST_MV_RD( pmx, pmy, satd, 0,0 );
|
2740 |
|
|
+ /* The hex motion search is guaranteed to not repeat the center candidate,
|
2741 |
|
|
+ * so if pmv is chosen, set the "MV to avoid checking" to bmv instead. */
|
2742 |
|
|
+ if( bmx == pmx && bmy == pmy )
|
2743 |
|
|
{
|
2744 |
|
|
- pmx = m->mv[0];
|
2745 |
|
|
- pmy = m->mv[1];
|
2746 |
|
|
+ pmx = m->mv[0];
|
2747 |
|
|
+ pmy = m->mv[1];
|
2748 |
|
|
}
|
2749 |
|
|
}
|
2750 |
|
|
|
2751 |
|
|
- if( bmy < h->mb.mv_min_spel[1] + 3 ||
|
2752 |
|
|
- bmy > h->mb.mv_max_spel[1] - 3 )
|
2753 |
|
|
- return;
|
2754 |
|
|
-
|
2755 |
|
|
- /* subpel hex search, same pattern as ME HEX. */
|
2756 |
|
|
- dir = -2;
|
2757 |
|
|
- omx = bmx;
|
2758 |
|
|
- omy = bmy;
|
2759 |
|
|
- for( j=0; j<6; j++ ) COST_MV_SATD( omx + hex2[j+1][0], omy + hex2[j+1][1], satds[j], 1 );
|
2760 |
|
|
- for( j=0; j<6; j++ ) COST_MV_RD ( omx + hex2[j+1][0], omy + hex2[j+1][1], satds[j], 1,j );
|
2761 |
|
|
+ if( bmy < h->mb.mv_min_spel[1] + 3 ||
|
2762 |
|
|
+ bmy > h->mb.mv_max_spel[1] - 3 )
|
2763 |
|
|
+ return;
|
2764 |
|
|
+
|
2765 |
|
|
+ /* subpel hex search, same pattern as ME HEX. */
|
2766 |
|
|
+ dir = -2;
|
2767 |
|
|
+ omx = bmx;
|
2768 |
|
|
+ omy = bmy;
|
2769 |
|
|
+ for( j=0; j<6; j++ ) COST_MV_SATD( omx + hex2[j+1][0], omy + hex2[j+1][1], satds[j], 1 );
|
2770 |
|
|
+ for( j=0; j<6; j++ ) COST_MV_RD ( omx + hex2[j+1][0], omy + hex2[j+1][1], satds[j], 1,j );
|
2771 |
|
|
|
2772 |
|
|
- if( dir != -2 )
|
2773 |
|
|
+ if( dir != -2 )
|
2774 |
|
|
{
|
2775 |
|
|
- /* half hexagon, not overlapping the previous iteration */
|
2776 |
|
|
- for( i = 1; i < 10; i++ )
|
2777 |
|
|
+ /* half hexagon, not overlapping the previous iteration */
|
2778 |
|
|
+ for( i = 1; i < 10; i++ )
|
2779 |
|
|
{
|
2780 |
|
|
- const int odir = mod6m1[dir+1];
|
2781 |
|
|
- if( bmy < h->mb.mv_min_spel[1] + 3 ||
|
2782 |
|
|
- bmy > h->mb.mv_max_spel[1] - 3 )
|
2783 |
|
|
- break;
|
2784 |
|
|
- dir = -2;
|
2785 |
|
|
- omx = bmx;
|
2786 |
|
|
- omy = bmy;
|
2787 |
|
|
- for( j=0; j<3; j++ ) COST_MV_SATD( omx + hex2[odir+j][0], omy + hex2[odir+j][1], satds[j], 1 );
|
2788 |
|
|
- for( j=0; j<3; j++ ) COST_MV_RD ( omx + hex2[odir+j][0], omy + hex2[odir+j][1], satds[j], 1, odir-1+j );
|
2789 |
|
|
- if( dir == -2 )
|
2790 |
|
|
- break;
|
2791 |
|
|
+ const int odir = mod6m1[dir+1];
|
2792 |
|
|
+ if( bmy < h->mb.mv_min_spel[1] + 3 ||
|
2793 |
|
|
+ bmy > h->mb.mv_max_spel[1] - 3 )
|
2794 |
|
|
+ break;
|
2795 |
|
|
+ dir = -2;
|
2796 |
|
|
+ omx = bmx;
|
2797 |
|
|
+ omy = bmy;
|
2798 |
|
|
+ for( j=0; j<3; j++ ) COST_MV_SATD( omx + hex2[odir+j][0], omy + hex2[odir+j][1], satds[j], 1 );
|
2799 |
|
|
+ for( j=0; j<3; j++ ) COST_MV_RD ( omx + hex2[odir+j][0], omy + hex2[odir+j][1], satds[j], 1, odir-1+j );
|
2800 |
|
|
+ if( dir == -2 )
|
2801 |
|
|
+ break;
|
2802 |
|
|
}
|
2803 |
|
|
}
|
2804 |
|
|
|
2805 |
|
|
- /* square refine, same pattern as ME HEX. */
|
2806 |
|
|
- omx = bmx;
|
2807 |
|
|
- omy = bmy;
|
2808 |
|
|
- for( i=0; i<8; i++ ) COST_MV_SATD( omx + square1[i+1][0], omy + square1[i+1][1], satds[i], 1 );
|
2809 |
|
|
- for( i=0; i<8; i++ ) COST_MV_RD ( omx + square1[i+1][0], omy + square1[i+1][1], satds[i], 0,0 );
|
2810 |
|
|
-
|
2811 |
|
|
- m->cost = bcost;
|
2812 |
|
|
- m->mv[0] = bmx;
|
2813 |
|
|
- m->mv[1] = bmy;
|
2814 |
|
|
- x264_macroblock_cache_mv ( h, block_idx_x[i4], block_idx_y[i4], bw, bh, i_list, pack16to32_mask(bmx, bmy) );
|
2815 |
|
|
- x264_macroblock_cache_mvd( h, block_idx_x[i4], block_idx_y[i4], bw, bh, i_list, pack16to32_mask(bmx - m->mvp[0], bmy - m->mvp[1]) );
|
2816 |
|
|
+ /* square refine, same pattern as ME HEX. */
|
2817 |
|
|
+ omx = bmx;
|
2818 |
|
|
+ omy = bmy;
|
2819 |
|
|
+ for( i=0; i<8; i++ ) COST_MV_SATD( omx + square1[i+1][0], omy + square1[i+1][1], satds[i], 1 );
|
2820 |
|
|
+ for( i=0; i<8; i++ ) COST_MV_RD ( omx + square1[i+1][0], omy + square1[i+1][1], satds[i], 0,0 );
|
2821 |
|
|
+
|
2822 |
|
|
+ m->cost = bcost;
|
2823 |
|
|
+ m->mv[0] = bmx;
|
2824 |
|
|
+ m->mv[1] = bmy;
|
2825 |
|
|
+ x264_macroblock_cache_mv ( h, block_idx_x[i4], block_idx_y[i4], bw, bh, i_list, pack16to32_mask(bmx, bmy) );
|
2826 |
|
|
+ x264_macroblock_cache_mvd( h, block_idx_x[i4], block_idx_y[i4], bw, bh, i_list, pack16to32_mask(bmx - m->mvp[0], bmy - m->mvp[1]) );
|
2827 |
|
|
}
|
2828 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/encoder/slicetype.c x264-or/encoder/slicetype.c
|
2829 |
|
|
--- x264/encoder/slicetype.c 2009-10-25 17:41:22.000000000 +0100
|
2830 |
|
|
+++ x264-or/encoder/slicetype.c 2009-10-28 15:05:29.000000000 +0100
|
2831 |
|
|
@@ -909,7 +909,9 @@
|
2832 |
|
|
|
2833 |
|
|
/* Restore frametypes for all frames that haven't actually been decided yet. */
|
2834 |
|
|
for( j = reset_start; j <= num_frames; j++ )
|
2835 |
|
|
- frames[j]->i_type = X264_TYPE_AUTO;
|
2836 |
|
|
+ frames[j]->i_type = X264_TYPE_AUTO;
|
2837 |
|
|
+
|
2838 |
|
|
+ return;
|
2839 |
|
|
}
|
2840 |
|
|
|
2841 |
|
|
void x264_slicetype_decide( x264_t *h )
|
2842 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/link.ld x264-or/link.ld
|
2843 |
|
|
--- x264/link.ld 1970-01-01 01:00:00.000000000 +0100
|
2844 |
|
|
+++ x264-or/link.ld 2009-10-28 15:05:29.000000000 +0100
|
2845 |
|
|
@@ -0,0 +1,100 @@
|
2846 |
|
|
+/*
|
2847 |
|
|
+MEMORY
|
2848 |
|
|
+ {
|
2849 |
|
|
+ vectors : ORIGIN = 0x00000000, LENGTH = 0x00002000
|
2850 |
|
|
+ flash : ORIGIN = 0x04000000, LENGTH = 0x00200000
|
2851 |
|
|
+ ram : ORIGIN = 0x00002000, LENGTH = 0x001fe000
|
2852 |
|
|
+ icm : ORIGIN = 0x00800000, LENGTH = 0x00004000
|
2853 |
|
|
+ }
|
2854 |
|
|
+ */
|
2855 |
|
|
+
|
2856 |
|
|
+MEMORY
|
2857 |
|
|
+ {
|
2858 |
|
|
+/*
|
2859 |
|
|
+ reset : ORIGIN = 0x00000000, LENGTH = 0x00000200
|
2860 |
|
|
+ vectors : ORIGIN = 0x00000200, LENGTH = 0x00001E00
|
2861 |
|
|
+ text : ORIGIN = 0x00002000, LENGTH = 0x000fe000
|
2862 |
|
|
+ data : ORIGIN = 0x00100000, LENGTH = 0x00fe0000
|
2863 |
|
|
+ stack : ORIGIN = 0x001fe000, LENGTH = 0x00010000
|
2864 |
|
|
+*/
|
2865 |
|
|
+ yuv_data : ORIGIN = 25M, LENGTH = 7M
|
2866 |
|
|
+ }
|
2867 |
|
|
+
|
2868 |
|
|
+/*
|
2869 |
|
|
+MEMORY
|
2870 |
|
|
+ {
|
2871 |
|
|
+ reset : ORIGIN = 0xc0000000, LENGTH = 0x00000200
|
2872 |
|
|
+ vectors : ORIGIN = 0xc0000200, LENGTH = 0x00001000
|
2873 |
|
|
+ ram : ORIGIN = 0xc0001200, LENGTH = 0x00FFED00
|
2874 |
|
|
+ }
|
2875 |
|
|
+*/
|
2876 |
|
|
+SECTIONS
|
2877 |
|
|
+{
|
2878 |
|
|
+/*
|
2879 |
|
|
+ .reset :
|
2880 |
|
|
+ {
|
2881 |
|
|
+ *(.reset)
|
2882 |
|
|
+ } > reset
|
2883 |
|
|
+
|
2884 |
|
|
+
|
2885 |
|
|
+
|
2886 |
|
|
+ .vectors :
|
2887 |
|
|
+ {
|
2888 |
|
|
+ _vec_start = .;
|
2889 |
|
|
+ *(.vectors)
|
2890 |
|
|
+ _vec_end = .;
|
2891 |
|
|
+ } > vectors
|
2892 |
|
|
+
|
2893 |
|
|
+ .text :
|
2894 |
|
|
+ {
|
2895 |
|
|
+ *(.text)
|
2896 |
|
|
+ } > text
|
2897 |
|
|
+
|
2898 |
|
|
+ .rodata :
|
2899 |
|
|
+ {
|
2900 |
|
|
+ *(.rodata)
|
2901 |
|
|
+ *(.rodata.*)
|
2902 |
|
|
+ } > text
|
2903 |
|
|
+
|
2904 |
|
|
+ .icm :
|
2905 |
|
|
+ {
|
2906 |
|
|
+ _icm_start = .;
|
2907 |
|
|
+ *(.icm)
|
2908 |
|
|
+ _icm_end = .;
|
2909 |
|
|
+ } > data
|
2910 |
|
|
+
|
2911 |
|
|
+ .data :
|
2912 |
|
|
+ {
|
2913 |
|
|
+ _dst_beg = .;
|
2914 |
|
|
+ *(.data)
|
2915 |
|
|
+ _dst_end = .;
|
2916 |
|
|
+ } > data
|
2917 |
|
|
+
|
2918 |
|
|
+ .bss :
|
2919 |
|
|
+ {
|
2920 |
|
|
+ *(.bss)
|
2921 |
|
|
+ } > data
|
2922 |
|
|
+
|
2923 |
|
|
+ .heap :
|
2924 |
|
|
+ {
|
2925 |
|
|
+ _heap_start = .;
|
2926 |
|
|
+ *(.heap)
|
2927 |
|
|
+ _heap_end = .;
|
2928 |
|
|
+ } > data
|
2929 |
|
|
+
|
2930 |
|
|
+ .stack (NOLOAD) :
|
2931 |
|
|
+ {
|
2932 |
|
|
+ *(.stack)
|
2933 |
|
|
+ _src_addr = .;
|
2934 |
|
|
+ } > data
|
2935 |
|
|
+*/
|
2936 |
|
|
+ .yuv_data :
|
2937 |
|
|
+ {
|
2938 |
|
|
+ _yuv_data_start = .;
|
2939 |
|
|
+ __yuv_data_start = .;
|
2940 |
|
|
+ *(.yuv_data)
|
2941 |
|
|
+ _yuv_data_end = .;
|
2942 |
|
|
+ __yuv_data_end = .;
|
2943 |
|
|
+ } > yuv_data
|
2944 |
|
|
+
|
2945 |
|
|
+}
|
2946 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/Makefile x264-or/Makefile
|
2947 |
|
|
--- x264/Makefile 2009-10-25 17:41:22.000000000 +0100
|
2948 |
|
|
+++ x264-or/Makefile 2009-11-15 18:48:46.000000000 +0100
|
2949 |
|
|
@@ -91,7 +91,66 @@
|
2950 |
|
|
$(SONAME): .depend $(OBJS) $(OBJASM)
|
2951 |
|
|
$(CC) -shared -o $@ $(OBJS) $(OBJASM) $(SOFLAGS) $(LDFLAGS)
|
2952 |
|
|
|
2953 |
|
|
-x264$(EXE): $(OBJCLI) libx264.a
|
2954 |
|
|
+
|
2955 |
|
|
+## OR32-specific build rules
|
2956 |
|
|
+##
|
2957 |
|
|
+## Essentially we create some sample YUV video data
|
2958 |
|
|
+## and embed it in an ELF file, in a section called yuv_data.
|
2959 |
|
|
+## In the linker script we then link this section to a place
|
2960 |
|
|
+## in ram and tell x264 to look here when it wants data.
|
2961 |
|
|
+##
|
2962 |
|
|
+## You can download sample h264 encoded CIF sequences
|
2963 |
|
|
+## here: http://www.tkn.tu-berlin.de/research/evalvid/cif.html
|
2964 |
|
|
+##
|
2965 |
|
|
+##
|
2966 |
|
|
+GEN_FILES=encoder/analyse_init_log2.c
|
2967 |
|
|
+VIDEO_DATA_FILE=yuv_data.elf
|
2968 |
|
|
+INPUT_VIDEO_FILE ?= ../test-sequences/football_cif.264
|
2969 |
|
|
+INPUT_VIDEO_SIZE ?= cif
|
2970 |
|
|
+YUV_VIDEO_FILE ?= video_data.yuv
|
2971 |
|
|
+
|
2972 |
|
|
+# We will use a limit of about 5MB of video data to encode
|
2973 |
|
|
+ifeq ($(INPUT_VIDEO_SIZE), 4cif)
|
2974 |
|
|
+NUM_FRAMES ?=10
|
2975 |
|
|
+endif
|
2976 |
|
|
+ifeq ($(INPUT_VIDEO_SIZE), cif)
|
2977 |
|
|
+NUM_FRAMES ?=30
|
2978 |
|
|
+endif
|
2979 |
|
|
+ifeq ($(INPUT_VIDEO_SIZE), qcif)
|
2980 |
|
|
+NUM_FRAMES ?=90
|
2981 |
|
|
+endif
|
2982 |
|
|
+
|
2983 |
|
|
+$(INPUT_VIDEO_FILE):
|
2984 |
|
|
+ @echo; echo;
|
2985 |
|
|
+ @echo "\tNo sample video file to embed! Please edit the Makefile"
|
2986 |
|
|
+ @echo "\tand set the variable INPUT_VIDEO_FILE to the location of"
|
2987 |
|
|
+ @echo "\tsome sample video material."
|
2988 |
|
|
+ @echo "\tOr, isntead of editing the makefile, specify it on the"
|
2989 |
|
|
+ @echo "\tcommand line like so:"
|
2990 |
|
|
+ @echo "\t\tINPUT_VIDEO_FILE=../coastguard_cif.yuv"; echo
|
2991 |
|
|
+ @echo "\tYou can also specify the size of the video (cif, qcif etc.)"
|
2992 |
|
|
+ @echo "\tby specifying INPUT_VIDEO_SIZE - the default is cif, however"
|
2993 |
|
|
+ @echo "\tyou will need to change the program's hardcoded resolution"
|
2994 |
|
|
+ @echo
|
2995 |
|
|
+ exit 1
|
2996 |
|
|
+$(YUV_VIDEO_FILE): $(INPUT_VIDEO_FILE)
|
2997 |
|
|
+# First convert it to raw YUV, only about 5MB large, so for cif take 30 frames, qcif is 90 frames
|
2998 |
|
|
+ ffmpeg -s $(INPUT_VIDEO_SIZE) -i $(INPUT_VIDEO_FILE) -vframes $(NUM_FRAMES) $(YUV_VIDEO_FILE)
|
2999 |
|
|
+$(VIDEO_DATA_FILE): $(YUV_VIDEO_FILE)
|
3000 |
|
|
+ or32-elf-ld -r -b binary -o yuv_data.o $(YUV_VIDEO_FILE)
|
3001 |
|
|
+ or32-elf-objcopy --rename-section .data=.yuv_data yuv_data.o
|
3002 |
|
|
+ mv yuv_data.o $(VIDEO_DATA_FILE)
|
3003 |
|
|
+encoder/analyse_init_log2.c: encoder/analyse_gen_init_array.sh
|
3004 |
|
|
+ cd encoder && chmod a+x analyse_gen_init_array.sh && ./analyse_gen_init_array.sh
|
3005 |
|
|
+#OR32_DEPS= reset.o except.o uart.o syscalls.o $(VIDEO_DATA_FILE)
|
3006 |
|
|
+
|
3007 |
|
|
+OR32_DEPS= $(VIDEO_DATA_FILE) $(GEN_FILES)
|
3008 |
|
|
+
|
3009 |
|
|
+sim: x264$(EXE)
|
3010 |
|
|
+ or32-elf-sim -f or1ksim_x264.cfg $<
|
3011 |
|
|
+
|
3012 |
|
|
+
|
3013 |
|
|
+x264$(EXE): $(OR32_DEPS) $(OBJCLI) libx264.a
|
3014 |
|
|
$(CC) -o $@ $+ $(LDFLAGS)
|
3015 |
|
|
|
3016 |
|
|
checkasm: tools/checkasm.o libx264.a
|
3017 |
|
|
@@ -147,12 +206,13 @@
|
3018 |
|
|
endif
|
3019 |
|
|
|
3020 |
|
|
clean:
|
3021 |
|
|
- rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS
|
3022 |
|
|
+ rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS $(YUV_VIDEO_FILE)
|
3023 |
|
|
rm -f checkasm checkasm.exe tools/checkasm.o tools/checkasm-a.o
|
3024 |
|
|
rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
|
3025 |
|
|
- sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
|
3026 |
|
|
|
3027 |
|
|
distclean: clean
|
3028 |
|
|
+ rm -f $(OR32_DEPS) uart0* $(GEN_FILES)
|
3029 |
|
|
rm -f config.mak config.h x264.pc
|
3030 |
|
|
rm -rf test/
|
3031 |
|
|
|
3032 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/muxers.c x264-or/muxers.c
|
3033 |
|
|
--- x264/muxers.c 2009-10-25 17:41:22.000000000 +0100
|
3034 |
|
|
+++ x264-or/muxers.c 2009-11-15 18:45:09.000000000 +0100
|
3035 |
|
|
@@ -52,15 +52,32 @@
|
3036 |
|
|
|
3037 |
|
|
typedef struct
|
3038 |
|
|
{
|
3039 |
|
|
- FILE *fh;
|
3040 |
|
|
- int width, height;
|
3041 |
|
|
- int next_frame;
|
3042 |
|
|
+ //FILE *fh;
|
3043 |
|
|
+ char *fh;
|
3044 |
|
|
+
|
3045 |
|
|
+ int width, height;
|
3046 |
|
|
+ int next_frame;
|
3047 |
|
|
+
|
3048 |
|
|
} yuv_input_t;
|
3049 |
|
|
|
3050 |
|
|
+void init_yuv_dataspace(char* yuv_dat_addr, hnd_t *p_handle, x264_param_t *p_param)
|
3051 |
|
|
+{
|
3052 |
|
|
+ yuv_input_t *h = malloc( sizeof(yuv_input_t) );
|
3053 |
|
|
+ V(fprintf( stderr, "init_yuv_dataspace: h addr = 0x%.8x\n", h));
|
3054 |
|
|
+ h->fh = yuv_dat_addr;
|
3055 |
|
|
+ V(fprintf( stderr, "init_yuv_dataspace: h->fh 0x%.8x\n",h->fh));
|
3056 |
|
|
+ h->width = p_param->i_width;
|
3057 |
|
|
+ V(fprintf( stderr, "init_yuv_dataspace: h->width %d\n",h->width));
|
3058 |
|
|
+ h->height = p_param->i_height;
|
3059 |
|
|
+ V(fprintf( stderr, "init_yuv_dataspace: h->height %d\n",h->height));
|
3060 |
|
|
+ h->next_frame = 0;
|
3061 |
|
|
+ *p_handle = (hnd_t *)h;
|
3062 |
|
|
+}
|
3063 |
|
|
+
|
3064 |
|
|
/* raw 420 yuv file operation */
|
3065 |
|
|
int open_file_yuv( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param )
|
3066 |
|
|
{
|
3067 |
|
|
- yuv_input_t *h = malloc( sizeof(yuv_input_t) );
|
3068 |
|
|
+ yuv_input_t *h = malloc( sizeof(yuv_input_t) );
|
3069 |
|
|
if( !h )
|
3070 |
|
|
return -1;
|
3071 |
|
|
h->width = p_param->i_width;
|
3072 |
|
|
@@ -80,7 +97,10 @@
|
3073 |
|
|
|
3074 |
|
|
int get_frame_total_yuv( hnd_t handle )
|
3075 |
|
|
{
|
3076 |
|
|
- yuv_input_t *h = handle;
|
3077 |
|
|
+ yuv_input_t *h = handle;
|
3078 |
|
|
+
|
3079 |
|
|
+ V(fprintf(stderr, "get_frame_total_yuv args: handle: 0x%.8x, h: 0x%.8x\n", handle, h));
|
3080 |
|
|
+ /*
|
3081 |
|
|
int i_frame_total = 0;
|
3082 |
|
|
|
3083 |
|
|
if( !fseek( h->fh, 0, SEEK_END ) )
|
3084 |
|
|
@@ -88,24 +108,45 @@
|
3085 |
|
|
uint64_t i_size = ftell( h->fh );
|
3086 |
|
|
fseek( h->fh, 0, SEEK_SET );
|
3087 |
|
|
i_frame_total = (int)(i_size / ( h->width * h->height * 3 / 2 ));
|
3088 |
|
|
- }
|
3089 |
|
|
+ }*/
|
3090 |
|
|
+
|
3091 |
|
|
+#ifdef USE_HARDCODED_FRAME_NUM
|
3092 |
|
|
+ return (int)HARDCODED_FRAME_NUM;
|
3093 |
|
|
+#else
|
3094 |
|
|
+ fprintf( stderr, "get_frame_total_yuv: %d %d %d %d\n",
|
3095 |
|
|
+ h->width, h->height,
|
3096 |
|
|
+ YUV_DATA_SIZE,
|
3097 |
|
|
+ (int)(YUV_DATA_SIZE / ( h->width * h->height * 3 / 2 )));
|
3098 |
|
|
+ return (int)(YUV_DATA_SIZE / ( h->width * h->height * 3 / 2 ));//i_frame_total;
|
3099 |
|
|
+
|
3100 |
|
|
+#endif
|
3101 |
|
|
|
3102 |
|
|
- return i_frame_total;
|
3103 |
|
|
}
|
3104 |
|
|
|
3105 |
|
|
int read_frame_yuv( x264_picture_t *p_pic, hnd_t handle, int i_frame )
|
3106 |
|
|
{
|
3107 |
|
|
yuv_input_t *h = handle;
|
3108 |
|
|
-
|
3109 |
|
|
+ int i;
|
3110 |
|
|
+
|
3111 |
|
|
if( i_frame != h->next_frame )
|
3112 |
|
|
- if( fseek( h->fh, (uint64_t)i_frame * h->width * h->height * 3 / 2, SEEK_SET ) )
|
3113 |
|
|
- return -1;
|
3114 |
|
|
-
|
3115 |
|
|
- if( fread( p_pic->img.plane[0], 1, h->width * h->height, h->fh ) <= 0
|
3116 |
|
|
- || fread( p_pic->img.plane[1], 1, h->width * h->height / 4, h->fh ) <= 0
|
3117 |
|
|
- || fread( p_pic->img.plane[2], 1, h->width * h->height / 4, h->fh ) <= 0 )
|
3118 |
|
|
- return -1;
|
3119 |
|
|
+ //if( fseek( h->fh, (uint64_t)i_frame * h->width * h->height * 3 / 2, SEEK_SET ) )
|
3120 |
|
|
+ // Progress pointer to beginning of this frame
|
3121 |
|
|
+ h->fh = (void*) YUV_DATA_ADDR + i_frame * h->width * h->height * 3 / 2;
|
3122 |
|
|
+ //return -1;
|
3123 |
|
|
+
|
3124 |
|
|
+ //if( fread( p_pic->img.plane[0], 1, h->width * h->height, h->fh ) <= 0
|
3125 |
|
|
+ for (i=0;i<h->width * h->height;i++) p_pic->img.plane[0][i] = h->fh[i];
|
3126 |
|
|
+ h->fh += h->width * h->height;
|
3127 |
|
|
+ //|| fread( p_pic->img.plane[1], 1, h->width * h->height / 4, h->fh ) <= 0
|
3128 |
|
|
+ for (i=0;i<(h->width * h->height) / 4;i++) p_pic->img.plane[1][i] = h->fh[i];
|
3129 |
|
|
+ h->fh += (h->width * h->height) / 4;
|
3130 |
|
|
+
|
3131 |
|
|
+ //|| fread( p_pic->img.plane[2], 1, h->width * h->height / 4, h->fh ) <= 0 )
|
3132 |
|
|
+ for (i=0;i<(h->width * h->height) / 4;i++) p_pic->img.plane[2][i] = h->fh[i];
|
3133 |
|
|
+ h->fh += (h->width * h->height) / 4;
|
3134 |
|
|
|
3135 |
|
|
+ //return -1;
|
3136 |
|
|
+
|
3137 |
|
|
h->next_frame = i_frame+1;
|
3138 |
|
|
|
3139 |
|
|
return 0;
|
3140 |
|
|
@@ -113,12 +154,15 @@
|
3141 |
|
|
|
3142 |
|
|
int close_file_yuv(hnd_t handle)
|
3143 |
|
|
{
|
3144 |
|
|
+ return 0;
|
3145 |
|
|
+ /* // -- jb
|
3146 |
|
|
yuv_input_t *h = handle;
|
3147 |
|
|
if( !h || !h->fh )
|
3148 |
|
|
return 0;
|
3149 |
|
|
fclose( h->fh );
|
3150 |
|
|
free( h );
|
3151 |
|
|
return 0;
|
3152 |
|
|
+ */
|
3153 |
|
|
}
|
3154 |
|
|
|
3155 |
|
|
/* YUV4MPEG2 raw 420 yuv file operation */
|
3156 |
|
|
@@ -530,11 +574,21 @@
|
3157 |
|
|
}
|
3158 |
|
|
#endif
|
3159 |
|
|
|
3160 |
|
|
+#ifdef ENC_OUT_ADDR
|
3161 |
|
|
+char * enc_out_pos;
|
3162 |
|
|
+#endif
|
3163 |
|
|
|
3164 |
|
|
int open_file_bsf( char *psz_filename, hnd_t *p_handle )
|
3165 |
|
|
{
|
3166 |
|
|
+#ifdef ENC_OUT_ADDR
|
3167 |
|
|
+ V(fprintf(stderr, "open_file_bsf\n"));
|
3168 |
|
|
+ // Use a hardcoded memory location for outputting encoded data to
|
3169 |
|
|
+ p_handle = (void *) ENC_OUT_ADDR;
|
3170 |
|
|
+ enc_out_pos = (char *) ENC_OUT_ADDR;
|
3171 |
|
|
+#else
|
3172 |
|
|
if( !(*p_handle = fopen(psz_filename, "w+b")) )
|
3173 |
|
|
return -1;
|
3174 |
|
|
+#endif
|
3175 |
|
|
|
3176 |
|
|
return 0;
|
3177 |
|
|
}
|
3178 |
|
|
@@ -546,9 +600,16 @@
|
3179 |
|
|
|
3180 |
|
|
int write_nalu_bsf( hnd_t handle, uint8_t *p_nalu, int i_size )
|
3181 |
|
|
{
|
3182 |
|
|
+#ifdef ENC_OUT_ADDR
|
3183 |
|
|
+ V(fprintf(stderr, "write_nalu_bsf: writing %d bytes from 0x%.8x\n", i_size, (unsigned long) enc_out_pos));
|
3184 |
|
|
+ // Just write to the spot in memory and increment the pointer
|
3185 |
|
|
+ int i; for (i=0;i<i_size;i++) *enc_out_pos++ = p_nalu[i];
|
3186 |
|
|
+ return i_size;
|
3187 |
|
|
+#else
|
3188 |
|
|
if( fwrite( p_nalu, i_size, 1, (FILE*)handle ) > 0 )
|
3189 |
|
|
return i_size;
|
3190 |
|
|
return -1;
|
3191 |
|
|
+#endif
|
3192 |
|
|
}
|
3193 |
|
|
|
3194 |
|
|
int set_eop_bsf( hnd_t handle, x264_picture_t *p_picture )
|
3195 |
|
|
@@ -558,6 +619,15 @@
|
3196 |
|
|
|
3197 |
|
|
int close_file_bsf( hnd_t handle )
|
3198 |
|
|
{
|
3199 |
|
|
+#ifdef ENC_OUT_ADDR
|
3200 |
|
|
+ // Let's calculate a checksum for the written data
|
3201 |
|
|
+ int i; char* d = (char*)ENC_OUT_ADDR; unsigned int cksum;
|
3202 |
|
|
+ unsigned int size = (unsigned int)enc_out_pos - (unsigned int)ENC_OUT_ADDR;
|
3203 |
|
|
+ for(i=0;i<size;i++)cksum+=d[i++];
|
3204 |
|
|
+ fprintf(stderr, "close_file_bsf: wrote %d bytes from 0x%.8x to 0x%.8x\n", size, (unsigned int) ENC_OUT_ADDR, (unsigned int) enc_out_pos);
|
3205 |
|
|
+ fprintf(stderr, "close_file_bsf: cksum 0x%.8x\n", cksum);
|
3206 |
|
|
+ return 0;
|
3207 |
|
|
+#endif
|
3208 |
|
|
if( !handle || handle == stdout )
|
3209 |
|
|
return 0;
|
3210 |
|
|
|
3211 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/muxers.h x264-or/muxers.h
|
3212 |
|
|
--- x264/muxers.h 2009-10-25 17:41:22.000000000 +0100
|
3213 |
|
|
+++ x264-or/muxers.h 2009-10-28 15:05:29.000000000 +0100
|
3214 |
|
|
@@ -27,6 +27,7 @@
|
3215 |
|
|
typedef void *hnd_t;
|
3216 |
|
|
|
3217 |
|
|
int open_file_yuv( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param );
|
3218 |
|
|
+void init_yuv_dataspace(char* yuv_dat_addr, hnd_t *p_handle, x264_param_t *p_param);
|
3219 |
|
|
int get_frame_total_yuv( hnd_t handle );
|
3220 |
|
|
int read_frame_yuv( x264_picture_t *p_pic, hnd_t handle, int i_frame );
|
3221 |
|
|
int close_file_yuv( hnd_t handle );
|
3222 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/or1ksim_x264.cfg x264-or/or1ksim_x264.cfg
|
3223 |
|
|
--- x264/or1ksim_x264.cfg 1970-01-01 01:00:00.000000000 +0100
|
3224 |
|
|
+++ x264-or/or1ksim_x264.cfg 2009-11-15 19:57:09.000000000 +0100
|
3225 |
|
|
@@ -0,0 +1,886 @@
|
3226 |
|
|
+/* sim.cfg -- Simulator configuration script file
|
3227 |
|
|
+ Copyright (C) 2001-2002, Marko Mlinar, markom@opencores.org
|
3228 |
|
|
+
|
3229 |
|
|
+This file is part of OpenRISC 1000 Architectural Simulator.
|
3230 |
|
|
+It contains the default configuration and help about configuring
|
3231 |
|
|
+the simulator.
|
3232 |
|
|
+
|
3233 |
|
|
+This program is free software; you can redistribute it and/or modify
|
3234 |
|
|
+it under the terms of the GNU General Public License as published by
|
3235 |
|
|
+the Free Software Foundation; either version 2 of the License, or
|
3236 |
|
|
+(at your option) any later version.
|
3237 |
|
|
+
|
3238 |
|
|
+This program is distributed in the hope that it will be useful,
|
3239 |
|
|
+but WITHOUT ANY WARRANTY; without even the implied warranty of
|
3240 |
|
|
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
3241 |
|
|
+GNU General Public License for more details.
|
3242 |
|
|
+
|
3243 |
|
|
+You should have received a copy of the GNU General Public License
|
3244 |
|
|
+along with this program; if not, write to the Free Software
|
3245 |
|
|
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
3246 |
|
|
+
|
3247 |
|
|
+
|
3248 |
|
|
+/* INTRODUCTION
|
3249 |
|
|
+
|
3250 |
|
|
+ The ork1sim has various parameters, that are set in configuration files
|
3251 |
|
|
+ like this one. The user can switch between configurations at startup by
|
3252 |
|
|
+ specifying the required configuration file with the -f <filename.cfg> option.
|
3253 |
|
|
+ If no configuration file is specified or1ksim searches for the default
|
3254 |
|
|
+ configuration file sim.cfg. First it searches for './sim.cfg'. If this
|
3255 |
|
|
+ file is not found, it searches for '~/or1k/sim.cfg'. If this file is
|
3256 |
|
|
+ not found too, it reverts to the built-in default configuration.
|
3257 |
|
|
+
|
3258 |
|
|
+ NOTE: Users should not rely on the built-in configuration, since the
|
3259 |
|
|
+ default configuration may differ between version.
|
3260 |
|
|
+ Rather create a configuration file that sets all critical values.
|
3261 |
|
|
+
|
3262 |
|
|
+ This file may contain (standard C) comments only - no // support.
|
3263 |
|
|
+
|
3264 |
|
|
+ Configure files may be be included, using:
|
3265 |
|
|
+ include "file_name_to_include"
|
3266 |
|
|
+
|
3267 |
|
|
+ Like normal configuration files, the included file is divided into
|
3268 |
|
|
+ sections. Each section is described in detail also.
|
3269 |
|
|
+
|
3270 |
|
|
+ Some section have subsections. One example of such a subsection is:
|
3271 |
|
|
+
|
3272 |
|
|
+ device <index>
|
3273 |
|
|
+ instance specific parameters...
|
3274 |
|
|
+ enddevice
|
3275 |
|
|
+
|
3276 |
|
|
+ which creates a device instance.
|
3277 |
|
|
+*/
|
3278 |
|
|
+
|
3279 |
|
|
+
|
3280 |
|
|
+/* MEMORY SECTION
|
3281 |
|
|
+
|
3282 |
|
|
+ This section specifies how the memory is generated and the blocks
|
3283 |
|
|
+ it consists of.
|
3284 |
|
|
+
|
3285 |
|
|
+ type = random/unknown/pattern
|
3286 |
|
|
+ Specifies the initial memory values.
|
3287 |
|
|
+ 'random' generates random memory using seed 'random_seed'.
|
3288 |
|
|
+ 'pattern' fills memory with 'pattern'.
|
3289 |
|
|
+ 'unknown' does not specify how memory should be generated,
|
3290 |
|
|
+ leaving the memory in a undefined state. This is the fastest
|
3291 |
|
|
+ option.
|
3292 |
|
|
+
|
3293 |
|
|
+ random_seed = <value>
|
3294 |
|
|
+ random seed for randomizer, used if type = 'random'.
|
3295 |
|
|
+
|
3296 |
|
|
+ pattern = <value>
|
3297 |
|
|
+ pattern to fill memory, used if type = 'pattern'.
|
3298 |
|
|
+
|
3299 |
|
|
+ nmemories = <value>
|
3300 |
|
|
+ number of memory instances connected
|
3301 |
|
|
+
|
3302 |
|
|
+ baseaddr = <hex_value>
|
3303 |
|
|
+ memory start address
|
3304 |
|
|
+
|
3305 |
|
|
+ size = <hex_value>
|
3306 |
|
|
+ memory size
|
3307 |
|
|
+
|
3308 |
|
|
+ name = "<string>"
|
3309 |
|
|
+ memory block name
|
3310 |
|
|
+
|
3311 |
|
|
+ ce = <value>
|
3312 |
|
|
+ chip enable index of the memory instance
|
3313 |
|
|
+
|
3314 |
|
|
+ mc = <value>
|
3315 |
|
|
+ memory controller this memory is connected to
|
3316 |
|
|
+
|
3317 |
|
|
+ delayr = <value>
|
3318 |
|
|
+ cycles, required for read access, -1 if instance does not support reading
|
3319 |
|
|
+
|
3320 |
|
|
+ delayw = <value>
|
3321 |
|
|
+ cycles, required for write access, -1 if instance does not support writing
|
3322 |
|
|
+
|
3323 |
|
|
+ log = "<filename>"
|
3324 |
|
|
+ filename, where to log memory accesses to, no log, if log command is not specified
|
3325 |
|
|
+*/
|
3326 |
|
|
+
|
3327 |
|
|
+
|
3328 |
|
|
+section memory
|
3329 |
|
|
+ /*random_seed = 12345
|
3330 |
|
|
+ type = random*/
|
3331 |
|
|
+ pattern = 0x00
|
3332 |
|
|
+ type = unknown /* Fastest */
|
3333 |
|
|
+
|
3334 |
|
|
+ name = "FLASH"
|
3335 |
|
|
+ ce = 0
|
3336 |
|
|
+ mc = 0
|
3337 |
|
|
+ baseaddr = 0xf0000000
|
3338 |
|
|
+ size = 0x01000000
|
3339 |
|
|
+ delayr = 10
|
3340 |
|
|
+ delayw = -1
|
3341 |
|
|
+end
|
3342 |
|
|
+
|
3343 |
|
|
+section memory
|
3344 |
|
|
+ /*random_seed = 12345
|
3345 |
|
|
+ type = random*/
|
3346 |
|
|
+ pattern = 0x00
|
3347 |
|
|
+ type = unknown /* Fastest */
|
3348 |
|
|
+
|
3349 |
|
|
+ name = "RAM"
|
3350 |
|
|
+ ce = 1
|
3351 |
|
|
+ mc = 0
|
3352 |
|
|
+ baseaddr = 0x00000000
|
3353 |
|
|
+ size = 0x02000000
|
3354 |
|
|
+ delayr = 20
|
3355 |
|
|
+ delayw = 25
|
3356 |
|
|
+end
|
3357 |
|
|
+
|
3358 |
|
|
+section memory
|
3359 |
|
|
+ /*random_seed = 12345
|
3360 |
|
|
+ type = random*/
|
3361 |
|
|
+ pattern = 0x00
|
3362 |
|
|
+ type = unknown /* Fastest */
|
3363 |
|
|
+
|
3364 |
|
|
+ name = "SRAM"
|
3365 |
|
|
+ mc = 0
|
3366 |
|
|
+ ce = 2
|
3367 |
|
|
+ baseaddr = 0xa4000000
|
3368 |
|
|
+ size = 0x00100000
|
3369 |
|
|
+ delayr = 1
|
3370 |
|
|
+ delayw = 2
|
3371 |
|
|
+end
|
3372 |
|
|
+
|
3373 |
|
|
+
|
3374 |
|
|
+/* IMMU SECTION
|
3375 |
|
|
+
|
3376 |
|
|
+ This section configures the Instruction Memory Manangement Unit
|
3377 |
|
|
+
|
3378 |
|
|
+ enabled = 0/1
|
3379 |
|
|
+ '0': disabled
|
3380 |
|
|
+ '1': enabled
|
3381 |
|
|
+ (NOTE: UPR bit is set)
|
3382 |
|
|
+
|
3383 |
|
|
+ nsets = <value>
|
3384 |
|
|
+ number of ITLB sets; must be power of two
|
3385 |
|
|
+
|
3386 |
|
|
+ nways = <value>
|
3387 |
|
|
+ number of ITLB ways
|
3388 |
|
|
+
|
3389 |
|
|
+ pagesize = <value>
|
3390 |
|
|
+ instruction page size; must be power of two
|
3391 |
|
|
+
|
3392 |
|
|
+ entrysize = <value>
|
3393 |
|
|
+ instruction entry size in bytes
|
3394 |
|
|
+
|
3395 |
|
|
+ ustates = <value>
|
3396 |
|
|
+ number of ITLB usage states (2, 3, 4 etc., max is 4)
|
3397 |
|
|
+
|
3398 |
|
|
+ hitdelay = <value>
|
3399 |
|
|
+ number of cycles immu hit costs
|
3400 |
|
|
+
|
3401 |
|
|
+ missdelay = <value>
|
3402 |
|
|
+ number of cycles immu miss costs
|
3403 |
|
|
+*/
|
3404 |
|
|
+
|
3405 |
|
|
+section immu
|
3406 |
|
|
+ enabled = 1
|
3407 |
|
|
+ nsets = 64
|
3408 |
|
|
+ nways = 1
|
3409 |
|
|
+ pagesize = 8192
|
3410 |
|
|
+ hitdelay = 0
|
3411 |
|
|
+ missdelay = 0
|
3412 |
|
|
+end
|
3413 |
|
|
+
|
3414 |
|
|
+
|
3415 |
|
|
+/* DMMU SECTION
|
3416 |
|
|
+
|
3417 |
|
|
+ This section configures the Data Memory Manangement Unit
|
3418 |
|
|
+
|
3419 |
|
|
+ enabled = 0/1
|
3420 |
|
|
+ '0': disabled
|
3421 |
|
|
+ '1': enabled
|
3422 |
|
|
+ (NOTE: UPR bit is set)
|
3423 |
|
|
+
|
3424 |
|
|
+ nsets = <value>
|
3425 |
|
|
+ number of DTLB sets; must be power of two
|
3426 |
|
|
+
|
3427 |
|
|
+ nways = <value>
|
3428 |
|
|
+ number of DTLB ways
|
3429 |
|
|
+
|
3430 |
|
|
+ pagesize = <value>
|
3431 |
|
|
+ data page size; must be power of two
|
3432 |
|
|
+
|
3433 |
|
|
+ entrysize = <value>
|
3434 |
|
|
+ data entry size in bytes
|
3435 |
|
|
+
|
3436 |
|
|
+ ustates = <value>
|
3437 |
|
|
+ number of DTLB usage states (2, 3, 4 etc., max is 4)
|
3438 |
|
|
+
|
3439 |
|
|
+ hitdelay = <value>
|
3440 |
|
|
+ number of cycles dmmu hit costs
|
3441 |
|
|
+
|
3442 |
|
|
+ missdelay = <value>
|
3443 |
|
|
+ number of cycles dmmu miss costs
|
3444 |
|
|
+*/
|
3445 |
|
|
+
|
3446 |
|
|
+section dmmu
|
3447 |
|
|
+ enabled = 1
|
3448 |
|
|
+ nsets = 64
|
3449 |
|
|
+ nways = 1
|
3450 |
|
|
+ pagesize = 8192
|
3451 |
|
|
+ hitdelay = 0
|
3452 |
|
|
+ missdelay = 0
|
3453 |
|
|
+end
|
3454 |
|
|
+
|
3455 |
|
|
+
|
3456 |
|
|
+/* IC SECTION
|
3457 |
|
|
+
|
3458 |
|
|
+ This section configures the Instruction Cache
|
3459 |
|
|
+
|
3460 |
|
|
+ enabled = 0/1
|
3461 |
|
|
+ '0': disabled
|
3462 |
|
|
+ '1': enabled
|
3463 |
|
|
+ (NOTE: UPR bit is set)
|
3464 |
|
|
+
|
3465 |
|
|
+ nsets = <value>
|
3466 |
|
|
+ number of IC sets; must be power of two
|
3467 |
|
|
+
|
3468 |
|
|
+ nways = <value>
|
3469 |
|
|
+ number of IC ways
|
3470 |
|
|
+
|
3471 |
|
|
+ blocksize = <value>
|
3472 |
|
|
+ IC block size in bytes; must be power of two
|
3473 |
|
|
+
|
3474 |
|
|
+ ustates = <value>
|
3475 |
|
|
+ number of IC usage states (2, 3, 4 etc., max is 4)
|
3476 |
|
|
+
|
3477 |
|
|
+ hitdelay = <value>
|
3478 |
|
|
+ number of cycles ic hit costs
|
3479 |
|
|
+
|
3480 |
|
|
+ missdelay = <value>
|
3481 |
|
|
+ number of cycles ic miss costs
|
3482 |
|
|
+*/
|
3483 |
|
|
+
|
3484 |
|
|
+section ic
|
3485 |
|
|
+ enabled = 0
|
3486 |
|
|
+ nsets = 512
|
3487 |
|
|
+ nways = 1
|
3488 |
|
|
+ blocksize = 16
|
3489 |
|
|
+ hitdelay = 20
|
3490 |
|
|
+ missdelay = 20
|
3491 |
|
|
+end
|
3492 |
|
|
+
|
3493 |
|
|
+
|
3494 |
|
|
+/* DC SECTION
|
3495 |
|
|
+
|
3496 |
|
|
+ This section configures the Data Cache
|
3497 |
|
|
+
|
3498 |
|
|
+ enabled = 0/1
|
3499 |
|
|
+ '0': disabled
|
3500 |
|
|
+ '1': enabled
|
3501 |
|
|
+ (NOTE: UPR bit is set)
|
3502 |
|
|
+
|
3503 |
|
|
+ nsets = <value>
|
3504 |
|
|
+ number of DC sets; must be power of two
|
3505 |
|
|
+
|
3506 |
|
|
+ nways = <value>
|
3507 |
|
|
+ number of DC ways
|
3508 |
|
|
+
|
3509 |
|
|
+ blocksize = <value>
|
3510 |
|
|
+ DC block size in bytes; must be power of two
|
3511 |
|
|
+
|
3512 |
|
|
+ ustates = <value>
|
3513 |
|
|
+ number of DC usage states (2, 3, 4 etc., max is 4)
|
3514 |
|
|
+
|
3515 |
|
|
+ load_hitdelay = <value>
|
3516 |
|
|
+ number of cycles dc load hit costs
|
3517 |
|
|
+
|
3518 |
|
|
+ load_missdelay = <value>
|
3519 |
|
|
+ number of cycles dc load miss costs
|
3520 |
|
|
+
|
3521 |
|
|
+ store_hitdelay = <value>
|
3522 |
|
|
+ number of cycles dc load hit costs
|
3523 |
|
|
+
|
3524 |
|
|
+ store_missdelay = <value>
|
3525 |
|
|
+ number of cycles dc load miss costs
|
3526 |
|
|
+*/
|
3527 |
|
|
+
|
3528 |
|
|
+section dc
|
3529 |
|
|
+ enabled = 0
|
3530 |
|
|
+ nsets = 512
|
3531 |
|
|
+ nways = 1
|
3532 |
|
|
+ blocksize = 16
|
3533 |
|
|
+ load_hitdelay = 20
|
3534 |
|
|
+ load_missdelay = 20
|
3535 |
|
|
+ store_hitdelay = 20
|
3536 |
|
|
+ store_missdelay = 20
|
3537 |
|
|
+end
|
3538 |
|
|
+
|
3539 |
|
|
+
|
3540 |
|
|
+/* SIM SECTION
|
3541 |
|
|
+
|
3542 |
|
|
+ This section specifies how or1ksim should behave.
|
3543 |
|
|
+
|
3544 |
|
|
+ verbose = 0/1
|
3545 |
|
|
+ '0': don't print extra messages
|
3546 |
|
|
+ '1': print extra messages
|
3547 |
|
|
+
|
3548 |
|
|
+ debug = 0-9
|
3549 |
|
|
+ 0 : no debug messages
|
3550 |
|
|
+ 1-9: debug message level.
|
3551 |
|
|
+ higher numbers produce more messages
|
3552 |
|
|
+
|
3553 |
|
|
+ profile = 0/1
|
3554 |
|
|
+ '0': don't generate profiling file 'sim.profile'
|
3555 |
|
|
+ '1': don't generate profiling file 'sim.profile'
|
3556 |
|
|
+
|
3557 |
|
|
+ prof_fn = "<filename>"
|
3558 |
|
|
+ optional filename for the profiling file.
|
3559 |
|
|
+ valid only if 'profile' is set
|
3560 |
|
|
+
|
3561 |
|
|
+ mprofile = 0/1
|
3562 |
|
|
+ '0': don't generate memory profiling file 'sim.mprofile'
|
3563 |
|
|
+ '1': generate memory profiling file 'sim.mprofile'
|
3564 |
|
|
+
|
3565 |
|
|
+ mprof_fn = "<filename>"
|
3566 |
|
|
+ optional filename for the memory profiling file.
|
3567 |
|
|
+ valid only if 'mprofile' is set
|
3568 |
|
|
+
|
3569 |
|
|
+ history = 0/1
|
3570 |
|
|
+ '0': don't track execution flow
|
3571 |
|
|
+ '1': track execution flow
|
3572 |
|
|
+ Execution flow can be tracked for the simulator's
|
3573 |
|
|
+ 'hist' command. Useful for back-trace debugging.
|
3574 |
|
|
+
|
3575 |
|
|
+ iprompt = 0/1
|
3576 |
|
|
+ '0': start in <not interactive prompt> (so what do we start in ???)
|
3577 |
|
|
+ '1': start in interactive prompt.
|
3578 |
|
|
+
|
3579 |
|
|
+ exe_log = 0/1
|
3580 |
|
|
+ '0': don't generate execution log.
|
3581 |
|
|
+ '1': generate execution log.
|
3582 |
|
|
+
|
3583 |
|
|
+ exe_log = default/hardware/simple/software
|
3584 |
|
|
+ type of execution log, default is used when not specified
|
3585 |
|
|
+
|
3586 |
|
|
+ exe_log_start = <value>
|
3587 |
|
|
+ index of first instruction to start logging, default = 0
|
3588 |
|
|
+
|
3589 |
|
|
+ exe_log_end = <value>
|
3590 |
|
|
+ index of last instruction to end logging; not limited, if omitted
|
3591 |
|
|
+
|
3592 |
|
|
+ exe_log_marker = <value>
|
3593 |
|
|
+ <value> specifies number of instructions before horizontal marker is
|
3594 |
|
|
+ printed; if zero, markers are disabled (default)
|
3595 |
|
|
+
|
3596 |
|
|
+ exe_log_fn = "<filename>"
|
3597 |
|
|
+ filename for the exection log file.
|
3598 |
|
|
+ valid only if 'exe_log' is set
|
3599 |
|
|
+
|
3600 |
|
|
+ clkcycle = <value>[ps|ns|us|ms]
|
3601 |
|
|
+ specifies time measurement for one cycle
|
3602 |
|
|
+*/
|
3603 |
|
|
+
|
3604 |
|
|
+section sim
|
3605 |
|
|
+ verbose = 1
|
3606 |
|
|
+ debug = 0
|
3607 |
|
|
+ profile = 0
|
3608 |
|
|
+ history = 0
|
3609 |
|
|
+
|
3610 |
|
|
+ clkcycle = 10ns
|
3611 |
|
|
+end
|
3612 |
|
|
+
|
3613 |
|
|
+
|
3614 |
|
|
+/* SECTION VAPI
|
3615 |
|
|
+
|
3616 |
|
|
+ This section configures the Verification API, used for Advanced
|
3617 |
|
|
+ Core Verification.
|
3618 |
|
|
+
|
3619 |
|
|
+ enabled = 0/1
|
3620 |
|
|
+ '0': disbable VAPI server
|
3621 |
|
|
+ '1': enable/start VAPI server
|
3622 |
|
|
+
|
3623 |
|
|
+ server_port = <value>
|
3624 |
|
|
+ TCP/IP port to start VAPI server on
|
3625 |
|
|
+
|
3626 |
|
|
+ log_enabled = 0/1
|
3627 |
|
|
+ '0': disable VAPI requests logging
|
3628 |
|
|
+ '1': enable VAPI requests logging
|
3629 |
|
|
+
|
3630 |
|
|
+ hide_device_id = 0/1
|
3631 |
|
|
+ '0': don't log device id (for compatability with old version)
|
3632 |
|
|
+ '1': log device id
|
3633 |
|
|
+
|
3634 |
|
|
+
|
3635 |
|
|
+ vapi_fn = <filename>
|
3636 |
|
|
+ filename for the log file.
|
3637 |
|
|
+ valid only if log_enabled is set
|
3638 |
|
|
+*/
|
3639 |
|
|
+
|
3640 |
|
|
+section VAPI
|
3641 |
|
|
+ enabled = 0
|
3642 |
|
|
+ server_port = 9998
|
3643 |
|
|
+ log_enabled = 0
|
3644 |
|
|
+ vapi_log_fn = "vapi.log"
|
3645 |
|
|
+end
|
3646 |
|
|
+
|
3647 |
|
|
+
|
3648 |
|
|
+/* CPU SECTION
|
3649 |
|
|
+
|
3650 |
|
|
+ This section specifies various CPU parameters.
|
3651 |
|
|
+
|
3652 |
|
|
+ ver = <value>
|
3653 |
|
|
+ rev = <value>
|
3654 |
|
|
+ specifies version and revision of the CPU used
|
3655 |
|
|
+
|
3656 |
|
|
+ upr = <value>
|
3657 |
|
|
+ changes the upr register
|
3658 |
|
|
+
|
3659 |
|
|
+ sr = <value>
|
3660 |
|
|
+ sets the initial Supervision Register value
|
3661 |
|
|
+
|
3662 |
|
|
+ superscalar = 0/1
|
3663 |
|
|
+ '0': CPU is scalar
|
3664 |
|
|
+ '1': CPU is superscalar
|
3665 |
|
|
+ (modify cpu/or32/execute.c to tune superscalar model)
|
3666 |
|
|
+
|
3667 |
|
|
+ hazards = 0/1
|
3668 |
|
|
+ '0': don't track data hazards in superscalar CPU
|
3669 |
|
|
+ '1': track data hazards in superscalar CPU
|
3670 |
|
|
+ If tracked, data hazards can be displayed using the
|
3671 |
|
|
+ simulator's 'r' command.
|
3672 |
|
|
+
|
3673 |
|
|
+ dependstats = 0/1
|
3674 |
|
|
+ '0': don't calculate inter-instruction dependencies.
|
3675 |
|
|
+ '1': calculate inter-instruction dependencies.
|
3676 |
|
|
+ If calculated, inter-instruction dependencies can be
|
3677 |
|
|
+ displayed using the simulator's 'stat' command.
|
3678 |
|
|
+
|
3679 |
|
|
+ sbuf_len = <value>
|
3680 |
|
|
+ length of store buffer (<= 256), 0 = disabled
|
3681 |
|
|
+*/
|
3682 |
|
|
+
|
3683 |
|
|
+section cpu
|
3684 |
|
|
+ ver = 0x12
|
3685 |
|
|
+ cfg = 0x00
|
3686 |
|
|
+ rev = 0x01
|
3687 |
|
|
+ /* upr = */
|
3688 |
|
|
+ superscalar = 0
|
3689 |
|
|
+ hazards = 0
|
3690 |
|
|
+ dependstats = 0
|
3691 |
|
|
+ sbuf_len = 0
|
3692 |
|
|
+ hardfloat = 1
|
3693 |
|
|
+end
|
3694 |
|
|
+
|
3695 |
|
|
+
|
3696 |
|
|
+/* PM SECTION
|
3697 |
|
|
+
|
3698 |
|
|
+ This section specifies Power Management parameters
|
3699 |
|
|
+
|
3700 |
|
|
+ enabled = 0/1
|
3701 |
|
|
+ '0': disable power management
|
3702 |
|
|
+ '1': enable power management
|
3703 |
|
|
+*/
|
3704 |
|
|
+
|
3705 |
|
|
+section pm
|
3706 |
|
|
+ enabled = 0
|
3707 |
|
|
+end
|
3708 |
|
|
+
|
3709 |
|
|
+
|
3710 |
|
|
+/* BPB SECTION
|
3711 |
|
|
+
|
3712 |
|
|
+ This section specifies how branch prediction should behave.
|
3713 |
|
|
+
|
3714 |
|
|
+ enabled = 0/1
|
3715 |
|
|
+ '0': disable branch prediction
|
3716 |
|
|
+ '1': enable branch prediction
|
3717 |
|
|
+
|
3718 |
|
|
+ btic = 0/1
|
3719 |
|
|
+ '0': disable branch target instruction cache model
|
3720 |
|
|
+ '1': enable branch target instruction cache model
|
3721 |
|
|
+
|
3722 |
|
|
+ sbp_bf_fwd = 0/1
|
3723 |
|
|
+ Static branch prediction for 'l.bf'
|
3724 |
|
|
+ '0': don't use forward prediction
|
3725 |
|
|
+ '1': use forward prediction
|
3726 |
|
|
+
|
3727 |
|
|
+ sbp_bnf_fwd = 0/1
|
3728 |
|
|
+ Static branch prediction for 'l.bnf'
|
3729 |
|
|
+ '0': don't use forward prediction
|
3730 |
|
|
+ '1': use forward prediction
|
3731 |
|
|
+
|
3732 |
|
|
+ hitdelay = <value>
|
3733 |
|
|
+ number of cycles bpb hit costs
|
3734 |
|
|
+
|
3735 |
|
|
+ missdelay = <value>
|
3736 |
|
|
+ number of cycles bpb miss costs
|
3737 |
|
|
+*/
|
3738 |
|
|
+
|
3739 |
|
|
+section bpb
|
3740 |
|
|
+ enabled = 0
|
3741 |
|
|
+ btic = 0
|
3742 |
|
|
+ sbp_bf_fwd = 0
|
3743 |
|
|
+ sbp_bnf_fwd = 0
|
3744 |
|
|
+ hitdelay = 0
|
3745 |
|
|
+ missdelay = 0
|
3746 |
|
|
+end
|
3747 |
|
|
+
|
3748 |
|
|
+
|
3749 |
|
|
+/* DEBUG SECTION
|
3750 |
|
|
+
|
3751 |
|
|
+ This sections specifies how the debug unit should behave.
|
3752 |
|
|
+
|
3753 |
|
|
+ enabled = 0/1
|
3754 |
|
|
+ '0': disable debug unit
|
3755 |
|
|
+ '1': enable debug unit
|
3756 |
|
|
+
|
3757 |
|
|
+ gdb_enabled = 0/1
|
3758 |
|
|
+ '0': don't start gdb server
|
3759 |
|
|
+ '1': start gdb server at port 'server_port'
|
3760 |
|
|
+
|
3761 |
|
|
+ server_port = <value>
|
3762 |
|
|
+ TCP/IP port to start gdb server on
|
3763 |
|
|
+ valid only if gdb_enabled is set
|
3764 |
|
|
+
|
3765 |
|
|
+ vapi_id = <hex_value>
|
3766 |
|
|
+ Used to create "fake" vapi log file containing the JTAG proxy messages.
|
3767 |
|
|
+*/
|
3768 |
|
|
+section debug
|
3769 |
|
|
+ enabled = 0
|
3770 |
|
|
+ rsp_enabled = 0
|
3771 |
|
|
+ rsp_port = 5554
|
3772 |
|
|
+ /*server_port = 9999*/
|
3773 |
|
|
+end
|
3774 |
|
|
+
|
3775 |
|
|
+
|
3776 |
|
|
+/* MC SECTION
|
3777 |
|
|
+
|
3778 |
|
|
+ This section configures the memory controller
|
3779 |
|
|
+
|
3780 |
|
|
+ enabled = 0/1
|
3781 |
|
|
+ '0': disable memory controller
|
3782 |
|
|
+ '1': enable memory controller
|
3783 |
|
|
+
|
3784 |
|
|
+ baseaddr = <hex_value>
|
3785 |
|
|
+ address of first MC register
|
3786 |
|
|
+
|
3787 |
|
|
+ POC = <hex_value>
|
3788 |
|
|
+ Power On Configuration register
|
3789 |
|
|
+
|
3790 |
|
|
+ index = <value>
|
3791 |
|
|
+ Index of this memory controller amongst all the memory controllers
|
3792 |
|
|
+*/
|
3793 |
|
|
+
|
3794 |
|
|
+section mc
|
3795 |
|
|
+ enabled = 0
|
3796 |
|
|
+ baseaddr = 0x93000000
|
3797 |
|
|
+ POC = 0x00000008 /* Power on configuration register */
|
3798 |
|
|
+ index = 0
|
3799 |
|
|
+end
|
3800 |
|
|
+
|
3801 |
|
|
+
|
3802 |
|
|
+/* UART SECTION
|
3803 |
|
|
+
|
3804 |
|
|
+ This section configures the UARTs
|
3805 |
|
|
+
|
3806 |
|
|
+ enabled = <0|1>
|
3807 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
3808 |
|
|
+
|
3809 |
|
|
+ baseaddr = <hex_value>
|
3810 |
|
|
+ address of first UART register for this device
|
3811 |
|
|
+
|
3812 |
|
|
+
|
3813 |
|
|
+ channel = <channeltype>:<args>
|
3814 |
|
|
+
|
3815 |
|
|
+ The channel parameter indicates the source of received UART characters
|
3816 |
|
|
+ and the sink for transmitted UART characters.
|
3817 |
|
|
+
|
3818 |
|
|
+ The <channeltype> can be either "file", "xterm", "tcp", "fd", or "tty"
|
3819 |
|
|
+ (without quotes).
|
3820 |
|
|
+
|
3821 |
|
|
+ A) To send/receive characters from a pair of files, use a file
|
3822 |
|
|
+ channel:
|
3823 |
|
|
+
|
3824 |
|
|
+ channel=file:<rxfile>,<txfile>
|
3825 |
|
|
+
|
3826 |
|
|
+ B) To create an interactive terminal window, use an xterm channel:
|
3827 |
|
|
+
|
3828 |
|
|
+ channel=xterm:[<xterm_arg>]*
|
3829 |
|
|
+
|
3830 |
|
|
+ C) To create a bidirectional tcp socket which one could, for example,
|
3831 |
|
|
+ access via telnet, use a tcp channel:
|
3832 |
|
|
+
|
3833 |
|
|
+ channel=tcp:<port number>
|
3834 |
|
|
+
|
3835 |
|
|
+ D) To cause the UART to read/write from existing numeric file
|
3836 |
|
|
+ descriptors, use an fd channel:
|
3837 |
|
|
+
|
3838 |
|
|
+ channel=fd:<rx file descriptor num>,<tx file descriptor num>
|
3839 |
|
|
+
|
3840 |
|
|
+ E) To connect the UART to a physical serial port, create a tty
|
3841 |
|
|
+ channel:
|
3842 |
|
|
+
|
3843 |
|
|
+ channel=tty:device=/dev/ttyS0,baud=9600
|
3844 |
|
|
+
|
3845 |
|
|
+ irq = <value>
|
3846 |
|
|
+ irq number for this device
|
3847 |
|
|
+
|
3848 |
|
|
+ 16550 = 0/1
|
3849 |
|
|
+ '0': this device is a UART16450
|
3850 |
|
|
+ '1': this device is a UART16550
|
3851 |
|
|
+
|
3852 |
|
|
+ jitter = <value>
|
3853 |
|
|
+ in msecs... time to block, -1 to disable it
|
3854 |
|
|
+
|
3855 |
|
|
+ vapi_id = <hex_value>
|
3856 |
|
|
+ VAPI id of this instance
|
3857 |
|
|
+*/
|
3858 |
|
|
+
|
3859 |
|
|
+section uart
|
3860 |
|
|
+ enabled = 1
|
3861 |
|
|
+ baseaddr = 0x90000000
|
3862 |
|
|
+ irq = 2
|
3863 |
|
|
+ channel = "file:uart0.rx,uart0.tx"
|
3864 |
|
|
+ /* channel = "tcp:10084" */
|
3865 |
|
|
+ /* channel = "xterm:" */
|
3866 |
|
|
+ jitter = -1 /* async behaviour */
|
3867 |
|
|
+ 16550 = 1
|
3868 |
|
|
+end
|
3869 |
|
|
+
|
3870 |
|
|
+
|
3871 |
|
|
+/* DMA SECTION
|
3872 |
|
|
+
|
3873 |
|
|
+ This section configures the DMAs
|
3874 |
|
|
+
|
3875 |
|
|
+ enabled = <0|1>
|
3876 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
3877 |
|
|
+
|
3878 |
|
|
+ baseaddr = <hex_value>
|
3879 |
|
|
+ address of first DMA register for this device
|
3880 |
|
|
+
|
3881 |
|
|
+ irq = <value>
|
3882 |
|
|
+ irq number for this device
|
3883 |
|
|
+
|
3884 |
|
|
+ vapi_id = <hex_value>
|
3885 |
|
|
+ VAPI id of this instance
|
3886 |
|
|
+*/
|
3887 |
|
|
+
|
3888 |
|
|
+section dma
|
3889 |
|
|
+ enabled = 1
|
3890 |
|
|
+ baseaddr = 0x9a000000
|
3891 |
|
|
+ irq = 11
|
3892 |
|
|
+end
|
3893 |
|
|
+
|
3894 |
|
|
+
|
3895 |
|
|
+/* ETHERNET SECTION
|
3896 |
|
|
+
|
3897 |
|
|
+ This section configures the ETHERNETs
|
3898 |
|
|
+
|
3899 |
|
|
+ enabled = <0|1>
|
3900 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
3901 |
|
|
+
|
3902 |
|
|
+ baseaddr = <hex_value>
|
3903 |
|
|
+ address of first ethernet register for this device
|
3904 |
|
|
+
|
3905 |
|
|
+ dma = <value>
|
3906 |
|
|
+ which controller is this ethernet "connected" to
|
3907 |
|
|
+
|
3908 |
|
|
+ irq = <value>
|
3909 |
|
|
+ ethernet mac IRQ level
|
3910 |
|
|
+
|
3911 |
|
|
+ rtx_type = <value>
|
3912 |
|
|
+ use 0 - file interface, 1 - socket interface
|
3913 |
|
|
+
|
3914 |
|
|
+ rx_channel = <value>
|
3915 |
|
|
+ DMA channel used for RX
|
3916 |
|
|
+
|
3917 |
|
|
+ tx_channel = <value>
|
3918 |
|
|
+ DMA channel used for TX
|
3919 |
|
|
+
|
3920 |
|
|
+ rxfile = "<filename>"
|
3921 |
|
|
+ filename, where to read data from
|
3922 |
|
|
+
|
3923 |
|
|
+ txfile = "<filename>"
|
3924 |
|
|
+ filename, where to write data to
|
3925 |
|
|
+
|
3926 |
|
|
+ sockif = "<ifacename>"
|
3927 |
|
|
+ interface name of ethernet socket
|
3928 |
|
|
+
|
3929 |
|
|
+ vapi_id = <hex_value>
|
3930 |
|
|
+ VAPI id of this instance
|
3931 |
|
|
+*/
|
3932 |
|
|
+
|
3933 |
|
|
+section ethernet
|
3934 |
|
|
+ enabled = 0
|
3935 |
|
|
+ baseaddr = 0x92000000
|
3936 |
|
|
+ /* dma = 0 */
|
3937 |
|
|
+ irq = 4
|
3938 |
|
|
+ rtx_type = 0
|
3939 |
|
|
+ /* tx_channel = 0 */
|
3940 |
|
|
+ /* rx_channel = 1 */
|
3941 |
|
|
+ /*rxfile = "eth0.rx"*/
|
3942 |
|
|
+ txfile = "eth0.tx"
|
3943 |
|
|
+ sockif = "eth0"
|
3944 |
|
|
+end
|
3945 |
|
|
+
|
3946 |
|
|
+
|
3947 |
|
|
+/* GPIO SECTION
|
3948 |
|
|
+
|
3949 |
|
|
+ This section configures the GPIOs
|
3950 |
|
|
+
|
3951 |
|
|
+ enabled = <0|1>
|
3952 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
3953 |
|
|
+
|
3954 |
|
|
+ baseaddr = <hex_value>
|
3955 |
|
|
+ address of first GPIO register for this device
|
3956 |
|
|
+
|
3957 |
|
|
+ irq = <value>
|
3958 |
|
|
+ irq number for this device
|
3959 |
|
|
+
|
3960 |
|
|
+ base_vapi_id = <hex_value>
|
3961 |
|
|
+ first VAPI id of this instance
|
3962 |
|
|
+ GPIO uses 8 consecutive VAPI IDs
|
3963 |
|
|
+*/
|
3964 |
|
|
+
|
3965 |
|
|
+section gpio
|
3966 |
|
|
+ enabled = 0
|
3967 |
|
|
+ baseaddr = 0x91000000
|
3968 |
|
|
+ irq = 3
|
3969 |
|
|
+ base_vapi_id = 0x0200
|
3970 |
|
|
+end
|
3971 |
|
|
+
|
3972 |
|
|
+/* VGA SECTION
|
3973 |
|
|
+
|
3974 |
|
|
+ This section configures the VGA/LCD controller
|
3975 |
|
|
+
|
3976 |
|
|
+ enabled = <0|1>
|
3977 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
3978 |
|
|
+
|
3979 |
|
|
+ baseaddr = <hex_value>
|
3980 |
|
|
+ address of first VGA register
|
3981 |
|
|
+
|
3982 |
|
|
+ irq = <value>
|
3983 |
|
|
+ irq number for this device
|
3984 |
|
|
+
|
3985 |
|
|
+ refresh_rate = <value>
|
3986 |
|
|
+ number of cycles between screen dumps
|
3987 |
|
|
+
|
3988 |
|
|
+ filename = "<filename>"
|
3989 |
|
|
+ template name for generated names (e.g. "primary" produces "primary0023.bmp")
|
3990 |
|
|
+*/
|
3991 |
|
|
+
|
3992 |
|
|
+section vga
|
3993 |
|
|
+ enabled = 1
|
3994 |
|
|
+ baseaddr = 0x97100000
|
3995 |
|
|
+ irq = 8
|
3996 |
|
|
+ refresh_rate = 100000
|
3997 |
|
|
+ filename = "primary"
|
3998 |
|
|
+end
|
3999 |
|
|
+
|
4000 |
|
|
+
|
4001 |
|
|
+/* TICK TIMER SECTION
|
4002 |
|
|
+
|
4003 |
|
|
+ This section configures tick timer
|
4004 |
|
|
+
|
4005 |
|
|
+ enabled = 0/1
|
4006 |
|
|
+ whether tick timer is enabled
|
4007 |
|
|
+*/
|
4008 |
|
|
+
|
4009 |
|
|
+section pic
|
4010 |
|
|
+ enabled = 1
|
4011 |
|
|
+ edge_trigger = 1
|
4012 |
|
|
+end
|
4013 |
|
|
+
|
4014 |
|
|
+/* FB SECTION
|
4015 |
|
|
+
|
4016 |
|
|
+ This section configures the frame buffer
|
4017 |
|
|
+
|
4018 |
|
|
+ enabled = <0|1>
|
4019 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4020 |
|
|
+
|
4021 |
|
|
+ baseaddr = <hex_value>
|
4022 |
|
|
+ base address of frame buffer
|
4023 |
|
|
+
|
4024 |
|
|
+ paladdr = <hex_value>
|
4025 |
|
|
+ base address of first palette entry
|
4026 |
|
|
+
|
4027 |
|
|
+ refresh_rate = <value>
|
4028 |
|
|
+ number of cycles between screen dumps
|
4029 |
|
|
+
|
4030 |
|
|
+ filename = "<filename>"
|
4031 |
|
|
+ template name for generated names (e.g. "primary" produces "primary0023.bmp")
|
4032 |
|
|
+*/
|
4033 |
|
|
+
|
4034 |
|
|
+section fb
|
4035 |
|
|
+ enabled = 1
|
4036 |
|
|
+ baseaddr = 0x97000000
|
4037 |
|
|
+ refresh_rate = 1000000
|
4038 |
|
|
+ filename = "primary"
|
4039 |
|
|
+end
|
4040 |
|
|
+
|
4041 |
|
|
+
|
4042 |
|
|
+/* KBD SECTION
|
4043 |
|
|
+
|
4044 |
|
|
+ This section configures the PS/2 compatible keyboard
|
4045 |
|
|
+
|
4046 |
|
|
+ baseaddr = <hex_value>
|
4047 |
|
|
+ base address of the keyboard device
|
4048 |
|
|
+
|
4049 |
|
|
+ rxfile = "<filename>"
|
4050 |
|
|
+ filename, where to read data from
|
4051 |
|
|
+*/
|
4052 |
|
|
+
|
4053 |
|
|
+section kbd
|
4054 |
|
|
+ enabled = 1
|
4055 |
|
|
+ irq = 5
|
4056 |
|
|
+ baseaddr = 0x94000000
|
4057 |
|
|
+ rxfile = "kbd.rx"
|
4058 |
|
|
+end
|
4059 |
|
|
+
|
4060 |
|
|
+
|
4061 |
|
|
+/* ATA SECTION
|
4062 |
|
|
+
|
4063 |
|
|
+ This section configures the ATA/ATAPI host controller
|
4064 |
|
|
+
|
4065 |
|
|
+ baseaddr = <hex_value>
|
4066 |
|
|
+ address of first ATA register
|
4067 |
|
|
+
|
4068 |
|
|
+ enabled = <0|1>
|
4069 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4070 |
|
|
+
|
4071 |
|
|
+ irq = <value>
|
4072 |
|
|
+ irq number for this device
|
4073 |
|
|
+
|
4074 |
|
|
+ debug = <value>
|
4075 |
|
|
+ debug level for ata models.
|
4076 |
|
|
+ 0: no debug messages
|
4077 |
|
|
+ 1: verbose messages
|
4078 |
|
|
+ 3: normal messages (more messages than verbose)
|
4079 |
|
|
+ 5: debug messages (normal debug messages)
|
4080 |
|
|
+ 7: flow control messages (debug statemachine flows)
|
4081 |
|
|
+ 9: low priority message (display everything the code does)
|
4082 |
|
|
+
|
4083 |
|
|
+ dev_type0/1 = <value>
|
4084 |
|
|
+ ata device 0 type
|
4085 |
|
|
+ 0: NO_CONNeCT: none (not connected)
|
4086 |
|
|
+ 1: FILE : simulated harddisk
|
4087 |
|
|
+ 2: LOCAL : local system harddisk
|
4088 |
|
|
+
|
4089 |
|
|
+ dev_file0/1 = "<filename>"
|
4090 |
|
|
+ filename for simulated ATA device
|
4091 |
|
|
+ valid only if dev_type0 == 1
|
4092 |
|
|
+
|
4093 |
|
|
+ dev_size0/1 = <value>
|
4094 |
|
|
+ size of simulated hard-disk (in MBytes)
|
4095 |
|
|
+ valid only if dev_type0 == 1
|
4096 |
|
|
+
|
4097 |
|
|
+ dev_packet0/1 = <value>
|
4098 |
|
|
+ 0: simulated ATA device does NOT implement PACKET command feature set
|
4099 |
|
|
+ 1: simulated ATA device does implement PACKET command feature set
|
4100 |
|
|
+
|
4101 |
|
|
+ FIXME: irq number
|
4102 |
|
|
+*/
|
4103 |
|
|
+
|
4104 |
|
|
+section ata
|
4105 |
|
|
+ enabled = 0
|
4106 |
|
|
+ baseaddr = 0x9e000000
|
4107 |
|
|
+ irq = 15
|
4108 |
|
|
+
|
4109 |
|
|
+end
|
4110 |
|
|
+
|
4111 |
|
|
+
|
4112 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/or1ksim_x264_sadssdmod.cfg x264-or/or1ksim_x264_sadssdmod.cfg
|
4113 |
|
|
--- x264/or1ksim_x264_sadssdmod.cfg 1970-01-01 01:00:00.000000000 +0100
|
4114 |
|
|
+++ x264-or/or1ksim_x264_sadssdmod.cfg 2009-11-17 00:15:03.000000000 +0100
|
4115 |
|
|
@@ -0,0 +1,896 @@
|
4116 |
|
|
+/* sim.cfg -- Simulator configuration script file
|
4117 |
|
|
+ Copyright (C) 2001-2002, Marko Mlinar, markom@opencores.org
|
4118 |
|
|
+
|
4119 |
|
|
+This file is part of OpenRISC 1000 Architectural Simulator.
|
4120 |
|
|
+It contains the default configuration and help about configuring
|
4121 |
|
|
+the simulator.
|
4122 |
|
|
+
|
4123 |
|
|
+This program is free software; you can redistribute it and/or modify
|
4124 |
|
|
+it under the terms of the GNU General Public License as published by
|
4125 |
|
|
+the Free Software Foundation; either version 2 of the License, or
|
4126 |
|
|
+(at your option) any later version.
|
4127 |
|
|
+
|
4128 |
|
|
+This program is distributed in the hope that it will be useful,
|
4129 |
|
|
+but WITHOUT ANY WARRANTY; without even the implied warranty of
|
4130 |
|
|
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
4131 |
|
|
+GNU General Public License for more details.
|
4132 |
|
|
+
|
4133 |
|
|
+You should have received a copy of the GNU General Public License
|
4134 |
|
|
+along with this program; if not, write to the Free Software
|
4135 |
|
|
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
4136 |
|
|
+
|
4137 |
|
|
+
|
4138 |
|
|
+/* INTRODUCTION
|
4139 |
|
|
+
|
4140 |
|
|
+ The ork1sim has various parameters, that are set in configuration files
|
4141 |
|
|
+ like this one. The user can switch between configurations at startup by
|
4142 |
|
|
+ specifying the required configuration file with the -f <filename.cfg> option.
|
4143 |
|
|
+ If no configuration file is specified or1ksim searches for the default
|
4144 |
|
|
+ configuration file sim.cfg. First it searches for './sim.cfg'. If this
|
4145 |
|
|
+ file is not found, it searches for '~/or1k/sim.cfg'. If this file is
|
4146 |
|
|
+ not found too, it reverts to the built-in default configuration.
|
4147 |
|
|
+
|
4148 |
|
|
+ NOTE: Users should not rely on the built-in configuration, since the
|
4149 |
|
|
+ default configuration may differ between version.
|
4150 |
|
|
+ Rather create a configuration file that sets all critical values.
|
4151 |
|
|
+
|
4152 |
|
|
+ This file may contain (standard C) comments only - no // support.
|
4153 |
|
|
+
|
4154 |
|
|
+ Configure files may be be included, using:
|
4155 |
|
|
+ include "file_name_to_include"
|
4156 |
|
|
+
|
4157 |
|
|
+ Like normal configuration files, the included file is divided into
|
4158 |
|
|
+ sections. Each section is described in detail also.
|
4159 |
|
|
+
|
4160 |
|
|
+ Some section have subsections. One example of such a subsection is:
|
4161 |
|
|
+
|
4162 |
|
|
+ device <index>
|
4163 |
|
|
+ instance specific parameters...
|
4164 |
|
|
+ enddevice
|
4165 |
|
|
+
|
4166 |
|
|
+ which creates a device instance.
|
4167 |
|
|
+*/
|
4168 |
|
|
+
|
4169 |
|
|
+
|
4170 |
|
|
+/* MEMORY SECTION
|
4171 |
|
|
+
|
4172 |
|
|
+ This section specifies how the memory is generated and the blocks
|
4173 |
|
|
+ it consists of.
|
4174 |
|
|
+
|
4175 |
|
|
+ type = random/unknown/pattern
|
4176 |
|
|
+ Specifies the initial memory values.
|
4177 |
|
|
+ 'random' generates random memory using seed 'random_seed'.
|
4178 |
|
|
+ 'pattern' fills memory with 'pattern'.
|
4179 |
|
|
+ 'unknown' does not specify how memory should be generated,
|
4180 |
|
|
+ leaving the memory in a undefined state. This is the fastest
|
4181 |
|
|
+ option.
|
4182 |
|
|
+
|
4183 |
|
|
+ random_seed = <value>
|
4184 |
|
|
+ random seed for randomizer, used if type = 'random'.
|
4185 |
|
|
+
|
4186 |
|
|
+ pattern = <value>
|
4187 |
|
|
+ pattern to fill memory, used if type = 'pattern'.
|
4188 |
|
|
+
|
4189 |
|
|
+ nmemories = <value>
|
4190 |
|
|
+ number of memory instances connected
|
4191 |
|
|
+
|
4192 |
|
|
+ baseaddr = <hex_value>
|
4193 |
|
|
+ memory start address
|
4194 |
|
|
+
|
4195 |
|
|
+ size = <hex_value>
|
4196 |
|
|
+ memory size
|
4197 |
|
|
+
|
4198 |
|
|
+ name = "<string>"
|
4199 |
|
|
+ memory block name
|
4200 |
|
|
+
|
4201 |
|
|
+ ce = <value>
|
4202 |
|
|
+ chip enable index of the memory instance
|
4203 |
|
|
+
|
4204 |
|
|
+ mc = <value>
|
4205 |
|
|
+ memory controller this memory is connected to
|
4206 |
|
|
+
|
4207 |
|
|
+ delayr = <value>
|
4208 |
|
|
+ cycles, required for read access, -1 if instance does not support reading
|
4209 |
|
|
+
|
4210 |
|
|
+ delayw = <value>
|
4211 |
|
|
+ cycles, required for write access, -1 if instance does not support writing
|
4212 |
|
|
+
|
4213 |
|
|
+ log = "<filename>"
|
4214 |
|
|
+ filename, where to log memory accesses to, no log, if log command is not specified
|
4215 |
|
|
+*/
|
4216 |
|
|
+
|
4217 |
|
|
+
|
4218 |
|
|
+section memory
|
4219 |
|
|
+ /*random_seed = 12345
|
4220 |
|
|
+ type = random*/
|
4221 |
|
|
+ pattern = 0x00
|
4222 |
|
|
+ type = unknown /* Fastest */
|
4223 |
|
|
+
|
4224 |
|
|
+ name = "FLASH"
|
4225 |
|
|
+ ce = 0
|
4226 |
|
|
+ mc = 0
|
4227 |
|
|
+ baseaddr = 0xf0000000
|
4228 |
|
|
+ size = 0x01000000
|
4229 |
|
|
+ delayr = 10
|
4230 |
|
|
+ delayw = -1
|
4231 |
|
|
+end
|
4232 |
|
|
+
|
4233 |
|
|
+section memory
|
4234 |
|
|
+ /*random_seed = 12345
|
4235 |
|
|
+ type = random*/
|
4236 |
|
|
+ pattern = 0x00
|
4237 |
|
|
+ type = unknown /* Fastest */
|
4238 |
|
|
+
|
4239 |
|
|
+ name = "RAM"
|
4240 |
|
|
+ ce = 1
|
4241 |
|
|
+ mc = 0
|
4242 |
|
|
+ baseaddr = 0x00000000
|
4243 |
|
|
+ size = 0x02000000
|
4244 |
|
|
+ delayr = 20
|
4245 |
|
|
+ delayw = 25
|
4246 |
|
|
+end
|
4247 |
|
|
+
|
4248 |
|
|
+section memory
|
4249 |
|
|
+ /*random_seed = 12345
|
4250 |
|
|
+ type = random*/
|
4251 |
|
|
+ pattern = 0x00
|
4252 |
|
|
+ type = unknown /* Fastest */
|
4253 |
|
|
+
|
4254 |
|
|
+ name = "SRAM"
|
4255 |
|
|
+ mc = 0
|
4256 |
|
|
+ ce = 2
|
4257 |
|
|
+ baseaddr = 0xa4000000
|
4258 |
|
|
+ size = 0x00100000
|
4259 |
|
|
+ delayr = 1
|
4260 |
|
|
+ delayw = 2
|
4261 |
|
|
+end
|
4262 |
|
|
+
|
4263 |
|
|
+
|
4264 |
|
|
+/* IMMU SECTION
|
4265 |
|
|
+
|
4266 |
|
|
+ This section configures the Instruction Memory Manangement Unit
|
4267 |
|
|
+
|
4268 |
|
|
+ enabled = 0/1
|
4269 |
|
|
+ '0': disabled
|
4270 |
|
|
+ '1': enabled
|
4271 |
|
|
+ (NOTE: UPR bit is set)
|
4272 |
|
|
+
|
4273 |
|
|
+ nsets = <value>
|
4274 |
|
|
+ number of ITLB sets; must be power of two
|
4275 |
|
|
+
|
4276 |
|
|
+ nways = <value>
|
4277 |
|
|
+ number of ITLB ways
|
4278 |
|
|
+
|
4279 |
|
|
+ pagesize = <value>
|
4280 |
|
|
+ instruction page size; must be power of two
|
4281 |
|
|
+
|
4282 |
|
|
+ entrysize = <value>
|
4283 |
|
|
+ instruction entry size in bytes
|
4284 |
|
|
+
|
4285 |
|
|
+ ustates = <value>
|
4286 |
|
|
+ number of ITLB usage states (2, 3, 4 etc., max is 4)
|
4287 |
|
|
+
|
4288 |
|
|
+ hitdelay = <value>
|
4289 |
|
|
+ number of cycles immu hit costs
|
4290 |
|
|
+
|
4291 |
|
|
+ missdelay = <value>
|
4292 |
|
|
+ number of cycles immu miss costs
|
4293 |
|
|
+*/
|
4294 |
|
|
+
|
4295 |
|
|
+section immu
|
4296 |
|
|
+ enabled = 0
|
4297 |
|
|
+ nsets = 64
|
4298 |
|
|
+ nways = 1
|
4299 |
|
|
+ pagesize = 8192
|
4300 |
|
|
+ hitdelay = 0
|
4301 |
|
|
+ missdelay = 0
|
4302 |
|
|
+end
|
4303 |
|
|
+
|
4304 |
|
|
+
|
4305 |
|
|
+/* DMMU SECTION
|
4306 |
|
|
+
|
4307 |
|
|
+ This section configures the Data Memory Manangement Unit
|
4308 |
|
|
+
|
4309 |
|
|
+ enabled = 0/1
|
4310 |
|
|
+ '0': disabled
|
4311 |
|
|
+ '1': enabled
|
4312 |
|
|
+ (NOTE: UPR bit is set)
|
4313 |
|
|
+
|
4314 |
|
|
+ nsets = <value>
|
4315 |
|
|
+ number of DTLB sets; must be power of two
|
4316 |
|
|
+
|
4317 |
|
|
+ nways = <value>
|
4318 |
|
|
+ number of DTLB ways
|
4319 |
|
|
+
|
4320 |
|
|
+ pagesize = <value>
|
4321 |
|
|
+ data page size; must be power of two
|
4322 |
|
|
+
|
4323 |
|
|
+ entrysize = <value>
|
4324 |
|
|
+ data entry size in bytes
|
4325 |
|
|
+
|
4326 |
|
|
+ ustates = <value>
|
4327 |
|
|
+ number of DTLB usage states (2, 3, 4 etc., max is 4)
|
4328 |
|
|
+
|
4329 |
|
|
+ hitdelay = <value>
|
4330 |
|
|
+ number of cycles dmmu hit costs
|
4331 |
|
|
+
|
4332 |
|
|
+ missdelay = <value>
|
4333 |
|
|
+ number of cycles dmmu miss costs
|
4334 |
|
|
+*/
|
4335 |
|
|
+
|
4336 |
|
|
+section dmmu
|
4337 |
|
|
+ enabled = 0
|
4338 |
|
|
+ nsets = 64
|
4339 |
|
|
+ nways = 1
|
4340 |
|
|
+ pagesize = 8192
|
4341 |
|
|
+ hitdelay = 0
|
4342 |
|
|
+ missdelay = 0
|
4343 |
|
|
+end
|
4344 |
|
|
+
|
4345 |
|
|
+
|
4346 |
|
|
+/* IC SECTION
|
4347 |
|
|
+
|
4348 |
|
|
+ This section configures the Instruction Cache
|
4349 |
|
|
+
|
4350 |
|
|
+ enabled = 0/1
|
4351 |
|
|
+ '0': disabled
|
4352 |
|
|
+ '1': enabled
|
4353 |
|
|
+ (NOTE: UPR bit is set)
|
4354 |
|
|
+
|
4355 |
|
|
+ nsets = <value>
|
4356 |
|
|
+ number of IC sets; must be power of two
|
4357 |
|
|
+
|
4358 |
|
|
+ nways = <value>
|
4359 |
|
|
+ number of IC ways
|
4360 |
|
|
+
|
4361 |
|
|
+ blocksize = <value>
|
4362 |
|
|
+ IC block size in bytes; must be power of two
|
4363 |
|
|
+
|
4364 |
|
|
+ ustates = <value>
|
4365 |
|
|
+ number of IC usage states (2, 3, 4 etc., max is 4)
|
4366 |
|
|
+
|
4367 |
|
|
+ hitdelay = <value>
|
4368 |
|
|
+ number of cycles ic hit costs
|
4369 |
|
|
+
|
4370 |
|
|
+ missdelay = <value>
|
4371 |
|
|
+ number of cycles ic miss costs
|
4372 |
|
|
+*/
|
4373 |
|
|
+
|
4374 |
|
|
+section ic
|
4375 |
|
|
+ enabled = 0
|
4376 |
|
|
+ nsets = 512
|
4377 |
|
|
+ nways = 1
|
4378 |
|
|
+ blocksize = 16
|
4379 |
|
|
+ hitdelay = 20
|
4380 |
|
|
+ missdelay = 20
|
4381 |
|
|
+end
|
4382 |
|
|
+
|
4383 |
|
|
+
|
4384 |
|
|
+/* DC SECTION
|
4385 |
|
|
+
|
4386 |
|
|
+ This section configures the Data Cache
|
4387 |
|
|
+
|
4388 |
|
|
+ enabled = 0/1
|
4389 |
|
|
+ '0': disabled
|
4390 |
|
|
+ '1': enabled
|
4391 |
|
|
+ (NOTE: UPR bit is set)
|
4392 |
|
|
+
|
4393 |
|
|
+ nsets = <value>
|
4394 |
|
|
+ number of DC sets; must be power of two
|
4395 |
|
|
+
|
4396 |
|
|
+ nways = <value>
|
4397 |
|
|
+ number of DC ways
|
4398 |
|
|
+
|
4399 |
|
|
+ blocksize = <value>
|
4400 |
|
|
+ DC block size in bytes; must be power of two
|
4401 |
|
|
+
|
4402 |
|
|
+ ustates = <value>
|
4403 |
|
|
+ number of DC usage states (2, 3, 4 etc., max is 4)
|
4404 |
|
|
+
|
4405 |
|
|
+ load_hitdelay = <value>
|
4406 |
|
|
+ number of cycles dc load hit costs
|
4407 |
|
|
+
|
4408 |
|
|
+ load_missdelay = <value>
|
4409 |
|
|
+ number of cycles dc load miss costs
|
4410 |
|
|
+
|
4411 |
|
|
+ store_hitdelay = <value>
|
4412 |
|
|
+ number of cycles dc load hit costs
|
4413 |
|
|
+
|
4414 |
|
|
+ store_missdelay = <value>
|
4415 |
|
|
+ number of cycles dc load miss costs
|
4416 |
|
|
+*/
|
4417 |
|
|
+
|
4418 |
|
|
+section dc
|
4419 |
|
|
+ enabled = 0
|
4420 |
|
|
+ nsets = 512
|
4421 |
|
|
+ nways = 1
|
4422 |
|
|
+ blocksize = 16
|
4423 |
|
|
+ load_hitdelay = 20
|
4424 |
|
|
+ load_missdelay = 20
|
4425 |
|
|
+ store_hitdelay = 20
|
4426 |
|
|
+ store_missdelay = 20
|
4427 |
|
|
+end
|
4428 |
|
|
+
|
4429 |
|
|
+
|
4430 |
|
|
+/* SIM SECTION
|
4431 |
|
|
+
|
4432 |
|
|
+ This section specifies how or1ksim should behave.
|
4433 |
|
|
+
|
4434 |
|
|
+ verbose = 0/1
|
4435 |
|
|
+ '0': don't print extra messages
|
4436 |
|
|
+ '1': print extra messages
|
4437 |
|
|
+
|
4438 |
|
|
+ debug = 0-9
|
4439 |
|
|
+ 0 : no debug messages
|
4440 |
|
|
+ 1-9: debug message level.
|
4441 |
|
|
+ higher numbers produce more messages
|
4442 |
|
|
+
|
4443 |
|
|
+ profile = 0/1
|
4444 |
|
|
+ '0': don't generate profiling file 'sim.profile'
|
4445 |
|
|
+ '1': don't generate profiling file 'sim.profile'
|
4446 |
|
|
+
|
4447 |
|
|
+ prof_fn = "<filename>"
|
4448 |
|
|
+ optional filename for the profiling file.
|
4449 |
|
|
+ valid only if 'profile' is set
|
4450 |
|
|
+
|
4451 |
|
|
+ mprofile = 0/1
|
4452 |
|
|
+ '0': don't generate memory profiling file 'sim.mprofile'
|
4453 |
|
|
+ '1': generate memory profiling file 'sim.mprofile'
|
4454 |
|
|
+
|
4455 |
|
|
+ mprof_fn = "<filename>"
|
4456 |
|
|
+ optional filename for the memory profiling file.
|
4457 |
|
|
+ valid only if 'mprofile' is set
|
4458 |
|
|
+
|
4459 |
|
|
+ history = 0/1
|
4460 |
|
|
+ '0': don't track execution flow
|
4461 |
|
|
+ '1': track execution flow
|
4462 |
|
|
+ Execution flow can be tracked for the simulator's
|
4463 |
|
|
+ 'hist' command. Useful for back-trace debugging.
|
4464 |
|
|
+
|
4465 |
|
|
+ iprompt = 0/1
|
4466 |
|
|
+ '0': start in <not interactive prompt> (so what do we start in ???)
|
4467 |
|
|
+ '1': start in interactive prompt.
|
4468 |
|
|
+
|
4469 |
|
|
+ exe_log = 0/1
|
4470 |
|
|
+ '0': don't generate execution log.
|
4471 |
|
|
+ '1': generate execution log.
|
4472 |
|
|
+
|
4473 |
|
|
+ exe_log = default/hardware/simple/software
|
4474 |
|
|
+ type of execution log, default is used when not specified
|
4475 |
|
|
+
|
4476 |
|
|
+ exe_log_start = <value>
|
4477 |
|
|
+ index of first instruction to start logging, default = 0
|
4478 |
|
|
+
|
4479 |
|
|
+ exe_log_end = <value>
|
4480 |
|
|
+ index of last instruction to end logging; not limited, if omitted
|
4481 |
|
|
+
|
4482 |
|
|
+ exe_log_marker = <value>
|
4483 |
|
|
+ <value> specifies number of instructions before horizontal marker is
|
4484 |
|
|
+ printed; if zero, markers are disabled (default)
|
4485 |
|
|
+
|
4486 |
|
|
+ exe_log_fn = "<filename>"
|
4487 |
|
|
+ filename for the exection log file.
|
4488 |
|
|
+ valid only if 'exe_log' is set
|
4489 |
|
|
+
|
4490 |
|
|
+ clkcycle = <value>[ps|ns|us|ms]
|
4491 |
|
|
+ specifies time measurement for one cycle
|
4492 |
|
|
+*/
|
4493 |
|
|
+
|
4494 |
|
|
+section sim
|
4495 |
|
|
+ verbose = 1
|
4496 |
|
|
+ debug = 0
|
4497 |
|
|
+ profile = 0
|
4498 |
|
|
+ history = 0
|
4499 |
|
|
+
|
4500 |
|
|
+ clkcycle = 10ns
|
4501 |
|
|
+end
|
4502 |
|
|
+
|
4503 |
|
|
+
|
4504 |
|
|
+/* SECTION VAPI
|
4505 |
|
|
+
|
4506 |
|
|
+ This section configures the Verification API, used for Advanced
|
4507 |
|
|
+ Core Verification.
|
4508 |
|
|
+
|
4509 |
|
|
+ enabled = 0/1
|
4510 |
|
|
+ '0': disbable VAPI server
|
4511 |
|
|
+ '1': enable/start VAPI server
|
4512 |
|
|
+
|
4513 |
|
|
+ server_port = <value>
|
4514 |
|
|
+ TCP/IP port to start VAPI server on
|
4515 |
|
|
+
|
4516 |
|
|
+ log_enabled = 0/1
|
4517 |
|
|
+ '0': disable VAPI requests logging
|
4518 |
|
|
+ '1': enable VAPI requests logging
|
4519 |
|
|
+
|
4520 |
|
|
+ hide_device_id = 0/1
|
4521 |
|
|
+ '0': don't log device id (for compatability with old version)
|
4522 |
|
|
+ '1': log device id
|
4523 |
|
|
+
|
4524 |
|
|
+
|
4525 |
|
|
+ vapi_fn = <filename>
|
4526 |
|
|
+ filename for the log file.
|
4527 |
|
|
+ valid only if log_enabled is set
|
4528 |
|
|
+*/
|
4529 |
|
|
+
|
4530 |
|
|
+section VAPI
|
4531 |
|
|
+ enabled = 0
|
4532 |
|
|
+ server_port = 9998
|
4533 |
|
|
+ log_enabled = 0
|
4534 |
|
|
+ vapi_log_fn = "vapi.log"
|
4535 |
|
|
+end
|
4536 |
|
|
+
|
4537 |
|
|
+
|
4538 |
|
|
+/* CPU SECTION
|
4539 |
|
|
+
|
4540 |
|
|
+ This section specifies various CPU parameters.
|
4541 |
|
|
+
|
4542 |
|
|
+ ver = <value>
|
4543 |
|
|
+ rev = <value>
|
4544 |
|
|
+ specifies version and revision of the CPU used
|
4545 |
|
|
+
|
4546 |
|
|
+ upr = <value>
|
4547 |
|
|
+ changes the upr register
|
4548 |
|
|
+
|
4549 |
|
|
+ sr = <value>
|
4550 |
|
|
+ sets the initial Supervision Register value
|
4551 |
|
|
+
|
4552 |
|
|
+ superscalar = 0/1
|
4553 |
|
|
+ '0': CPU is scalar
|
4554 |
|
|
+ '1': CPU is superscalar
|
4555 |
|
|
+ (modify cpu/or32/execute.c to tune superscalar model)
|
4556 |
|
|
+
|
4557 |
|
|
+ hazards = 0/1
|
4558 |
|
|
+ '0': don't track data hazards in superscalar CPU
|
4559 |
|
|
+ '1': track data hazards in superscalar CPU
|
4560 |
|
|
+ If tracked, data hazards can be displayed using the
|
4561 |
|
|
+ simulator's 'r' command.
|
4562 |
|
|
+
|
4563 |
|
|
+ dependstats = 0/1
|
4564 |
|
|
+ '0': don't calculate inter-instruction dependencies.
|
4565 |
|
|
+ '1': calculate inter-instruction dependencies.
|
4566 |
|
|
+ If calculated, inter-instruction dependencies can be
|
4567 |
|
|
+ displayed using the simulator's 'stat' command.
|
4568 |
|
|
+
|
4569 |
|
|
+ sbuf_len = <value>
|
4570 |
|
|
+ length of store buffer (<= 256), 0 = disabled
|
4571 |
|
|
+*/
|
4572 |
|
|
+
|
4573 |
|
|
+section cpu
|
4574 |
|
|
+ ver = 0x12
|
4575 |
|
|
+ cfg = 0x00
|
4576 |
|
|
+ rev = 0x01
|
4577 |
|
|
+ /* upr = */
|
4578 |
|
|
+ superscalar = 0
|
4579 |
|
|
+ hazards = 0
|
4580 |
|
|
+ dependstats = 0
|
4581 |
|
|
+ sbuf_len = 0
|
4582 |
|
|
+ hardfloat = 1
|
4583 |
|
|
+end
|
4584 |
|
|
+
|
4585 |
|
|
+
|
4586 |
|
|
+/* PM SECTION
|
4587 |
|
|
+
|
4588 |
|
|
+ This section specifies Power Management parameters
|
4589 |
|
|
+
|
4590 |
|
|
+ enabled = 0/1
|
4591 |
|
|
+ '0': disable power management
|
4592 |
|
|
+ '1': enable power management
|
4593 |
|
|
+*/
|
4594 |
|
|
+
|
4595 |
|
|
+section pm
|
4596 |
|
|
+ enabled = 0
|
4597 |
|
|
+end
|
4598 |
|
|
+
|
4599 |
|
|
+
|
4600 |
|
|
+/* BPB SECTION
|
4601 |
|
|
+
|
4602 |
|
|
+ This section specifies how branch prediction should behave.
|
4603 |
|
|
+
|
4604 |
|
|
+ enabled = 0/1
|
4605 |
|
|
+ '0': disable branch prediction
|
4606 |
|
|
+ '1': enable branch prediction
|
4607 |
|
|
+
|
4608 |
|
|
+ btic = 0/1
|
4609 |
|
|
+ '0': disable branch target instruction cache model
|
4610 |
|
|
+ '1': enable branch target instruction cache model
|
4611 |
|
|
+
|
4612 |
|
|
+ sbp_bf_fwd = 0/1
|
4613 |
|
|
+ Static branch prediction for 'l.bf'
|
4614 |
|
|
+ '0': don't use forward prediction
|
4615 |
|
|
+ '1': use forward prediction
|
4616 |
|
|
+
|
4617 |
|
|
+ sbp_bnf_fwd = 0/1
|
4618 |
|
|
+ Static branch prediction for 'l.bnf'
|
4619 |
|
|
+ '0': don't use forward prediction
|
4620 |
|
|
+ '1': use forward prediction
|
4621 |
|
|
+
|
4622 |
|
|
+ hitdelay = <value>
|
4623 |
|
|
+ number of cycles bpb hit costs
|
4624 |
|
|
+
|
4625 |
|
|
+ missdelay = <value>
|
4626 |
|
|
+ number of cycles bpb miss costs
|
4627 |
|
|
+*/
|
4628 |
|
|
+
|
4629 |
|
|
+section bpb
|
4630 |
|
|
+ enabled = 0
|
4631 |
|
|
+ btic = 0
|
4632 |
|
|
+ sbp_bf_fwd = 0
|
4633 |
|
|
+ sbp_bnf_fwd = 0
|
4634 |
|
|
+ hitdelay = 0
|
4635 |
|
|
+ missdelay = 0
|
4636 |
|
|
+end
|
4637 |
|
|
+
|
4638 |
|
|
+
|
4639 |
|
|
+/* DEBUG SECTION
|
4640 |
|
|
+
|
4641 |
|
|
+ This sections specifies how the debug unit should behave.
|
4642 |
|
|
+
|
4643 |
|
|
+ enabled = 0/1
|
4644 |
|
|
+ '0': disable debug unit
|
4645 |
|
|
+ '1': enable debug unit
|
4646 |
|
|
+
|
4647 |
|
|
+ gdb_enabled = 0/1
|
4648 |
|
|
+ '0': don't start gdb server
|
4649 |
|
|
+ '1': start gdb server at port 'server_port'
|
4650 |
|
|
+
|
4651 |
|
|
+ server_port = <value>
|
4652 |
|
|
+ TCP/IP port to start gdb server on
|
4653 |
|
|
+ valid only if gdb_enabled is set
|
4654 |
|
|
+
|
4655 |
|
|
+ vapi_id = <hex_value>
|
4656 |
|
|
+ Used to create "fake" vapi log file containing the JTAG proxy messages.
|
4657 |
|
|
+*/
|
4658 |
|
|
+section debug
|
4659 |
|
|
+ enabled = 0
|
4660 |
|
|
+ rsp_enabled = 0
|
4661 |
|
|
+ rsp_port = 5554
|
4662 |
|
|
+ /*server_port = 9999*/
|
4663 |
|
|
+end
|
4664 |
|
|
+
|
4665 |
|
|
+
|
4666 |
|
|
+/* MC SECTION
|
4667 |
|
|
+
|
4668 |
|
|
+ This section configures the memory controller
|
4669 |
|
|
+
|
4670 |
|
|
+ enabled = 0/1
|
4671 |
|
|
+ '0': disable memory controller
|
4672 |
|
|
+ '1': enable memory controller
|
4673 |
|
|
+
|
4674 |
|
|
+ baseaddr = <hex_value>
|
4675 |
|
|
+ address of first MC register
|
4676 |
|
|
+
|
4677 |
|
|
+ POC = <hex_value>
|
4678 |
|
|
+ Power On Configuration register
|
4679 |
|
|
+
|
4680 |
|
|
+ index = <value>
|
4681 |
|
|
+ Index of this memory controller amongst all the memory controllers
|
4682 |
|
|
+*/
|
4683 |
|
|
+
|
4684 |
|
|
+section mc
|
4685 |
|
|
+ enabled = 0
|
4686 |
|
|
+ baseaddr = 0x93000000
|
4687 |
|
|
+ POC = 0x00000008 /* Power on configuration register */
|
4688 |
|
|
+ index = 0
|
4689 |
|
|
+end
|
4690 |
|
|
+
|
4691 |
|
|
+
|
4692 |
|
|
+/* UART SECTION
|
4693 |
|
|
+
|
4694 |
|
|
+ This section configures the UARTs
|
4695 |
|
|
+
|
4696 |
|
|
+ enabled = <0|1>
|
4697 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4698 |
|
|
+
|
4699 |
|
|
+ baseaddr = <hex_value>
|
4700 |
|
|
+ address of first UART register for this device
|
4701 |
|
|
+
|
4702 |
|
|
+
|
4703 |
|
|
+ channel = <channeltype>:<args>
|
4704 |
|
|
+
|
4705 |
|
|
+ The channel parameter indicates the source of received UART characters
|
4706 |
|
|
+ and the sink for transmitted UART characters.
|
4707 |
|
|
+
|
4708 |
|
|
+ The <channeltype> can be either "file", "xterm", "tcp", "fd", or "tty"
|
4709 |
|
|
+ (without quotes).
|
4710 |
|
|
+
|
4711 |
|
|
+ A) To send/receive characters from a pair of files, use a file
|
4712 |
|
|
+ channel:
|
4713 |
|
|
+
|
4714 |
|
|
+ channel=file:<rxfile>,<txfile>
|
4715 |
|
|
+
|
4716 |
|
|
+ B) To create an interactive terminal window, use an xterm channel:
|
4717 |
|
|
+
|
4718 |
|
|
+ channel=xterm:[<xterm_arg>]*
|
4719 |
|
|
+
|
4720 |
|
|
+ C) To create a bidirectional tcp socket which one could, for example,
|
4721 |
|
|
+ access via telnet, use a tcp channel:
|
4722 |
|
|
+
|
4723 |
|
|
+ channel=tcp:<port number>
|
4724 |
|
|
+
|
4725 |
|
|
+ D) To cause the UART to read/write from existing numeric file
|
4726 |
|
|
+ descriptors, use an fd channel:
|
4727 |
|
|
+
|
4728 |
|
|
+ channel=fd:<rx file descriptor num>,<tx file descriptor num>
|
4729 |
|
|
+
|
4730 |
|
|
+ E) To connect the UART to a physical serial port, create a tty
|
4731 |
|
|
+ channel:
|
4732 |
|
|
+
|
4733 |
|
|
+ channel=tty:device=/dev/ttyS0,baud=9600
|
4734 |
|
|
+
|
4735 |
|
|
+ irq = <value>
|
4736 |
|
|
+ irq number for this device
|
4737 |
|
|
+
|
4738 |
|
|
+ 16550 = 0/1
|
4739 |
|
|
+ '0': this device is a UART16450
|
4740 |
|
|
+ '1': this device is a UART16550
|
4741 |
|
|
+
|
4742 |
|
|
+ jitter = <value>
|
4743 |
|
|
+ in msecs... time to block, -1 to disable it
|
4744 |
|
|
+
|
4745 |
|
|
+ vapi_id = <hex_value>
|
4746 |
|
|
+ VAPI id of this instance
|
4747 |
|
|
+*/
|
4748 |
|
|
+
|
4749 |
|
|
+section uart
|
4750 |
|
|
+ enabled = 1
|
4751 |
|
|
+ baseaddr = 0x90000000
|
4752 |
|
|
+ irq = 2
|
4753 |
|
|
+ channel = "file:uart0.rx,uart0.tx"
|
4754 |
|
|
+ /* channel = "tcp:10084" */
|
4755 |
|
|
+ /* channel = "xterm:" */
|
4756 |
|
|
+ jitter = -1 /* async behaviour */
|
4757 |
|
|
+ 16550 = 1
|
4758 |
|
|
+end
|
4759 |
|
|
+
|
4760 |
|
|
+
|
4761 |
|
|
+/* DMA SECTION
|
4762 |
|
|
+
|
4763 |
|
|
+ This section configures the DMAs
|
4764 |
|
|
+
|
4765 |
|
|
+ enabled = <0|1>
|
4766 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4767 |
|
|
+
|
4768 |
|
|
+ baseaddr = <hex_value>
|
4769 |
|
|
+ address of first DMA register for this device
|
4770 |
|
|
+
|
4771 |
|
|
+ irq = <value>
|
4772 |
|
|
+ irq number for this device
|
4773 |
|
|
+
|
4774 |
|
|
+ vapi_id = <hex_value>
|
4775 |
|
|
+ VAPI id of this instance
|
4776 |
|
|
+*/
|
4777 |
|
|
+
|
4778 |
|
|
+section dma
|
4779 |
|
|
+ enabled = 0
|
4780 |
|
|
+ baseaddr = 0x9a000000
|
4781 |
|
|
+ irq = 11
|
4782 |
|
|
+end
|
4783 |
|
|
+
|
4784 |
|
|
+
|
4785 |
|
|
+/* ETHERNET SECTION
|
4786 |
|
|
+
|
4787 |
|
|
+ This section configures the ETHERNETs
|
4788 |
|
|
+
|
4789 |
|
|
+ enabled = <0|1>
|
4790 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4791 |
|
|
+
|
4792 |
|
|
+ baseaddr = <hex_value>
|
4793 |
|
|
+ address of first ethernet register for this device
|
4794 |
|
|
+
|
4795 |
|
|
+ dma = <value>
|
4796 |
|
|
+ which controller is this ethernet "connected" to
|
4797 |
|
|
+
|
4798 |
|
|
+ irq = <value>
|
4799 |
|
|
+ ethernet mac IRQ level
|
4800 |
|
|
+
|
4801 |
|
|
+ rtx_type = <value>
|
4802 |
|
|
+ use 0 - file interface, 1 - socket interface
|
4803 |
|
|
+
|
4804 |
|
|
+ rx_channel = <value>
|
4805 |
|
|
+ DMA channel used for RX
|
4806 |
|
|
+
|
4807 |
|
|
+ tx_channel = <value>
|
4808 |
|
|
+ DMA channel used for TX
|
4809 |
|
|
+
|
4810 |
|
|
+ rxfile = "<filename>"
|
4811 |
|
|
+ filename, where to read data from
|
4812 |
|
|
+
|
4813 |
|
|
+ txfile = "<filename>"
|
4814 |
|
|
+ filename, where to write data to
|
4815 |
|
|
+
|
4816 |
|
|
+ sockif = "<ifacename>"
|
4817 |
|
|
+ interface name of ethernet socket
|
4818 |
|
|
+
|
4819 |
|
|
+ vapi_id = <hex_value>
|
4820 |
|
|
+ VAPI id of this instance
|
4821 |
|
|
+*/
|
4822 |
|
|
+
|
4823 |
|
|
+section ethernet
|
4824 |
|
|
+ enabled = 0
|
4825 |
|
|
+ baseaddr = 0x92000000
|
4826 |
|
|
+ /* dma = 0 */
|
4827 |
|
|
+ irq = 4
|
4828 |
|
|
+ rtx_type = 0
|
4829 |
|
|
+ /* tx_channel = 0 */
|
4830 |
|
|
+ /* rx_channel = 1 */
|
4831 |
|
|
+ /*rxfile = "eth0.rx"*/
|
4832 |
|
|
+ txfile = "eth0.tx"
|
4833 |
|
|
+ sockif = "eth0"
|
4834 |
|
|
+end
|
4835 |
|
|
+
|
4836 |
|
|
+
|
4837 |
|
|
+/* GPIO SECTION
|
4838 |
|
|
+
|
4839 |
|
|
+ This section configures the GPIOs
|
4840 |
|
|
+
|
4841 |
|
|
+ enabled = <0|1>
|
4842 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4843 |
|
|
+
|
4844 |
|
|
+ baseaddr = <hex_value>
|
4845 |
|
|
+ address of first GPIO register for this device
|
4846 |
|
|
+
|
4847 |
|
|
+ irq = <value>
|
4848 |
|
|
+ irq number for this device
|
4849 |
|
|
+
|
4850 |
|
|
+ base_vapi_id = <hex_value>
|
4851 |
|
|
+ first VAPI id of this instance
|
4852 |
|
|
+ GPIO uses 8 consecutive VAPI IDs
|
4853 |
|
|
+*/
|
4854 |
|
|
+
|
4855 |
|
|
+section gpio
|
4856 |
|
|
+ enabled = 0
|
4857 |
|
|
+ baseaddr = 0x91000000
|
4858 |
|
|
+ irq = 3
|
4859 |
|
|
+ base_vapi_id = 0x0200
|
4860 |
|
|
+end
|
4861 |
|
|
+
|
4862 |
|
|
+/* VGA SECTION
|
4863 |
|
|
+
|
4864 |
|
|
+ This section configures the VGA/LCD controller
|
4865 |
|
|
+
|
4866 |
|
|
+ enabled = <0|1>
|
4867 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4868 |
|
|
+
|
4869 |
|
|
+ baseaddr = <hex_value>
|
4870 |
|
|
+ address of first VGA register
|
4871 |
|
|
+
|
4872 |
|
|
+ irq = <value>
|
4873 |
|
|
+ irq number for this device
|
4874 |
|
|
+
|
4875 |
|
|
+ refresh_rate = <value>
|
4876 |
|
|
+ number of cycles between screen dumps
|
4877 |
|
|
+
|
4878 |
|
|
+ filename = "<filename>"
|
4879 |
|
|
+ template name for generated names (e.g. "primary" produces "primary0023.bmp")
|
4880 |
|
|
+*/
|
4881 |
|
|
+
|
4882 |
|
|
+section vga
|
4883 |
|
|
+ enabled = 0
|
4884 |
|
|
+ baseaddr = 0x97100000
|
4885 |
|
|
+ irq = 8
|
4886 |
|
|
+ refresh_rate = 100000
|
4887 |
|
|
+ filename = "primary"
|
4888 |
|
|
+end
|
4889 |
|
|
+
|
4890 |
|
|
+
|
4891 |
|
|
+/* TICK TIMER SECTION
|
4892 |
|
|
+
|
4893 |
|
|
+ This section configures tick timer
|
4894 |
|
|
+
|
4895 |
|
|
+ enabled = 0/1
|
4896 |
|
|
+ whether tick timer is enabled
|
4897 |
|
|
+*/
|
4898 |
|
|
+
|
4899 |
|
|
+section pic
|
4900 |
|
|
+ enabled = 1
|
4901 |
|
|
+ edge_trigger = 1
|
4902 |
|
|
+end
|
4903 |
|
|
+
|
4904 |
|
|
+/* FB SECTION
|
4905 |
|
|
+
|
4906 |
|
|
+ This section configures the frame buffer
|
4907 |
|
|
+
|
4908 |
|
|
+ enabled = <0|1>
|
4909 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4910 |
|
|
+
|
4911 |
|
|
+ baseaddr = <hex_value>
|
4912 |
|
|
+ base address of frame buffer
|
4913 |
|
|
+
|
4914 |
|
|
+ paladdr = <hex_value>
|
4915 |
|
|
+ base address of first palette entry
|
4916 |
|
|
+
|
4917 |
|
|
+ refresh_rate = <value>
|
4918 |
|
|
+ number of cycles between screen dumps
|
4919 |
|
|
+
|
4920 |
|
|
+ filename = "<filename>"
|
4921 |
|
|
+ template name for generated names (e.g. "primary" produces "primary0023.bmp")
|
4922 |
|
|
+*/
|
4923 |
|
|
+
|
4924 |
|
|
+section fb
|
4925 |
|
|
+ enabled = 0
|
4926 |
|
|
+ baseaddr = 0x97000000
|
4927 |
|
|
+ refresh_rate = 1000000
|
4928 |
|
|
+ filename = "primary"
|
4929 |
|
|
+end
|
4930 |
|
|
+
|
4931 |
|
|
+
|
4932 |
|
|
+/* KBD SECTION
|
4933 |
|
|
+
|
4934 |
|
|
+ This section configures the PS/2 compatible keyboard
|
4935 |
|
|
+
|
4936 |
|
|
+ baseaddr = <hex_value>
|
4937 |
|
|
+ base address of the keyboard device
|
4938 |
|
|
+
|
4939 |
|
|
+ rxfile = "<filename>"
|
4940 |
|
|
+ filename, where to read data from
|
4941 |
|
|
+*/
|
4942 |
|
|
+
|
4943 |
|
|
+section kbd
|
4944 |
|
|
+ enabled = 0
|
4945 |
|
|
+ irq = 5
|
4946 |
|
|
+ baseaddr = 0x94000000
|
4947 |
|
|
+ rxfile = "kbd.rx"
|
4948 |
|
|
+end
|
4949 |
|
|
+
|
4950 |
|
|
+
|
4951 |
|
|
+/* ATA SECTION
|
4952 |
|
|
+
|
4953 |
|
|
+ This section configures the ATA/ATAPI host controller
|
4954 |
|
|
+
|
4955 |
|
|
+ baseaddr = <hex_value>
|
4956 |
|
|
+ address of first ATA register
|
4957 |
|
|
+
|
4958 |
|
|
+ enabled = <0|1>
|
4959 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
4960 |
|
|
+
|
4961 |
|
|
+ irq = <value>
|
4962 |
|
|
+ irq number for this device
|
4963 |
|
|
+
|
4964 |
|
|
+ debug = <value>
|
4965 |
|
|
+ debug level for ata models.
|
4966 |
|
|
+ 0: no debug messages
|
4967 |
|
|
+ 1: verbose messages
|
4968 |
|
|
+ 3: normal messages (more messages than verbose)
|
4969 |
|
|
+ 5: debug messages (normal debug messages)
|
4970 |
|
|
+ 7: flow control messages (debug statemachine flows)
|
4971 |
|
|
+ 9: low priority message (display everything the code does)
|
4972 |
|
|
+
|
4973 |
|
|
+ dev_type0/1 = <value>
|
4974 |
|
|
+ ata device 0 type
|
4975 |
|
|
+ 0: NO_CONNeCT: none (not connected)
|
4976 |
|
|
+ 1: FILE : simulated harddisk
|
4977 |
|
|
+ 2: LOCAL : local system harddisk
|
4978 |
|
|
+
|
4979 |
|
|
+ dev_file0/1 = "<filename>"
|
4980 |
|
|
+ filename for simulated ATA device
|
4981 |
|
|
+ valid only if dev_type0 == 1
|
4982 |
|
|
+
|
4983 |
|
|
+ dev_size0/1 = <value>
|
4984 |
|
|
+ size of simulated hard-disk (in MBytes)
|
4985 |
|
|
+ valid only if dev_type0 == 1
|
4986 |
|
|
+
|
4987 |
|
|
+ dev_packet0/1 = <value>
|
4988 |
|
|
+ 0: simulated ATA device does NOT implement PACKET command feature set
|
4989 |
|
|
+ 1: simulated ATA device does implement PACKET command feature set
|
4990 |
|
|
+
|
4991 |
|
|
+ FIXME: irq number
|
4992 |
|
|
+*/
|
4993 |
|
|
+
|
4994 |
|
|
+section ata
|
4995 |
|
|
+ enabled = 0
|
4996 |
|
|
+ baseaddr = 0x9e000000
|
4997 |
|
|
+ irq = 15
|
4998 |
|
|
+
|
4999 |
|
|
+end
|
5000 |
|
|
+
|
5001 |
|
|
+
|
5002 |
|
|
+
|
5003 |
|
|
+/* SAD/SSD MODULE SECTION
|
5004 |
|
|
+ This module calculates SAD/SSD on a set of data, specifically
|
5005 |
|
|
+ for use with the x264 H.264 encoding software.
|
5006 |
|
|
+*/
|
5007 |
|
|
+section x264_sadssdmod
|
5008 |
|
|
+ enabled = 1
|
5009 |
|
|
+ baseaddr = 0x26400000
|
5010 |
|
|
+ name = "x264_sadssdmod0"
|
5011 |
|
|
+end
|
5012 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/rsp_or1ksim_x264.cfg x264-or/rsp_or1ksim_x264.cfg
|
5013 |
|
|
--- x264/rsp_or1ksim_x264.cfg 1970-01-01 01:00:00.000000000 +0100
|
5014 |
|
|
+++ x264-or/rsp_or1ksim_x264.cfg 2009-11-15 19:56:58.000000000 +0100
|
5015 |
|
|
@@ -0,0 +1,886 @@
|
5016 |
|
|
+/* sim.cfg -- Simulator configuration script file
|
5017 |
|
|
+ Copyright (C) 2001-2002, Marko Mlinar, markom@opencores.org
|
5018 |
|
|
+
|
5019 |
|
|
+This file is part of OpenRISC 1000 Architectural Simulator.
|
5020 |
|
|
+It contains the default configuration and help about configuring
|
5021 |
|
|
+the simulator.
|
5022 |
|
|
+
|
5023 |
|
|
+This program is free software; you can redistribute it and/or modify
|
5024 |
|
|
+it under the terms of the GNU General Public License as published by
|
5025 |
|
|
+the Free Software Foundation; either version 2 of the License, or
|
5026 |
|
|
+(at your option) any later version.
|
5027 |
|
|
+
|
5028 |
|
|
+This program is distributed in the hope that it will be useful,
|
5029 |
|
|
+but WITHOUT ANY WARRANTY; without even the implied warranty of
|
5030 |
|
|
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
5031 |
|
|
+GNU General Public License for more details.
|
5032 |
|
|
+
|
5033 |
|
|
+You should have received a copy of the GNU General Public License
|
5034 |
|
|
+along with this program; if not, write to the Free Software
|
5035 |
|
|
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
5036 |
|
|
+
|
5037 |
|
|
+
|
5038 |
|
|
+/* INTRODUCTION
|
5039 |
|
|
+
|
5040 |
|
|
+ The ork1sim has various parameters, that are set in configuration files
|
5041 |
|
|
+ like this one. The user can switch between configurations at startup by
|
5042 |
|
|
+ specifying the required configuration file with the -f <filename.cfg> option.
|
5043 |
|
|
+ If no configuration file is specified or1ksim searches for the default
|
5044 |
|
|
+ configuration file sim.cfg. First it searches for './sim.cfg'. If this
|
5045 |
|
|
+ file is not found, it searches for '~/or1k/sim.cfg'. If this file is
|
5046 |
|
|
+ not found too, it reverts to the built-in default configuration.
|
5047 |
|
|
+
|
5048 |
|
|
+ NOTE: Users should not rely on the built-in configuration, since the
|
5049 |
|
|
+ default configuration may differ between version.
|
5050 |
|
|
+ Rather create a configuration file that sets all critical values.
|
5051 |
|
|
+
|
5052 |
|
|
+ This file may contain (standard C) comments only - no // support.
|
5053 |
|
|
+
|
5054 |
|
|
+ Configure files may be be included, using:
|
5055 |
|
|
+ include "file_name_to_include"
|
5056 |
|
|
+
|
5057 |
|
|
+ Like normal configuration files, the included file is divided into
|
5058 |
|
|
+ sections. Each section is described in detail also.
|
5059 |
|
|
+
|
5060 |
|
|
+ Some section have subsections. One example of such a subsection is:
|
5061 |
|
|
+
|
5062 |
|
|
+ device <index>
|
5063 |
|
|
+ instance specific parameters...
|
5064 |
|
|
+ enddevice
|
5065 |
|
|
+
|
5066 |
|
|
+ which creates a device instance.
|
5067 |
|
|
+*/
|
5068 |
|
|
+
|
5069 |
|
|
+
|
5070 |
|
|
+/* MEMORY SECTION
|
5071 |
|
|
+
|
5072 |
|
|
+ This section specifies how the memory is generated and the blocks
|
5073 |
|
|
+ it consists of.
|
5074 |
|
|
+
|
5075 |
|
|
+ type = random/unknown/pattern
|
5076 |
|
|
+ Specifies the initial memory values.
|
5077 |
|
|
+ 'random' generates random memory using seed 'random_seed'.
|
5078 |
|
|
+ 'pattern' fills memory with 'pattern'.
|
5079 |
|
|
+ 'unknown' does not specify how memory should be generated,
|
5080 |
|
|
+ leaving the memory in a undefined state. This is the fastest
|
5081 |
|
|
+ option.
|
5082 |
|
|
+
|
5083 |
|
|
+ random_seed = <value>
|
5084 |
|
|
+ random seed for randomizer, used if type = 'random'.
|
5085 |
|
|
+
|
5086 |
|
|
+ pattern = <value>
|
5087 |
|
|
+ pattern to fill memory, used if type = 'pattern'.
|
5088 |
|
|
+
|
5089 |
|
|
+ nmemories = <value>
|
5090 |
|
|
+ number of memory instances connected
|
5091 |
|
|
+
|
5092 |
|
|
+ baseaddr = <hex_value>
|
5093 |
|
|
+ memory start address
|
5094 |
|
|
+
|
5095 |
|
|
+ size = <hex_value>
|
5096 |
|
|
+ memory size
|
5097 |
|
|
+
|
5098 |
|
|
+ name = "<string>"
|
5099 |
|
|
+ memory block name
|
5100 |
|
|
+
|
5101 |
|
|
+ ce = <value>
|
5102 |
|
|
+ chip enable index of the memory instance
|
5103 |
|
|
+
|
5104 |
|
|
+ mc = <value>
|
5105 |
|
|
+ memory controller this memory is connected to
|
5106 |
|
|
+
|
5107 |
|
|
+ delayr = <value>
|
5108 |
|
|
+ cycles, required for read access, -1 if instance does not support reading
|
5109 |
|
|
+
|
5110 |
|
|
+ delayw = <value>
|
5111 |
|
|
+ cycles, required for write access, -1 if instance does not support writing
|
5112 |
|
|
+
|
5113 |
|
|
+ log = "<filename>"
|
5114 |
|
|
+ filename, where to log memory accesses to, no log, if log command is not specified
|
5115 |
|
|
+*/
|
5116 |
|
|
+
|
5117 |
|
|
+
|
5118 |
|
|
+section memory
|
5119 |
|
|
+ /*random_seed = 12345
|
5120 |
|
|
+ type = random*/
|
5121 |
|
|
+ pattern = 0x00
|
5122 |
|
|
+ type = unknown /* Fastest */
|
5123 |
|
|
+
|
5124 |
|
|
+ name = "FLASH"
|
5125 |
|
|
+ ce = 0
|
5126 |
|
|
+ mc = 0
|
5127 |
|
|
+ baseaddr = 0xf0000000
|
5128 |
|
|
+ size = 0x01000000
|
5129 |
|
|
+ delayr = 10
|
5130 |
|
|
+ delayw = -1
|
5131 |
|
|
+end
|
5132 |
|
|
+
|
5133 |
|
|
+section memory
|
5134 |
|
|
+ /*random_seed = 12345
|
5135 |
|
|
+ type = random*/
|
5136 |
|
|
+ pattern = 0x00
|
5137 |
|
|
+ type = unknown /* Fastest */
|
5138 |
|
|
+
|
5139 |
|
|
+ name = "RAM"
|
5140 |
|
|
+ ce = 1
|
5141 |
|
|
+ mc = 0
|
5142 |
|
|
+ baseaddr = 0x00000000
|
5143 |
|
|
+ size = 0x02000000
|
5144 |
|
|
+ delayr = 20
|
5145 |
|
|
+ delayw = 25
|
5146 |
|
|
+end
|
5147 |
|
|
+
|
5148 |
|
|
+section memory
|
5149 |
|
|
+ /*random_seed = 12345
|
5150 |
|
|
+ type = random*/
|
5151 |
|
|
+ pattern = 0x00
|
5152 |
|
|
+ type = unknown /* Fastest */
|
5153 |
|
|
+
|
5154 |
|
|
+ name = "SRAM"
|
5155 |
|
|
+ mc = 0
|
5156 |
|
|
+ ce = 2
|
5157 |
|
|
+ baseaddr = 0xa4000000
|
5158 |
|
|
+ size = 0x00100000
|
5159 |
|
|
+ delayr = 1
|
5160 |
|
|
+ delayw = 2
|
5161 |
|
|
+end
|
5162 |
|
|
+
|
5163 |
|
|
+
|
5164 |
|
|
+/* IMMU SECTION
|
5165 |
|
|
+
|
5166 |
|
|
+ This section configures the Instruction Memory Manangement Unit
|
5167 |
|
|
+
|
5168 |
|
|
+ enabled = 0/1
|
5169 |
|
|
+ '0': disabled
|
5170 |
|
|
+ '1': enabled
|
5171 |
|
|
+ (NOTE: UPR bit is set)
|
5172 |
|
|
+
|
5173 |
|
|
+ nsets = <value>
|
5174 |
|
|
+ number of ITLB sets; must be power of two
|
5175 |
|
|
+
|
5176 |
|
|
+ nways = <value>
|
5177 |
|
|
+ number of ITLB ways
|
5178 |
|
|
+
|
5179 |
|
|
+ pagesize = <value>
|
5180 |
|
|
+ instruction page size; must be power of two
|
5181 |
|
|
+
|
5182 |
|
|
+ entrysize = <value>
|
5183 |
|
|
+ instruction entry size in bytes
|
5184 |
|
|
+
|
5185 |
|
|
+ ustates = <value>
|
5186 |
|
|
+ number of ITLB usage states (2, 3, 4 etc., max is 4)
|
5187 |
|
|
+
|
5188 |
|
|
+ hitdelay = <value>
|
5189 |
|
|
+ number of cycles immu hit costs
|
5190 |
|
|
+
|
5191 |
|
|
+ missdelay = <value>
|
5192 |
|
|
+ number of cycles immu miss costs
|
5193 |
|
|
+*/
|
5194 |
|
|
+
|
5195 |
|
|
+section immu
|
5196 |
|
|
+ enabled = 1
|
5197 |
|
|
+ nsets = 64
|
5198 |
|
|
+ nways = 1
|
5199 |
|
|
+ pagesize = 8192
|
5200 |
|
|
+ hitdelay = 0
|
5201 |
|
|
+ missdelay = 0
|
5202 |
|
|
+end
|
5203 |
|
|
+
|
5204 |
|
|
+
|
5205 |
|
|
+/* DMMU SECTION
|
5206 |
|
|
+
|
5207 |
|
|
+ This section configures the Data Memory Manangement Unit
|
5208 |
|
|
+
|
5209 |
|
|
+ enabled = 0/1
|
5210 |
|
|
+ '0': disabled
|
5211 |
|
|
+ '1': enabled
|
5212 |
|
|
+ (NOTE: UPR bit is set)
|
5213 |
|
|
+
|
5214 |
|
|
+ nsets = <value>
|
5215 |
|
|
+ number of DTLB sets; must be power of two
|
5216 |
|
|
+
|
5217 |
|
|
+ nways = <value>
|
5218 |
|
|
+ number of DTLB ways
|
5219 |
|
|
+
|
5220 |
|
|
+ pagesize = <value>
|
5221 |
|
|
+ data page size; must be power of two
|
5222 |
|
|
+
|
5223 |
|
|
+ entrysize = <value>
|
5224 |
|
|
+ data entry size in bytes
|
5225 |
|
|
+
|
5226 |
|
|
+ ustates = <value>
|
5227 |
|
|
+ number of DTLB usage states (2, 3, 4 etc., max is 4)
|
5228 |
|
|
+
|
5229 |
|
|
+ hitdelay = <value>
|
5230 |
|
|
+ number of cycles dmmu hit costs
|
5231 |
|
|
+
|
5232 |
|
|
+ missdelay = <value>
|
5233 |
|
|
+ number of cycles dmmu miss costs
|
5234 |
|
|
+*/
|
5235 |
|
|
+
|
5236 |
|
|
+section dmmu
|
5237 |
|
|
+ enabled = 1
|
5238 |
|
|
+ nsets = 64
|
5239 |
|
|
+ nways = 1
|
5240 |
|
|
+ pagesize = 8192
|
5241 |
|
|
+ hitdelay = 0
|
5242 |
|
|
+ missdelay = 0
|
5243 |
|
|
+end
|
5244 |
|
|
+
|
5245 |
|
|
+
|
5246 |
|
|
+/* IC SECTION
|
5247 |
|
|
+
|
5248 |
|
|
+ This section configures the Instruction Cache
|
5249 |
|
|
+
|
5250 |
|
|
+ enabled = 0/1
|
5251 |
|
|
+ '0': disabled
|
5252 |
|
|
+ '1': enabled
|
5253 |
|
|
+ (NOTE: UPR bit is set)
|
5254 |
|
|
+
|
5255 |
|
|
+ nsets = <value>
|
5256 |
|
|
+ number of IC sets; must be power of two
|
5257 |
|
|
+
|
5258 |
|
|
+ nways = <value>
|
5259 |
|
|
+ number of IC ways
|
5260 |
|
|
+
|
5261 |
|
|
+ blocksize = <value>
|
5262 |
|
|
+ IC block size in bytes; must be power of two
|
5263 |
|
|
+
|
5264 |
|
|
+ ustates = <value>
|
5265 |
|
|
+ number of IC usage states (2, 3, 4 etc., max is 4)
|
5266 |
|
|
+
|
5267 |
|
|
+ hitdelay = <value>
|
5268 |
|
|
+ number of cycles ic hit costs
|
5269 |
|
|
+
|
5270 |
|
|
+ missdelay = <value>
|
5271 |
|
|
+ number of cycles ic miss costs
|
5272 |
|
|
+*/
|
5273 |
|
|
+
|
5274 |
|
|
+section ic
|
5275 |
|
|
+ enabled = 0
|
5276 |
|
|
+ nsets = 512
|
5277 |
|
|
+ nways = 1
|
5278 |
|
|
+ blocksize = 16
|
5279 |
|
|
+ hitdelay = 20
|
5280 |
|
|
+ missdelay = 20
|
5281 |
|
|
+end
|
5282 |
|
|
+
|
5283 |
|
|
+
|
5284 |
|
|
+/* DC SECTION
|
5285 |
|
|
+
|
5286 |
|
|
+ This section configures the Data Cache
|
5287 |
|
|
+
|
5288 |
|
|
+ enabled = 0/1
|
5289 |
|
|
+ '0': disabled
|
5290 |
|
|
+ '1': enabled
|
5291 |
|
|
+ (NOTE: UPR bit is set)
|
5292 |
|
|
+
|
5293 |
|
|
+ nsets = <value>
|
5294 |
|
|
+ number of DC sets; must be power of two
|
5295 |
|
|
+
|
5296 |
|
|
+ nways = <value>
|
5297 |
|
|
+ number of DC ways
|
5298 |
|
|
+
|
5299 |
|
|
+ blocksize = <value>
|
5300 |
|
|
+ DC block size in bytes; must be power of two
|
5301 |
|
|
+
|
5302 |
|
|
+ ustates = <value>
|
5303 |
|
|
+ number of DC usage states (2, 3, 4 etc., max is 4)
|
5304 |
|
|
+
|
5305 |
|
|
+ load_hitdelay = <value>
|
5306 |
|
|
+ number of cycles dc load hit costs
|
5307 |
|
|
+
|
5308 |
|
|
+ load_missdelay = <value>
|
5309 |
|
|
+ number of cycles dc load miss costs
|
5310 |
|
|
+
|
5311 |
|
|
+ store_hitdelay = <value>
|
5312 |
|
|
+ number of cycles dc load hit costs
|
5313 |
|
|
+
|
5314 |
|
|
+ store_missdelay = <value>
|
5315 |
|
|
+ number of cycles dc load miss costs
|
5316 |
|
|
+*/
|
5317 |
|
|
+
|
5318 |
|
|
+section dc
|
5319 |
|
|
+ enabled = 0
|
5320 |
|
|
+ nsets = 512
|
5321 |
|
|
+ nways = 1
|
5322 |
|
|
+ blocksize = 16
|
5323 |
|
|
+ load_hitdelay = 20
|
5324 |
|
|
+ load_missdelay = 20
|
5325 |
|
|
+ store_hitdelay = 20
|
5326 |
|
|
+ store_missdelay = 20
|
5327 |
|
|
+end
|
5328 |
|
|
+
|
5329 |
|
|
+
|
5330 |
|
|
+/* SIM SECTION
|
5331 |
|
|
+
|
5332 |
|
|
+ This section specifies how or1ksim should behave.
|
5333 |
|
|
+
|
5334 |
|
|
+ verbose = 0/1
|
5335 |
|
|
+ '0': don't print extra messages
|
5336 |
|
|
+ '1': print extra messages
|
5337 |
|
|
+
|
5338 |
|
|
+ debug = 0-9
|
5339 |
|
|
+ 0 : no debug messages
|
5340 |
|
|
+ 1-9: debug message level.
|
5341 |
|
|
+ higher numbers produce more messages
|
5342 |
|
|
+
|
5343 |
|
|
+ profile = 0/1
|
5344 |
|
|
+ '0': don't generate profiling file 'sim.profile'
|
5345 |
|
|
+ '1': don't generate profiling file 'sim.profile'
|
5346 |
|
|
+
|
5347 |
|
|
+ prof_fn = "<filename>"
|
5348 |
|
|
+ optional filename for the profiling file.
|
5349 |
|
|
+ valid only if 'profile' is set
|
5350 |
|
|
+
|
5351 |
|
|
+ mprofile = 0/1
|
5352 |
|
|
+ '0': don't generate memory profiling file 'sim.mprofile'
|
5353 |
|
|
+ '1': generate memory profiling file 'sim.mprofile'
|
5354 |
|
|
+
|
5355 |
|
|
+ mprof_fn = "<filename>"
|
5356 |
|
|
+ optional filename for the memory profiling file.
|
5357 |
|
|
+ valid only if 'mprofile' is set
|
5358 |
|
|
+
|
5359 |
|
|
+ history = 0/1
|
5360 |
|
|
+ '0': don't track execution flow
|
5361 |
|
|
+ '1': track execution flow
|
5362 |
|
|
+ Execution flow can be tracked for the simulator's
|
5363 |
|
|
+ 'hist' command. Useful for back-trace debugging.
|
5364 |
|
|
+
|
5365 |
|
|
+ iprompt = 0/1
|
5366 |
|
|
+ '0': start in <not interactive prompt> (so what do we start in ???)
|
5367 |
|
|
+ '1': start in interactive prompt.
|
5368 |
|
|
+
|
5369 |
|
|
+ exe_log = 0/1
|
5370 |
|
|
+ '0': don't generate execution log.
|
5371 |
|
|
+ '1': generate execution log.
|
5372 |
|
|
+
|
5373 |
|
|
+ exe_log = default/hardware/simple/software
|
5374 |
|
|
+ type of execution log, default is used when not specified
|
5375 |
|
|
+
|
5376 |
|
|
+ exe_log_start = <value>
|
5377 |
|
|
+ index of first instruction to start logging, default = 0
|
5378 |
|
|
+
|
5379 |
|
|
+ exe_log_end = <value>
|
5380 |
|
|
+ index of last instruction to end logging; not limited, if omitted
|
5381 |
|
|
+
|
5382 |
|
|
+ exe_log_marker = <value>
|
5383 |
|
|
+ <value> specifies number of instructions before horizontal marker is
|
5384 |
|
|
+ printed; if zero, markers are disabled (default)
|
5385 |
|
|
+
|
5386 |
|
|
+ exe_log_fn = "<filename>"
|
5387 |
|
|
+ filename for the exection log file.
|
5388 |
|
|
+ valid only if 'exe_log' is set
|
5389 |
|
|
+
|
5390 |
|
|
+ clkcycle = <value>[ps|ns|us|ms]
|
5391 |
|
|
+ specifies time measurement for one cycle
|
5392 |
|
|
+*/
|
5393 |
|
|
+
|
5394 |
|
|
+section sim
|
5395 |
|
|
+ verbose = 1
|
5396 |
|
|
+ debug = 0
|
5397 |
|
|
+ profile = 0
|
5398 |
|
|
+ history = 0
|
5399 |
|
|
+
|
5400 |
|
|
+ clkcycle = 10ns
|
5401 |
|
|
+end
|
5402 |
|
|
+
|
5403 |
|
|
+
|
5404 |
|
|
+/* SECTION VAPI
|
5405 |
|
|
+
|
5406 |
|
|
+ This section configures the Verification API, used for Advanced
|
5407 |
|
|
+ Core Verification.
|
5408 |
|
|
+
|
5409 |
|
|
+ enabled = 0/1
|
5410 |
|
|
+ '0': disbable VAPI server
|
5411 |
|
|
+ '1': enable/start VAPI server
|
5412 |
|
|
+
|
5413 |
|
|
+ server_port = <value>
|
5414 |
|
|
+ TCP/IP port to start VAPI server on
|
5415 |
|
|
+
|
5416 |
|
|
+ log_enabled = 0/1
|
5417 |
|
|
+ '0': disable VAPI requests logging
|
5418 |
|
|
+ '1': enable VAPI requests logging
|
5419 |
|
|
+
|
5420 |
|
|
+ hide_device_id = 0/1
|
5421 |
|
|
+ '0': don't log device id (for compatability with old version)
|
5422 |
|
|
+ '1': log device id
|
5423 |
|
|
+
|
5424 |
|
|
+
|
5425 |
|
|
+ vapi_fn = <filename>
|
5426 |
|
|
+ filename for the log file.
|
5427 |
|
|
+ valid only if log_enabled is set
|
5428 |
|
|
+*/
|
5429 |
|
|
+
|
5430 |
|
|
+section VAPI
|
5431 |
|
|
+ enabled = 0
|
5432 |
|
|
+ server_port = 9998
|
5433 |
|
|
+ log_enabled = 0
|
5434 |
|
|
+ vapi_log_fn = "vapi.log"
|
5435 |
|
|
+end
|
5436 |
|
|
+
|
5437 |
|
|
+
|
5438 |
|
|
+/* CPU SECTION
|
5439 |
|
|
+
|
5440 |
|
|
+ This section specifies various CPU parameters.
|
5441 |
|
|
+
|
5442 |
|
|
+ ver = <value>
|
5443 |
|
|
+ rev = <value>
|
5444 |
|
|
+ specifies version and revision of the CPU used
|
5445 |
|
|
+
|
5446 |
|
|
+ upr = <value>
|
5447 |
|
|
+ changes the upr register
|
5448 |
|
|
+
|
5449 |
|
|
+ sr = <value>
|
5450 |
|
|
+ sets the initial Supervision Register value
|
5451 |
|
|
+
|
5452 |
|
|
+ superscalar = 0/1
|
5453 |
|
|
+ '0': CPU is scalar
|
5454 |
|
|
+ '1': CPU is superscalar
|
5455 |
|
|
+ (modify cpu/or32/execute.c to tune superscalar model)
|
5456 |
|
|
+
|
5457 |
|
|
+ hazards = 0/1
|
5458 |
|
|
+ '0': don't track data hazards in superscalar CPU
|
5459 |
|
|
+ '1': track data hazards in superscalar CPU
|
5460 |
|
|
+ If tracked, data hazards can be displayed using the
|
5461 |
|
|
+ simulator's 'r' command.
|
5462 |
|
|
+
|
5463 |
|
|
+ dependstats = 0/1
|
5464 |
|
|
+ '0': don't calculate inter-instruction dependencies.
|
5465 |
|
|
+ '1': calculate inter-instruction dependencies.
|
5466 |
|
|
+ If calculated, inter-instruction dependencies can be
|
5467 |
|
|
+ displayed using the simulator's 'stat' command.
|
5468 |
|
|
+
|
5469 |
|
|
+ sbuf_len = <value>
|
5470 |
|
|
+ length of store buffer (<= 256), 0 = disabled
|
5471 |
|
|
+*/
|
5472 |
|
|
+
|
5473 |
|
|
+section cpu
|
5474 |
|
|
+ ver = 0x12
|
5475 |
|
|
+ cfg = 0x00
|
5476 |
|
|
+ rev = 0x01
|
5477 |
|
|
+ /* upr = */
|
5478 |
|
|
+ superscalar = 0
|
5479 |
|
|
+ hazards = 0
|
5480 |
|
|
+ dependstats = 0
|
5481 |
|
|
+ sbuf_len = 0
|
5482 |
|
|
+ hardfloat = 1
|
5483 |
|
|
+end
|
5484 |
|
|
+
|
5485 |
|
|
+
|
5486 |
|
|
+/* PM SECTION
|
5487 |
|
|
+
|
5488 |
|
|
+ This section specifies Power Management parameters
|
5489 |
|
|
+
|
5490 |
|
|
+ enabled = 0/1
|
5491 |
|
|
+ '0': disable power management
|
5492 |
|
|
+ '1': enable power management
|
5493 |
|
|
+*/
|
5494 |
|
|
+
|
5495 |
|
|
+section pm
|
5496 |
|
|
+ enabled = 0
|
5497 |
|
|
+end
|
5498 |
|
|
+
|
5499 |
|
|
+
|
5500 |
|
|
+/* BPB SECTION
|
5501 |
|
|
+
|
5502 |
|
|
+ This section specifies how branch prediction should behave.
|
5503 |
|
|
+
|
5504 |
|
|
+ enabled = 0/1
|
5505 |
|
|
+ '0': disable branch prediction
|
5506 |
|
|
+ '1': enable branch prediction
|
5507 |
|
|
+
|
5508 |
|
|
+ btic = 0/1
|
5509 |
|
|
+ '0': disable branch target instruction cache model
|
5510 |
|
|
+ '1': enable branch target instruction cache model
|
5511 |
|
|
+
|
5512 |
|
|
+ sbp_bf_fwd = 0/1
|
5513 |
|
|
+ Static branch prediction for 'l.bf'
|
5514 |
|
|
+ '0': don't use forward prediction
|
5515 |
|
|
+ '1': use forward prediction
|
5516 |
|
|
+
|
5517 |
|
|
+ sbp_bnf_fwd = 0/1
|
5518 |
|
|
+ Static branch prediction for 'l.bnf'
|
5519 |
|
|
+ '0': don't use forward prediction
|
5520 |
|
|
+ '1': use forward prediction
|
5521 |
|
|
+
|
5522 |
|
|
+ hitdelay = <value>
|
5523 |
|
|
+ number of cycles bpb hit costs
|
5524 |
|
|
+
|
5525 |
|
|
+ missdelay = <value>
|
5526 |
|
|
+ number of cycles bpb miss costs
|
5527 |
|
|
+*/
|
5528 |
|
|
+
|
5529 |
|
|
+section bpb
|
5530 |
|
|
+ enabled = 0
|
5531 |
|
|
+ btic = 0
|
5532 |
|
|
+ sbp_bf_fwd = 0
|
5533 |
|
|
+ sbp_bnf_fwd = 0
|
5534 |
|
|
+ hitdelay = 0
|
5535 |
|
|
+ missdelay = 0
|
5536 |
|
|
+end
|
5537 |
|
|
+
|
5538 |
|
|
+
|
5539 |
|
|
+/* DEBUG SECTION
|
5540 |
|
|
+
|
5541 |
|
|
+ This sections specifies how the debug unit should behave.
|
5542 |
|
|
+
|
5543 |
|
|
+ enabled = 0/1
|
5544 |
|
|
+ '0': disable debug unit
|
5545 |
|
|
+ '1': enable debug unit
|
5546 |
|
|
+
|
5547 |
|
|
+ gdb_enabled = 0/1
|
5548 |
|
|
+ '0': don't start gdb server
|
5549 |
|
|
+ '1': start gdb server at port 'server_port'
|
5550 |
|
|
+
|
5551 |
|
|
+ server_port = <value>
|
5552 |
|
|
+ TCP/IP port to start gdb server on
|
5553 |
|
|
+ valid only if gdb_enabled is set
|
5554 |
|
|
+
|
5555 |
|
|
+ vapi_id = <hex_value>
|
5556 |
|
|
+ Used to create "fake" vapi log file containing the JTAG proxy messages.
|
5557 |
|
|
+*/
|
5558 |
|
|
+section debug
|
5559 |
|
|
+ enabled = 1
|
5560 |
|
|
+ rsp_enabled = 1
|
5561 |
|
|
+ rsp_port = 5554
|
5562 |
|
|
+ /*server_port = 9999*/
|
5563 |
|
|
+end
|
5564 |
|
|
+
|
5565 |
|
|
+
|
5566 |
|
|
+/* MC SECTION
|
5567 |
|
|
+
|
5568 |
|
|
+ This section configures the memory controller
|
5569 |
|
|
+
|
5570 |
|
|
+ enabled = 0/1
|
5571 |
|
|
+ '0': disable memory controller
|
5572 |
|
|
+ '1': enable memory controller
|
5573 |
|
|
+
|
5574 |
|
|
+ baseaddr = <hex_value>
|
5575 |
|
|
+ address of first MC register
|
5576 |
|
|
+
|
5577 |
|
|
+ POC = <hex_value>
|
5578 |
|
|
+ Power On Configuration register
|
5579 |
|
|
+
|
5580 |
|
|
+ index = <value>
|
5581 |
|
|
+ Index of this memory controller amongst all the memory controllers
|
5582 |
|
|
+*/
|
5583 |
|
|
+
|
5584 |
|
|
+section mc
|
5585 |
|
|
+ enabled = 0
|
5586 |
|
|
+ baseaddr = 0x93000000
|
5587 |
|
|
+ POC = 0x00000008 /* Power on configuration register */
|
5588 |
|
|
+ index = 0
|
5589 |
|
|
+end
|
5590 |
|
|
+
|
5591 |
|
|
+
|
5592 |
|
|
+/* UART SECTION
|
5593 |
|
|
+
|
5594 |
|
|
+ This section configures the UARTs
|
5595 |
|
|
+
|
5596 |
|
|
+ enabled = <0|1>
|
5597 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
5598 |
|
|
+
|
5599 |
|
|
+ baseaddr = <hex_value>
|
5600 |
|
|
+ address of first UART register for this device
|
5601 |
|
|
+
|
5602 |
|
|
+
|
5603 |
|
|
+ channel = <channeltype>:<args>
|
5604 |
|
|
+
|
5605 |
|
|
+ The channel parameter indicates the source of received UART characters
|
5606 |
|
|
+ and the sink for transmitted UART characters.
|
5607 |
|
|
+
|
5608 |
|
|
+ The <channeltype> can be either "file", "xterm", "tcp", "fd", or "tty"
|
5609 |
|
|
+ (without quotes).
|
5610 |
|
|
+
|
5611 |
|
|
+ A) To send/receive characters from a pair of files, use a file
|
5612 |
|
|
+ channel:
|
5613 |
|
|
+
|
5614 |
|
|
+ channel=file:<rxfile>,<txfile>
|
5615 |
|
|
+
|
5616 |
|
|
+ B) To create an interactive terminal window, use an xterm channel:
|
5617 |
|
|
+
|
5618 |
|
|
+ channel=xterm:[<xterm_arg>]*
|
5619 |
|
|
+
|
5620 |
|
|
+ C) To create a bidirectional tcp socket which one could, for example,
|
5621 |
|
|
+ access via telnet, use a tcp channel:
|
5622 |
|
|
+
|
5623 |
|
|
+ channel=tcp:<port number>
|
5624 |
|
|
+
|
5625 |
|
|
+ D) To cause the UART to read/write from existing numeric file
|
5626 |
|
|
+ descriptors, use an fd channel:
|
5627 |
|
|
+
|
5628 |
|
|
+ channel=fd:<rx file descriptor num>,<tx file descriptor num>
|
5629 |
|
|
+
|
5630 |
|
|
+ E) To connect the UART to a physical serial port, create a tty
|
5631 |
|
|
+ channel:
|
5632 |
|
|
+
|
5633 |
|
|
+ channel=tty:device=/dev/ttyS0,baud=9600
|
5634 |
|
|
+
|
5635 |
|
|
+ irq = <value>
|
5636 |
|
|
+ irq number for this device
|
5637 |
|
|
+
|
5638 |
|
|
+ 16550 = 0/1
|
5639 |
|
|
+ '0': this device is a UART16450
|
5640 |
|
|
+ '1': this device is a UART16550
|
5641 |
|
|
+
|
5642 |
|
|
+ jitter = <value>
|
5643 |
|
|
+ in msecs... time to block, -1 to disable it
|
5644 |
|
|
+
|
5645 |
|
|
+ vapi_id = <hex_value>
|
5646 |
|
|
+ VAPI id of this instance
|
5647 |
|
|
+*/
|
5648 |
|
|
+
|
5649 |
|
|
+section uart
|
5650 |
|
|
+ enabled = 1
|
5651 |
|
|
+ baseaddr = 0x90000000
|
5652 |
|
|
+ irq = 2
|
5653 |
|
|
+ channel = "file:uart0.rx,uart0.tx"
|
5654 |
|
|
+ /* channel = "tcp:10084" */
|
5655 |
|
|
+ /* channel = "xterm:" */
|
5656 |
|
|
+ jitter = -1 /* async behaviour */
|
5657 |
|
|
+ 16550 = 1
|
5658 |
|
|
+end
|
5659 |
|
|
+
|
5660 |
|
|
+
|
5661 |
|
|
+/* DMA SECTION
|
5662 |
|
|
+
|
5663 |
|
|
+ This section configures the DMAs
|
5664 |
|
|
+
|
5665 |
|
|
+ enabled = <0|1>
|
5666 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
5667 |
|
|
+
|
5668 |
|
|
+ baseaddr = <hex_value>
|
5669 |
|
|
+ address of first DMA register for this device
|
5670 |
|
|
+
|
5671 |
|
|
+ irq = <value>
|
5672 |
|
|
+ irq number for this device
|
5673 |
|
|
+
|
5674 |
|
|
+ vapi_id = <hex_value>
|
5675 |
|
|
+ VAPI id of this instance
|
5676 |
|
|
+*/
|
5677 |
|
|
+
|
5678 |
|
|
+section dma
|
5679 |
|
|
+ enabled = 1
|
5680 |
|
|
+ baseaddr = 0x9a000000
|
5681 |
|
|
+ irq = 11
|
5682 |
|
|
+end
|
5683 |
|
|
+
|
5684 |
|
|
+
|
5685 |
|
|
+/* ETHERNET SECTION
|
5686 |
|
|
+
|
5687 |
|
|
+ This section configures the ETHERNETs
|
5688 |
|
|
+
|
5689 |
|
|
+ enabled = <0|1>
|
5690 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
5691 |
|
|
+
|
5692 |
|
|
+ baseaddr = <hex_value>
|
5693 |
|
|
+ address of first ethernet register for this device
|
5694 |
|
|
+
|
5695 |
|
|
+ dma = <value>
|
5696 |
|
|
+ which controller is this ethernet "connected" to
|
5697 |
|
|
+
|
5698 |
|
|
+ irq = <value>
|
5699 |
|
|
+ ethernet mac IRQ level
|
5700 |
|
|
+
|
5701 |
|
|
+ rtx_type = <value>
|
5702 |
|
|
+ use 0 - file interface, 1 - socket interface
|
5703 |
|
|
+
|
5704 |
|
|
+ rx_channel = <value>
|
5705 |
|
|
+ DMA channel used for RX
|
5706 |
|
|
+
|
5707 |
|
|
+ tx_channel = <value>
|
5708 |
|
|
+ DMA channel used for TX
|
5709 |
|
|
+
|
5710 |
|
|
+ rxfile = "<filename>"
|
5711 |
|
|
+ filename, where to read data from
|
5712 |
|
|
+
|
5713 |
|
|
+ txfile = "<filename>"
|
5714 |
|
|
+ filename, where to write data to
|
5715 |
|
|
+
|
5716 |
|
|
+ sockif = "<ifacename>"
|
5717 |
|
|
+ interface name of ethernet socket
|
5718 |
|
|
+
|
5719 |
|
|
+ vapi_id = <hex_value>
|
5720 |
|
|
+ VAPI id of this instance
|
5721 |
|
|
+*/
|
5722 |
|
|
+
|
5723 |
|
|
+section ethernet
|
5724 |
|
|
+ enabled = 0
|
5725 |
|
|
+ baseaddr = 0x92000000
|
5726 |
|
|
+ /* dma = 0 */
|
5727 |
|
|
+ irq = 4
|
5728 |
|
|
+ rtx_type = 0
|
5729 |
|
|
+ /* tx_channel = 0 */
|
5730 |
|
|
+ /* rx_channel = 1 */
|
5731 |
|
|
+ /*rxfile = "eth0.rx"*/
|
5732 |
|
|
+ txfile = "eth0.tx"
|
5733 |
|
|
+ sockif = "eth0"
|
5734 |
|
|
+end
|
5735 |
|
|
+
|
5736 |
|
|
+
|
5737 |
|
|
+/* GPIO SECTION
|
5738 |
|
|
+
|
5739 |
|
|
+ This section configures the GPIOs
|
5740 |
|
|
+
|
5741 |
|
|
+ enabled = <0|1>
|
5742 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
5743 |
|
|
+
|
5744 |
|
|
+ baseaddr = <hex_value>
|
5745 |
|
|
+ address of first GPIO register for this device
|
5746 |
|
|
+
|
5747 |
|
|
+ irq = <value>
|
5748 |
|
|
+ irq number for this device
|
5749 |
|
|
+
|
5750 |
|
|
+ base_vapi_id = <hex_value>
|
5751 |
|
|
+ first VAPI id of this instance
|
5752 |
|
|
+ GPIO uses 8 consecutive VAPI IDs
|
5753 |
|
|
+*/
|
5754 |
|
|
+
|
5755 |
|
|
+section gpio
|
5756 |
|
|
+ enabled = 0
|
5757 |
|
|
+ baseaddr = 0x91000000
|
5758 |
|
|
+ irq = 3
|
5759 |
|
|
+ base_vapi_id = 0x0200
|
5760 |
|
|
+end
|
5761 |
|
|
+
|
5762 |
|
|
+/* VGA SECTION
|
5763 |
|
|
+
|
5764 |
|
|
+ This section configures the VGA/LCD controller
|
5765 |
|
|
+
|
5766 |
|
|
+ enabled = <0|1>
|
5767 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
5768 |
|
|
+
|
5769 |
|
|
+ baseaddr = <hex_value>
|
5770 |
|
|
+ address of first VGA register
|
5771 |
|
|
+
|
5772 |
|
|
+ irq = <value>
|
5773 |
|
|
+ irq number for this device
|
5774 |
|
|
+
|
5775 |
|
|
+ refresh_rate = <value>
|
5776 |
|
|
+ number of cycles between screen dumps
|
5777 |
|
|
+
|
5778 |
|
|
+ filename = "<filename>"
|
5779 |
|
|
+ template name for generated names (e.g. "primary" produces "primary0023.bmp")
|
5780 |
|
|
+*/
|
5781 |
|
|
+
|
5782 |
|
|
+section vga
|
5783 |
|
|
+ enabled = 1
|
5784 |
|
|
+ baseaddr = 0x97100000
|
5785 |
|
|
+ irq = 8
|
5786 |
|
|
+ refresh_rate = 100000
|
5787 |
|
|
+ filename = "primary"
|
5788 |
|
|
+end
|
5789 |
|
|
+
|
5790 |
|
|
+
|
5791 |
|
|
+/* TICK TIMER SECTION
|
5792 |
|
|
+
|
5793 |
|
|
+ This section configures tick timer
|
5794 |
|
|
+
|
5795 |
|
|
+ enabled = 0/1
|
5796 |
|
|
+ whether tick timer is enabled
|
5797 |
|
|
+*/
|
5798 |
|
|
+
|
5799 |
|
|
+section pic
|
5800 |
|
|
+ enabled = 1
|
5801 |
|
|
+ edge_trigger = 1
|
5802 |
|
|
+end
|
5803 |
|
|
+
|
5804 |
|
|
+/* FB SECTION
|
5805 |
|
|
+
|
5806 |
|
|
+ This section configures the frame buffer
|
5807 |
|
|
+
|
5808 |
|
|
+ enabled = <0|1>
|
5809 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
5810 |
|
|
+
|
5811 |
|
|
+ baseaddr = <hex_value>
|
5812 |
|
|
+ base address of frame buffer
|
5813 |
|
|
+
|
5814 |
|
|
+ paladdr = <hex_value>
|
5815 |
|
|
+ base address of first palette entry
|
5816 |
|
|
+
|
5817 |
|
|
+ refresh_rate = <value>
|
5818 |
|
|
+ number of cycles between screen dumps
|
5819 |
|
|
+
|
5820 |
|
|
+ filename = "<filename>"
|
5821 |
|
|
+ template name for generated names (e.g. "primary" produces "primary0023.bmp")
|
5822 |
|
|
+*/
|
5823 |
|
|
+
|
5824 |
|
|
+section fb
|
5825 |
|
|
+ enabled = 1
|
5826 |
|
|
+ baseaddr = 0x97000000
|
5827 |
|
|
+ refresh_rate = 1000000
|
5828 |
|
|
+ filename = "primary"
|
5829 |
|
|
+end
|
5830 |
|
|
+
|
5831 |
|
|
+
|
5832 |
|
|
+/* KBD SECTION
|
5833 |
|
|
+
|
5834 |
|
|
+ This section configures the PS/2 compatible keyboard
|
5835 |
|
|
+
|
5836 |
|
|
+ baseaddr = <hex_value>
|
5837 |
|
|
+ base address of the keyboard device
|
5838 |
|
|
+
|
5839 |
|
|
+ rxfile = "<filename>"
|
5840 |
|
|
+ filename, where to read data from
|
5841 |
|
|
+*/
|
5842 |
|
|
+
|
5843 |
|
|
+section kbd
|
5844 |
|
|
+ enabled = 1
|
5845 |
|
|
+ irq = 5
|
5846 |
|
|
+ baseaddr = 0x94000000
|
5847 |
|
|
+ rxfile = "kbd.rx"
|
5848 |
|
|
+end
|
5849 |
|
|
+
|
5850 |
|
|
+
|
5851 |
|
|
+/* ATA SECTION
|
5852 |
|
|
+
|
5853 |
|
|
+ This section configures the ATA/ATAPI host controller
|
5854 |
|
|
+
|
5855 |
|
|
+ baseaddr = <hex_value>
|
5856 |
|
|
+ address of first ATA register
|
5857 |
|
|
+
|
5858 |
|
|
+ enabled = <0|1>
|
5859 |
|
|
+ Enable/disable the peripheral. By default if it is enabled.
|
5860 |
|
|
+
|
5861 |
|
|
+ irq = <value>
|
5862 |
|
|
+ irq number for this device
|
5863 |
|
|
+
|
5864 |
|
|
+ debug = <value>
|
5865 |
|
|
+ debug level for ata models.
|
5866 |
|
|
+ 0: no debug messages
|
5867 |
|
|
+ 1: verbose messages
|
5868 |
|
|
+ 3: normal messages (more messages than verbose)
|
5869 |
|
|
+ 5: debug messages (normal debug messages)
|
5870 |
|
|
+ 7: flow control messages (debug statemachine flows)
|
5871 |
|
|
+ 9: low priority message (display everything the code does)
|
5872 |
|
|
+
|
5873 |
|
|
+ dev_type0/1 = <value>
|
5874 |
|
|
+ ata device 0 type
|
5875 |
|
|
+ 0: NO_CONNeCT: none (not connected)
|
5876 |
|
|
+ 1: FILE : simulated harddisk
|
5877 |
|
|
+ 2: LOCAL : local system harddisk
|
5878 |
|
|
+
|
5879 |
|
|
+ dev_file0/1 = "<filename>"
|
5880 |
|
|
+ filename for simulated ATA device
|
5881 |
|
|
+ valid only if dev_type0 == 1
|
5882 |
|
|
+
|
5883 |
|
|
+ dev_size0/1 = <value>
|
5884 |
|
|
+ size of simulated hard-disk (in MBytes)
|
5885 |
|
|
+ valid only if dev_type0 == 1
|
5886 |
|
|
+
|
5887 |
|
|
+ dev_packet0/1 = <value>
|
5888 |
|
|
+ 0: simulated ATA device does NOT implement PACKET command feature set
|
5889 |
|
|
+ 1: simulated ATA device does implement PACKET command feature set
|
5890 |
|
|
+
|
5891 |
|
|
+ FIXME: irq number
|
5892 |
|
|
+*/
|
5893 |
|
|
+
|
5894 |
|
|
+section ata
|
5895 |
|
|
+ enabled = 0
|
5896 |
|
|
+ baseaddr = 0x9e000000
|
5897 |
|
|
+ irq = 15
|
5898 |
|
|
+
|
5899 |
|
|
+end
|
5900 |
|
|
+
|
5901 |
|
|
+
|
5902 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/x264.c x264-or/x264.c
|
5903 |
|
|
--- x264/x264.c 2009-10-25 17:41:22.000000000 +0100
|
5904 |
|
|
+++ x264-or/x264.c 2009-11-15 17:35:30.000000000 +0100
|
5905 |
|
|
@@ -40,6 +40,8 @@
|
5906 |
|
|
#define SetConsoleTitle(t)
|
5907 |
|
|
#endif
|
5908 |
|
|
|
5909 |
|
|
+//#include "uart.h"
|
5910 |
|
|
+
|
5911 |
|
|
uint8_t *mux_buffer = NULL;
|
5912 |
|
|
int mux_buffer_size = 0;
|
5913 |
|
|
|
5914 |
|
|
@@ -54,11 +56,11 @@
|
5915 |
|
|
}
|
5916 |
|
|
|
5917 |
|
|
typedef struct {
|
5918 |
|
|
- int b_progress;
|
5919 |
|
|
- int i_seek;
|
5920 |
|
|
- hnd_t hin;
|
5921 |
|
|
- hnd_t hout;
|
5922 |
|
|
- FILE *qpfile;
|
5923 |
|
|
+ int b_progress;
|
5924 |
|
|
+ int i_seek;
|
5925 |
|
|
+ hnd_t hin; /* hnd_t is a void* */
|
5926 |
|
|
+ hnd_t hout;
|
5927 |
|
|
+ FILE *qpfile;
|
5928 |
|
|
} cli_opt_t;
|
5929 |
|
|
|
5930 |
|
|
/* input file operation function pointers */
|
5931 |
|
|
@@ -78,15 +80,28 @@
|
5932 |
|
|
static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt );
|
5933 |
|
|
static int Encode( x264_param_t *param, cli_opt_t *opt );
|
5934 |
|
|
|
5935 |
|
|
-
|
5936 |
|
|
+int yuv_data_size;
|
5937 |
|
|
/****************************************************************************
|
5938 |
|
|
* main:
|
5939 |
|
|
****************************************************************************/
|
5940 |
|
|
int main( int argc, char **argv )
|
5941 |
|
|
{
|
5942 |
|
|
- x264_param_t param;
|
5943 |
|
|
- cli_opt_t opt;
|
5944 |
|
|
- int ret;
|
5945 |
|
|
+ char* new_argv ="./x264 --profile=baseline";
|
5946 |
|
|
+ argc = 2;
|
5947 |
|
|
+
|
5948 |
|
|
+ x264_param_t param;
|
5949 |
|
|
+ cli_opt_t opt;
|
5950 |
|
|
+ int ret;
|
5951 |
|
|
+
|
5952 |
|
|
+ //uart_init() ;
|
5953 |
|
|
+
|
5954 |
|
|
+ extern int _end; // start of free memory
|
5955 |
|
|
+ extern int _stack; // end of free memory
|
5956 |
|
|
+
|
5957 |
|
|
+ V(fprintf( stderr, "start of heap at 0x%.8x, size of heap: %d bytes\n",
|
5958 |
|
|
+ (unsigned int) &_end, (unsigned int) ((unsigned int) &_stack) - ((unsigned int) &_end)));
|
5959 |
|
|
+
|
5960 |
|
|
+ //fprintf(stderr,"start\n");
|
5961 |
|
|
|
5962 |
|
|
#ifdef PTW32_STATIC_LIB
|
5963 |
|
|
pthread_win32_process_attach_np();
|
5964 |
|
|
@@ -100,14 +115,90 @@
|
5965 |
|
|
|
5966 |
|
|
x264_param_default( ¶m );
|
5967 |
|
|
|
5968 |
|
|
- /* Parse command line */
|
5969 |
|
|
- if( Parse( argc, argv, ¶m, &opt ) < 0 )
|
5970 |
|
|
- return -1;
|
5971 |
|
|
+ // Baseline parameters
|
5972 |
|
|
+ param.analyse.b_transform_8x8 = 0;
|
5973 |
|
|
+ param.b_cabac = 0;
|
5974 |
|
|
+ param.i_cqm_preset = X264_CQM_FLAT;
|
5975 |
|
|
+ param.i_bframe = 0;
|
5976 |
|
|
+ /*
|
5977 |
|
|
+ // Ultrafast preset
|
5978 |
|
|
+ param.i_frame_reference = 1;
|
5979 |
|
|
+ param.i_scenecut_threshold = 0;
|
5980 |
|
|
+ param.b_deblocking_filter = 0;
|
5981 |
|
|
+ param.b_cabac = 0;
|
5982 |
|
|
+ param.i_bframe = 0;
|
5983 |
|
|
+ param.analyse.intra = 0;
|
5984 |
|
|
+ param.analyse.inter = 0;
|
5985 |
|
|
+ param.analyse.b_transform_8x8 = 0;
|
5986 |
|
|
+ param.analyse.i_me_method = X264_ME_DIA;
|
5987 |
|
|
+ param.analyse.i_subpel_refine = 0;
|
5988 |
|
|
+ param.rc.i_aq_mode = 0;
|
5989 |
|
|
+ param.analyse.b_mixed_references = 0;
|
5990 |
|
|
+ param.analyse.i_trellis = 0;
|
5991 |
|
|
+ param.i_bframe_adaptive = X264_B_ADAPT_NONE;
|
5992 |
|
|
+ param.rc.b_mb_tree = 0;
|
5993 |
|
|
+ */
|
5994 |
|
|
+ // Fast preset, standard
|
5995 |
|
|
+ /*
|
5996 |
|
|
+ param.i_frame_reference = 2;
|
5997 |
|
|
+ param.analyse.i_subpel_refine = 6;
|
5998 |
|
|
+ param.rc.i_lookahead = 30;
|
5999 |
|
|
+ */
|
6000 |
|
|
+ // Fast preset, but with 0 lookahead
|
6001 |
|
|
+ param.i_frame_reference = 2;
|
6002 |
|
|
+ param.analyse.i_subpel_refine = 6;
|
6003 |
|
|
+ param.rc.i_lookahead = 0;
|
6004 |
|
|
+
|
6005 |
|
|
+ // Verbose (info per frame encoded)
|
6006 |
|
|
+ param.i_log_level = X264_LOG_DEBUG;
|
6007 |
|
|
+
|
6008 |
|
|
+ // Set a bitrate
|
6009 |
|
|
+ param.rc.i_bitrate = 500; // kbps
|
6010 |
|
|
+ param.rc.i_rc_method = X264_RC_ABR;
|
6011 |
|
|
+
|
6012 |
|
|
+ // A smaller range of QP (qp_max - qp_min) means less startup time for computing motion vectors costs (not sure exactly how this is done) --jb
|
6013 |
|
|
+ // Defaults here were i_qp_min = 10, i_qp_max = 51
|
6014 |
|
|
+ param.rc.i_qp_min = 10;
|
6015 |
|
|
+ param.rc.i_qp_max = 51;
|
6016 |
|
|
+ param.rc.i_qp_step = 4;
|
6017 |
|
|
+
|
6018 |
|
|
+
|
6019 |
|
|
+ // Picture height and width
|
6020 |
|
|
+ // CIF = 352x288
|
6021 |
|
|
+ param.i_width = 352;
|
6022 |
|
|
+ param.i_height = 288;
|
6023 |
|
|
+ V(fprintf( stderr, "x264 [info]: %dx%d @ %.2f fps\n",
|
6024 |
|
|
+ param.i_width, param.i_height,
|
6025 |
|
|
+ (float)param.i_fps_num / (float)param.i_fps_den));
|
6026 |
|
|
+
|
6027 |
|
|
+ // VBV buffer size in kbits
|
6028 |
|
|
+ param.rc.i_vbv_buffer_size = (352*288*12*4)/1024; // 4 frames of VBV (?!)
|
6029 |
|
|
+
|
6030 |
|
|
+
|
6031 |
|
|
+
|
6032 |
|
|
+ V(printf("video file in memory from 0x%.8x, size %d bytes\n", YUV_DATA_ADDR, YUV_DATA_SIZE));
|
6033 |
|
|
+ /* Must define a few things for use of static CIF data
|
6034 |
|
|
+ YUV_DATA_ADDR - address where the data starts
|
6035 |
|
|
+ YUV_DATA_SIZE - size of data in bytes
|
6036 |
|
|
+ ENC_OUT_ADDR - where we'll store the encoded data
|
6037 |
|
|
+ */
|
6038 |
|
|
+
|
6039 |
|
|
+ /* Parse command line */
|
6040 |
|
|
+ Parse( argc, &new_argv, ¶m, &opt );
|
6041 |
|
|
+ //if( Parse( argc, &new_argv, ¶m, &opt ) < 0 )
|
6042 |
|
|
+ //return -1;
|
6043 |
|
|
+
|
6044 |
|
|
+ // We specify a place in memory of some YUV CIF data instad of opening a file
|
6045 |
|
|
+ init_yuv_dataspace((char *)YUV_DATA_ADDR, (hnd_t *)&opt.hin, ¶m);
|
6046 |
|
|
+#ifdef ENC_OUT_ADDR
|
6047 |
|
|
+ p_open_outfile( 0, &opt.hout ); // Setup the out "file" which is really just a spot in memory
|
6048 |
|
|
+#endif
|
6049 |
|
|
+ //opt.hout = (void*) ENC_OUT_ADDR; // We specify a place in memory of where we'll dump the encoded data
|
6050 |
|
|
|
6051 |
|
|
- /* Control-C handler */
|
6052 |
|
|
- signal( SIGINT, SigIntHandler );
|
6053 |
|
|
+ /* Control-C handler */
|
6054 |
|
|
+ //signal( SIGINT, SigIntHandler );
|
6055 |
|
|
|
6056 |
|
|
- ret = Encode( ¶m, &opt );
|
6057 |
|
|
+ ret = Encode( ¶m, &opt );
|
6058 |
|
|
|
6059 |
|
|
#ifdef PTW32_STATIC_LIB
|
6060 |
|
|
pthread_win32_thread_detach_np();
|
6061 |
|
|
@@ -555,10 +646,12 @@
|
6062 |
|
|
/* Default output file driver */
|
6063 |
|
|
p_open_outfile = open_file_bsf;
|
6064 |
|
|
p_set_outfile_param = set_param_bsf;
|
6065 |
|
|
- p_write_nalu = write_nalu_bsf;
|
6066 |
|
|
+ p_write_nalu = write_nalu_bsf; //--jb
|
6067 |
|
|
p_set_eop = set_eop_bsf;
|
6068 |
|
|
p_close_outfile = close_file_bsf;
|
6069 |
|
|
|
6070 |
|
|
+ return 0; // -- added jb
|
6071 |
|
|
+
|
6072 |
|
|
/* Presets are applied before all other options. */
|
6073 |
|
|
for( optind = 0;; )
|
6074 |
|
|
{
|
6075 |
|
|
@@ -978,9 +1071,11 @@
|
6076 |
|
|
}
|
6077 |
|
|
else
|
6078 |
|
|
{
|
6079 |
|
|
- sscanf( argv[optind++], "%ux%u", ¶m->i_width, ¶m->i_height );
|
6080 |
|
|
- if( param->i_log_level >= X264_LOG_INFO )
|
6081 |
|
|
- fprintf( stderr, "x264 [info]: %dx%d @ %.2f fps\n", param->i_width, param->i_height, (double)param->i_fps_num / (double)param->i_fps_den);
|
6082 |
|
|
+ sscanf( argv[optind++], "%ux%u", ¶m->i_width, ¶m->i_height );
|
6083 |
|
|
+ if( param->i_log_level >= X264_LOG_INFO )
|
6084 |
|
|
+ fprintf( stderr, "x264 [info]: %dx%d @ %.2f fps\n",
|
6085 |
|
|
+ param->i_width, param->i_height,
|
6086 |
|
|
+ (double)param->i_fps_num / (double)param->i_fps_den);
|
6087 |
|
|
}
|
6088 |
|
|
}
|
6089 |
|
|
|
6090 |
|
|
@@ -1127,7 +1222,10 @@
|
6091 |
|
|
{
|
6092 |
|
|
i_nalu_size = p_write_nalu( hout, nal[i].p_payload, nal[i].i_payload );
|
6093 |
|
|
if( i_nalu_size < 0 )
|
6094 |
|
|
+ {
|
6095 |
|
|
+ fprintf(stderr, "Encode_frame: p_write_nalu() returned i_nalu_size < 0: %d\n", i_nalu_size);
|
6096 |
|
|
return -1;
|
6097 |
|
|
+ }
|
6098 |
|
|
i_file += i_nalu_size;
|
6099 |
|
|
}
|
6100 |
|
|
if (i_nal)
|
6101 |
|
|
@@ -1172,12 +1270,15 @@
|
6102 |
|
|
opt->b_progress &= param->i_log_level < X264_LOG_DEBUG;
|
6103 |
|
|
i_frame_total = p_get_frame_total( opt->hin );
|
6104 |
|
|
i_frame_total -= opt->i_seek;
|
6105 |
|
|
+
|
6106 |
|
|
if( ( i_frame_total == 0 || param->i_frame_total < i_frame_total )
|
6107 |
|
|
&& param->i_frame_total > 0 )
|
6108 |
|
|
i_frame_total = param->i_frame_total;
|
6109 |
|
|
+
|
6110 |
|
|
param->i_frame_total = i_frame_total;
|
6111 |
|
|
+ V(fprintf(stderr, "Encode: i_frame_total:%d\n", param->i_frame_total));
|
6112 |
|
|
i_update_interval = i_frame_total ? x264_clip3( i_frame_total / 1000, 1, 10 ) : 10;
|
6113 |
|
|
-
|
6114 |
|
|
+ V(fprintf(stderr, "Encode: i_update_interval:%d\n", i_update_interval));
|
6115 |
|
|
if( ( h = x264_encoder_open( param ) ) == NULL )
|
6116 |
|
|
{
|
6117 |
|
|
fprintf( stderr, "x264 [error]: x264_encoder_open failed\n" );
|
6118 |
|
|
@@ -1202,6 +1303,7 @@
|
6119 |
|
|
|
6120 |
|
|
i_start = x264_mdate();
|
6121 |
|
|
|
6122 |
|
|
+ V(fprintf(stderr, "Starting Encoder loop: i_frame_total %d\n", i_frame_total));
|
6123 |
|
|
/* Encode frames */
|
6124 |
|
|
for( i_frame = 0, i_file = 0, i_frame_output = 0; b_ctrl_c == 0 && (i_frame < i_frame_total || i_frame_total == 0); )
|
6125 |
|
|
{
|
6126 |
|
|
diff --exclude=.git --exclude=/gitignore -Naur x264/x264.h x264-or/x264.h
|
6127 |
|
|
--- x264/x264.h 2009-10-25 17:41:22.000000000 +0100
|
6128 |
|
|
+++ x264-or/x264.h 2009-10-28 15:05:29.000000000 +0100
|
6129 |
|
|
@@ -24,6 +24,29 @@
|
6130 |
|
|
#ifndef X264_X264_H
|
6131 |
|
|
#define X264_X264_H
|
6132 |
|
|
|
6133 |
|
|
+extern int yuv_data_start;
|
6134 |
|
|
+extern int yuv_data_end;
|
6135 |
|
|
+//#define YUV_DATA_ADDR 0x01000000
|
6136 |
|
|
+#define YUV_DATA_ADDR &yuv_data_start
|
6137 |
|
|
+#define YUV_DATA_SIZE ((int)(&yuv_data_end) - (int)(YUV_DATA_ADDR))
|
6138 |
|
|
+#define ENC_OUT_ADDR &yuv_data_end
|
6139 |
|
|
+
|
6140 |
|
|
+//#define USE_HARDCODED_FRAME_NUM
|
6141 |
|
|
+#define HARDCODED_FRAME_NUM 10
|
6142 |
|
|
+
|
6143 |
|
|
+
|
6144 |
|
|
+
|
6145 |
|
|
+/* Enable for verbose output during runtime */
|
6146 |
|
|
+//#define X264_VERBOSE
|
6147 |
|
|
+#ifdef X264_VERBOSE
|
6148 |
|
|
+#define V(x) x
|
6149 |
|
|
+#else
|
6150 |
|
|
+#define V(x)
|
6151 |
|
|
+#endif
|
6152 |
|
|
+
|
6153 |
|
|
+
|
6154 |
|
|
+extern int yuv_data_size;
|
6155 |
|
|
+
|
6156 |
|
|
#if !defined(_STDINT_H) && !defined(_STDINT_H_) && \
|
6157 |
|
|
!defined(_INTTYPES_H) && !defined(_INTTYPES_H_)
|
6158 |
|
|
# ifdef _MSC_VER
|