GCC Code Coverage Report
Directory: ../../../ffmpeg/ Exec Total Coverage
File: src/libavcodec/amr.h Lines: 11 11 100.0 %
Date: 2019-11-22 03:34:36 Branches: 4 4 100.0 %

Line Branch Exec Source
1
/*
2
 * Shared functions between AMR codecs
3
 *
4
 * Copyright (c) 2010 Marcelo Galvao Povoa
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
#ifndef AVCODEC_AMR_H
24
#define AVCODEC_AMR_H
25
26
#include <string.h>
27
28
#include "avcodec.h"
29
30
#ifdef AMR_USE_16BIT_TABLES
31
typedef uint16_t R_TABLE_TYPE;
32
#else
33
typedef uint8_t R_TABLE_TYPE;
34
#endif
35
36
/**
37
 * Fill the frame structure variables from bitstream by parsing the
38
 * given reordering table that uses the following format:
39
 *
40
 * Each field (16 bits) in the AMR Frame is stored as:
41
 * - one byte for the number of bits in the field
42
 * - one byte for the field index
43
 * - then, one byte for each bit of the field (from most-significant to least)
44
 *         of the position of that bit in the AMR frame.
45
 *
46
 * @param out pointer to the frame struct
47
 * @param size the size in bytes of the frame struct
48
 * @param data input bitstream after the frame header
49
 * @param ord_table the reordering table as above
50
 */
51
8528
static inline void ff_amr_bit_reorder(uint16_t *out, int size,
52
                                      const uint8_t *data,
53
                                      const R_TABLE_TYPE *ord_table)
54
{
55
    int field_size;
56
57
8528
    memset(out, 0, size);
58
352512
    while ((field_size = *ord_table++)) {
59
343984
        int field = 0;
60
343984
        int field_offset = *ord_table++;
61
2938668
        while (field_size--) {
62
2594684
           int bit = *ord_table++;
63
2594684
           field <<= 1;
64
2594684
           field |= data[bit >> 3] >> (bit & 7) & 1;
65
        }
66
343984
        out[field_offset >> 1] = field;
67
    }
68
8528
}
69
70
#endif /* AVCODEC_AMR_H */