# HG changeset patch # User michaelni # Date 1019611446 0 # Node ID bf26081c373c0377f41b3fab678ee4cc33598516 # Parent f24c77638413c3ac86a8c6a6220e6b0651049c94 avcodec_flush_buffers() diff -r f24c77638413 -r bf26081c373c avcodec.h --- a/avcodec.h Tue Apr 23 08:52:53 2002 +0000 +++ b/avcodec.h Wed Apr 24 01:24:06 2002 +0000 @@ -5,8 +5,8 @@ #define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION "0.4.6" -#define LIBAVCODEC_BUILD 4602 -#define LIBAVCODEC_BUILD_STR "4602" +#define LIBAVCODEC_BUILD 4603 +#define LIBAVCODEC_BUILD_STR "4603" enum CodecID { CODEC_ID_NONE, @@ -340,6 +340,8 @@ void avcodec_register_all(void); +void avcodec_flush_buffers(AVCodecContext *avctx); + #ifdef FF_POSTPROCESS #ifndef MBC #define MBC 128 diff -r f24c77638413 -r bf26081c373c h263.c --- a/h263.c Tue Apr 23 08:52:53 2002 +0000 +++ b/h263.c Wed Apr 24 01:24:06 2002 +0000 @@ -1034,7 +1034,7 @@ if(s->low_delay){ put_bits(&s->pb, 1, 1); /* vol control parameters= yes */ - put_bits(&s->pb, 2, 1); /* chroma format 422 */ + put_bits(&s->pb, 2, 1); /* chroma format YUV 420/YV12 */ put_bits(&s->pb, 1, s->low_delay); put_bits(&s->pb, 1, 0); /* vbv parameters= no */ }else{ @@ -2602,7 +2602,7 @@ } else { vo_ver_id = 1; } - +//printf("vo type:%d\n",s->vo_type); s->aspect_ratio_info= get_bits(&s->gb, 4); if(s->aspect_ratio_info == EXTENDET_PAR){ skip_bits(&s->gb, 8); //par_width diff -r f24c77638413 -r bf26081c373c h263dec.c --- a/h263dec.c Tue Apr 23 08:52:53 2002 +0000 +++ b/h263dec.c Wed Apr 24 01:24:06 2002 +0000 @@ -135,7 +135,6 @@ } else { ret = h263_decode_picture_header(s); } - if(ret==FRAME_SKIPED) return 0; /* After H263 & mpeg4 header decode we have the height, width,*/ /* and other parameters. So then we could init the picture */ @@ -154,9 +153,12 @@ return -1; } + if(ret==FRAME_SKIPED) return 0; if (ret < 0) return -1; - + /* skip b frames if we dont have reference frames */ + if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return 0; + MPV_frame_start(s); #ifdef DEBUG @@ -222,7 +224,8 @@ } MPV_decode_mb(s, s->block); } - if (avctx->draw_horiz_band) { + if ( avctx->draw_horiz_band + && (s->num_available_buffers>=1 || (!s->has_b_frames)) ) { UINT8 *src_ptr[3]; int y, h, offset; y = s->mb_y * 16; @@ -279,7 +282,11 @@ /* we substract 1 because it is added on utils.c */ avctx->frame_number = s->picture_number - 1; - *data_size = sizeof(AVPicture); + /* dont output the last pic after seeking + note we allready added +1 for the current pix in MPV_frame_end(s) */ + if(s->num_available_buffers>=2 || (!s->has_b_frames)) + *data_size = sizeof(AVPicture); + return buf_size; } diff -r f24c77638413 -r bf26081c373c mpegvideo.c --- a/mpegvideo.c Tue Apr 23 08:52:53 2002 +0000 +++ b/mpegvideo.c Wed Apr 24 01:24:06 2002 +0000 @@ -629,6 +629,8 @@ s->last_non_b_pict_type= s->pict_type; s->last_non_b_qscale= s->qscale; s->last_non_b_mc_mb_var= s->mc_mb_var; + s->num_available_buffers++; + if(s->num_available_buffers>2) s->num_available_buffers= 2; } } diff -r f24c77638413 -r bf26081c373c mpegvideo.h --- a/mpegvideo.h Tue Apr 23 08:52:53 2002 +0000 +++ b/mpegvideo.h Wed Apr 24 01:24:06 2002 +0000 @@ -129,6 +129,7 @@ UINT8 *aux_picture[3]; /* aux picture (for B frames only) */ UINT8 *aux_picture_base[3]; /* real start of the picture */ UINT8 *current_picture[3]; /* buffer to store the decompressed current picture */ + int num_available_buffers; /* is 0 at the start & after seeking, after the first I frame its 1 after next I/P 2 */ int last_dc[3]; /* last DC values for MPEG1 */ INT16 *dc_val[3]; /* used for mpeg4 DC prediction, all 3 arrays must be continuous */ int y_dc_scale, c_dc_scale; diff -r f24c77638413 -r bf26081c373c utils.c --- a/utils.c Tue Apr 23 08:52:53 2002 +0000 +++ b/utils.c Wed Apr 24 01:24:06 2002 +0000 @@ -22,6 +22,7 @@ #include "common.h" #include "dsputil.h" #include "avcodec.h" +#include "mpegvideo.h" #ifdef HAVE_MALLOC_H #include #else @@ -479,6 +480,14 @@ #undef PCM_CODEC } +/* this should be called after seeking and before trying to decode the next frame */ +void avcodec_flush_buffers(AVCodecContext *avctx) +{ + MpegEncContext *s = avctx->priv_data; + s->num_available_buffers=0; +} + + static int encode_init(AVCodecContext *s) { return 0;