diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-02-08 12:00:57 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-02-08 12:00:57 +0000 |
commit | 63b15e559ac725321ea7a5bc38c123da8cf7d764 (patch) | |
tree | 66e05b6308ca7b4a52e18c63e4b2d996a5e496e1 /libavcodec/mpegvideo.c | |
parent | 27efd8467a92a5ea2af49acabf451bf233d5184d (diff) |
mpeg1 bframe encoding patch by (Raphaël LEGRAND) with some modifications by me
Originally committed as revision 1551 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r-- | libavcodec/mpegvideo.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 15bd0249b0..34687d735e 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -2872,7 +2872,8 @@ static void encode_picture(MpegEncContext *s, int picture_number) #ifdef CONFIG_RISKY /* we need to initialize some time vars before we can encode b-frames */ - if (s->h263_pred && !s->h263_msmpeg4) + // RAL: Condition added for MPEG1VIDEO + if (s->codec_id == CODEC_ID_MPEG1VIDEO || (s->h263_pred && !s->h263_msmpeg4)) ff_set_mpeg4_time(s, s->picture_number); #endif @@ -2965,12 +2966,24 @@ static void encode_picture(MpegEncContext *s, int picture_number) //printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum); } - if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) + if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) { s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER); + + // RAL: Next call moved into that bloc ff_fix_long_p_mvs(s); + } + + // RAL: All this bloc changed if(s->pict_type==B_TYPE){ - s->f_code= ff_get_best_fcode(s, s->b_forw_mv_table, MB_TYPE_FORWARD); - s->b_code= ff_get_best_fcode(s, s->b_back_mv_table, MB_TYPE_BACKWARD); + int a, b; + + a = ff_get_best_fcode(s, s->b_forw_mv_table, MB_TYPE_FORWARD); + b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, MB_TYPE_BIDIR); + s->f_code = FFMAX(a, b); + + a = ff_get_best_fcode(s, s->b_back_mv_table, MB_TYPE_BACKWARD); + b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, MB_TYPE_BIDIR); + s->b_code = FFMAX(a, b); ff_fix_long_b_mvs(s, s->b_forw_mv_table, s->f_code, MB_TYPE_FORWARD); ff_fix_long_b_mvs(s, s->b_back_mv_table, s->b_code, MB_TYPE_BACKWARD); @@ -3064,6 +3077,10 @@ static void encode_picture(MpegEncContext *s, int picture_number) s->mb_incr = 1; s->last_mv[0][0][0] = 0; s->last_mv[0][0][1] = 0; + s->last_mv[1][0][0] = 0; + s->last_mv[1][0][1] = 0; + + s->last_mv_dir = 0; #ifdef CONFIG_RISKY if (s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P) @@ -3227,7 +3244,7 @@ static void encode_picture(MpegEncContext *s, int picture_number) &dmin, &next_block, mx, my); } if(mb_type&MB_TYPE_INTRA){ - s->mv_dir = MV_DIR_FORWARD; + s->mv_dir = 0; s->mv_type = MV_TYPE_16X16; s->mb_intra= 1; s->mv[0][0][0] = 0; @@ -3348,7 +3365,7 @@ static void encode_picture(MpegEncContext *s, int picture_number) switch(mb_type){ case MB_TYPE_INTRA: - s->mv_dir = MV_DIR_FORWARD; + s->mv_dir = 0; s->mb_intra= 1; motion_x= s->mv[0][0][0] = 0; motion_y= s->mv[0][0][1] = 0; @@ -3405,8 +3422,13 @@ static void encode_picture(MpegEncContext *s, int picture_number) motion_x=motion_y=0; //gcc warning fix printf("illegal MB type\n"); } + encode_mb(s, motion_x, motion_y); + + // RAL: Update last macrobloc type + s->last_mv_dir = s->mv_dir; } + /* clean the MV table in IPS frames for direct mode in B frames */ if(s->mb_intra /* && I,P,S_TYPE */){ s->p_mv_table[xy][0]=0; |