comparison h264.c @ 7423:2eb0e5a2efad libavcodec

left_block intialisation optimisation. This patch changes the left_block initialisation code in the fill_caches function from individual array element setters to a simple pointer to a pre-initialised array. Patch by (Paul Kendall ! paul X kcbbs knodel gen knodel nz) Date: Sun, 27 Jul 2008 11:40:18 +1200 Subject: [FFmpeg-devel] [PATCH] h264 fill_caches left_block intialisation optimisation
author michael
date Sun, 27 Jul 2008 13:01:17 +0000
parents 74534206d329
children 69766900be2d
comparison
equal deleted inserted replaced
7422:e29ac68d3152 7423:2eb0e5a2efad
77 77
78 const uint8_t ff_div6[52]={ 78 const uint8_t ff_div6[52]={
79 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 79 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
80 }; 80 };
81 81
82 static const int left_block_options[4][8]={
83 {0,1,2,3,7,10,8,11},
84 {2,2,3,3,8,11,8,11},
85 {0,0,1,1,7,10,7,10},
86 {0,2,0,2,7,10,7,10}
87 };
82 88
83 static void fill_caches(H264Context *h, int mb_type, int for_deblock){ 89 static void fill_caches(H264Context *h, int mb_type, int for_deblock){
84 MpegEncContext * const s = &h->s; 90 MpegEncContext * const s = &h->s;
85 const int mb_xy= h->mb_xy; 91 const int mb_xy= h->mb_xy;
86 int topleft_xy, top_xy, topright_xy, left_xy[2]; 92 int topleft_xy, top_xy, topright_xy, left_xy[2];
87 int topleft_type, top_type, topright_type, left_type[2]; 93 int topleft_type, top_type, topright_type, left_type[2];
88 int left_block[8]; 94 int * left_block;
89 int topleft_partition= -1; 95 int topleft_partition= -1;
90 int i; 96 int i;
91 97
92 top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE); 98 top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE);
93 99
99 * stuff, I can't imagine that these complex rules are worth it. */ 105 * stuff, I can't imagine that these complex rules are worth it. */
100 106
101 topleft_xy = top_xy - 1; 107 topleft_xy = top_xy - 1;
102 topright_xy= top_xy + 1; 108 topright_xy= top_xy + 1;
103 left_xy[1] = left_xy[0] = mb_xy-1; 109 left_xy[1] = left_xy[0] = mb_xy-1;
104 left_block[0]= 0; 110 left_block = left_block_options[0];
105 left_block[1]= 1;
106 left_block[2]= 2;
107 left_block[3]= 3;
108 left_block[4]= 7;
109 left_block[5]= 10;
110 left_block[6]= 8;
111 left_block[7]= 11;
112 if(FRAME_MBAFF){ 111 if(FRAME_MBAFF){
113 const int pair_xy = s->mb_x + (s->mb_y & ~1)*s->mb_stride; 112 const int pair_xy = s->mb_x + (s->mb_y & ~1)*s->mb_stride;
114 const int top_pair_xy = pair_xy - s->mb_stride; 113 const int top_pair_xy = pair_xy - s->mb_stride;
115 const int topleft_pair_xy = top_pair_xy - 1; 114 const int topleft_pair_xy = top_pair_xy - 1;
116 const int topright_pair_xy = top_pair_xy + 1; 115 const int topright_pair_xy = top_pair_xy + 1;
145 } 144 }
146 if (left_mb_frame_flag != curr_mb_frame_flag) { 145 if (left_mb_frame_flag != curr_mb_frame_flag) {
147 left_xy[1] = left_xy[0] = pair_xy - 1; 146 left_xy[1] = left_xy[0] = pair_xy - 1;
148 if (curr_mb_frame_flag) { 147 if (curr_mb_frame_flag) {
149 if (bottom) { 148 if (bottom) {
150 left_block[0]= 2; 149 left_block = left_block_options[1];
151 left_block[1]= 2;
152 left_block[2]= 3;
153 left_block[3]= 3;
154 left_block[4]= 8;
155 left_block[5]= 11;
156 left_block[6]= 8;
157 left_block[7]= 11;
158 } else { 150 } else {
159 left_block[0]= 0; 151 left_block= left_block_options[2];
160 left_block[1]= 0;
161 left_block[2]= 1;
162 left_block[3]= 1;
163 left_block[4]= 7;
164 left_block[5]= 10;
165 left_block[6]= 7;
166 left_block[7]= 10;
167 } 152 }
168 } else { 153 } else {
169 left_xy[1] += s->mb_stride; 154 left_xy[1] += s->mb_stride;
170 //left_block[0]= 0; 155 left_block = left_block_options[3];
171 left_block[1]= 2;
172 left_block[2]= 0;
173 left_block[3]= 2;
174 //left_block[4]= 7;
175 left_block[5]= 10;
176 left_block[6]= 7;
177 left_block[7]= 10;
178 } 156 }
179 } 157 }
180 } 158 }
181 159
182 h->top_mb_xy = top_xy; 160 h->top_mb_xy = top_xy;