yading@11
|
1 /*
|
yading@11
|
2 * This file is part of FFmpeg.
|
yading@11
|
3 *
|
yading@11
|
4 * FFmpeg is free software; you can redistribute it and/or
|
yading@11
|
5 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
6 * License as published by the Free Software Foundation; either
|
yading@11
|
7 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
8 *
|
yading@11
|
9 * FFmpeg is distributed in the hope that it will be useful,
|
yading@11
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
12 * Lesser General Public License for more details.
|
yading@11
|
13 *
|
yading@11
|
14 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
15 * License along with FFmpeg; if not, write to the Free Software
|
yading@11
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
17 */
|
yading@11
|
18
|
yading@11
|
19 #include "config.h"
|
yading@11
|
20 #include "avutil.h"
|
yading@11
|
21 #include "avassert.h"
|
yading@11
|
22 #include "samplefmt.h"
|
yading@11
|
23 #include "pixdesc.h"
|
yading@11
|
24
|
yading@11
|
25 /**
|
yading@11
|
26 * @file
|
yading@11
|
27 * various utility functions
|
yading@11
|
28 */
|
yading@11
|
29
|
yading@11
|
30 unsigned avutil_version(void)
|
yading@11
|
31 {
|
yading@11
|
32 static int checks_done;
|
yading@11
|
33 if (checks_done)
|
yading@11
|
34 return LIBAVUTIL_VERSION_INT;
|
yading@11
|
35
|
yading@11
|
36 av_assert0(AV_PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
|
yading@11
|
37 av_assert0(AV_SAMPLE_FMT_DBLP == 9);
|
yading@11
|
38 av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
|
yading@11
|
39 av_assert0(AV_PICTURE_TYPE_BI == 7);
|
yading@11
|
40 av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
|
yading@11
|
41 av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
|
yading@11
|
42
|
yading@11
|
43 if (av_sat_dadd32(1, 2) != 5) {
|
yading@11
|
44 av_log(NULL, AV_LOG_FATAL, "Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\n");
|
yading@11
|
45 abort();
|
yading@11
|
46 }
|
yading@11
|
47
|
yading@11
|
48 ff_check_pixfmt_descriptors();
|
yading@11
|
49 checks_done = 1;
|
yading@11
|
50 return LIBAVUTIL_VERSION_INT;
|
yading@11
|
51 }
|
yading@11
|
52
|
yading@11
|
53 const char *avutil_configuration(void)
|
yading@11
|
54 {
|
yading@11
|
55 return FFMPEG_CONFIGURATION;
|
yading@11
|
56 }
|
yading@11
|
57
|
yading@11
|
58 const char *avutil_license(void)
|
yading@11
|
59 {
|
yading@11
|
60 #define LICENSE_PREFIX "libavutil license: "
|
yading@11
|
61 return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
|
yading@11
|
62 }
|
yading@11
|
63
|
yading@11
|
64 const char *av_get_media_type_string(enum AVMediaType media_type)
|
yading@11
|
65 {
|
yading@11
|
66 switch (media_type) {
|
yading@11
|
67 case AVMEDIA_TYPE_VIDEO: return "video";
|
yading@11
|
68 case AVMEDIA_TYPE_AUDIO: return "audio";
|
yading@11
|
69 case AVMEDIA_TYPE_DATA: return "data";
|
yading@11
|
70 case AVMEDIA_TYPE_SUBTITLE: return "subtitle";
|
yading@11
|
71 case AVMEDIA_TYPE_ATTACHMENT: return "attachment";
|
yading@11
|
72 default: return NULL;
|
yading@11
|
73 }
|
yading@11
|
74 }
|
yading@11
|
75
|
yading@11
|
76 char av_get_picture_type_char(enum AVPictureType pict_type)
|
yading@11
|
77 {
|
yading@11
|
78 switch (pict_type) {
|
yading@11
|
79 case AV_PICTURE_TYPE_I: return 'I';
|
yading@11
|
80 case AV_PICTURE_TYPE_P: return 'P';
|
yading@11
|
81 case AV_PICTURE_TYPE_B: return 'B';
|
yading@11
|
82 case AV_PICTURE_TYPE_S: return 'S';
|
yading@11
|
83 case AV_PICTURE_TYPE_SI: return 'i';
|
yading@11
|
84 case AV_PICTURE_TYPE_SP: return 'p';
|
yading@11
|
85 case AV_PICTURE_TYPE_BI: return 'b';
|
yading@11
|
86 default: return '?';
|
yading@11
|
87 }
|
yading@11
|
88 }
|
yading@11
|
89
|
yading@11
|
90 unsigned av_int_list_length_for_size(unsigned elsize,
|
yading@11
|
91 const void *list, uint64_t term)
|
yading@11
|
92 {
|
yading@11
|
93 unsigned i;
|
yading@11
|
94
|
yading@11
|
95 if (!list)
|
yading@11
|
96 return 0;
|
yading@11
|
97 #define LIST_LENGTH(type) \
|
yading@11
|
98 { type t = term, *l = list; for (i = 0; l[i] != t; i++); }
|
yading@11
|
99 switch (elsize) {
|
yading@11
|
100 case 1: LIST_LENGTH(uint8_t); break;
|
yading@11
|
101 case 2: LIST_LENGTH(uint16_t); break;
|
yading@11
|
102 case 4: LIST_LENGTH(uint32_t); break;
|
yading@11
|
103 case 8: LIST_LENGTH(uint64_t); break;
|
yading@11
|
104 default: av_assert0(!"valid element size");
|
yading@11
|
105 }
|
yading@11
|
106 return i;
|
yading@11
|
107 }
|