Coverage Report

Created: 2026-10-28 08:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavutil/utils.c
Line
Count
Source
1
/*
2
 * This file is part of FFmpeg.
3
 *
4
 * FFmpeg 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
 * FFmpeg 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 GNU
12
 * 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 FFmpeg; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 */
18
19
#include "config.h"
20
#include "avutil.h"
21
#include "avassert.h"
22
23
/**
24
 * @file
25
 * various utility functions
26
 */
27
28
const char *av_get_media_type_string(enum AVMediaType media_type)
29
2.04M
{
30
2.04M
    switch (media_type) {
31
926k
    case AVMEDIA_TYPE_VIDEO:      return "video";
32
928k
    case AVMEDIA_TYPE_AUDIO:      return "audio";
33
774
    case AVMEDIA_TYPE_DATA:       return "data";
34
25.3k
    case AVMEDIA_TYPE_SUBTITLE:   return "subtitle";
35
11.3k
    case AVMEDIA_TYPE_ATTACHMENT: return "attachment";
36
155k
    default:                      return NULL;
37
2.04M
    }
38
2.04M
}
39
40
char av_get_picture_type_char(enum AVPictureType pict_type)
41
783k
{
42
783k
    switch (pict_type) {
43
290k
    case AV_PICTURE_TYPE_I:  return 'I';
44
313k
    case AV_PICTURE_TYPE_P:  return 'P';
45
99.4k
    case AV_PICTURE_TYPE_B:  return 'B';
46
7.81k
    case AV_PICTURE_TYPE_S:  return 'S';
47
12.9k
    case AV_PICTURE_TYPE_SI: return 'i';
48
32.2k
    case AV_PICTURE_TYPE_SP: return 'p';
49
26
    case AV_PICTURE_TYPE_BI: return 'b';
50
27.2k
    default:                 return '?';
51
783k
    }
52
783k
}
53
54
char *av_fourcc_make_string(char *buf, uint32_t fourcc)
55
105M
{
56
105M
    int i;
57
105M
    char *orig_buf = buf;
58
105M
    size_t buf_size = AV_FOURCC_MAX_STRING_SIZE;
59
60
527M
    for (i = 0; i < 4; i++) {
61
422M
        const int c = fourcc & 0xff;
62
422M
        const int print_chr = (c >= '0' && c <= '9') ||
63
415M
                              (c >= 'a' && c <= 'z') ||
64
160M
                              (c >= 'A' && c <= 'Z') ||
65
146M
                              (c && strchr(". -_", c));
66
422M
        const int len = snprintf(buf, buf_size, print_chr ? "%c" : "[%d]", c);
67
422M
        if (len < 0)
68
0
            break;
69
422M
        buf += len;
70
422M
        buf_size = buf_size > len ? buf_size - len : 0;
71
422M
        fourcc >>= 8;
72
422M
    }
73
74
105M
    return orig_buf;
75
105M
}
76
77
AVRational av_get_time_base_q(void)
78
0
{
79
0
    return (AVRational){1, AV_TIME_BASE};
80
0
}
81
#if FF_API_ASSERT_FPU
82
0
void av_assert0_fpu(void) {
83
#if HAVE_MMX_INLINE
84
    uint16_t state[14];
85
     __asm__ volatile (
86
        "fstenv %0 \n\t"
87
        : "+m" (state)
88
        :
89
        : "memory"
90
    );
91
    av_assert0((state[4] & 3) == 3);
92
#endif
93
0
}
94
#endif