Mercurial > libavcodec.hg
comparison h264.c @ 5160:13386224ff72 libavcodec
Factor out init_scan_tables(), patch by Andreas ªÓman %andreas A olebyn.nu%
original thread:
Date: Jun 15, 2007 10:10 PM
Subject: [FFmpeg-devel] [PATCH] h264 parallelized, (was: Parallelized h264 proof-of-concept)
author | gpoirier |
---|---|
date | Sat, 16 Jun 2007 19:54:04 +0000 |
parents | b985439e3e15 |
children | 0f6a38c1b63c |
comparison
equal
deleted
inserted
replaced
5159:883a5619f52f | 5160:13386224ff72 |
---|---|
4151 s->current_picture_ptr->poc= FFMIN(field_poc[0], field_poc[1]); | 4151 s->current_picture_ptr->poc= FFMIN(field_poc[0], field_poc[1]); |
4152 | 4152 |
4153 return 0; | 4153 return 0; |
4154 } | 4154 } |
4155 | 4155 |
4156 | |
4157 /** | |
4158 * initialize scan tables | |
4159 */ | |
4160 static void init_scan_tables(H264Context *h){ | |
4161 MpegEncContext * const s = &h->s; | |
4162 int i; | |
4163 if(s->dsp.h264_idct_add == ff_h264_idct_add_c){ //FIXME little ugly | |
4164 memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t)); | |
4165 memcpy(h-> field_scan, field_scan, 16*sizeof(uint8_t)); | |
4166 }else{ | |
4167 for(i=0; i<16; i++){ | |
4168 #define T(x) (x>>2) | ((x<<2) & 0xF) | |
4169 h->zigzag_scan[i] = T(zigzag_scan[i]); | |
4170 h-> field_scan[i] = T( field_scan[i]); | |
4171 #undef T | |
4172 } | |
4173 } | |
4174 if(s->dsp.h264_idct8_add == ff_h264_idct8_add_c){ | |
4175 memcpy(h->zigzag_scan8x8, zigzag_scan8x8, 64*sizeof(uint8_t)); | |
4176 memcpy(h->zigzag_scan8x8_cavlc, zigzag_scan8x8_cavlc, 64*sizeof(uint8_t)); | |
4177 memcpy(h->field_scan8x8, field_scan8x8, 64*sizeof(uint8_t)); | |
4178 memcpy(h->field_scan8x8_cavlc, field_scan8x8_cavlc, 64*sizeof(uint8_t)); | |
4179 }else{ | |
4180 for(i=0; i<64; i++){ | |
4181 #define T(x) (x>>3) | ((x&7)<<3) | |
4182 h->zigzag_scan8x8[i] = T(zigzag_scan8x8[i]); | |
4183 h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]); | |
4184 h->field_scan8x8[i] = T(field_scan8x8[i]); | |
4185 h->field_scan8x8_cavlc[i] = T(field_scan8x8_cavlc[i]); | |
4186 #undef T | |
4187 } | |
4188 } | |
4189 if(h->sps.transform_bypass){ //FIXME same ugly | |
4190 h->zigzag_scan_q0 = zigzag_scan; | |
4191 h->zigzag_scan8x8_q0 = zigzag_scan8x8; | |
4192 h->zigzag_scan8x8_cavlc_q0 = zigzag_scan8x8_cavlc; | |
4193 h->field_scan_q0 = field_scan; | |
4194 h->field_scan8x8_q0 = field_scan8x8; | |
4195 h->field_scan8x8_cavlc_q0 = field_scan8x8_cavlc; | |
4196 }else{ | |
4197 h->zigzag_scan_q0 = h->zigzag_scan; | |
4198 h->zigzag_scan8x8_q0 = h->zigzag_scan8x8; | |
4199 h->zigzag_scan8x8_cavlc_q0 = h->zigzag_scan8x8_cavlc; | |
4200 h->field_scan_q0 = h->field_scan; | |
4201 h->field_scan8x8_q0 = h->field_scan8x8; | |
4202 h->field_scan8x8_cavlc_q0 = h->field_scan8x8_cavlc; | |
4203 } | |
4204 } | |
4156 /** | 4205 /** |
4157 * decodes a slice header. | 4206 * decodes a slice header. |
4158 * this will allso call MPV_common_init() and frame_start() as needed | 4207 * this will allso call MPV_common_init() and frame_start() as needed |
4159 */ | 4208 */ |
4160 static int decode_slice_header(H264Context *h){ | 4209 static int decode_slice_header(H264Context *h){ |
4237 } | 4286 } |
4238 if (!s->context_initialized) { | 4287 if (!s->context_initialized) { |
4239 if (MPV_common_init(s) < 0) | 4288 if (MPV_common_init(s) < 0) |
4240 return -1; | 4289 return -1; |
4241 | 4290 |
4242 if(s->dsp.h264_idct_add == ff_h264_idct_add_c){ //FIXME little ugly | 4291 init_scan_tables(h); |
4243 memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t)); | |
4244 memcpy(h-> field_scan, field_scan, 16*sizeof(uint8_t)); | |
4245 }else{ | |
4246 int i; | |
4247 for(i=0; i<16; i++){ | |
4248 #define T(x) (x>>2) | ((x<<2) & 0xF) | |
4249 h->zigzag_scan[i] = T(zigzag_scan[i]); | |
4250 h-> field_scan[i] = T( field_scan[i]); | |
4251 #undef T | |
4252 } | |
4253 } | |
4254 if(s->dsp.h264_idct8_add == ff_h264_idct8_add_c){ | |
4255 memcpy(h->zigzag_scan8x8, zigzag_scan8x8, 64*sizeof(uint8_t)); | |
4256 memcpy(h->zigzag_scan8x8_cavlc, zigzag_scan8x8_cavlc, 64*sizeof(uint8_t)); | |
4257 memcpy(h->field_scan8x8, field_scan8x8, 64*sizeof(uint8_t)); | |
4258 memcpy(h->field_scan8x8_cavlc, field_scan8x8_cavlc, 64*sizeof(uint8_t)); | |
4259 }else{ | |
4260 int i; | |
4261 for(i=0; i<64; i++){ | |
4262 #define T(x) (x>>3) | ((x&7)<<3) | |
4263 h->zigzag_scan8x8[i] = T(zigzag_scan8x8[i]); | |
4264 h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]); | |
4265 h->field_scan8x8[i] = T(field_scan8x8[i]); | |
4266 h->field_scan8x8_cavlc[i] = T(field_scan8x8_cavlc[i]); | |
4267 #undef T | |
4268 } | |
4269 } | |
4270 if(h->sps.transform_bypass){ //FIXME same ugly | |
4271 h->zigzag_scan_q0 = zigzag_scan; | |
4272 h->zigzag_scan8x8_q0 = zigzag_scan8x8; | |
4273 h->zigzag_scan8x8_cavlc_q0 = zigzag_scan8x8_cavlc; | |
4274 h->field_scan_q0 = field_scan; | |
4275 h->field_scan8x8_q0 = field_scan8x8; | |
4276 h->field_scan8x8_cavlc_q0 = field_scan8x8_cavlc; | |
4277 }else{ | |
4278 h->zigzag_scan_q0 = h->zigzag_scan; | |
4279 h->zigzag_scan8x8_q0 = h->zigzag_scan8x8; | |
4280 h->zigzag_scan8x8_cavlc_q0 = h->zigzag_scan8x8_cavlc; | |
4281 h->field_scan_q0 = h->field_scan; | |
4282 h->field_scan8x8_q0 = h->field_scan8x8; | |
4283 h->field_scan8x8_cavlc_q0 = h->field_scan8x8_cavlc; | |
4284 } | |
4285 | |
4286 alloc_tables(h); | 4292 alloc_tables(h); |
4287 | 4293 |
4288 s->avctx->width = s->width; | 4294 s->avctx->width = s->width; |
4289 s->avctx->height = s->height; | 4295 s->avctx->height = s->height; |
4290 s->avctx->sample_aspect_ratio= h->sps.sar; | 4296 s->avctx->sample_aspect_ratio= h->sps.sar; |