| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | |||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdio.h> | ||
| 23 | |||
| 24 | #include "libavutil/internal.h" | ||
| 25 | #include "libavutil/mem.h" | ||
| 26 | |||
| 27 | #include "libavcodec/get_bits.h" | ||
| 28 | #include "libavcodec/golomb.h" | ||
| 29 | #include "libavcodec/put_bits.h" | ||
| 30 | #include "libavcodec/put_golomb.h" | ||
| 31 | |||
| 32 | #define COUNT 8191 | ||
| 33 | #define SIZE (COUNT * 4) | ||
| 34 | |||
| 35 | 1 | int main(void) | |
| 36 | { | ||
| 37 | 1 | int i, ret = 0; | |
| 38 | uint8_t *temp; | ||
| 39 | PutBitContext pb; | ||
| 40 | GetBitContext gb; | ||
| 41 | |||
| 42 | 1 | temp = av_malloc(SIZE); | |
| 43 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!temp) |
| 44 | ✗ | return 2; | |
| 45 | |||
| 46 | 1 | init_put_bits(&pb, temp, SIZE); | |
| 47 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) |
| 48 | 8191 | set_ue_golomb(&pb, i); | |
| 49 | 1 | flush_put_bits(&pb); | |
| 50 | |||
| 51 | 1 | init_get_bits(&gb, temp, 8 * SIZE); | |
| 52 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) { |
| 53 | 8191 | int j, s = show_bits(&gb, 25); | |
| 54 | |||
| 55 | 8191 | j = get_ue_golomb(&gb); | |
| 56 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8191 times.
|
8191 | if (j != i) { |
| 57 | ✗ | fprintf(stderr, "get_ue_golomb: expected %d, got %d. bits: %7x\n", | |
| 58 | i, j, s); | ||
| 59 | ✗ | ret = 1; | |
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | #define EXTEND(i) ((i) << 3 | (i) & 7) | ||
| 64 | 1 | init_put_bits(&pb, temp, SIZE); | |
| 65 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) |
| 66 | 8191 | set_ue_golomb(&pb, EXTEND(i)); | |
| 67 | 1 | flush_put_bits(&pb); | |
| 68 | |||
| 69 | 1 | init_get_bits(&gb, temp, 8 * SIZE); | |
| 70 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) { |
| 71 | 8191 | int j, s = show_bits_long(&gb, 32); | |
| 72 | |||
| 73 | 8191 | j = get_ue_golomb_long(&gb); | |
| 74 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8191 times.
|
8191 | if (j != EXTEND(i)) { |
| 75 | ✗ | fprintf(stderr, "get_ue_golomb_long: expected %d, got %d. " | |
| 76 | ✗ | "bits: %8x\n", EXTEND(i), j, s); | |
| 77 | ✗ | ret = 1; | |
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | #define EXTEND_L(i) ((i) << 4 | (i) & 15) | ||
| 82 | 1 | init_put_bits(&pb, temp, SIZE); | |
| 83 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) |
| 84 | 8191 | set_ue_golomb_long(&pb, EXTEND_L(i)); | |
| 85 | 1 | flush_put_bits(&pb); | |
| 86 | |||
| 87 | 1 | init_get_bits(&gb, temp, 8 * SIZE); | |
| 88 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) { |
| 89 | 8191 | int j, s = show_bits_long(&gb, 32); | |
| 90 | |||
| 91 | 8191 | j = get_ue_golomb_long(&gb); | |
| 92 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8191 times.
|
8191 | if (j != EXTEND_L(i)) { |
| 93 | ✗ | fprintf(stderr, "get_ue_golomb_long: expected %d, got %d. " | |
| 94 | ✗ | "bits: %8x\n", EXTEND_L(i), j, s); | |
| 95 | ✗ | ret = 1; | |
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | 1 | init_put_bits(&pb, temp, SIZE); | |
| 100 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) |
| 101 | 8191 | set_se_golomb(&pb, i - COUNT / 2); | |
| 102 | 1 | flush_put_bits(&pb); | |
| 103 | |||
| 104 | 1 | init_get_bits(&gb, temp, 8 * SIZE); | |
| 105 |
2/2✓ Branch 0 taken 8191 times.
✓ Branch 1 taken 1 times.
|
8192 | for (i = 0; i < COUNT; i++) { |
| 106 | 8191 | int j, s = show_bits(&gb, 25); | |
| 107 | |||
| 108 | 8191 | j = get_se_golomb(&gb); | |
| 109 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8191 times.
|
8191 | if (j != i - COUNT / 2) { |
| 110 | ✗ | fprintf(stderr, "get_se_golomb: expected %d, got %d. bits: %7x\n", | |
| 111 | i - COUNT / 2, j, s); | ||
| 112 | ✗ | ret = 1; | |
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | 1 | av_free(temp); | |
| 117 | |||
| 118 | 1 | return ret; | |
| 119 | } | ||
| 120 |