| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Lagarith range decoder | ||
| 3 | * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com> | ||
| 4 | * Copyright (c) 2009 David Conrad | ||
| 5 | * | ||
| 6 | * This file is part of FFmpeg. | ||
| 7 | * | ||
| 8 | * FFmpeg is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with FFmpeg; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | /** | ||
| 24 | * @file | ||
| 25 | * Lagarith range decoder | ||
| 26 | * @author Nathan Caldwell | ||
| 27 | * @author David Conrad | ||
| 28 | */ | ||
| 29 | |||
| 30 | #include "get_bits.h" | ||
| 31 | #include "lagarithrac.h" | ||
| 32 | |||
| 33 | 126 | void ff_lag_rac_init(lag_rac *l, GetBitContext *gb, int length) | |
| 34 | { | ||
| 35 | int i, j, left; | ||
| 36 | |||
| 37 | /* According to reference decoder "1st byte is garbage", | ||
| 38 | * however, it gets skipped by the call to align_get_bits() | ||
| 39 | */ | ||
| 40 | 126 | align_get_bits(gb); | |
| 41 | 126 | left = get_bits_left(gb) >> 3; | |
| 42 | 126 | l->bytestream_start = | |
| 43 | 126 | l->bytestream = gb->buffer + get_bits_count(gb) / 8; | |
| 44 | 126 | l->bytestream_end = l->bytestream_start + left; | |
| 45 | |||
| 46 | 126 | l->range = 0x80; | |
| 47 | 126 | l->low = *l->bytestream >> 1; | |
| 48 | 126 | l->hash_shift = FFMAX(l->scale, 10) - 10; | |
| 49 | 126 | l->overread = 0; | |
| 50 | |||
| 51 |
2/2✓ Branch 0 taken 129024 times.
✓ Branch 1 taken 126 times.
|
129150 | for (i = j = 0; i < 1024; i++) { |
| 52 | 129024 | unsigned r = i << l->hash_shift; | |
| 53 |
2/2✓ Branch 0 taken 32130 times.
✓ Branch 1 taken 129024 times.
|
161154 | while (l->prob[j + 1] <= r) |
| 54 | 32130 | j++; | |
| 55 | 129024 | l->range_hash[i] = j; | |
| 56 | } | ||
| 57 | 126 | } | |
| 58 |