From 3994623df2efd2749631c3492184dd8d4ffa9d1b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 2 Oct 2002 17:07:39 +0000 Subject: [PATCH] optimization Originally committed as revision 992 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/h263dec.c | 7 ++++++- libavcodec/mpeg12.c | 5 ++++- libavcodec/mpegvideo.c | 12 +++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index c8c38cac87..fc3dca3d00 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -362,7 +362,12 @@ uint64_t time= rdtsc(); h = s->height - y; if (h > 16) h = 16; - offset = y * s->linesize; + + if(s->pict_type==B_TYPE) + offset = 0; + else + offset = y * s->linesize; + if(s->pict_type==B_TYPE || (!s->has_b_frames)){ src_ptr[0] = s->current_picture[0] + offset; src_ptr[1] = s->current_picture[1] + (offset >> 2); diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 97169fa4da..18afa7630f 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -1604,7 +1604,10 @@ static int mpeg_decode_slice(AVCodecContext *avctx, h = s->height - y; if (h > 16) h = 16; - offset = y * s->linesize; + if(s->pict_type==B_TYPE) + offset = 0; + else + offset = y * s->linesize; if(s->pict_type==B_TYPE || (!s->has_b_frames)){ src_ptr[0] = s->current_picture[0] + offset; src_ptr[1] = s->current_picture[1] + (offset >> 2); diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 5c487a1ef2..9ff046e059 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1684,9 +1684,15 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) } } - dest_y = s->current_picture [0] + (mb_y * 16* s->linesize ) + mb_x * 16; - dest_cb = s->current_picture[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; - dest_cr = s->current_picture[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; + if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band){ + dest_y = s->current_picture [0] + mb_x * 16; + dest_cb = s->current_picture[1] + mb_x * 8; + dest_cr = s->current_picture[2] + mb_x * 8; + }else{ + dest_y = s->current_picture [0] + (mb_y * 16* s->linesize ) + mb_x * 16; + dest_cb = s->current_picture[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; + dest_cr = s->current_picture[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; + } if (s->interlaced_dct) { dct_linesize = s->linesize * 2;