OpenCores
URL https://opencores.org/ocsvn/oc-h264-encoder/oc-h264-encoder/trunk

Subversion Repositories oc-h264-encoder

[/] [oc-h264-encoder/] [trunk/] [x264/] [patches/] [x264-e381f6d-or32-or1ksim-with-fp-1.0.patch] - Blame information for rev 49

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 49 julius
diff --exclude=.git --exclude=.gitignore -Naur ../x264/common/common.c x264/common/common.c
2
--- ../x264/common/common.c     2009-10-25 17:41:22.000000000 +0100
3
+++ x264/common/common.c        2009-10-27 16:45:55.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/common/common.h
16
--- ../x264/common/common.h     2009-10-25 17:41:22.000000000 +0100
17
+++ x264/common/common.h        2009-10-27 16:45:55.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
diff --exclude=.git --exclude=.gitignore -Naur ../x264/common/frame.c x264/common/frame.c
29
--- ../x264/common/frame.c      2009-10-25 17:41:10.000000000 +0100
30
+++ x264/common/frame.c 2009-10-27 16:45:55.000000000 +0100
31
@@ -31,6 +31,8 @@
32
     x264_frame_t *frame;
33
     int i, j;
34
 
35
+    //V(fprintf(stderr, "x264_frame_new\n"));
36
+
37
     int i_mb_count = h->mb.i_mb_count;
38
     int i_stride, i_width, i_lines;
39
     int i_padv = PADV << h->param.b_interlaced;
40
@@ -981,11 +983,14 @@
41
 
42
 x264_frame_t *x264_frame_pop_unused( x264_t *h, int b_fdec )
43
 {
44
+  //V(fprintf(stderr, "x264_frame_pop_unused\n"));
45
     x264_frame_t *frame;
46
     if( h->frames.unused[b_fdec][0] )
47
         frame = x264_frame_pop( h->frames.unused[b_fdec] );
48
     else
49
         frame = x264_frame_new( h, b_fdec );
50
+
51
+    //V(fprintf(stderr, "x264_frame_pop_unused: frame ptr = 0x%.8x\n", (unsigned long) frame));
52
     if( !frame )
53
         return NULL;
54
     frame->b_last_minigop_bframe = 0;
55
diff --exclude=.git --exclude=.gitignore -Naur ../x264/common/mdate.c x264/common/mdate.c
56
--- ../x264/common/mdate.c      2009-10-25 17:41:10.000000000 +0100
57
+++ x264/common/mdate.c 2009-10-27 16:45:55.000000000 +0100
58
@@ -32,9 +32,12 @@
59
 int64_t x264_mdate( void )
60
 {
61
 #ifndef __MINGW32__
62
+  /* --jb
63
     struct timeval tv_date;
64
     gettimeofday( &tv_date, NULL );
65
     return( (int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec );
66
+  */
67
+  return 0;
68
 #else
69
     struct _timeb tb;
70
     _ftime(&tb);
71
diff --exclude=.git --exclude=.gitignore -Naur ../x264/common/pixel.c x264/common/pixel.c
72
--- ../x264/common/pixel.c      2009-10-25 17:41:10.000000000 +0100
73
+++ x264/common/pixel.c 2009-10-27 16:45:55.000000000 +0100
74
@@ -22,6 +22,7 @@
75
  *****************************************************************************/
76
 
77
 #include "common.h"
78
+#include "x264.h"
79
 
80
 #ifdef HAVE_MMX
81
 #   include "x86/pixel.h"
82
@@ -40,6 +41,7 @@
83
 /****************************************************************************
84
  * pixel_sad_WxH
85
  ****************************************************************************/
86
+/*  V(fprintf(stderr, "pixel_sad %d x %d, *pix1: 0x%.8x *pix2: 0x%.8x i_stride_pix1: %d i_stride_pix2: %d\n", lx, ly, (unsigned long) pix1, (unsigned long) pix2, i_stride_pix1, i_stride_pix2)); \*/
87
 #define PIXEL_SAD_C( name, lx, ly ) \
88
 static int name( uint8_t *pix1, int i_stride_pix1,  \
89
                  uint8_t *pix2, int i_stride_pix2 ) \
90
@@ -387,6 +389,7 @@
91
 
92
 /****************************************************************************
93
  * pixel_sad_x4
94
+ * 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)); \
95
  ****************************************************************************/
96
 #define SAD_X( size ) \
97
 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] )\
98
diff --exclude=.git --exclude=.gitignore -Naur ../x264/configure x264/configure
99
--- ../x264/configure   2009-10-25 17:41:10.000000000 +0100
100
+++ x264/configure      2009-10-27 16:45:55.000000000 +0100
101
@@ -29,7 +29,7 @@
102
     rm -f conftest.c
103
     [ -n "$1" ] && echo "#include <$1>" > conftest.c
104
     echo "int main () { $3 return 0; }" >> conftest.c
105
-    $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
106
+    $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest #2>$DEVNULL
107
 }
108
 
109
 as_check() {
110
diff --exclude=.git --exclude=.gitignore -Naur ../x264/encoder/analyse.c x264/encoder/analyse.c
111
--- ../x264/encoder/analyse.c   2009-10-25 17:41:10.000000000 +0100
112
+++ x264/encoder/analyse.c      2009-10-27 16:45:55.000000000 +0100
113
@@ -27,6 +27,7 @@
114
 #include <unistd.h>
115
 
116
 #include "common/common.h"
117
+#include "x264.h"
118
 #include "common/cpu.h"
119
 #include "macroblock.h"
120
 #include "me.h"
121
@@ -34,6 +35,7 @@
122
 #include "analyse.h"
123
 #include "rdo.c"
124
 
125
+
126
 typedef struct
127
 {
128
     /* 16x16 */
129
@@ -233,40 +235,76 @@
130
     5, 3, 3, 1
131
 };
132
 
133
+extern const float x264_analyse_init_log2_array[]; //jb
134
+
135
 static void x264_analyse_update_cache( x264_t *h, x264_mb_analysis_t *a );
136
 
137
 static uint16_t x264_cost_ref[92][3][33];
138
 static x264_pthread_mutex_t cost_ref_mutex = X264_PTHREAD_MUTEX_INITIALIZER;
139
 
140
+/*
141
+float log2f( float n )
142
+{
143
+// log(n)/log(2) is log2.
144
+//return log10( n ) / log10( 2 );
145
+  return (float) (log( n ) / _M_LOG2_E);
146
+}
147
+*/
148
 int x264_analyse_init_costs( x264_t *h, int qp )
149
 {
150
     int i, j;
151
     int lambda = x264_lambda_tab[qp];
152
+    float tmp_f,lambda_f = lambda;
153
+
154
     if( h->cost_mv[lambda] )
155
         return 0;
156
+
157
+    fprintf( stderr,
158
+            "x264_analyse_init_costs: lambda (= x264_lambda_tab[%d])  = %d\n",
159
+            qp, lambda);
160
+
161
     /* factor of 4 from qpel, 2 from sign, and 2 because mv can be opposite from mvp */
162
     CHECKED_MALLOC( h->cost_mv[lambda], (4*4*2048 + 1) * sizeof(uint16_t) );
163
+
164
     h->cost_mv[lambda] += 2*4*2048;
165
+
166
+    /* Computationally expensive thing: logs, floating point math, much of -- jb*/
167
+    //fprintf(stderr, "x264_analyse_init_costs: beginning loop of 2*4*2048");
168
+
169
     for( i = 0; i <= 2*4*2048; i++ )
170
-    {
171
-        h->cost_mv[lambda][-i] =
172
-        h->cost_mv[lambda][i]  = lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
173
-    }
174
+      {
175
+
176
+         //h->cost_mv[lambda][i]  = lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
177
+         //h->cost_mv[lambda][i]  = lambda * (log2(i+1)*2 + 0.718f + !!i) + .5f;
178
+
179
+       // precalulated array, doing the above few calculations for us
180
+       tmp_f = lambda_f * x264_analyse_init_log2_array[i];
181
+       tmp_f += .5f;
182
+       h->cost_mv[lambda][-i] =
183
+         h->cost_mv[lambda][i]  = tmp_f;
184
+
185
+
186
+      }
187
     x264_pthread_mutex_lock( &cost_ref_mutex );
188
+    //fprintf(stderr, "\tfinished\n");
189
+    /* -- for now jb
190
     for( i = 0; i < 3; i++ )
191
-        for( j = 0; j < 33; j++ )
192
-            x264_cost_ref[lambda][i][j] = i ? lambda * bs_size_te( i, j ) : 0;
193
+      for( j = 0; j < 33; j++ )
194
+       x264_cost_ref[lambda][i][j] = i ? lambda * bs_size_te( i, j ) : 0;
195
+
196
     x264_pthread_mutex_unlock( &cost_ref_mutex );
197
     if( h->param.analyse.i_me_method >= X264_ME_ESA && !h->cost_mv_fpel[lambda][0] )
198
-    {
199
+      {
200
+       printf("analyse_init_costs: h->param.analyse.i_me_method >= X264_ME_ESA && !h->cost_mv_fpel[lambda][0]\n");
201
         for( j=0; j<4; j++ )
202
-        {
203
+         {
204
             CHECKED_MALLOC( h->cost_mv_fpel[lambda][j], (4*2048 + 1) * sizeof(uint16_t) );
205
             h->cost_mv_fpel[lambda][j] += 2*2048;
206
             for( i = -2*2048; i < 2*2048; i++ )
207
-                h->cost_mv_fpel[lambda][j][i] = h->cost_mv[lambda][i*4+j];
208
+             h->cost_mv_fpel[lambda][j][i] = h->cost_mv[lambda][i*4+j];
209
         }
210
     }
211
+    */
212
     return 0;
213
 fail:
214
     return -1;
215
@@ -288,6 +326,7 @@
216
 /* initialize an array of lambda*nbits for all possible mvs */
217
 static void x264_mb_analyse_load_costs( x264_t *h, x264_mb_analysis_t *a )
218
 {
219
+  //V(fprintf(stderr, "x264_mb_analyse_load_costs() called\n"));
220
     a->p_cost_mv = h->cost_mv[a->i_lambda];
221
     a->p_cost_ref0 = x264_cost_ref[a->i_lambda][x264_clip3(h->sh.i_num_ref_idx_l0_active-1,0,2)];
222
     a->p_cost_ref1 = x264_cost_ref[a->i_lambda][x264_clip3(h->sh.i_num_ref_idx_l1_active-1,0,2)];
223
diff --exclude=.git --exclude=.gitignore -Naur ../x264/encoder/analyse_gen_init_array.sh x264/encoder/analyse_gen_init_array.sh
224
--- ../x264/encoder/analyse_gen_init_array.sh   1970-01-01 01:00:00.000000000 +0100
225
+++ x264/encoder/analyse_gen_init_array.sh      2009-10-27 16:45:55.000000000 +0100
226
@@ -0,0 +1,32 @@
227
+#!/bin/bash
228
+# Pre-generate an array of numbers according to the algorithm from analyse_init_costs()
229
+# to speedup calculation. Here we calculate the stuff in brackets:
230
+# lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;
231
+outfile=analyse_init_log2.c
232
+
233
+echo; echo "Generating analyse_init_log2_array[] to $outfile"
234
+echo "This may take a minute or two..."
235
+
236
+#Size of the array: 4*2*2048
237
+numvals=16384
238
+
239
+rm  -f $outfile
240
+
241
+echo "const float x264_analyse_init_log2_array[] = {" >> $outfile
242
+
243
+n=0
244
+
245
+    for num in `seq 1 $numvals`;
246
+    do
247
+# Use bc to do the calculation, scale down to the output to one decimal place
248
+       newnum=`echo "a=((l($num)/l(2))*2)+1.718; scale=1; a=(a*2)/2; a" | bc -l`
249
+       echo -n $newnum >> $outfile
250
+       if [ $num -lt $numvals ]; then echo -n ", " >> $outfile; fi;
251
+       # Newline every 16 values
252
+       let "n = $num % 16"
253
+       if [ $n -eq 0 ]; then echo >> $outfile; fi;
254
+    done
255
+echo "};" >> $outfile
256
+
257
+echo "finished"
258
+echo
259
diff --exclude=.git --exclude=.gitignore -Naur ../x264/encoder/encoder.c x264/encoder/encoder.c
260
--- ../x264/encoder/encoder.c   2009-10-25 17:41:22.000000000 +0100
261
+++ x264/encoder/encoder.c      2009-10-27 16:45:55.000000000 +0100
262
@@ -62,6 +62,9 @@
263
 
264
 static void x264_frame_dump( x264_t *h )
265
 {
266
+  //printf("frame_dump()\n");
267
+  return;
268
+
269
     FILE *f = fopen( h->param.psz_dump_yuv, "r+b" );
270
     int i, y;
271
     if( !f )
272
@@ -301,6 +304,7 @@
273
     if( ( h->param.b_cabac && (h->cabac.p_end - h->cabac.p < 2500) )
274
      || ( h->out.bs.p_end - h->out.bs.p < 2500 ) )
275
     {
276
+      //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 ));
277
         intptr_t delta;
278
         int i;
279
 
280
@@ -695,6 +699,8 @@
281
 static void mbcmp_init( x264_t *h )
282
 {
283
     int satd = !h->mb.b_lossless && h->param.analyse.i_subpel_refine > 1;
284
+    //V(if (satd)fprintf(stderr, "macroblock compare functions. satd enabled\n"));
285
+    //V(if (!satd)fprintf(stderr, "macroblock compare functions. satd not enabled\n"));
286
     memcpy( h->pixf.mbcmp, satd ? h->pixf.satd : h->pixf.sad_aligned, sizeof(h->pixf.mbcmp) );
287
     memcpy( h->pixf.mbcmp_unaligned, satd ? h->pixf.satd : h->pixf.sad, sizeof(h->pixf.mbcmp_unaligned) );
288
     h->pixf.intra_mbcmp_x3_16x16 = satd ? h->pixf.intra_satd_x3_16x16 : h->pixf.intra_sad_x3_16x16;
289
@@ -750,15 +756,14 @@
290
     x264_t *h;
291
     char buf[1000], *p;
292
     int i, qp, i_slicetype_length;
293
-
294
+
295
     CHECKED_MALLOCZERO( h, sizeof(x264_t) );
296
-
297
+
298
     /* Create a copy of param */
299
     memcpy( &h->param, param, sizeof(x264_param_t) );
300
-
301
     if( param->param_free )
302
         param->param_free( param );
303
-
304
+
305
     if( x264_validate_parameters( h ) < 0 )
306
         goto fail;
307
 
308
@@ -772,7 +777,7 @@
309
         h->param.rc.psz_stat_in = strdup( h->param.rc.psz_stat_in );
310
 
311
     x264_set_aspect_ratio( h, param, 1 );
312
-
313
+
314
     x264_reduce_fraction( &h->param.i_fps_num, &h->param.i_fps_den );
315
 
316
     /* Init x264_t */
317
@@ -831,8 +836,8 @@
318
     h->i_ref0 = 0;
319
     h->i_ref1 = 0;
320
 
321
-    x264_rdo_init();
322
-
323
+    x264_rdo_init();
324
+
325
     /* init CPU functions */
326
     x264_predict_16x16_init( h->param.cpu, h->predict_16x16 );
327
     x264_predict_8x8c_init( h->param.cpu, h->predict_8x8c );
328
@@ -870,17 +875,25 @@
329
         p += sprintf( p, " none!" );
330
     x264_log( h, X264_LOG_INFO, "%s\n", buf );
331
 
332
+    /* // should skip during cycle accurate -- jb    */
333
+    // Check the different quantisation points and their costs
334
     for( qp = h->param.rc.i_qp_min; qp <= h->param.rc.i_qp_max; qp++ )
335
+      {
336
+       //printf("%d\n", qp);
337
         if( x264_analyse_init_costs( h, qp ) )
338
-            goto fail;
339
+         goto fail;
340
+      }
341
     if( x264_analyse_init_costs( h, X264_LOOKAHEAD_QP ) )
342
         goto fail;
343
     if( h->cost_mv[1][2013] != 24 )
344
-    {
345
+      {
346
+       //fprintf(stderr, "h->cost_mv[1][2013] = %d\n",h->cost_mv[1][2013]);
347
         x264_log( h, X264_LOG_ERROR, "MV cost test failed: x264 has been miscompiled!\n" );
348
         goto fail;
349
     }
350
 
351
+    //exit(0); // jb
352
+
353
     h->out.i_nal = 0;
354
     h->out.i_bitstream = X264_MAX( 1000000, h->param.i_width * h->param.i_height * 4
355
         * ( h->param.rc.i_rc_method == X264_RC_ABR ? pow( 0.95, h->param.rc.i_qp_min )
356
@@ -908,16 +921,17 @@
357
         if( x264_macroblock_cache_init( h->thread[i] ) < 0 )
358
             goto fail;
359
     }
360
-
361
+
362
     if( x264_lookahead_init( h, i_slicetype_length ) )
363
         goto fail;
364
 
365
     if( x264_ratecontrol_new( h ) < 0 )
366
         goto fail;
367
-
368
+
369
+    /* // skip this for now, it's a fopen() call we won't really do, plus it's an option we'll never need --jb
370
     if( h->param.psz_dump_yuv )
371
     {
372
-        /* create or truncate the reconstructed video file */
373
+    //create or truncate the reconstructed video file
374
         FILE *f = fopen( h->param.psz_dump_yuv, "w" );
375
         if( f )
376
             fclose( f );
377
@@ -927,6 +941,8 @@
378
             goto fail;
379
         }
380
     }
381
+    */
382
+
383
 
384
     x264_log( h, X264_LOG_INFO, "profile %s, level %d.%d\n",
385
         h->sps->i_profile_idc == PROFILE_BASELINE ? "Baseline" :
386
@@ -1307,6 +1323,8 @@
387
     int slice_max_size = h->param.i_slice_max_size > 0 ? (h->param.i_slice_max_size-3-NALU_OVERHEAD)*8 : INT_MAX;
388
     int starting_bits = bs_pos(&h->out.bs);
389
 
390
+    //V(fprintf(stderr, "x264_slice_write\n"));
391
+
392
     /* Slice */
393
     x264_nal_start( h, h->i_nal_type, h->i_nal_ref_idc );
394
 
395
@@ -1320,6 +1338,7 @@
396
         /* init cabac */
397
         x264_cabac_context_init( &h->cabac, h->sh.i_type, h->sh.i_qp, h->sh.i_cabac_init_idc );
398
         x264_cabac_encode_init ( &h->cabac, h->out.bs.p, h->out.bs.p_end );
399
+       //V(fprintf(stderr, "\tcabac inited\n"));
400
     }
401
     h->mb.i_last_qp = h->sh.i_qp;
402
     h->mb.i_last_dqp = 0;
403
@@ -1362,7 +1381,10 @@
404
         x264_macroblock_encode( h );
405
 
406
         if( x264_bitstream_check_buffer( h ) )
407
+         {
408
+           //V(fprintf(stderr, "\tx264_bitstream_check_buffer failed\n"));
409
             return -1;
410
+         }
411
 
412
         if( h->param.b_cabac )
413
         {
414
@@ -1522,6 +1544,8 @@
415
         x264_fdec_filter_row( h, h->sps->i_mb_height );
416
     }
417
 
418
+    //V(fprintf(stderr, "x264_slice_write ok\n"));
419
+
420
     return 0;
421
 }
422
 
423
@@ -1625,8 +1649,8 @@
424
     int     i_nal_type, i;
425
     int     i_nal_ref_idc;
426
 
427
-    int   i_global_qp;
428
 
429
+    int   i_global_qp;
430
     if( h->param.i_threads > 1)
431
     {
432
         int i = ++h->i_thread_phase;
433
@@ -1653,6 +1677,7 @@
434
     /* no data out */
435
     *pi_nal = 0;
436
     *pp_nal = NULL;
437
+
438
 
439
     /* ------------------- Setup new frame from picture -------------------- */
440
     if( pic_in != NULL )
441
@@ -1663,7 +1688,10 @@
442
             return -1;
443
 
444
         if( x264_frame_copy_picture( h, fenc, pic_in ) < 0 )
445
+         {
446
+           //V(fprintf(stderr, "x264_frame_copy_picture returned >0\n"));
447
             return -1;
448
+         }
449
 
450
         if( h->param.i_width != 16 * h->sps->i_mb_width ||
451
             h->param.i_height != 16 * h->sps->i_mb_height )
452
@@ -1684,13 +1712,15 @@
453
 
454
         /* 2: Place the frame into the queue for its slice type decision */
455
         x264_lookahead_put_frame( h, fenc );
456
-
457
+
458
+       //V(fprintf(stderr, "x264_encoder_encode setup new frame from picture\n"));
459
+
460
         if( h->frames.i_input <= h->frames.i_delay + 1 - h->param.i_threads )
461
         {
462
             /* Nothing yet to encode, waiting for filling of buffers */
463
             pic_out->i_type = X264_TYPE_AUTO;
464
             return 0;
465
-        }
466
+        }
467
     }
468
     else
469
     {
470
@@ -1873,7 +1903,10 @@
471
     }
472
     else
473
         if( (intptr_t)x264_slices_write( h ) )
474
+         {
475
+           //V(fprintf(stderr, "x264_encoder_encode(): x264_slices_write() failed\n"));
476
             return -1;
477
+         }
478
 
479
     return x264_encoder_frame_end( thread_oldest, thread_current, pp_nal, pi_nal, pic_out );
480
 }
481
diff --exclude=.git --exclude=.gitignore -Naur ../x264/encoder/me.c x264/encoder/me.c
482
--- ../x264/encoder/me.c        2009-10-25 17:41:10.000000000 +0100
483
+++ x264/encoder/me.c   2009-10-27 16:45:55.000000000 +0100
484
@@ -182,6 +182,7 @@
485
     int omx, omy, pmx, pmy;
486
     uint8_t *p_fenc = m->p_fenc[0];
487
     uint8_t *p_fref = m->p_fref[0];
488
+    //V(fprintf(stderr, "s264_me_search_ref *p_fenc = 0x%.8x *p_fref = 0x%.8x\n", (unsigned long) p_fenc, (unsigned long) p_fref));
489
     ALIGNED_ARRAY_16( uint8_t, pix,[16*16] );
490
 
491
     int i, j;
492
@@ -197,7 +198,7 @@
493
 
494
     const uint16_t *p_cost_mvx = m->p_cost_mv - m->mvp[0];
495
     const uint16_t *p_cost_mvy = m->p_cost_mv - m->mvp[1];
496
-
497
+    //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]));
498
     bmx = x264_clip3( m->mvp[0], mv_x_min*4, mv_x_max*4 );
499
     bmy = x264_clip3( m->mvp[1], mv_y_min*4, mv_y_max*4 );
500
     pmx = ( bmx + 2 ) >> 2;
501
@@ -251,6 +252,7 @@
502
     {
503
     case X264_ME_DIA:
504
         /* diamond search, radius 1 */
505
+      //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));
506
         i = 0;
507
         bcost <<= 4;
508
         do
509
diff --exclude=.git --exclude=.gitignore -Naur ../x264/encoder/slicetype.c x264/encoder/slicetype.c
510
--- ../x264/encoder/slicetype.c 2009-10-25 17:41:22.000000000 +0100
511
+++ x264/encoder/slicetype.c    2009-10-27 16:45:55.000000000 +0100
512
@@ -909,7 +909,9 @@
513
 
514
     /* Restore frametypes for all frames that haven't actually been decided yet. */
515
     for( j = reset_start; j <= num_frames; j++ )
516
-        frames[j]->i_type = X264_TYPE_AUTO;
517
+      frames[j]->i_type = X264_TYPE_AUTO;
518
+
519
+    return;
520
 }
521
 
522
 void x264_slicetype_decide( x264_t *h )
523
diff --exclude=.git --exclude=.gitignore -Naur ../x264/link.ld x264/link.ld
524
--- ../x264/link.ld     1970-01-01 01:00:00.000000000 +0100
525
+++ x264/link.ld        2009-10-27 16:45:55.000000000 +0100
526
@@ -0,0 +1,100 @@
527
+/*
528
+MEMORY
529
+        {
530
+        vectors : ORIGIN = 0x00000000, LENGTH = 0x00002000
531
+        flash   : ORIGIN = 0x04000000, LENGTH = 0x00200000
532
+        ram     : ORIGIN = 0x00002000, LENGTH = 0x001fe000
533
+        icm     : ORIGIN = 0x00800000, LENGTH = 0x00004000
534
+        }
535
+ */
536
+
537
+MEMORY
538
+       {
539
+/*
540
+       reset    : ORIGIN = 0x00000000, LENGTH = 0x00000200
541
+       vectors  : ORIGIN = 0x00000200, LENGTH = 0x00001E00
542
+        text     : ORIGIN = 0x00002000, LENGTH = 0x000fe000
543
+       data     : ORIGIN = 0x00100000, LENGTH = 0x00fe0000
544
+       stack    : ORIGIN = 0x001fe000, LENGTH = 0x00010000
545
+*/
546
+       yuv_data : ORIGIN = 25M, LENGTH = 7M
547
+       }
548
+
549
+/*
550
+MEMORY
551
+        {
552
+        reset   : ORIGIN = 0xc0000000, LENGTH = 0x00000200
553
+        vectors : ORIGIN = 0xc0000200, LENGTH = 0x00001000
554
+        ram     : ORIGIN = 0xc0001200, LENGTH = 0x00FFED00
555
+        }
556
+*/
557
+SECTIONS
558
+{
559
+/*
560
+       .reset :
561
+        {
562
+        *(.reset)
563
+        } > reset
564
+
565
+
566
+
567
+       .vectors :
568
+        {
569
+        _vec_start = .;
570
+        *(.vectors)
571
+        _vec_end = .;
572
+        } > vectors
573
+
574
+        .text :
575
+        {
576
+        *(.text)
577
+        } > text
578
+
579
+      .rodata :
580
+        {
581
+        *(.rodata)
582
+        *(.rodata.*)
583
+        } > text
584
+
585
+     .icm :
586
+        {
587
+        _icm_start = .;
588
+        *(.icm)
589
+        _icm_end = .;
590
+        } > data
591
+
592
+     .data :
593
+        {
594
+        _dst_beg = .;
595
+        *(.data)
596
+        _dst_end = .;
597
+        } > data
598
+
599
+      .bss :
600
+        {
601
+        *(.bss)
602
+        } > data
603
+
604
+       .heap :
605
+       {
606
+       _heap_start = .;
607
+       *(.heap)
608
+       _heap_end = .;
609
+       } > data
610
+
611
+      .stack (NOLOAD) :
612
+        {
613
+        *(.stack)
614
+        _src_addr = .;
615
+        } > data
616
+*/
617
+       .yuv_data :
618
+       {
619
+       _yuv_data_start = .;
620
+       __yuv_data_start = .;
621
+       *(.yuv_data)
622
+       _yuv_data_end = .;
623
+       __yuv_data_end = .;
624
+       } > yuv_data
625
+
626
+}
627
diff --exclude=.git --exclude=.gitignore -Naur ../x264/Makefile x264/Makefile
628
--- ../x264/Makefile    2009-10-25 17:41:22.000000000 +0100
629
+++ x264/Makefile       2009-10-27 17:30:09.000000000 +0100
630
@@ -91,7 +91,54 @@
631
 $(SONAME): .depend $(OBJS) $(OBJASM)
632
        $(CC) -shared -o $@ $(OBJS) $(OBJASM) $(SOFLAGS) $(LDFLAGS)
633
 
634
-x264$(EXE): $(OBJCLI) libx264.a
635
+
636
+## OR32-specific build rules
637
+##
638
+## Essentially we create some sample YUV video data
639
+## and embed it in an ELF file, in a section called yuv_data.
640
+## In the linker script we then link this section to a place
641
+## in ram and tell x264 to look here when it wants data.
642
+##
643
+## You can download sample h264 encoded CIF sequences
644
+## here: http://www.tkn.tu-berlin.de/research/evalvid/cif.html
645
+##
646
+##
647
+GEN_FILES=encoder/analyse_init_log2.c
648
+VIDEO_DATA_FILE=yuv_data.elf
649
+H264_VIDEO_FILE ?= ../test-sequences/football_cif.264
650
+YUV_VIDEO_FILE ?= video_data.yuv
651
+# We will use a limit of about 5MB of video data to encode
652
+# For CIF resultion of 4:2:0 this is about 30 frames. It's
653
+# possible to convert a set amount of data with ffmpeg but
654
+# it's probably not wise to attempt to encode partial frames
655
+NUM_FRAMES=30
656
+
657
+$(H264_VIDEO_FILE):
658
+       @echo; echo;
659
+       @echo "\tNo sample video file to embed! Please edit the Makefile"
660
+       @echo "\tand set the variable H264_VIDEO_FILE to the location of "
661
+       @echo "\ta raw h264 bitstream file, or set this variable on the"
662
+       @echo "\tcommand line when calling make, eg.:"
663
+       @echo "\t\tH264_VIDEO_FILE=../football_cif.264 make"; echo
664
+       exit 1
665
+$(YUV_VIDEO_FILE): $(H264_VIDEO_FILE)
666
+# First convert it to raw YUV, only about 5MB large, so for cif take 30 frames
667
+       ffmpeg -i $(H264_VIDEO_FILE) -vframes $(NUM_FRAMES) $(YUV_VIDEO_FILE)
668
+$(VIDEO_DATA_FILE): $(YUV_VIDEO_FILE)
669
+       or32-elf-ld -r -b binary -o yuv_data.o $(YUV_VIDEO_FILE)
670
+       or32-elf-objcopy --rename-section .data=.yuv_data yuv_data.o
671
+       mv yuv_data.o $(VIDEO_DATA_FILE)
672
+encoder/analyse_init_log2.c: encoder/analyse_gen_init_array.sh
673
+       cd encoder && chmod a+x analyse_gen_init_array.sh && ./analyse_gen_init_array.sh
674
+#OR32_DEPS= reset.o except.o uart.o syscalls.o $(VIDEO_DATA_FILE)
675
+
676
+OR32_DEPS= $(VIDEO_DATA_FILE) $(GEN_FILES)
677
+
678
+sim: x264$(EXE)
679
+       or32-elf-sim -f or1ksim_x264.cfg $<
680
+
681
+
682
+x264$(EXE): $(OR32_DEPS) $(OBJCLI) libx264.a
683
        $(CC) -o $@ $+ $(LDFLAGS)
684
 
685
 checkasm: tools/checkasm.o libx264.a
686
@@ -147,12 +194,13 @@
687
 endif
688
 
689
 clean:
690
-       rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS
691
+       rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(SONAME) *.a x264 x264.exe .depend TAGS $(YUV_VIDEO_FILE)
692
        rm -f checkasm checkasm.exe tools/checkasm.o tools/checkasm-a.o
693
        rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno)
694
        - sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak
695
 
696
 distclean: clean
697
+       rm -f $(OR32_DEPS) uart0* $(GEN_FILES)
698
        rm -f config.mak config.h x264.pc
699
        rm -rf test/
700
 
701
diff --exclude=.git --exclude=.gitignore -Naur ../x264/muxers.c x264/muxers.c
702
--- ../x264/muxers.c    2009-10-25 17:41:22.000000000 +0100
703
+++ x264/muxers.c       2009-10-27 16:45:55.000000000 +0100
704
@@ -52,15 +52,32 @@
705
 
706
 typedef struct
707
 {
708
-    FILE *fh;
709
-    int width, height;
710
-    int next_frame;
711
+  //FILE *fh;
712
+  char *fh;
713
+
714
+  int width, height;
715
+  int next_frame;
716
+
717
 } yuv_input_t;
718
 
719
+void init_yuv_dataspace(char* yuv_dat_addr, hnd_t *p_handle, x264_param_t *p_param)
720
+{
721
+  yuv_input_t *h = malloc( sizeof(yuv_input_t) );
722
+  V(fprintf( stderr, "init_yuv_dataspace: h addr = 0x%.8x\n", h));
723
+  h->fh = yuv_dat_addr;
724
+  V(fprintf( stderr, "init_yuv_dataspace: h->fh 0x%.8x\n",h->fh));
725
+  h->width = p_param->i_width;
726
+  V(fprintf( stderr, "init_yuv_dataspace: h->width %d\n",h->width));
727
+  h->height = p_param->i_height;
728
+  V(fprintf( stderr, "init_yuv_dataspace: h->height %d\n",h->height));
729
+  h->next_frame = 0;
730
+  *p_handle = (hnd_t *)h;
731
+}
732
+
733
 /* raw 420 yuv file operation */
734
 int open_file_yuv( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param )
735
 {
736
-    yuv_input_t *h = malloc( sizeof(yuv_input_t) );
737
+  yuv_input_t *h = malloc( sizeof(yuv_input_t) );
738
     if( !h )
739
         return -1;
740
     h->width = p_param->i_width;
741
@@ -80,7 +97,10 @@
742
 
743
 int get_frame_total_yuv( hnd_t handle )
744
 {
745
-    yuv_input_t *h = handle;
746
+      yuv_input_t *h = handle;
747
+
748
+      V(fprintf(stderr, "get_frame_total_yuv args: handle: 0x%.8x, h: 0x%.8x\n", handle, h));
749
+      /*
750
     int i_frame_total = 0;
751
 
752
     if( !fseek( h->fh, 0, SEEK_END ) )
753
@@ -88,24 +108,45 @@
754
         uint64_t i_size = ftell( h->fh );
755
         fseek( h->fh, 0, SEEK_SET );
756
         i_frame_total = (int)(i_size / ( h->width * h->height * 3 / 2 ));
757
-    }
758
+       }*/
759
+
760
+#ifdef      USE_HARDCODED_FRAME_NUM
761
+      return (int)HARDCODED_FRAME_NUM;
762
+#else
763
+      fprintf( stderr, "get_frame_total_yuv: %d %d %d %d\n",
764
+                h->width, h->height,
765
+                YUV_DATA_SIZE,
766
+                (int)(YUV_DATA_SIZE / ( h->width * h->height * 3 / 2 )));
767
+      return (int)(YUV_DATA_SIZE / ( h->width * h->height * 3 / 2 ));//i_frame_total;
768
+
769
+#endif
770
 
771
-    return i_frame_total;
772
 }
773
 
774
 int read_frame_yuv( x264_picture_t *p_pic, hnd_t handle, int i_frame )
775
 {
776
     yuv_input_t *h = handle;
777
-
778
+    int i;
779
+
780
     if( i_frame != h->next_frame )
781
-        if( fseek( h->fh, (uint64_t)i_frame * h->width * h->height * 3 / 2, SEEK_SET ) )
782
-            return -1;
783
-
784
-    if( fread( p_pic->img.plane[0], 1, h->width * h->height, h->fh ) <= 0
785
-     || fread( p_pic->img.plane[1], 1, h->width * h->height / 4, h->fh ) <= 0
786
-     || fread( p_pic->img.plane[2], 1, h->width * h->height / 4, h->fh ) <= 0 )
787
-        return -1;
788
+      //if( fseek( h->fh, (uint64_t)i_frame * h->width * h->height * 3 / 2, SEEK_SET ) )
789
+      // Progress pointer to beginning of this frame
790
+      h->fh = (void*) YUV_DATA_ADDR + i_frame * h->width * h->height * 3 / 2;
791
+      //return -1;
792
+
793
+    //if( fread( p_pic->img.plane[0], 1, h->width * h->height, h->fh ) <= 0
794
+    for (i=0;i<h->width * h->height;i++) p_pic->img.plane[0][i] = h->fh[i];
795
+    h->fh += h->width * h->height;
796
+    //|| fread( p_pic->img.plane[1], 1, h->width * h->height / 4, h->fh ) <= 0
797
+    for (i=0;i<(h->width * h->height) / 4;i++) p_pic->img.plane[1][i] = h->fh[i];
798
+    h->fh += (h->width * h->height) / 4;
799
+
800
+    //|| fread( p_pic->img.plane[2], 1, h->width * h->height / 4, h->fh ) <= 0 )
801
+    for (i=0;i<(h->width * h->height) / 4;i++) p_pic->img.plane[2][i] = h->fh[i];
802
+    h->fh += (h->width * h->height) / 4;
803
 
804
+    //return -1;
805
+
806
     h->next_frame = i_frame+1;
807
 
808
     return 0;
809
@@ -113,12 +154,15 @@
810
 
811
 int close_file_yuv(hnd_t handle)
812
 {
813
+  return 0;
814
+  /* // -- jb
815
     yuv_input_t *h = handle;
816
     if( !h || !h->fh )
817
         return 0;
818
     fclose( h->fh );
819
     free( h );
820
     return 0;
821
+  */
822
 }
823
 
824
 /* YUV4MPEG2 raw 420 yuv file operation */
825
@@ -530,11 +574,21 @@
826
 }
827
 #endif
828
 
829
+#ifdef ENC_OUT_ADDR
830
+char * enc_out_pos;
831
+#endif
832
 
833
 int open_file_bsf( char *psz_filename, hnd_t *p_handle )
834
 {
835
+#ifdef ENC_OUT_ADDR
836
+  V(fprintf(stderr, "open_file_bsf\n"));
837
+  // Use a hardcoded memory location for outputting encoded data to
838
+  p_handle = (void *) ENC_OUT_ADDR;
839
+  enc_out_pos = (char *) ENC_OUT_ADDR;
840
+#else
841
     if( !(*p_handle = fopen(psz_filename, "w+b")) )
842
         return -1;
843
+#endif
844
 
845
     return 0;
846
 }
847
@@ -546,9 +600,16 @@
848
 
849
 int write_nalu_bsf( hnd_t handle, uint8_t *p_nalu, int i_size )
850
 {
851
+#ifdef ENC_OUT_ADDR
852
+  V(fprintf(stderr, "write_nalu_bsf: writing %d bytes from 0x%.8x\n", i_size, (unsigned long) enc_out_pos));
853
+  // Just write to the spot in memory and increment the pointer
854
+  int i; for (i=0;i<i_size;i++) *enc_out_pos++ = p_nalu[i];
855
+  return i_size;
856
+#else
857
     if( fwrite( p_nalu, i_size, 1, (FILE*)handle ) > 0 )
858
         return i_size;
859
     return -1;
860
+#endif
861
 }
862
 
863
 int set_eop_bsf( hnd_t handle,  x264_picture_t *p_picture )
864
@@ -558,6 +619,9 @@
865
 
866
 int close_file_bsf( hnd_t handle )
867
 {
868
+#ifdef ENC_OUT_ADDR
869
+  return 0;
870
+#endif
871
     if( !handle || handle == stdout )
872
         return 0;
873
 
874
diff --exclude=.git --exclude=.gitignore -Naur ../x264/muxers.h x264/muxers.h
875
--- ../x264/muxers.h    2009-10-25 17:41:22.000000000 +0100
876
+++ x264/muxers.h       2009-10-27 16:45:55.000000000 +0100
877
@@ -27,6 +27,7 @@
878
 typedef void *hnd_t;
879
 
880
 int open_file_yuv( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param );
881
+void init_yuv_dataspace(char* yuv_dat_addr, hnd_t *p_handle, x264_param_t *p_param);
882
 int get_frame_total_yuv( hnd_t handle );
883
 int read_frame_yuv( x264_picture_t *p_pic, hnd_t handle, int i_frame );
884
 int close_file_yuv( hnd_t handle );
885
diff --exclude=.git --exclude=.gitignore -Naur ../x264/or1ksim_x264.cfg x264/or1ksim_x264.cfg
886
--- ../x264/or1ksim_x264.cfg    1970-01-01 01:00:00.000000000 +0100
887
+++ x264/or1ksim_x264.cfg       2009-10-27 16:45:55.000000000 +0100
888
@@ -0,0 +1,886 @@
889
+/* sim.cfg -- Simulator configuration script file
890
+   Copyright (C) 2001-2002, Marko Mlinar, markom@opencores.org
891
+
892
+This file is part of OpenRISC 1000 Architectural Simulator.
893
+It contains the default configuration and help about configuring
894
+the simulator.
895
+
896
+This program is free software; you can redistribute it and/or modify
897
+it under the terms of the GNU General Public License as published by
898
+the Free Software Foundation; either version 2 of the License, or
899
+(at your option) any later version.
900
+
901
+This program is distributed in the hope that it will be useful,
902
+but WITHOUT ANY WARRANTY; without even the implied warranty of
903
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
904
+GNU General Public License for more details.
905
+
906
+You should have received a copy of the GNU General Public License
907
+along with this program; if not, write to the Free Software
908
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
909
+
910
+
911
+/* INTRODUCTION
912
+
913
+   The ork1sim has various parameters, that are set in configuration files
914
+   like this one. The user can switch between configurations at startup by
915
+   specifying the required configuration file with the -f <filename.cfg> option.
916
+   If no configuration file is specified or1ksim searches for the default
917
+   configuration file sim.cfg. First it searches for './sim.cfg'. If this
918
+   file is not found, it searches for '~/or1k/sim.cfg'. If this file is
919
+   not found too, it reverts to the built-in default configuration.
920
+
921
+   NOTE: Users should not rely on the built-in configuration, since the
922
+         default configuration may differ between version.
923
+         Rather create a configuration file that sets all critical values.
924
+
925
+   This file may contain (standard C) comments only - no // support.
926
+
927
+   Configure files may be be included, using:
928
+   include "file_name_to_include"
929
+
930
+   Like normal configuration files, the included file is divided into
931
+   sections. Each section is described in detail also.
932
+
933
+   Some section have subsections. One example of such a subsection is:
934
+
935
+   device <index>
936
+     instance specific parameters...
937
+   enddevice
938
+
939
+   which creates a device instance.
940
+*/
941
+
942
+
943
+/* MEMORY SECTION
944
+
945
+   This section specifies how the memory is generated and the blocks
946
+   it consists of.
947
+
948
+   type = random/unknown/pattern
949
+      Specifies the initial memory values.
950
+      'random' generates random memory using seed 'random_seed'.
951
+      'pattern' fills memory with 'pattern'.
952
+      'unknown' does not specify how memory should be generated,
953
+      leaving the memory in a undefined state. This is the fastest
954
+      option.
955
+
956
+   random_seed = <value>
957
+      random seed for randomizer, used if type = 'random'.
958
+
959
+   pattern = <value>
960
+      pattern to fill memory, used if type = 'pattern'.
961
+
962
+   nmemories = <value>
963
+      number of memory instances connected
964
+
965
+   baseaddr = <hex_value>
966
+      memory start address
967
+
968
+   size = <hex_value>
969
+      memory size
970
+
971
+   name = "<string>"
972
+      memory block name
973
+
974
+   ce = <value>
975
+      chip enable index of the memory instance
976
+
977
+   mc = <value>
978
+      memory controller this memory is connected to
979
+
980
+   delayr = <value>
981
+      cycles, required for read access, -1 if instance does not support reading
982
+
983
+   delayw = <value>
984
+      cycles, required for write access, -1 if instance does not support writing
985
+
986
+   log = "<filename>"
987
+      filename, where to log memory accesses to, no log, if log command is not specified
988
+*/
989
+
990
+
991
+section memory
992
+  /*random_seed = 12345
993
+  type = random*/
994
+  pattern = 0x00
995
+  type = unknown /* Fastest */
996
+
997
+  name = "FLASH"
998
+  ce = 0
999
+  mc = 0
1000
+  baseaddr = 0xf0000000
1001
+  size = 0x01000000
1002
+  delayr = 10
1003
+  delayw = -1
1004
+end
1005
+
1006
+section memory
1007
+  /*random_seed = 12345
1008
+  type = random*/
1009
+  pattern = 0x00
1010
+  type = unknown /* Fastest */
1011
+
1012
+  name = "RAM"
1013
+  ce = 1
1014
+  mc = 0
1015
+  baseaddr = 0x00000000
1016
+  size = 0x02000000
1017
+  delayr = 20
1018
+  delayw = 25
1019
+end
1020
+
1021
+section memory
1022
+  /*random_seed = 12345
1023
+  type = random*/
1024
+  pattern = 0x00
1025
+  type = unknown /* Fastest */
1026
+
1027
+  name = "SRAM"
1028
+  mc = 0
1029
+  ce = 2
1030
+  baseaddr = 0xa4000000
1031
+  size = 0x00100000
1032
+  delayr = 1
1033
+  delayw = 2
1034
+end
1035
+
1036
+
1037
+/* IMMU SECTION
1038
+
1039
+    This section configures the Instruction Memory Manangement Unit
1040
+
1041
+    enabled = 0/1
1042
+       '0': disabled
1043
+       '1': enabled
1044
+       (NOTE: UPR bit is set)
1045
+
1046
+    nsets = <value>
1047
+       number of ITLB sets; must be power of two
1048
+
1049
+    nways = <value>
1050
+       number of ITLB ways
1051
+
1052
+    pagesize = <value>
1053
+       instruction page size; must be power of two
1054
+
1055
+    entrysize = <value>
1056
+       instruction entry size in bytes
1057
+
1058
+    ustates = <value>
1059
+       number of ITLB usage states (2, 3, 4 etc., max is 4)
1060
+
1061
+    hitdelay = <value>
1062
+       number of cycles immu hit costs
1063
+
1064
+    missdelay = <value>
1065
+       number of cycles immu miss costs
1066
+*/
1067
+
1068
+section immu
1069
+  enabled = 1
1070
+  nsets = 64
1071
+  nways = 1
1072
+  pagesize = 8192
1073
+  hitdelay = 0
1074
+  missdelay = 0
1075
+end
1076
+
1077
+
1078
+/* DMMU SECTION
1079
+
1080
+    This section configures the Data Memory Manangement Unit
1081
+
1082
+    enabled = 0/1
1083
+       '0': disabled
1084
+       '1': enabled
1085
+       (NOTE: UPR bit is set)
1086
+
1087
+    nsets = <value>
1088
+       number of DTLB sets; must be power of two
1089
+
1090
+    nways = <value>
1091
+       number of DTLB ways
1092
+
1093
+    pagesize = <value>
1094
+       data page size; must be power of two
1095
+
1096
+    entrysize = <value>
1097
+       data entry size in bytes
1098
+
1099
+    ustates = <value>
1100
+       number of DTLB usage states (2, 3, 4 etc., max is 4)
1101
+
1102
+    hitdelay = <value>
1103
+       number of cycles dmmu hit costs
1104
+
1105
+    missdelay = <value>
1106
+       number of cycles dmmu miss costs
1107
+*/
1108
+
1109
+section dmmu
1110
+  enabled = 1
1111
+  nsets = 64
1112
+  nways = 1
1113
+  pagesize = 8192
1114
+  hitdelay = 0
1115
+  missdelay = 0
1116
+end
1117
+
1118
+
1119
+/* IC SECTION
1120
+
1121
+   This section configures the Instruction Cache
1122
+
1123
+   enabled = 0/1
1124
+       '0': disabled
1125
+       '1': enabled
1126
+      (NOTE: UPR bit is set)
1127
+
1128
+   nsets = <value>
1129
+      number of IC sets; must be power of two
1130
+
1131
+   nways = <value>
1132
+      number of IC ways
1133
+
1134
+   blocksize = <value>
1135
+      IC block size in bytes; must be power of two
1136
+
1137
+   ustates = <value>
1138
+      number of IC usage states (2, 3, 4 etc., max is 4)
1139
+
1140
+   hitdelay = <value>
1141
+      number of cycles ic hit costs
1142
+
1143
+    missdelay = <value>
1144
+      number of cycles ic miss costs
1145
+*/
1146
+
1147
+section ic
1148
+  enabled = 0
1149
+  nsets = 512
1150
+  nways = 1
1151
+  blocksize = 16
1152
+  hitdelay = 20
1153
+  missdelay = 20
1154
+end
1155
+
1156
+
1157
+/* DC SECTION
1158
+
1159
+   This section configures the Data Cache
1160
+
1161
+   enabled = 0/1
1162
+       '0': disabled
1163
+       '1': enabled
1164
+      (NOTE: UPR bit is set)
1165
+
1166
+   nsets = <value>
1167
+      number of DC sets; must be power of two
1168
+
1169
+   nways = <value>
1170
+      number of DC ways
1171
+
1172
+   blocksize = <value>
1173
+      DC block size in bytes; must be power of two
1174
+
1175
+   ustates = <value>
1176
+      number of DC usage states (2, 3, 4 etc., max is 4)
1177
+
1178
+   load_hitdelay = <value>
1179
+      number of cycles dc load hit costs
1180
+
1181
+   load_missdelay = <value>
1182
+      number of cycles dc load miss costs
1183
+
1184
+   store_hitdelay = <value>
1185
+      number of cycles dc load hit costs
1186
+
1187
+   store_missdelay = <value>
1188
+      number of cycles dc load miss costs
1189
+*/
1190
+
1191
+section dc
1192
+  enabled = 0
1193
+  nsets = 512
1194
+  nways = 1
1195
+  blocksize = 16
1196
+  load_hitdelay = 20
1197
+  load_missdelay = 20
1198
+  store_hitdelay = 20
1199
+  store_missdelay = 20
1200
+end
1201
+
1202
+
1203
+/* SIM SECTION
1204
+
1205
+  This section specifies how or1ksim should behave.
1206
+
1207
+  verbose = 0/1
1208
+       '0': don't print extra messages
1209
+       '1': print extra messages
1210
+
1211
+  debug = 0-9
1212
+      0  : no debug messages
1213
+      1-9: debug message level.
1214
+           higher numbers produce more messages
1215
+
1216
+  profile = 0/1
1217
+      '0': don't generate profiling file 'sim.profile'
1218
+      '1': don't generate profiling file 'sim.profile'
1219
+
1220
+  prof_fn = "<filename>"
1221
+      optional filename for the profiling file.
1222
+      valid only if 'profile' is set
1223
+
1224
+  mprofile = 0/1
1225
+      '0': don't generate memory profiling file 'sim.mprofile'
1226
+      '1': generate memory profiling file 'sim.mprofile'
1227
+
1228
+  mprof_fn = "<filename>"
1229
+      optional filename for the memory profiling file.
1230
+      valid only if 'mprofile' is set
1231
+
1232
+  history = 0/1
1233
+      '0': don't track execution flow
1234
+      '1': track execution flow
1235
+      Execution flow can be tracked for the simulator's
1236
+      'hist' command. Useful for back-trace debugging.
1237
+
1238
+  iprompt = 0/1
1239
+     '0': start in <not interactive prompt> (so what do we start in ???)
1240
+     '1': start in interactive prompt.
1241
+
1242
+  exe_log = 0/1
1243
+      '0': don't generate execution log.
1244
+      '1': generate execution log.
1245
+
1246
+  exe_log = default/hardware/simple/software
1247
+      type of execution log, default is used when not specified
1248
+
1249
+  exe_log_start = <value>
1250
+      index of first instruction to start logging, default = 0
1251
+
1252
+  exe_log_end = <value>
1253
+      index of last instruction to end logging; not limited, if omitted
1254
+
1255
+  exe_log_marker = <value>
1256
+      <value> specifies number of instructions before horizontal marker is
1257
+      printed; if zero, markers are disabled (default)
1258
+
1259
+  exe_log_fn = "<filename>"
1260
+      filename for the exection log file.
1261
+      valid only if 'exe_log' is set
1262
+
1263
+  clkcycle = <value>[ps|ns|us|ms]
1264
+      specifies time measurement for one cycle
1265
+*/
1266
+
1267
+section sim
1268
+  verbose = 1
1269
+  debug = 0
1270
+  profile = 0
1271
+  history = 0
1272
+
1273
+  clkcycle = 10ns
1274
+end
1275
+
1276
+
1277
+/* SECTION VAPI
1278
+
1279
+    This section configures the Verification API, used for Advanced
1280
+    Core Verification.
1281
+
1282
+    enabled = 0/1
1283
+        '0': disbable VAPI server
1284
+        '1': enable/start VAPI server
1285
+
1286
+    server_port = <value>
1287
+        TCP/IP port to start VAPI server on
1288
+
1289
+    log_enabled = 0/1
1290
+       '0': disable VAPI requests logging
1291
+       '1': enable VAPI requests logging
1292
+
1293
+    hide_device_id = 0/1
1294
+       '0': don't log device id (for compatability with old version)
1295
+       '1': log device id
1296
+
1297
+
1298
+    vapi_fn = <filename>
1299
+       filename for the log file.
1300
+       valid only if log_enabled is set
1301
+*/
1302
+
1303
+section VAPI
1304
+  enabled = 0
1305
+  server_port = 9998
1306
+  log_enabled = 0
1307
+  vapi_log_fn = "vapi.log"
1308
+end
1309
+
1310
+
1311
+/* CPU SECTION
1312
+
1313
+   This section specifies various CPU parameters.
1314
+
1315
+   ver = <value>
1316
+   rev = <value>
1317
+      specifies version and revision of the CPU used
1318
+
1319
+   upr = <value>
1320
+      changes the upr register
1321
+
1322
+   sr = <value>
1323
+      sets the initial Supervision Register value
1324
+
1325
+   superscalar = 0/1
1326
+      '0': CPU is scalar
1327
+      '1': CPU is superscalar
1328
+      (modify cpu/or32/execute.c to tune superscalar model)
1329
+
1330
+   hazards = 0/1
1331
+      '0': don't track data hazards in superscalar CPU
1332
+      '1': track data hazards in superscalar CPU
1333
+      If tracked, data hazards can be displayed using the
1334
+      simulator's 'r' command.
1335
+
1336
+   dependstats = 0/1
1337
+      '0': don't calculate inter-instruction dependencies.
1338
+      '1': calculate inter-instruction dependencies.
1339
+      If calculated, inter-instruction dependencies can be
1340
+      displayed using the simulator's 'stat' command.
1341
+
1342
+   sbuf_len = <value>
1343
+      length of store buffer (<= 256), 0 = disabled
1344
+*/
1345
+
1346
+section cpu
1347
+  ver = 0x12
1348
+  cfg = 0x00
1349
+  rev = 0x01
1350
+  /* upr = */
1351
+  superscalar = 0
1352
+  hazards = 0
1353
+  dependstats = 0
1354
+  sbuf_len = 0
1355
+  hardfloat = 1
1356
+end
1357
+
1358
+
1359
+/* PM SECTION
1360
+
1361
+   This section specifies Power Management parameters
1362
+
1363
+   enabled = 0/1
1364
+      '0': disable power management
1365
+      '1': enable power management
1366
+*/
1367
+
1368
+section pm
1369
+  enabled = 0
1370
+end
1371
+
1372
+
1373
+/* BPB SECTION
1374
+
1375
+   This section specifies how branch prediction should behave.
1376
+
1377
+   enabled = 0/1
1378
+     '0': disable branch prediction
1379
+     '1': enable branch prediction
1380
+
1381
+   btic = 0/1
1382
+     '0': disable branch target instruction cache model
1383
+     '1': enable branch target instruction cache model
1384
+
1385
+   sbp_bf_fwd = 0/1
1386
+     Static branch prediction for 'l.bf'
1387
+     '0': don't use forward prediction
1388
+     '1': use forward prediction
1389
+
1390
+   sbp_bnf_fwd = 0/1
1391
+     Static branch prediction for 'l.bnf'
1392
+     '0': don't use forward prediction
1393
+     '1': use forward prediction
1394
+
1395
+   hitdelay = <value>
1396
+       number of cycles bpb hit costs
1397
+
1398
+   missdelay = <value>
1399
+       number of cycles bpb miss costs
1400
+*/
1401
+
1402
+section bpb
1403
+  enabled = 0
1404
+  btic = 0
1405
+  sbp_bf_fwd = 0
1406
+  sbp_bnf_fwd = 0
1407
+  hitdelay = 0
1408
+  missdelay = 0
1409
+end
1410
+
1411
+
1412
+/* DEBUG SECTION
1413
+
1414
+   This sections specifies how the debug unit should behave.
1415
+
1416
+   enabled = 0/1
1417
+      '0': disable debug unit
1418
+      '1': enable debug unit
1419
+
1420
+   gdb_enabled = 0/1
1421
+      '0': don't start gdb server
1422
+      '1': start gdb server at port 'server_port'
1423
+
1424
+   server_port = <value>
1425
+      TCP/IP port to start gdb server on
1426
+      valid only if gdb_enabled is set
1427
+
1428
+   vapi_id = <hex_value>
1429
+      Used to create "fake" vapi log file containing the JTAG proxy messages.
1430
+*/
1431
+section debug
1432
+  enabled = 0
1433
+  rsp_enabled = 0
1434
+  rsp_port = 5554
1435
+  /*server_port = 9999*/
1436
+end
1437
+
1438
+
1439
+/* MC SECTION
1440
+
1441
+   This section configures the memory controller
1442
+
1443
+   enabled = 0/1
1444
+     '0': disable memory controller
1445
+     '1': enable memory controller
1446
+
1447
+   baseaddr = <hex_value>
1448
+      address of first MC register
1449
+
1450
+   POC = <hex_value>
1451
+      Power On Configuration register
1452
+
1453
+   index = <value>
1454
+      Index of this memory controller amongst all the memory controllers
1455
+*/
1456
+
1457
+section mc
1458
+  enabled = 0
1459
+  baseaddr = 0x93000000
1460
+  POC = 0x00000008                 /* Power on configuration register */
1461
+  index = 0
1462
+end
1463
+
1464
+
1465
+/* UART SECTION
1466
+
1467
+   This section configures the UARTs
1468
+
1469
+     enabled = <0|1>
1470
+        Enable/disable the peripheral.  By default if it is enabled.
1471
+
1472
+     baseaddr = <hex_value>
1473
+        address of first UART register for this device
1474
+
1475
+
1476
+     channel = <channeltype>:<args>
1477
+
1478
+        The channel parameter indicates the source of received UART characters
1479
+        and the sink for transmitted UART characters.
1480
+
1481
+        The <channeltype> can be either "file", "xterm", "tcp", "fd", or "tty"
1482
+        (without quotes).
1483
+
1484
+          A) To send/receive characters from a pair of files, use a file
1485
+             channel:
1486
+
1487
+               channel=file:<rxfile>,<txfile>
1488
+
1489
+         B) To create an interactive terminal window, use an xterm channel:
1490
+
1491
+               channel=xterm:[<xterm_arg>]*
1492
+
1493
+         C) To create a bidirectional tcp socket which one could, for example,
1494
+             access via telnet, use a tcp channel:
1495
+
1496
+               channel=tcp:<port number>
1497
+
1498
+         D) To cause the UART to read/write from existing numeric file
1499
+             descriptors, use an fd channel:
1500
+
1501
+               channel=fd:<rx file descriptor num>,<tx file descriptor num>
1502
+
1503
+          E) To connect the UART to a physical serial port, create a tty
1504
+             channel:
1505
+
1506
+              channel=tty:device=/dev/ttyS0,baud=9600
1507
+
1508
+     irq = <value>
1509
+        irq number for this device
1510
+
1511
+     16550 = 0/1
1512
+        '0': this device is a UART16450
1513
+        '1': this device is a UART16550
1514
+
1515
+     jitter = <value>
1516
+        in msecs... time to block, -1 to disable it
1517
+
1518
+     vapi_id = <hex_value>
1519
+        VAPI id of this instance
1520
+*/
1521
+
1522
+section uart
1523
+  enabled = 1
1524
+  baseaddr = 0x90000000
1525
+  irq = 2
1526
+  channel = "file:uart0.rx,uart0.tx"
1527
+  /* channel = "tcp:10084" */
1528
+  /* channel = "xterm:" */
1529
+  jitter = -1                     /* async behaviour */
1530
+  16550 = 1
1531
+end
1532
+
1533
+
1534
+/* DMA SECTION
1535
+
1536
+   This section configures the DMAs
1537
+
1538
+     enabled = <0|1>
1539
+        Enable/disable the peripheral.  By default if it is enabled.
1540
+
1541
+     baseaddr = <hex_value>
1542
+        address of first DMA register for this device
1543
+
1544
+     irq = <value>
1545
+        irq number for this device
1546
+
1547
+     vapi_id = <hex_value>
1548
+        VAPI id of this instance
1549
+*/
1550
+
1551
+section dma
1552
+  enabled = 1
1553
+  baseaddr = 0x9a000000
1554
+  irq = 11
1555
+end
1556
+
1557
+
1558
+/* ETHERNET SECTION
1559
+
1560
+   This section configures the ETHERNETs
1561
+
1562
+     enabled = <0|1>
1563
+        Enable/disable the peripheral.  By default if it is enabled.
1564
+
1565
+     baseaddr = <hex_value>
1566
+        address of first ethernet register for this device
1567
+
1568
+     dma = <value>
1569
+        which controller is this ethernet "connected" to
1570
+
1571
+     irq = <value>
1572
+        ethernet mac IRQ level
1573
+
1574
+     rtx_type = <value>
1575
+        use 0 - file interface, 1 - socket interface
1576
+
1577
+     rx_channel = <value>
1578
+        DMA channel used for RX
1579
+
1580
+     tx_channel = <value>
1581
+        DMA channel used for TX
1582
+
1583
+     rxfile = "<filename>"
1584
+        filename, where to read data from
1585
+
1586
+     txfile = "<filename>"
1587
+        filename, where to write data to
1588
+
1589
+     sockif = "<ifacename>"
1590
+        interface name of ethernet socket
1591
+
1592
+     vapi_id = <hex_value>
1593
+        VAPI id of this instance
1594
+*/
1595
+
1596
+section ethernet
1597
+  enabled = 0
1598
+  baseaddr = 0x92000000
1599
+  /* dma = 0 */
1600
+  irq = 4
1601
+  rtx_type = 0
1602
+  /* tx_channel = 0 */
1603
+  /* rx_channel = 1 */
1604
+  /*rxfile = "eth0.rx"*/
1605
+  txfile = "eth0.tx"
1606
+  sockif = "eth0"
1607
+end
1608
+
1609
+
1610
+/* GPIO SECTION
1611
+
1612
+   This section configures the GPIOs
1613
+
1614
+     enabled = <0|1>
1615
+        Enable/disable the peripheral.  By default if it is enabled.
1616
+
1617
+     baseaddr = <hex_value>
1618
+        address of first GPIO register for this device
1619
+
1620
+     irq = <value>
1621
+        irq number for this device
1622
+
1623
+     base_vapi_id = <hex_value>
1624
+        first VAPI id of this instance
1625
+       GPIO uses 8 consecutive VAPI IDs
1626
+*/
1627
+
1628
+section gpio
1629
+  enabled = 0
1630
+  baseaddr = 0x91000000
1631
+  irq = 3
1632
+  base_vapi_id = 0x0200
1633
+end
1634
+
1635
+/* VGA SECTION
1636
+
1637
+    This section configures the VGA/LCD controller
1638
+
1639
+      enabled = <0|1>
1640
+        Enable/disable the peripheral.  By default if it is enabled.
1641
+
1642
+      baseaddr = <hex_value>
1643
+        address of first VGA register
1644
+
1645
+      irq = <value>
1646
+        irq number for this device
1647
+
1648
+      refresh_rate = <value>
1649
+        number of cycles between screen dumps
1650
+
1651
+      filename = "<filename>"
1652
+        template name for generated names (e.g. "primary" produces "primary0023.bmp")
1653
+*/
1654
+
1655
+section vga
1656
+  enabled = 1
1657
+  baseaddr = 0x97100000
1658
+  irq = 8
1659
+  refresh_rate = 100000
1660
+  filename = "primary"
1661
+end
1662
+
1663
+
1664
+/* TICK TIMER SECTION
1665
+
1666
+    This section configures tick timer
1667
+
1668
+    enabled = 0/1
1669
+      whether tick timer is enabled
1670
+*/
1671
+
1672
+section pic
1673
+  enabled = 1
1674
+  edge_trigger = 1
1675
+end
1676
+
1677
+/* FB SECTION
1678
+
1679
+    This section configures the frame buffer
1680
+
1681
+    enabled = <0|1>
1682
+      Enable/disable the peripheral.  By default if it is enabled.
1683
+
1684
+    baseaddr = <hex_value>
1685
+      base address of frame buffer
1686
+
1687
+    paladdr = <hex_value>
1688
+      base address of first palette entry
1689
+
1690
+    refresh_rate = <value>
1691
+      number of cycles between screen dumps
1692
+
1693
+    filename = "<filename>"
1694
+      template name for generated names (e.g. "primary" produces "primary0023.bmp")
1695
+*/
1696
+
1697
+section fb
1698
+  enabled = 1
1699
+  baseaddr = 0x97000000
1700
+  refresh_rate = 1000000
1701
+  filename = "primary"
1702
+end
1703
+
1704
+
1705
+/* KBD SECTION
1706
+
1707
+    This section configures the PS/2 compatible keyboard
1708
+
1709
+    baseaddr = <hex_value>
1710
+      base address of the keyboard device
1711
+
1712
+    rxfile = "<filename>"
1713
+      filename, where to read data from
1714
+*/
1715
+
1716
+section kbd
1717
+  enabled = 1
1718
+  irq = 5
1719
+  baseaddr = 0x94000000
1720
+  rxfile = "kbd.rx"
1721
+end
1722
+
1723
+
1724
+/* ATA SECTION
1725
+
1726
+    This section configures the ATA/ATAPI host controller
1727
+
1728
+      baseaddr = <hex_value>
1729
+        address of first ATA register
1730
+
1731
+      enabled = <0|1>
1732
+        Enable/disable the peripheral.  By default if it is enabled.
1733
+
1734
+      irq = <value>
1735
+        irq number for this device
1736
+
1737
+      debug = <value>
1738
+        debug level for ata models.
1739
+       0: no debug messages
1740
+       1: verbose messages
1741
+       3: normal messages (more messages than verbose)
1742
+        5: debug messages (normal debug messages)
1743
+       7: flow control messages (debug statemachine flows)
1744
+       9: low priority message (display everything the code does)
1745
+
1746
+      dev_type0/1 = <value>
1747
+        ata device 0 type
1748
+        0: NO_CONNeCT: none (not connected)
1749
+       1: FILE      : simulated harddisk
1750
+       2: LOCAL     : local system harddisk
1751
+
1752
+      dev_file0/1 = "<filename>"
1753
+        filename for simulated ATA device
1754
+       valid only if dev_type0 == 1
1755
+
1756
+      dev_size0/1 = <value>
1757
+        size of simulated hard-disk (in MBytes)
1758
+       valid only if dev_type0 == 1
1759
+
1760
+      dev_packet0/1 = <value>
1761
+        0: simulated ATA device does NOT implement PACKET command feature set
1762
+       1: simulated ATA device does implement PACKET command feature set
1763
+
1764
+   FIXME: irq number
1765
+*/
1766
+
1767
+section ata
1768
+  enabled = 0
1769
+  baseaddr = 0x9e000000
1770
+  irq = 15
1771
+
1772
+end
1773
+
1774
+
1775
diff --exclude=.git --exclude=.gitignore -Naur ../x264/x264.c x264/x264.c
1776
--- ../x264/x264.c      2009-10-25 17:41:22.000000000 +0100
1777
+++ x264/x264.c 2009-10-27 16:45:55.000000000 +0100
1778
@@ -40,6 +40,8 @@
1779
 #define SetConsoleTitle(t)
1780
 #endif
1781
 
1782
+//#include "uart.h"
1783
+
1784
 uint8_t *mux_buffer = NULL;
1785
 int mux_buffer_size = 0;
1786
 
1787
@@ -54,11 +56,11 @@
1788
 }
1789
 
1790
 typedef struct {
1791
-    int b_progress;
1792
-    int i_seek;
1793
-    hnd_t hin;
1794
-    hnd_t hout;
1795
-    FILE *qpfile;
1796
+  int b_progress;
1797
+  int i_seek;
1798
+  hnd_t hin; /* hnd_t is a void* */
1799
+  hnd_t hout;
1800
+  FILE *qpfile;
1801
 } cli_opt_t;
1802
 
1803
 /* input file operation function pointers */
1804
@@ -78,15 +80,28 @@
1805
 static int  Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt );
1806
 static int  Encode( x264_param_t *param, cli_opt_t *opt );
1807
 
1808
-
1809
+int yuv_data_size;
1810
 /****************************************************************************
1811
  * main:
1812
  ****************************************************************************/
1813
 int main( int argc, char **argv )
1814
 {
1815
-    x264_param_t param;
1816
-    cli_opt_t opt;
1817
-    int ret;
1818
+  char* new_argv ="./x264 --profile=baseline";
1819
+  argc = 2;
1820
+
1821
+  x264_param_t param;
1822
+  cli_opt_t opt;
1823
+  int ret;
1824
+
1825
+  //uart_init()  ;
1826
+
1827
+  extern int _end;   // start of free memory
1828
+  extern int _stack; // end of free memory
1829
+
1830
+  V(fprintf( stderr, "start of heap at 0x%.8x, size of heap: %d bytes\n",
1831
+            (unsigned int) &_end, (unsigned int) ((unsigned int) &_stack) - ((unsigned int) &_end)));
1832
+
1833
+  //fprintf(stderr,"start\n");
1834
 
1835
 #ifdef PTW32_STATIC_LIB
1836
     pthread_win32_process_attach_np();
1837
@@ -100,14 +115,74 @@
1838
 
1839
     x264_param_default( &param );
1840
 
1841
-    /* Parse command line */
1842
-    if( Parse( argc, argv, &param, &opt ) < 0 )
1843
-        return -1;
1844
+    // Baseline parameters
1845
+     param.analyse.b_transform_8x8 = 0;
1846
+     param.b_cabac = 0;
1847
+     param.i_cqm_preset = X264_CQM_FLAT;
1848
+     param.i_bframe = 0;
1849
+
1850
+     // Ultrafast preset
1851
+     param.i_frame_reference = 1;
1852
+     param.i_scenecut_threshold = 0;
1853
+     param.b_deblocking_filter = 0;
1854
+     param.b_cabac = 0;
1855
+     param.i_bframe = 0;
1856
+     param.analyse.intra = 0;
1857
+     param.analyse.inter = 0;
1858
+     param.analyse.b_transform_8x8 = 0;
1859
+     param.analyse.i_me_method = X264_ME_DIA;
1860
+     param.analyse.i_subpel_refine = 0;
1861
+     param.rc.i_aq_mode = 0;
1862
+     param.analyse.b_mixed_references = 0;
1863
+     param.analyse.i_trellis = 0;
1864
+     param.i_bframe_adaptive = X264_B_ADAPT_NONE;
1865
+     param.rc.b_mb_tree = 0;
1866
+
1867
+     // Verbose (info per frame encoded)
1868
+     param.i_log_level = X264_LOG_DEBUG;
1869
+
1870
+     // Set a bitrate
1871
+     param.rc.i_bitrate = 1000; // kbps
1872
+     param.rc.i_rc_method = X264_RC_ABR;
1873
+
1874
+     // 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
1875
+     // Defaults here were i_qp_min = 10, i_qp_max = 51
1876
+     param.rc.i_qp_min = 10;
1877
+     param.rc.i_qp_max = 51;
1878
+     param.rc.i_qp_step = 4;
1879
+
1880
+
1881
+     // Picture height and width
1882
+     // CIF = 352x288
1883
+     param.i_width = 352;
1884
+     param.i_height = 288;
1885
+     V(fprintf( stderr, "x264 [info]: %dx%d @ %.2f fps\n",
1886
+               param.i_width, param.i_height,
1887
+               (float)param.i_fps_num / (float)param.i_fps_den));
1888
+
1889
+     V(printf("video file in memory from 0x%.8x, size %d bytes\n", YUV_DATA_ADDR, YUV_DATA_SIZE));
1890
+     /* Must define a few things for use of static CIF data
1891
+       YUV_DATA_ADDR - address where the data starts
1892
+       YUV_DATA_SIZE - size of data in bytes
1893
+       ENC_OUT_ADDR  - where we'll store the encoded data
1894
+     */
1895
+
1896
+     /* Parse command line */
1897
+     Parse( argc, &new_argv, &param, &opt );
1898
+     //if( Parse( argc, &new_argv, &param, &opt ) < 0 )
1899
+     //return -1;
1900
+
1901
+     // We specify a place in memory of some YUV CIF data instad of opening a file
1902
+     init_yuv_dataspace((char *)YUV_DATA_ADDR, (hnd_t *)&opt.hin, &param);
1903
+#ifdef ENC_OUT_ADDR
1904
+     p_open_outfile( 0, &opt.hout ); // Setup the out "file" which is really just a spot in memory
1905
+#endif
1906
+     //opt.hout = (void*) ENC_OUT_ADDR; // We specify a place in memory of where we'll dump the encoded data
1907
 
1908
-    /* Control-C handler */
1909
-    signal( SIGINT, SigIntHandler );
1910
+     /* Control-C handler */
1911
+     //signal( SIGINT, SigIntHandler );
1912
 
1913
-    ret = Encode( &param, &opt );
1914
+   ret = Encode( &param, &opt );
1915
 
1916
 #ifdef PTW32_STATIC_LIB
1917
     pthread_win32_thread_detach_np();
1918
@@ -555,10 +630,12 @@
1919
     /* Default output file driver */
1920
     p_open_outfile = open_file_bsf;
1921
     p_set_outfile_param = set_param_bsf;
1922
-    p_write_nalu = write_nalu_bsf;
1923
+    p_write_nalu = write_nalu_bsf; //--jb
1924
     p_set_eop = set_eop_bsf;
1925
     p_close_outfile = close_file_bsf;
1926
 
1927
+    return 0; // -- added jb
1928
+
1929
     /* Presets are applied before all other options. */
1930
     for( optind = 0;; )
1931
     {
1932
@@ -978,9 +1055,11 @@
1933
         }
1934
         else
1935
         {
1936
-            sscanf( argv[optind++], "%ux%u", &param->i_width, &param->i_height );
1937
-            if( param->i_log_level >= X264_LOG_INFO )
1938
-                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);
1939
+         sscanf( argv[optind++], "%ux%u", &param->i_width, &param->i_height );
1940
+         if( param->i_log_level >= X264_LOG_INFO )
1941
+           fprintf( stderr, "x264 [info]: %dx%d @ %.2f fps\n",
1942
+                    param->i_width, param->i_height,
1943
+                    (double)param->i_fps_num / (double)param->i_fps_den);
1944
         }
1945
     }
1946
 
1947
@@ -1127,7 +1206,10 @@
1948
     {
1949
         i_nalu_size = p_write_nalu( hout, nal[i].p_payload, nal[i].i_payload );
1950
         if( i_nalu_size < 0 )
1951
+         {
1952
+           fprintf(stderr, "Encode_frame: p_write_nalu() returned i_nalu_size < 0: %d\n", i_nalu_size);
1953
             return -1;
1954
+         }
1955
         i_file += i_nalu_size;
1956
     }
1957
     if (i_nal)
1958
@@ -1172,12 +1254,15 @@
1959
     opt->b_progress &= param->i_log_level < X264_LOG_DEBUG;
1960
     i_frame_total = p_get_frame_total( opt->hin );
1961
     i_frame_total -= opt->i_seek;
1962
+
1963
     if( ( i_frame_total == 0 || param->i_frame_total < i_frame_total )
1964
         && param->i_frame_total > 0 )
1965
         i_frame_total = param->i_frame_total;
1966
+
1967
     param->i_frame_total = i_frame_total;
1968
+    V(fprintf(stderr, "Encode: i_frame_total:%d\n", param->i_frame_total));
1969
     i_update_interval = i_frame_total ? x264_clip3( i_frame_total / 1000, 1, 10 ) : 10;
1970
-
1971
+    V(fprintf(stderr, "Encode: i_update_interval:%d\n", i_update_interval));
1972
     if( ( h = x264_encoder_open( param ) ) == NULL )
1973
     {
1974
         fprintf( stderr, "x264 [error]: x264_encoder_open failed\n" );
1975
@@ -1202,6 +1287,7 @@
1976
 
1977
     i_start = x264_mdate();
1978
 
1979
+    V(fprintf(stderr, "Starting Encoder loop: i_frame_total %d\n", i_frame_total));
1980
     /* Encode frames */
1981
     for( i_frame = 0, i_file = 0, i_frame_output = 0; b_ctrl_c == 0 && (i_frame < i_frame_total || i_frame_total == 0); )
1982
     {
1983
diff --exclude=.git --exclude=.gitignore -Naur ../x264/x264.h x264/x264.h
1984
--- ../x264/x264.h      2009-10-25 17:41:22.000000000 +0100
1985
+++ x264/x264.h 2009-10-27 16:45:55.000000000 +0100
1986
@@ -24,6 +24,29 @@
1987
 #ifndef X264_X264_H
1988
 #define X264_X264_H
1989
 
1990
+extern int yuv_data_start;
1991
+extern int yuv_data_end;
1992
+//#define YUV_DATA_ADDR 0x01000000
1993
+#define YUV_DATA_ADDR &yuv_data_start
1994
+#define YUV_DATA_SIZE ((int)(&yuv_data_end) - (int)(YUV_DATA_ADDR))
1995
+#define ENC_OUT_ADDR &yuv_data_end
1996
+
1997
+//#define USE_HARDCODED_FRAME_NUM
1998
+#define HARDCODED_FRAME_NUM 10
1999
+
2000
+
2001
+
2002
+/* Enable for verbose output during runtime */
2003
+//#define X264_VERBOSE
2004
+#ifdef X264_VERBOSE
2005
+#define V(x) x
2006
+#else
2007
+#define V(x)
2008
+#endif
2009
+
2010
+
2011
+extern int yuv_data_size;
2012
+
2013
 #if !defined(_STDINT_H) && !defined(_STDINT_H_) && \
2014
     !defined(_INTTYPES_H) && !defined(_INTTYPES_H_)
2015
 # ifdef _MSC_VER

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.