Coverage Report

Created: 2026-04-01 07:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/mpeg4audio_copy_pce.h
Line
Count
Source
1
/*
2
 * MPEG-4 Audio PCE copying function
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
#ifndef AVCODEC_MPEG4AUDIO_COPY_PCE_H
22
#define AVCODEC_MPEG4AUDIO_COPY_PCE_H
23
24
#include "libavutil/attributes.h"
25
26
#include "get_bits.h"
27
#include "put_bits.h"
28
29
static av_always_inline unsigned int ff_pce_copy_bits(PutBitContext *pb,
30
                                                      GetBitContext *gb,
31
                                                      int bits)
32
79.2k
{
33
79.2k
    unsigned int el = get_bits(gb, bits);
34
79.2k
    put_bits(pb, bits, el);
35
79.2k
    return el;
36
79.2k
}
37
38
static inline int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
39
567
{
40
567
    int five_bit_ch, four_bit_ch, comment_size, bits;
41
567
    int offset = put_bits_count(pb);
42
43
567
    ff_pce_copy_bits(pb, gb, 10);               // Tag, Object Type, Frequency
44
567
    five_bit_ch  = ff_pce_copy_bits(pb, gb, 4); // Front
45
567
    five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Side
46
567
    five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Back
47
567
    four_bit_ch  = ff_pce_copy_bits(pb, gb, 2); // LFE
48
567
    four_bit_ch += ff_pce_copy_bits(pb, gb, 3); // Data
49
567
    five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Coupling
50
567
    if (ff_pce_copy_bits(pb, gb, 1))            // Mono Mixdown
51
325
        ff_pce_copy_bits(pb, gb, 4);
52
567
    if (ff_pce_copy_bits(pb, gb, 1))            // Stereo Mixdown
53
304
        ff_pce_copy_bits(pb, gb, 4);
54
567
    if (ff_pce_copy_bits(pb, gb, 1))            // Matrix Mixdown
55
281
        ff_pce_copy_bits(pb, gb, 3);
56
5.58k
    for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16)
57
5.01k
        ff_pce_copy_bits(pb, gb, 16);
58
567
    if (bits)
59
522
        ff_pce_copy_bits(pb, gb, bits);
60
567
    align_put_bits(pb);
61
567
    align_get_bits(gb);
62
567
    comment_size = ff_pce_copy_bits(pb, gb, 8);
63
67.1k
    for (; comment_size > 0; comment_size--)
64
66.5k
        ff_pce_copy_bits(pb, gb, 8);
65
66
567
    return put_bits_count(pb) - offset;
67
567
}
68
69
#endif /* AVCODEC_MPEG4AUDIO_COPY_PCE_H */