Commit 650788c4 authored by michael's avatar michael

change

for(){
    if(){
        switch(){

to
switch(){
    for(){
        if(){

this halfs the number of times the switch is executed in bidir blocks, in 
other blocks the number is the same


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@9860 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent f570727b
...@@ -375,12 +375,12 @@ static int mpeg_decode_mb(MpegEncContext *s, ...@@ -375,12 +375,12 @@ static int mpeg_decode_mb(MpegEncContext *s,
/* motion vectors */ /* motion vectors */
s->mv_dir = 0; s->mv_dir = 0;
for(i=0;i<2;i++) { dprintf(s->avctx, "motion_type=%d\n", motion_type);
if (USES_LIST(mb_type, i)) { switch(motion_type) {
s->mv_dir |= (MV_DIR_FORWARD >> i); case MT_FRAME: /* or MT_16X8 */
dprintf(s->avctx, "motion_type=%d\n", motion_type); for(i=0;i<2;i++) {
switch(motion_type) { if (USES_LIST(mb_type, i)) {
case MT_FRAME: /* or MT_16X8 */ s->mv_dir |= (MV_DIR_FORWARD >> i);
if (s->picture_structure == PICT_FRAME) { if (s->picture_structure == PICT_FRAME) {
/* MT_FRAME */ /* MT_FRAME */
mb_type |= MB_TYPE_16x16; mb_type |= MB_TYPE_16x16;
...@@ -408,9 +408,14 @@ static int mpeg_decode_mb(MpegEncContext *s, ...@@ -408,9 +408,14 @@ static int mpeg_decode_mb(MpegEncContext *s,
} }
} }
} }
break; }
case MT_FIELD: }
s->mv_type = MV_TYPE_FIELD; break;
case MT_FIELD:
s->mv_type = MV_TYPE_FIELD;
for(i=0;i<2;i++) {
if (USES_LIST(mb_type, i)) {
s->mv_dir |= (MV_DIR_FORWARD >> i);
if (s->picture_structure == PICT_FRAME) { if (s->picture_structure == PICT_FRAME) {
mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED; mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
for(j=0;j<2;j++) { for(j=0;j<2;j++) {
...@@ -437,59 +442,61 @@ static int mpeg_decode_mb(MpegEncContext *s, ...@@ -437,59 +442,61 @@ static int mpeg_decode_mb(MpegEncContext *s,
s->mv[i][0][k] = val; s->mv[i][0][k] = val;
} }
} }
break; }
case MT_DMV: }
{ break;
int dmx, dmy, mx, my, m; case MT_DMV:
s->mv_type = MV_TYPE_DMV;
mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0], for(i=0;i<2;i++) {
s->last_mv[i][0][0]); if (USES_LIST(mb_type, i)) {
s->last_mv[i][0][0] = mx; int dmx, dmy, mx, my, m;
s->last_mv[i][1][0] = mx; s->mv_dir |= (MV_DIR_FORWARD >> i);
dmx = get_dmv(s); mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][0]);
s->last_mv[i][0][1] >> 1); s->last_mv[i][0][0] = mx;
dmy = get_dmv(s); s->last_mv[i][1][0] = mx;
s->mv_type = MV_TYPE_DMV; dmx = get_dmv(s);
my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][0][1] >> 1);
s->last_mv[i][0][1] = my<<1; dmy = get_dmv(s);
s->last_mv[i][1][1] = my<<1;
s->mv[i][0][0] = mx; s->last_mv[i][0][1] = my<<1;
s->mv[i][0][1] = my; s->last_mv[i][1][1] = my<<1;
s->mv[i][1][0] = mx;//not used
s->mv[i][1][1] = my;//not used s->mv[i][0][0] = mx;
s->mv[i][0][1] = my;
if (s->picture_structure == PICT_FRAME) { s->mv[i][1][0] = mx;//not used
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED; s->mv[i][1][1] = my;//not used
//m = 1 + 2 * s->top_field_first; if (s->picture_structure == PICT_FRAME) {
m = s->top_field_first ? 1 : 3; mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
/* top -> top pred */ //m = 1 + 2 * s->top_field_first;
s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx; m = s->top_field_first ? 1 : 3;
s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
m = 4 - m; /* top -> top pred */
s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx; s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1; s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
} else { m = 4 - m;
mb_type |= MB_TYPE_16x16; s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx; } else {
s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy; mb_type |= MB_TYPE_16x16;
if(s->picture_structure == PICT_TOP_FIELD)
s->mv[i][2][1]--; s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
else s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
s->mv[i][2][1]++; if(s->picture_structure == PICT_TOP_FIELD)
} s->mv[i][2][1]--;
else
s->mv[i][2][1]++;
} }
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return -1;
} }
} }
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
return -1;
} }
} }
......
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