| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> | ||
| 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 | /** | ||
| 22 | * @file | ||
| 23 | * Range decoder functions common to VP8 and VP9 | ||
| 24 | */ | ||
| 25 | |||
| 26 | #ifndef AVCODEC_VP89_RAC_H | ||
| 27 | #define AVCODEC_VP89_RAC_H | ||
| 28 | |||
| 29 | #include <stdint.h> | ||
| 30 | |||
| 31 | #include "libavutil/attributes.h" | ||
| 32 | |||
| 33 | #include "vpx_rac.h" | ||
| 34 | |||
| 35 | // rounding is different than vpx_rac_get, is vpx_rac_get wrong? | ||
| 36 | 10324687 | static av_always_inline int vp89_rac_get(VPXRangeCoder *c) | |
| 37 | { | ||
| 38 | 10324687 | return vpx_rac_get_prob(c, 128); | |
| 39 | } | ||
| 40 | |||
| 41 | 49424 | av_unused static int vp89_rac_get_uint(VPXRangeCoder *c, int bits) | |
| 42 | { | ||
| 43 | 49424 | int value = 0; | |
| 44 | |||
| 45 |
2/2✓ Branch 0 taken 249959 times.
✓ Branch 1 taken 49424 times.
|
299383 | while (bits--) { |
| 46 | 249959 | value = (value << 1) | vp89_rac_get(c); | |
| 47 | } | ||
| 48 | |||
| 49 | 49424 | return value; | |
| 50 | } | ||
| 51 | |||
| 52 | // how probabilities are associated with decisions is different I think | ||
| 53 | // well, the new scheme fits in the old but this way has one fewer branches per decision | ||
| 54 | 4310819 | static av_always_inline int vp89_rac_get_tree(VPXRangeCoder *c, const int8_t (*tree)[2], | |
| 55 | const uint8_t *probs) | ||
| 56 | { | ||
| 57 | 4310819 | int i = 0; | |
| 58 | |||
| 59 | do { | ||
| 60 | 9594907 | i = tree[i][vpx_rac_get_prob(c, probs[i])]; | |
| 61 |
2/2✓ Branch 0 taken 5284088 times.
✓ Branch 1 taken 4310819 times.
|
9594907 | } while (i > 0); |
| 62 | |||
| 63 | 4310819 | return -i; | |
| 64 | } | ||
| 65 | |||
| 66 | #endif /* AVCODEC_VP89_RAC_H */ | ||
| 67 |