Commit 6f91bcd1 authored by Michael Niedermayer's avatar Michael Niedermayer

mpeg4 b-frames :)

create slightly more correct headers & add "ffmpeg" user-data section

Originally committed as revision 328 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent e2263827
This diff is collapsed.
......@@ -45,6 +45,7 @@ static int h263_decode_init(AVCodecContext *avctx)
case CODEC_ID_MPEG4:
s->time_increment_bits = 4; /* default value for broken headers */
s->h263_pred = 1;
s->has_b_frames = 1;
break;
case CODEC_ID_MSMPEG4:
s->h263_msmpeg4 = 1;
......@@ -219,9 +220,15 @@ static int h263_decode_frame(AVCodecContext *avctx,
MPV_frame_end(s);
pict->data[0] = s->current_picture[0];
pict->data[1] = s->current_picture[1];
pict->data[2] = s->current_picture[2];
if(s->pict_type==B_TYPE){
pict->data[0] = s->current_picture[0];
pict->data[1] = s->current_picture[1];
pict->data[2] = s->current_picture[2];
} else {
pict->data[0] = s->last_picture[0];
pict->data[1] = s->last_picture[1];
pict->data[2] = s->last_picture[2];
}
pict->linesize[0] = s->linesize;
pict->linesize[1] = s->linesize / 2;
pict->linesize[2] = s->linesize / 2;
......
......@@ -99,3 +99,7 @@ static const UINT16 sprite_trajectory_tab[15][2] = {
{0x0E, 4}, {0x1E, 5}, {0x3E, 6}, {0x7E, 7}, {0xFE, 8},
{0x1FE, 9},{0x3FE, 10},{0x7FE, 11},{0xFFE, 12},
};
static const UINT8 mb_type_b_tab[4][2] = {
{1, 1}, {1, 2}, {1, 3}, {1, 4},
};
......@@ -430,6 +430,7 @@ void MPV_frame_start(MpegEncContext *s)
s->current_picture[i] = s->aux_picture[i];
}
} else {
s->last_non_b_pict_type= s->pict_type;
for(i=0;i<3;i++) {
/* swap next and last */
tmp = s->last_picture[i];
......@@ -745,7 +746,7 @@ static inline void MPV_motion(MpegEncContext *s,
ref_picture, 0,
16);
#endif
}else if(s->quarter_sample){
}else if(s->quarter_sample && dir==0){ //FIXME
qpel_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, 0,
0, pix_op, qpix_op,
......@@ -930,8 +931,9 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
else if (s->h263_pred || s->h263_aic)
s->mbintra_table[mb_x + mb_y*s->mb_width]=1;
/* update motion predictor */
/* update motion predictor, not for B-frames as they need the motion_val from the last P/S-Frame */
if (s->out_format == FMT_H263) {
if(s->pict_type!=B_TYPE){
int xy, wrap, motion_x, motion_y;
wrap = 2 * s->mb_width + 2;
......@@ -954,6 +956,7 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
s->motion_val[xy + 1 + wrap][0] = motion_x;
s->motion_val[xy + 1 + wrap][1] = motion_y;
}
}
}
if (!s->intra_only) {
......
......@@ -84,19 +84,21 @@ typedef struct MpegEncContext {
int qscale;
int pict_type;
int last_non_b_pict_type; /* used for mpeg4 gmc b-frames */
int frame_rate_index;
/* motion compensation */
int unrestricted_mv;
int h263_long_vectors; /* use horrible h263v1 long vector mode */
int f_code; /* resolution */
int b_code; /* resolution for B Frames*/
INT16 *mv_table[2]; /* MV table */
INT16 (*motion_val)[2]; /* used for MV prediction */
int b_code; /* backward resolution for B Frames (mpeg4) */
INT16 *mv_table[2]; /* MV table (1MV per MB)*/
INT16 (*motion_val)[2]; /* used for MV prediction (4MV per MB)*/
int full_search;
int mv_dir;
#define MV_DIR_BACKWARD 1
#define MV_DIR_FORWARD 2
#define MV_DIRECT 4 // bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4)
int mv_type;
#define MV_TYPE_16X16 0 /* 1 vector for the whole mb */
#define MV_TYPE_8X8 1 /* 4 vectors (h263) */
......@@ -156,7 +158,12 @@ typedef struct MpegEncContext {
int h263_aic_dir; /* AIC direction: 0 = left, 1 = top */
/* mpeg4 specific */
int time_increment_resolution;
int time_increment_bits;
int time_increment;
int time_base;
int time;
int last_non_b_time[2];
int shape;
int vol_sprite_usage;
int sprite_width;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment