2 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of FFmpeg.
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.
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.
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
24 #include "libavutil/mem.h"
31 #define SIZE (COUNT * 4)
40 temp = av_malloc(SIZE);
44 init_put_bits(&pb, temp, SIZE);
45 for (i = 0; i < COUNT; i++)
46 set_ue_golomb(&pb, i);
49 init_get_bits(&gb, temp, 8 * SIZE);
50 for (i = 0; i < COUNT; i++) {
51 int j, s = show_bits(&gb, 25);
53 j = get_ue_golomb(&gb);
55 fprintf(stderr, "get_ue_golomb: expected %d, got %d. bits: %7x\n",
61 #define EXTEND(i) ((i) << 3 | (i) & 7)
62 init_put_bits(&pb, temp, SIZE);
63 for (i = 0; i < COUNT; i++)
64 set_ue_golomb(&pb, EXTEND(i));
67 init_get_bits(&gb, temp, 8 * SIZE);
68 for (i = 0; i < COUNT; i++) {
69 int j, s = show_bits_long(&gb, 32);
71 j = get_ue_golomb_long(&gb);
73 fprintf(stderr, "get_ue_golomb_long: expected %d, got %d. "
74 "bits: %8x\n", EXTEND(i), j, s);
79 init_put_bits(&pb, temp, SIZE);
80 for (i = 0; i < COUNT; i++)
81 set_se_golomb(&pb, i - COUNT / 2);
84 init_get_bits(&gb, temp, 8 * SIZE);
85 for (i = 0; i < COUNT; i++) {
86 int j, s = show_bits(&gb, 25);
88 j = get_se_golomb(&gb);
89 if (j != i - COUNT / 2) {
90 fprintf(stderr, "get_se_golomb: expected %d, got %d. bits: %7x\n",