Coverage Report

Created: 2025-12-27 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mpv/misc/lavc_compat.h
Line
Count
Source
1
/*
2
 * This file is part of mpv.
3
 *
4
 * mpv is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * mpv is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with mpv.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
#pragma once
19
20
#include <libavcodec/avcodec.h>
21
22
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 13, 100)
23
enum AVCodecConfig {
24
    AV_CODEC_CONFIG_PIX_FORMAT,     ///< AVPixelFormat, terminated by AV_PIX_FMT_NONE
25
    AV_CODEC_CONFIG_FRAME_RATE,     ///< AVRational, terminated by {0, 0}
26
    AV_CODEC_CONFIG_SAMPLE_RATE,    ///< int, terminated by 0
27
    AV_CODEC_CONFIG_SAMPLE_FORMAT,  ///< AVSampleFormat, terminated by AV_SAMPLE_FMT_NONE
28
    AV_CODEC_CONFIG_CHANNEL_LAYOUT, ///< AVChannelLayout, terminated by {0}
29
    AV_CODEC_CONFIG_COLOR_RANGE,    ///< AVColorRange, terminated by AVCOL_RANGE_UNSPECIFIED
30
    AV_CODEC_CONFIG_COLOR_SPACE,    ///< AVColorSpace, terminated by AVCOL_SPC_UNSPECIFIED
31
};
32
#endif
33
34
static inline int mp_avcodec_get_supported_config(const AVCodecContext *avctx,
35
                                                  const AVCodec *codec,
36
                                                  enum AVCodecConfig config,
37
                                                  const void **out_configs)
38
0
{
39
0
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 13, 100)
40
0
    return avcodec_get_supported_config(avctx, codec, config, 0, out_configs, NULL);
41
#else
42
    const AVCodec *avcodec = codec ? codec : avctx->codec;
43
44
    switch (config) {
45
    case AV_CODEC_CONFIG_PIX_FORMAT:
46
        *out_configs = avcodec->pix_fmts;
47
        break;
48
    case AV_CODEC_CONFIG_FRAME_RATE:
49
        *out_configs = avcodec->supported_framerates;
50
        break;
51
    case AV_CODEC_CONFIG_SAMPLE_RATE:
52
        *out_configs = avcodec->supported_samplerates;
53
        break;
54
    case AV_CODEC_CONFIG_SAMPLE_FORMAT:
55
        *out_configs = avcodec->sample_fmts;
56
        break;
57
    case AV_CODEC_CONFIG_CHANNEL_LAYOUT:
58
        *out_configs = avcodec->ch_layouts;
59
        break;
60
    default:
61
        abort();  // Not implemented
62
    }
63
64
    return *out_configs ? 0 : -1;
65
#endif
66
0
}
Unexecuted instantiation: image_writer.c:mp_avcodec_get_supported_config
Unexecuted instantiation: vo_lavc.c:mp_avcodec_get_supported_config
Unexecuted instantiation: ao_lavc.c:mp_avcodec_get_supported_config
Unexecuted instantiation: af_lavcac3enc.c:mp_avcodec_get_supported_config