[FFmpeg-cvslog] r21173 - in trunk/libavcodec: h264.c h264.h svq3.c
michael
subversion
Tue Jan 12 22:17:26 CET 2010
Author: michael
Date: Tue Jan 12 22:17:26 2010
New Revision: 21173
Log:
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)
Modified:
trunk/libavcodec/h264.c
trunk/libavcodec/h264.h
trunk/libavcodec/svq3.c
Modified: trunk/libavcodec/h264.c
==============================================================================
--- trunk/libavcodec/h264.c Tue Jan 12 21:59:00 2010 (r21172)
+++ trunk/libavcodec/h264.c Tue Jan 12 22:17:26 2010 (r21173)
@@ -544,6 +544,45 @@ void ff_h264_write_back_intra_pred_mode(
/**
* checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
*/
+int ff_h264_check_intra4x4_pred_mode(H264Context *h){
+ MpegEncContext * const s = &h->s;
+ static const int8_t top [12]= {-1, 0,LEFT_DC_PRED,-1,-1,-1,-1,-1, 0};
+ static const int8_t left[12]= { 0,-1, TOP_DC_PRED, 0,-1,-1,-1, 0,-1,DC_128_PRED};
+ int i;
+
+ if(!(h->top_samples_available&0x8000)){
+ for(i=0; i<4; i++){
+ int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ];
+ if(status<0){
+ 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);
+ return -1;
+ } else if(status){
+ h->intra4x4_pred_mode_cache[scan8[0] + i]= status;
+ }
+ }
+ }
+
+ if((h->left_samples_available&0x8888)!=0x8888){
+ static const int mask[4]={0x8000,0x2000,0x80,0x20};
+ for(i=0; i<4; i++){
+ if(!(h->left_samples_available&mask[i])){
+ int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ];
+ if(status<0){
+ 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);
+ return -1;
+ } else if(status){
+ h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status;
+ }
+ }
+ }
+ }
+
+ return 0;
+} //FIXME cleanup like ff_h264_check_intra_pred_mode
+
+/**
+ * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
+ */
int ff_h264_check_intra_pred_mode(H264Context *h, int mode){
MpegEncContext * const s = &h->s;
static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1};
@@ -3277,7 +3316,7 @@ decode_intra_mb:
h->intra4x4_pred_mode_cache[ scan8[i] ] = mode;
}
ff_h264_write_back_intra_pred_mode(h);
- if( check_intra4x4_pred_mode(h) < 0)
+ if( ff_h264_check_intra4x4_pred_mode(h) < 0)
return -1;
}else{
h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode(h, h->intra16x16_pred_mode);
@@ -4378,7 +4417,7 @@ decode_intra_mb:
}
}
ff_h264_write_back_intra_pred_mode(h);
- if( check_intra4x4_pred_mode(h) < 0 ) return -1;
+ if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1;
} else {
h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode );
if( h->intra16x16_pred_mode < 0 ) return -1;
Modified: trunk/libavcodec/h264.h
==============================================================================
--- trunk/libavcodec/h264.h Tue Jan 12 21:59:00 2010 (r21172)
+++ trunk/libavcodec/h264.h Tue Jan 12 22:17:26 2010 (r21173)
@@ -630,6 +630,11 @@ int ff_h264_decode_ref_pic_marking(H264C
/**
* checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
*/
+int ff_h264_check_intra4x4_pred_mode(H264Context *h);
+
+/**
+ * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
+ */
int ff_h264_check_intra_pred_mode(H264Context *h, int mode);
void ff_h264_write_back_intra_pred_mode(H264Context *h);
@@ -683,45 +688,6 @@ static av_always_inline uint32_t pack16t
}
/**
- * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
- */
-static inline int check_intra4x4_pred_mode(H264Context *h){
- MpegEncContext * const s = &h->s;
- static const int8_t top [12]= {-1, 0,LEFT_DC_PRED,-1,-1,-1,-1,-1, 0};
- static const int8_t left[12]= { 0,-1, TOP_DC_PRED, 0,-1,-1,-1, 0,-1,DC_128_PRED};
- int i;
-
- if(!(h->top_samples_available&0x8000)){
- for(i=0; i<4; i++){
- int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ];
- if(status<0){
- 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);
- return -1;
- } else if(status){
- h->intra4x4_pred_mode_cache[scan8[0] + i]= status;
- }
- }
- }
-
- if((h->left_samples_available&0x8888)!=0x8888){
- static const int mask[4]={0x8000,0x2000,0x80,0x20};
- for(i=0; i<4; i++){
- if(!(h->left_samples_available&mask[i])){
- int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ];
- if(status<0){
- 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);
- return -1;
- } else if(status){
- h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status;
- }
- }
- }
- }
-
- return 0;
-} //FIXME cleanup like ff_h264_check_intra_pred_mode
-
-/**
* gets the chroma qp.
*/
static inline int get_chroma_qp(H264Context *h, int t, int qscale){
Modified: trunk/libavcodec/svq3.c
==============================================================================
--- trunk/libavcodec/svq3.c Tue Jan 12 21:59:00 2010 (r21172)
+++ trunk/libavcodec/svq3.c Tue Jan 12 22:17:26 2010 (r21173)
@@ -589,7 +589,7 @@ static int svq3_decode_mb(H264Context *h
ff_h264_write_back_intra_pred_mode(h);
if (mb_type == 8) {
- check_intra4x4_pred_mode(h);
+ ff_h264_check_intra4x4_pred_mode(h);
h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
More information about the ffmpeg-cvslog
mailing list