Commit 163ea5b9 authored by michael's avatar michael

motion estimation for SVQ1


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@3126 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 6daff126
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
#ifdef CONFIG_ENCODERS #ifdef CONFIG_ENCODERS
static void h263_encode_block(MpegEncContext * s, DCTELEM * block, static void h263_encode_block(MpegEncContext * s, DCTELEM * block,
int n); int n);
static void h263_encode_motion(MpegEncContext * s, int val, int fcode);
static void h263p_encode_umotion(MpegEncContext * s, int val); static void h263p_encode_umotion(MpegEncContext * s, int val);
static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block,
int n, int dc, uint8_t *scan_table, int n, int dc, uint8_t *scan_table,
...@@ -851,23 +850,23 @@ void mpeg4_encode_mb(MpegEncContext * s, ...@@ -851,23 +850,23 @@ void mpeg4_encode_mb(MpegEncContext * s,
if(mb_type == 0){ if(mb_type == 0){
assert(s->mv_dir & MV_DIRECT); assert(s->mv_dir & MV_DIRECT);
h263_encode_motion(s, motion_x, 1); ff_h263_encode_motion(s, motion_x, 1);
h263_encode_motion(s, motion_y, 1); ff_h263_encode_motion(s, motion_y, 1);
s->b_count++; s->b_count++;
s->f_count++; s->f_count++;
}else{ }else{
assert(mb_type > 0 && mb_type < 4); assert(mb_type > 0 && mb_type < 4);
if(s->mv_type != MV_TYPE_FIELD){ if(s->mv_type != MV_TYPE_FIELD){
if(s->mv_dir & MV_DIR_FORWARD){ if(s->mv_dir & MV_DIR_FORWARD){
h263_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code); ff_h263_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code);
h263_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code); ff_h263_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code);
s->last_mv[0][0][0]= s->last_mv[0][1][0]= s->mv[0][0][0]; s->last_mv[0][0][0]= s->last_mv[0][1][0]= s->mv[0][0][0];
s->last_mv[0][0][1]= s->last_mv[0][1][1]= s->mv[0][0][1]; s->last_mv[0][0][1]= s->last_mv[0][1][1]= s->mv[0][0][1];
s->f_count++; s->f_count++;
} }
if(s->mv_dir & MV_DIR_BACKWARD){ if(s->mv_dir & MV_DIR_BACKWARD){
h263_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code); ff_h263_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code);
h263_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code); ff_h263_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code);
s->last_mv[1][0][0]= s->last_mv[1][1][0]= s->mv[1][0][0]; s->last_mv[1][0][0]= s->last_mv[1][1][0]= s->mv[1][0][0];
s->last_mv[1][0][1]= s->last_mv[1][1][1]= s->mv[1][0][1]; s->last_mv[1][0][1]= s->last_mv[1][1][1]= s->mv[1][0][1];
s->b_count++; s->b_count++;
...@@ -883,8 +882,8 @@ void mpeg4_encode_mb(MpegEncContext * s, ...@@ -883,8 +882,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
} }
if(s->mv_dir & MV_DIR_FORWARD){ if(s->mv_dir & MV_DIR_FORWARD){
for(i=0; i<2; i++){ for(i=0; i<2; i++){
h263_encode_motion(s, s->mv[0][i][0] - s->last_mv[0][i][0] , s->f_code); ff_h263_encode_motion(s, s->mv[0][i][0] - s->last_mv[0][i][0] , s->f_code);
h263_encode_motion(s, s->mv[0][i][1] - s->last_mv[0][i][1]/2, s->f_code); ff_h263_encode_motion(s, s->mv[0][i][1] - s->last_mv[0][i][1]/2, s->f_code);
s->last_mv[0][i][0]= s->mv[0][i][0]; s->last_mv[0][i][0]= s->mv[0][i][0];
s->last_mv[0][i][1]= s->mv[0][i][1]*2; s->last_mv[0][i][1]= s->mv[0][i][1]*2;
} }
...@@ -892,8 +891,8 @@ void mpeg4_encode_mb(MpegEncContext * s, ...@@ -892,8 +891,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
} }
if(s->mv_dir & MV_DIR_BACKWARD){ if(s->mv_dir & MV_DIR_BACKWARD){
for(i=0; i<2; i++){ for(i=0; i<2; i++){
h263_encode_motion(s, s->mv[1][i][0] - s->last_mv[1][i][0] , s->b_code); ff_h263_encode_motion(s, s->mv[1][i][0] - s->last_mv[1][i][0] , s->b_code);
h263_encode_motion(s, s->mv[1][i][1] - s->last_mv[1][i][1]/2, s->b_code); ff_h263_encode_motion(s, s->mv[1][i][1] - s->last_mv[1][i][1]/2, s->b_code);
s->last_mv[1][i][0]= s->mv[1][i][0]; s->last_mv[1][i][0]= s->mv[1][i][0];
s->last_mv[1][i][1]= s->mv[1][i][1]*2; s->last_mv[1][i][1]= s->mv[1][i][1]*2;
} }
...@@ -993,8 +992,8 @@ void mpeg4_encode_mb(MpegEncContext * s, ...@@ -993,8 +992,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
/* motion vectors: 16x16 mode */ /* motion vectors: 16x16 mode */
h263_pred_motion(s, 0, 0, &pred_x, &pred_y); h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
h263_encode_motion(s, motion_x - pred_x, s->f_code); ff_h263_encode_motion(s, motion_x - pred_x, s->f_code);
h263_encode_motion(s, motion_y - pred_y, s->f_code); ff_h263_encode_motion(s, motion_y - pred_y, s->f_code);
}else if(s->mv_type==MV_TYPE_FIELD){ }else if(s->mv_type==MV_TYPE_FIELD){
if(s->dquant) cbpc+= 8; if(s->dquant) cbpc+= 8;
put_bits(&s->pb, put_bits(&s->pb,
...@@ -1021,10 +1020,10 @@ void mpeg4_encode_mb(MpegEncContext * s, ...@@ -1021,10 +1020,10 @@ void mpeg4_encode_mb(MpegEncContext * s,
put_bits(&s->pb, 1, s->field_select[0][0]); put_bits(&s->pb, 1, s->field_select[0][0]);
put_bits(&s->pb, 1, s->field_select[0][1]); put_bits(&s->pb, 1, s->field_select[0][1]);
h263_encode_motion(s, s->mv[0][0][0] - pred_x, s->f_code); ff_h263_encode_motion(s, s->mv[0][0][0] - pred_x, s->f_code);
h263_encode_motion(s, s->mv[0][0][1] - pred_y, s->f_code); ff_h263_encode_motion(s, s->mv[0][0][1] - pred_y, s->f_code);
h263_encode_motion(s, s->mv[0][1][0] - pred_x, s->f_code); ff_h263_encode_motion(s, s->mv[0][1][0] - pred_x, s->f_code);
h263_encode_motion(s, s->mv[0][1][1] - pred_y, s->f_code); ff_h263_encode_motion(s, s->mv[0][1][1] - pred_y, s->f_code);
}else{ }else{
assert(s->mv_type==MV_TYPE_8X8); assert(s->mv_type==MV_TYPE_8X8);
put_bits(&s->pb, put_bits(&s->pb,
...@@ -1045,8 +1044,8 @@ void mpeg4_encode_mb(MpegEncContext * s, ...@@ -1045,8 +1044,8 @@ void mpeg4_encode_mb(MpegEncContext * s,
/* motion vectors: 8x8 mode*/ /* motion vectors: 8x8 mode*/
h263_pred_motion(s, i, 0, &pred_x, &pred_y); h263_pred_motion(s, i, 0, &pred_x, &pred_y);
h263_encode_motion(s, s->current_picture.motion_val[0][ s->block_index[i] ][0] - pred_x, s->f_code); ff_h263_encode_motion(s, s->current_picture.motion_val[0][ s->block_index[i] ][0] - pred_x, s->f_code);
h263_encode_motion(s, s->current_picture.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code); ff_h263_encode_motion(s, s->current_picture.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code);
} }
} }
...@@ -1186,8 +1185,8 @@ void h263_encode_mb(MpegEncContext * s, ...@@ -1186,8 +1185,8 @@ void h263_encode_mb(MpegEncContext * s,
h263_pred_motion(s, 0, 0, &pred_x, &pred_y); h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
if (!s->umvplus) { if (!s->umvplus) {
h263_encode_motion(s, motion_x - pred_x, 1); ff_h263_encode_motion(s, motion_x - pred_x, 1);
h263_encode_motion(s, motion_y - pred_y, 1); ff_h263_encode_motion(s, motion_y - pred_y, 1);
} }
else { else {
h263p_encode_umotion(s, motion_x - pred_x); h263p_encode_umotion(s, motion_x - pred_x);
...@@ -1215,8 +1214,8 @@ void h263_encode_mb(MpegEncContext * s, ...@@ -1215,8 +1214,8 @@ void h263_encode_mb(MpegEncContext * s,
motion_x= s->current_picture.motion_val[0][ s->block_index[i] ][0]; motion_x= s->current_picture.motion_val[0][ s->block_index[i] ][0];
motion_y= s->current_picture.motion_val[0][ s->block_index[i] ][1]; motion_y= s->current_picture.motion_val[0][ s->block_index[i] ][1];
if (!s->umvplus) { if (!s->umvplus) {
h263_encode_motion(s, motion_x - pred_x, 1); ff_h263_encode_motion(s, motion_x - pred_x, 1);
h263_encode_motion(s, motion_y - pred_y, 1); ff_h263_encode_motion(s, motion_y - pred_y, 1);
} }
else { else {
h263p_encode_umotion(s, motion_x - pred_x); h263p_encode_umotion(s, motion_x - pred_x);
...@@ -1619,7 +1618,7 @@ int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir, ...@@ -1619,7 +1618,7 @@ int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
} }
#ifdef CONFIG_ENCODERS #ifdef CONFIG_ENCODERS
static void h263_encode_motion(MpegEncContext * s, int val, int f_code) void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code)
{ {
int range, l, bit_size, sign, code, bits; int range, l, bit_size, sign, code, bits;
......
...@@ -903,6 +903,7 @@ int ff_h263_resync(MpegEncContext *s); ...@@ -903,6 +903,7 @@ int ff_h263_resync(MpegEncContext *s);
int ff_h263_get_gob_height(MpegEncContext *s); int ff_h263_get_gob_height(MpegEncContext *s);
int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my); int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
inline int ff_h263_round_chroma(int x); inline int ff_h263_round_chroma(int x);
void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code);
/* rv10.c */ /* rv10.c */
......
This diff is collapsed.
...@@ -8,28 +8,6 @@ static const uint8_t svq1_block_type_vlc[4][2] = { ...@@ -8,28 +8,6 @@ static const uint8_t svq1_block_type_vlc[4][2] = {
}; };
/* values in this table range from -32..32; adjust retrieved value by -32 */
static const uint8_t svq1_motion_component_vlc[65][2] = {
/* { code, length } */
{ 0x5, 13 }, { 0x7, 13 }, { 0x5, 12 }, { 0x7, 12 },
{ 0x9, 12 }, { 0xB, 12 }, { 0xD, 12 }, { 0xF, 12 },
{ 0x9, 11 }, { 0xB, 11 }, { 0xD, 11 }, { 0xF, 11 },
{ 0x11, 11 }, { 0x13, 11 }, { 0x15, 11 }, { 0x17, 11 },
{ 0x19, 11 }, { 0x1B, 11 }, { 0x1D, 11 }, { 0x1F, 11 },
{ 0x21, 11 }, { 0x23, 11 }, { 0x13, 10 }, { 0x15, 10 },
{ 0x17, 10 }, { 0x7, 8 }, { 0x9, 8 }, { 0xB, 8 },
{ 0x7, 7 }, { 0x3, 5 }, { 0x3, 4 }, { 0x3, 3 },
{ 0x1, 1 }, { 0x2, 3 }, { 0x2, 4 }, { 0x2, 5 },
{ 0x6, 7 }, { 0xA, 8 }, { 0x8, 8 }, { 0x6, 8 },
{ 0x16, 10 }, { 0x14, 10 }, { 0x12, 10 }, { 0x22, 11 },
{ 0x20, 11 }, { 0x1E, 11 }, { 0x1C, 11 }, { 0x1A, 11 },
{ 0x18, 11 }, { 0x16, 11 }, { 0x14, 11 }, { 0x12, 11 },
{ 0x10, 11 }, { 0xE, 11 }, { 0xC, 11 }, { 0xA, 11 },
{ 0x8, 11 }, { 0xE, 12 }, { 0xC, 12 }, { 0xA, 12 },
{ 0x8, 12 }, { 0x6, 12 }, { 0x4, 12 }, { 0x6, 13 },
{ 0x4, 13 }
};
/* values in this table range from -1..6; adjust retrieved value by -1 */ /* values in this table range from -1..6; adjust retrieved value by -1 */
static const uint8_t svq1_intra_multistage_vlc[6][8][2] = { static const uint8_t svq1_intra_multistage_vlc[6][8][2] = {
/* { code, length } */ /* { code, length } */
......
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