Commit 0e69003e authored by michaelni's avatar michaelni

interlaced mpeg4 b frame decoding


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@936 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 12908406
This diff is collapsed.
...@@ -1391,8 +1391,8 @@ static inline int direct_search(MpegEncContext * s, ...@@ -1391,8 +1391,8 @@ static inline int direct_search(MpegEncContext * s,
const int motion_px= s->p_mv_table[mot_xy][0]; const int motion_px= s->p_mv_table[mot_xy][0];
const int motion_py= s->p_mv_table[mot_xy][1]; const int motion_py= s->p_mv_table[mot_xy][1];
const int time_pp= s->pp_time; const int time_pp= s->pp_time;
const int time_bp= s->bp_time; const int time_pb= s->pb_time;
const int time_pb= time_pp - time_bp; const int time_bp= time_pp - time_pb;
int bx, by; int bx, by;
int mx, my, mx2, my2; int mx, my, mx2, my2;
uint8_t *ref_picture= s->me_scratchpad - (mb_x - 1 + (mb_y - 1)*s->linesize)*16; uint8_t *ref_picture= s->me_scratchpad - (mb_x - 1 + (mb_y - 1)*s->linesize)*16;
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#define MOTION_MARKER 0x1F001 #define MOTION_MARKER 0x1F001
#define DC_MARKER 0x6B001 #define DC_MARKER 0x6B001
#define MB_TYPE_B_DIRECT 0
#define MB_TYPE_B_BIDIR 1
#define MB_TYPE_B_BACKW 2
#define MB_TYPE_B_FORW 3
/* dc encoding for mpeg4 */ /* dc encoding for mpeg4 */
const UINT8 DCtab_lum[13][2] = const UINT8 DCtab_lum[13][2] =
......
...@@ -259,9 +259,13 @@ int MPV_common_init(MpegEncContext *s) ...@@ -259,9 +259,13 @@ int MPV_common_init(MpegEncContext *s)
/* MV prediction */ /* MV prediction */
size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(INT16)); CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(INT16));
}
/* 4mv direct mode decoding table */
CHECKED_ALLOCZ(s->non_b_mv4_table, size * sizeof(UINT8)) if(s->codec_id==CODEC_ID_MPEG4){
/* 4mv and interlaced direct mode decoding tables */
CHECKED_ALLOCZ(s->co_located_type_table, s->mb_num * sizeof(UINT8))
CHECKED_ALLOCZ(s->field_mv_table, s->mb_num*2*2 * sizeof(INT16))
CHECKED_ALLOCZ(s->field_select_table, s->mb_num*2* sizeof(INT8))
} }
if (s->h263_pred || s->h263_plus) { if (s->h263_pred || s->h263_plus) {
...@@ -350,7 +354,9 @@ void MPV_common_end(MpegEncContext *s) ...@@ -350,7 +354,9 @@ void MPV_common_end(MpegEncContext *s)
av_freep(&s->tex_pb_buffer); av_freep(&s->tex_pb_buffer);
av_freep(&s->pb2_buffer); av_freep(&s->pb2_buffer);
av_freep(&s->edge_emu_buffer); av_freep(&s->edge_emu_buffer);
av_freep(&s->non_b_mv4_table); av_freep(&s->co_located_type_table);
av_freep(&s->field_mv_table);
av_freep(&s->field_select_table);
av_freep(&s->avctx->stats_out); av_freep(&s->avctx->stats_out);
av_freep(&s->ac_stats); av_freep(&s->ac_stats);
...@@ -1466,20 +1472,32 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) ...@@ -1466,20 +1472,32 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
const int wrap = s->block_wrap[0]; const int wrap = s->block_wrap[0];
const int xy = s->block_index[0]; const int xy = s->block_index[0];
const int mb_index= s->mb_x + s->mb_y*s->mb_width;
if(s->mv_type == MV_TYPE_8X8){ if(s->mv_type == MV_TYPE_8X8){
s->non_b_mv4_table[xy]=1; s->co_located_type_table[mb_index]= CO_LOCATED_TYPE_4MV;
} else { } else {
int motion_x, motion_y; int motion_x, motion_y;
if (s->mb_intra) { if (s->mb_intra) {
motion_x = 0; motion_x = 0;
motion_y = 0; motion_y = 0;
if(s->co_located_type_table)
s->co_located_type_table[mb_index]= 0;
} else if (s->mv_type == MV_TYPE_16X16) { } else if (s->mv_type == MV_TYPE_16X16) {
motion_x = s->mv[0][0][0]; motion_x = s->mv[0][0][0];
motion_y = s->mv[0][0][1]; motion_y = s->mv[0][0][1];
if(s->co_located_type_table)
s->co_located_type_table[mb_index]= 0;
} else /*if (s->mv_type == MV_TYPE_FIELD)*/ { } else /*if (s->mv_type == MV_TYPE_FIELD)*/ {
int i;
motion_x = s->mv[0][0][0] + s->mv[0][1][0]; motion_x = s->mv[0][0][0] + s->mv[0][1][0];
motion_y = s->mv[0][0][1] + s->mv[0][1][1]; motion_y = s->mv[0][0][1] + s->mv[0][1][1];
motion_x = (motion_x>>1) | (motion_x&1); motion_x = (motion_x>>1) | (motion_x&1);
for(i=0; i<2; i++){
s->field_mv_table[mb_index][i][0]= s->mv[0][i][0];
s->field_mv_table[mb_index][i][1]= s->mv[0][i][1];
s->field_select_table[mb_index][i]= s->field_select[0][i];
}
s->co_located_type_table[mb_index]= CO_LOCATED_TYPE_FIELDMV;
} }
/* no update if 8X8 because it has been done during parsing */ /* no update if 8X8 because it has been done during parsing */
s->motion_val[xy][0] = motion_x; s->motion_val[xy][0] = motion_x;
...@@ -1490,7 +1508,6 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) ...@@ -1490,7 +1508,6 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
s->motion_val[xy + wrap][1] = motion_y; s->motion_val[xy + wrap][1] = motion_y;
s->motion_val[xy + 1 + wrap][0] = motion_x; s->motion_val[xy + 1 + wrap][0] = motion_x;
s->motion_val[xy + 1 + wrap][1] = motion_y; s->motion_val[xy + 1 + wrap][1] = motion_y;
s->non_b_mv4_table[xy]=0;
} }
} }
......
...@@ -339,7 +339,9 @@ typedef struct MpegEncContext { ...@@ -339,7 +339,9 @@ typedef struct MpegEncContext {
INT64 time; /* time of current frame */ INT64 time; /* time of current frame */
INT64 last_non_b_time; INT64 last_non_b_time;
UINT16 pp_time; /* time distance between the last 2 p,s,i frames */ UINT16 pp_time; /* time distance between the last 2 p,s,i frames */
UINT16 bp_time; /* time distance between the last b and p,s,i frame */ UINT16 pb_time; /* time distance between the last b and p,s,i frame */
UINT16 pp_field_time;
UINT16 pb_field_time; /* like above, just for interlaced */
int shape; int shape;
int vol_sprite_usage; int vol_sprite_usage;
int sprite_width; int sprite_width;
...@@ -377,7 +379,12 @@ typedef struct MpegEncContext { ...@@ -377,7 +379,12 @@ typedef struct MpegEncContext {
uint8_t *tex_pb_buffer; uint8_t *tex_pb_buffer;
uint8_t *pb2_buffer; uint8_t *pb2_buffer;
int mpeg_quant; int mpeg_quant;
INT8 *non_b_mv4_table; #define CO_LOCATED_TYPE_4MV 1
#define CO_LOCATED_TYPE_FIELDMV 2
INT8 *co_located_type_table; /* 4mv & field_mv info for next b frame */
INT16 (*field_mv_table)[2][2]; /* used for interlaced b frame decoding */
INT8 (*field_select_table)[2]; /* wtf, no really another table for interlaced b frames */
int t_frame; /* time distance of first I -> B, used for interlaced b frames */
/* divx specific, used to workaround (many) bugs in divx5 */ /* divx specific, used to workaround (many) bugs in divx5 */
int divx_version; int divx_version;
......
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