Mercurial > libavcodec.hg
comparison h264.c @ 2272:cd43603c46f9 libavcodec
move h264 idct to its own file and call via function pointer in DspContext
allow h264 idct to be used for lowres=1
author | michael |
---|---|
date | Mon, 27 Sep 2004 19:47:17 +0000 |
parents | 507690ff49a2 |
children | 6d26e105f68f |
comparison
equal
deleted
inserted
replaced
2271:859535b5eb57 | 2272:cd43603c46f9 |
---|---|
1321 | 1321 |
1322 return chroma_qp[clip(qscale + h->pps.chroma_qp_index_offset, 0, 51)]; | 1322 return chroma_qp[clip(qscale + h->pps.chroma_qp_index_offset, 0, 51)]; |
1323 } | 1323 } |
1324 | 1324 |
1325 | 1325 |
1326 /** | |
1327 * | |
1328 */ | |
1329 static void h264_add_idct_c(uint8_t *dst, DCTELEM *block, int stride){ | |
1330 int i; | |
1331 uint8_t *cm = cropTbl + MAX_NEG_CROP; | |
1332 | |
1333 block[0] += 32; | |
1334 | |
1335 for(i=0; i<4; i++){ | |
1336 const int z0= block[0 + 4*i] + block[2 + 4*i]; | |
1337 const int z1= block[0 + 4*i] - block[2 + 4*i]; | |
1338 const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i]; | |
1339 const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1); | |
1340 | |
1341 block[0 + 4*i]= z0 + z3; | |
1342 block[1 + 4*i]= z1 + z2; | |
1343 block[2 + 4*i]= z1 - z2; | |
1344 block[3 + 4*i]= z0 - z3; | |
1345 } | |
1346 | |
1347 for(i=0; i<4; i++){ | |
1348 const int z0= block[i + 4*0] + block[i + 4*2]; | |
1349 const int z1= block[i + 4*0] - block[i + 4*2]; | |
1350 const int z2= (block[i + 4*1]>>1) - block[i + 4*3]; | |
1351 const int z3= block[i + 4*1] + (block[i + 4*3]>>1); | |
1352 | |
1353 dst[i + 0*stride]= cm[ dst[i + 0*stride] + ((z0 + z3) >> 6) ]; | |
1354 dst[i + 1*stride]= cm[ dst[i + 1*stride] + ((z1 + z2) >> 6) ]; | |
1355 dst[i + 2*stride]= cm[ dst[i + 2*stride] + ((z1 - z2) >> 6) ]; | |
1356 dst[i + 3*stride]= cm[ dst[i + 3*stride] + ((z0 - z3) >> 6) ]; | |
1357 } | |
1358 } | |
1359 | |
1360 #if 0 | 1326 #if 0 |
1361 static void h264_diff_dct_c(DCTELEM *block, uint8_t *src1, uint8_t *src2, int stride){ | 1327 static void h264_diff_dct_c(DCTELEM *block, uint8_t *src1, uint8_t *src2, int stride){ |
1362 int i; | 1328 int i; |
1363 //FIXME try int temp instead of block | 1329 //FIXME try int temp instead of block |
1364 | 1330 |
2438 } | 2404 } |
2439 | 2405 |
2440 h->pred4x4[ dir ](ptr, topright, linesize); | 2406 h->pred4x4[ dir ](ptr, topright, linesize); |
2441 if(h->non_zero_count_cache[ scan8[i] ]){ | 2407 if(h->non_zero_count_cache[ scan8[i] ]){ |
2442 if(s->codec_id == CODEC_ID_H264) | 2408 if(s->codec_id == CODEC_ID_H264) |
2443 h264_add_idct_c(ptr, h->mb + i*16, linesize); | 2409 s->dsp.h264_idct_add(ptr, h->mb + i*16, linesize); |
2444 else | 2410 else |
2445 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); | 2411 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); |
2446 } | 2412 } |
2447 } | 2413 } |
2448 } | 2414 } |
2465 if(!IS_INTRA4x4(mb_type)){ | 2431 if(!IS_INTRA4x4(mb_type)){ |
2466 if(s->codec_id == CODEC_ID_H264){ | 2432 if(s->codec_id == CODEC_ID_H264){ |
2467 for(i=0; i<16; i++){ | 2433 for(i=0; i<16; i++){ |
2468 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below | 2434 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below |
2469 uint8_t * const ptr= dest_y + h->block_offset[i]; | 2435 uint8_t * const ptr= dest_y + h->block_offset[i]; |
2470 h264_add_idct_c(ptr, h->mb + i*16, linesize); | 2436 s->dsp.h264_idct_add(ptr, h->mb + i*16, linesize); |
2471 } | 2437 } |
2472 } | 2438 } |
2473 }else{ | 2439 }else{ |
2474 for(i=0; i<16; i++){ | 2440 for(i=0; i<16; i++){ |
2475 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below | 2441 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below |
2485 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp); | 2451 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp); |
2486 if(s->codec_id == CODEC_ID_H264){ | 2452 if(s->codec_id == CODEC_ID_H264){ |
2487 for(i=16; i<16+4; i++){ | 2453 for(i=16; i<16+4; i++){ |
2488 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 2454 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
2489 uint8_t * const ptr= dest_cb + h->block_offset[i]; | 2455 uint8_t * const ptr= dest_cb + h->block_offset[i]; |
2490 h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); | 2456 s->dsp.h264_idct_add(ptr, h->mb + i*16, uvlinesize); |
2491 } | 2457 } |
2492 } | 2458 } |
2493 for(i=20; i<20+4; i++){ | 2459 for(i=20; i<20+4; i++){ |
2494 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 2460 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
2495 uint8_t * const ptr= dest_cr + h->block_offset[i]; | 2461 uint8_t * const ptr= dest_cr + h->block_offset[i]; |
2496 h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); | 2462 s->dsp.h264_idct_add(ptr, h->mb + i*16, uvlinesize); |
2497 } | 2463 } |
2498 } | 2464 } |
2499 }else{ | 2465 }else{ |
2500 for(i=16; i<16+4; i++){ | 2466 for(i=16; i<16+4; i++){ |
2501 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 2467 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
3230 buf=GET_CACHE(re, gb); | 3196 buf=GET_CACHE(re, gb); |
3231 | 3197 |
3232 log= 32 - av_log2(buf); | 3198 log= 32 - av_log2(buf); |
3233 #ifdef TRACE | 3199 #ifdef TRACE |
3234 print_bin(buf>>(32-log), log); | 3200 print_bin(buf>>(32-log), log); |
3235 printf("%5d %2d %3d lpr @%5d in %s get_level_prefix\n", buf>>(32-log), log, log-1, get_bits_count(gb), __FILE__); | 3201 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d lpr @%5d in %s get_level_prefix\n", buf>>(32-log), log, log-1, get_bits_count(gb), __FILE__); |
3236 #endif | 3202 #endif |
3237 | 3203 |
3238 LAST_SKIP_BITS(re, gb, log); | 3204 LAST_SKIP_BITS(re, gb, log); |
3239 CLOSE_READER(re, gb); | 3205 CLOSE_READER(re, gb); |
3240 | 3206 |
5973 if(j&1) block[j]= (block[j]*4 + 2)/5; | 5939 if(j&1) block[j]= (block[j]*4 + 2)/5; |
5974 if(j&4) block[j]= (block[j]*4 + 2)/5; | 5940 if(j&4) block[j]= (block[j]*4 + 2)/5; |
5975 } | 5941 } |
5976 // printf("\n"); | 5942 // printf("\n"); |
5977 | 5943 |
5978 h264_add_idct_c(ref, block, 4); | 5944 s->dsp.h264_idct_add(ref, block, 4); |
5979 /* for(j=0; j<16; j++){ | 5945 /* for(j=0; j<16; j++){ |
5980 printf("%d ", ref[j]); | 5946 printf("%d ", ref[j]); |
5981 } | 5947 } |
5982 printf("\n");*/ | 5948 printf("\n");*/ |
5983 | 5949 |