Mercurial > libavcodec.hg
comparison h264.c @ 10863:974ac220c93a libavcodec
Move check_intra4x4_pred_mode() back from h264.h to h264.c, the function is just
called once per MB in worst case and doesnt seem to benefit from static inline.
Actually the code might be a hair faster now (0.1% according to my benchmark but
this could be random noise)
author | michael |
---|---|
date | Tue, 12 Jan 2010 21:17:26 +0000 |
parents | d9c084a0c22b |
children | e3f5eb016712 |
comparison
equal
deleted
inserted
replaced
10862:d9c084a0c22b | 10863:974ac220c93a |
---|---|
538 h->intra4x4_pred_mode[mb_xy][3]= h->intra4x4_pred_mode_cache[7+8*4]; | 538 h->intra4x4_pred_mode[mb_xy][3]= h->intra4x4_pred_mode_cache[7+8*4]; |
539 h->intra4x4_pred_mode[mb_xy][4]= h->intra4x4_pred_mode_cache[4+8*4]; | 539 h->intra4x4_pred_mode[mb_xy][4]= h->intra4x4_pred_mode_cache[4+8*4]; |
540 h->intra4x4_pred_mode[mb_xy][5]= h->intra4x4_pred_mode_cache[5+8*4]; | 540 h->intra4x4_pred_mode[mb_xy][5]= h->intra4x4_pred_mode_cache[5+8*4]; |
541 h->intra4x4_pred_mode[mb_xy][6]= h->intra4x4_pred_mode_cache[6+8*4]; | 541 h->intra4x4_pred_mode[mb_xy][6]= h->intra4x4_pred_mode_cache[6+8*4]; |
542 } | 542 } |
543 | |
544 /** | |
545 * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. | |
546 */ | |
547 int ff_h264_check_intra4x4_pred_mode(H264Context *h){ | |
548 MpegEncContext * const s = &h->s; | |
549 static const int8_t top [12]= {-1, 0,LEFT_DC_PRED,-1,-1,-1,-1,-1, 0}; | |
550 static const int8_t left[12]= { 0,-1, TOP_DC_PRED, 0,-1,-1,-1, 0,-1,DC_128_PRED}; | |
551 int i; | |
552 | |
553 if(!(h->top_samples_available&0x8000)){ | |
554 for(i=0; i<4; i++){ | |
555 int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ]; | |
556 if(status<0){ | |
557 av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y); | |
558 return -1; | |
559 } else if(status){ | |
560 h->intra4x4_pred_mode_cache[scan8[0] + i]= status; | |
561 } | |
562 } | |
563 } | |
564 | |
565 if((h->left_samples_available&0x8888)!=0x8888){ | |
566 static const int mask[4]={0x8000,0x2000,0x80,0x20}; | |
567 for(i=0; i<4; i++){ | |
568 if(!(h->left_samples_available&mask[i])){ | |
569 int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ]; | |
570 if(status<0){ | |
571 av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y); | |
572 return -1; | |
573 } else if(status){ | |
574 h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status; | |
575 } | |
576 } | |
577 } | |
578 } | |
579 | |
580 return 0; | |
581 } //FIXME cleanup like ff_h264_check_intra_pred_mode | |
543 | 582 |
544 /** | 583 /** |
545 * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. | 584 * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. |
546 */ | 585 */ |
547 int ff_h264_check_intra_pred_mode(H264Context *h, int mode){ | 586 int ff_h264_check_intra_pred_mode(H264Context *h, int mode){ |
3275 fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 ); | 3314 fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 ); |
3276 else | 3315 else |
3277 h->intra4x4_pred_mode_cache[ scan8[i] ] = mode; | 3316 h->intra4x4_pred_mode_cache[ scan8[i] ] = mode; |
3278 } | 3317 } |
3279 ff_h264_write_back_intra_pred_mode(h); | 3318 ff_h264_write_back_intra_pred_mode(h); |
3280 if( check_intra4x4_pred_mode(h) < 0) | 3319 if( ff_h264_check_intra4x4_pred_mode(h) < 0) |
3281 return -1; | 3320 return -1; |
3282 }else{ | 3321 }else{ |
3283 h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode(h, h->intra16x16_pred_mode); | 3322 h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode(h, h->intra16x16_pred_mode); |
3284 if(h->intra16x16_pred_mode < 0) | 3323 if(h->intra16x16_pred_mode < 0) |
3285 return -1; | 3324 return -1; |
4376 | 4415 |
4377 //av_log( s->avctx, AV_LOG_ERROR, "i4x4 pred=%d mode=%d\n", pred, h->intra4x4_pred_mode_cache[ scan8[i] ] ); | 4416 //av_log( s->avctx, AV_LOG_ERROR, "i4x4 pred=%d mode=%d\n", pred, h->intra4x4_pred_mode_cache[ scan8[i] ] ); |
4378 } | 4417 } |
4379 } | 4418 } |
4380 ff_h264_write_back_intra_pred_mode(h); | 4419 ff_h264_write_back_intra_pred_mode(h); |
4381 if( check_intra4x4_pred_mode(h) < 0 ) return -1; | 4420 if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1; |
4382 } else { | 4421 } else { |
4383 h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode ); | 4422 h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode ); |
4384 if( h->intra16x16_pred_mode < 0 ) return -1; | 4423 if( h->intra16x16_pred_mode < 0 ) return -1; |
4385 } | 4424 } |
4386 if(CHROMA){ | 4425 if(CHROMA){ |