Coverage Report

Created: 2026-09-14 08:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/dcadec.h
Line
Count
Source
1
/*
2
 * Copyright (C) 2016 foo86
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_DCADEC_H
22
#define AVCODEC_DCADEC_H
23
24
#include <stdint.h>
25
26
#include "libavutil/crc.h"
27
#include "libavutil/float_dsp.h"
28
#include "libavutil/log.h"
29
30
#include "avcodec.h"
31
#include "get_bits.h"
32
#include "dca.h"
33
#include "dcadsp.h"
34
#include "dca_core.h"
35
#include "dca_exss.h"
36
#include "dca_xll.h"
37
#include "dca_lbr.h"
38
39
592k
#define DCA_PACKET_CORE         0x01
40
194k
#define DCA_PACKET_EXSS         0x02
41
349k
#define DCA_PACKET_XLL          0x04
42
307k
#define DCA_PACKET_LBR          0x08
43
293k
#define DCA_PACKET_MASK         0x0f
44
45
27.1k
#define DCA_PACKET_RECOVERY     0x10    ///< Sync error recovery flag
46
15.1k
#define DCA_PACKET_RESIDUAL     0x20    ///< Core valid for residual decoding
47
48
enum DCAOutputChannelOrder {
49
    CHANNEL_ORDER_DEFAULT,
50
    CHANNEL_ORDER_CODED,
51
};
52
53
typedef struct DCAContext {
54
    const AVClass   *class;       ///< class for AVOptions
55
    AVCodecContext  *avctx;
56
57
    DCACoreDecoder core;  ///< Core decoder context
58
    DCAExssParser  exss;  ///< EXSS parser context
59
    DCAXllDecoder  xll;   ///< XLL decoder context
60
    DCALbrDecoder  lbr;   ///< LBR decoder context
61
62
    DCADSPContext   dcadsp;
63
64
    const AVCRC     *crctab;
65
66
    uint8_t         *buffer;    ///< Packet buffer
67
    unsigned int    buffer_size;
68
69
    int     packet; ///< Packet flags
70
71
    int     request_channel_layout; ///< Converted from avctx.request_channel_layout
72
    int     core_only;              ///< Core only decoding flag
73
    int     output_channel_order;
74
    AVChannelLayout downmix_layout;
75
} DCAContext;
76
77
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask);
78
79
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples,
80
                                    int *coeff_l, int nsamples, int ch_mask);
81
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples,
82
                                    int *coeff_l, int nsamples, int ch_mask);
83
int ff_dca_export_downmix_matrix(AVCodecContext *avctx, AVFrame *frame,
84
                                 enum DCADownMixType downmix_type,
85
                                 int output_mask, const int *coeff_l);
86
87
static inline int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s,
88
                                   int p1, int p2)
89
387k
{
90
387k
    DCAContext *dca = avctx->priv_data;
91
92
387k
    if (!(avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)))
93
339k
        return 0;
94
48.4k
    if (((p1 | p2) & 7) || p1 < 0 || p2 > s->size_in_bits || p2 - p1 < 16)
95
10.4k
        return -1;
96
38.0k
    if (av_crc(dca->crctab, 0xffff, s->buffer + p1 / 8, (p2 - p1) / 8))
97
10.0k
        return -1;
98
27.9k
    return 0;
99
38.0k
}
dca_exss.c:ff_dca_check_crc
Line
Count
Source
89
230k
{
90
230k
    DCAContext *dca = avctx->priv_data;
91
92
230k
    if (!(avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)))
93
205k
        return 0;
94
25.6k
    if (((p1 | p2) & 7) || p1 < 0 || p2 > s->size_in_bits || p2 - p1 < 16)
95
8.81k
        return -1;
96
16.8k
    if (av_crc(dca->crctab, 0xffff, s->buffer + p1 / 8, (p2 - p1) / 8))
97
5.32k
        return -1;
98
11.5k
    return 0;
99
16.8k
}
Unexecuted instantiation: dcadec.c:ff_dca_check_crc
dca_core.c:ff_dca_check_crc
Line
Count
Source
89
22.2k
{
90
22.2k
    DCAContext *dca = avctx->priv_data;
91
92
22.2k
    if (!(avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)))
93
15.1k
        return 0;
94
7.12k
    if (((p1 | p2) & 7) || p1 < 0 || p2 > s->size_in_bits || p2 - p1 < 16)
95
718
        return -1;
96
6.40k
    if (av_crc(dca->crctab, 0xffff, s->buffer + p1 / 8, (p2 - p1) / 8))
97
1.05k
        return -1;
98
5.35k
    return 0;
99
6.40k
}
Unexecuted instantiation: dca_lbr.c:ff_dca_check_crc
dca_xll.c:ff_dca_check_crc
Line
Count
Source
89
134k
{
90
134k
    DCAContext *dca = avctx->priv_data;
91
92
134k
    if (!(avctx->err_recognition & (AV_EF_CRCCHECK | AV_EF_CAREFUL)))
93
118k
        return 0;
94
15.6k
    if (((p1 | p2) & 7) || p1 < 0 || p2 > s->size_in_bits || p2 - p1 < 16)
95
908
        return -1;
96
14.7k
    if (av_crc(dca->crctab, 0xffff, s->buffer + p1 / 8, (p2 - p1) / 8))
97
3.67k
        return -1;
98
11.0k
    return 0;
99
14.7k
}
100
101
static inline int ff_dca_seek_bits(GetBitContext *s, int p)
102
1.72M
{
103
1.72M
    if (p < get_bits_count(s) || p > s->size_in_bits)
104
811k
        return -1;
105
910k
    skip_bits_long(s, p - get_bits_count(s));
106
910k
    return 0;
107
1.72M
}
dca_exss.c:ff_dca_seek_bits
Line
Count
Source
102
1.43M
{
103
1.43M
    if (p < get_bits_count(s) || p > s->size_in_bits)
104
755k
        return -1;
105
677k
    skip_bits_long(s, p - get_bits_count(s));
106
677k
    return 0;
107
1.43M
}
Unexecuted instantiation: dcadec.c:ff_dca_seek_bits
dca_core.c:ff_dca_seek_bits
Line
Count
Source
102
103k
{
103
103k
    if (p < get_bits_count(s) || p > s->size_in_bits)
104
6.85k
        return -1;
105
97.0k
    skip_bits_long(s, p - get_bits_count(s));
106
97.0k
    return 0;
107
103k
}
Unexecuted instantiation: dca_lbr.c:ff_dca_seek_bits
dca_xll.c:ff_dca_seek_bits
Line
Count
Source
102
184k
{
103
184k
    if (p < get_bits_count(s) || p > s->size_in_bits)
104
49.0k
        return -1;
105
135k
    skip_bits_long(s, p - get_bits_count(s));
106
135k
    return 0;
107
184k
}
108
109
#endif