You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.0KB

  1. /*
  2. * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdint.h>
  21. #include <stdio.h>
  22. #include "avcodec.h"
  23. #include "dsputil.h"
  24. #include "get_bits.h"
  25. #include "golomb.h"
  26. #include "put_bits.h"
  27. #undef printf
  28. #define COUNT 8000
  29. #define SIZE (COUNT * 40)
  30. int main(void)
  31. {
  32. int i;
  33. uint8_t temp[SIZE];
  34. PutBitContext pb;
  35. GetBitContext gb;
  36. init_put_bits(&pb, temp, SIZE);
  37. printf("testing unsigned exp golomb\n");
  38. for (i = 0; i < COUNT; i++)
  39. set_ue_golomb(&pb, i);
  40. flush_put_bits(&pb);
  41. init_get_bits(&gb, temp, 8 * SIZE);
  42. for (i = 0; i < COUNT; i++) {
  43. int j, s = show_bits(&gb, 24);
  44. j = get_ue_golomb(&gb);
  45. if (j != i)
  46. printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s);
  47. }
  48. init_put_bits(&pb, temp, SIZE);
  49. printf("testing signed exp golomb\n");
  50. for (i = 0; i < COUNT; i++)
  51. set_se_golomb(&pb, i - COUNT / 2);
  52. flush_put_bits(&pb);
  53. init_get_bits(&gb, temp, 8 * SIZE);
  54. for (i = 0; i < COUNT; i++) {
  55. int j, s = show_bits(&gb, 24);
  56. j = get_se_golomb(&gb);
  57. if (j != i - COUNT / 2)
  58. printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s);
  59. }
  60. return 0;
  61. }