+ s->f_count++;
+ } else
+ { // RAL: All the following bloc added for B frames:
+ if (cbp != 0)
+ { // With coded bloc pattern
+ if (s->mv_dir == (MV_DIR_FORWARD | MV_DIR_BACKWARD))
+ { // Bi-directional motion
+ if (s->dquant)
+ { // With QScale
+ put_bits(&s->pb, 5, 2);
+ put_bits(&s->pb, 5, s->qscale);
+ }
+ else // Without QScale
+ put_bits(&s->pb, 2, 3);
+ s->misc_bits += get_bits_diff(s);
+ mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code);
+ mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ s->f_count++;
+ s->mv_bits += get_bits_diff(s);
+ put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);
+ }
+ else if (s->mv_dir == MV_DIR_BACKWARD)
+ { // Backward motion
+ if (s->dquant)
+ { // With QScale
+ put_bits(&s->pb, 6, 2);
+ put_bits(&s->pb, 5, s->qscale);
+ }
+ else // Without QScale
+ put_bits(&s->pb, 3, 3);
+ s->misc_bits += get_bits_diff(s);
+ mpeg1_encode_motion(s, motion_x - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ s->mv_bits += get_bits_diff(s);
+ put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);
+ }
+ else if (s->mv_dir == MV_DIR_FORWARD)
+ { // Forward motion
+ if (s->dquant)
+ { // With QScale
+ put_bits(&s->pb, 6, 3);
+ put_bits(&s->pb, 5, s->qscale);
+ }
+ else // Without QScale
+ put_bits(&s->pb, 4, 3);
+ s->misc_bits += get_bits_diff(s);
+ mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code);
+ s->f_count++;
+ s->mv_bits += get_bits_diff(s);
+ put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);
+ }
+ }
+ else
+ { // No coded bloc pattern
+ if (s->mv_dir == (MV_DIR_FORWARD | MV_DIR_BACKWARD))
+ { // Bi-directional motion
+ put_bits(&s->pb, 2, 2); /* backward & forward motion */
+ mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code);
+ mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ s->f_count++;
+ }
+ else if (s->mv_dir == MV_DIR_BACKWARD)
+ { // Backward motion
+ put_bits(&s->pb, 3, 2); /* backward motion only */
+ mpeg1_encode_motion(s, motion_x - s->last_mv[1][0][0], s->b_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[1][0][1], s->b_code);
+ s->b_count++;
+ }
+ else if (s->mv_dir == MV_DIR_FORWARD)
+ { // Forward motion
+ put_bits(&s->pb, 4, 2); /* forward motion only */
+ mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code);
+ mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code);
+ s->f_count++;
+ }
+ s->qscale -= s->dquant;
+ s->mv_bits += get_bits_diff(s);
+ }
+ // End of bloc from RAL