yading@11: /* yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #include "config.h" yading@11: #include "avutil.h" yading@11: #include "avassert.h" yading@11: #include "samplefmt.h" yading@11: #include "pixdesc.h" yading@11: yading@11: /** yading@11: * @file yading@11: * various utility functions yading@11: */ yading@11: yading@11: unsigned avutil_version(void) yading@11: { yading@11: static int checks_done; yading@11: if (checks_done) yading@11: return LIBAVUTIL_VERSION_INT; yading@11: yading@11: 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: av_assert0(AV_SAMPLE_FMT_DBLP == 9); yading@11: av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4); yading@11: av_assert0(AV_PICTURE_TYPE_BI == 7); yading@11: av_assert0(LIBAVUTIL_VERSION_MICRO >= 100); yading@11: av_assert0(HAVE_MMX2 == HAVE_MMXEXT); yading@11: yading@11: if (av_sat_dadd32(1, 2) != 5) { yading@11: av_log(NULL, AV_LOG_FATAL, "Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\n"); yading@11: abort(); yading@11: } yading@11: yading@11: ff_check_pixfmt_descriptors(); yading@11: checks_done = 1; yading@11: return LIBAVUTIL_VERSION_INT; yading@11: } yading@11: yading@11: const char *avutil_configuration(void) yading@11: { yading@11: return FFMPEG_CONFIGURATION; yading@11: } yading@11: yading@11: const char *avutil_license(void) yading@11: { yading@11: #define LICENSE_PREFIX "libavutil license: " yading@11: return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; yading@11: } yading@11: yading@11: const char *av_get_media_type_string(enum AVMediaType media_type) yading@11: { yading@11: switch (media_type) { yading@11: case AVMEDIA_TYPE_VIDEO: return "video"; yading@11: case AVMEDIA_TYPE_AUDIO: return "audio"; yading@11: case AVMEDIA_TYPE_DATA: return "data"; yading@11: case AVMEDIA_TYPE_SUBTITLE: return "subtitle"; yading@11: case AVMEDIA_TYPE_ATTACHMENT: return "attachment"; yading@11: default: return NULL; yading@11: } yading@11: } yading@11: yading@11: char av_get_picture_type_char(enum AVPictureType pict_type) yading@11: { yading@11: switch (pict_type) { yading@11: case AV_PICTURE_TYPE_I: return 'I'; yading@11: case AV_PICTURE_TYPE_P: return 'P'; yading@11: case AV_PICTURE_TYPE_B: return 'B'; yading@11: case AV_PICTURE_TYPE_S: return 'S'; yading@11: case AV_PICTURE_TYPE_SI: return 'i'; yading@11: case AV_PICTURE_TYPE_SP: return 'p'; yading@11: case AV_PICTURE_TYPE_BI: return 'b'; yading@11: default: return '?'; yading@11: } yading@11: } yading@11: yading@11: unsigned av_int_list_length_for_size(unsigned elsize, yading@11: const void *list, uint64_t term) yading@11: { yading@11: unsigned i; yading@11: yading@11: if (!list) yading@11: return 0; yading@11: #define LIST_LENGTH(type) \ yading@11: { type t = term, *l = list; for (i = 0; l[i] != t; i++); } yading@11: switch (elsize) { yading@11: case 1: LIST_LENGTH(uint8_t); break; yading@11: case 2: LIST_LENGTH(uint16_t); break; yading@11: case 4: LIST_LENGTH(uint32_t); break; yading@11: case 8: LIST_LENGTH(uint64_t); break; yading@11: default: av_assert0(!"valid element size"); yading@11: } yading@11: return i; yading@11: }