Coverage Report

Created: 2025-11-16 07:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/raw.c
Line
Count
Source
1
/*
2
 * Raw Video Codec
3
 * Copyright (c) 2001 Fabrice Bellard
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21
22
/**
23
 * @file
24
 * Raw Video Codec
25
 */
26
27
#include "avcodec.h"
28
#include "raw.h"
29
#include "raw_pix_fmt_tags.h"
30
31
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
32
24.6k
{
33
24.6k
    const PixelFormatTag *tags = raw_pix_fmt_tags;
34
4.64M
    while (tags->pix_fmt >= 0) {
35
4.62M
        if (tags->pix_fmt == fmt)
36
9.12k
            return tags->fourcc;
37
4.61M
        tags++;
38
4.61M
    }
39
15.5k
    return 0;
40
24.6k
}
41
42
static const PixelFormatTag pix_fmt_bps_avi[] = {
43
    { AV_PIX_FMT_PAL8,    1 },
44
    { AV_PIX_FMT_PAL8,    2 },
45
    { AV_PIX_FMT_PAL8,    4 },
46
    { AV_PIX_FMT_PAL8,    8 },
47
    { AV_PIX_FMT_RGB444LE, 12 },
48
    { AV_PIX_FMT_RGB555LE, 15 },
49
    { AV_PIX_FMT_RGB555LE, 16 },
50
    { AV_PIX_FMT_BGR24,  24 },
51
    { AV_PIX_FMT_BGRA,   32 },
52
    { AV_PIX_FMT_NONE,    0 },
53
};
54
55
static const PixelFormatTag pix_fmt_bps_mov[] = {
56
    { AV_PIX_FMT_PAL8,      1 },
57
    { AV_PIX_FMT_PAL8,      2 },
58
    { AV_PIX_FMT_PAL8,      4 },
59
    { AV_PIX_FMT_PAL8,      8 },
60
    { AV_PIX_FMT_RGB555BE, 16 },
61
    { AV_PIX_FMT_RGB24,    24 },
62
    { AV_PIX_FMT_ARGB,     32 },
63
    { AV_PIX_FMT_PAL8,     33 },
64
    { AV_PIX_FMT_NONE,      0 },
65
};
66
67
static enum AVPixelFormat find_pix_fmt(const PixelFormatTag *tags,
68
                                       unsigned int fourcc)
69
25.8k
{
70
4.80M
    while (tags->pix_fmt != AV_PIX_FMT_NONE) {
71
4.78M
        if (tags->fourcc == fourcc)
72
10.0k
            return tags->pix_fmt;
73
4.77M
        tags++;
74
4.77M
    }
75
15.8k
    return AV_PIX_FMT_NONE;
76
25.8k
}
77
78
enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
79
                                       unsigned fourcc)
80
25.8k
{
81
25.8k
    const PixelFormatTag *tags;
82
83
25.8k
    switch (list) {
84
25.3k
    case PIX_FMT_LIST_RAW:
85
25.3k
        tags = raw_pix_fmt_tags;
86
25.3k
        break;
87
449
    case PIX_FMT_LIST_AVI:
88
449
        tags = pix_fmt_bps_avi;
89
449
        break;
90
32
    case PIX_FMT_LIST_MOV:
91
32
        tags = pix_fmt_bps_mov;
92
32
        break;
93
25.8k
    }
94
25.8k
    return find_pix_fmt(tags, fourcc);
95
25.8k
}