| 343 | } |
| 344 | |
| 345 | static void msmpeg4v2_encode_motion(MPVEncContext *const s, int val) |
| 346 | { |
| 347 | int range, bit_size, sign, code, bits; |
| 348 | |
| 349 | if (val == 0) { |
| 350 | /* zero vector; corresponds to ff_mvtab[0] */ |
| 351 | put_bits(&s->pb, 1, 0x1); |
| 352 | } else { |
| 353 | bit_size = s->f_code - 1; |
| 354 | range = 1 << bit_size; |
| 355 | if (val <= -64) |
| 356 | val += 64; |
| 357 | else if (val >= 64) |
| 358 | val -= 64; |
| 359 | |
| 360 | if (val >= 0) { |
| 361 | sign = 0; |
| 362 | } else { |
| 363 | val = -val; |
| 364 | sign = 1; |
| 365 | } |
| 366 | val--; |
| 367 | code = (val >> bit_size) + 1; |
| 368 | bits = val & (range - 1); |
| 369 | |
| 370 | put_bits(&s->pb, ff_mvtab[code][1] + 1, (ff_mvtab[code][0] << 1) | sign); |
| 371 | if (bit_size > 0) { |
| 372 | put_bits(&s->pb, bit_size, bits); |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | static void msmpeg4_encode_mb(MPVEncContext *const s, |
| 378 | int16_t block[][64], |
no test coverage detected