diff options
Diffstat (limited to 'all_pairs/source/mpeg2/mpeg2.c')
| -rw-r--r-- | all_pairs/source/mpeg2/mpeg2.c | 13218 |
1 files changed, 13218 insertions, 0 deletions
diff --git a/all_pairs/source/mpeg2/mpeg2.c b/all_pairs/source/mpeg2/mpeg2.c new file mode 100644 index 0000000..e89e1f9 --- /dev/null +++ b/all_pairs/source/mpeg2/mpeg2.c | |||
| @@ -0,0 +1,13218 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | This program is part of the TACLeBench benchmark suite. | ||
| 4 | Version V 2.0 | ||
| 5 | |||
| 6 | Name: mpeg2 | ||
| 7 | |||
| 8 | Author: MPEG Software Simulation Group | ||
| 9 | |||
| 10 | Function: This file contains MPEG 2 motion estimation code. | ||
| 11 | |||
| 12 | Source: MediaBench II | ||
| 13 | http://euler.slu.edu/~fritts/mediabench (mirror) | ||
| 14 | |||
| 15 | Original name: MPEG-2 | ||
| 16 | |||
| 17 | Changes: For TACLeBench, the code has been changed such that input and | ||
| 18 | output arrays are scaled down so that the code plus its data fits to the | ||
| 19 | memories of typical resource-constrained embedded devices. | ||
| 20 | |||
| 21 | License: See the following disclaimer from the original source codes. | ||
| 22 | |||
| 23 | Disclaimer of Warranty | ||
| 24 | |||
| 25 | These software programs are available to the user without any license fee or | ||
| 26 | royalty on an "as is" basis. The MPEG Software Simulation Group disclaims | ||
| 27 | any and all warranties, whether express, implied, or statuary, including any | ||
| 28 | implied warranties or merchantability or of fitness for a particular | ||
| 29 | purpose. In no event shall the copyright-holder be liable for any | ||
| 30 | incidental, punitive, or consequential damages of any kind whatsoever | ||
| 31 | arising from the use of these programs. | ||
| 32 | |||
| 33 | This disclaimer of warranty extends to the user of these programs and user's | ||
| 34 | customers, employees, agents, transferees, successors, and assigns. | ||
| 35 | |||
| 36 | The MPEG Software Simulation Group does not represent or warrant that the | ||
| 37 | programs furnished hereunder are free of infringement of any third-party | ||
| 38 | patents. | ||
| 39 | |||
| 40 | Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, | ||
| 41 | are subject to royalty fees to patent holders. Many of these patents are | ||
| 42 | general enough such that they are unavoidable regardless of implementation | ||
| 43 | design. | ||
| 44 | |||
| 45 | */ | ||
| 46 | |||
| 47 | |||
| 48 | /* | ||
| 49 | Forward declaration of data types | ||
| 50 | */ | ||
| 51 | #include "../extra.h" | ||
| 52 | struct mbinfo; | ||
| 53 | |||
| 54 | |||
| 55 | /* | ||
| 56 | Forward declaration of functions | ||
| 57 | */ | ||
| 58 | |||
| 59 | void mpeg2_init( void ); | ||
| 60 | int mpeg2_return( void ); | ||
| 61 | void mpeg2_motion_estimation( unsigned char *, unsigned char *, unsigned char *, | ||
| 62 | unsigned char *, unsigned char *, unsigned char *, | ||
| 63 | int, int, int, int, struct mbinfo *, int, int ); | ||
| 64 | void mpeg2_frame_ME( unsigned char *, unsigned char *, unsigned char *, | ||
| 65 | unsigned char *, unsigned char *, int, int, int, int, int, | ||
| 66 | int, struct mbinfo * ); | ||
| 67 | void mpeg2_field_ME( unsigned char *, unsigned char *, unsigned char *, | ||
| 68 | unsigned char *, unsigned char *, unsigned char *, int, | ||
| 69 | int, int, int, int, int, struct mbinfo *, int, int ); | ||
| 70 | void mpeg2_frame_estimate( unsigned char *, unsigned char *, unsigned char *, | ||
| 71 | int, int, int, int, int *, int *, int *, int *, | ||
| 72 | int *, int *, int *, int *, int *, int *, | ||
| 73 | int[ 2 ][ 2 ], int[ 2 ][ 2 ] ); | ||
| 74 | void mpeg2_field_estimate( unsigned char *, unsigned char *, unsigned char *, | ||
| 75 | unsigned char *, unsigned char *, int, int, int, int, | ||
| 76 | int, int *, int *, int *, int *, int *, int *, int *, | ||
| 77 | int *, int *, int *, int *, int *, int *, int * ); | ||
| 78 | void mpeg2_dpframe_estimate( unsigned char *, unsigned char *, int, int, | ||
| 79 | int[ 2 ][ 2 ], int[ 2 ][ 2 ], int *, int *, int *, | ||
| 80 | int *, int *, int * ); | ||
| 81 | void mpeg2_dpfield_estimate( unsigned char *, unsigned char *, unsigned char *, | ||
| 82 | int, int, int, int, int *, int *, int *, int * ); | ||
| 83 | int mpeg2_fullsearch( unsigned char *, unsigned char *, unsigned char *, int, | ||
| 84 | int, int, int, int, int, int, int, int *, int * ); | ||
| 85 | int mpeg2_dist1( unsigned char *, unsigned char *, int, int, int, int, int ); | ||
| 86 | int mpeg2_dist2( unsigned char *, unsigned char *, int, int, int, int ); | ||
| 87 | int mpeg2_bdist1( unsigned char *, unsigned char *, unsigned char *, int, int, | ||
| 88 | int, int, int, int ); | ||
| 89 | int mpeg2_bdist2( unsigned char *, unsigned char *, unsigned char *, int, int, | ||
| 90 | int, int, int, int ); | ||
| 91 | int mpeg2_variance( unsigned char *, int ); | ||
| 92 | void mpeg2_main( void ); | ||
| 93 | //int main( void ); | ||
| 94 | |||
| 95 | |||
| 96 | /* | ||
| 97 | Declaration of global variables | ||
| 98 | */ | ||
| 99 | |||
| 100 | struct mbinfo { | ||
| 101 | int mb_type; | ||
| 102 | int motion_type; | ||
| 103 | int dct_type; | ||
| 104 | int mquant; | ||
| 105 | int cbp; | ||
| 106 | int skipped; | ||
| 107 | int MV[ 2 ][ 2 ][ 2 ]; | ||
| 108 | int mv_field_sel[ 2 ][ 2 ]; | ||
| 109 | int dmvector[ 2 ]; | ||
| 110 | double act; | ||
| 111 | int var; | ||
| 112 | }; | ||
| 113 | |||
| 114 | volatile int mpeg2_width = 352; | ||
| 115 | volatile int mpeg2_height = 256; | ||
| 116 | volatile int mpeg2_width2 = 352; | ||
| 117 | volatile int mpeg2_height2 = 256; | ||
| 118 | volatile int mpeg2_M = 3; | ||
| 119 | volatile int mpeg2_pict_type = 3; | ||
| 120 | volatile int mpeg2_pict_struct = 3; | ||
| 121 | volatile int mpeg2_topfirst = 1; | ||
| 122 | volatile int mpeg2_frame_pred_dct = 0; | ||
| 123 | struct mbinfo mpeg2_mbinfo[ 352 ]; | ||
| 124 | |||
| 125 | unsigned char mpeg2_oldorgframe[] = { | ||
| 126 | 0x9f, 0x9d, 0x9b, 0x9d, 0x9f, 0xa1, 0xa2, 0xa3, | ||
| 127 | 0x9e, 0xa2, 0xa5, 0xa5, 0xa2, 0xa1, 0xa4, 0xa7, | ||
| 128 | 0xa3, 0xa3, 0xa5, 0xa6, 0xa5, 0xa5, 0xa3, 0xa2, | ||
| 129 | 0x9d, 0xa1, 0xa5, 0xa8, 0xa6, 0xa1, 0x9a, 0x95, | ||
| 130 | 0x8e, 0x7e, 0x7a, 0x78, 0x70, 0x76, 0x7c, 0x73, | ||
| 131 | 0x7d, 0x7a, 0x7a, 0x79, 0x7b, 0x83, 0x82, 0x74, | ||
| 132 | 0x64, 0x57, 0x48, 0x5e, 0x7e, 0x84, 0x6f, 0x4a, | ||
| 133 | 0x31, 0x43, 0x61, 0x81, 0x9b, 0xac, 0xb6, 0xb9, | ||
| 134 | 0xb0, 0xa8, 0x9e, 0x9a, 0x9b, 0xa1, 0xaa, 0xb1, | ||
| 135 | 0x9d, 0x83, 0x65, 0x49, 0x33, 0x30, 0x34, 0x32, | ||
| 136 | 0x4b, 0x54, 0x68, 0x83, 0x99, 0x9f, 0x94, 0x87, | ||
| 137 | 0x4f, 0x5e, 0x72, 0x7f, 0x75, 0x52, 0x23, 0x02, | ||
| 138 | 0x1a, 0x24, 0x24, 0x1b, 0x14, 0x13, 0x1e, 0x30, | ||
| 139 | 0x43, 0x60, 0x7b, 0x8a, 0x96, 0x9c, 0x97, 0x90, | ||
| 140 | 0x99, 0x99, 0x92, 0x88, 0x7f, 0x80, 0x97, 0xb5, | ||
| 141 | 0xa0, 0x94, 0x9a, 0x96, 0x66, 0x2d, 0x14, 0x12, | ||
| 142 | 0x15, 0x17, 0x27, 0x1c, 0x15, 0x1e, 0x25, 0x3b, | ||
| 143 | 0x7a, 0xa2, 0xbe, 0xbf, 0xb2, 0x9f, 0x9e, 0xaf, | ||
| 144 | 0xba, 0x7b, 0x64, 0x8a, 0xa9, 0xa7, 0xa4, 0xaa, | ||
| 145 | 0xa8, 0xab, 0xad, 0xab, 0xa7, 0xa6, 0xaa, 0xaf, | ||
| 146 | 0xa4, 0xa6, 0xa9, 0xab, 0xac, 0xac, 0xaa, 0xa9, | ||
| 147 | 0xa7, 0xaf, 0xba, 0xbc, 0xaf, 0x94, 0x75, 0x60, | ||
| 148 | 0x7a, 0x85, 0x90, 0x9a, 0xa7, 0xa2, 0x7c, 0x50, | ||
| 149 | 0x2f, 0x48, 0x65, 0x77, 0x7e, 0x8b, 0xa3, 0xb7, | ||
| 150 | 0xae, 0x95, 0x7a, 0x6f, 0x75, 0x79, 0x73, 0x69, | ||
| 151 | 0x56, 0x63, 0x6e, 0x6e, 0x6a, 0x6b, 0x72, 0x78, | ||
| 152 | 0x65, 0x67, 0x61, 0x51, 0x3f, 0x36, 0x3b, 0x43, | ||
| 153 | 0x33, 0x24, 0x25, 0x3d, 0x4d, 0x4b, 0x48, 0x4d, | ||
| 154 | 0x57, 0x4b, 0x42, 0x47, 0x56, 0x62, 0x63, 0x5f, | ||
| 155 | 0x60, 0x6d, 0x6f, 0x5b, 0x3f, 0x38, 0x4d, 0x67, | ||
| 156 | 0x4c, 0x3c, 0x2d, 0x2f, 0x3a, 0x3e, 0x33, 0x25, | ||
| 157 | 0x3b, 0x4e, 0x6d, 0x84, 0x82, 0x75, 0x71, 0x78, | ||
| 158 | 0x7f, 0x78, 0x6c, 0x61, 0x5a, 0x58, 0x5a, 0x5d, | ||
| 159 | 0x69, 0x64, 0x59, 0x4c, 0x41, 0x3c, 0x3f, 0x43, | ||
| 160 | 0x32, 0x3c, 0x26, 0x26, 0x2f, 0x2b, 0x2e, 0x1f, | ||
| 161 | 0x34, 0x8e, 0xbb, 0xaf, 0xae, 0xb0, 0xa7, 0xa8, | ||
| 162 | 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, | ||
| 163 | 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, | ||
| 164 | 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, | ||
| 165 | 0xa8, 0xa5, 0xa4, 0xa5, 0xa7, 0xa7, 0xa5, 0xa4, | ||
| 166 | 0xa0, 0xac, 0xa1, 0x97, 0xa7, 0xac, 0xa5, 0xa9, | ||
| 167 | 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, | ||
| 168 | 0xa7, 0xa6, 0xa6, 0xa5, 0xa5, 0xa4, 0xa4, 0xa3, | ||
| 169 | 0x9e, 0xa0, 0x9d, 0x9a, 0xa1, 0x95, 0x1d, 0x06, | ||
| 170 | 0x8b, 0x86, 0x87, 0x8e, 0x95, 0x94, 0x90, 0x8d, | ||
| 171 | 0x92, 0x94, 0x97, 0x9b, 0x9f, 0xa0, 0x9e, 0x9d, | ||
| 172 | 0x99, 0x9b, 0x9e, 0x9d, 0x98, 0x8e, 0x83, 0x7c, | ||
| 173 | 0x80, 0x7b, 0x76, 0x74, 0x78, 0x83, 0x8f, 0x97, | ||
| 174 | 0x92, 0x8f, 0x99, 0xaf, 0xb8, 0xa8, 0x99, 0x9b, | ||
| 175 | 0x97, 0xb9, 0xc0, 0xb5, 0xb2, 0x9e, 0x8a, 0x90, | ||
| 176 | 0xa7, 0xc1, 0x9d, 0x6a, 0x56, 0x4a, 0x48, 0x4c, | ||
| 177 | 0x58, 0x86, 0xb9, 0xca, 0xb8, 0xa1, 0x9c, 0xa1, | ||
| 178 | 0xbd, 0xc1, 0xba, 0x99, 0x63, 0x30, 0x11, 0x06, | ||
| 179 | 0x1b, 0x33, 0x5d, 0x7f, 0x91, 0xa7, 0xbf, 0xcb, | ||
| 180 | 0xbb, 0xb5, 0xb1, 0xb2, 0xb5, 0xb0, 0xa2, 0x95, | ||
| 181 | 0xca, 0xc3, 0xa6, 0x74, 0x4f, 0x5d, 0x99, 0xd1, | ||
| 182 | 0xcb, 0xbb, 0xb0, 0x95, 0x69, 0x54, 0x52, 0x48, | ||
| 183 | 0x5a, 0x51, 0x3d, 0x42, 0x5d, 0x64, 0x73, 0x9c, | ||
| 184 | 0x9d, 0x91, 0x96, 0x9f, 0x9b, 0x98, 0x91, 0x7f, | ||
| 185 | 0x64, 0x41, 0x15, 0x12, 0x39, 0x5f, 0x74, 0x83, | ||
| 186 | 0x86, 0x80, 0x7b, 0x84, 0x8a, 0x7c, 0x5e, 0x41, | ||
| 187 | 0x36, 0x42, 0x6f, 0xa7, 0xbb, 0xa8, 0x91, 0x89, | ||
| 188 | 0x88, 0x98, 0xb2, 0xbc, 0xb2, 0xae, 0xb3, 0xb4, | ||
| 189 | 0xb6, 0xb4, 0xb3, 0xb5, 0xb9, 0xbb, 0xbc, 0xbb, | ||
| 190 | 0xb6, 0xb6, 0xb6, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, | ||
| 191 | 0x9d, 0x80, 0x61, 0x5e, 0x79, 0x9c, 0xb3, 0xbb, | ||
| 192 | 0xca, 0xc1, 0xaf, 0xa3, 0xac, 0xb9, 0xaf, 0x98, | ||
| 193 | 0x6e, 0x48, 0x2b, 0x41, 0x7a, 0xa5, 0xa7, 0x96, | ||
| 194 | 0x9d, 0x87, 0x6e, 0x65, 0x6c, 0x72, 0x6e, 0x67, | ||
| 195 | 0x66, 0x78, 0x7d, 0x76, 0x7f, 0x96, 0x99, 0x89, | ||
| 196 | 0x6a, 0x78, 0x87, 0x8a, 0x80, 0x72, 0x6a, 0x68, | ||
