[svn] / trunk / xvidcore / src / bitstream / cbp.c Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/bitstream/cbp.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 912 - (view) (download)

1 : Isibaar 3 #include "../portab.h"
2 :     #include "cbp.h"
3 :    
4 :     cbpFuncPtr calc_cbp;
5 :    
6 : edgomez 46 /*
7 :     * Returns a field of bits that indicates non zero ac blocks
8 :     * for this macro block
9 :     */
10 : chl 911
11 :     /* naive C */
12 : edgomez 195 uint32_t
13 : chl 911 calc_cbp_plain(const int16_t codes[6 * 64])
14 : Isibaar 3 {
15 : chl 911 int i, j;
16 : edgomez 46 uint32_t cbp = 0;
17 : Isibaar 3
18 : edgomez 195 for (i = 0; i < 6; i++) {
19 : chl 911 for (j=1; j<64;j++) {
20 :     if (codes[64*i+j]) {
21 :     cbp |= 1 << (5-i);
22 : Isibaar 3 break;
23 :     }
24 :     }
25 : chl 911 }
26 :     return cbp;
27 :     }
28 : edgomez 46
29 : chl 911 /* optimized C */
30 :     uint32_t
31 :     calc_cbp_c(const int16_t codes[6 * 64])
32 :     {
33 : chl 912 unsigned int i=6;
34 : chl 911 uint32_t cbp = 0;
35 : edgomez 46
36 : chl 912 /* uses fixed relation: 4*codes = 1*codes64 */
37 :     /* if prototype is changed (e.g. from int16_t to something like int32) this routine
38 :     has to be changed! */
39 : chl 911
40 : chl 912 do {
41 :     uint64_t *codes64 = (uint64_t*)codes; /* the compiler doesn't really make this */
42 :     uint32_t *codes32 = (uint32_t*)codes; /* variables, just "addressing modes" */
43 :    
44 : chl 911 cbp += cbp;
45 : chl 912 if (codes[1] || codes32[1]) {
46 : chl 911 cbp++;
47 :     }
48 : chl 912 else if (codes64[1] | codes64[2] | codes64[3]) {
49 : chl 911 cbp++;
50 :     }
51 : chl 912 else if (codes64[4] | codes64[5] | codes64[6] | codes64[7]) {
52 : chl 911 cbp++;
53 :     }
54 : chl 912 else if (codes64[8] | codes64[9] | codes64[10] | codes64[11]) {
55 : chl 911 cbp++;
56 :     }
57 : chl 912 else if (codes64[12] | codes64[13] | codes64[14] | codes64[15]) {
58 : chl 911 cbp++;
59 :     }
60 : chl 912 codes += 64;
61 :     i--;
62 :     } while (i != 0);
63 : chl 911
64 :     return cbp;
65 :     }
66 :    
67 :    
68 :    
69 :    
70 :     /* older code maybe better on some plattforms? */
71 :     #if (0==1)
72 :     for (i = 5; i >= 0; i--) {
73 :     if (codes[1] | codes[2] | codes[3])
74 :     cbp |= 1 << i;
75 :     else {
76 :     for (j = 4; j <= 56; j+=4) /* [60],[61],[62],[63] are last */
77 :     if (codes[j] | codes[j+1] | codes[j+2] | codes[j+3]) {
78 :     cbp |= 1 << i;
79 :     break;
80 :     }
81 :     }
82 :     codes += 64;
83 : edgomez 46 }
84 :    
85 :     return cbp;
86 : chl 911 #endif

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4