~ubuntu-branches/ubuntu/intrepid/x264/intrepid

« back to all changes in this revision

Viewing changes to common/common.h

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-05-03 01:12:18 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080503011218-3l7ra58egb7gezht
Tags: 1:0.svn20080408-0.0ubuntu1
* Merge from debian-multimedia. Remaining Ubuntu changes:
 - Maintainer field
 - Set epoch

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define XCHG(type,a,b) { type t = a; a = b; b = t; }
37
37
#define FIX8(f) ((int)(f*(1<<8)+.5))
38
38
 
39
 
#ifndef offsetof
40
 
#define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
41
 
#endif
42
 
 
43
39
#define CHECKED_MALLOC( var, size )\
44
40
{\
45
41
    var = x264_malloc( size );\
64
60
 ****************************************************************************/
65
61
#include "osdep.h"
66
62
#include <stdarg.h>
 
63
#include <stddef.h>
67
64
#include <stdlib.h>
68
65
#include <string.h>
69
66
#include <assert.h>
76
73
#include "frame.h"
77
74
#include "dct.h"
78
75
#include "cabac.h"
79
 
#include "csp.h"
80
76
#include "quant.h"
81
77
 
82
78
/****************************************************************************
103
99
 
104
100
void x264_reduce_fraction( int *n, int *d );
105
101
 
 
102
static inline uint8_t x264_clip_uint8( int x )
 
103
{
 
104
    return x&(~255) ? (-x)>>31 : x;
 
105
}
 
106
 
106
107
static inline int x264_clip3( int v, int i_min, int i_max )
107
108
{
108
109
    return ( (v < i_min) ? i_min : (v > i_max) ? i_max : v );
228
229
*/
229
230
 
230
231
typedef struct x264_ratecontrol_t   x264_ratecontrol_t;
231
 
typedef struct x264_vlc_table_t     x264_vlc_table_t;
232
232
 
233
233
struct x264_t
234
234
{
336
336
    /* Current MB DCT coeffs */
337
337
    struct
338
338
    {
339
 
        DECLARE_ALIGNED( int, luma16x16_dc[16], 16 );
340
 
        DECLARE_ALIGNED( int, chroma_dc[2][4], 16 );
341
 
        // FIXME merge with union
342
 
        DECLARE_ALIGNED( int, luma8x8[4][64], 16 );
343
 
        union
344
 
        {
345
 
            DECLARE_ALIGNED( int, residual_ac[15], 16 );
346
 
            DECLARE_ALIGNED( int, luma4x4[16], 16 );
347
 
        } block[16+8];
 
339
        DECLARE_ALIGNED_16( int16_t luma16x16_dc[16] );
 
340
        DECLARE_ALIGNED_16( int16_t chroma_dc[2][4] );
 
341
        // FIXME share memory?
 
342
        DECLARE_ALIGNED_16( int16_t luma8x8[4][64] );
 
343
        DECLARE_ALIGNED_16( int16_t luma4x4[16+8][16] );
348
344
    } dct;
349
345
 
350
346
    /* MB table and cache for current frame/mb */
423
419
        int     i_intra16x16_pred_mode;
424
420
        int     i_chroma_pred_mode;
425
421
 
 
422
        /* skip flags for i4x4 and i8x8
 
423
         * 0 = encode as normal.
 
424
         * 1 (non-RD only) = the DCT is still in h->dct, restore fdec and skip reconstruction.
 
425
         * 2 (RD only) = the DCT has since been overwritten by RD; restore that too. */
 
426
        int i_skip_intra;
 
427
 
426
428
        struct
427
429
        {
428
430
            /* space for p_fenc and p_fdec */
429
431
#define FENC_STRIDE 16
430
432
#define FDEC_STRIDE 32
431
 
            DECLARE_ALIGNED( uint8_t, fenc_buf[24*FENC_STRIDE], 16 );
432
 
            DECLARE_ALIGNED( uint8_t, fdec_buf[27*FDEC_STRIDE], 16 );
 
433
            DECLARE_ALIGNED_16( uint8_t fenc_buf[24*FENC_STRIDE] );
 
434
            DECLARE_ALIGNED_16( uint8_t fdec_buf[27*FDEC_STRIDE] );
 
435
 
 
436
            /* i4x4 and i8x8 backup data, for skipping the encode stage when possible */            
 
437
            DECLARE_ALIGNED_16( uint8_t i4x4_fdec_buf[16*16] );
 
438
            DECLARE_ALIGNED_16( uint8_t i8x8_fdec_buf[16*16] );
 
439
            DECLARE_ALIGNED_16( int16_t i8x8_dct_buf[3][64] );
 
440
            DECLARE_ALIGNED_16( int16_t i4x4_dct_buf[15][16] );
433
441
 
434
442
            /* pointer over mb of the frame to be compressed */
435
443
            uint8_t *p_fenc[3];
450
458
        struct
451
459
        {
452
460
            /* real intra4x4_pred_mode if I_4X4 or I_8X8, I_PRED_4x4_DC if mb available, -1 if not */
453
 
            int     intra4x4_pred_mode[X264_SCAN8_SIZE];
 
461
            int8_t  intra4x4_pred_mode[X264_SCAN8_SIZE];
454
462
 
455
463
            /* i_non_zero_count if available else 0x80 */
456
 
            int     non_zero_count[X264_SCAN8_SIZE];
 
464
            uint8_t non_zero_count[X264_SCAN8_SIZE];
457
465
 
458
466
            /* -1 if unused, -2 if unavailable */
459
 
            int8_t  ref[2][X264_SCAN8_SIZE];
 
467
            DECLARE_ALIGNED_4( int8_t ref[2][X264_SCAN8_SIZE] );
460
468
 
461
469
            /* 0 if not available */
462
 
            int16_t mv[2][X264_SCAN8_SIZE][2];
463
 
            int16_t mvd[2][X264_SCAN8_SIZE][2];
 
470
            DECLARE_ALIGNED_16( int16_t mv[2][X264_SCAN8_SIZE][2] );
 
471
            DECLARE_ALIGNED_4( int16_t mvd[2][X264_SCAN8_SIZE][2] );
464
472
 
465
473
            /* 1 if SKIP or DIRECT. set only for B-frames + CABAC */
466
 
            int8_t  skip[X264_SCAN8_SIZE];
 
474
            DECLARE_ALIGNED_4( int8_t skip[X264_SCAN8_SIZE] );
467
475
 
468
 
            int16_t direct_mv[2][X264_SCAN8_SIZE][2];
 
476
            DECLARE_ALIGNED_16( int16_t direct_mv[2][X264_SCAN8_SIZE][2] );
469
477
            int8_t  direct_ref[2][X264_SCAN8_SIZE];
470
478
            int     pskip_mv[2];
471
479
 
485
493
        int     b_direct_auto_write; /* analyse direct modes, to use and/or save */
486
494
 
487
495
        /* B_direct and weighted prediction */
488
 
        int     dist_scale_factor[16][2];
489
 
        int     bipred_weight[32][4];
 
496
        int16_t dist_scale_factor[16][2];
 
497
        int16_t bipred_weight[32][4];
490
498
        /* maps fref1[0]'s ref indices into the current list0 */
491
 
        int     map_col_to_list0_buf[2]; // for negative indices
492
 
        int     map_col_to_list0[16];
 
499
        int8_t  map_col_to_list0_buf[2]; // for negative indices
 
500
        int8_t  map_col_to_list0[16];
493
501
    } mb;
494
502
 
495
503
    /* rate control encoding only */
530
538
        /* per slice info */
531
539
        int     i_slice_count[5];
532
540
        int64_t i_slice_size[5];
533
 
        int     i_slice_qp[5];
 
541
        double  f_slice_qp[5];
534
542
        /* */
535
543
        int64_t i_sqe_global[5];
536
 
        float   f_psnr_average[5];
537
 
        float   f_psnr_mean_y[5];
538
 
        float   f_psnr_mean_u[5];
539
 
        float   f_psnr_mean_v[5];
540
 
        float   f_ssim_mean_y[5];
 
544
        double  f_psnr_average[5];
 
545
        double  f_psnr_mean_y[5];
 
546
        double  f_psnr_mean_u[5];
 
547
        double  f_psnr_mean_v[5];
 
548
        double  f_ssim_mean_y[5];
541
549
        /* */
542
550
        int64_t i_mb_count[5][19];
543
551
        int64_t i_mb_count_8x8dct[2];
559
567
    x264_mc_functions_t   mc;
560
568
    x264_dct_function_t   dctf;
561
569
    x264_zigzag_function_t zigzagf;
562
 
    x264_csp_function_t   csp;
563
570
    x264_quant_function_t quantf;
564
571
    x264_deblock_function_t loopf;
565
572
 
566
 
    /* vlc table for decoding purpose only */
567
 
    x264_vlc_table_t *x264_coeff_token_lookup[5];
568
 
    x264_vlc_table_t *x264_level_prefix_lookup;
569
 
    x264_vlc_table_t *x264_total_zeros_lookup[15];
570
 
    x264_vlc_table_t *x264_total_zeros_dc_lookup[3];
571
 
    x264_vlc_table_t *x264_run_before_lookup[7];
572
 
 
573
573
#if VISUALIZE
574
574
    struct visualize_t *visualize;
575
575
#endif