Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ffmpeg/include/libavformat/version.h +47 -0
- ffmpeg/include/libavformat/version_major.h +54 -0
- ffmpeg/include/libavutil/adler32.h +63 -0
- ffmpeg/include/libavutil/aes.h +69 -0
- ffmpeg/include/libavutil/aes_ctr.h +99 -0
- ffmpeg/include/libavutil/ambient_viewing_environment.h +72 -0
- ffmpeg/include/libavutil/attributes.h +173 -0
- ffmpeg/include/libavutil/audio_fifo.h +187 -0
- ffmpeg/include/libavutil/avassert.h +78 -0
- ffmpeg/include/libavutil/avconfig.h +6 -0
- ffmpeg/include/libavutil/avstring.h +428 -0
- ffmpeg/include/libavutil/avutil.h +365 -0
- ffmpeg/include/libavutil/base64.h +72 -0
- ffmpeg/include/libavutil/blowfish.h +82 -0
- ffmpeg/include/libavutil/bprint.h +254 -0
- ffmpeg/include/libavutil/bswap.h +105 -0
- ffmpeg/include/libavutil/buffer.h +322 -0
- ffmpeg/include/libavutil/camellia.h +70 -0
- ffmpeg/include/libavutil/cast5.h +80 -0
- ffmpeg/include/libavutil/channel_layout.h +762 -0
- ffmpeg/include/libavutil/common.h +589 -0
- ffmpeg/include/libavutil/container_fifo.h +130 -0
- ffmpeg/include/libavutil/cpu.h +150 -0
- ffmpeg/include/libavutil/crc.h +102 -0
- ffmpeg/include/libavutil/csp.h +192 -0
- ffmpeg/include/libavutil/des.h +81 -0
- ffmpeg/include/libavutil/detection_bbox.h +108 -0
- ffmpeg/include/libavutil/dict.h +241 -0
- ffmpeg/include/libavutil/display.h +109 -0
- ffmpeg/include/libavutil/dovi_meta.h +396 -0
- ffmpeg/include/libavutil/downmix_info.h +115 -0
- ffmpeg/include/libavutil/encryption_info.h +205 -0
- ffmpeg/include/libavutil/error.h +129 -0
- ffmpeg/include/libavutil/eval.h +140 -0
- ffmpeg/include/libavutil/executor.h +67 -0
- ffmpeg/include/libavutil/ffversion.h +5 -0
- ffmpeg/include/libavutil/fifo.h +242 -0
- ffmpeg/include/libavutil/file.h +62 -0
- ffmpeg/include/libavutil/film_grain_params.h +322 -0
- ffmpeg/include/libavutil/frame.h +1202 -0
- ffmpeg/include/libavutil/hash.h +264 -0
- ffmpeg/include/libavutil/hdr_dynamic_metadata.h +376 -0
- ffmpeg/include/libavutil/hdr_dynamic_vivid_metadata.h +346 -0
- ffmpeg/include/libavutil/hmac.h +99 -0
- ffmpeg/include/libavutil/hwcontext.h +598 -0
- ffmpeg/include/libavutil/hwcontext_cuda.h +74 -0
- ffmpeg/include/libavutil/hwcontext_d3d11va.h +178 -0
- ffmpeg/include/libavutil/hwcontext_d3d12va.h +142 -0
- ffmpeg/include/libavutil/hwcontext_drm.h +169 -0
- ffmpeg/include/libavutil/hwcontext_dxva2.h +75 -0
ffmpeg/include/libavformat/version.h
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Version macros.
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVFORMAT_VERSION_H
|
| 22 |
+
#define AVFORMAT_VERSION_H
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @file
|
| 26 |
+
* @ingroup libavf
|
| 27 |
+
* Libavformat version macros
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
#include "libavutil/version.h"
|
| 31 |
+
|
| 32 |
+
#include "version_major.h"
|
| 33 |
+
|
| 34 |
+
#define LIBAVFORMAT_VERSION_MINOR 9
|
| 35 |
+
#define LIBAVFORMAT_VERSION_MICRO 104
|
| 36 |
+
|
| 37 |
+
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
| 38 |
+
LIBAVFORMAT_VERSION_MINOR, \
|
| 39 |
+
LIBAVFORMAT_VERSION_MICRO)
|
| 40 |
+
#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \
|
| 41 |
+
LIBAVFORMAT_VERSION_MINOR, \
|
| 42 |
+
LIBAVFORMAT_VERSION_MICRO)
|
| 43 |
+
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
|
| 44 |
+
|
| 45 |
+
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
|
| 46 |
+
|
| 47 |
+
#endif /* AVFORMAT_VERSION_H */
|
ffmpeg/include/libavformat/version_major.h
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Version macros.
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVFORMAT_VERSION_MAJOR_H
|
| 22 |
+
#define AVFORMAT_VERSION_MAJOR_H
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @file
|
| 26 |
+
* @ingroup libavf
|
| 27 |
+
* Libavformat version macros
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
|
| 31 |
+
// Also please add any ticket numbers that you believe might be affected here
|
| 32 |
+
#define LIBAVFORMAT_VERSION_MAJOR 61
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* FF_API_* defines may be placed below to indicate public API that will be
|
| 36 |
+
* dropped at a future version bump. The defines themselves are not part of
|
| 37 |
+
* the public API and may change, break or disappear at any time.
|
| 38 |
+
*
|
| 39 |
+
* @note, when bumping the major version it is recommended to manually
|
| 40 |
+
* disable each FF_API_* in its own commit instead of disabling them all
|
| 41 |
+
* at once through the bump. This improves the git bisect-ability of the change.
|
| 42 |
+
*
|
| 43 |
+
*/
|
| 44 |
+
#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 62)
|
| 45 |
+
#define FF_API_LAVF_SHORTEST (LIBAVFORMAT_VERSION_MAJOR < 62)
|
| 46 |
+
#define FF_API_ALLOW_FLUSH (LIBAVFORMAT_VERSION_MAJOR < 62)
|
| 47 |
+
#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 62)
|
| 48 |
+
|
| 49 |
+
#define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62)
|
| 50 |
+
#define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 62)
|
| 51 |
+
|
| 52 |
+
#define FF_API_R_FRAME_RATE 1
|
| 53 |
+
|
| 54 |
+
#endif /* AVFORMAT_VERSION_MAJOR_H */
|
ffmpeg/include/libavutil/adler32.h
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2006 Mans Rullgard
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* @ingroup lavu_adler32
|
| 24 |
+
* Public header for Adler-32 hash function implementation.
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_ADLER32_H
|
| 28 |
+
#define AVUTIL_ADLER32_H
|
| 29 |
+
|
| 30 |
+
#include <stddef.h>
|
| 31 |
+
#include <stdint.h>
|
| 32 |
+
#include "attributes.h"
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* @defgroup lavu_adler32 Adler-32
|
| 36 |
+
* @ingroup lavu_hash
|
| 37 |
+
* Adler-32 hash function implementation.
|
| 38 |
+
*
|
| 39 |
+
* @{
|
| 40 |
+
*/
|
| 41 |
+
|
| 42 |
+
typedef uint32_t AVAdler;
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Calculate the Adler32 checksum of a buffer.
|
| 46 |
+
*
|
| 47 |
+
* Passing the return value to a subsequent av_adler32_update() call
|
| 48 |
+
* allows the checksum of multiple buffers to be calculated as though
|
| 49 |
+
* they were concatenated.
|
| 50 |
+
*
|
| 51 |
+
* @param adler initial checksum value
|
| 52 |
+
* @param buf pointer to input buffer
|
| 53 |
+
* @param len size of input buffer
|
| 54 |
+
* @return updated checksum
|
| 55 |
+
*/
|
| 56 |
+
AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf,
|
| 57 |
+
size_t len) av_pure;
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* @}
|
| 61 |
+
*/
|
| 62 |
+
|
| 63 |
+
#endif /* AVUTIL_ADLER32_H */
|
ffmpeg/include/libavutil/aes.h
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_AES_H
|
| 22 |
+
#define AVUTIL_AES_H
|
| 23 |
+
|
| 24 |
+
#include <stdint.h>
|
| 25 |
+
|
| 26 |
+
#include "attributes.h"
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @defgroup lavu_aes AES
|
| 30 |
+
* @ingroup lavu_crypto
|
| 31 |
+
* @{
|
| 32 |
+
*/
|
| 33 |
+
|
| 34 |
+
extern const int av_aes_size;
|
| 35 |
+
|
| 36 |
+
struct AVAES;
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Allocate an AVAES context.
|
| 40 |
+
*/
|
| 41 |
+
struct AVAES *av_aes_alloc(void);
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Initialize an AVAES context.
|
| 45 |
+
*
|
| 46 |
+
* @param a The AVAES context
|
| 47 |
+
* @param key Pointer to the key
|
| 48 |
+
* @param key_bits 128, 192 or 256
|
| 49 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 50 |
+
*/
|
| 51 |
+
int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Encrypt or decrypt a buffer using a previously initialized context.
|
| 55 |
+
*
|
| 56 |
+
* @param a The AVAES context
|
| 57 |
+
* @param dst destination array, can be equal to src
|
| 58 |
+
* @param src source array, can be equal to dst
|
| 59 |
+
* @param count number of 16 byte blocks
|
| 60 |
+
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
| 61 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 62 |
+
*/
|
| 63 |
+
void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* @}
|
| 67 |
+
*/
|
| 68 |
+
|
| 69 |
+
#endif /* AVUTIL_AES_H */
|
ffmpeg/include/libavutil/aes_ctr.h
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* AES-CTR cipher
|
| 3 |
+
* Copyright (c) 2015 Eran Kornblau <erankor at gmail dot com>
|
| 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 |
+
#ifndef AVUTIL_AES_CTR_H
|
| 23 |
+
#define AVUTIL_AES_CTR_H
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* @defgroup lavu_aes_ctr AES-CTR
|
| 27 |
+
* @ingroup lavu_crypto
|
| 28 |
+
* @{
|
| 29 |
+
*/
|
| 30 |
+
|
| 31 |
+
#include <stdint.h>
|
| 32 |
+
|
| 33 |
+
#include "attributes.h"
|
| 34 |
+
|
| 35 |
+
#define AES_CTR_KEY_SIZE (16)
|
| 36 |
+
#define AES_CTR_IV_SIZE (8)
|
| 37 |
+
|
| 38 |
+
struct AVAESCTR;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Allocate an AVAESCTR context.
|
| 42 |
+
*/
|
| 43 |
+
struct AVAESCTR *av_aes_ctr_alloc(void);
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Initialize an AVAESCTR context.
|
| 47 |
+
*
|
| 48 |
+
* @param a The AVAESCTR context to initialize
|
| 49 |
+
* @param key encryption key, must have a length of AES_CTR_KEY_SIZE
|
| 50 |
+
*/
|
| 51 |
+
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key);
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Release an AVAESCTR context.
|
| 55 |
+
*
|
| 56 |
+
* @param a The AVAESCTR context
|
| 57 |
+
*/
|
| 58 |
+
void av_aes_ctr_free(struct AVAESCTR *a);
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Process a buffer using a previously initialized context.
|
| 62 |
+
*
|
| 63 |
+
* @param a The AVAESCTR context
|
| 64 |
+
* @param dst destination array, can be equal to src
|
| 65 |
+
* @param src source array, can be equal to dst
|
| 66 |
+
* @param size the size of src and dst
|
| 67 |
+
*/
|
| 68 |
+
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int size);
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Get the current iv
|
| 72 |
+
*/
|
| 73 |
+
const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a);
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* Generate a random iv
|
| 77 |
+
*/
|
| 78 |
+
void av_aes_ctr_set_random_iv(struct AVAESCTR *a);
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Forcefully change the 8-byte iv
|
| 82 |
+
*/
|
| 83 |
+
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv);
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Forcefully change the "full" 16-byte iv, including the counter
|
| 87 |
+
*/
|
| 88 |
+
void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv);
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* Increment the top 64 bit of the iv (performed after each frame)
|
| 92 |
+
*/
|
| 93 |
+
void av_aes_ctr_increment_iv(struct AVAESCTR *a);
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* @}
|
| 97 |
+
*/
|
| 98 |
+
|
| 99 |
+
#endif /* AVUTIL_AES_CTR_H */
|
ffmpeg/include/libavutil/ambient_viewing_environment.h
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2023 Jan Ekström <jeebjp@gmail.com>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
|
| 22 |
+
#define AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
|
| 23 |
+
|
| 24 |
+
#include <stddef.h>
|
| 25 |
+
#include "frame.h"
|
| 26 |
+
#include "rational.h"
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Ambient viewing environment metadata as defined by H.274. The values are
|
| 30 |
+
* saved in AVRationals so that they keep their exactness, while allowing for
|
| 31 |
+
* easy access to a double value with f.ex. av_q2d.
|
| 32 |
+
*
|
| 33 |
+
* @note sizeof(AVAmbientViewingEnvironment) is not part of the public ABI, and
|
| 34 |
+
* it must be allocated using av_ambient_viewing_environment_alloc.
|
| 35 |
+
*/
|
| 36 |
+
typedef struct AVAmbientViewingEnvironment {
|
| 37 |
+
/**
|
| 38 |
+
* Environmental illuminance of the ambient viewing environment in lux.
|
| 39 |
+
*/
|
| 40 |
+
AVRational ambient_illuminance;
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Normalized x chromaticity coordinate of the environmental ambient light
|
| 44 |
+
* in the nominal viewing environment according to the CIE 1931 definition
|
| 45 |
+
* of x and y as specified in ISO/CIE 11664-1.
|
| 46 |
+
*/
|
| 47 |
+
AVRational ambient_light_x;
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Normalized y chromaticity coordinate of the environmental ambient light
|
| 51 |
+
* in the nominal viewing environment according to the CIE 1931 definition
|
| 52 |
+
* of x and y as specified in ISO/CIE 11664-1.
|
| 53 |
+
*/
|
| 54 |
+
AVRational ambient_light_y;
|
| 55 |
+
} AVAmbientViewingEnvironment;
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Allocate an AVAmbientViewingEnvironment structure.
|
| 59 |
+
*
|
| 60 |
+
* @return the newly allocated struct or NULL on failure
|
| 61 |
+
*/
|
| 62 |
+
AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size);
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Allocate and add an AVAmbientViewingEnvironment structure to an existing
|
| 66 |
+
* AVFrame as side data.
|
| 67 |
+
*
|
| 68 |
+
* @return the newly allocated struct, or NULL on failure
|
| 69 |
+
*/
|
| 70 |
+
AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame);
|
| 71 |
+
|
| 72 |
+
#endif /* AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H */
|
ffmpeg/include/libavutil/attributes.h
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* Macro definitions for various function/variable attributes
|
| 24 |
+
*/
|
| 25 |
+
|
| 26 |
+
#ifndef AVUTIL_ATTRIBUTES_H
|
| 27 |
+
#define AVUTIL_ATTRIBUTES_H
|
| 28 |
+
|
| 29 |
+
#ifdef __GNUC__
|
| 30 |
+
# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
|
| 31 |
+
# define AV_GCC_VERSION_AT_MOST(x,y) (__GNUC__ < (x) || __GNUC__ == (x) && __GNUC_MINOR__ <= (y))
|
| 32 |
+
#else
|
| 33 |
+
# define AV_GCC_VERSION_AT_LEAST(x,y) 0
|
| 34 |
+
# define AV_GCC_VERSION_AT_MOST(x,y) 0
|
| 35 |
+
#endif
|
| 36 |
+
|
| 37 |
+
#ifdef __has_builtin
|
| 38 |
+
# define AV_HAS_BUILTIN(x) __has_builtin(x)
|
| 39 |
+
#else
|
| 40 |
+
# define AV_HAS_BUILTIN(x) 0
|
| 41 |
+
#endif
|
| 42 |
+
|
| 43 |
+
#ifndef av_always_inline
|
| 44 |
+
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
| 45 |
+
# define av_always_inline __attribute__((always_inline)) inline
|
| 46 |
+
#elif defined(_MSC_VER)
|
| 47 |
+
# define av_always_inline __forceinline
|
| 48 |
+
#else
|
| 49 |
+
# define av_always_inline inline
|
| 50 |
+
#endif
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
#ifndef av_extern_inline
|
| 54 |
+
#if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
|
| 55 |
+
# define av_extern_inline extern inline
|
| 56 |
+
#else
|
| 57 |
+
# define av_extern_inline inline
|
| 58 |
+
#endif
|
| 59 |
+
#endif
|
| 60 |
+
|
| 61 |
+
#if AV_GCC_VERSION_AT_LEAST(3,4)
|
| 62 |
+
# define av_warn_unused_result __attribute__((warn_unused_result))
|
| 63 |
+
#else
|
| 64 |
+
# define av_warn_unused_result
|
| 65 |
+
#endif
|
| 66 |
+
|
| 67 |
+
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
| 68 |
+
# define av_noinline __attribute__((noinline))
|
| 69 |
+
#elif defined(_MSC_VER)
|
| 70 |
+
# define av_noinline __declspec(noinline)
|
| 71 |
+
#else
|
| 72 |
+
# define av_noinline
|
| 73 |
+
#endif
|
| 74 |
+
|
| 75 |
+
#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
|
| 76 |
+
# define av_pure __attribute__((pure))
|
| 77 |
+
#else
|
| 78 |
+
# define av_pure
|
| 79 |
+
#endif
|
| 80 |
+
|
| 81 |
+
#if AV_GCC_VERSION_AT_LEAST(2,6) || defined(__clang__)
|
| 82 |
+
# define av_const __attribute__((const))
|
| 83 |
+
#else
|
| 84 |
+
# define av_const
|
| 85 |
+
#endif
|
| 86 |
+
|
| 87 |
+
#if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__)
|
| 88 |
+
# define av_cold __attribute__((cold))
|
| 89 |
+
#else
|
| 90 |
+
# define av_cold
|
| 91 |
+
#endif
|
| 92 |
+
|
| 93 |
+
#if AV_GCC_VERSION_AT_LEAST(4,1) && !defined(__llvm__)
|
| 94 |
+
# define av_flatten __attribute__((flatten))
|
| 95 |
+
#else
|
| 96 |
+
# define av_flatten
|
| 97 |
+
#endif
|
| 98 |
+
|
| 99 |
+
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
| 100 |
+
# define attribute_deprecated __attribute__((deprecated))
|
| 101 |
+
#elif defined(_MSC_VER)
|
| 102 |
+
# define attribute_deprecated __declspec(deprecated)
|
| 103 |
+
#else
|
| 104 |
+
# define attribute_deprecated
|
| 105 |
+
#endif
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Disable warnings about deprecated features
|
| 109 |
+
* This is useful for sections of code kept for backward compatibility and
|
| 110 |
+
* scheduled for removal.
|
| 111 |
+
*/
|
| 112 |
+
#ifndef AV_NOWARN_DEPRECATED
|
| 113 |
+
#if AV_GCC_VERSION_AT_LEAST(4,6) || defined(__clang__)
|
| 114 |
+
# define AV_NOWARN_DEPRECATED(code) \
|
| 115 |
+
_Pragma("GCC diagnostic push") \
|
| 116 |
+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
|
| 117 |
+
code \
|
| 118 |
+
_Pragma("GCC diagnostic pop")
|
| 119 |
+
#elif defined(_MSC_VER)
|
| 120 |
+
# define AV_NOWARN_DEPRECATED(code) \
|
| 121 |
+
__pragma(warning(push)) \
|
| 122 |
+
__pragma(warning(disable : 4996)) \
|
| 123 |
+
code; \
|
| 124 |
+
__pragma(warning(pop))
|
| 125 |
+
#else
|
| 126 |
+
# define AV_NOWARN_DEPRECATED(code) code
|
| 127 |
+
#endif
|
| 128 |
+
#endif
|
| 129 |
+
|
| 130 |
+
#if defined(__GNUC__) || defined(__clang__)
|
| 131 |
+
# define av_unused __attribute__((unused))
|
| 132 |
+
#else
|
| 133 |
+
# define av_unused
|
| 134 |
+
#endif
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* Mark a variable as used and prevent the compiler from optimizing it
|
| 138 |
+
* away. This is useful for variables accessed only from inline
|
| 139 |
+
* assembler without the compiler being aware.
|
| 140 |
+
*/
|
| 141 |
+
#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__)
|
| 142 |
+
# define av_used __attribute__((used))
|
| 143 |
+
#else
|
| 144 |
+
# define av_used
|
| 145 |
+
#endif
|
| 146 |
+
|
| 147 |
+
#if AV_GCC_VERSION_AT_LEAST(3,3) || defined(__clang__)
|
| 148 |
+
# define av_alias __attribute__((may_alias))
|
| 149 |
+
#else
|
| 150 |
+
# define av_alias
|
| 151 |
+
#endif
|
| 152 |
+
|
| 153 |
+
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER)
|
| 154 |
+
# define av_uninit(x) x=x
|
| 155 |
+
#else
|
| 156 |
+
# define av_uninit(x) x
|
| 157 |
+
#endif
|
| 158 |
+
|
| 159 |
+
#if defined(__GNUC__) || defined(__clang__)
|
| 160 |
+
# define av_builtin_constant_p __builtin_constant_p
|
| 161 |
+
# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
|
| 162 |
+
#else
|
| 163 |
+
# define av_builtin_constant_p(x) 0
|
| 164 |
+
# define av_printf_format(fmtpos, attrpos)
|
| 165 |
+
#endif
|
| 166 |
+
|
| 167 |
+
#if AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__)
|
| 168 |
+
# define av_noreturn __attribute__((noreturn))
|
| 169 |
+
#else
|
| 170 |
+
# define av_noreturn
|
| 171 |
+
#endif
|
| 172 |
+
|
| 173 |
+
#endif /* AVUTIL_ATTRIBUTES_H */
|
ffmpeg/include/libavutil/audio_fifo.h
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Audio FIFO
|
| 3 |
+
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
| 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 |
+
* Audio FIFO Buffer
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_AUDIO_FIFO_H
|
| 28 |
+
#define AVUTIL_AUDIO_FIFO_H
|
| 29 |
+
|
| 30 |
+
#include "attributes.h"
|
| 31 |
+
#include "samplefmt.h"
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* @addtogroup lavu_audio
|
| 35 |
+
* @{
|
| 36 |
+
*
|
| 37 |
+
* @defgroup lavu_audiofifo Audio FIFO Buffer
|
| 38 |
+
* @{
|
| 39 |
+
*/
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Context for an Audio FIFO Buffer.
|
| 43 |
+
*
|
| 44 |
+
* - Operates at the sample level rather than the byte level.
|
| 45 |
+
* - Supports multiple channels with either planar or packed sample format.
|
| 46 |
+
* - Automatic reallocation when writing to a full buffer.
|
| 47 |
+
*/
|
| 48 |
+
typedef struct AVAudioFifo AVAudioFifo;
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Free an AVAudioFifo.
|
| 52 |
+
*
|
| 53 |
+
* @param af AVAudioFifo to free
|
| 54 |
+
*/
|
| 55 |
+
void av_audio_fifo_free(AVAudioFifo *af);
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Allocate an AVAudioFifo.
|
| 59 |
+
*
|
| 60 |
+
* @param sample_fmt sample format
|
| 61 |
+
* @param channels number of channels
|
| 62 |
+
* @param nb_samples initial allocation size, in samples
|
| 63 |
+
* @return newly allocated AVAudioFifo, or NULL on error
|
| 64 |
+
*/
|
| 65 |
+
AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
|
| 66 |
+
int nb_samples);
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Reallocate an AVAudioFifo.
|
| 70 |
+
*
|
| 71 |
+
* @param af AVAudioFifo to reallocate
|
| 72 |
+
* @param nb_samples new allocation size, in samples
|
| 73 |
+
* @return 0 if OK, or negative AVERROR code on failure
|
| 74 |
+
*/
|
| 75 |
+
av_warn_unused_result
|
| 76 |
+
int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Write data to an AVAudioFifo.
|
| 80 |
+
*
|
| 81 |
+
* The AVAudioFifo will be reallocated automatically if the available space
|
| 82 |
+
* is less than nb_samples.
|
| 83 |
+
*
|
| 84 |
+
* @see enum AVSampleFormat
|
| 85 |
+
* The documentation for AVSampleFormat describes the data layout.
|
| 86 |
+
*
|
| 87 |
+
* @param af AVAudioFifo to write to
|
| 88 |
+
* @param data audio data plane pointers
|
| 89 |
+
* @param nb_samples number of samples to write
|
| 90 |
+
* @return number of samples actually written, or negative AVERROR
|
| 91 |
+
* code on failure. If successful, the number of samples
|
| 92 |
+
* actually written will always be nb_samples.
|
| 93 |
+
*/
|
| 94 |
+
int av_audio_fifo_write(AVAudioFifo *af, void * const *data, int nb_samples);
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Peek data from an AVAudioFifo.
|
| 98 |
+
*
|
| 99 |
+
* @see enum AVSampleFormat
|
| 100 |
+
* The documentation for AVSampleFormat describes the data layout.
|
| 101 |
+
*
|
| 102 |
+
* @param af AVAudioFifo to read from
|
| 103 |
+
* @param data audio data plane pointers
|
| 104 |
+
* @param nb_samples number of samples to peek
|
| 105 |
+
* @return number of samples actually peek, or negative AVERROR code
|
| 106 |
+
* on failure. The number of samples actually peek will not
|
| 107 |
+
* be greater than nb_samples, and will only be less than
|
| 108 |
+
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
| 109 |
+
*/
|
| 110 |
+
int av_audio_fifo_peek(const AVAudioFifo *af, void * const *data, int nb_samples);
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* Peek data from an AVAudioFifo.
|
| 114 |
+
*
|
| 115 |
+
* @see enum AVSampleFormat
|
| 116 |
+
* The documentation for AVSampleFormat describes the data layout.
|
| 117 |
+
*
|
| 118 |
+
* @param af AVAudioFifo to read from
|
| 119 |
+
* @param data audio data plane pointers
|
| 120 |
+
* @param nb_samples number of samples to peek
|
| 121 |
+
* @param offset offset from current read position
|
| 122 |
+
* @return number of samples actually peek, or negative AVERROR code
|
| 123 |
+
* on failure. The number of samples actually peek will not
|
| 124 |
+
* be greater than nb_samples, and will only be less than
|
| 125 |
+
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
| 126 |
+
*/
|
| 127 |
+
int av_audio_fifo_peek_at(const AVAudioFifo *af, void * const *data,
|
| 128 |
+
int nb_samples, int offset);
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Read data from an AVAudioFifo.
|
| 132 |
+
*
|
| 133 |
+
* @see enum AVSampleFormat
|
| 134 |
+
* The documentation for AVSampleFormat describes the data layout.
|
| 135 |
+
*
|
| 136 |
+
* @param af AVAudioFifo to read from
|
| 137 |
+
* @param data audio data plane pointers
|
| 138 |
+
* @param nb_samples number of samples to read
|
| 139 |
+
* @return number of samples actually read, or negative AVERROR code
|
| 140 |
+
* on failure. The number of samples actually read will not
|
| 141 |
+
* be greater than nb_samples, and will only be less than
|
| 142 |
+
* nb_samples if av_audio_fifo_size is less than nb_samples.
|
| 143 |
+
*/
|
| 144 |
+
int av_audio_fifo_read(AVAudioFifo *af, void * const *data, int nb_samples);
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* Drain data from an AVAudioFifo.
|
| 148 |
+
*
|
| 149 |
+
* Removes the data without reading it.
|
| 150 |
+
*
|
| 151 |
+
* @param af AVAudioFifo to drain
|
| 152 |
+
* @param nb_samples number of samples to drain
|
| 153 |
+
* @return 0 if OK, or negative AVERROR code on failure
|
| 154 |
+
*/
|
| 155 |
+
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* Reset the AVAudioFifo buffer.
|
| 159 |
+
*
|
| 160 |
+
* This empties all data in the buffer.
|
| 161 |
+
*
|
| 162 |
+
* @param af AVAudioFifo to reset
|
| 163 |
+
*/
|
| 164 |
+
void av_audio_fifo_reset(AVAudioFifo *af);
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Get the current number of samples in the AVAudioFifo available for reading.
|
| 168 |
+
*
|
| 169 |
+
* @param af the AVAudioFifo to query
|
| 170 |
+
* @return number of samples available for reading
|
| 171 |
+
*/
|
| 172 |
+
int av_audio_fifo_size(AVAudioFifo *af);
|
| 173 |
+
|
| 174 |
+
/**
|
| 175 |
+
* Get the current number of samples in the AVAudioFifo available for writing.
|
| 176 |
+
*
|
| 177 |
+
* @param af the AVAudioFifo to query
|
| 178 |
+
* @return number of samples available for writing
|
| 179 |
+
*/
|
| 180 |
+
int av_audio_fifo_space(AVAudioFifo *af);
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* @}
|
| 184 |
+
* @}
|
| 185 |
+
*/
|
| 186 |
+
|
| 187 |
+
#endif /* AVUTIL_AUDIO_FIFO_H */
|
ffmpeg/include/libavutil/avassert.h
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2010 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* simple assert() macros that are a bit more flexible than ISO C assert().
|
| 24 |
+
* @author Michael Niedermayer <michaelni@gmx.at>
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_AVASSERT_H
|
| 28 |
+
#define AVUTIL_AVASSERT_H
|
| 29 |
+
|
| 30 |
+
#include <stdlib.h>
|
| 31 |
+
#ifdef HAVE_AV_CONFIG_H
|
| 32 |
+
# include "config.h"
|
| 33 |
+
#endif
|
| 34 |
+
#include "log.h"
|
| 35 |
+
#include "macros.h"
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* assert() equivalent, that is always enabled.
|
| 39 |
+
*/
|
| 40 |
+
#define av_assert0(cond) do { \
|
| 41 |
+
if (!(cond)) { \
|
| 42 |
+
av_log(NULL, AV_LOG_PANIC, "Assertion %s failed at %s:%d\n", \
|
| 43 |
+
AV_STRINGIFY(cond), __FILE__, __LINE__); \
|
| 44 |
+
abort(); \
|
| 45 |
+
} \
|
| 46 |
+
} while (0)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* assert() equivalent, that does not lie in speed critical code.
|
| 51 |
+
* These asserts() thus can be enabled without fearing speed loss.
|
| 52 |
+
*/
|
| 53 |
+
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0
|
| 54 |
+
#define av_assert1(cond) av_assert0(cond)
|
| 55 |
+
#else
|
| 56 |
+
#define av_assert1(cond) ((void)0)
|
| 57 |
+
#endif
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* assert() equivalent, that does lie in speed critical code.
|
| 62 |
+
*/
|
| 63 |
+
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
|
| 64 |
+
#define av_assert2(cond) av_assert0(cond)
|
| 65 |
+
#define av_assert2_fpu() av_assert0_fpu()
|
| 66 |
+
#else
|
| 67 |
+
#define av_assert2(cond) ((void)0)
|
| 68 |
+
#define av_assert2_fpu() ((void)0)
|
| 69 |
+
#endif
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Assert that floating point operations can be executed.
|
| 73 |
+
*
|
| 74 |
+
* This will av_assert0() that the cpu is not in MMX state on X86
|
| 75 |
+
*/
|
| 76 |
+
void av_assert0_fpu(void);
|
| 77 |
+
|
| 78 |
+
#endif /* AVUTIL_AVASSERT_H */
|
ffmpeg/include/libavutil/avconfig.h
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Generated by ffmpeg configure */
|
| 2 |
+
#ifndef AVUTIL_AVCONFIG_H
|
| 3 |
+
#define AVUTIL_AVCONFIG_H
|
| 4 |
+
#define AV_HAVE_BIGENDIAN 0
|
| 5 |
+
#define AV_HAVE_FAST_UNALIGNED 1
|
| 6 |
+
#endif /* AVUTIL_AVCONFIG_H */
|
ffmpeg/include/libavutil/avstring.h
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2007 Mans Rullgard
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_AVSTRING_H
|
| 22 |
+
#define AVUTIL_AVSTRING_H
|
| 23 |
+
|
| 24 |
+
#include <stddef.h>
|
| 25 |
+
#include <stdint.h>
|
| 26 |
+
#include "attributes.h"
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @addtogroup lavu_string
|
| 30 |
+
* @{
|
| 31 |
+
*/
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
|
| 35 |
+
* the address of the first character in str after the prefix.
|
| 36 |
+
*
|
| 37 |
+
* @param str input string
|
| 38 |
+
* @param pfx prefix to test
|
| 39 |
+
* @param ptr updated if the prefix is matched inside str
|
| 40 |
+
* @return non-zero if the prefix matches, zero otherwise
|
| 41 |
+
*/
|
| 42 |
+
int av_strstart(const char *str, const char *pfx, const char **ptr);
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Return non-zero if pfx is a prefix of str independent of case. If
|
| 46 |
+
* it is, *ptr is set to the address of the first character in str
|
| 47 |
+
* after the prefix.
|
| 48 |
+
*
|
| 49 |
+
* @param str input string
|
| 50 |
+
* @param pfx prefix to test
|
| 51 |
+
* @param ptr updated if the prefix is matched inside str
|
| 52 |
+
* @return non-zero if the prefix matches, zero otherwise
|
| 53 |
+
*/
|
| 54 |
+
int av_stristart(const char *str, const char *pfx, const char **ptr);
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Locate the first case-independent occurrence in the string haystack
|
| 58 |
+
* of the string needle. A zero-length string needle is considered to
|
| 59 |
+
* match at the start of haystack.
|
| 60 |
+
*
|
| 61 |
+
* This function is a case-insensitive version of the standard strstr().
|
| 62 |
+
*
|
| 63 |
+
* @param haystack string to search in
|
| 64 |
+
* @param needle string to search for
|
| 65 |
+
* @return pointer to the located match within haystack
|
| 66 |
+
* or a null pointer if no match
|
| 67 |
+
*/
|
| 68 |
+
char *av_stristr(const char *haystack, const char *needle);
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Locate the first occurrence of the string needle in the string haystack
|
| 72 |
+
* where not more than hay_length characters are searched. A zero-length
|
| 73 |
+
* string needle is considered to match at the start of haystack.
|
| 74 |
+
*
|
| 75 |
+
* This function is a length-limited version of the standard strstr().
|
| 76 |
+
*
|
| 77 |
+
* @param haystack string to search in
|
| 78 |
+
* @param needle string to search for
|
| 79 |
+
* @param hay_length length of string to search in
|
| 80 |
+
* @return pointer to the located match within haystack
|
| 81 |
+
* or a null pointer if no match
|
| 82 |
+
*/
|
| 83 |
+
char *av_strnstr(const char *haystack, const char *needle, size_t hay_length);
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Copy the string src to dst, but no more than size - 1 bytes, and
|
| 87 |
+
* null-terminate dst.
|
| 88 |
+
*
|
| 89 |
+
* This function is the same as BSD strlcpy().
|
| 90 |
+
*
|
| 91 |
+
* @param dst destination buffer
|
| 92 |
+
* @param src source string
|
| 93 |
+
* @param size size of destination buffer
|
| 94 |
+
* @return the length of src
|
| 95 |
+
*
|
| 96 |
+
* @warning since the return value is the length of src, src absolutely
|
| 97 |
+
* _must_ be a properly 0-terminated string, otherwise this will read beyond
|
| 98 |
+
* the end of the buffer and possibly crash.
|
| 99 |
+
*/
|
| 100 |
+
size_t av_strlcpy(char *dst, const char *src, size_t size);
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Append the string src to the string dst, but to a total length of
|
| 104 |
+
* no more than size - 1 bytes, and null-terminate dst.
|
| 105 |
+
*
|
| 106 |
+
* This function is similar to BSD strlcat(), but differs when
|
| 107 |
+
* size <= strlen(dst).
|
| 108 |
+
*
|
| 109 |
+
* @param dst destination buffer
|
| 110 |
+
* @param src source string
|
| 111 |
+
* @param size size of destination buffer
|
| 112 |
+
* @return the total length of src and dst
|
| 113 |
+
*
|
| 114 |
+
* @warning since the return value use the length of src and dst, these
|
| 115 |
+
* absolutely _must_ be a properly 0-terminated strings, otherwise this
|
| 116 |
+
* will read beyond the end of the buffer and possibly crash.
|
| 117 |
+
*/
|
| 118 |
+
size_t av_strlcat(char *dst, const char *src, size_t size);
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Append output to a string, according to a format. Never write out of
|
| 122 |
+
* the destination buffer, and always put a terminating 0 within
|
| 123 |
+
* the buffer.
|
| 124 |
+
* @param dst destination buffer (string to which the output is
|
| 125 |
+
* appended)
|
| 126 |
+
* @param size total size of the destination buffer
|
| 127 |
+
* @param fmt printf-compatible format string, specifying how the
|
| 128 |
+
* following parameters are used
|
| 129 |
+
* @return the length of the string that would have been generated
|
| 130 |
+
* if enough space had been available
|
| 131 |
+
*/
|
| 132 |
+
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* Get the count of continuous non zero chars starting from the beginning.
|
| 136 |
+
*
|
| 137 |
+
* @param s the string whose length to count
|
| 138 |
+
* @param len maximum number of characters to check in the string, that
|
| 139 |
+
* is the maximum value which is returned by the function
|
| 140 |
+
*/
|
| 141 |
+
static inline size_t av_strnlen(const char *s, size_t len)
|
| 142 |
+
{
|
| 143 |
+
size_t i;
|
| 144 |
+
for (i = 0; i < len && s[i]; i++)
|
| 145 |
+
;
|
| 146 |
+
return i;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
/**
|
| 150 |
+
* Print arguments following specified format into a large enough auto
|
| 151 |
+
* allocated buffer. It is similar to GNU asprintf().
|
| 152 |
+
* @param fmt printf-compatible format string, specifying how the
|
| 153 |
+
* following parameters are used.
|
| 154 |
+
* @return the allocated string
|
| 155 |
+
* @note You have to free the string yourself with av_free().
|
| 156 |
+
*/
|
| 157 |
+
char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2);
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* Unescape the given string until a non escaped terminating char,
|
| 161 |
+
* and return the token corresponding to the unescaped string.
|
| 162 |
+
*
|
| 163 |
+
* The normal \ and ' escaping is supported. Leading and trailing
|
| 164 |
+
* whitespaces are removed, unless they are escaped with '\' or are
|
| 165 |
+
* enclosed between ''.
|
| 166 |
+
*
|
| 167 |
+
* @param buf the buffer to parse, buf will be updated to point to the
|
| 168 |
+
* terminating char
|
| 169 |
+
* @param term a 0-terminated list of terminating chars
|
| 170 |
+
* @return the malloced unescaped string, which must be av_freed by
|
| 171 |
+
* the user, NULL in case of allocation failure
|
| 172 |
+
*/
|
| 173 |
+
char *av_get_token(const char **buf, const char *term);
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Split the string into several tokens which can be accessed by
|
| 177 |
+
* successive calls to av_strtok().
|
| 178 |
+
*
|
| 179 |
+
* A token is defined as a sequence of characters not belonging to the
|
| 180 |
+
* set specified in delim.
|
| 181 |
+
*
|
| 182 |
+
* On the first call to av_strtok(), s should point to the string to
|
| 183 |
+
* parse, and the value of saveptr is ignored. In subsequent calls, s
|
| 184 |
+
* should be NULL, and saveptr should be unchanged since the previous
|
| 185 |
+
* call.
|
| 186 |
+
*
|
| 187 |
+
* This function is similar to strtok_r() defined in POSIX.1.
|
| 188 |
+
*
|
| 189 |
+
* @param s the string to parse, may be NULL
|
| 190 |
+
* @param delim 0-terminated list of token delimiters, must be non-NULL
|
| 191 |
+
* @param saveptr user-provided pointer which points to stored
|
| 192 |
+
* information necessary for av_strtok() to continue scanning the same
|
| 193 |
+
* string. saveptr is updated to point to the next character after the
|
| 194 |
+
* first delimiter found, or to NULL if the string was terminated
|
| 195 |
+
* @return the found token, or NULL when no token is found
|
| 196 |
+
*/
|
| 197 |
+
char *av_strtok(char *s, const char *delim, char **saveptr);
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* Locale-independent conversion of ASCII isdigit.
|
| 201 |
+
*/
|
| 202 |
+
static inline av_const int av_isdigit(int c)
|
| 203 |
+
{
|
| 204 |
+
return c >= '0' && c <= '9';
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
/**
|
| 208 |
+
* Locale-independent conversion of ASCII isgraph.
|
| 209 |
+
*/
|
| 210 |
+
static inline av_const int av_isgraph(int c)
|
| 211 |
+
{
|
| 212 |
+
return c > 32 && c < 127;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
* Locale-independent conversion of ASCII isspace.
|
| 217 |
+
*/
|
| 218 |
+
static inline av_const int av_isspace(int c)
|
| 219 |
+
{
|
| 220 |
+
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' ||
|
| 221 |
+
c == '\v';
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
* Locale-independent conversion of ASCII characters to uppercase.
|
| 226 |
+
*/
|
| 227 |
+
static inline av_const int av_toupper(int c)
|
| 228 |
+
{
|
| 229 |
+
if (c >= 'a' && c <= 'z')
|
| 230 |
+
c ^= 0x20;
|
| 231 |
+
return c;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/**
|
| 235 |
+
* Locale-independent conversion of ASCII characters to lowercase.
|
| 236 |
+
*/
|
| 237 |
+
static inline av_const int av_tolower(int c)
|
| 238 |
+
{
|
| 239 |
+
if (c >= 'A' && c <= 'Z')
|
| 240 |
+
c ^= 0x20;
|
| 241 |
+
return c;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* Locale-independent conversion of ASCII isxdigit.
|
| 246 |
+
*/
|
| 247 |
+
static inline av_const int av_isxdigit(int c)
|
| 248 |
+
{
|
| 249 |
+
c = av_tolower(c);
|
| 250 |
+
return av_isdigit(c) || (c >= 'a' && c <= 'f');
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Locale-independent case-insensitive compare.
|
| 255 |
+
* @note This means only ASCII-range characters are case-insensitive
|
| 256 |
+
*/
|
| 257 |
+
int av_strcasecmp(const char *a, const char *b);
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
* Locale-independent case-insensitive compare.
|
| 261 |
+
* @note This means only ASCII-range characters are case-insensitive
|
| 262 |
+
*/
|
| 263 |
+
int av_strncasecmp(const char *a, const char *b, size_t n);
|
| 264 |
+
|
| 265 |
+
/**
|
| 266 |
+
* Locale-independent strings replace.
|
| 267 |
+
* @note This means only ASCII-range characters are replaced.
|
| 268 |
+
*/
|
| 269 |
+
char *av_strireplace(const char *str, const char *from, const char *to);
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
* Thread safe basename.
|
| 273 |
+
* @param path the string to parse, on DOS both \ and / are considered separators.
|
| 274 |
+
* @return pointer to the basename substring.
|
| 275 |
+
* If path does not contain a slash, the function returns a copy of path.
|
| 276 |
+
* If path is a NULL pointer or points to an empty string, a pointer
|
| 277 |
+
* to a string "." is returned.
|
| 278 |
+
*/
|
| 279 |
+
const char *av_basename(const char *path);
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* Thread safe dirname.
|
| 283 |
+
* @param path the string to parse, on DOS both \ and / are considered separators.
|
| 284 |
+
* @return A pointer to a string that's the parent directory of path.
|
| 285 |
+
* If path is a NULL pointer or points to an empty string, a pointer
|
| 286 |
+
* to a string "." is returned.
|
| 287 |
+
* @note the function may modify the contents of the path, so copies should be passed.
|
| 288 |
+
*/
|
| 289 |
+
const char *av_dirname(char *path);
|
| 290 |
+
|
| 291 |
+
/**
|
| 292 |
+
* Match instances of a name in a comma-separated list of names.
|
| 293 |
+
* List entries are checked from the start to the end of the names list,
|
| 294 |
+
* the first match ends further processing. If an entry prefixed with '-'
|
| 295 |
+
* matches, then 0 is returned. The "ALL" list entry is considered to
|
| 296 |
+
* match all names.
|
| 297 |
+
*
|
| 298 |
+
* @param name Name to look for.
|
| 299 |
+
* @param names List of names.
|
| 300 |
+
* @return 1 on match, 0 otherwise.
|
| 301 |
+
*/
|
| 302 |
+
int av_match_name(const char *name, const char *names);
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* Append path component to the existing path.
|
| 306 |
+
* Path separator '/' is placed between when needed.
|
| 307 |
+
* Resulting string have to be freed with av_free().
|
| 308 |
+
* @param path base path
|
| 309 |
+
* @param component component to be appended
|
| 310 |
+
* @return new path or NULL on error.
|
| 311 |
+
*/
|
| 312 |
+
char *av_append_path_component(const char *path, const char *component);
|
| 313 |
+
|
| 314 |
+
enum AVEscapeMode {
|
| 315 |
+
AV_ESCAPE_MODE_AUTO, ///< Use auto-selected escaping mode.
|
| 316 |
+
AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
|
| 317 |
+
AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.
|
| 318 |
+
AV_ESCAPE_MODE_XML, ///< Use XML non-markup character data escaping.
|
| 319 |
+
};
|
| 320 |
+
|
| 321 |
+
/**
|
| 322 |
+
* Consider spaces special and escape them even in the middle of the
|
| 323 |
+
* string.
|
| 324 |
+
*
|
| 325 |
+
* This is equivalent to adding the whitespace characters to the special
|
| 326 |
+
* characters lists, except it is guaranteed to use the exact same list
|
| 327 |
+
* of whitespace characters as the rest of libavutil.
|
| 328 |
+
*/
|
| 329 |
+
#define AV_ESCAPE_FLAG_WHITESPACE (1 << 0)
|
| 330 |
+
|
| 331 |
+
/**
|
| 332 |
+
* Escape only specified special characters.
|
| 333 |
+
* Without this flag, escape also any characters that may be considered
|
| 334 |
+
* special by av_get_token(), such as the single quote.
|
| 335 |
+
*/
|
| 336 |
+
#define AV_ESCAPE_FLAG_STRICT (1 << 1)
|
| 337 |
+
|
| 338 |
+
/**
|
| 339 |
+
* Within AV_ESCAPE_MODE_XML, additionally escape single quotes for single
|
| 340 |
+
* quoted attributes.
|
| 341 |
+
*/
|
| 342 |
+
#define AV_ESCAPE_FLAG_XML_SINGLE_QUOTES (1 << 2)
|
| 343 |
+
|
| 344 |
+
/**
|
| 345 |
+
* Within AV_ESCAPE_MODE_XML, additionally escape double quotes for double
|
| 346 |
+
* quoted attributes.
|
| 347 |
+
*/
|
| 348 |
+
#define AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES (1 << 3)
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
/**
|
| 352 |
+
* Escape string in src, and put the escaped string in an allocated
|
| 353 |
+
* string in *dst, which must be freed with av_free().
|
| 354 |
+
*
|
| 355 |
+
* @param dst pointer where an allocated string is put
|
| 356 |
+
* @param src string to escape, must be non-NULL
|
| 357 |
+
* @param special_chars string containing the special characters which
|
| 358 |
+
* need to be escaped, can be NULL
|
| 359 |
+
* @param mode escape mode to employ, see AV_ESCAPE_MODE_* macros.
|
| 360 |
+
* Any unknown value for mode will be considered equivalent to
|
| 361 |
+
* AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without
|
| 362 |
+
* notice.
|
| 363 |
+
* @param flags flags which control how to escape, see AV_ESCAPE_FLAG_ macros
|
| 364 |
+
* @return the length of the allocated string, or a negative error code in case of error
|
| 365 |
+
* @see av_bprint_escape()
|
| 366 |
+
*/
|
| 367 |
+
av_warn_unused_result
|
| 368 |
+
int av_escape(char **dst, const char *src, const char *special_chars,
|
| 369 |
+
enum AVEscapeMode mode, int flags);
|
| 370 |
+
|
| 371 |
+
#define AV_UTF8_FLAG_ACCEPT_INVALID_BIG_CODES 1 ///< accept codepoints over 0x10FFFF
|
| 372 |
+
#define AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS 2 ///< accept non-characters - 0xFFFE and 0xFFFF
|
| 373 |
+
#define AV_UTF8_FLAG_ACCEPT_SURROGATES 4 ///< accept UTF-16 surrogates codes
|
| 374 |
+
#define AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES 8 ///< exclude control codes not accepted by XML
|
| 375 |
+
|
| 376 |
+
#define AV_UTF8_FLAG_ACCEPT_ALL \
|
| 377 |
+
AV_UTF8_FLAG_ACCEPT_INVALID_BIG_CODES|AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS|AV_UTF8_FLAG_ACCEPT_SURROGATES
|
| 378 |
+
|
| 379 |
+
/**
|
| 380 |
+
* Read and decode a single UTF-8 code point (character) from the
|
| 381 |
+
* buffer in *buf, and update *buf to point to the next byte to
|
| 382 |
+
* decode.
|
| 383 |
+
*
|
| 384 |
+
* In case of an invalid byte sequence, the pointer will be updated to
|
| 385 |
+
* the next byte after the invalid sequence and the function will
|
| 386 |
+
* return an error code.
|
| 387 |
+
*
|
| 388 |
+
* Depending on the specified flags, the function will also fail in
|
| 389 |
+
* case the decoded code point does not belong to a valid range.
|
| 390 |
+
*
|
| 391 |
+
* @note For speed-relevant code a carefully implemented use of
|
| 392 |
+
* GET_UTF8() may be preferred.
|
| 393 |
+
*
|
| 394 |
+
* @param codep pointer used to return the parsed code in case of success.
|
| 395 |
+
* The value in *codep is set even in case the range check fails.
|
| 396 |
+
* @param bufp pointer to the address the first byte of the sequence
|
| 397 |
+
* to decode, updated by the function to point to the
|
| 398 |
+
* byte next after the decoded sequence
|
| 399 |
+
* @param buf_end pointer to the end of the buffer, points to the next
|
| 400 |
+
* byte past the last in the buffer. This is used to
|
| 401 |
+
* avoid buffer overreads (in case of an unfinished
|
| 402 |
+
* UTF-8 sequence towards the end of the buffer).
|
| 403 |
+
* @param flags a collection of AV_UTF8_FLAG_* flags
|
| 404 |
+
* @return >= 0 in case a sequence was successfully read, a negative
|
| 405 |
+
* value in case of invalid sequence
|
| 406 |
+
*/
|
| 407 |
+
av_warn_unused_result
|
| 408 |
+
int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end,
|
| 409 |
+
unsigned int flags);
|
| 410 |
+
|
| 411 |
+
/**
|
| 412 |
+
* Check if a name is in a list.
|
| 413 |
+
* @returns 0 if not found, or the 1 based index where it has been found in the
|
| 414 |
+
* list.
|
| 415 |
+
*/
|
| 416 |
+
int av_match_list(const char *name, const char *list, char separator);
|
| 417 |
+
|
| 418 |
+
/**
|
| 419 |
+
* See libc sscanf manual for more information.
|
| 420 |
+
* Locale-independent sscanf implementation.
|
| 421 |
+
*/
|
| 422 |
+
int av_sscanf(const char *string, const char *format, ...);
|
| 423 |
+
|
| 424 |
+
/**
|
| 425 |
+
* @}
|
| 426 |
+
*/
|
| 427 |
+
|
| 428 |
+
#endif /* AVUTIL_AVSTRING_H */
|
ffmpeg/include/libavutil/avutil.h
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_AVUTIL_H
|
| 22 |
+
#define AVUTIL_AVUTIL_H
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @file
|
| 26 |
+
* @ingroup lavu
|
| 27 |
+
* Convenience header that includes @ref lavu "libavutil"'s core.
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @mainpage
|
| 32 |
+
*
|
| 33 |
+
* @section ffmpeg_intro Introduction
|
| 34 |
+
*
|
| 35 |
+
* This document describes the usage of the different libraries
|
| 36 |
+
* provided by FFmpeg.
|
| 37 |
+
*
|
| 38 |
+
* @li @ref libavc "libavcodec" encoding/decoding library
|
| 39 |
+
* @li @ref lavfi "libavfilter" graph-based frame editing library
|
| 40 |
+
* @li @ref libavf "libavformat" I/O and muxing/demuxing library
|
| 41 |
+
* @li @ref lavd "libavdevice" special devices muxing/demuxing library
|
| 42 |
+
* @li @ref lavu "libavutil" common utility library
|
| 43 |
+
* @li @ref lswr "libswresample" audio resampling, format conversion and mixing
|
| 44 |
+
* @li @ref lpp "libpostproc" post processing library
|
| 45 |
+
* @li @ref libsws "libswscale" color conversion and scaling library
|
| 46 |
+
*
|
| 47 |
+
* @section ffmpeg_versioning Versioning and compatibility
|
| 48 |
+
*
|
| 49 |
+
* Each of the FFmpeg libraries contains a version.h header, which defines a
|
| 50 |
+
* major, minor and micro version number with the
|
| 51 |
+
* <em>LIBRARYNAME_VERSION_{MAJOR,MINOR,MICRO}</em> macros. The major version
|
| 52 |
+
* number is incremented with backward incompatible changes - e.g. removing
|
| 53 |
+
* parts of the public API, reordering public struct members, etc. The minor
|
| 54 |
+
* version number is incremented for backward compatible API changes or major
|
| 55 |
+
* new features - e.g. adding a new public function or a new decoder. The micro
|
| 56 |
+
* version number is incremented for smaller changes that a calling program
|
| 57 |
+
* might still want to check for - e.g. changing behavior in a previously
|
| 58 |
+
* unspecified situation.
|
| 59 |
+
*
|
| 60 |
+
* FFmpeg guarantees backward API and ABI compatibility for each library as long
|
| 61 |
+
* as its major version number is unchanged. This means that no public symbols
|
| 62 |
+
* will be removed or renamed. Types and names of the public struct members and
|
| 63 |
+
* values of public macros and enums will remain the same (unless they were
|
| 64 |
+
* explicitly declared as not part of the public API). Documented behavior will
|
| 65 |
+
* not change.
|
| 66 |
+
*
|
| 67 |
+
* In other words, any correct program that works with a given FFmpeg snapshot
|
| 68 |
+
* should work just as well without any changes with any later snapshot with the
|
| 69 |
+
* same major versions. This applies to both rebuilding the program against new
|
| 70 |
+
* FFmpeg versions or to replacing the dynamic FFmpeg libraries that a program
|
| 71 |
+
* links against.
|
| 72 |
+
*
|
| 73 |
+
* However, new public symbols may be added and new members may be appended to
|
| 74 |
+
* public structs whose size is not part of public ABI (most public structs in
|
| 75 |
+
* FFmpeg). New macros and enum values may be added. Behavior in undocumented
|
| 76 |
+
* situations may change slightly (and be documented). All those are accompanied
|
| 77 |
+
* by an entry in doc/APIchanges and incrementing either the minor or micro
|
| 78 |
+
* version number.
|
| 79 |
+
*/
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* @defgroup lavu libavutil
|
| 83 |
+
* Common code shared across all FFmpeg libraries.
|
| 84 |
+
*
|
| 85 |
+
* @note
|
| 86 |
+
* libavutil is designed to be modular. In most cases, in order to use the
|
| 87 |
+
* functions provided by one component of libavutil you must explicitly include
|
| 88 |
+
* the specific header containing that feature. If you are only using
|
| 89 |
+
* media-related components, you could simply include libavutil/avutil.h, which
|
| 90 |
+
* brings in most of the "core" components.
|
| 91 |
+
*
|
| 92 |
+
* @{
|
| 93 |
+
*
|
| 94 |
+
* @defgroup lavu_crypto Crypto and Hashing
|
| 95 |
+
*
|
| 96 |
+
* @{
|
| 97 |
+
* @}
|
| 98 |
+
*
|
| 99 |
+
* @defgroup lavu_math Mathematics
|
| 100 |
+
* @{
|
| 101 |
+
*
|
| 102 |
+
* @}
|
| 103 |
+
*
|
| 104 |
+
* @defgroup lavu_string String Manipulation
|
| 105 |
+
*
|
| 106 |
+
* @{
|
| 107 |
+
*
|
| 108 |
+
* @}
|
| 109 |
+
*
|
| 110 |
+
* @defgroup lavu_mem Memory Management
|
| 111 |
+
*
|
| 112 |
+
* @{
|
| 113 |
+
*
|
| 114 |
+
* @}
|
| 115 |
+
*
|
| 116 |
+
* @defgroup lavu_data Data Structures
|
| 117 |
+
* @{
|
| 118 |
+
*
|
| 119 |
+
* @}
|
| 120 |
+
*
|
| 121 |
+
* @defgroup lavu_video Video related
|
| 122 |
+
*
|
| 123 |
+
* @{
|
| 124 |
+
*
|
| 125 |
+
* @}
|
| 126 |
+
*
|
| 127 |
+
* @defgroup lavu_audio Audio related
|
| 128 |
+
*
|
| 129 |
+
* @{
|
| 130 |
+
*
|
| 131 |
+
* @}
|
| 132 |
+
*
|
| 133 |
+
* @defgroup lavu_error Error Codes
|
| 134 |
+
*
|
| 135 |
+
* @{
|
| 136 |
+
*
|
| 137 |
+
* @}
|
| 138 |
+
*
|
| 139 |
+
* @defgroup lavu_log Logging Facility
|
| 140 |
+
*
|
| 141 |
+
* @{
|
| 142 |
+
*
|
| 143 |
+
* @}
|
| 144 |
+
*
|
| 145 |
+
* @defgroup lavu_misc Other
|
| 146 |
+
*
|
| 147 |
+
* @{
|
| 148 |
+
*
|
| 149 |
+
* @defgroup preproc_misc Preprocessor String Macros
|
| 150 |
+
*
|
| 151 |
+
* @{
|
| 152 |
+
*
|
| 153 |
+
* @}
|
| 154 |
+
*
|
| 155 |
+
* @defgroup version_utils Library Version Macros
|
| 156 |
+
*
|
| 157 |
+
* @{
|
| 158 |
+
*
|
| 159 |
+
* @}
|
| 160 |
+
*/
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* @addtogroup lavu_ver
|
| 165 |
+
* @{
|
| 166 |
+
*/
|
| 167 |
+
|
| 168 |
+
/**
|
| 169 |
+
* Return the LIBAVUTIL_VERSION_INT constant.
|
| 170 |
+
*/
|
| 171 |
+
unsigned avutil_version(void);
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
* Return an informative version string. This usually is the actual release
|
| 175 |
+
* version number or a git commit description. This string has no fixed format
|
| 176 |
+
* and can change any time. It should never be parsed by code.
|
| 177 |
+
*/
|
| 178 |
+
const char *av_version_info(void);
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* Return the libavutil build-time configuration.
|
| 182 |
+
*/
|
| 183 |
+
const char *avutil_configuration(void);
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* Return the libavutil license.
|
| 187 |
+
*/
|
| 188 |
+
const char *avutil_license(void);
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* @}
|
| 192 |
+
*/
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* @addtogroup lavu_media Media Type
|
| 196 |
+
* @brief Media Type
|
| 197 |
+
*/
|
| 198 |
+
|
| 199 |
+
enum AVMediaType {
|
| 200 |
+
AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA
|
| 201 |
+
AVMEDIA_TYPE_VIDEO,
|
| 202 |
+
AVMEDIA_TYPE_AUDIO,
|
| 203 |
+
AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous
|
| 204 |
+
AVMEDIA_TYPE_SUBTITLE,
|
| 205 |
+
AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse
|
| 206 |
+
AVMEDIA_TYPE_NB
|
| 207 |
+
};
|
| 208 |
+
|
| 209 |
+
/**
|
| 210 |
+
* Return a string describing the media_type enum, NULL if media_type
|
| 211 |
+
* is unknown.
|
| 212 |
+
*/
|
| 213 |
+
const char *av_get_media_type_string(enum AVMediaType media_type);
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
* @defgroup lavu_const Constants
|
| 217 |
+
* @{
|
| 218 |
+
*
|
| 219 |
+
* @defgroup lavu_enc Encoding specific
|
| 220 |
+
*
|
| 221 |
+
* @note those definition should move to avcodec
|
| 222 |
+
* @{
|
| 223 |
+
*/
|
| 224 |
+
|
| 225 |
+
#define FF_LAMBDA_SHIFT 7
|
| 226 |
+
#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
|
| 227 |
+
#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
|
| 228 |
+
#define FF_LAMBDA_MAX (256*128-1)
|
| 229 |
+
|
| 230 |
+
#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
|
| 231 |
+
|
| 232 |
+
/**
|
| 233 |
+
* @}
|
| 234 |
+
* @defgroup lavu_time Timestamp specific
|
| 235 |
+
*
|
| 236 |
+
* FFmpeg internal timebase and timestamp definitions
|
| 237 |
+
*
|
| 238 |
+
* @{
|
| 239 |
+
*/
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
* @brief Undefined timestamp value
|
| 243 |
+
*
|
| 244 |
+
* Usually reported by demuxer that work on containers that do not provide
|
| 245 |
+
* either pts or dts.
|
| 246 |
+
*/
|
| 247 |
+
|
| 248 |
+
#define AV_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000))
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* Internal time base represented as integer
|
| 252 |
+
*/
|
| 253 |
+
|
| 254 |
+
#define AV_TIME_BASE 1000000
|
| 255 |
+
|
| 256 |
+
/**
|
| 257 |
+
* Internal time base represented as fractional value
|
| 258 |
+
*/
|
| 259 |
+
|
| 260 |
+
#ifdef __cplusplus
|
| 261 |
+
/* ISO C++ forbids compound-literals. */
|
| 262 |
+
#define AV_TIME_BASE_Q av_make_q(1, AV_TIME_BASE)
|
| 263 |
+
#else
|
| 264 |
+
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
|
| 265 |
+
#endif
|
| 266 |
+
|
| 267 |
+
/**
|
| 268 |
+
* @}
|
| 269 |
+
* @}
|
| 270 |
+
* @defgroup lavu_picture Image related
|
| 271 |
+
*
|
| 272 |
+
* AVPicture types, pixel formats and basic image planes manipulation.
|
| 273 |
+
*
|
| 274 |
+
* @{
|
| 275 |
+
*/
|
| 276 |
+
|
| 277 |
+
enum AVPictureType {
|
| 278 |
+
AV_PICTURE_TYPE_NONE = 0, ///< Undefined
|
| 279 |
+
AV_PICTURE_TYPE_I, ///< Intra
|
| 280 |
+
AV_PICTURE_TYPE_P, ///< Predicted
|
| 281 |
+
AV_PICTURE_TYPE_B, ///< Bi-dir predicted
|
| 282 |
+
AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG-4
|
| 283 |
+
AV_PICTURE_TYPE_SI, ///< Switching Intra
|
| 284 |
+
AV_PICTURE_TYPE_SP, ///< Switching Predicted
|
| 285 |
+
AV_PICTURE_TYPE_BI, ///< BI type
|
| 286 |
+
};
|
| 287 |
+
|
| 288 |
+
/**
|
| 289 |
+
* Return a single letter to describe the given picture type
|
| 290 |
+
* pict_type.
|
| 291 |
+
*
|
| 292 |
+
* @param[in] pict_type the picture type @return a single character
|
| 293 |
+
* representing the picture type, '?' if pict_type is unknown
|
| 294 |
+
*/
|
| 295 |
+
char av_get_picture_type_char(enum AVPictureType pict_type);
|
| 296 |
+
|
| 297 |
+
/**
|
| 298 |
+
* @}
|
| 299 |
+
*/
|
| 300 |
+
|
| 301 |
+
#include "common.h"
|
| 302 |
+
#include "rational.h"
|
| 303 |
+
#include "version.h"
|
| 304 |
+
#include "macros.h"
|
| 305 |
+
#include "mathematics.h"
|
| 306 |
+
#include "log.h"
|
| 307 |
+
#include "pixfmt.h"
|
| 308 |
+
|
| 309 |
+
/**
|
| 310 |
+
* Return x default pointer in case p is NULL.
|
| 311 |
+
*/
|
| 312 |
+
static inline void *av_x_if_null(const void *p, const void *x)
|
| 313 |
+
{
|
| 314 |
+
return (void *)(intptr_t)(p ? p : x);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
#if FF_API_OPT_INT_LIST
|
| 318 |
+
/**
|
| 319 |
+
* Compute the length of an integer list.
|
| 320 |
+
*
|
| 321 |
+
* @param elsize size in bytes of each list element (only 1, 2, 4 or 8)
|
| 322 |
+
* @param term list terminator (usually 0 or -1)
|
| 323 |
+
* @param list pointer to the list
|
| 324 |
+
* @return length of the list, in elements, not counting the terminator
|
| 325 |
+
*/
|
| 326 |
+
attribute_deprecated
|
| 327 |
+
unsigned av_int_list_length_for_size(unsigned elsize,
|
| 328 |
+
const void *list, uint64_t term) av_pure;
|
| 329 |
+
|
| 330 |
+
/**
|
| 331 |
+
* Compute the length of an integer list.
|
| 332 |
+
*
|
| 333 |
+
* @param term list terminator (usually 0 or -1)
|
| 334 |
+
* @param list pointer to the list
|
| 335 |
+
* @return length of the list, in elements, not counting the terminator
|
| 336 |
+
*/
|
| 337 |
+
#define av_int_list_length(list, term) \
|
| 338 |
+
av_int_list_length_for_size(sizeof(*(list)), list, term)
|
| 339 |
+
#endif
|
| 340 |
+
|
| 341 |
+
/**
|
| 342 |
+
* Return the fractional representation of the internal time base.
|
| 343 |
+
*/
|
| 344 |
+
AVRational av_get_time_base_q(void);
|
| 345 |
+
|
| 346 |
+
#define AV_FOURCC_MAX_STRING_SIZE 32
|
| 347 |
+
|
| 348 |
+
#define av_fourcc2str(fourcc) av_fourcc_make_string((char[AV_FOURCC_MAX_STRING_SIZE]){0}, fourcc)
|
| 349 |
+
|
| 350 |
+
/**
|
| 351 |
+
* Fill the provided buffer with a string containing a FourCC (four-character
|
| 352 |
+
* code) representation.
|
| 353 |
+
*
|
| 354 |
+
* @param buf a buffer with size in bytes of at least AV_FOURCC_MAX_STRING_SIZE
|
| 355 |
+
* @param fourcc the fourcc to represent
|
| 356 |
+
* @return the buffer in input
|
| 357 |
+
*/
|
| 358 |
+
char *av_fourcc_make_string(char *buf, uint32_t fourcc);
|
| 359 |
+
|
| 360 |
+
/**
|
| 361 |
+
* @}
|
| 362 |
+
* @}
|
| 363 |
+
*/
|
| 364 |
+
|
| 365 |
+
#endif /* AVUTIL_AVUTIL_H */
|
ffmpeg/include/libavutil/base64.h
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com)
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_BASE64_H
|
| 22 |
+
#define AVUTIL_BASE64_H
|
| 23 |
+
|
| 24 |
+
#include <stdint.h>
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @defgroup lavu_base64 Base64
|
| 28 |
+
* @ingroup lavu_crypto
|
| 29 |
+
* @{
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Decode a base64-encoded string.
|
| 34 |
+
*
|
| 35 |
+
* @param out buffer for decoded data
|
| 36 |
+
* @param in null-terminated input string
|
| 37 |
+
* @param out_size size in bytes of the out buffer, must be at
|
| 38 |
+
* least 3/4 of the length of in, that is AV_BASE64_DECODE_SIZE(strlen(in))
|
| 39 |
+
* @return number of bytes written, or a negative value in case of
|
| 40 |
+
* invalid input
|
| 41 |
+
*/
|
| 42 |
+
int av_base64_decode(uint8_t *out, const char *in, int out_size);
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Calculate the output size in bytes needed to decode a base64 string
|
| 46 |
+
* with length x to a data buffer.
|
| 47 |
+
*/
|
| 48 |
+
#define AV_BASE64_DECODE_SIZE(x) ((x) * 3LL / 4)
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Encode data to base64 and null-terminate.
|
| 52 |
+
*
|
| 53 |
+
* @param out buffer for encoded data
|
| 54 |
+
* @param out_size size in bytes of the out buffer (including the
|
| 55 |
+
* null terminator), must be at least AV_BASE64_SIZE(in_size)
|
| 56 |
+
* @param in input buffer containing the data to encode
|
| 57 |
+
* @param in_size size in bytes of the in buffer
|
| 58 |
+
* @return out or NULL in case of error
|
| 59 |
+
*/
|
| 60 |
+
char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size);
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* Calculate the output size needed to base64-encode x bytes to a
|
| 64 |
+
* null-terminated string.
|
| 65 |
+
*/
|
| 66 |
+
#define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1)
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* @}
|
| 70 |
+
*/
|
| 71 |
+
|
| 72 |
+
#endif /* AVUTIL_BASE64_H */
|
ffmpeg/include/libavutil/blowfish.h
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Blowfish algorithm
|
| 3 |
+
* Copyright (c) 2012 Samuel Pitoiset
|
| 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 |
+
#ifndef AVUTIL_BLOWFISH_H
|
| 23 |
+
#define AVUTIL_BLOWFISH_H
|
| 24 |
+
|
| 25 |
+
#include <stdint.h>
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @defgroup lavu_blowfish Blowfish
|
| 29 |
+
* @ingroup lavu_crypto
|
| 30 |
+
* @{
|
| 31 |
+
*/
|
| 32 |
+
|
| 33 |
+
#define AV_BF_ROUNDS 16
|
| 34 |
+
|
| 35 |
+
typedef struct AVBlowfish {
|
| 36 |
+
uint32_t p[AV_BF_ROUNDS + 2];
|
| 37 |
+
uint32_t s[4][256];
|
| 38 |
+
} AVBlowfish;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Allocate an AVBlowfish context.
|
| 42 |
+
*/
|
| 43 |
+
AVBlowfish *av_blowfish_alloc(void);
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Initialize an AVBlowfish context.
|
| 47 |
+
*
|
| 48 |
+
* @param ctx an AVBlowfish context
|
| 49 |
+
* @param key a key
|
| 50 |
+
* @param key_len length of the key
|
| 51 |
+
*/
|
| 52 |
+
void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Encrypt or decrypt a buffer using a previously initialized context.
|
| 56 |
+
*
|
| 57 |
+
* @param ctx an AVBlowfish context
|
| 58 |
+
* @param xl left four bytes halves of input to be encrypted
|
| 59 |
+
* @param xr right four bytes halves of input to be encrypted
|
| 60 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 61 |
+
*/
|
| 62 |
+
void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
|
| 63 |
+
int decrypt);
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Encrypt or decrypt a buffer using a previously initialized context.
|
| 67 |
+
*
|
| 68 |
+
* @param ctx an AVBlowfish context
|
| 69 |
+
* @param dst destination array, can be equal to src
|
| 70 |
+
* @param src source array, can be equal to dst
|
| 71 |
+
* @param count number of 8 byte blocks
|
| 72 |
+
* @param iv initialization vector for CBC mode, if NULL ECB will be used
|
| 73 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 74 |
+
*/
|
| 75 |
+
void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
|
| 76 |
+
int count, uint8_t *iv, int decrypt);
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* @}
|
| 80 |
+
*/
|
| 81 |
+
|
| 82 |
+
#endif /* AVUTIL_BLOWFISH_H */
|
ffmpeg/include/libavutil/bprint.h
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2012 Nicolas George
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* @ingroup lavu_avbprint
|
| 24 |
+
* AVBPrint public header
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_BPRINT_H
|
| 28 |
+
#define AVUTIL_BPRINT_H
|
| 29 |
+
|
| 30 |
+
#include <stdarg.h>
|
| 31 |
+
|
| 32 |
+
#include "attributes.h"
|
| 33 |
+
#include "avstring.h"
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @defgroup lavu_avbprint AVBPrint
|
| 37 |
+
* @ingroup lavu_data
|
| 38 |
+
*
|
| 39 |
+
* A buffer to print data progressively
|
| 40 |
+
* @{
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Define a structure with extra padding to a fixed size
|
| 45 |
+
* This helps ensuring binary compatibility with future versions.
|
| 46 |
+
*/
|
| 47 |
+
|
| 48 |
+
#define FF_PAD_STRUCTURE(name, size, ...) \
|
| 49 |
+
struct ff_pad_helper_##name { __VA_ARGS__ }; \
|
| 50 |
+
typedef struct name { \
|
| 51 |
+
__VA_ARGS__ \
|
| 52 |
+
char reserved_padding[size - sizeof(struct ff_pad_helper_##name)]; \
|
| 53 |
+
} name;
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Buffer to print data progressively
|
| 57 |
+
*
|
| 58 |
+
* The string buffer grows as necessary and is always 0-terminated.
|
| 59 |
+
* The content of the string is never accessed, and thus is
|
| 60 |
+
* encoding-agnostic and can even hold binary data.
|
| 61 |
+
*
|
| 62 |
+
* Small buffers are kept in the structure itself, and thus require no
|
| 63 |
+
* memory allocation at all (unless the contents of the buffer is needed
|
| 64 |
+
* after the structure goes out of scope). This is almost as lightweight as
|
| 65 |
+
* declaring a local `char buf[512]`.
|
| 66 |
+
*
|
| 67 |
+
* The length of the string can go beyond the allocated size: the buffer is
|
| 68 |
+
* then truncated, but the functions still keep account of the actual total
|
| 69 |
+
* length.
|
| 70 |
+
*
|
| 71 |
+
* In other words, AVBPrint.len can be greater than AVBPrint.size and records
|
| 72 |
+
* the total length of what would have been to the buffer if there had been
|
| 73 |
+
* enough memory.
|
| 74 |
+
*
|
| 75 |
+
* Append operations do not need to be tested for failure: if a memory
|
| 76 |
+
* allocation fails, data stop being appended to the buffer, but the length
|
| 77 |
+
* is still updated. This situation can be tested with
|
| 78 |
+
* av_bprint_is_complete().
|
| 79 |
+
*
|
| 80 |
+
* The AVBPrint.size_max field determines several possible behaviours:
|
| 81 |
+
* - `size_max = -1` (= `UINT_MAX`) or any large value will let the buffer be
|
| 82 |
+
* reallocated as necessary, with an amortized linear cost.
|
| 83 |
+
* - `size_max = 0` prevents writing anything to the buffer: only the total
|
| 84 |
+
* length is computed. The write operations can then possibly be repeated in
|
| 85 |
+
* a buffer with exactly the necessary size
|
| 86 |
+
* (using `size_init = size_max = len + 1`).
|
| 87 |
+
* - `size_max = 1` is automatically replaced by the exact size available in the
|
| 88 |
+
* structure itself, thus ensuring no dynamic memory allocation. The
|
| 89 |
+
* internal buffer is large enough to hold a reasonable paragraph of text,
|
| 90 |
+
* such as the current paragraph.
|
| 91 |
+
*/
|
| 92 |
+
|
| 93 |
+
FF_PAD_STRUCTURE(AVBPrint, 1024,
|
| 94 |
+
char *str; /**< string so far */
|
| 95 |
+
unsigned len; /**< length so far */
|
| 96 |
+
unsigned size; /**< allocated memory */
|
| 97 |
+
unsigned size_max; /**< maximum allocated memory */
|
| 98 |
+
char reserved_internal_buffer[1];
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* @name Max size special values
|
| 103 |
+
* Convenience macros for special values for av_bprint_init() size_max
|
| 104 |
+
* parameter.
|
| 105 |
+
* @{
|
| 106 |
+
*/
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Buffer will be reallocated as necessary, with an amortized linear cost.
|
| 110 |
+
*/
|
| 111 |
+
#define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
|
| 112 |
+
/**
|
| 113 |
+
* Use the exact size available in the AVBPrint structure itself.
|
| 114 |
+
*
|
| 115 |
+
* Thus ensuring no dynamic memory allocation. The internal buffer is large
|
| 116 |
+
* enough to hold a reasonable paragraph of text, such as the current paragraph.
|
| 117 |
+
*/
|
| 118 |
+
#define AV_BPRINT_SIZE_AUTOMATIC 1
|
| 119 |
+
/**
|
| 120 |
+
* Do not write anything to the buffer, only calculate the total length.
|
| 121 |
+
*
|
| 122 |
+
* The write operations can then possibly be repeated in a buffer with
|
| 123 |
+
* exactly the necessary size (using `size_init = size_max = AVBPrint.len + 1`).
|
| 124 |
+
*/
|
| 125 |
+
#define AV_BPRINT_SIZE_COUNT_ONLY 0
|
| 126 |
+
/** @} */
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* Init a print buffer.
|
| 130 |
+
*
|
| 131 |
+
* @param buf buffer to init
|
| 132 |
+
* @param size_init initial size (including the final 0)
|
| 133 |
+
* @param size_max maximum size;
|
| 134 |
+
* - `0` means do not write anything, just count the length
|
| 135 |
+
* - `1` is replaced by the maximum value for automatic storage
|
| 136 |
+
* any large value means that the internal buffer will be
|
| 137 |
+
* reallocated as needed up to that limit
|
| 138 |
+
* - `-1` is converted to `UINT_MAX`, the largest limit possible.
|
| 139 |
+
* Check also `AV_BPRINT_SIZE_*` macros.
|
| 140 |
+
*/
|
| 141 |
+
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
* Init a print buffer using a pre-existing buffer.
|
| 145 |
+
*
|
| 146 |
+
* The buffer will not be reallocated.
|
| 147 |
+
* In case size equals zero, the AVBPrint will be initialized to use
|
| 148 |
+
* the internal buffer as if using AV_BPRINT_SIZE_COUNT_ONLY with
|
| 149 |
+
* av_bprint_init().
|
| 150 |
+
*
|
| 151 |
+
* @param buf buffer structure to init
|
| 152 |
+
* @param buffer byte buffer to use for the string data
|
| 153 |
+
* @param size size of buffer
|
| 154 |
+
*/
|
| 155 |
+
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* Append a formatted string to a print buffer.
|
| 159 |
+
*/
|
| 160 |
+
void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Append a formatted string to a print buffer.
|
| 164 |
+
*/
|
| 165 |
+
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg);
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Append char c n times to a print buffer.
|
| 169 |
+
*/
|
| 170 |
+
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Append data to a print buffer.
|
| 174 |
+
*
|
| 175 |
+
* @param buf bprint buffer to use
|
| 176 |
+
* @param data pointer to data
|
| 177 |
+
* @param size size of data
|
| 178 |
+
*/
|
| 179 |
+
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size);
|
| 180 |
+
|
| 181 |
+
struct tm;
|
| 182 |
+
/**
|
| 183 |
+
* Append a formatted date and time to a print buffer.
|
| 184 |
+
*
|
| 185 |
+
* @param buf bprint buffer to use
|
| 186 |
+
* @param fmt date and time format string, see strftime()
|
| 187 |
+
* @param tm broken-down time structure to translate
|
| 188 |
+
*
|
| 189 |
+
* @note due to poor design of the standard strftime function, it may
|
| 190 |
+
* produce poor results if the format string expands to a very long text and
|
| 191 |
+
* the bprint buffer is near the limit stated by the size_max option.
|
| 192 |
+
*/
|
| 193 |
+
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm);
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
* Allocate bytes in the buffer for external use.
|
| 197 |
+
*
|
| 198 |
+
* @param[in] buf buffer structure
|
| 199 |
+
* @param[in] size required size
|
| 200 |
+
* @param[out] mem pointer to the memory area
|
| 201 |
+
* @param[out] actual_size size of the memory area after allocation;
|
| 202 |
+
* can be larger or smaller than size
|
| 203 |
+
*/
|
| 204 |
+
void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
|
| 205 |
+
unsigned char **mem, unsigned *actual_size);
|
| 206 |
+
|
| 207 |
+
/**
|
| 208 |
+
* Reset the string to "" but keep internal allocated data.
|
| 209 |
+
*/
|
| 210 |
+
void av_bprint_clear(AVBPrint *buf);
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* Test if the print buffer is complete (not truncated).
|
| 214 |
+
*
|
| 215 |
+
* It may have been truncated due to a memory allocation failure
|
| 216 |
+
* or the size_max limit (compare size and size_max if necessary).
|
| 217 |
+
*/
|
| 218 |
+
static inline int av_bprint_is_complete(const AVBPrint *buf)
|
| 219 |
+
{
|
| 220 |
+
return buf->len < buf->size;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
/**
|
| 224 |
+
* Finalize a print buffer.
|
| 225 |
+
*
|
| 226 |
+
* The print buffer can no longer be used afterwards,
|
| 227 |
+
* but the len and size fields are still valid.
|
| 228 |
+
*
|
| 229 |
+
* @arg[out] ret_str if not NULL, used to return a permanent copy of the
|
| 230 |
+
* buffer contents, or NULL if memory allocation fails;
|
| 231 |
+
* if NULL, the buffer is discarded and freed
|
| 232 |
+
* @return 0 for success or error code (probably AVERROR(ENOMEM))
|
| 233 |
+
*/
|
| 234 |
+
int av_bprint_finalize(AVBPrint *buf, char **ret_str);
|
| 235 |
+
|
| 236 |
+
/**
|
| 237 |
+
* Escape the content in src and append it to dstbuf.
|
| 238 |
+
*
|
| 239 |
+
* @param dstbuf already inited destination bprint buffer
|
| 240 |
+
* @param src string containing the text to escape
|
| 241 |
+
* @param special_chars string containing the special characters which
|
| 242 |
+
* need to be escaped, can be NULL
|
| 243 |
+
* @param mode escape mode to employ, see AV_ESCAPE_MODE_* macros.
|
| 244 |
+
* Any unknown value for mode will be considered equivalent to
|
| 245 |
+
* AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without
|
| 246 |
+
* notice.
|
| 247 |
+
* @param flags flags which control how to escape, see AV_ESCAPE_FLAG_* macros
|
| 248 |
+
*/
|
| 249 |
+
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
|
| 250 |
+
enum AVEscapeMode mode, int flags);
|
| 251 |
+
|
| 252 |
+
/** @} */
|
| 253 |
+
|
| 254 |
+
#endif /* AVUTIL_BPRINT_H */
|
ffmpeg/include/libavutil/bswap.h
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* byte swapping routines
|
| 24 |
+
*/
|
| 25 |
+
|
| 26 |
+
#ifndef AVUTIL_BSWAP_H
|
| 27 |
+
#define AVUTIL_BSWAP_H
|
| 28 |
+
|
| 29 |
+
#include <stdint.h>
|
| 30 |
+
#include "libavutil/avconfig.h"
|
| 31 |
+
#include "attributes.h"
|
| 32 |
+
|
| 33 |
+
#ifdef HAVE_AV_CONFIG_H
|
| 34 |
+
|
| 35 |
+
#include "config.h"
|
| 36 |
+
|
| 37 |
+
#if ARCH_ARM
|
| 38 |
+
# include "arm/bswap.h"
|
| 39 |
+
#elif ARCH_RISCV
|
| 40 |
+
# include "riscv/bswap.h"
|
| 41 |
+
#elif ARCH_X86
|
| 42 |
+
# include "x86/bswap.h"
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#endif /* HAVE_AV_CONFIG_H */
|
| 46 |
+
|
| 47 |
+
#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))
|
| 48 |
+
#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))
|
| 49 |
+
#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32))
|
| 50 |
+
|
| 51 |
+
#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x)
|
| 52 |
+
|
| 53 |
+
#ifndef av_bswap16
|
| 54 |
+
static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
|
| 55 |
+
{
|
| 56 |
+
x= (x>>8) | (x<<8);
|
| 57 |
+
return x;
|
| 58 |
+
}
|
| 59 |
+
#endif
|
| 60 |
+
|
| 61 |
+
#ifndef av_bswap32
|
| 62 |
+
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
|
| 63 |
+
{
|
| 64 |
+
return AV_BSWAP32C(x);
|
| 65 |
+
}
|
| 66 |
+
#endif
|
| 67 |
+
|
| 68 |
+
#ifndef av_bswap64
|
| 69 |
+
static inline uint64_t av_const av_bswap64(uint64_t x)
|
| 70 |
+
{
|
| 71 |
+
return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32);
|
| 72 |
+
}
|
| 73 |
+
#endif
|
| 74 |
+
|
| 75 |
+
// be2ne ... big-endian to native-endian
|
| 76 |
+
// le2ne ... little-endian to native-endian
|
| 77 |
+
|
| 78 |
+
#if AV_HAVE_BIGENDIAN
|
| 79 |
+
#define av_be2ne16(x) (x)
|
| 80 |
+
#define av_be2ne32(x) (x)
|
| 81 |
+
#define av_be2ne64(x) (x)
|
| 82 |
+
#define av_le2ne16(x) av_bswap16(x)
|
| 83 |
+
#define av_le2ne32(x) av_bswap32(x)
|
| 84 |
+
#define av_le2ne64(x) av_bswap64(x)
|
| 85 |
+
#define AV_BE2NEC(s, x) (x)
|
| 86 |
+
#define AV_LE2NEC(s, x) AV_BSWAPC(s, x)
|
| 87 |
+
#else
|
| 88 |
+
#define av_be2ne16(x) av_bswap16(x)
|
| 89 |
+
#define av_be2ne32(x) av_bswap32(x)
|
| 90 |
+
#define av_be2ne64(x) av_bswap64(x)
|
| 91 |
+
#define av_le2ne16(x) (x)
|
| 92 |
+
#define av_le2ne32(x) (x)
|
| 93 |
+
#define av_le2ne64(x) (x)
|
| 94 |
+
#define AV_BE2NEC(s, x) AV_BSWAPC(s, x)
|
| 95 |
+
#define AV_LE2NEC(s, x) (x)
|
| 96 |
+
#endif
|
| 97 |
+
|
| 98 |
+
#define AV_BE2NE16C(x) AV_BE2NEC(16, x)
|
| 99 |
+
#define AV_BE2NE32C(x) AV_BE2NEC(32, x)
|
| 100 |
+
#define AV_BE2NE64C(x) AV_BE2NEC(64, x)
|
| 101 |
+
#define AV_LE2NE16C(x) AV_LE2NEC(16, x)
|
| 102 |
+
#define AV_LE2NE32C(x) AV_LE2NEC(32, x)
|
| 103 |
+
#define AV_LE2NE64C(x) AV_LE2NEC(64, x)
|
| 104 |
+
|
| 105 |
+
#endif /* AVUTIL_BSWAP_H */
|
ffmpeg/include/libavutil/buffer.h
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/**
|
| 20 |
+
* @file
|
| 21 |
+
* @ingroup lavu_buffer
|
| 22 |
+
* refcounted data buffer API
|
| 23 |
+
*/
|
| 24 |
+
|
| 25 |
+
#ifndef AVUTIL_BUFFER_H
|
| 26 |
+
#define AVUTIL_BUFFER_H
|
| 27 |
+
|
| 28 |
+
#include <stddef.h>
|
| 29 |
+
#include <stdint.h>
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @defgroup lavu_buffer AVBuffer
|
| 33 |
+
* @ingroup lavu_data
|
| 34 |
+
*
|
| 35 |
+
* @{
|
| 36 |
+
* AVBuffer is an API for reference-counted data buffers.
|
| 37 |
+
*
|
| 38 |
+
* There are two core objects in this API -- AVBuffer and AVBufferRef. AVBuffer
|
| 39 |
+
* represents the data buffer itself; it is opaque and not meant to be accessed
|
| 40 |
+
* by the caller directly, but only through AVBufferRef. However, the caller may
|
| 41 |
+
* e.g. compare two AVBuffer pointers to check whether two different references
|
| 42 |
+
* are describing the same data buffer. AVBufferRef represents a single
|
| 43 |
+
* reference to an AVBuffer and it is the object that may be manipulated by the
|
| 44 |
+
* caller directly.
|
| 45 |
+
*
|
| 46 |
+
* There are two functions provided for creating a new AVBuffer with a single
|
| 47 |
+
* reference -- av_buffer_alloc() to just allocate a new buffer, and
|
| 48 |
+
* av_buffer_create() to wrap an existing array in an AVBuffer. From an existing
|
| 49 |
+
* reference, additional references may be created with av_buffer_ref().
|
| 50 |
+
* Use av_buffer_unref() to free a reference (this will automatically free the
|
| 51 |
+
* data once all the references are freed).
|
| 52 |
+
*
|
| 53 |
+
* The convention throughout this API and the rest of FFmpeg is such that the
|
| 54 |
+
* buffer is considered writable if there exists only one reference to it (and
|
| 55 |
+
* it has not been marked as read-only). The av_buffer_is_writable() function is
|
| 56 |
+
* provided to check whether this is true and av_buffer_make_writable() will
|
| 57 |
+
* automatically create a new writable buffer when necessary.
|
| 58 |
+
* Of course nothing prevents the calling code from violating this convention,
|
| 59 |
+
* however that is safe only when all the existing references are under its
|
| 60 |
+
* control.
|
| 61 |
+
*
|
| 62 |
+
* @note Referencing and unreferencing the buffers is thread-safe and thus
|
| 63 |
+
* may be done from multiple threads simultaneously without any need for
|
| 64 |
+
* additional locking.
|
| 65 |
+
*
|
| 66 |
+
* @note Two different references to the same buffer can point to different
|
| 67 |
+
* parts of the buffer (i.e. their AVBufferRef.data will not be equal).
|
| 68 |
+
*/
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* A reference counted buffer type. It is opaque and is meant to be used through
|
| 72 |
+
* references (AVBufferRef).
|
| 73 |
+
*/
|
| 74 |
+
typedef struct AVBuffer AVBuffer;
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* A reference to a data buffer.
|
| 78 |
+
*
|
| 79 |
+
* The size of this struct is not a part of the public ABI and it is not meant
|
| 80 |
+
* to be allocated directly.
|
| 81 |
+
*/
|
| 82 |
+
typedef struct AVBufferRef {
|
| 83 |
+
AVBuffer *buffer;
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* The data buffer. It is considered writable if and only if
|
| 87 |
+
* this is the only reference to the buffer, in which case
|
| 88 |
+
* av_buffer_is_writable() returns 1.
|
| 89 |
+
*/
|
| 90 |
+
uint8_t *data;
|
| 91 |
+
/**
|
| 92 |
+
* Size of data in bytes.
|
| 93 |
+
*/
|
| 94 |
+
size_t size;
|
| 95 |
+
} AVBufferRef;
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* Allocate an AVBuffer of the given size using av_malloc().
|
| 99 |
+
*
|
| 100 |
+
* @return an AVBufferRef of given size or NULL when out of memory
|
| 101 |
+
*/
|
| 102 |
+
AVBufferRef *av_buffer_alloc(size_t size);
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* Same as av_buffer_alloc(), except the returned buffer will be initialized
|
| 106 |
+
* to zero.
|
| 107 |
+
*/
|
| 108 |
+
AVBufferRef *av_buffer_allocz(size_t size);
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* Always treat the buffer as read-only, even when it has only one
|
| 112 |
+
* reference.
|
| 113 |
+
*/
|
| 114 |
+
#define AV_BUFFER_FLAG_READONLY (1 << 0)
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* Create an AVBuffer from an existing array.
|
| 118 |
+
*
|
| 119 |
+
* If this function is successful, data is owned by the AVBuffer. The caller may
|
| 120 |
+
* only access data through the returned AVBufferRef and references derived from
|
| 121 |
+
* it.
|
| 122 |
+
* If this function fails, data is left untouched.
|
| 123 |
+
* @param data data array
|
| 124 |
+
* @param size size of data in bytes
|
| 125 |
+
* @param free a callback for freeing this buffer's data
|
| 126 |
+
* @param opaque parameter to be got for processing or passed to free
|
| 127 |
+
* @param flags a combination of AV_BUFFER_FLAG_*
|
| 128 |
+
*
|
| 129 |
+
* @return an AVBufferRef referring to data on success, NULL on failure.
|
| 130 |
+
*/
|
| 131 |
+
AVBufferRef *av_buffer_create(uint8_t *data, size_t size,
|
| 132 |
+
void (*free)(void *opaque, uint8_t *data),
|
| 133 |
+
void *opaque, int flags);
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* Default free callback, which calls av_free() on the buffer data.
|
| 137 |
+
* This function is meant to be passed to av_buffer_create(), not called
|
| 138 |
+
* directly.
|
| 139 |
+
*/
|
| 140 |
+
void av_buffer_default_free(void *opaque, uint8_t *data);
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Create a new reference to an AVBuffer.
|
| 144 |
+
*
|
| 145 |
+
* @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on
|
| 146 |
+
* failure.
|
| 147 |
+
*/
|
| 148 |
+
AVBufferRef *av_buffer_ref(const AVBufferRef *buf);
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* Free a given reference and automatically free the buffer if there are no more
|
| 152 |
+
* references to it.
|
| 153 |
+
*
|
| 154 |
+
* @param buf the reference to be freed. The pointer is set to NULL on return.
|
| 155 |
+
*/
|
| 156 |
+
void av_buffer_unref(AVBufferRef **buf);
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* @return 1 if the caller may write to the data referred to by buf (which is
|
| 160 |
+
* true if and only if buf is the only reference to the underlying AVBuffer).
|
| 161 |
+
* Return 0 otherwise.
|
| 162 |
+
* A positive answer is valid until av_buffer_ref() is called on buf.
|
| 163 |
+
*/
|
| 164 |
+
int av_buffer_is_writable(const AVBufferRef *buf);
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* @return the opaque parameter set by av_buffer_create.
|
| 168 |
+
*/
|
| 169 |
+
void *av_buffer_get_opaque(const AVBufferRef *buf);
|
| 170 |
+
|
| 171 |
+
int av_buffer_get_ref_count(const AVBufferRef *buf);
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
* Create a writable reference from a given buffer reference, avoiding data copy
|
| 175 |
+
* if possible.
|
| 176 |
+
*
|
| 177 |
+
* @param buf buffer reference to make writable. On success, buf is either left
|
| 178 |
+
* untouched, or it is unreferenced and a new writable AVBufferRef is
|
| 179 |
+
* written in its place. On failure, buf is left untouched.
|
| 180 |
+
* @return 0 on success, a negative AVERROR on failure.
|
| 181 |
+
*/
|
| 182 |
+
int av_buffer_make_writable(AVBufferRef **buf);
|
| 183 |
+
|
| 184 |
+
/**
|
| 185 |
+
* Reallocate a given buffer.
|
| 186 |
+
*
|
| 187 |
+
* @param buf a buffer reference to reallocate. On success, buf will be
|
| 188 |
+
* unreferenced and a new reference with the required size will be
|
| 189 |
+
* written in its place. On failure buf will be left untouched. *buf
|
| 190 |
+
* may be NULL, then a new buffer is allocated.
|
| 191 |
+
* @param size required new buffer size.
|
| 192 |
+
* @return 0 on success, a negative AVERROR on failure.
|
| 193 |
+
*
|
| 194 |
+
* @note the buffer is actually reallocated with av_realloc() only if it was
|
| 195 |
+
* initially allocated through av_buffer_realloc(NULL) and there is only one
|
| 196 |
+
* reference to it (i.e. the one passed to this function). In all other cases
|
| 197 |
+
* a new buffer is allocated and the data is copied.
|
| 198 |
+
*/
|
| 199 |
+
int av_buffer_realloc(AVBufferRef **buf, size_t size);
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Ensure dst refers to the same data as src.
|
| 203 |
+
*
|
| 204 |
+
* When *dst is already equivalent to src, do nothing. Otherwise unreference dst
|
| 205 |
+
* and replace it with a new reference to src.
|
| 206 |
+
*
|
| 207 |
+
* @param dst Pointer to either a valid buffer reference or NULL. On success,
|
| 208 |
+
* this will point to a buffer reference equivalent to src. On
|
| 209 |
+
* failure, dst will be left untouched.
|
| 210 |
+
* @param src A buffer reference to replace dst with. May be NULL, then this
|
| 211 |
+
* function is equivalent to av_buffer_unref(dst).
|
| 212 |
+
* @return 0 on success
|
| 213 |
+
* AVERROR(ENOMEM) on memory allocation failure.
|
| 214 |
+
*/
|
| 215 |
+
int av_buffer_replace(AVBufferRef **dst, const AVBufferRef *src);
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* @}
|
| 219 |
+
*/
|
| 220 |
+
|
| 221 |
+
/**
|
| 222 |
+
* @defgroup lavu_bufferpool AVBufferPool
|
| 223 |
+
* @ingroup lavu_data
|
| 224 |
+
*
|
| 225 |
+
* @{
|
| 226 |
+
* AVBufferPool is an API for a lock-free thread-safe pool of AVBuffers.
|
| 227 |
+
*
|
| 228 |
+
* Frequently allocating and freeing large buffers may be slow. AVBufferPool is
|
| 229 |
+
* meant to solve this in cases when the caller needs a set of buffers of the
|
| 230 |
+
* same size (the most obvious use case being buffers for raw video or audio
|
| 231 |
+
* frames).
|
| 232 |
+
*
|
| 233 |
+
* At the beginning, the user must call av_buffer_pool_init() to create the
|
| 234 |
+
* buffer pool. Then whenever a buffer is needed, call av_buffer_pool_get() to
|
| 235 |
+
* get a reference to a new buffer, similar to av_buffer_alloc(). This new
|
| 236 |
+
* reference works in all aspects the same way as the one created by
|
| 237 |
+
* av_buffer_alloc(). However, when the last reference to this buffer is
|
| 238 |
+
* unreferenced, it is returned to the pool instead of being freed and will be
|
| 239 |
+
* reused for subsequent av_buffer_pool_get() calls.
|
| 240 |
+
*
|
| 241 |
+
* When the caller is done with the pool and no longer needs to allocate any new
|
| 242 |
+
* buffers, av_buffer_pool_uninit() must be called to mark the pool as freeable.
|
| 243 |
+
* Once all the buffers are released, it will automatically be freed.
|
| 244 |
+
*
|
| 245 |
+
* Allocating and releasing buffers with this API is thread-safe as long as
|
| 246 |
+
* either the default alloc callback is used, or the user-supplied one is
|
| 247 |
+
* thread-safe.
|
| 248 |
+
*/
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* The buffer pool. This structure is opaque and not meant to be accessed
|
| 252 |
+
* directly. It is allocated with av_buffer_pool_init() and freed with
|
| 253 |
+
* av_buffer_pool_uninit().
|
| 254 |
+
*/
|
| 255 |
+
typedef struct AVBufferPool AVBufferPool;
|
| 256 |
+
|
| 257 |
+
/**
|
| 258 |
+
* Allocate and initialize a buffer pool.
|
| 259 |
+
*
|
| 260 |
+
* @param size size of each buffer in this pool
|
| 261 |
+
* @param alloc a function that will be used to allocate new buffers when the
|
| 262 |
+
* pool is empty. May be NULL, then the default allocator will be used
|
| 263 |
+
* (av_buffer_alloc()).
|
| 264 |
+
* @return newly created buffer pool on success, NULL on error.
|
| 265 |
+
*/
|
| 266 |
+
AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size));
|
| 267 |
+
|
| 268 |
+
/**
|
| 269 |
+
* Allocate and initialize a buffer pool with a more complex allocator.
|
| 270 |
+
*
|
| 271 |
+
* @param size size of each buffer in this pool
|
| 272 |
+
* @param opaque arbitrary user data used by the allocator
|
| 273 |
+
* @param alloc a function that will be used to allocate new buffers when the
|
| 274 |
+
* pool is empty. May be NULL, then the default allocator will be
|
| 275 |
+
* used (av_buffer_alloc()).
|
| 276 |
+
* @param pool_free a function that will be called immediately before the pool
|
| 277 |
+
* is freed. I.e. after av_buffer_pool_uninit() is called
|
| 278 |
+
* by the caller and all the frames are returned to the pool
|
| 279 |
+
* and freed. It is intended to uninitialize the user opaque
|
| 280 |
+
* data. May be NULL.
|
| 281 |
+
* @return newly created buffer pool on success, NULL on error.
|
| 282 |
+
*/
|
| 283 |
+
AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque,
|
| 284 |
+
AVBufferRef* (*alloc)(void *opaque, size_t size),
|
| 285 |
+
void (*pool_free)(void *opaque));
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* Mark the pool as being available for freeing. It will actually be freed only
|
| 289 |
+
* once all the allocated buffers associated with the pool are released. Thus it
|
| 290 |
+
* is safe to call this function while some of the allocated buffers are still
|
| 291 |
+
* in use.
|
| 292 |
+
*
|
| 293 |
+
* @param pool pointer to the pool to be freed. It will be set to NULL.
|
| 294 |
+
*/
|
| 295 |
+
void av_buffer_pool_uninit(AVBufferPool **pool);
|
| 296 |
+
|
| 297 |
+
/**
|
| 298 |
+
* Allocate a new AVBuffer, reusing an old buffer from the pool when available.
|
| 299 |
+
* This function may be called simultaneously from multiple threads.
|
| 300 |
+
*
|
| 301 |
+
* @return a reference to the new buffer on success, NULL on error.
|
| 302 |
+
*/
|
| 303 |
+
AVBufferRef *av_buffer_pool_get(AVBufferPool *pool);
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* Query the original opaque parameter of an allocated buffer in the pool.
|
| 307 |
+
*
|
| 308 |
+
* @param ref a buffer reference to a buffer returned by av_buffer_pool_get.
|
| 309 |
+
* @return the opaque parameter set by the buffer allocator function of the
|
| 310 |
+
* buffer pool.
|
| 311 |
+
*
|
| 312 |
+
* @note the opaque parameter of ref is used by the buffer pool implementation,
|
| 313 |
+
* therefore you have to use this function to access the original opaque
|
| 314 |
+
* parameter of an allocated buffer.
|
| 315 |
+
*/
|
| 316 |
+
void *av_buffer_pool_buffer_get_opaque(const AVBufferRef *ref);
|
| 317 |
+
|
| 318 |
+
/**
|
| 319 |
+
* @}
|
| 320 |
+
*/
|
| 321 |
+
|
| 322 |
+
#endif /* AVUTIL_BUFFER_H */
|
ffmpeg/include/libavutil/camellia.h
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* An implementation of the CAMELLIA algorithm as mentioned in RFC3713
|
| 3 |
+
* Copyright (c) 2014 Supraja Meedinti
|
| 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 |
+
#ifndef AVUTIL_CAMELLIA_H
|
| 23 |
+
#define AVUTIL_CAMELLIA_H
|
| 24 |
+
|
| 25 |
+
#include <stdint.h>
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @file
|
| 30 |
+
* @brief Public header for libavutil CAMELLIA algorithm
|
| 31 |
+
* @defgroup lavu_camellia CAMELLIA
|
| 32 |
+
* @ingroup lavu_crypto
|
| 33 |
+
* @{
|
| 34 |
+
*/
|
| 35 |
+
|
| 36 |
+
extern const int av_camellia_size;
|
| 37 |
+
|
| 38 |
+
struct AVCAMELLIA;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Allocate an AVCAMELLIA context
|
| 42 |
+
* To free the struct: av_free(ptr)
|
| 43 |
+
*/
|
| 44 |
+
struct AVCAMELLIA *av_camellia_alloc(void);
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Initialize an AVCAMELLIA context.
|
| 48 |
+
*
|
| 49 |
+
* @param ctx an AVCAMELLIA context
|
| 50 |
+
* @param key a key of 16, 24, 32 bytes used for encryption/decryption
|
| 51 |
+
* @param key_bits number of keybits: possible are 128, 192, 256
|
| 52 |
+
*/
|
| 53 |
+
int av_camellia_init(struct AVCAMELLIA *ctx, const uint8_t *key, int key_bits);
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Encrypt or decrypt a buffer using a previously initialized context
|
| 57 |
+
*
|
| 58 |
+
* @param ctx an AVCAMELLIA context
|
| 59 |
+
* @param dst destination array, can be equal to src
|
| 60 |
+
* @param src source array, can be equal to dst
|
| 61 |
+
* @param count number of 16 byte blocks
|
| 62 |
+
* @param iv initialization vector for CBC mode, NULL for ECB mode
|
| 63 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 64 |
+
*/
|
| 65 |
+
void av_camellia_crypt(struct AVCAMELLIA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt);
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* @}
|
| 69 |
+
*/
|
| 70 |
+
#endif /* AVUTIL_CAMELLIA_H */
|
ffmpeg/include/libavutil/cast5.h
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* An implementation of the CAST128 algorithm as mentioned in RFC2144
|
| 3 |
+
* Copyright (c) 2014 Supraja Meedinti
|
| 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 |
+
#ifndef AVUTIL_CAST5_H
|
| 23 |
+
#define AVUTIL_CAST5_H
|
| 24 |
+
|
| 25 |
+
#include <stdint.h>
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @file
|
| 30 |
+
* @brief Public header for libavutil CAST5 algorithm
|
| 31 |
+
* @defgroup lavu_cast5 CAST5
|
| 32 |
+
* @ingroup lavu_crypto
|
| 33 |
+
* @{
|
| 34 |
+
*/
|
| 35 |
+
|
| 36 |
+
extern const int av_cast5_size;
|
| 37 |
+
|
| 38 |
+
struct AVCAST5;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Allocate an AVCAST5 context
|
| 42 |
+
* To free the struct: av_free(ptr)
|
| 43 |
+
*/
|
| 44 |
+
struct AVCAST5 *av_cast5_alloc(void);
|
| 45 |
+
/**
|
| 46 |
+
* Initialize an AVCAST5 context.
|
| 47 |
+
*
|
| 48 |
+
* @param ctx an AVCAST5 context
|
| 49 |
+
* @param key a key of 5,6,...16 bytes used for encryption/decryption
|
| 50 |
+
* @param key_bits number of keybits: possible are 40,48,...,128
|
| 51 |
+
* @return 0 on success, less than 0 on failure
|
| 52 |
+
*/
|
| 53 |
+
int av_cast5_init(struct AVCAST5 *ctx, const uint8_t *key, int key_bits);
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Encrypt or decrypt a buffer using a previously initialized context, ECB mode only
|
| 57 |
+
*
|
| 58 |
+
* @param ctx an AVCAST5 context
|
| 59 |
+
* @param dst destination array, can be equal to src
|
| 60 |
+
* @param src source array, can be equal to dst
|
| 61 |
+
* @param count number of 8 byte blocks
|
| 62 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 63 |
+
*/
|
| 64 |
+
void av_cast5_crypt(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, int decrypt);
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Encrypt or decrypt a buffer using a previously initialized context
|
| 68 |
+
*
|
| 69 |
+
* @param ctx an AVCAST5 context
|
| 70 |
+
* @param dst destination array, can be equal to src
|
| 71 |
+
* @param src source array, can be equal to dst
|
| 72 |
+
* @param count number of 8 byte blocks
|
| 73 |
+
* @param iv initialization vector for CBC mode, NULL for ECB mode
|
| 74 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 75 |
+
*/
|
| 76 |
+
void av_cast5_crypt2(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
| 77 |
+
/**
|
| 78 |
+
* @}
|
| 79 |
+
*/
|
| 80 |
+
#endif /* AVUTIL_CAST5_H */
|
ffmpeg/include/libavutil/channel_layout.h
ADDED
|
@@ -0,0 +1,762 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
* Copyright (c) 2008 Peter Ross
|
| 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 |
+
#ifndef AVUTIL_CHANNEL_LAYOUT_H
|
| 23 |
+
#define AVUTIL_CHANNEL_LAYOUT_H
|
| 24 |
+
|
| 25 |
+
#include <stdint.h>
|
| 26 |
+
#include <stdlib.h>
|
| 27 |
+
|
| 28 |
+
#include "version.h"
|
| 29 |
+
#include "attributes.h"
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @file
|
| 33 |
+
* @ingroup lavu_audio_channels
|
| 34 |
+
* Public libavutil channel layout APIs header.
|
| 35 |
+
*/
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* @defgroup lavu_audio_channels Audio channels
|
| 40 |
+
* @ingroup lavu_audio
|
| 41 |
+
*
|
| 42 |
+
* Audio channel layout utility functions
|
| 43 |
+
*
|
| 44 |
+
* @{
|
| 45 |
+
*/
|
| 46 |
+
|
| 47 |
+
enum AVChannel {
|
| 48 |
+
///< Invalid channel index
|
| 49 |
+
AV_CHAN_NONE = -1,
|
| 50 |
+
AV_CHAN_FRONT_LEFT,
|
| 51 |
+
AV_CHAN_FRONT_RIGHT,
|
| 52 |
+
AV_CHAN_FRONT_CENTER,
|
| 53 |
+
AV_CHAN_LOW_FREQUENCY,
|
| 54 |
+
AV_CHAN_BACK_LEFT,
|
| 55 |
+
AV_CHAN_BACK_RIGHT,
|
| 56 |
+
AV_CHAN_FRONT_LEFT_OF_CENTER,
|
| 57 |
+
AV_CHAN_FRONT_RIGHT_OF_CENTER,
|
| 58 |
+
AV_CHAN_BACK_CENTER,
|
| 59 |
+
AV_CHAN_SIDE_LEFT,
|
| 60 |
+
AV_CHAN_SIDE_RIGHT,
|
| 61 |
+
AV_CHAN_TOP_CENTER,
|
| 62 |
+
AV_CHAN_TOP_FRONT_LEFT,
|
| 63 |
+
AV_CHAN_TOP_FRONT_CENTER,
|
| 64 |
+
AV_CHAN_TOP_FRONT_RIGHT,
|
| 65 |
+
AV_CHAN_TOP_BACK_LEFT,
|
| 66 |
+
AV_CHAN_TOP_BACK_CENTER,
|
| 67 |
+
AV_CHAN_TOP_BACK_RIGHT,
|
| 68 |
+
/** Stereo downmix. */
|
| 69 |
+
AV_CHAN_STEREO_LEFT = 29,
|
| 70 |
+
/** See above. */
|
| 71 |
+
AV_CHAN_STEREO_RIGHT,
|
| 72 |
+
AV_CHAN_WIDE_LEFT,
|
| 73 |
+
AV_CHAN_WIDE_RIGHT,
|
| 74 |
+
AV_CHAN_SURROUND_DIRECT_LEFT,
|
| 75 |
+
AV_CHAN_SURROUND_DIRECT_RIGHT,
|
| 76 |
+
AV_CHAN_LOW_FREQUENCY_2,
|
| 77 |
+
AV_CHAN_TOP_SIDE_LEFT,
|
| 78 |
+
AV_CHAN_TOP_SIDE_RIGHT,
|
| 79 |
+
AV_CHAN_BOTTOM_FRONT_CENTER,
|
| 80 |
+
AV_CHAN_BOTTOM_FRONT_LEFT,
|
| 81 |
+
AV_CHAN_BOTTOM_FRONT_RIGHT,
|
| 82 |
+
AV_CHAN_SIDE_SURROUND_LEFT, ///< +90 degrees, Lss, SiL
|
| 83 |
+
AV_CHAN_SIDE_SURROUND_RIGHT, ///< -90 degrees, Rss, SiR
|
| 84 |
+
AV_CHAN_TOP_SURROUND_LEFT, ///< +110 degrees, Lvs, TpLS
|
| 85 |
+
AV_CHAN_TOP_SURROUND_RIGHT, ///< -110 degrees, Rvs, TpRS
|
| 86 |
+
|
| 87 |
+
AV_CHAN_BINAURAL_LEFT = 61,
|
| 88 |
+
AV_CHAN_BINAURAL_RIGHT,
|
| 89 |
+
|
| 90 |
+
/** Channel is empty can be safely skipped. */
|
| 91 |
+
AV_CHAN_UNUSED = 0x200,
|
| 92 |
+
|
| 93 |
+
/** Channel contains data, but its position is unknown. */
|
| 94 |
+
AV_CHAN_UNKNOWN = 0x300,
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Range of channels between AV_CHAN_AMBISONIC_BASE and
|
| 98 |
+
* AV_CHAN_AMBISONIC_END represent Ambisonic components using the ACN system.
|
| 99 |
+
*
|
| 100 |
+
* Given a channel id `<i>` between AV_CHAN_AMBISONIC_BASE and
|
| 101 |
+
* AV_CHAN_AMBISONIC_END (inclusive), the ACN index of the channel `<n>` is
|
| 102 |
+
* `<n> = <i> - AV_CHAN_AMBISONIC_BASE`.
|
| 103 |
+
*
|
| 104 |
+
* @note these values are only used for AV_CHANNEL_ORDER_CUSTOM channel
|
| 105 |
+
* orderings, the AV_CHANNEL_ORDER_AMBISONIC ordering orders the channels
|
| 106 |
+
* implicitly by their position in the stream.
|
| 107 |
+
*/
|
| 108 |
+
AV_CHAN_AMBISONIC_BASE = 0x400,
|
| 109 |
+
// leave space for 1024 ids, which correspond to maximum order-32 harmonics,
|
| 110 |
+
// which should be enough for the foreseeable use cases
|
| 111 |
+
AV_CHAN_AMBISONIC_END = 0x7ff,
|
| 112 |
+
};
|
| 113 |
+
|
| 114 |
+
enum AVChannelOrder {
|
| 115 |
+
/**
|
| 116 |
+
* Only the channel count is specified, without any further information
|
| 117 |
+
* about the channel order.
|
| 118 |
+
*/
|
| 119 |
+
AV_CHANNEL_ORDER_UNSPEC,
|
| 120 |
+
/**
|
| 121 |
+
* The native channel order, i.e. the channels are in the same order in
|
| 122 |
+
* which they are defined in the AVChannel enum. This supports up to 63
|
| 123 |
+
* different channels.
|
| 124 |
+
*/
|
| 125 |
+
AV_CHANNEL_ORDER_NATIVE,
|
| 126 |
+
/**
|
| 127 |
+
* The channel order does not correspond to any other predefined order and
|
| 128 |
+
* is stored as an explicit map. For example, this could be used to support
|
| 129 |
+
* layouts with 64 or more channels, or with empty/skipped (AV_CHAN_UNUSED)
|
| 130 |
+
* channels at arbitrary positions.
|
| 131 |
+
*/
|
| 132 |
+
AV_CHANNEL_ORDER_CUSTOM,
|
| 133 |
+
/**
|
| 134 |
+
* The audio is represented as the decomposition of the sound field into
|
| 135 |
+
* spherical harmonics. Each channel corresponds to a single expansion
|
| 136 |
+
* component. Channels are ordered according to ACN (Ambisonic Channel
|
| 137 |
+
* Number).
|
| 138 |
+
*
|
| 139 |
+
* The channel with the index n in the stream contains the spherical
|
| 140 |
+
* harmonic of degree l and order m given by
|
| 141 |
+
* @code{.unparsed}
|
| 142 |
+
* l = floor(sqrt(n)),
|
| 143 |
+
* m = n - l * (l + 1).
|
| 144 |
+
* @endcode
|
| 145 |
+
*
|
| 146 |
+
* Conversely given a spherical harmonic of degree l and order m, the
|
| 147 |
+
* corresponding channel index n is given by
|
| 148 |
+
* @code{.unparsed}
|
| 149 |
+
* n = l * (l + 1) + m.
|
| 150 |
+
* @endcode
|
| 151 |
+
*
|
| 152 |
+
* Normalization is assumed to be SN3D (Schmidt Semi-Normalization)
|
| 153 |
+
* as defined in AmbiX format $ 2.1.
|
| 154 |
+
*/
|
| 155 |
+
AV_CHANNEL_ORDER_AMBISONIC,
|
| 156 |
+
/**
|
| 157 |
+
* Number of channel orders, not part of ABI/API
|
| 158 |
+
*/
|
| 159 |
+
FF_CHANNEL_ORDER_NB
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* @defgroup channel_masks Audio channel masks
|
| 165 |
+
*
|
| 166 |
+
* A channel layout is a 64-bits integer with a bit set for every channel.
|
| 167 |
+
* The number of bits set must be equal to the number of channels.
|
| 168 |
+
* The value 0 means that the channel layout is not known.
|
| 169 |
+
* @note this data structure is not powerful enough to handle channels
|
| 170 |
+
* combinations that have the same channel multiple times, such as
|
| 171 |
+
* dual-mono.
|
| 172 |
+
*
|
| 173 |
+
* @{
|
| 174 |
+
*/
|
| 175 |
+
#define AV_CH_FRONT_LEFT (1ULL << AV_CHAN_FRONT_LEFT )
|
| 176 |
+
#define AV_CH_FRONT_RIGHT (1ULL << AV_CHAN_FRONT_RIGHT )
|
| 177 |
+
#define AV_CH_FRONT_CENTER (1ULL << AV_CHAN_FRONT_CENTER )
|
| 178 |
+
#define AV_CH_LOW_FREQUENCY (1ULL << AV_CHAN_LOW_FREQUENCY )
|
| 179 |
+
#define AV_CH_BACK_LEFT (1ULL << AV_CHAN_BACK_LEFT )
|
| 180 |
+
#define AV_CH_BACK_RIGHT (1ULL << AV_CHAN_BACK_RIGHT )
|
| 181 |
+
#define AV_CH_FRONT_LEFT_OF_CENTER (1ULL << AV_CHAN_FRONT_LEFT_OF_CENTER )
|
| 182 |
+
#define AV_CH_FRONT_RIGHT_OF_CENTER (1ULL << AV_CHAN_FRONT_RIGHT_OF_CENTER)
|
| 183 |
+
#define AV_CH_BACK_CENTER (1ULL << AV_CHAN_BACK_CENTER )
|
| 184 |
+
#define AV_CH_SIDE_LEFT (1ULL << AV_CHAN_SIDE_LEFT )
|
| 185 |
+
#define AV_CH_SIDE_RIGHT (1ULL << AV_CHAN_SIDE_RIGHT )
|
| 186 |
+
#define AV_CH_TOP_CENTER (1ULL << AV_CHAN_TOP_CENTER )
|
| 187 |
+
#define AV_CH_TOP_FRONT_LEFT (1ULL << AV_CHAN_TOP_FRONT_LEFT )
|
| 188 |
+
#define AV_CH_TOP_FRONT_CENTER (1ULL << AV_CHAN_TOP_FRONT_CENTER )
|
| 189 |
+
#define AV_CH_TOP_FRONT_RIGHT (1ULL << AV_CHAN_TOP_FRONT_RIGHT )
|
| 190 |
+
#define AV_CH_TOP_BACK_LEFT (1ULL << AV_CHAN_TOP_BACK_LEFT )
|
| 191 |
+
#define AV_CH_TOP_BACK_CENTER (1ULL << AV_CHAN_TOP_BACK_CENTER )
|
| 192 |
+
#define AV_CH_TOP_BACK_RIGHT (1ULL << AV_CHAN_TOP_BACK_RIGHT )
|
| 193 |
+
#define AV_CH_STEREO_LEFT (1ULL << AV_CHAN_STEREO_LEFT )
|
| 194 |
+
#define AV_CH_STEREO_RIGHT (1ULL << AV_CHAN_STEREO_RIGHT )
|
| 195 |
+
#define AV_CH_WIDE_LEFT (1ULL << AV_CHAN_WIDE_LEFT )
|
| 196 |
+
#define AV_CH_WIDE_RIGHT (1ULL << AV_CHAN_WIDE_RIGHT )
|
| 197 |
+
#define AV_CH_SURROUND_DIRECT_LEFT (1ULL << AV_CHAN_SURROUND_DIRECT_LEFT )
|
| 198 |
+
#define AV_CH_SURROUND_DIRECT_RIGHT (1ULL << AV_CHAN_SURROUND_DIRECT_RIGHT)
|
| 199 |
+
#define AV_CH_LOW_FREQUENCY_2 (1ULL << AV_CHAN_LOW_FREQUENCY_2 )
|
| 200 |
+
#define AV_CH_TOP_SIDE_LEFT (1ULL << AV_CHAN_TOP_SIDE_LEFT )
|
| 201 |
+
#define AV_CH_TOP_SIDE_RIGHT (1ULL << AV_CHAN_TOP_SIDE_RIGHT )
|
| 202 |
+
#define AV_CH_BOTTOM_FRONT_CENTER (1ULL << AV_CHAN_BOTTOM_FRONT_CENTER )
|
| 203 |
+
#define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT )
|
| 204 |
+
#define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT )
|
| 205 |
+
#define AV_CH_SIDE_SURROUND_LEFT (1ULL << AV_CHAN_SIDE_SURROUND_LEFT )
|
| 206 |
+
#define AV_CH_SIDE_SURROUND_RIGHT (1ULL << AV_CHAN_SIDE_SURROUND_RIGHT )
|
| 207 |
+
#define AV_CH_TOP_SURROUND_LEFT (1ULL << AV_CHAN_TOP_SURROUND_LEFT )
|
| 208 |
+
#define AV_CH_TOP_SURROUND_RIGHT (1ULL << AV_CHAN_TOP_SURROUND_RIGHT )
|
| 209 |
+
#define AV_CH_BINAURAL_LEFT (1ULL << AV_CHAN_BINAURAL_LEFT )
|
| 210 |
+
#define AV_CH_BINAURAL_RIGHT (1ULL << AV_CHAN_BINAURAL_RIGHT )
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* @}
|
| 214 |
+
* @defgroup channel_mask_c Audio channel layouts
|
| 215 |
+
* @{
|
| 216 |
+
* */
|
| 217 |
+
#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER)
|
| 218 |
+
#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
|
| 219 |
+
#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
|
| 220 |
+
#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
|
| 221 |
+
#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
|
| 222 |
+
#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
|
| 223 |
+
#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
|
| 224 |
+
#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
|
| 225 |
+
#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
| 226 |
+
#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
| 227 |
+
#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
| 228 |
+
#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
|
| 229 |
+
#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
| 230 |
+
#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
|
| 231 |
+
#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
|
| 232 |
+
#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
| 233 |
+
#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
|
| 234 |
+
#define AV_CH_LAYOUT_3POINT1POINT2 (AV_CH_LAYOUT_3POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
| 235 |
+
#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
|
| 236 |
+
#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
|
| 237 |
+
#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
|
| 238 |
+
#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
| 239 |
+
#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
| 240 |
+
#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
| 241 |
+
#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
| 242 |
+
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
| 243 |
+
#define AV_CH_LAYOUT_5POINT1POINT2 (AV_CH_LAYOUT_5POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
| 244 |
+
#define AV_CH_LAYOUT_5POINT1POINT2_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
| 245 |
+
#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
|
| 246 |
+
#define AV_CH_LAYOUT_CUBE (AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)
|
| 247 |
+
#define AV_CH_LAYOUT_5POINT1POINT4_BACK (AV_CH_LAYOUT_5POINT1POINT2|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)
|
| 248 |
+
#define AV_CH_LAYOUT_7POINT1POINT2 (AV_CH_LAYOUT_7POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
| 249 |
+
#define AV_CH_LAYOUT_7POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)
|
| 250 |
+
#define AV_CH_LAYOUT_7POINT2POINT3 (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_CENTER|AV_CH_LOW_FREQUENCY_2)
|
| 251 |
+
#define AV_CH_LAYOUT_9POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
| 252 |
+
#define AV_CH_LAYOUT_9POINT1POINT6 (AV_CH_LAYOUT_9POINT1POINT4_BACK|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT)
|
| 253 |
+
#define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
|
| 254 |
+
#define AV_CH_LAYOUT_BINAURAL (AV_CH_BINAURAL_LEFT|AV_CH_BINAURAL_RIGHT)
|
| 255 |
+
#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
|
| 256 |
+
#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_9POINT1POINT6|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
|
| 257 |
+
|
| 258 |
+
#define AV_CH_LAYOUT_7POINT1_TOP_BACK AV_CH_LAYOUT_5POINT1POINT2_BACK
|
| 259 |
+
|
| 260 |
+
enum AVMatrixEncoding {
|
| 261 |
+
AV_MATRIX_ENCODING_NONE,
|
| 262 |
+
AV_MATRIX_ENCODING_DOLBY,
|
| 263 |
+
AV_MATRIX_ENCODING_DPLII,
|
| 264 |
+
AV_MATRIX_ENCODING_DPLIIX,
|
| 265 |
+
AV_MATRIX_ENCODING_DPLIIZ,
|
| 266 |
+
AV_MATRIX_ENCODING_DOLBYEX,
|
| 267 |
+
AV_MATRIX_ENCODING_DOLBYHEADPHONE,
|
| 268 |
+
AV_MATRIX_ENCODING_NB
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
* @}
|
| 273 |
+
*/
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* An AVChannelCustom defines a single channel within a custom order layout
|
| 277 |
+
*
|
| 278 |
+
* Unlike most structures in FFmpeg, sizeof(AVChannelCustom) is a part of the
|
| 279 |
+
* public ABI.
|
| 280 |
+
*
|
| 281 |
+
* No new fields may be added to it without a major version bump.
|
| 282 |
+
*/
|
| 283 |
+
typedef struct AVChannelCustom {
|
| 284 |
+
enum AVChannel id;
|
| 285 |
+
char name[16];
|
| 286 |
+
void *opaque;
|
| 287 |
+
} AVChannelCustom;
|
| 288 |
+
|
| 289 |
+
/**
|
| 290 |
+
* An AVChannelLayout holds information about the channel layout of audio data.
|
| 291 |
+
*
|
| 292 |
+
* A channel layout here is defined as a set of channels ordered in a specific
|
| 293 |
+
* way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an
|
| 294 |
+
* AVChannelLayout carries only the channel count).
|
| 295 |
+
* All orders may be treated as if they were AV_CHANNEL_ORDER_UNSPEC by
|
| 296 |
+
* ignoring everything but the channel count, as long as av_channel_layout_check()
|
| 297 |
+
* considers they are valid.
|
| 298 |
+
*
|
| 299 |
+
* Unlike most structures in FFmpeg, sizeof(AVChannelLayout) is a part of the
|
| 300 |
+
* public ABI and may be used by the caller. E.g. it may be allocated on stack
|
| 301 |
+
* or embedded in caller-defined structs.
|
| 302 |
+
*
|
| 303 |
+
* AVChannelLayout can be initialized as follows:
|
| 304 |
+
* - default initialization with {0}, followed by setting all used fields
|
| 305 |
+
* correctly;
|
| 306 |
+
* - by assigning one of the predefined AV_CHANNEL_LAYOUT_* initializers;
|
| 307 |
+
* - with a constructor function, such as av_channel_layout_default(),
|
| 308 |
+
* av_channel_layout_from_mask() or av_channel_layout_from_string().
|
| 309 |
+
*
|
| 310 |
+
* The channel layout must be unitialized with av_channel_layout_uninit()
|
| 311 |
+
*
|
| 312 |
+
* Copying an AVChannelLayout via assigning is forbidden,
|
| 313 |
+
* av_channel_layout_copy() must be used instead (and its return value should
|
| 314 |
+
* be checked)
|
| 315 |
+
*
|
| 316 |
+
* No new fields may be added to it without a major version bump, except for
|
| 317 |
+
* new elements of the union fitting in sizeof(uint64_t).
|
| 318 |
+
*/
|
| 319 |
+
typedef struct AVChannelLayout {
|
| 320 |
+
/**
|
| 321 |
+
* Channel order used in this layout.
|
| 322 |
+
* This is a mandatory field.
|
| 323 |
+
*/
|
| 324 |
+
enum AVChannelOrder order;
|
| 325 |
+
|
| 326 |
+
/**
|
| 327 |
+
* Number of channels in this layout. Mandatory field.
|
| 328 |
+
*/
|
| 329 |
+
int nb_channels;
|
| 330 |
+
|
| 331 |
+
/**
|
| 332 |
+
* Details about which channels are present in this layout.
|
| 333 |
+
* For AV_CHANNEL_ORDER_UNSPEC, this field is undefined and must not be
|
| 334 |
+
* used.
|
| 335 |
+
*/
|
| 336 |
+
union {
|
| 337 |
+
/**
|
| 338 |
+
* This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used
|
| 339 |
+
* for AV_CHANNEL_ORDER_AMBISONIC to signal non-diegetic channels.
|
| 340 |
+
* It is a bitmask, where the position of each set bit means that the
|
| 341 |
+
* AVChannel with the corresponding value is present.
|
| 342 |
+
*
|
| 343 |
+
* I.e. when (mask & (1 << AV_CHAN_FOO)) is non-zero, then AV_CHAN_FOO
|
| 344 |
+
* is present in the layout. Otherwise it is not present.
|
| 345 |
+
*
|
| 346 |
+
* @note when a channel layout using a bitmask is constructed or
|
| 347 |
+
* modified manually (i.e. not using any of the av_channel_layout_*
|
| 348 |
+
* functions), the code doing it must ensure that the number of set bits
|
| 349 |
+
* is equal to nb_channels.
|
| 350 |
+
*/
|
| 351 |
+
uint64_t mask;
|
| 352 |
+
/**
|
| 353 |
+
* This member must be used when the channel order is
|
| 354 |
+
* AV_CHANNEL_ORDER_CUSTOM. It is a nb_channels-sized array, with each
|
| 355 |
+
* element signalling the presence of the AVChannel with the
|
| 356 |
+
* corresponding value in map[i].id.
|
| 357 |
+
*
|
| 358 |
+
* I.e. when map[i].id is equal to AV_CHAN_FOO, then AV_CH_FOO is the
|
| 359 |
+
* i-th channel in the audio data.
|
| 360 |
+
*
|
| 361 |
+
* When map[i].id is in the range between AV_CHAN_AMBISONIC_BASE and
|
| 362 |
+
* AV_CHAN_AMBISONIC_END (inclusive), the channel contains an ambisonic
|
| 363 |
+
* component with ACN index (as defined above)
|
| 364 |
+
* n = map[i].id - AV_CHAN_AMBISONIC_BASE.
|
| 365 |
+
*
|
| 366 |
+
* map[i].name may be filled with a 0-terminated string, in which case
|
| 367 |
+
* it will be used for the purpose of identifying the channel with the
|
| 368 |
+
* convenience functions below. Otherise it must be zeroed.
|
| 369 |
+
*/
|
| 370 |
+
AVChannelCustom *map;
|
| 371 |
+
} u;
|
| 372 |
+
|
| 373 |
+
/**
|
| 374 |
+
* For some private data of the user.
|
| 375 |
+
*/
|
| 376 |
+
void *opaque;
|
| 377 |
+
} AVChannelLayout;
|
| 378 |
+
|
| 379 |
+
/**
|
| 380 |
+
* Macro to define native channel layouts
|
| 381 |
+
*
|
| 382 |
+
* @note This doesn't use designated initializers for compatibility with C++ 17 and older.
|
| 383 |
+
*/
|
| 384 |
+
#define AV_CHANNEL_LAYOUT_MASK(nb, m) \
|
| 385 |
+
{ /* .order */ AV_CHANNEL_ORDER_NATIVE, \
|
| 386 |
+
/* .nb_channels */ (nb), \
|
| 387 |
+
/* .u.mask */ { m }, \
|
| 388 |
+
/* .opaque */ NULL }
|
| 389 |
+
|
| 390 |
+
/**
|
| 391 |
+
* @name Common pre-defined channel layouts
|
| 392 |
+
* @{
|
| 393 |
+
*/
|
| 394 |
+
#define AV_CHANNEL_LAYOUT_MONO AV_CHANNEL_LAYOUT_MASK(1, AV_CH_LAYOUT_MONO)
|
| 395 |
+
#define AV_CHANNEL_LAYOUT_STEREO AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO)
|
| 396 |
+
#define AV_CHANNEL_LAYOUT_2POINT1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2POINT1)
|
| 397 |
+
#define AV_CHANNEL_LAYOUT_2_1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2_1)
|
| 398 |
+
#define AV_CHANNEL_LAYOUT_SURROUND AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_SURROUND)
|
| 399 |
+
#define AV_CHANNEL_LAYOUT_3POINT1 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_3POINT1)
|
| 400 |
+
#define AV_CHANNEL_LAYOUT_4POINT0 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_4POINT0)
|
| 401 |
+
#define AV_CHANNEL_LAYOUT_4POINT1 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_4POINT1)
|
| 402 |
+
#define AV_CHANNEL_LAYOUT_2_2 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_2_2)
|
| 403 |
+
#define AV_CHANNEL_LAYOUT_QUAD AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_QUAD)
|
| 404 |
+
#define AV_CHANNEL_LAYOUT_5POINT0 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0)
|
| 405 |
+
#define AV_CHANNEL_LAYOUT_5POINT1 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1)
|
| 406 |
+
#define AV_CHANNEL_LAYOUT_5POINT0_BACK AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0_BACK)
|
| 407 |
+
#define AV_CHANNEL_LAYOUT_5POINT1_BACK AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1_BACK)
|
| 408 |
+
#define AV_CHANNEL_LAYOUT_6POINT0 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0)
|
| 409 |
+
#define AV_CHANNEL_LAYOUT_6POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0_FRONT)
|
| 410 |
+
#define AV_CHANNEL_LAYOUT_3POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_3POINT1POINT2)
|
| 411 |
+
#define AV_CHANNEL_LAYOUT_HEXAGONAL AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_HEXAGONAL)
|
| 412 |
+
#define AV_CHANNEL_LAYOUT_6POINT1 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1)
|
| 413 |
+
#define AV_CHANNEL_LAYOUT_6POINT1_BACK AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_BACK)
|
| 414 |
+
#define AV_CHANNEL_LAYOUT_6POINT1_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_FRONT)
|
| 415 |
+
#define AV_CHANNEL_LAYOUT_7POINT0 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0)
|
| 416 |
+
#define AV_CHANNEL_LAYOUT_7POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0_FRONT)
|
| 417 |
+
#define AV_CHANNEL_LAYOUT_7POINT1 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1)
|
| 418 |
+
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE)
|
| 419 |
+
#define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE_BACK)
|
| 420 |
+
#define AV_CHANNEL_LAYOUT_5POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_5POINT1POINT2)
|
| 421 |
+
#define AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_5POINT1POINT2_BACK)
|
| 422 |
+
#define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL)
|
| 423 |
+
#define AV_CHANNEL_LAYOUT_CUBE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_CUBE)
|
| 424 |
+
#define AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_5POINT1POINT4_BACK)
|
| 425 |
+
#define AV_CHANNEL_LAYOUT_7POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(10, AV_CH_LAYOUT_7POINT1POINT2)
|
| 426 |
+
#define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT1POINT4_BACK)
|
| 427 |
+
#define AV_CHANNEL_LAYOUT_7POINT2POINT3 AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT2POINT3)
|
| 428 |
+
#define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(14, AV_CH_LAYOUT_9POINT1POINT4_BACK)
|
| 429 |
+
#define AV_CHANNEL_LAYOUT_9POINT1POINT6 AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_9POINT1POINT6)
|
| 430 |
+
#define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL)
|
| 431 |
+
#define AV_CHANNEL_LAYOUT_BINAURAL AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_BINAURAL)
|
| 432 |
+
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO_DOWNMIX)
|
| 433 |
+
#define AV_CHANNEL_LAYOUT_22POINT2 AV_CHANNEL_LAYOUT_MASK(24, AV_CH_LAYOUT_22POINT2)
|
| 434 |
+
|
| 435 |
+
#define AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK
|
| 436 |
+
|
| 437 |
+
#define AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER \
|
| 438 |
+
{ /* .order */ AV_CHANNEL_ORDER_AMBISONIC, \
|
| 439 |
+
/* .nb_channels */ 4, \
|
| 440 |
+
/* .u.mask */ { 0 }, \
|
| 441 |
+
/* .opaque */ NULL }
|
| 442 |
+
/** @} */
|
| 443 |
+
|
| 444 |
+
struct AVBPrint;
|
| 445 |
+
|
| 446 |
+
/**
|
| 447 |
+
* Get a human readable string in an abbreviated form describing a given channel.
|
| 448 |
+
* This is the inverse function of @ref av_channel_from_string().
|
| 449 |
+
*
|
| 450 |
+
* @param buf pre-allocated buffer where to put the generated string
|
| 451 |
+
* @param buf_size size in bytes of the buffer.
|
| 452 |
+
* @param channel the AVChannel whose name to get
|
| 453 |
+
* @return amount of bytes needed to hold the output string, or a negative AVERROR
|
| 454 |
+
* on failure. If the returned value is bigger than buf_size, then the
|
| 455 |
+
* string was truncated.
|
| 456 |
+
*/
|
| 457 |
+
int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel);
|
| 458 |
+
|
| 459 |
+
/**
|
| 460 |
+
* bprint variant of av_channel_name().
|
| 461 |
+
*
|
| 462 |
+
* @note the string will be appended to the bprint buffer.
|
| 463 |
+
*/
|
| 464 |
+
void av_channel_name_bprint(struct AVBPrint *bp, enum AVChannel channel_id);
|
| 465 |
+
|
| 466 |
+
/**
|
| 467 |
+
* Get a human readable string describing a given channel.
|
| 468 |
+
*
|
| 469 |
+
* @param buf pre-allocated buffer where to put the generated string
|
| 470 |
+
* @param buf_size size in bytes of the buffer.
|
| 471 |
+
* @param channel the AVChannel whose description to get
|
| 472 |
+
* @return amount of bytes needed to hold the output string, or a negative AVERROR
|
| 473 |
+
* on failure. If the returned value is bigger than buf_size, then the
|
| 474 |
+
* string was truncated.
|
| 475 |
+
*/
|
| 476 |
+
int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel);
|
| 477 |
+
|
| 478 |
+
/**
|
| 479 |
+
* bprint variant of av_channel_description().
|
| 480 |
+
*
|
| 481 |
+
* @note the string will be appended to the bprint buffer.
|
| 482 |
+
*/
|
| 483 |
+
void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_id);
|
| 484 |
+
|
| 485 |
+
/**
|
| 486 |
+
* This is the inverse function of @ref av_channel_name().
|
| 487 |
+
*
|
| 488 |
+
* @return the channel with the given name
|
| 489 |
+
* AV_CHAN_NONE when name does not identify a known channel
|
| 490 |
+
*/
|
| 491 |
+
enum AVChannel av_channel_from_string(const char *name);
|
| 492 |
+
|
| 493 |
+
/**
|
| 494 |
+
* Initialize a custom channel layout with the specified number of channels.
|
| 495 |
+
* The channel map will be allocated and the designation of all channels will
|
| 496 |
+
* be set to AV_CHAN_UNKNOWN.
|
| 497 |
+
*
|
| 498 |
+
* This is only a convenience helper function, a custom channel layout can also
|
| 499 |
+
* be constructed without using this.
|
| 500 |
+
*
|
| 501 |
+
* @param channel_layout the layout structure to be initialized
|
| 502 |
+
* @param nb_channels the number of channels
|
| 503 |
+
*
|
| 504 |
+
* @return 0 on success
|
| 505 |
+
* AVERROR(EINVAL) if the number of channels <= 0
|
| 506 |
+
* AVERROR(ENOMEM) if the channel map could not be allocated
|
| 507 |
+
*/
|
| 508 |
+
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels);
|
| 509 |
+
|
| 510 |
+
/**
|
| 511 |
+
* Initialize a native channel layout from a bitmask indicating which channels
|
| 512 |
+
* are present.
|
| 513 |
+
*
|
| 514 |
+
* @param channel_layout the layout structure to be initialized
|
| 515 |
+
* @param mask bitmask describing the channel layout
|
| 516 |
+
*
|
| 517 |
+
* @return 0 on success
|
| 518 |
+
* AVERROR(EINVAL) for invalid mask values
|
| 519 |
+
*/
|
| 520 |
+
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask);
|
| 521 |
+
|
| 522 |
+
/**
|
| 523 |
+
* Initialize a channel layout from a given string description.
|
| 524 |
+
* The input string can be represented by:
|
| 525 |
+
* - the formal channel layout name (returned by av_channel_layout_describe())
|
| 526 |
+
* - single or multiple channel names (returned by av_channel_name(), eg. "FL",
|
| 527 |
+
* or concatenated with "+", each optionally containing a custom name after
|
| 528 |
+
* a "@", eg. "FL@Left+FR@Right+LFE")
|
| 529 |
+
* - a decimal or hexadecimal value of a native channel layout (eg. "4" or "0x4")
|
| 530 |
+
* - the number of channels with default layout (eg. "4c")
|
| 531 |
+
* - the number of unordered channels (eg. "4C" or "4 channels")
|
| 532 |
+
* - the ambisonic order followed by optional non-diegetic channels (eg.
|
| 533 |
+
* "ambisonic 2+stereo")
|
| 534 |
+
* On error, the channel layout will remain uninitialized, but not necessarily
|
| 535 |
+
* untouched.
|
| 536 |
+
*
|
| 537 |
+
* @param channel_layout uninitialized channel layout for the result
|
| 538 |
+
* @param str string describing the channel layout
|
| 539 |
+
* @return 0 on success parsing the channel layout
|
| 540 |
+
* AVERROR(EINVAL) if an invalid channel layout string was provided
|
| 541 |
+
* AVERROR(ENOMEM) if there was not enough memory
|
| 542 |
+
*/
|
| 543 |
+
int av_channel_layout_from_string(AVChannelLayout *channel_layout,
|
| 544 |
+
const char *str);
|
| 545 |
+
|
| 546 |
+
/**
|
| 547 |
+
* Get the default channel layout for a given number of channels.
|
| 548 |
+
*
|
| 549 |
+
* @param ch_layout the layout structure to be initialized
|
| 550 |
+
* @param nb_channels number of channels
|
| 551 |
+
*/
|
| 552 |
+
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels);
|
| 553 |
+
|
| 554 |
+
/**
|
| 555 |
+
* Iterate over all standard channel layouts.
|
| 556 |
+
*
|
| 557 |
+
* @param opaque a pointer where libavutil will store the iteration state. Must
|
| 558 |
+
* point to NULL to start the iteration.
|
| 559 |
+
*
|
| 560 |
+
* @return the standard channel layout or NULL when the iteration is
|
| 561 |
+
* finished
|
| 562 |
+
*/
|
| 563 |
+
const AVChannelLayout *av_channel_layout_standard(void **opaque);
|
| 564 |
+
|
| 565 |
+
/**
|
| 566 |
+
* Free any allocated data in the channel layout and reset the channel
|
| 567 |
+
* count to 0.
|
| 568 |
+
*
|
| 569 |
+
* @param channel_layout the layout structure to be uninitialized
|
| 570 |
+
*/
|
| 571 |
+
void av_channel_layout_uninit(AVChannelLayout *channel_layout);
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Make a copy of a channel layout. This differs from just assigning src to dst
|
| 575 |
+
* in that it allocates and copies the map for AV_CHANNEL_ORDER_CUSTOM.
|
| 576 |
+
*
|
| 577 |
+
* @note the destination channel_layout will be always uninitialized before copy.
|
| 578 |
+
*
|
| 579 |
+
* @param dst destination channel layout
|
| 580 |
+
* @param src source channel layout
|
| 581 |
+
* @return 0 on success, a negative AVERROR on error.
|
| 582 |
+
*/
|
| 583 |
+
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src);
|
| 584 |
+
|
| 585 |
+
/**
|
| 586 |
+
* Get a human-readable string describing the channel layout properties.
|
| 587 |
+
* The string will be in the same format that is accepted by
|
| 588 |
+
* @ref av_channel_layout_from_string(), allowing to rebuild the same
|
| 589 |
+
* channel layout, except for opaque pointers.
|
| 590 |
+
*
|
| 591 |
+
* @param channel_layout channel layout to be described
|
| 592 |
+
* @param buf pre-allocated buffer where to put the generated string
|
| 593 |
+
* @param buf_size size in bytes of the buffer.
|
| 594 |
+
* @return amount of bytes needed to hold the output string, or a negative AVERROR
|
| 595 |
+
* on failure. If the returned value is bigger than buf_size, then the
|
| 596 |
+
* string was truncated.
|
| 597 |
+
*/
|
| 598 |
+
int av_channel_layout_describe(const AVChannelLayout *channel_layout,
|
| 599 |
+
char *buf, size_t buf_size);
|
| 600 |
+
|
| 601 |
+
/**
|
| 602 |
+
* bprint variant of av_channel_layout_describe().
|
| 603 |
+
*
|
| 604 |
+
* @note the string will be appended to the bprint buffer.
|
| 605 |
+
* @return 0 on success, or a negative AVERROR value on failure.
|
| 606 |
+
*/
|
| 607 |
+
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout,
|
| 608 |
+
struct AVBPrint *bp);
|
| 609 |
+
|
| 610 |
+
/**
|
| 611 |
+
* Get the channel with the given index in a channel layout.
|
| 612 |
+
*
|
| 613 |
+
* @param channel_layout input channel layout
|
| 614 |
+
* @param idx index of the channel
|
| 615 |
+
* @return channel with the index idx in channel_layout on success or
|
| 616 |
+
* AV_CHAN_NONE on failure (if idx is not valid or the channel order is
|
| 617 |
+
* unspecified)
|
| 618 |
+
*/
|
| 619 |
+
enum AVChannel
|
| 620 |
+
av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx);
|
| 621 |
+
|
| 622 |
+
/**
|
| 623 |
+
* Get the index of a given channel in a channel layout. In case multiple
|
| 624 |
+
* channels are found, only the first match will be returned.
|
| 625 |
+
*
|
| 626 |
+
* @param channel_layout input channel layout
|
| 627 |
+
* @param channel the channel whose index to obtain
|
| 628 |
+
* @return index of channel in channel_layout on success or a negative number if
|
| 629 |
+
* channel is not present in channel_layout.
|
| 630 |
+
*/
|
| 631 |
+
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout,
|
| 632 |
+
enum AVChannel channel);
|
| 633 |
+
|
| 634 |
+
/**
|
| 635 |
+
* Get the index in a channel layout of a channel described by the given string.
|
| 636 |
+
* In case multiple channels are found, only the first match will be returned.
|
| 637 |
+
*
|
| 638 |
+
* This function accepts channel names in the same format as
|
| 639 |
+
* @ref av_channel_from_string().
|
| 640 |
+
*
|
| 641 |
+
* @param channel_layout input channel layout
|
| 642 |
+
* @param name string describing the channel whose index to obtain
|
| 643 |
+
* @return a channel index described by the given string, or a negative AVERROR
|
| 644 |
+
* value.
|
| 645 |
+
*/
|
| 646 |
+
int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout,
|
| 647 |
+
const char *name);
|
| 648 |
+
|
| 649 |
+
/**
|
| 650 |
+
* Get a channel described by the given string.
|
| 651 |
+
*
|
| 652 |
+
* This function accepts channel names in the same format as
|
| 653 |
+
* @ref av_channel_from_string().
|
| 654 |
+
*
|
| 655 |
+
* @param channel_layout input channel layout
|
| 656 |
+
* @param name string describing the channel to obtain
|
| 657 |
+
* @return a channel described by the given string in channel_layout on success
|
| 658 |
+
* or AV_CHAN_NONE on failure (if the string is not valid or the channel
|
| 659 |
+
* order is unspecified)
|
| 660 |
+
*/
|
| 661 |
+
enum AVChannel
|
| 662 |
+
av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout,
|
| 663 |
+
const char *name);
|
| 664 |
+
|
| 665 |
+
/**
|
| 666 |
+
* Find out what channels from a given set are present in a channel layout,
|
| 667 |
+
* without regard for their positions.
|
| 668 |
+
*
|
| 669 |
+
* @param channel_layout input channel layout
|
| 670 |
+
* @param mask a combination of AV_CH_* representing a set of channels
|
| 671 |
+
* @return a bitfield representing all the channels from mask that are present
|
| 672 |
+
* in channel_layout
|
| 673 |
+
*/
|
| 674 |
+
uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout,
|
| 675 |
+
uint64_t mask);
|
| 676 |
+
|
| 677 |
+
/**
|
| 678 |
+
* Check whether a channel layout is valid, i.e. can possibly describe audio
|
| 679 |
+
* data.
|
| 680 |
+
*
|
| 681 |
+
* @param channel_layout input channel layout
|
| 682 |
+
* @return 1 if channel_layout is valid, 0 otherwise.
|
| 683 |
+
*/
|
| 684 |
+
int av_channel_layout_check(const AVChannelLayout *channel_layout);
|
| 685 |
+
|
| 686 |
+
/**
|
| 687 |
+
* Check whether two channel layouts are semantically the same, i.e. the same
|
| 688 |
+
* channels are present on the same positions in both.
|
| 689 |
+
*
|
| 690 |
+
* If one of the channel layouts is AV_CHANNEL_ORDER_UNSPEC, while the other is
|
| 691 |
+
* not, they are considered to be unequal. If both are AV_CHANNEL_ORDER_UNSPEC,
|
| 692 |
+
* they are considered equal iff the channel counts are the same in both.
|
| 693 |
+
*
|
| 694 |
+
* @param chl input channel layout
|
| 695 |
+
* @param chl1 input channel layout
|
| 696 |
+
* @return 0 if chl and chl1 are equal, 1 if they are not equal. A negative
|
| 697 |
+
* AVERROR code if one or both are invalid.
|
| 698 |
+
*/
|
| 699 |
+
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1);
|
| 700 |
+
|
| 701 |
+
/**
|
| 702 |
+
* Return the order if the layout is n-th order standard-order ambisonic.
|
| 703 |
+
* The presence of optional extra non-diegetic channels at the end is not taken
|
| 704 |
+
* into account.
|
| 705 |
+
*
|
| 706 |
+
* @param channel_layout input channel layout
|
| 707 |
+
* @return the order of the layout, a negative error code otherwise.
|
| 708 |
+
*/
|
| 709 |
+
int av_channel_layout_ambisonic_order(const AVChannelLayout *channel_layout);
|
| 710 |
+
|
| 711 |
+
/**
|
| 712 |
+
* The conversion must be lossless.
|
| 713 |
+
*/
|
| 714 |
+
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS (1 << 0)
|
| 715 |
+
|
| 716 |
+
/**
|
| 717 |
+
* The specified retype target order is ignored and the simplest possible
|
| 718 |
+
* (canonical) order is used for which the input layout can be losslessy
|
| 719 |
+
* represented.
|
| 720 |
+
*/
|
| 721 |
+
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL (1 << 1)
|
| 722 |
+
|
| 723 |
+
/**
|
| 724 |
+
* Change the AVChannelOrder of a channel layout.
|
| 725 |
+
*
|
| 726 |
+
* Change of AVChannelOrder can be either lossless or lossy. In case of a
|
| 727 |
+
* lossless conversion all the channel designations and the associated channel
|
| 728 |
+
* names (if any) are kept. On a lossy conversion the channel names and channel
|
| 729 |
+
* designations might be lost depending on the capabilities of the desired
|
| 730 |
+
* AVChannelOrder. Note that some conversions are simply not possible in which
|
| 731 |
+
* case this function returns AVERROR(ENOSYS).
|
| 732 |
+
*
|
| 733 |
+
* The following conversions are supported:
|
| 734 |
+
*
|
| 735 |
+
* Any -> Custom : Always possible, always lossless.
|
| 736 |
+
* Any -> Unspecified: Always possible, lossless if channel designations
|
| 737 |
+
* are all unknown and channel names are not used, lossy otherwise.
|
| 738 |
+
* Custom -> Ambisonic : Possible if it contains ambisonic channels with
|
| 739 |
+
* optional non-diegetic channels in the end. Lossy if the channels have
|
| 740 |
+
* custom names, lossless otherwise.
|
| 741 |
+
* Custom -> Native : Possible if it contains native channels in native
|
| 742 |
+
* order. Lossy if the channels have custom names, lossless otherwise.
|
| 743 |
+
*
|
| 744 |
+
* On error this function keeps the original channel layout untouched.
|
| 745 |
+
*
|
| 746 |
+
* @param channel_layout channel layout which will be changed
|
| 747 |
+
* @param order the desired channel layout order
|
| 748 |
+
* @param flags a combination of AV_CHANNEL_LAYOUT_RETYPE_FLAG_* constants
|
| 749 |
+
* @return 0 if the conversion was successful and lossless or if the channel
|
| 750 |
+
* layout was already in the desired order
|
| 751 |
+
* >0 if the conversion was successful but lossy
|
| 752 |
+
* AVERROR(ENOSYS) if the conversion was not possible (or would be
|
| 753 |
+
* lossy and AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS was specified)
|
| 754 |
+
* AVERROR(EINVAL), AVERROR(ENOMEM) on error
|
| 755 |
+
*/
|
| 756 |
+
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags);
|
| 757 |
+
|
| 758 |
+
/**
|
| 759 |
+
* @}
|
| 760 |
+
*/
|
| 761 |
+
|
| 762 |
+
#endif /* AVUTIL_CHANNEL_LAYOUT_H */
|
ffmpeg/include/libavutil/common.h
ADDED
|
@@ -0,0 +1,589 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* common internal and external API header
|
| 24 |
+
*/
|
| 25 |
+
|
| 26 |
+
#ifndef AVUTIL_COMMON_H
|
| 27 |
+
#define AVUTIL_COMMON_H
|
| 28 |
+
|
| 29 |
+
#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) && !defined(UINT64_C)
|
| 30 |
+
#error missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
|
| 31 |
+
#endif
|
| 32 |
+
|
| 33 |
+
#include <errno.h>
|
| 34 |
+
#include <inttypes.h>
|
| 35 |
+
#include <limits.h>
|
| 36 |
+
#include <math.h>
|
| 37 |
+
#include <stdint.h>
|
| 38 |
+
#include <stdio.h>
|
| 39 |
+
#include <stdlib.h>
|
| 40 |
+
#include <string.h>
|
| 41 |
+
|
| 42 |
+
#include "attributes.h"
|
| 43 |
+
#include "error.h"
|
| 44 |
+
#include "macros.h"
|
| 45 |
+
#include "version.h"
|
| 46 |
+
|
| 47 |
+
#ifdef HAVE_AV_CONFIG_H
|
| 48 |
+
# include "config.h"
|
| 49 |
+
# include "intmath.h"
|
| 50 |
+
# include "internal.h"
|
| 51 |
+
#else
|
| 52 |
+
# include "mem.h"
|
| 53 |
+
#endif /* HAVE_AV_CONFIG_H */
|
| 54 |
+
|
| 55 |
+
//rounded division & shift
|
| 56 |
+
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
|
| 57 |
+
/* assume b>0 */
|
| 58 |
+
#define ROUNDED_DIV(a,b) (((a)>=0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
|
| 59 |
+
/* Fast a/(1<<b) rounded toward +inf. Assume a>=0 and b>=0 */
|
| 60 |
+
#define AV_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) \
|
| 61 |
+
: ((a) + (1<<(b)) - 1) >> (b))
|
| 62 |
+
/* Backwards compat. */
|
| 63 |
+
#define FF_CEIL_RSHIFT AV_CEIL_RSHIFT
|
| 64 |
+
|
| 65 |
+
#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
|
| 66 |
+
#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they
|
| 70 |
+
* are not representable as absolute values of their type. This is the same
|
| 71 |
+
* as with *abs()
|
| 72 |
+
* @see FFNABS()
|
| 73 |
+
*/
|
| 74 |
+
#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
|
| 75 |
+
#define FFSIGN(a) ((a) > 0 ? 1 : -1)
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Negative Absolute value.
|
| 79 |
+
* this works for all integers of all types.
|
| 80 |
+
* As with many macros, this evaluates its argument twice, it thus must not have
|
| 81 |
+
* a sideeffect, that is FFNABS(x++) has undefined behavior.
|
| 82 |
+
*/
|
| 83 |
+
#define FFNABS(a) ((a) <= 0 ? (a) : (-(a)))
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Unsigned Absolute value.
|
| 87 |
+
* This takes the absolute value of a signed int and returns it as a unsigned.
|
| 88 |
+
* This also works with INT_MIN which would otherwise not be representable
|
| 89 |
+
* As with many macros, this evaluates its argument twice.
|
| 90 |
+
*/
|
| 91 |
+
#define FFABSU(a) ((a) <= 0 ? -(unsigned)(a) : (unsigned)(a))
|
| 92 |
+
#define FFABS64U(a) ((a) <= 0 ? -(uint64_t)(a) : (uint64_t)(a))
|
| 93 |
+
|
| 94 |
+
/* misc math functions */
|
| 95 |
+
|
| 96 |
+
#ifndef av_ceil_log2
|
| 97 |
+
# define av_ceil_log2 av_ceil_log2_c
|
| 98 |
+
#endif
|
| 99 |
+
#ifndef av_clip
|
| 100 |
+
# define av_clip av_clip_c
|
| 101 |
+
#endif
|
| 102 |
+
#ifndef av_clip64
|
| 103 |
+
# define av_clip64 av_clip64_c
|
| 104 |
+
#endif
|
| 105 |
+
#ifndef av_clip_uint8
|
| 106 |
+
# define av_clip_uint8 av_clip_uint8_c
|
| 107 |
+
#endif
|
| 108 |
+
#ifndef av_clip_int8
|
| 109 |
+
# define av_clip_int8 av_clip_int8_c
|
| 110 |
+
#endif
|
| 111 |
+
#ifndef av_clip_uint16
|
| 112 |
+
# define av_clip_uint16 av_clip_uint16_c
|
| 113 |
+
#endif
|
| 114 |
+
#ifndef av_clip_int16
|
| 115 |
+
# define av_clip_int16 av_clip_int16_c
|
| 116 |
+
#endif
|
| 117 |
+
#ifndef av_clipl_int32
|
| 118 |
+
# define av_clipl_int32 av_clipl_int32_c
|
| 119 |
+
#endif
|
| 120 |
+
#ifndef av_clip_intp2
|
| 121 |
+
# define av_clip_intp2 av_clip_intp2_c
|
| 122 |
+
#endif
|
| 123 |
+
#ifndef av_clip_uintp2
|
| 124 |
+
# define av_clip_uintp2 av_clip_uintp2_c
|
| 125 |
+
#endif
|
| 126 |
+
#ifndef av_sat_add32
|
| 127 |
+
# define av_sat_add32 av_sat_add32_c
|
| 128 |
+
#endif
|
| 129 |
+
#ifndef av_sat_dadd32
|
| 130 |
+
# define av_sat_dadd32 av_sat_dadd32_c
|
| 131 |
+
#endif
|
| 132 |
+
#ifndef av_sat_sub32
|
| 133 |
+
# define av_sat_sub32 av_sat_sub32_c
|
| 134 |
+
#endif
|
| 135 |
+
#ifndef av_sat_dsub32
|
| 136 |
+
# define av_sat_dsub32 av_sat_dsub32_c
|
| 137 |
+
#endif
|
| 138 |
+
#ifndef av_sat_add64
|
| 139 |
+
# define av_sat_add64 av_sat_add64_c
|
| 140 |
+
#endif
|
| 141 |
+
#ifndef av_sat_sub64
|
| 142 |
+
# define av_sat_sub64 av_sat_sub64_c
|
| 143 |
+
#endif
|
| 144 |
+
#ifndef av_clipf
|
| 145 |
+
# define av_clipf av_clipf_c
|
| 146 |
+
#endif
|
| 147 |
+
#ifndef av_clipd
|
| 148 |
+
# define av_clipd av_clipd_c
|
| 149 |
+
#endif
|
| 150 |
+
#ifndef av_zero_extend
|
| 151 |
+
# define av_zero_extend av_zero_extend_c
|
| 152 |
+
#endif
|
| 153 |
+
#ifndef av_popcount
|
| 154 |
+
# define av_popcount av_popcount_c
|
| 155 |
+
#endif
|
| 156 |
+
#ifndef av_popcount64
|
| 157 |
+
# define av_popcount64 av_popcount64_c
|
| 158 |
+
#endif
|
| 159 |
+
#ifndef av_parity
|
| 160 |
+
# define av_parity av_parity_c
|
| 161 |
+
#endif
|
| 162 |
+
|
| 163 |
+
#ifndef av_log2
|
| 164 |
+
av_const int av_log2(unsigned v);
|
| 165 |
+
#endif
|
| 166 |
+
|
| 167 |
+
#ifndef av_log2_16bit
|
| 168 |
+
av_const int av_log2_16bit(unsigned v);
|
| 169 |
+
#endif
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
* Clip a signed integer value into the amin-amax range.
|
| 173 |
+
* @param a value to clip
|
| 174 |
+
* @param amin minimum value of the clip range
|
| 175 |
+
* @param amax maximum value of the clip range
|
| 176 |
+
* @return clipped value
|
| 177 |
+
*/
|
| 178 |
+
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
|
| 179 |
+
{
|
| 180 |
+
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
| 181 |
+
if (amin > amax) abort();
|
| 182 |
+
#endif
|
| 183 |
+
if (a < amin) return amin;
|
| 184 |
+
else if (a > amax) return amax;
|
| 185 |
+
else return a;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Clip a signed 64bit integer value into the amin-amax range.
|
| 190 |
+
* @param a value to clip
|
| 191 |
+
* @param amin minimum value of the clip range
|
| 192 |
+
* @param amax maximum value of the clip range
|
| 193 |
+
* @return clipped value
|
| 194 |
+
*/
|
| 195 |
+
static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
|
| 196 |
+
{
|
| 197 |
+
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
| 198 |
+
if (amin > amax) abort();
|
| 199 |
+
#endif
|
| 200 |
+
if (a < amin) return amin;
|
| 201 |
+
else if (a > amax) return amax;
|
| 202 |
+
else return a;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
* Clip a signed integer value into the 0-255 range.
|
| 207 |
+
* @param a value to clip
|
| 208 |
+
* @return clipped value
|
| 209 |
+
*/
|
| 210 |
+
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
|
| 211 |
+
{
|
| 212 |
+
if (a&(~0xFF)) return (~a)>>31;
|
| 213 |
+
else return a;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* Clip a signed integer value into the -128,127 range.
|
| 218 |
+
* @param a value to clip
|
| 219 |
+
* @return clipped value
|
| 220 |
+
*/
|
| 221 |
+
static av_always_inline av_const int8_t av_clip_int8_c(int a)
|
| 222 |
+
{
|
| 223 |
+
if ((a+0x80U) & ~0xFF) return (a>>31) ^ 0x7F;
|
| 224 |
+
else return a;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* Clip a signed integer value into the 0-65535 range.
|
| 229 |
+
* @param a value to clip
|
| 230 |
+
* @return clipped value
|
| 231 |
+
*/
|
| 232 |
+
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
|
| 233 |
+
{
|
| 234 |
+
if (a&(~0xFFFF)) return (~a)>>31;
|
| 235 |
+
else return a;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* Clip a signed integer value into the -32768,32767 range.
|
| 240 |
+
* @param a value to clip
|
| 241 |
+
* @return clipped value
|
| 242 |
+
*/
|
| 243 |
+
static av_always_inline av_const int16_t av_clip_int16_c(int a)
|
| 244 |
+
{
|
| 245 |
+
if ((a+0x8000U) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
|
| 246 |
+
else return a;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* Clip a signed 64-bit integer value into the -2147483648,2147483647 range.
|
| 251 |
+
* @param a value to clip
|
| 252 |
+
* @return clipped value
|
| 253 |
+
*/
|
| 254 |
+
static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
| 255 |
+
{
|
| 256 |
+
if ((a+UINT64_C(0x80000000)) & ~UINT64_C(0xFFFFFFFF)) return (int32_t)((a>>63) ^ 0x7FFFFFFF);
|
| 257 |
+
else return (int32_t)a;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
/**
|
| 261 |
+
* Clip a signed integer into the -(2^p),(2^p-1) range.
|
| 262 |
+
* @param a value to clip
|
| 263 |
+
* @param p bit position to clip at
|
| 264 |
+
* @return clipped value
|
| 265 |
+
*/
|
| 266 |
+
static av_always_inline av_const int av_clip_intp2_c(int a, int p)
|
| 267 |
+
{
|
| 268 |
+
if (((unsigned)a + (1U << p)) & ~((2U << p) - 1))
|
| 269 |
+
return (a >> 31) ^ ((1 << p) - 1);
|
| 270 |
+
else
|
| 271 |
+
return a;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
* Clip a signed integer to an unsigned power of two range.
|
| 276 |
+
* @param a value to clip
|
| 277 |
+
* @param p bit position to clip at
|
| 278 |
+
* @return clipped value
|
| 279 |
+
*/
|
| 280 |
+
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
|
| 281 |
+
{
|
| 282 |
+
if (a & ~((1U<<p) - 1)) return (~a) >> 31 & ((1U<<p) - 1);
|
| 283 |
+
else return a;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/**
|
| 287 |
+
* Clear high bits from an unsigned integer starting with specific bit position
|
| 288 |
+
* @param a value to clip
|
| 289 |
+
* @param p bit position to clip at. Must be between 0 and 31.
|
| 290 |
+
* @return clipped value
|
| 291 |
+
*/
|
| 292 |
+
static av_always_inline av_const unsigned av_zero_extend_c(unsigned a, unsigned p)
|
| 293 |
+
{
|
| 294 |
+
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
| 295 |
+
if (p > 31) abort();
|
| 296 |
+
#endif
|
| 297 |
+
return a & ((1U << p) - 1);
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
#if FF_API_MOD_UINTP2
|
| 301 |
+
#ifndef av_mod_uintp2
|
| 302 |
+
# define av_mod_uintp2 av_mod_uintp2_c
|
| 303 |
+
#endif
|
| 304 |
+
attribute_deprecated
|
| 305 |
+
static av_always_inline av_const unsigned av_mod_uintp2_c(unsigned a, unsigned p)
|
| 306 |
+
{
|
| 307 |
+
return av_zero_extend_c(a, p);
|
| 308 |
+
}
|
| 309 |
+
#endif
|
| 310 |
+
|
| 311 |
+
/**
|
| 312 |
+
* Add two signed 32-bit values with saturation.
|
| 313 |
+
*
|
| 314 |
+
* @param a one value
|
| 315 |
+
* @param b another value
|
| 316 |
+
* @return sum with signed saturation
|
| 317 |
+
*/
|
| 318 |
+
static av_always_inline int av_sat_add32_c(int a, int b)
|
| 319 |
+
{
|
| 320 |
+
return av_clipl_int32((int64_t)a + b);
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
/**
|
| 324 |
+
* Add a doubled value to another value with saturation at both stages.
|
| 325 |
+
*
|
| 326 |
+
* @param a first value
|
| 327 |
+
* @param b value doubled and added to a
|
| 328 |
+
* @return sum sat(a + sat(2*b)) with signed saturation
|
| 329 |
+
*/
|
| 330 |
+
static av_always_inline int av_sat_dadd32_c(int a, int b)
|
| 331 |
+
{
|
| 332 |
+
return av_sat_add32(a, av_sat_add32(b, b));
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
* Subtract two signed 32-bit values with saturation.
|
| 337 |
+
*
|
| 338 |
+
* @param a one value
|
| 339 |
+
* @param b another value
|
| 340 |
+
* @return difference with signed saturation
|
| 341 |
+
*/
|
| 342 |
+
static av_always_inline int av_sat_sub32_c(int a, int b)
|
| 343 |
+
{
|
| 344 |
+
return av_clipl_int32((int64_t)a - b);
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
/**
|
| 348 |
+
* Subtract a doubled value from another value with saturation at both stages.
|
| 349 |
+
*
|
| 350 |
+
* @param a first value
|
| 351 |
+
* @param b value doubled and subtracted from a
|
| 352 |
+
* @return difference sat(a - sat(2*b)) with signed saturation
|
| 353 |
+
*/
|
| 354 |
+
static av_always_inline int av_sat_dsub32_c(int a, int b)
|
| 355 |
+
{
|
| 356 |
+
return av_sat_sub32(a, av_sat_add32(b, b));
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
/**
|
| 360 |
+
* Add two signed 64-bit values with saturation.
|
| 361 |
+
*
|
| 362 |
+
* @param a one value
|
| 363 |
+
* @param b another value
|
| 364 |
+
* @return sum with signed saturation
|
| 365 |
+
*/
|
| 366 |
+
static av_always_inline int64_t av_sat_add64_c(int64_t a, int64_t b) {
|
| 367 |
+
#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_add_overflow)
|
| 368 |
+
int64_t tmp;
|
| 369 |
+
return !__builtin_add_overflow(a, b, &tmp) ? tmp : (tmp < 0 ? INT64_MAX : INT64_MIN);
|
| 370 |
+
#else
|
| 371 |
+
int64_t s = a+(uint64_t)b;
|
| 372 |
+
if ((int64_t)(a^b | ~s^b) >= 0)
|
| 373 |
+
return INT64_MAX ^ (b >> 63);
|
| 374 |
+
return s;
|
| 375 |
+
#endif
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
/**
|
| 379 |
+
* Subtract two signed 64-bit values with saturation.
|
| 380 |
+
*
|
| 381 |
+
* @param a one value
|
| 382 |
+
* @param b another value
|
| 383 |
+
* @return difference with signed saturation
|
| 384 |
+
*/
|
| 385 |
+
static av_always_inline int64_t av_sat_sub64_c(int64_t a, int64_t b) {
|
| 386 |
+
#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_sub_overflow)
|
| 387 |
+
int64_t tmp;
|
| 388 |
+
return !__builtin_sub_overflow(a, b, &tmp) ? tmp : (tmp < 0 ? INT64_MAX : INT64_MIN);
|
| 389 |
+
#else
|
| 390 |
+
if (b <= 0 && a >= INT64_MAX + b)
|
| 391 |
+
return INT64_MAX;
|
| 392 |
+
if (b >= 0 && a <= INT64_MIN + b)
|
| 393 |
+
return INT64_MIN;
|
| 394 |
+
return a - b;
|
| 395 |
+
#endif
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
/**
|
| 399 |
+
* Clip a float value into the amin-amax range.
|
| 400 |
+
* If a is nan or -inf amin will be returned.
|
| 401 |
+
* If a is +inf amax will be returned.
|
| 402 |
+
* @param a value to clip
|
| 403 |
+
* @param amin minimum value of the clip range
|
| 404 |
+
* @param amax maximum value of the clip range
|
| 405 |
+
* @return clipped value
|
| 406 |
+
*/
|
| 407 |
+
static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
|
| 408 |
+
{
|
| 409 |
+
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
| 410 |
+
if (amin > amax) abort();
|
| 411 |
+
#endif
|
| 412 |
+
return FFMIN(FFMAX(a, amin), amax);
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
* Clip a double value into the amin-amax range.
|
| 417 |
+
* If a is nan or -inf amin will be returned.
|
| 418 |
+
* If a is +inf amax will be returned.
|
| 419 |
+
* @param a value to clip
|
| 420 |
+
* @param amin minimum value of the clip range
|
| 421 |
+
* @param amax maximum value of the clip range
|
| 422 |
+
* @return clipped value
|
| 423 |
+
*/
|
| 424 |
+
static av_always_inline av_const double av_clipd_c(double a, double amin, double amax)
|
| 425 |
+
{
|
| 426 |
+
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
| 427 |
+
if (amin > amax) abort();
|
| 428 |
+
#endif
|
| 429 |
+
return FFMIN(FFMAX(a, amin), amax);
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
/** Compute ceil(log2(x)).
|
| 433 |
+
* @param x value used to compute ceil(log2(x))
|
| 434 |
+
* @return computed ceiling of log2(x)
|
| 435 |
+
*/
|
| 436 |
+
static av_always_inline av_const int av_ceil_log2_c(int x)
|
| 437 |
+
{
|
| 438 |
+
return av_log2((x - 1U) << 1);
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
/**
|
| 442 |
+
* Count number of bits set to one in x
|
| 443 |
+
* @param x value to count bits of
|
| 444 |
+
* @return the number of bits set to one in x
|
| 445 |
+
*/
|
| 446 |
+
static av_always_inline av_const int av_popcount_c(uint32_t x)
|
| 447 |
+
{
|
| 448 |
+
x -= (x >> 1) & 0x55555555;
|
| 449 |
+
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
| 450 |
+
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
| 451 |
+
x += x >> 8;
|
| 452 |
+
return (x + (x >> 16)) & 0x3F;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* Count number of bits set to one in x
|
| 457 |
+
* @param x value to count bits of
|
| 458 |
+
* @return the number of bits set to one in x
|
| 459 |
+
*/
|
| 460 |
+
static av_always_inline av_const int av_popcount64_c(uint64_t x)
|
| 461 |
+
{
|
| 462 |
+
return av_popcount((uint32_t)x) + av_popcount((uint32_t)(x >> 32));
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
static av_always_inline av_const int av_parity_c(uint32_t v)
|
| 466 |
+
{
|
| 467 |
+
return av_popcount(v) & 1;
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
/**
|
| 471 |
+
* Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
|
| 472 |
+
*
|
| 473 |
+
* @param val Output value, must be an lvalue of type uint32_t.
|
| 474 |
+
* @param GET_BYTE Expression reading one byte from the input.
|
| 475 |
+
* Evaluated up to 7 times (4 for the currently
|
| 476 |
+
* assigned Unicode range). With a memory buffer
|
| 477 |
+
* input, this could be *ptr++, or if you want to make sure
|
| 478 |
+
* that *ptr stops at the end of a NULL terminated string then
|
| 479 |
+
* *ptr ? *ptr++ : 0
|
| 480 |
+
* @param ERROR Expression to be evaluated on invalid input,
|
| 481 |
+
* typically a goto statement.
|
| 482 |
+
*
|
| 483 |
+
* @warning ERROR should not contain a loop control statement which
|
| 484 |
+
* could interact with the internal while loop, and should force an
|
| 485 |
+
* exit from the macro code (e.g. through a goto or a return) in order
|
| 486 |
+
* to prevent undefined results.
|
| 487 |
+
*/
|
| 488 |
+
#define GET_UTF8(val, GET_BYTE, ERROR)\
|
| 489 |
+
val= (GET_BYTE);\
|
| 490 |
+
{\
|
| 491 |
+
uint32_t top = (val & 128) >> 1;\
|
| 492 |
+
if ((val & 0xc0) == 0x80 || val >= 0xFE)\
|
| 493 |
+
{ERROR}\
|
| 494 |
+
while (val & top) {\
|
| 495 |
+
unsigned int tmp = (GET_BYTE) - 128;\
|
| 496 |
+
if(tmp>>6)\
|
| 497 |
+
{ERROR}\
|
| 498 |
+
val= (val<<6) + tmp;\
|
| 499 |
+
top <<= 5;\
|
| 500 |
+
}\
|
| 501 |
+
val &= (top << 1) - 1;\
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
/**
|
| 505 |
+
* Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
|
| 506 |
+
*
|
| 507 |
+
* @param val Output value, must be an lvalue of type uint32_t.
|
| 508 |
+
* @param GET_16BIT Expression returning two bytes of UTF-16 data converted
|
| 509 |
+
* to native byte order. Evaluated one or two times.
|
| 510 |
+
* @param ERROR Expression to be evaluated on invalid input,
|
| 511 |
+
* typically a goto statement.
|
| 512 |
+
*/
|
| 513 |
+
#define GET_UTF16(val, GET_16BIT, ERROR)\
|
| 514 |
+
val = (GET_16BIT);\
|
| 515 |
+
{\
|
| 516 |
+
unsigned int hi = val - 0xD800;\
|
| 517 |
+
if (hi < 0x800) {\
|
| 518 |
+
val = (GET_16BIT) - 0xDC00;\
|
| 519 |
+
if (val > 0x3FFU || hi > 0x3FFU)\
|
| 520 |
+
{ERROR}\
|
| 521 |
+
val += (hi<<10) + 0x10000;\
|
| 522 |
+
}\
|
| 523 |
+
}\
|
| 524 |
+
|
| 525 |
+
/**
|
| 526 |
+
* @def PUT_UTF8(val, tmp, PUT_BYTE)
|
| 527 |
+
* Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
|
| 528 |
+
* @param val is an input-only argument and should be of type uint32_t. It holds
|
| 529 |
+
* a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
|
| 530 |
+
* val is given as a function it is executed only once.
|
| 531 |
+
* @param tmp is a temporary variable and should be of type uint8_t. It
|
| 532 |
+
* represents an intermediate value during conversion that is to be
|
| 533 |
+
* output by PUT_BYTE.
|
| 534 |
+
* @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
|
| 535 |
+
* It could be a function or a statement, and uses tmp as the input byte.
|
| 536 |
+
* For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
|
| 537 |
+
* executed up to 4 times for values in the valid UTF-8 range and up to
|
| 538 |
+
* 7 times in the general case, depending on the length of the converted
|
| 539 |
+
* Unicode character.
|
| 540 |
+
*/
|
| 541 |
+
#define PUT_UTF8(val, tmp, PUT_BYTE)\
|
| 542 |
+
{\
|
| 543 |
+
int bytes, shift;\
|
| 544 |
+
uint32_t in = val;\
|
| 545 |
+
if (in < 0x80) {\
|
| 546 |
+
tmp = in;\
|
| 547 |
+
PUT_BYTE\
|
| 548 |
+
} else {\
|
| 549 |
+
bytes = (av_log2(in) + 4) / 5;\
|
| 550 |
+
shift = (bytes - 1) * 6;\
|
| 551 |
+
tmp = (256 - (256 >> bytes)) | (in >> shift);\
|
| 552 |
+
PUT_BYTE\
|
| 553 |
+
while (shift >= 6) {\
|
| 554 |
+
shift -= 6;\
|
| 555 |
+
tmp = 0x80 | ((in >> shift) & 0x3f);\
|
| 556 |
+
PUT_BYTE\
|
| 557 |
+
}\
|
| 558 |
+
}\
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
/**
|
| 562 |
+
* @def PUT_UTF16(val, tmp, PUT_16BIT)
|
| 563 |
+
* Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
|
| 564 |
+
* @param val is an input-only argument and should be of type uint32_t. It holds
|
| 565 |
+
* a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
|
| 566 |
+
* val is given as a function it is executed only once.
|
| 567 |
+
* @param tmp is a temporary variable and should be of type uint16_t. It
|
| 568 |
+
* represents an intermediate value during conversion that is to be
|
| 569 |
+
* output by PUT_16BIT.
|
| 570 |
+
* @param PUT_16BIT writes the converted UTF-16 data to any proper destination
|
| 571 |
+
* in desired endianness. It could be a function or a statement, and uses tmp
|
| 572 |
+
* as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
|
| 573 |
+
* PUT_BYTE will be executed 1 or 2 times depending on input character.
|
| 574 |
+
*/
|
| 575 |
+
#define PUT_UTF16(val, tmp, PUT_16BIT)\
|
| 576 |
+
{\
|
| 577 |
+
uint32_t in = val;\
|
| 578 |
+
if (in < 0x10000) {\
|
| 579 |
+
tmp = in;\
|
| 580 |
+
PUT_16BIT\
|
| 581 |
+
} else {\
|
| 582 |
+
tmp = 0xD800 | ((in - 0x10000) >> 10);\
|
| 583 |
+
PUT_16BIT\
|
| 584 |
+
tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
|
| 585 |
+
PUT_16BIT\
|
| 586 |
+
}\
|
| 587 |
+
}\
|
| 588 |
+
|
| 589 |
+
#endif /* AVUTIL_COMMON_H */
|
ffmpeg/include/libavutil/container_fifo.h
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_CONTAINER_FIFO_H
|
| 20 |
+
#define AVUTIL_CONTAINER_FIFO_H
|
| 21 |
+
|
| 22 |
+
#include <stddef.h>
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable
|
| 26 |
+
* structs (e.g. AVFrame or AVPacket). AVContainerFifo uses an internal pool of
|
| 27 |
+
* such containers to avoid allocating and freeing them repeatedly.
|
| 28 |
+
*/
|
| 29 |
+
typedef struct AVContainerFifo AVContainerFifo;
|
| 30 |
+
|
| 31 |
+
enum AVContainerFifoFlags {
|
| 32 |
+
/**
|
| 33 |
+
* Signal to av_container_fifo_write() that it should make a new reference
|
| 34 |
+
* to data in src rather than consume its contents.
|
| 35 |
+
*
|
| 36 |
+
* @note you must handle this flag manually in your own fifo_transfer()
|
| 37 |
+
* callback
|
| 38 |
+
*/
|
| 39 |
+
AV_CONTAINER_FIFO_FLAG_REF = (1 << 0),
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* This and all higher bits in flags may be set to any value by the caller
|
| 43 |
+
* and are guaranteed to be passed through to the fifo_transfer() callback
|
| 44 |
+
* and not be interpreted by AVContainerFifo code.
|
| 45 |
+
*/
|
| 46 |
+
AV_CONTAINER_FIFO_FLAG_USER = (1 << 16),
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Allocate a new AVContainerFifo for the container type defined by provided
|
| 51 |
+
* callbacks.
|
| 52 |
+
*
|
| 53 |
+
* @param opaque user data that will be passed to the callbacks provided to this
|
| 54 |
+
* function
|
| 55 |
+
* @param container_alloc allocate a new container instance and return a pointer
|
| 56 |
+
* to it, or NULL on failure
|
| 57 |
+
* @param container_reset reset the provided container instance to a clean state
|
| 58 |
+
* @param container_free free the provided container instance
|
| 59 |
+
* @param fifo_transfer Transfer the contents of container src to dst.
|
| 60 |
+
* @param flags currently unused
|
| 61 |
+
*
|
| 62 |
+
* @return newly allocated AVContainerFifo, or NULL on failure
|
| 63 |
+
*/
|
| 64 |
+
AVContainerFifo*
|
| 65 |
+
av_container_fifo_alloc(void *opaque,
|
| 66 |
+
void* (*container_alloc)(void *opaque),
|
| 67 |
+
void (*container_reset)(void *opaque, void *obj),
|
| 68 |
+
void (*container_free) (void *opaque, void *obj),
|
| 69 |
+
int (*fifo_transfer) (void *opaque, void *dst, void *src, unsigned flags),
|
| 70 |
+
unsigned flags);
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* Allocate an AVContainerFifo instance for AVFrames.
|
| 74 |
+
*
|
| 75 |
+
* @param flags currently unused
|
| 76 |
+
*/
|
| 77 |
+
AVContainerFifo *av_container_fifo_alloc_avframe(unsigned flags);
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Free a AVContainerFifo and everything in it.
|
| 81 |
+
*/
|
| 82 |
+
void av_container_fifo_free(AVContainerFifo **cf);
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Write the contents of obj to the FIFO.
|
| 86 |
+
*
|
| 87 |
+
* The fifo_transfer() callback previously provided to av_container_fifo_alloc()
|
| 88 |
+
* will be called with obj as src in order to perform the actual transfer.
|
| 89 |
+
*/
|
| 90 |
+
int av_container_fifo_write(AVContainerFifo *cf, void *obj, unsigned flags);
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Read the next available object from the FIFO into obj.
|
| 94 |
+
*
|
| 95 |
+
* The fifo_read() callback previously provided to av_container_fifo_alloc()
|
| 96 |
+
* will be called with obj as dst in order to perform the actual transfer.
|
| 97 |
+
*/
|
| 98 |
+
int av_container_fifo_read(AVContainerFifo *cf, void *obj, unsigned flags);
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Access objects stored in the FIFO without retrieving them. The
|
| 102 |
+
* fifo_transfer() callback will NOT be invoked and the FIFO state will not be
|
| 103 |
+
* modified.
|
| 104 |
+
*
|
| 105 |
+
* @param pobj Pointer to the object stored in the FIFO will be written here on
|
| 106 |
+
* success. The object remains owned by the FIFO and the caller may
|
| 107 |
+
* only access it as long as the FIFO is not modified.
|
| 108 |
+
* @param offset Position of the object to retrieve - 0 is the next item that
|
| 109 |
+
* would be read, 1 the one after, etc. Must be smaller than
|
| 110 |
+
* av_container_fifo_can_read().
|
| 111 |
+
*
|
| 112 |
+
* @retval 0 success, a pointer was written into pobj
|
| 113 |
+
* @retval AVERROR(EINVAL) invalid offset value
|
| 114 |
+
*/
|
| 115 |
+
int av_container_fifo_peek(AVContainerFifo *cf, void **pobj, size_t offset);
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Discard the specified number of elements from the FIFO.
|
| 119 |
+
*
|
| 120 |
+
* @param nb_elems number of elements to discard, MUST NOT be larger than
|
| 121 |
+
* av_fifo_can_read(f)
|
| 122 |
+
*/
|
| 123 |
+
void av_container_fifo_drain(AVContainerFifo *cf, size_t nb_elems);
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* @return number of objects available for reading
|
| 127 |
+
*/
|
| 128 |
+
size_t av_container_fifo_can_read(const AVContainerFifo *cf);
|
| 129 |
+
|
| 130 |
+
#endif // AVCODEC_CONTAINER_FIFO_H
|
ffmpeg/include/libavutil/cpu.h
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_CPU_H
|
| 22 |
+
#define AVUTIL_CPU_H
|
| 23 |
+
|
| 24 |
+
#include <stddef.h>
|
| 25 |
+
#include "version.h"
|
| 26 |
+
|
| 27 |
+
#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
|
| 28 |
+
|
| 29 |
+
/* lower 16 bits - CPU features */
|
| 30 |
+
#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX
|
| 31 |
+
#define AV_CPU_FLAG_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext
|
| 32 |
+
#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
|
| 33 |
+
#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW
|
| 34 |
+
#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions
|
| 35 |
+
#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions
|
| 36 |
+
#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster
|
| 37 |
+
///< than regular MMX/SSE (e.g. Core1)
|
| 38 |
+
#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt
|
| 39 |
+
#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions
|
| 40 |
+
#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster
|
| 41 |
+
///< than regular MMX/SSE (e.g. Core1)
|
| 42 |
+
#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions
|
| 43 |
+
#define AV_CPU_FLAG_SSSE3SLOW 0x4000000 ///< SSSE3 supported, but usually not faster
|
| 44 |
+
#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower
|
| 45 |
+
#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
|
| 46 |
+
#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions
|
| 47 |
+
#define AV_CPU_FLAG_AESNI 0x80000 ///< Advanced Encryption Standard functions
|
| 48 |
+
#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used
|
| 49 |
+
#define AV_CPU_FLAG_AVXSLOW 0x8000000 ///< AVX supported, but slow when using YMM registers (e.g. Bulldozer)
|
| 50 |
+
#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions
|
| 51 |
+
#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
|
| 52 |
+
#define AV_CPU_FLAG_CMOV 0x1000 ///< supports cmov instruction
|
| 53 |
+
#define AV_CPU_FLAG_AVX2 0x8000 ///< AVX2 functions: requires OS support even if YMM registers aren't used
|
| 54 |
+
#define AV_CPU_FLAG_FMA3 0x10000 ///< Haswell FMA3 functions
|
| 55 |
+
#define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1
|
| 56 |
+
#define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2
|
| 57 |
+
#define AV_CPU_FLAG_AVX512 0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used
|
| 58 |
+
#define AV_CPU_FLAG_AVX512ICL 0x200000 ///< F/CD/BW/DQ/VL/VNNI/IFMA/VBMI/VBMI2/VPOPCNTDQ/BITALG/GFNI/VAES/VPCLMULQDQ
|
| 59 |
+
#define AV_CPU_FLAG_SLOW_GATHER 0x2000000 ///< CPU has slow gathers.
|
| 60 |
+
|
| 61 |
+
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
|
| 62 |
+
#define AV_CPU_FLAG_VSX 0x0002 ///< ISA 2.06
|
| 63 |
+
#define AV_CPU_FLAG_POWER8 0x0004 ///< ISA 2.07
|
| 64 |
+
|
| 65 |
+
#define AV_CPU_FLAG_ARMV5TE (1 << 0)
|
| 66 |
+
#define AV_CPU_FLAG_ARMV6 (1 << 1)
|
| 67 |
+
#define AV_CPU_FLAG_ARMV6T2 (1 << 2)
|
| 68 |
+
#define AV_CPU_FLAG_VFP (1 << 3)
|
| 69 |
+
#define AV_CPU_FLAG_VFPV3 (1 << 4)
|
| 70 |
+
#define AV_CPU_FLAG_NEON (1 << 5)
|
| 71 |
+
#define AV_CPU_FLAG_ARMV8 (1 << 6)
|
| 72 |
+
#define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations
|
| 73 |
+
#define AV_CPU_FLAG_DOTPROD (1 << 8)
|
| 74 |
+
#define AV_CPU_FLAG_I8MM (1 << 9)
|
| 75 |
+
#define AV_CPU_FLAG_SVE (1 <<10)
|
| 76 |
+
#define AV_CPU_FLAG_SVE2 (1 <<11)
|
| 77 |
+
#define AV_CPU_FLAG_SETEND (1 <<16)
|
| 78 |
+
|
| 79 |
+
#define AV_CPU_FLAG_MMI (1 << 0)
|
| 80 |
+
#define AV_CPU_FLAG_MSA (1 << 1)
|
| 81 |
+
|
| 82 |
+
//Loongarch SIMD extension.
|
| 83 |
+
#define AV_CPU_FLAG_LSX (1 << 0)
|
| 84 |
+
#define AV_CPU_FLAG_LASX (1 << 1)
|
| 85 |
+
|
| 86 |
+
// RISC-V extensions
|
| 87 |
+
#define AV_CPU_FLAG_RVI (1 << 0) ///< I (full GPR bank)
|
| 88 |
+
#if FF_API_RISCV_FD_ZBA
|
| 89 |
+
#define AV_CPU_FLAG_RVF (1 << 1) ///< F (single precision FP)
|
| 90 |
+
#define AV_CPU_FLAG_RVD (1 << 2) ///< D (double precision FP)
|
| 91 |
+
#endif
|
| 92 |
+
#define AV_CPU_FLAG_RVV_I32 (1 << 3) ///< Vectors of 8/16/32-bit int's */
|
| 93 |
+
#define AV_CPU_FLAG_RVV_F32 (1 << 4) ///< Vectors of float's */
|
| 94 |
+
#define AV_CPU_FLAG_RVV_I64 (1 << 5) ///< Vectors of 64-bit int's */
|
| 95 |
+
#define AV_CPU_FLAG_RVV_F64 (1 << 6) ///< Vectors of double's
|
| 96 |
+
#define AV_CPU_FLAG_RVB_BASIC (1 << 7) ///< Basic bit-manipulations
|
| 97 |
+
#if FF_API_RISCV_FD_ZBA
|
| 98 |
+
#define AV_CPU_FLAG_RVB_ADDR (1 << 8) ///< Address bit-manipulations
|
| 99 |
+
#endif
|
| 100 |
+
#define AV_CPU_FLAG_RV_ZVBB (1 << 9) ///< Vector basic bit-manipulations
|
| 101 |
+
#define AV_CPU_FLAG_RV_MISALIGNED (1 <<10) ///< Fast misaligned accesses
|
| 102 |
+
#define AV_CPU_FLAG_RVB (1 <<11) ///< B (bit manipulations)
|
| 103 |
+
|
| 104 |
+
// WASM extensions
|
| 105 |
+
#define AV_CPU_FLAG_SIMD128 (1 << 0)
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Return the flags which specify extensions supported by the CPU.
|
| 109 |
+
* The returned value is affected by av_force_cpu_flags() if that was used
|
| 110 |
+
* before. So av_get_cpu_flags() can easily be used in an application to
|
| 111 |
+
* detect the enabled cpu flags.
|
| 112 |
+
*/
|
| 113 |
+
int av_get_cpu_flags(void);
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Disables cpu detection and forces the specified flags.
|
| 117 |
+
* -1 is a special case that disables forcing of specific flags.
|
| 118 |
+
*/
|
| 119 |
+
void av_force_cpu_flags(int flags);
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
|
| 123 |
+
*
|
| 124 |
+
* @return negative on error.
|
| 125 |
+
*/
|
| 126 |
+
int av_parse_cpu_caps(unsigned *flags, const char *s);
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* @return the number of logical CPU cores present.
|
| 130 |
+
*/
|
| 131 |
+
int av_cpu_count(void);
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Overrides cpu count detection and forces the specified count.
|
| 135 |
+
* Count < 1 disables forcing of specific count.
|
| 136 |
+
*/
|
| 137 |
+
void av_cpu_force_count(int count);
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* Get the maximum data alignment that may be required by FFmpeg.
|
| 141 |
+
*
|
| 142 |
+
* Note that this is affected by the build configuration and the CPU flags mask,
|
| 143 |
+
* so e.g. if the CPU supports AVX, but libavutil has been built with
|
| 144 |
+
* --disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through
|
| 145 |
+
* av_set_cpu_flags_mask(), then this function will behave as if AVX is not
|
| 146 |
+
* present.
|
| 147 |
+
*/
|
| 148 |
+
size_t av_cpu_max_align(void);
|
| 149 |
+
|
| 150 |
+
#endif /* AVUTIL_CPU_H */
|
ffmpeg/include/libavutil/crc.h
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* @ingroup lavu_crc32
|
| 24 |
+
* Public header for CRC hash function implementation.
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_CRC_H
|
| 28 |
+
#define AVUTIL_CRC_H
|
| 29 |
+
|
| 30 |
+
#include <stdint.h>
|
| 31 |
+
#include <stddef.h>
|
| 32 |
+
#include "attributes.h"
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* @defgroup lavu_crc32 CRC
|
| 36 |
+
* @ingroup lavu_hash
|
| 37 |
+
* CRC (Cyclic Redundancy Check) hash function implementation.
|
| 38 |
+
*
|
| 39 |
+
* This module supports numerous CRC polynomials, in addition to the most
|
| 40 |
+
* widely used CRC-32-IEEE. See @ref AVCRCId for a list of available
|
| 41 |
+
* polynomials.
|
| 42 |
+
*
|
| 43 |
+
* @{
|
| 44 |
+
*/
|
| 45 |
+
|
| 46 |
+
typedef uint32_t AVCRC;
|
| 47 |
+
|
| 48 |
+
typedef enum {
|
| 49 |
+
AV_CRC_8_ATM,
|
| 50 |
+
AV_CRC_16_ANSI,
|
| 51 |
+
AV_CRC_16_CCITT,
|
| 52 |
+
AV_CRC_32_IEEE,
|
| 53 |
+
AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */
|
| 54 |
+
AV_CRC_16_ANSI_LE, /*< reversed bitorder version of AV_CRC_16_ANSI */
|
| 55 |
+
AV_CRC_24_IEEE,
|
| 56 |
+
AV_CRC_8_EBU,
|
| 57 |
+
AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
|
| 58 |
+
}AVCRCId;
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Initialize a CRC table.
|
| 62 |
+
* @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
|
| 63 |
+
* @param le If 1, the lowest bit represents the coefficient for the highest
|
| 64 |
+
* exponent of the corresponding polynomial (both for poly and
|
| 65 |
+
* actual CRC).
|
| 66 |
+
* If 0, you must swap the CRC parameter and the result of av_crc
|
| 67 |
+
* if you need the standard representation (can be simplified in
|
| 68 |
+
* most cases to e.g. bswap16):
|
| 69 |
+
* av_bswap32(crc << (32-bits))
|
| 70 |
+
* @param bits number of bits for the CRC
|
| 71 |
+
* @param poly generator polynomial without the x**bits coefficient, in the
|
| 72 |
+
* representation as specified by le
|
| 73 |
+
* @param ctx_size size of ctx in bytes
|
| 74 |
+
* @return <0 on failure
|
| 75 |
+
*/
|
| 76 |
+
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Get an initialized standard CRC table.
|
| 80 |
+
* @param crc_id ID of a standard CRC
|
| 81 |
+
* @return a pointer to the CRC table or NULL on failure
|
| 82 |
+
*/
|
| 83 |
+
const AVCRC *av_crc_get_table(AVCRCId crc_id);
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Calculate the CRC of a block.
|
| 87 |
+
* @param ctx initialized AVCRC array (see av_crc_init())
|
| 88 |
+
* @param crc CRC of previous blocks if any or initial value for CRC
|
| 89 |
+
* @param buffer buffer whose CRC to calculate
|
| 90 |
+
* @param length length of the buffer
|
| 91 |
+
* @return CRC updated with the data from the given block
|
| 92 |
+
*
|
| 93 |
+
* @see av_crc_init() "le" parameter
|
| 94 |
+
*/
|
| 95 |
+
uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
|
| 96 |
+
const uint8_t *buffer, size_t length) av_pure;
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* @}
|
| 100 |
+
*/
|
| 101 |
+
|
| 102 |
+
#endif /* AVUTIL_CRC_H */
|
ffmpeg/include/libavutil/csp.h
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2015 Kevin Wheatley <kevin.j.wheatley@gmail.com>
|
| 3 |
+
* Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
|
| 4 |
+
* Copyright (c) 2023 Leo Izen <leo.izen@gmail.com>
|
| 5 |
+
*
|
| 6 |
+
* This file is part of FFmpeg.
|
| 7 |
+
*
|
| 8 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 9 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 10 |
+
* License as published by the Free Software Foundation; either
|
| 11 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 12 |
+
*
|
| 13 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 16 |
+
* Lesser General Public License for more details.
|
| 17 |
+
*
|
| 18 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 19 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 20 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
#ifndef AVUTIL_CSP_H
|
| 24 |
+
#define AVUTIL_CSP_H
|
| 25 |
+
|
| 26 |
+
#include "pixfmt.h"
|
| 27 |
+
#include "rational.h"
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @file
|
| 31 |
+
* Colorspace value utility functions for libavutil.
|
| 32 |
+
* @ingroup lavu_math_csp
|
| 33 |
+
* @author Ronald S. Bultje <rsbultje@gmail.com>
|
| 34 |
+
* @author Leo Izen <leo.izen@gmail.com>
|
| 35 |
+
* @author Kevin Wheatley <kevin.j.wheatley@gmail.com>
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* @defgroup lavu_math_csp Colorspace Utility
|
| 40 |
+
* @ingroup lavu_math
|
| 41 |
+
* @{
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar
|
| 46 |
+
* calculations.
|
| 47 |
+
*/
|
| 48 |
+
typedef struct AVLumaCoefficients {
|
| 49 |
+
AVRational cr, cg, cb;
|
| 50 |
+
} AVLumaCoefficients;
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* Struct containing chromaticity x and y values for the standard CIE 1931
|
| 54 |
+
* chromaticity definition.
|
| 55 |
+
*/
|
| 56 |
+
typedef struct AVCIExy {
|
| 57 |
+
AVRational x, y;
|
| 58 |
+
} AVCIExy;
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Struct defining the red, green, and blue primary locations in terms of CIE
|
| 62 |
+
* 1931 chromaticity x and y.
|
| 63 |
+
*/
|
| 64 |
+
typedef struct AVPrimaryCoefficients {
|
| 65 |
+
AVCIExy r, g, b;
|
| 66 |
+
} AVPrimaryCoefficients;
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Struct defining white point location in terms of CIE 1931 chromaticity x
|
| 70 |
+
* and y.
|
| 71 |
+
*/
|
| 72 |
+
typedef AVCIExy AVWhitepointCoefficients;
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Struct that contains both white point location and primaries location, providing
|
| 76 |
+
* the complete description of a color gamut.
|
| 77 |
+
*/
|
| 78 |
+
typedef struct AVColorPrimariesDesc {
|
| 79 |
+
AVWhitepointCoefficients wp;
|
| 80 |
+
AVPrimaryCoefficients prim;
|
| 81 |
+
} AVColorPrimariesDesc;
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Function pointer representing a double -> double transfer function that
|
| 85 |
+
* performs either an OETF transfer function, or alternatively an inverse EOTF
|
| 86 |
+
* function (in particular, for SMPTE ST 2084 / PQ). This function inputs
|
| 87 |
+
* linear light, and outputs gamma encoded light.
|
| 88 |
+
*
|
| 89 |
+
* See ITU-T H.273 for more information.
|
| 90 |
+
*/
|
| 91 |
+
typedef double (*av_csp_trc_function)(double);
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Retrieves the Luma coefficients necessary to construct a conversion matrix
|
| 95 |
+
* from an enum constant describing the colorspace.
|
| 96 |
+
* @param csp An enum constant indicating YUV or similar colorspace.
|
| 97 |
+
* @return The Luma coefficients associated with that colorspace, or NULL
|
| 98 |
+
* if the constant is unknown to libavutil.
|
| 99 |
+
*/
|
| 100 |
+
const AVLumaCoefficients *av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp);
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Retrieves a complete gamut description from an enum constant describing the
|
| 104 |
+
* color primaries.
|
| 105 |
+
* @param prm An enum constant indicating primaries
|
| 106 |
+
* @return A description of the colorspace gamut associated with that enum
|
| 107 |
+
* constant, or NULL if the constant is unknown to libavutil.
|
| 108 |
+
*/
|
| 109 |
+
const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries prm);
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* Detects which enum AVColorPrimaries constant corresponds to the given complete
|
| 113 |
+
* gamut description.
|
| 114 |
+
* @see enum AVColorPrimaries
|
| 115 |
+
* @param prm A description of the colorspace gamut
|
| 116 |
+
* @return The enum constant associated with this gamut, or
|
| 117 |
+
* AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified.
|
| 118 |
+
*/
|
| 119 |
+
enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm);
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Determine a suitable 'gamma' value to match the supplied
|
| 123 |
+
* AVColorTransferCharacteristic.
|
| 124 |
+
*
|
| 125 |
+
* See Apple Technical Note TN2257 (https://developer.apple.com/library/mac/technotes/tn2257/_index.html)
|
| 126 |
+
*
|
| 127 |
+
* This function returns the gamma exponent for the OETF. For example, sRGB is approximated
|
| 128 |
+
* by gamma 2.2, not by gamma 0.45455.
|
| 129 |
+
*
|
| 130 |
+
* @return Will return an approximation to the simple gamma function matching
|
| 131 |
+
* the supplied Transfer Characteristic, Will return 0.0 for any
|
| 132 |
+
* we cannot reasonably match against.
|
| 133 |
+
*/
|
| 134 |
+
double av_csp_approximate_trc_gamma(enum AVColorTransferCharacteristic trc);
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* Determine the function needed to apply the given
|
| 138 |
+
* AVColorTransferCharacteristic to linear input.
|
| 139 |
+
*
|
| 140 |
+
* The function returned should expect a nominal domain and range of [0.0-1.0]
|
| 141 |
+
* values outside of this range maybe valid depending on the chosen
|
| 142 |
+
* characteristic function.
|
| 143 |
+
*
|
| 144 |
+
* @return Will return pointer to the function matching the
|
| 145 |
+
* supplied Transfer Characteristic. If unspecified will
|
| 146 |
+
* return NULL:
|
| 147 |
+
*/
|
| 148 |
+
av_csp_trc_function av_csp_trc_func_from_id(enum AVColorTransferCharacteristic trc);
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* Returns the mathematical inverse of the corresponding TRC function.
|
| 152 |
+
*/
|
| 153 |
+
av_csp_trc_function av_csp_trc_func_inv_from_id(enum AVColorTransferCharacteristic trc);
|
| 154 |
+
|
| 155 |
+
/**
|
| 156 |
+
* Function pointer representing an ITU EOTF transfer for a given reference
|
| 157 |
+
* display configuration.
|
| 158 |
+
*
|
| 159 |
+
* @param Lw The white point luminance of the display, in nits (cd/m^2).
|
| 160 |
+
* @param Lb The black point luminance of the display, in nits (cd/m^2).
|
| 161 |
+
*/
|
| 162 |
+
typedef void (*av_csp_eotf_function)(double Lw, double Lb, double c[3]);
|
| 163 |
+
|
| 164 |
+
/**
|
| 165 |
+
* Returns the ITU EOTF corresponding to a given TRC. This converts from the
|
| 166 |
+
* signal level [0,1] to the raw output display luminance in nits (cd/m^2).
|
| 167 |
+
* This is done per channel in RGB space, except for AVCOL_TRC_SMPTE428, which
|
| 168 |
+
* assumes CIE XYZ in- and output.
|
| 169 |
+
*
|
| 170 |
+
* @return A pointer to the function implementing the given TRC, or NULL if no
|
| 171 |
+
* such function is defined.
|
| 172 |
+
*
|
| 173 |
+
* @note In general, the resulting function is defined (wherever possible) for
|
| 174 |
+
* out-of-range values, even though these values do not have a physical
|
| 175 |
+
* meaning on the given display. Users should clamp inputs (or outputs)
|
| 176 |
+
* if this behavior is not desired.
|
| 177 |
+
*
|
| 178 |
+
* This is also the case for functions like PQ, which are defined over an
|
| 179 |
+
* absolute signal range independent of the target display capabilities.
|
| 180 |
+
*/
|
| 181 |
+
av_csp_eotf_function av_csp_itu_eotf(enum AVColorTransferCharacteristic trc);
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* Returns the mathematical inverse of the corresponding EOTF.
|
| 185 |
+
*/
|
| 186 |
+
av_csp_eotf_function av_csp_itu_eotf_inv(enum AVColorTransferCharacteristic trc);
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* @}
|
| 190 |
+
*/
|
| 191 |
+
|
| 192 |
+
#endif /* AVUTIL_CSP_H */
|
ffmpeg/include/libavutil/des.h
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* DES encryption/decryption
|
| 3 |
+
* Copyright (c) 2007 Reimar Doeffinger
|
| 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 |
+
#ifndef AVUTIL_DES_H
|
| 23 |
+
#define AVUTIL_DES_H
|
| 24 |
+
|
| 25 |
+
#include <stdint.h>
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @defgroup lavu_des DES
|
| 29 |
+
* @ingroup lavu_crypto
|
| 30 |
+
* @{
|
| 31 |
+
*/
|
| 32 |
+
|
| 33 |
+
typedef struct AVDES {
|
| 34 |
+
uint64_t round_keys[3][16];
|
| 35 |
+
int triple_des;
|
| 36 |
+
} AVDES;
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Allocate an AVDES context.
|
| 40 |
+
*/
|
| 41 |
+
AVDES *av_des_alloc(void);
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* @brief Initializes an AVDES context.
|
| 45 |
+
*
|
| 46 |
+
* @param d pointer to a AVDES structure to initialize
|
| 47 |
+
* @param key pointer to the key to use
|
| 48 |
+
* @param key_bits must be 64 or 192
|
| 49 |
+
* @param decrypt 0 for encryption/CBC-MAC, 1 for decryption
|
| 50 |
+
* @return zero on success, negative value otherwise
|
| 51 |
+
*/
|
| 52 |
+
int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt);
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* @brief Encrypts / decrypts using the DES algorithm.
|
| 56 |
+
*
|
| 57 |
+
* @param d pointer to the AVDES structure
|
| 58 |
+
* @param dst destination array, can be equal to src, must be 8-byte aligned
|
| 59 |
+
* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
|
| 60 |
+
* @param count number of 8 byte blocks
|
| 61 |
+
* @param iv initialization vector for CBC mode, if NULL then ECB will be used,
|
| 62 |
+
* must be 8-byte aligned
|
| 63 |
+
* @param decrypt 0 for encryption, 1 for decryption
|
| 64 |
+
*/
|
| 65 |
+
void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* @brief Calculates CBC-MAC using the DES algorithm.
|
| 69 |
+
*
|
| 70 |
+
* @param d pointer to the AVDES structure
|
| 71 |
+
* @param dst destination array, can be equal to src, must be 8-byte aligned
|
| 72 |
+
* @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL
|
| 73 |
+
* @param count number of 8 byte blocks
|
| 74 |
+
*/
|
| 75 |
+
void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count);
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* @}
|
| 79 |
+
*/
|
| 80 |
+
|
| 81 |
+
#endif /* AVUTIL_DES_H */
|
ffmpeg/include/libavutil/detection_bbox.h
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_DETECTION_BBOX_H
|
| 20 |
+
#define AVUTIL_DETECTION_BBOX_H
|
| 21 |
+
|
| 22 |
+
#include "rational.h"
|
| 23 |
+
#include "avassert.h"
|
| 24 |
+
#include "frame.h"
|
| 25 |
+
|
| 26 |
+
typedef struct AVDetectionBBox {
|
| 27 |
+
/**
|
| 28 |
+
* Distance in pixels from the left/top edge of the frame,
|
| 29 |
+
* together with width and height, defining the bounding box.
|
| 30 |
+
*/
|
| 31 |
+
int x;
|
| 32 |
+
int y;
|
| 33 |
+
int w;
|
| 34 |
+
int h;
|
| 35 |
+
|
| 36 |
+
#define AV_DETECTION_BBOX_LABEL_NAME_MAX_SIZE 64
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Detect result with confidence
|
| 40 |
+
*/
|
| 41 |
+
char detect_label[AV_DETECTION_BBOX_LABEL_NAME_MAX_SIZE];
|
| 42 |
+
AVRational detect_confidence;
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* At most 4 classifications based on the detected bounding box.
|
| 46 |
+
* For example, we can get max 4 different attributes with 4 different
|
| 47 |
+
* DNN models on one bounding box.
|
| 48 |
+
* classify_count is zero if no classification.
|
| 49 |
+
*/
|
| 50 |
+
#define AV_NUM_DETECTION_BBOX_CLASSIFY 4
|
| 51 |
+
uint32_t classify_count;
|
| 52 |
+
char classify_labels[AV_NUM_DETECTION_BBOX_CLASSIFY][AV_DETECTION_BBOX_LABEL_NAME_MAX_SIZE];
|
| 53 |
+
AVRational classify_confidences[AV_NUM_DETECTION_BBOX_CLASSIFY];
|
| 54 |
+
} AVDetectionBBox;
|
| 55 |
+
|
| 56 |
+
typedef struct AVDetectionBBoxHeader {
|
| 57 |
+
/**
|
| 58 |
+
* Information about how the bounding box is generated.
|
| 59 |
+
* for example, the DNN model name.
|
| 60 |
+
*/
|
| 61 |
+
char source[256];
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Number of bounding boxes in the array.
|
| 65 |
+
*/
|
| 66 |
+
uint32_t nb_bboxes;
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Offset in bytes from the beginning of this structure at which
|
| 70 |
+
* the array of bounding boxes starts.
|
| 71 |
+
*/
|
| 72 |
+
size_t bboxes_offset;
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Size of each bounding box in bytes.
|
| 76 |
+
*/
|
| 77 |
+
size_t bbox_size;
|
| 78 |
+
} AVDetectionBBoxHeader;
|
| 79 |
+
|
| 80 |
+
/*
|
| 81 |
+
* Get the bounding box at the specified {@code idx}. Must be between 0 and nb_bboxes.
|
| 82 |
+
*/
|
| 83 |
+
static av_always_inline AVDetectionBBox *
|
| 84 |
+
av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx)
|
| 85 |
+
{
|
| 86 |
+
av_assert0(idx < header->nb_bboxes);
|
| 87 |
+
return (AVDetectionBBox *)((uint8_t *)header + header->bboxes_offset +
|
| 88 |
+
idx * header->bbox_size);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Allocates memory for AVDetectionBBoxHeader, plus an array of {@code nb_bboxes}
|
| 93 |
+
* AVDetectionBBox, and initializes the variables.
|
| 94 |
+
* Can be freed with a normal av_free() call.
|
| 95 |
+
*
|
| 96 |
+
* @param nb_bboxes number of AVDetectionBBox structures to allocate
|
| 97 |
+
* @param out_size if non-NULL, the size in bytes of the resulting data array is
|
| 98 |
+
* written here.
|
| 99 |
+
*/
|
| 100 |
+
AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_size);
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Allocates memory for AVDetectionBBoxHeader, plus an array of {@code nb_bboxes}
|
| 104 |
+
* AVDetectionBBox, in the given AVFrame {@code frame} as AVFrameSideData of type
|
| 105 |
+
* AV_FRAME_DATA_DETECTION_BBOXES and initializes the variables.
|
| 106 |
+
*/
|
| 107 |
+
AVDetectionBBoxHeader *av_detection_bbox_create_side_data(AVFrame *frame, uint32_t nb_bboxes);
|
| 108 |
+
#endif
|
ffmpeg/include/libavutil/dict.h
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/**
|
| 20 |
+
* @file
|
| 21 |
+
* Public dictionary API.
|
| 22 |
+
* @deprecated
|
| 23 |
+
* AVDictionary is provided for compatibility with libav. It is both in
|
| 24 |
+
* implementation as well as API inefficient. It does not scale and is
|
| 25 |
+
* extremely slow with large dictionaries.
|
| 26 |
+
* It is recommended that new code uses our tree container from tree.c/h
|
| 27 |
+
* where applicable, which uses AVL trees to achieve O(log n) performance.
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
#ifndef AVUTIL_DICT_H
|
| 31 |
+
#define AVUTIL_DICT_H
|
| 32 |
+
|
| 33 |
+
#include <stdint.h>
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @addtogroup lavu_dict AVDictionary
|
| 37 |
+
* @ingroup lavu_data
|
| 38 |
+
*
|
| 39 |
+
* @brief Simple key:value store
|
| 40 |
+
*
|
| 41 |
+
* @{
|
| 42 |
+
* Dictionaries are used for storing key-value pairs.
|
| 43 |
+
*
|
| 44 |
+
* - To **create an AVDictionary**, simply pass an address of a NULL
|
| 45 |
+
* pointer to av_dict_set(). NULL can be used as an empty dictionary
|
| 46 |
+
* wherever a pointer to an AVDictionary is required.
|
| 47 |
+
* - To **insert an entry**, use av_dict_set().
|
| 48 |
+
* - Use av_dict_get() to **retrieve an entry**.
|
| 49 |
+
* - To **iterate over all entries**, use av_dict_iterate().
|
| 50 |
+
* - In order to **free the dictionary and all its contents**, use av_dict_free().
|
| 51 |
+
*
|
| 52 |
+
@code
|
| 53 |
+
AVDictionary *d = NULL; // "create" an empty dictionary
|
| 54 |
+
AVDictionaryEntry *t = NULL;
|
| 55 |
+
|
| 56 |
+
av_dict_set(&d, "foo", "bar", 0); // add an entry
|
| 57 |
+
|
| 58 |
+
char *k = av_strdup("key"); // if your strings are already allocated,
|
| 59 |
+
char *v = av_strdup("value"); // you can avoid copying them like this
|
| 60 |
+
av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
| 61 |
+
|
| 62 |
+
while ((t = av_dict_iterate(d, t))) {
|
| 63 |
+
<....> // iterate over all entries in d
|
| 64 |
+
}
|
| 65 |
+
av_dict_free(&d);
|
| 66 |
+
@endcode
|
| 67 |
+
*/
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* @name AVDictionary Flags
|
| 71 |
+
* Flags that influence behavior of the matching of keys or insertion to the dictionary.
|
| 72 |
+
* @{
|
| 73 |
+
*/
|
| 74 |
+
#define AV_DICT_MATCH_CASE 1 /**< Only get an entry with exact-case key match. Only relevant in av_dict_get(). */
|
| 75 |
+
#define AV_DICT_IGNORE_SUFFIX 2 /**< Return first entry in a dictionary whose first part corresponds to the search key,
|
| 76 |
+
ignoring the suffix of the found key string. Only relevant in av_dict_get(). */
|
| 77 |
+
#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been
|
| 78 |
+
allocated with av_malloc() or another memory allocation function. */
|
| 79 |
+
#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
|
| 80 |
+
allocated with av_malloc() or another memory allocation function. */
|
| 81 |
+
#define AV_DICT_DONT_OVERWRITE 16 /**< Don't overwrite existing entries. */
|
| 82 |
+
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
|
| 83 |
+
delimiter is added, the strings are simply concatenated. */
|
| 84 |
+
#define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */
|
| 85 |
+
/**
|
| 86 |
+
* @}
|
| 87 |
+
*/
|
| 88 |
+
|
| 89 |
+
typedef struct AVDictionaryEntry {
|
| 90 |
+
char *key;
|
| 91 |
+
char *value;
|
| 92 |
+
} AVDictionaryEntry;
|
| 93 |
+
|
| 94 |
+
typedef struct AVDictionary AVDictionary;
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Get a dictionary entry with matching key.
|
| 98 |
+
*
|
| 99 |
+
* The returned entry key or value must not be changed, or it will
|
| 100 |
+
* cause undefined behavior.
|
| 101 |
+
*
|
| 102 |
+
* @param prev Set to the previous matching element to find the next.
|
| 103 |
+
* If set to NULL the first matching element is returned.
|
| 104 |
+
* @param key Matching key
|
| 105 |
+
* @param flags A collection of AV_DICT_* flags controlling how the
|
| 106 |
+
* entry is retrieved
|
| 107 |
+
*
|
| 108 |
+
* @return Found entry or NULL in case no matching entry was found in the dictionary
|
| 109 |
+
*/
|
| 110 |
+
AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
|
| 111 |
+
const AVDictionaryEntry *prev, int flags);
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Iterate over a dictionary
|
| 115 |
+
*
|
| 116 |
+
* Iterates through all entries in the dictionary.
|
| 117 |
+
*
|
| 118 |
+
* @warning The returned AVDictionaryEntry key/value must not be changed.
|
| 119 |
+
*
|
| 120 |
+
* @warning As av_dict_set() invalidates all previous entries returned
|
| 121 |
+
* by this function, it must not be called while iterating over the dict.
|
| 122 |
+
*
|
| 123 |
+
* Typical usage:
|
| 124 |
+
* @code
|
| 125 |
+
* const AVDictionaryEntry *e = NULL;
|
| 126 |
+
* while ((e = av_dict_iterate(m, e))) {
|
| 127 |
+
* // ...
|
| 128 |
+
* }
|
| 129 |
+
* @endcode
|
| 130 |
+
*
|
| 131 |
+
* @param m The dictionary to iterate over
|
| 132 |
+
* @param prev Pointer to the previous AVDictionaryEntry, NULL initially
|
| 133 |
+
*
|
| 134 |
+
* @retval AVDictionaryEntry* The next element in the dictionary
|
| 135 |
+
* @retval NULL No more elements in the dictionary
|
| 136 |
+
*/
|
| 137 |
+
const AVDictionaryEntry *av_dict_iterate(const AVDictionary *m,
|
| 138 |
+
const AVDictionaryEntry *prev);
|
| 139 |
+
|
| 140 |
+
/**
|
| 141 |
+
* Get number of entries in dictionary.
|
| 142 |
+
*
|
| 143 |
+
* @param m dictionary
|
| 144 |
+
* @return number of entries in dictionary
|
| 145 |
+
*/
|
| 146 |
+
int av_dict_count(const AVDictionary *m);
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* Set the given entry in *pm, overwriting an existing entry.
|
| 150 |
+
*
|
| 151 |
+
* Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set,
|
| 152 |
+
* these arguments will be freed on error.
|
| 153 |
+
*
|
| 154 |
+
* @warning Adding a new entry to a dictionary invalidates all existing entries
|
| 155 |
+
* previously returned with av_dict_get() or av_dict_iterate().
|
| 156 |
+
*
|
| 157 |
+
* @param pm Pointer to a pointer to a dictionary struct. If *pm is NULL
|
| 158 |
+
* a dictionary struct is allocated and put in *pm.
|
| 159 |
+
* @param key Entry key to add to *pm (will either be av_strduped or added as a new key depending on flags)
|
| 160 |
+
* @param value Entry value to add to *pm (will be av_strduped or added as a new key depending on flags).
|
| 161 |
+
* Passing a NULL value will cause an existing entry to be deleted.
|
| 162 |
+
*
|
| 163 |
+
* @return >= 0 on success otherwise an error code <0
|
| 164 |
+
*/
|
| 165 |
+
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Convenience wrapper for av_dict_set() that converts the value to a string
|
| 169 |
+
* and stores it.
|
| 170 |
+
*
|
| 171 |
+
* Note: If ::AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error.
|
| 172 |
+
*/
|
| 173 |
+
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags);
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Parse the key/value pairs list and add the parsed entries to a dictionary.
|
| 177 |
+
*
|
| 178 |
+
* In case of failure, all the successfully set entries are stored in
|
| 179 |
+
* *pm. You may need to manually free the created dictionary.
|
| 180 |
+
*
|
| 181 |
+
* @param key_val_sep A 0-terminated list of characters used to separate
|
| 182 |
+
* key from value
|
| 183 |
+
* @param pairs_sep A 0-terminated list of characters used to separate
|
| 184 |
+
* two pairs from each other
|
| 185 |
+
* @param flags Flags to use when adding to the dictionary.
|
| 186 |
+
* ::AV_DICT_DONT_STRDUP_KEY and ::AV_DICT_DONT_STRDUP_VAL
|
| 187 |
+
* are ignored since the key/value tokens will always
|
| 188 |
+
* be duplicated.
|
| 189 |
+
*
|
| 190 |
+
* @return 0 on success, negative AVERROR code on failure
|
| 191 |
+
*/
|
| 192 |
+
int av_dict_parse_string(AVDictionary **pm, const char *str,
|
| 193 |
+
const char *key_val_sep, const char *pairs_sep,
|
| 194 |
+
int flags);
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* Copy entries from one AVDictionary struct into another.
|
| 198 |
+
*
|
| 199 |
+
* @note Metadata is read using the ::AV_DICT_IGNORE_SUFFIX flag
|
| 200 |
+
*
|
| 201 |
+
* @param dst Pointer to a pointer to a AVDictionary struct to copy into. If *dst is NULL,
|
| 202 |
+
* this function will allocate a struct for you and put it in *dst
|
| 203 |
+
* @param src Pointer to the source AVDictionary struct to copy items from.
|
| 204 |
+
* @param flags Flags to use when setting entries in *dst
|
| 205 |
+
*
|
| 206 |
+
* @return 0 on success, negative AVERROR code on failure. If dst was allocated
|
| 207 |
+
* by this function, callers should free the associated memory.
|
| 208 |
+
*/
|
| 209 |
+
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags);
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* Free all the memory allocated for an AVDictionary struct
|
| 213 |
+
* and all keys and values.
|
| 214 |
+
*/
|
| 215 |
+
void av_dict_free(AVDictionary **m);
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* Get dictionary entries as a string.
|
| 219 |
+
*
|
| 220 |
+
* Create a string containing dictionary's entries.
|
| 221 |
+
* Such string may be passed back to av_dict_parse_string().
|
| 222 |
+
* @note String is escaped with backslashes ('\').
|
| 223 |
+
*
|
| 224 |
+
* @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same.
|
| 225 |
+
*
|
| 226 |
+
* @param[in] m The dictionary
|
| 227 |
+
* @param[out] buffer Pointer to buffer that will be allocated with string containg entries.
|
| 228 |
+
* Buffer must be freed by the caller when is no longer needed.
|
| 229 |
+
* @param[in] key_val_sep Character used to separate key from value
|
| 230 |
+
* @param[in] pairs_sep Character used to separate two pairs from each other
|
| 231 |
+
*
|
| 232 |
+
* @return >= 0 on success, negative on error
|
| 233 |
+
*/
|
| 234 |
+
int av_dict_get_string(const AVDictionary *m, char **buffer,
|
| 235 |
+
const char key_val_sep, const char pairs_sep);
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* @}
|
| 239 |
+
*/
|
| 240 |
+
|
| 241 |
+
#endif /* AVUTIL_DICT_H */
|
ffmpeg/include/libavutil/display.h
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2014 Vittorio Giovara <vittorio.giovara@gmail.com>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* @ingroup lavu_video_display
|
| 24 |
+
* Display matrix
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_DISPLAY_H
|
| 28 |
+
#define AVUTIL_DISPLAY_H
|
| 29 |
+
|
| 30 |
+
#include <stdint.h>
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* @defgroup lavu_video_display Display transformation matrix functions
|
| 34 |
+
* @ingroup lavu_video
|
| 35 |
+
*
|
| 36 |
+
* The display transformation matrix specifies an affine transformation that
|
| 37 |
+
* should be applied to video frames for correct presentation. It is compatible
|
| 38 |
+
* with the matrices stored in the ISO/IEC 14496-12 container format.
|
| 39 |
+
*
|
| 40 |
+
* The data is a 3x3 matrix represented as a 9-element array:
|
| 41 |
+
*
|
| 42 |
+
* @code{.unparsed}
|
| 43 |
+
* | a b u |
|
| 44 |
+
* (a, b, u, c, d, v, x, y, w) -> | c d v |
|
| 45 |
+
* | x y w |
|
| 46 |
+
* @endcode
|
| 47 |
+
*
|
| 48 |
+
* All numbers are stored in native endianness, as 16.16 fixed-point values,
|
| 49 |
+
* except for u, v and w, which are stored as 2.30 fixed-point values.
|
| 50 |
+
*
|
| 51 |
+
* The transformation maps a point (p, q) in the source (pre-transformation)
|
| 52 |
+
* frame to the point (p', q') in the destination (post-transformation) frame as
|
| 53 |
+
* follows:
|
| 54 |
+
*
|
| 55 |
+
* @code{.unparsed}
|
| 56 |
+
* | a b u |
|
| 57 |
+
* (p, q, 1) . | c d v | = z * (p', q', 1)
|
| 58 |
+
* | x y w |
|
| 59 |
+
* @endcode
|
| 60 |
+
*
|
| 61 |
+
* The transformation can also be more explicitly written in components as
|
| 62 |
+
* follows:
|
| 63 |
+
*
|
| 64 |
+
* @code{.unparsed}
|
| 65 |
+
* p' = (a * p + c * q + x) / z;
|
| 66 |
+
* q' = (b * p + d * q + y) / z;
|
| 67 |
+
* z = u * p + v * q + w
|
| 68 |
+
* @endcode
|
| 69 |
+
*
|
| 70 |
+
* @{
|
| 71 |
+
*/
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Extract the rotation component of the transformation matrix.
|
| 75 |
+
*
|
| 76 |
+
* @param matrix the transformation matrix
|
| 77 |
+
* @return the angle (in degrees) by which the transformation rotates the frame
|
| 78 |
+
* counterclockwise. The angle will be in range [-180.0, 180.0],
|
| 79 |
+
* or NaN if the matrix is singular.
|
| 80 |
+
*
|
| 81 |
+
* @note floating point numbers are inherently inexact, so callers are
|
| 82 |
+
* recommended to round the return value to nearest integer before use.
|
| 83 |
+
*/
|
| 84 |
+
double av_display_rotation_get(const int32_t matrix[9]);
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Initialize a transformation matrix describing a pure clockwise
|
| 88 |
+
* rotation by the specified angle (in degrees).
|
| 89 |
+
*
|
| 90 |
+
* @param[out] matrix a transformation matrix (will be fully overwritten
|
| 91 |
+
* by this function)
|
| 92 |
+
* @param angle rotation angle in degrees.
|
| 93 |
+
*/
|
| 94 |
+
void av_display_rotation_set(int32_t matrix[9], double angle);
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Flip the input matrix horizontally and/or vertically.
|
| 98 |
+
*
|
| 99 |
+
* @param[in,out] matrix a transformation matrix
|
| 100 |
+
* @param hflip whether the matrix should be flipped horizontally
|
| 101 |
+
* @param vflip whether the matrix should be flipped vertically
|
| 102 |
+
*/
|
| 103 |
+
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip);
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* @}
|
| 107 |
+
*/
|
| 108 |
+
|
| 109 |
+
#endif /* AVUTIL_DISPLAY_H */
|
ffmpeg/include/libavutil/dovi_meta.h
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2020 Vacing Fang <vacingfang@tencent.com>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* DOVI configuration
|
| 24 |
+
*/
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_DOVI_META_H
|
| 28 |
+
#define AVUTIL_DOVI_META_H
|
| 29 |
+
|
| 30 |
+
#include <stdint.h>
|
| 31 |
+
#include <stddef.h>
|
| 32 |
+
|
| 33 |
+
#include "rational.h"
|
| 34 |
+
#include "csp.h"
|
| 35 |
+
|
| 36 |
+
/*
|
| 37 |
+
* DOVI configuration
|
| 38 |
+
* ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.1.2
|
| 39 |
+
dolby-vision-bitstreams-in-mpeg-2-transport-stream-multiplex-v1.2
|
| 40 |
+
* @code
|
| 41 |
+
* uint8_t dv_version_major, the major version number that the stream complies with
|
| 42 |
+
* uint8_t dv_version_minor, the minor version number that the stream complies with
|
| 43 |
+
* uint8_t dv_profile, the Dolby Vision profile
|
| 44 |
+
* uint8_t dv_level, the Dolby Vision level
|
| 45 |
+
* uint8_t rpu_present_flag
|
| 46 |
+
* uint8_t el_present_flag
|
| 47 |
+
* uint8_t bl_present_flag
|
| 48 |
+
* uint8_t dv_bl_signal_compatibility_id
|
| 49 |
+
* uint8_t dv_md_compression, the compression method in use
|
| 50 |
+
* @endcode
|
| 51 |
+
*
|
| 52 |
+
* @note The struct must be allocated with av_dovi_alloc() and
|
| 53 |
+
* its size is not a part of the public ABI.
|
| 54 |
+
*/
|
| 55 |
+
typedef struct AVDOVIDecoderConfigurationRecord {
|
| 56 |
+
uint8_t dv_version_major;
|
| 57 |
+
uint8_t dv_version_minor;
|
| 58 |
+
uint8_t dv_profile;
|
| 59 |
+
uint8_t dv_level;
|
| 60 |
+
uint8_t rpu_present_flag;
|
| 61 |
+
uint8_t el_present_flag;
|
| 62 |
+
uint8_t bl_present_flag;
|
| 63 |
+
uint8_t dv_bl_signal_compatibility_id;
|
| 64 |
+
uint8_t dv_md_compression;
|
| 65 |
+
} AVDOVIDecoderConfigurationRecord;
|
| 66 |
+
|
| 67 |
+
enum AVDOVICompression {
|
| 68 |
+
AV_DOVI_COMPRESSION_NONE = 0,
|
| 69 |
+
AV_DOVI_COMPRESSION_LIMITED = 1,
|
| 70 |
+
AV_DOVI_COMPRESSION_RESERVED = 2,
|
| 71 |
+
AV_DOVI_COMPRESSION_EXTENDED = 3,
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Allocate a AVDOVIDecoderConfigurationRecord structure and initialize its
|
| 76 |
+
* fields to default values.
|
| 77 |
+
*
|
| 78 |
+
* @return the newly allocated struct or NULL on failure
|
| 79 |
+
*/
|
| 80 |
+
AVDOVIDecoderConfigurationRecord *av_dovi_alloc(size_t *size);
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Dolby Vision RPU data header.
|
| 84 |
+
*
|
| 85 |
+
* @note sizeof(AVDOVIRpuDataHeader) is not part of the public ABI.
|
| 86 |
+
*/
|
| 87 |
+
typedef struct AVDOVIRpuDataHeader {
|
| 88 |
+
uint8_t rpu_type;
|
| 89 |
+
uint16_t rpu_format;
|
| 90 |
+
uint8_t vdr_rpu_profile;
|
| 91 |
+
uint8_t vdr_rpu_level;
|
| 92 |
+
uint8_t chroma_resampling_explicit_filter_flag;
|
| 93 |
+
uint8_t coef_data_type; /* informative, lavc always converts to fixed */
|
| 94 |
+
uint8_t coef_log2_denom;
|
| 95 |
+
uint8_t vdr_rpu_normalized_idc;
|
| 96 |
+
uint8_t bl_video_full_range_flag;
|
| 97 |
+
uint8_t bl_bit_depth; /* [8, 16] */
|
| 98 |
+
uint8_t el_bit_depth; /* [8, 16] */
|
| 99 |
+
uint8_t vdr_bit_depth; /* [8, 16] */
|
| 100 |
+
uint8_t spatial_resampling_filter_flag;
|
| 101 |
+
uint8_t el_spatial_resampling_filter_flag;
|
| 102 |
+
uint8_t disable_residual_flag;
|
| 103 |
+
uint8_t ext_mapping_idc_0_4; /* extended base layer inverse mapping indicator */
|
| 104 |
+
uint8_t ext_mapping_idc_5_7; /* reserved */
|
| 105 |
+
} AVDOVIRpuDataHeader;
|
| 106 |
+
|
| 107 |
+
enum AVDOVIMappingMethod {
|
| 108 |
+
AV_DOVI_MAPPING_POLYNOMIAL = 0,
|
| 109 |
+
AV_DOVI_MAPPING_MMR = 1,
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* Coefficients of a piece-wise function. The pieces of the function span the
|
| 114 |
+
* value ranges between two adjacent pivot values.
|
| 115 |
+
*/
|
| 116 |
+
#define AV_DOVI_MAX_PIECES 8
|
| 117 |
+
typedef struct AVDOVIReshapingCurve {
|
| 118 |
+
uint8_t num_pivots; /* [2, 9] */
|
| 119 |
+
uint16_t pivots[AV_DOVI_MAX_PIECES + 1]; /* sorted ascending */
|
| 120 |
+
enum AVDOVIMappingMethod mapping_idc[AV_DOVI_MAX_PIECES];
|
| 121 |
+
/* AV_DOVI_MAPPING_POLYNOMIAL */
|
| 122 |
+
uint8_t poly_order[AV_DOVI_MAX_PIECES]; /* [1, 2] */
|
| 123 |
+
int64_t poly_coef[AV_DOVI_MAX_PIECES][3]; /* x^0, x^1, x^2 */
|
| 124 |
+
/* AV_DOVI_MAPPING_MMR */
|
| 125 |
+
uint8_t mmr_order[AV_DOVI_MAX_PIECES]; /* [1, 3] */
|
| 126 |
+
int64_t mmr_constant[AV_DOVI_MAX_PIECES];
|
| 127 |
+
int64_t mmr_coef[AV_DOVI_MAX_PIECES][3/* order - 1 */][7];
|
| 128 |
+
} AVDOVIReshapingCurve;
|
| 129 |
+
|
| 130 |
+
enum AVDOVINLQMethod {
|
| 131 |
+
AV_DOVI_NLQ_NONE = -1,
|
| 132 |
+
AV_DOVI_NLQ_LINEAR_DZ = 0,
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* Coefficients of the non-linear inverse quantization. For the interpretation
|
| 137 |
+
* of these, see ETSI GS CCM 001.
|
| 138 |
+
*/
|
| 139 |
+
typedef struct AVDOVINLQParams {
|
| 140 |
+
uint16_t nlq_offset;
|
| 141 |
+
uint64_t vdr_in_max;
|
| 142 |
+
/* AV_DOVI_NLQ_LINEAR_DZ */
|
| 143 |
+
uint64_t linear_deadzone_slope;
|
| 144 |
+
uint64_t linear_deadzone_threshold;
|
| 145 |
+
} AVDOVINLQParams;
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* Dolby Vision RPU data mapping parameters.
|
| 149 |
+
*
|
| 150 |
+
* @note sizeof(AVDOVIDataMapping) is not part of the public ABI.
|
| 151 |
+
*/
|
| 152 |
+
typedef struct AVDOVIDataMapping {
|
| 153 |
+
uint8_t vdr_rpu_id;
|
| 154 |
+
uint8_t mapping_color_space;
|
| 155 |
+
uint8_t mapping_chroma_format_idc;
|
| 156 |
+
AVDOVIReshapingCurve curves[3]; /* per component */
|
| 157 |
+
|
| 158 |
+
/* Non-linear inverse quantization */
|
| 159 |
+
enum AVDOVINLQMethod nlq_method_idc;
|
| 160 |
+
uint32_t num_x_partitions;
|
| 161 |
+
uint32_t num_y_partitions;
|
| 162 |
+
AVDOVINLQParams nlq[3]; /* per component */
|
| 163 |
+
uint16_t nlq_pivots[2];
|
| 164 |
+
} AVDOVIDataMapping;
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Dolby Vision RPU colorspace metadata parameters.
|
| 168 |
+
*
|
| 169 |
+
* @note sizeof(AVDOVIColorMetadata) is not part of the public ABI.
|
| 170 |
+
*/
|
| 171 |
+
typedef struct AVDOVIColorMetadata {
|
| 172 |
+
uint8_t dm_metadata_id;
|
| 173 |
+
uint8_t scene_refresh_flag;
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Coefficients of the custom Dolby Vision IPT-PQ matrices. These are to be
|
| 177 |
+
* used instead of the matrices indicated by the frame's colorspace tags.
|
| 178 |
+
* The output of rgb_to_lms_matrix is to be fed into a BT.2020 LMS->RGB
|
| 179 |
+
* matrix based on a Hunt-Pointer-Estevez transform, but without any
|
| 180 |
+
* crosstalk. (See the definition of the ICtCp colorspace for more
|
| 181 |
+
* information.)
|
| 182 |
+
*/
|
| 183 |
+
AVRational ycc_to_rgb_matrix[9]; /* before PQ linearization */
|
| 184 |
+
AVRational ycc_to_rgb_offset[3]; /* input offset of neutral value */
|
| 185 |
+
AVRational rgb_to_lms_matrix[9]; /* after PQ linearization */
|
| 186 |
+
|
| 187 |
+
/**
|
| 188 |
+
* Extra signal metadata (see Dolby patents for more info).
|
| 189 |
+
*/
|
| 190 |
+
uint16_t signal_eotf;
|
| 191 |
+
uint16_t signal_eotf_param0;
|
| 192 |
+
uint16_t signal_eotf_param1;
|
| 193 |
+
uint32_t signal_eotf_param2;
|
| 194 |
+
uint8_t signal_bit_depth;
|
| 195 |
+
uint8_t signal_color_space;
|
| 196 |
+
uint8_t signal_chroma_format;
|
| 197 |
+
uint8_t signal_full_range_flag; /* [0, 3] */
|
| 198 |
+
uint16_t source_min_pq;
|
| 199 |
+
uint16_t source_max_pq;
|
| 200 |
+
uint16_t source_diagonal;
|
| 201 |
+
} AVDOVIColorMetadata;
|
| 202 |
+
|
| 203 |
+
typedef struct AVDOVIDmLevel1 {
|
| 204 |
+
/* Per-frame brightness metadata */
|
| 205 |
+
uint16_t min_pq;
|
| 206 |
+
uint16_t max_pq;
|
| 207 |
+
uint16_t avg_pq;
|
| 208 |
+
} AVDOVIDmLevel1;
|
| 209 |
+
|
| 210 |
+
typedef struct AVDOVIDmLevel2 {
|
| 211 |
+
/* Usually derived from level 8 (at different levels) */
|
| 212 |
+
uint16_t target_max_pq;
|
| 213 |
+
uint16_t trim_slope;
|
| 214 |
+
uint16_t trim_offset;
|
| 215 |
+
uint16_t trim_power;
|
| 216 |
+
uint16_t trim_chroma_weight;
|
| 217 |
+
uint16_t trim_saturation_gain;
|
| 218 |
+
int16_t ms_weight;
|
| 219 |
+
} AVDOVIDmLevel2;
|
| 220 |
+
|
| 221 |
+
typedef struct AVDOVIDmLevel3 {
|
| 222 |
+
uint16_t min_pq_offset;
|
| 223 |
+
uint16_t max_pq_offset;
|
| 224 |
+
uint16_t avg_pq_offset;
|
| 225 |
+
} AVDOVIDmLevel3;
|
| 226 |
+
|
| 227 |
+
typedef struct AVDOVIDmLevel4 {
|
| 228 |
+
uint16_t anchor_pq;
|
| 229 |
+
uint16_t anchor_power;
|
| 230 |
+
} AVDOVIDmLevel4;
|
| 231 |
+
|
| 232 |
+
typedef struct AVDOVIDmLevel5 {
|
| 233 |
+
/* Active area definition */
|
| 234 |
+
uint16_t left_offset;
|
| 235 |
+
uint16_t right_offset;
|
| 236 |
+
uint16_t top_offset;
|
| 237 |
+
uint16_t bottom_offset;
|
| 238 |
+
} AVDOVIDmLevel5;
|
| 239 |
+
|
| 240 |
+
typedef struct AVDOVIDmLevel6 {
|
| 241 |
+
/* Static HDR10 metadata */
|
| 242 |
+
uint16_t max_luminance;
|
| 243 |
+
uint16_t min_luminance;
|
| 244 |
+
uint16_t max_cll;
|
| 245 |
+
uint16_t max_fall;
|
| 246 |
+
} AVDOVIDmLevel6;
|
| 247 |
+
|
| 248 |
+
typedef struct AVDOVIDmLevel8 {
|
| 249 |
+
/* Extended version of level 2 */
|
| 250 |
+
uint8_t target_display_index;
|
| 251 |
+
uint16_t trim_slope;
|
| 252 |
+
uint16_t trim_offset;
|
| 253 |
+
uint16_t trim_power;
|
| 254 |
+
uint16_t trim_chroma_weight;
|
| 255 |
+
uint16_t trim_saturation_gain;
|
| 256 |
+
uint16_t ms_weight;
|
| 257 |
+
uint16_t target_mid_contrast;
|
| 258 |
+
uint16_t clip_trim;
|
| 259 |
+
uint8_t saturation_vector_field[6];
|
| 260 |
+
uint8_t hue_vector_field[6];
|
| 261 |
+
} AVDOVIDmLevel8;
|
| 262 |
+
|
| 263 |
+
typedef struct AVDOVIDmLevel9 {
|
| 264 |
+
/* Source display characteristics */
|
| 265 |
+
uint8_t source_primary_index;
|
| 266 |
+
AVColorPrimariesDesc source_display_primaries;
|
| 267 |
+
} AVDOVIDmLevel9;
|
| 268 |
+
|
| 269 |
+
typedef struct AVDOVIDmLevel10 {
|
| 270 |
+
/* Target display characteristics */
|
| 271 |
+
uint8_t target_display_index;
|
| 272 |
+
uint16_t target_max_pq;
|
| 273 |
+
uint16_t target_min_pq;
|
| 274 |
+
uint8_t target_primary_index;
|
| 275 |
+
AVColorPrimariesDesc target_display_primaries;
|
| 276 |
+
} AVDOVIDmLevel10;
|
| 277 |
+
|
| 278 |
+
typedef struct AVDOVIDmLevel11 {
|
| 279 |
+
uint8_t content_type;
|
| 280 |
+
uint8_t whitepoint;
|
| 281 |
+
uint8_t reference_mode_flag;
|
| 282 |
+
uint8_t sharpness;
|
| 283 |
+
uint8_t noise_reduction;
|
| 284 |
+
uint8_t mpeg_noise_reduction;
|
| 285 |
+
uint8_t frame_rate_conversion;
|
| 286 |
+
uint8_t brightness;
|
| 287 |
+
uint8_t color;
|
| 288 |
+
} AVDOVIDmLevel11;
|
| 289 |
+
|
| 290 |
+
typedef struct AVDOVIDmLevel254 {
|
| 291 |
+
/* DMv2 info block, always present in samples with DMv2 metadata */
|
| 292 |
+
uint8_t dm_mode;
|
| 293 |
+
uint8_t dm_version_index;
|
| 294 |
+
} AVDOVIDmLevel254;
|
| 295 |
+
|
| 296 |
+
typedef struct AVDOVIDmLevel255 {
|
| 297 |
+
/* Debug block, not really used in samples */
|
| 298 |
+
uint8_t dm_run_mode;
|
| 299 |
+
uint8_t dm_run_version;
|
| 300 |
+
uint8_t dm_debug[4];
|
| 301 |
+
} AVDOVIDmLevel255;
|
| 302 |
+
|
| 303 |
+
/**
|
| 304 |
+
* Dolby Vision metadata extension block. Dynamic extension blocks may change
|
| 305 |
+
* from frame to frame, while static blocks are constant throughout the entire
|
| 306 |
+
* sequence.
|
| 307 |
+
*
|
| 308 |
+
* @note sizeof(AVDOVIDmData) is not part of the public API.
|
| 309 |
+
*/
|
| 310 |
+
typedef struct AVDOVIDmData {
|
| 311 |
+
uint8_t level; /* [1, 255] */
|
| 312 |
+
union {
|
| 313 |
+
AVDOVIDmLevel1 l1; /* dynamic */
|
| 314 |
+
AVDOVIDmLevel2 l2; /* dynamic, may appear multiple times */
|
| 315 |
+
AVDOVIDmLevel3 l3; /* dynamic */
|
| 316 |
+
AVDOVIDmLevel4 l4; /* dynamic */
|
| 317 |
+
AVDOVIDmLevel5 l5; /* dynamic */
|
| 318 |
+
AVDOVIDmLevel6 l6; /* static */
|
| 319 |
+
/* level 7 is currently unused */
|
| 320 |
+
AVDOVIDmLevel8 l8; /* dynamic, may appear multiple times */
|
| 321 |
+
AVDOVIDmLevel9 l9; /* dynamic */
|
| 322 |
+
AVDOVIDmLevel10 l10; /* static, may appear multiple times */
|
| 323 |
+
AVDOVIDmLevel11 l11; /* dynamic */
|
| 324 |
+
AVDOVIDmLevel254 l254; /* static */
|
| 325 |
+
AVDOVIDmLevel255 l255; /* static */
|
| 326 |
+
};
|
| 327 |
+
} AVDOVIDmData;
|
| 328 |
+
|
| 329 |
+
/**
|
| 330 |
+
* Combined struct representing a combination of header, mapping and color
|
| 331 |
+
* metadata, for attaching to frames as side data.
|
| 332 |
+
*
|
| 333 |
+
* @note The struct must be allocated with av_dovi_metadata_alloc() and
|
| 334 |
+
* its size is not a part of the public ABI.
|
| 335 |
+
*/
|
| 336 |
+
|
| 337 |
+
typedef struct AVDOVIMetadata {
|
| 338 |
+
/**
|
| 339 |
+
* Offset in bytes from the beginning of this structure at which the
|
| 340 |
+
* respective structs start.
|
| 341 |
+
*/
|
| 342 |
+
size_t header_offset; /* AVDOVIRpuDataHeader */
|
| 343 |
+
size_t mapping_offset; /* AVDOVIDataMapping */
|
| 344 |
+
size_t color_offset; /* AVDOVIColorMetadata */
|
| 345 |
+
|
| 346 |
+
size_t ext_block_offset; /* offset to start of ext blocks array */
|
| 347 |
+
size_t ext_block_size; /* size per element */
|
| 348 |
+
int num_ext_blocks; /* number of extension blocks */
|
| 349 |
+
|
| 350 |
+
/* static limit on num_ext_blocks, derived from bitstream limitations */
|
| 351 |
+
#define AV_DOVI_MAX_EXT_BLOCKS 32
|
| 352 |
+
} AVDOVIMetadata;
|
| 353 |
+
|
| 354 |
+
static av_always_inline AVDOVIRpuDataHeader *
|
| 355 |
+
av_dovi_get_header(const AVDOVIMetadata *data)
|
| 356 |
+
{
|
| 357 |
+
return (AVDOVIRpuDataHeader *)((uint8_t *) data + data->header_offset);
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
static av_always_inline AVDOVIDataMapping *
|
| 361 |
+
av_dovi_get_mapping(const AVDOVIMetadata *data)
|
| 362 |
+
{
|
| 363 |
+
return (AVDOVIDataMapping *)((uint8_t *) data + data->mapping_offset);
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
static av_always_inline AVDOVIColorMetadata *
|
| 367 |
+
av_dovi_get_color(const AVDOVIMetadata *data)
|
| 368 |
+
{
|
| 369 |
+
return (AVDOVIColorMetadata *)((uint8_t *) data + data->color_offset);
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
static av_always_inline AVDOVIDmData *
|
| 373 |
+
av_dovi_get_ext(const AVDOVIMetadata *data, int index)
|
| 374 |
+
{
|
| 375 |
+
return (AVDOVIDmData *)((uint8_t *) data + data->ext_block_offset +
|
| 376 |
+
data->ext_block_size * index);
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
/**
|
| 380 |
+
* Find an extension block with a given level, or NULL. In the case of
|
| 381 |
+
* multiple extension blocks, only the first is returned.
|
| 382 |
+
*/
|
| 383 |
+
AVDOVIDmData *av_dovi_find_level(const AVDOVIMetadata *data, uint8_t level);
|
| 384 |
+
|
| 385 |
+
/**
|
| 386 |
+
* Allocate an AVDOVIMetadata structure and initialize its
|
| 387 |
+
* fields to default values.
|
| 388 |
+
*
|
| 389 |
+
* @param size If this parameter is non-NULL, the size in bytes of the
|
| 390 |
+
* allocated struct will be written here on success
|
| 391 |
+
*
|
| 392 |
+
* @return the newly allocated struct or NULL on failure
|
| 393 |
+
*/
|
| 394 |
+
AVDOVIMetadata *av_dovi_metadata_alloc(size_t *size);
|
| 395 |
+
|
| 396 |
+
#endif /* AVUTIL_DOVI_META_H */
|
ffmpeg/include/libavutil/downmix_info.h
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_DOWNMIX_INFO_H
|
| 22 |
+
#define AVUTIL_DOWNMIX_INFO_H
|
| 23 |
+
|
| 24 |
+
#include "frame.h"
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @file
|
| 28 |
+
* audio downmix medatata
|
| 29 |
+
*/
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @addtogroup lavu_audio
|
| 33 |
+
* @{
|
| 34 |
+
*/
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* @defgroup downmix_info Audio downmix metadata
|
| 38 |
+
* @{
|
| 39 |
+
*/
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Possible downmix types.
|
| 43 |
+
*/
|
| 44 |
+
enum AVDownmixType {
|
| 45 |
+
AV_DOWNMIX_TYPE_UNKNOWN, /**< Not indicated. */
|
| 46 |
+
AV_DOWNMIX_TYPE_LORO, /**< Lo/Ro 2-channel downmix (Stereo). */
|
| 47 |
+
AV_DOWNMIX_TYPE_LTRT, /**< Lt/Rt 2-channel downmix, Dolby Surround compatible. */
|
| 48 |
+
AV_DOWNMIX_TYPE_DPLII, /**< Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible. */
|
| 49 |
+
AV_DOWNMIX_TYPE_NB /**< Number of downmix types. Not part of ABI. */
|
| 50 |
+
};
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* This structure describes optional metadata relevant to a downmix procedure.
|
| 54 |
+
*
|
| 55 |
+
* All fields are set by the decoder to the value indicated in the audio
|
| 56 |
+
* bitstream (if present), or to a "sane" default otherwise.
|
| 57 |
+
*/
|
| 58 |
+
typedef struct AVDownmixInfo {
|
| 59 |
+
/**
|
| 60 |
+
* Type of downmix preferred by the mastering engineer.
|
| 61 |
+
*/
|
| 62 |
+
enum AVDownmixType preferred_downmix_type;
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Absolute scale factor representing the nominal level of the center
|
| 66 |
+
* channel during a regular downmix.
|
| 67 |
+
*/
|
| 68 |
+
double center_mix_level;
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Absolute scale factor representing the nominal level of the center
|
| 72 |
+
* channel during an Lt/Rt compatible downmix.
|
| 73 |
+
*/
|
| 74 |
+
double center_mix_level_ltrt;
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Absolute scale factor representing the nominal level of the surround
|
| 78 |
+
* channels during a regular downmix.
|
| 79 |
+
*/
|
| 80 |
+
double surround_mix_level;
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Absolute scale factor representing the nominal level of the surround
|
| 84 |
+
* channels during an Lt/Rt compatible downmix.
|
| 85 |
+
*/
|
| 86 |
+
double surround_mix_level_ltrt;
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Absolute scale factor representing the level at which the LFE data is
|
| 90 |
+
* mixed into L/R channels during downmixing.
|
| 91 |
+
*/
|
| 92 |
+
double lfe_mix_level;
|
| 93 |
+
} AVDownmixInfo;
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.
|
| 97 |
+
*
|
| 98 |
+
* If the side data is absent, it is created and added to the frame.
|
| 99 |
+
*
|
| 100 |
+
* @param frame the frame for which the side data is to be obtained or created
|
| 101 |
+
*
|
| 102 |
+
* @return the AVDownmixInfo structure to be edited by the caller, or NULL if
|
| 103 |
+
* the structure cannot be allocated.
|
| 104 |
+
*/
|
| 105 |
+
AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame);
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* @}
|
| 109 |
+
*/
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* @}
|
| 113 |
+
*/
|
| 114 |
+
|
| 115 |
+
#endif /* AVUTIL_DOWNMIX_INFO_H */
|
ffmpeg/include/libavutil/encryption_info.h
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_ENCRYPTION_INFO_H
|
| 20 |
+
#define AVUTIL_ENCRYPTION_INFO_H
|
| 21 |
+
|
| 22 |
+
#include <stddef.h>
|
| 23 |
+
#include <stdint.h>
|
| 24 |
+
|
| 25 |
+
typedef struct AVSubsampleEncryptionInfo {
|
| 26 |
+
/** The number of bytes that are clear. */
|
| 27 |
+
unsigned int bytes_of_clear_data;
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* The number of bytes that are protected. If using pattern encryption,
|
| 31 |
+
* the pattern applies to only the protected bytes; if not using pattern
|
| 32 |
+
* encryption, all these bytes are encrypted.
|
| 33 |
+
*/
|
| 34 |
+
unsigned int bytes_of_protected_data;
|
| 35 |
+
} AVSubsampleEncryptionInfo;
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* This describes encryption info for a packet. This contains frame-specific
|
| 39 |
+
* info for how to decrypt the packet before passing it to the decoder.
|
| 40 |
+
*
|
| 41 |
+
* The size of this struct is not part of the public ABI.
|
| 42 |
+
*/
|
| 43 |
+
typedef struct AVEncryptionInfo {
|
| 44 |
+
/** The fourcc encryption scheme, in big-endian byte order. */
|
| 45 |
+
uint32_t scheme;
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Only used for pattern encryption. This is the number of 16-byte blocks
|
| 49 |
+
* that are encrypted.
|
| 50 |
+
*/
|
| 51 |
+
uint32_t crypt_byte_block;
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Only used for pattern encryption. This is the number of 16-byte blocks
|
| 55 |
+
* that are clear.
|
| 56 |
+
*/
|
| 57 |
+
uint32_t skip_byte_block;
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* The ID of the key used to encrypt the packet. This should always be
|
| 61 |
+
* 16 bytes long, but may be changed in the future.
|
| 62 |
+
*/
|
| 63 |
+
uint8_t *key_id;
|
| 64 |
+
uint32_t key_id_size;
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* The initialization vector. This may have been zero-filled to be the
|
| 68 |
+
* correct block size. This should always be 16 bytes long, but may be
|
| 69 |
+
* changed in the future.
|
| 70 |
+
*/
|
| 71 |
+
uint8_t *iv;
|
| 72 |
+
uint32_t iv_size;
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* An array of subsample encryption info specifying how parts of the sample
|
| 76 |
+
* are encrypted. If there are no subsamples, then the whole sample is
|
| 77 |
+
* encrypted.
|
| 78 |
+
*/
|
| 79 |
+
AVSubsampleEncryptionInfo *subsamples;
|
| 80 |
+
uint32_t subsample_count;
|
| 81 |
+
} AVEncryptionInfo;
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* This describes info used to initialize an encryption key system.
|
| 85 |
+
*
|
| 86 |
+
* The size of this struct is not part of the public ABI.
|
| 87 |
+
*/
|
| 88 |
+
typedef struct AVEncryptionInitInfo {
|
| 89 |
+
/**
|
| 90 |
+
* A unique identifier for the key system this is for, can be NULL if it
|
| 91 |
+
* is not known. This should always be 16 bytes, but may change in the
|
| 92 |
+
* future.
|
| 93 |
+
*/
|
| 94 |
+
uint8_t* system_id;
|
| 95 |
+
uint32_t system_id_size;
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* An array of key IDs this initialization data is for. All IDs are the
|
| 99 |
+
* same length. Can be NULL if there are no known key IDs.
|
| 100 |
+
*/
|
| 101 |
+
uint8_t** key_ids;
|
| 102 |
+
/** The number of key IDs. */
|
| 103 |
+
uint32_t num_key_ids;
|
| 104 |
+
/**
|
| 105 |
+
* The number of bytes in each key ID. This should always be 16, but may
|
| 106 |
+
* change in the future.
|
| 107 |
+
*/
|
| 108 |
+
uint32_t key_id_size;
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* Key-system specific initialization data. This data is copied directly
|
| 112 |
+
* from the file and the format depends on the specific key system. This
|
| 113 |
+
* can be NULL if there is no initialization data; in that case, there
|
| 114 |
+
* will be at least one key ID.
|
| 115 |
+
*/
|
| 116 |
+
uint8_t* data;
|
| 117 |
+
uint32_t data_size;
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* An optional pointer to the next initialization info in the list.
|
| 121 |
+
*/
|
| 122 |
+
struct AVEncryptionInitInfo *next;
|
| 123 |
+
} AVEncryptionInitInfo;
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* Allocates an AVEncryptionInfo structure and sub-pointers to hold the given
|
| 127 |
+
* number of subsamples. This will allocate pointers for the key ID, IV,
|
| 128 |
+
* and subsample entries, set the size members, and zero-initialize the rest.
|
| 129 |
+
*
|
| 130 |
+
* @param subsample_count The number of subsamples.
|
| 131 |
+
* @param key_id_size The number of bytes in the key ID, should be 16.
|
| 132 |
+
* @param iv_size The number of bytes in the IV, should be 16.
|
| 133 |
+
*
|
| 134 |
+
* @return The new AVEncryptionInfo structure, or NULL on error.
|
| 135 |
+
*/
|
| 136 |
+
AVEncryptionInfo *av_encryption_info_alloc(uint32_t subsample_count, uint32_t key_id_size, uint32_t iv_size);
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* Allocates an AVEncryptionInfo structure with a copy of the given data.
|
| 140 |
+
* @return The new AVEncryptionInfo structure, or NULL on error.
|
| 141 |
+
*/
|
| 142 |
+
AVEncryptionInfo *av_encryption_info_clone(const AVEncryptionInfo *info);
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* Frees the given encryption info object. This MUST NOT be used to free the
|
| 146 |
+
* side-data data pointer, that should use normal side-data methods.
|
| 147 |
+
*/
|
| 148 |
+
void av_encryption_info_free(AVEncryptionInfo *info);
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* Creates a copy of the AVEncryptionInfo that is contained in the given side
|
| 152 |
+
* data. The resulting object should be passed to av_encryption_info_free()
|
| 153 |
+
* when done.
|
| 154 |
+
*
|
| 155 |
+
* @return The new AVEncryptionInfo structure, or NULL on error.
|
| 156 |
+
*/
|
| 157 |
+
AVEncryptionInfo *av_encryption_info_get_side_data(const uint8_t *side_data, size_t side_data_size);
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* Allocates and initializes side data that holds a copy of the given encryption
|
| 161 |
+
* info. The resulting pointer should be either freed using av_free or given
|
| 162 |
+
* to av_packet_add_side_data().
|
| 163 |
+
*
|
| 164 |
+
* @return The new side-data pointer, or NULL.
|
| 165 |
+
*/
|
| 166 |
+
uint8_t *av_encryption_info_add_side_data(
|
| 167 |
+
const AVEncryptionInfo *info, size_t *side_data_size);
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
/**
|
| 171 |
+
* Allocates an AVEncryptionInitInfo structure and sub-pointers to hold the
|
| 172 |
+
* given sizes. This will allocate pointers and set all the fields.
|
| 173 |
+
*
|
| 174 |
+
* @return The new AVEncryptionInitInfo structure, or NULL on error.
|
| 175 |
+
*/
|
| 176 |
+
AVEncryptionInitInfo *av_encryption_init_info_alloc(
|
| 177 |
+
uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size);
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* Frees the given encryption init info object. This MUST NOT be used to free
|
| 181 |
+
* the side-data data pointer, that should use normal side-data methods.
|
| 182 |
+
*/
|
| 183 |
+
void av_encryption_init_info_free(AVEncryptionInitInfo* info);
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* Creates a copy of the AVEncryptionInitInfo that is contained in the given
|
| 187 |
+
* side data. The resulting object should be passed to
|
| 188 |
+
* av_encryption_init_info_free() when done.
|
| 189 |
+
*
|
| 190 |
+
* @return The new AVEncryptionInitInfo structure, or NULL on error.
|
| 191 |
+
*/
|
| 192 |
+
AVEncryptionInitInfo *av_encryption_init_info_get_side_data(
|
| 193 |
+
const uint8_t* side_data, size_t side_data_size);
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
* Allocates and initializes side data that holds a copy of the given encryption
|
| 197 |
+
* init info. The resulting pointer should be either freed using av_free or
|
| 198 |
+
* given to av_packet_add_side_data().
|
| 199 |
+
*
|
| 200 |
+
* @return The new side-data pointer, or NULL.
|
| 201 |
+
*/
|
| 202 |
+
uint8_t *av_encryption_init_info_add_side_data(
|
| 203 |
+
const AVEncryptionInitInfo *info, size_t *side_data_size);
|
| 204 |
+
|
| 205 |
+
#endif /* AVUTIL_ENCRYPTION_INFO_H */
|
ffmpeg/include/libavutil/error.h
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/**
|
| 20 |
+
* @file
|
| 21 |
+
* error code definitions
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
#ifndef AVUTIL_ERROR_H
|
| 25 |
+
#define AVUTIL_ERROR_H
|
| 26 |
+
|
| 27 |
+
#include <errno.h>
|
| 28 |
+
#include <stddef.h>
|
| 29 |
+
|
| 30 |
+
#include "macros.h"
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* @addtogroup lavu_error
|
| 34 |
+
*
|
| 35 |
+
* @{
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
/* error handling */
|
| 40 |
+
#if EDOM > 0
|
| 41 |
+
#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
|
| 42 |
+
#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
|
| 43 |
+
#else
|
| 44 |
+
/* Some platforms have E* and errno already negated. */
|
| 45 |
+
#define AVERROR(e) (e)
|
| 46 |
+
#define AVUNERROR(e) (e)
|
| 47 |
+
#endif
|
| 48 |
+
|
| 49 |
+
#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d))
|
| 50 |
+
|
| 51 |
+
#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
|
| 52 |
+
#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
|
| 53 |
+
#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
|
| 54 |
+
#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
|
| 55 |
+
#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
|
| 56 |
+
#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
|
| 57 |
+
#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
|
| 58 |
+
#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
|
| 59 |
+
#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
|
| 60 |
+
#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
|
| 61 |
+
#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
|
| 62 |
+
#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
|
| 63 |
+
#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
|
| 64 |
+
#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
|
| 65 |
+
#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
|
| 66 |
+
|
| 67 |
+
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
|
| 68 |
+
/**
|
| 69 |
+
* This is semantically identical to AVERROR_BUG
|
| 70 |
+
* it has been introduced in Libav after our AVERROR_BUG and with a modified value.
|
| 71 |
+
*/
|
| 72 |
+
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
|
| 73 |
+
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
|
| 74 |
+
#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
|
| 75 |
+
#define AVERROR_INPUT_CHANGED (-0x636e6701) ///< Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
|
| 76 |
+
#define AVERROR_OUTPUT_CHANGED (-0x636e6702) ///< Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
|
| 77 |
+
/* HTTP & RTSP errors */
|
| 78 |
+
#define AVERROR_HTTP_BAD_REQUEST FFERRTAG(0xF8,'4','0','0')
|
| 79 |
+
#define AVERROR_HTTP_UNAUTHORIZED FFERRTAG(0xF8,'4','0','1')
|
| 80 |
+
#define AVERROR_HTTP_FORBIDDEN FFERRTAG(0xF8,'4','0','3')
|
| 81 |
+
#define AVERROR_HTTP_NOT_FOUND FFERRTAG(0xF8,'4','0','4')
|
| 82 |
+
#define AVERROR_HTTP_TOO_MANY_REQUESTS FFERRTAG(0xF8,'4','2','9')
|
| 83 |
+
#define AVERROR_HTTP_OTHER_4XX FFERRTAG(0xF8,'4','X','X')
|
| 84 |
+
#define AVERROR_HTTP_SERVER_ERROR FFERRTAG(0xF8,'5','X','X')
|
| 85 |
+
|
| 86 |
+
#define AV_ERROR_MAX_STRING_SIZE 64
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Put a description of the AVERROR code errnum in errbuf.
|
| 90 |
+
* In case of failure the global variable errno is set to indicate the
|
| 91 |
+
* error. Even in case of failure av_strerror() will print a generic
|
| 92 |
+
* error message indicating the errnum provided to errbuf.
|
| 93 |
+
*
|
| 94 |
+
* @param errnum error code to describe
|
| 95 |
+
* @param errbuf buffer to which description is written
|
| 96 |
+
* @param errbuf_size the size in bytes of errbuf
|
| 97 |
+
* @return 0 on success, a negative value if a description for errnum
|
| 98 |
+
* cannot be found
|
| 99 |
+
*/
|
| 100 |
+
int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* Fill the provided buffer with a string containing an error string
|
| 104 |
+
* corresponding to the AVERROR code errnum.
|
| 105 |
+
*
|
| 106 |
+
* @param errbuf a buffer
|
| 107 |
+
* @param errbuf_size size in bytes of errbuf
|
| 108 |
+
* @param errnum error code to describe
|
| 109 |
+
* @return the buffer in input, filled with the error description
|
| 110 |
+
* @see av_strerror()
|
| 111 |
+
*/
|
| 112 |
+
static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum)
|
| 113 |
+
{
|
| 114 |
+
av_strerror(errnum, errbuf, errbuf_size);
|
| 115 |
+
return errbuf;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* Convenience macro, the return value should be used only directly in
|
| 120 |
+
* function arguments but never stand-alone.
|
| 121 |
+
*/
|
| 122 |
+
#define av_err2str(errnum) \
|
| 123 |
+
av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* @}
|
| 127 |
+
*/
|
| 128 |
+
|
| 129 |
+
#endif /* AVUTIL_ERROR_H */
|
ffmpeg/include/libavutil/eval.h
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* simple arithmetic expression evaluator
|
| 24 |
+
*/
|
| 25 |
+
|
| 26 |
+
#ifndef AVUTIL_EVAL_H
|
| 27 |
+
#define AVUTIL_EVAL_H
|
| 28 |
+
|
| 29 |
+
typedef struct AVExpr AVExpr;
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* Parse and evaluate an expression.
|
| 33 |
+
* Note, this is significantly slower than av_expr_eval().
|
| 34 |
+
*
|
| 35 |
+
* @param res a pointer to a double where is put the result value of
|
| 36 |
+
* the expression, or NAN in case of error
|
| 37 |
+
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
|
| 38 |
+
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
|
| 39 |
+
* @param const_values a zero terminated array of values for the identifiers from const_names
|
| 40 |
+
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
|
| 41 |
+
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
|
| 42 |
+
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
| 43 |
+
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
| 44 |
+
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
| 45 |
+
* @param log_offset log level offset, can be used to silence error messages
|
| 46 |
+
* @param log_ctx parent logging context
|
| 47 |
+
* @return >= 0 in case of success, a negative value corresponding to an
|
| 48 |
+
* AVERROR code otherwise
|
| 49 |
+
*/
|
| 50 |
+
int av_expr_parse_and_eval(double *res, const char *s,
|
| 51 |
+
const char * const *const_names, const double *const_values,
|
| 52 |
+
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
| 53 |
+
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
| 54 |
+
void *opaque, int log_offset, void *log_ctx);
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Parse an expression.
|
| 58 |
+
*
|
| 59 |
+
* @param expr a pointer where is put an AVExpr containing the parsed
|
| 60 |
+
* value in case of successful parsing, or NULL otherwise.
|
| 61 |
+
* The pointed to AVExpr must be freed with av_expr_free() by the user
|
| 62 |
+
* when it is not needed anymore.
|
| 63 |
+
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
|
| 64 |
+
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
|
| 65 |
+
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
|
| 66 |
+
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
|
| 67 |
+
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
| 68 |
+
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
| 69 |
+
* @param log_offset log level offset, can be used to silence error messages
|
| 70 |
+
* @param log_ctx parent logging context
|
| 71 |
+
* @return >= 0 in case of success, a negative value corresponding to an
|
| 72 |
+
* AVERROR code otherwise
|
| 73 |
+
*/
|
| 74 |
+
int av_expr_parse(AVExpr **expr, const char *s,
|
| 75 |
+
const char * const *const_names,
|
| 76 |
+
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
| 77 |
+
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
| 78 |
+
int log_offset, void *log_ctx);
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Evaluate a previously parsed expression.
|
| 82 |
+
*
|
| 83 |
+
* @param e the AVExpr to evaluate
|
| 84 |
+
* @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
|
| 85 |
+
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
| 86 |
+
* @return the value of the expression
|
| 87 |
+
*/
|
| 88 |
+
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* Track the presence of variables and their number of occurrences in a parsed expression
|
| 92 |
+
*
|
| 93 |
+
* @param e the AVExpr to track variables in
|
| 94 |
+
* @param counter a zero-initialized array where the count of each variable will be stored
|
| 95 |
+
* @param size size of array
|
| 96 |
+
* @return 0 on success, a negative value indicates that no expression or array was passed
|
| 97 |
+
* or size was zero
|
| 98 |
+
*/
|
| 99 |
+
int av_expr_count_vars(AVExpr *e, unsigned *counter, int size);
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Track the presence of user provided functions and their number of occurrences
|
| 103 |
+
* in a parsed expression.
|
| 104 |
+
*
|
| 105 |
+
* @param e the AVExpr to track user provided functions in
|
| 106 |
+
* @param counter a zero-initialized array where the count of each function will be stored
|
| 107 |
+
* if you passed 5 functions with 2 arguments to av_expr_parse()
|
| 108 |
+
* then for arg=2 this will use up to 5 entries.
|
| 109 |
+
* @param size size of array
|
| 110 |
+
* @param arg number of arguments the counted functions have
|
| 111 |
+
* @return 0 on success, a negative value indicates that no expression or array was passed
|
| 112 |
+
* or size was zero
|
| 113 |
+
*/
|
| 114 |
+
int av_expr_count_func(AVExpr *e, unsigned *counter, int size, int arg);
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* Free a parsed expression previously created with av_expr_parse().
|
| 118 |
+
*/
|
| 119 |
+
void av_expr_free(AVExpr *e);
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Parse the string in numstr and return its value as a double. If
|
| 123 |
+
* the string is empty, contains only whitespaces, or does not contain
|
| 124 |
+
* an initial substring that has the expected syntax for a
|
| 125 |
+
* floating-point number, no conversion is performed. In this case,
|
| 126 |
+
* returns a value of zero and the value returned in tail is the value
|
| 127 |
+
* of numstr.
|
| 128 |
+
*
|
| 129 |
+
* @param numstr a string representing a number, may contain one of
|
| 130 |
+
* the International System number postfixes, for example 'K', 'M',
|
| 131 |
+
* 'G'. If 'i' is appended after the postfix, powers of 2 are used
|
| 132 |
+
* instead of powers of 10. The 'B' postfix multiplies the value by
|
| 133 |
+
* 8, and can be appended after another postfix or used alone. This
|
| 134 |
+
* allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
|
| 135 |
+
* @param tail if non-NULL puts here the pointer to the char next
|
| 136 |
+
* after the last parsed character
|
| 137 |
+
*/
|
| 138 |
+
double av_strtod(const char *numstr, char **tail);
|
| 139 |
+
|
| 140 |
+
#endif /* AVUTIL_EVAL_H */
|
ffmpeg/include/libavutil/executor.h
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (C) 2023 Nuo Mi
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_EXECUTOR_H
|
| 22 |
+
#define AVUTIL_EXECUTOR_H
|
| 23 |
+
|
| 24 |
+
typedef struct AVExecutor AVExecutor;
|
| 25 |
+
typedef struct AVTask AVTask;
|
| 26 |
+
|
| 27 |
+
struct AVTask {
|
| 28 |
+
AVTask *next;
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
typedef struct AVTaskCallbacks {
|
| 32 |
+
void *user_data;
|
| 33 |
+
|
| 34 |
+
int local_context_size;
|
| 35 |
+
|
| 36 |
+
// return 1 if a's priority > b's priority
|
| 37 |
+
int (*priority_higher)(const AVTask *a, const AVTask *b);
|
| 38 |
+
|
| 39 |
+
// task is ready for run
|
| 40 |
+
int (*ready)(const AVTask *t, void *user_data);
|
| 41 |
+
|
| 42 |
+
// run the task
|
| 43 |
+
int (*run)(AVTask *t, void *local_context, void *user_data);
|
| 44 |
+
} AVTaskCallbacks;
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Alloc executor
|
| 48 |
+
* @param callbacks callback structure for executor
|
| 49 |
+
* @param thread_count worker thread number, 0 for run on caller's thread directly
|
| 50 |
+
* @return return the executor
|
| 51 |
+
*/
|
| 52 |
+
AVExecutor* av_executor_alloc(const AVTaskCallbacks *callbacks, int thread_count);
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Free executor
|
| 56 |
+
* @param e pointer to executor
|
| 57 |
+
*/
|
| 58 |
+
void av_executor_free(AVExecutor **e);
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Add task to executor
|
| 62 |
+
* @param e pointer to executor
|
| 63 |
+
* @param t pointer to task. If NULL, it will wakeup one work thread
|
| 64 |
+
*/
|
| 65 |
+
void av_executor_execute(AVExecutor *e, AVTask *t);
|
| 66 |
+
|
| 67 |
+
#endif //AVUTIL_EXECUTOR_H
|
ffmpeg/include/libavutil/ffversion.h
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Automatically generated by version.sh, do not manually edit! */
|
| 2 |
+
#ifndef AVUTIL_FFVERSION_H
|
| 3 |
+
#define AVUTIL_FFVERSION_H
|
| 4 |
+
#define FFMPEG_VERSION "N-118274-gc0fbb6d5b7-20250110"
|
| 5 |
+
#endif /* AVUTIL_FFVERSION_H */
|
ffmpeg/include/libavutil/fifo.h
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/**
|
| 20 |
+
* @file
|
| 21 |
+
* @ingroup lavu_fifo
|
| 22 |
+
* A generic FIFO API
|
| 23 |
+
*/
|
| 24 |
+
|
| 25 |
+
#ifndef AVUTIL_FIFO_H
|
| 26 |
+
#define AVUTIL_FIFO_H
|
| 27 |
+
|
| 28 |
+
#include <stddef.h>
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @defgroup lavu_fifo AVFifo
|
| 32 |
+
* @ingroup lavu_data
|
| 33 |
+
*
|
| 34 |
+
* @{
|
| 35 |
+
* A generic FIFO API
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
typedef struct AVFifo AVFifo;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Callback for writing or reading from a FIFO, passed to (and invoked from) the
|
| 42 |
+
* av_fifo_*_cb() functions. It may be invoked multiple times from a single
|
| 43 |
+
* av_fifo_*_cb() call and may process less data than the maximum size indicated
|
| 44 |
+
* by nb_elems.
|
| 45 |
+
*
|
| 46 |
+
* @param opaque the opaque pointer provided to the av_fifo_*_cb() function
|
| 47 |
+
* @param buf the buffer for reading or writing the data, depending on which
|
| 48 |
+
* av_fifo_*_cb function is called
|
| 49 |
+
* @param nb_elems On entry contains the maximum number of elements that can be
|
| 50 |
+
* read from / written into buf. On success, the callback should
|
| 51 |
+
* update it to contain the number of elements actually written.
|
| 52 |
+
*
|
| 53 |
+
* @return 0 on success, a negative error code on failure (will be returned from
|
| 54 |
+
* the invoking av_fifo_*_cb() function)
|
| 55 |
+
*/
|
| 56 |
+
typedef int AVFifoCB(void *opaque, void *buf, size_t *nb_elems);
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Automatically resize the FIFO on writes, so that the data fits. This
|
| 60 |
+
* automatic resizing happens up to a limit that can be modified with
|
| 61 |
+
* av_fifo_auto_grow_limit().
|
| 62 |
+
*/
|
| 63 |
+
#define AV_FIFO_FLAG_AUTO_GROW (1 << 0)
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Allocate and initialize an AVFifo with a given element size.
|
| 67 |
+
*
|
| 68 |
+
* @param elems initial number of elements that can be stored in the FIFO
|
| 69 |
+
* @param elem_size Size in bytes of a single element. Further operations on
|
| 70 |
+
* the returned FIFO will implicitly use this element size.
|
| 71 |
+
* @param flags a combination of AV_FIFO_FLAG_*
|
| 72 |
+
*
|
| 73 |
+
* @return newly-allocated AVFifo on success, a negative error code on failure
|
| 74 |
+
*/
|
| 75 |
+
AVFifo *av_fifo_alloc2(size_t elems, size_t elem_size,
|
| 76 |
+
unsigned int flags);
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* @return Element size for FIFO operations. This element size is set at
|
| 80 |
+
* FIFO allocation and remains constant during its lifetime
|
| 81 |
+
*/
|
| 82 |
+
size_t av_fifo_elem_size(const AVFifo *f);
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* Set the maximum size (in elements) to which the FIFO can be resized
|
| 86 |
+
* automatically. Has no effect unless AV_FIFO_FLAG_AUTO_GROW is used.
|
| 87 |
+
*/
|
| 88 |
+
void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems);
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* @return number of elements available for reading from the given FIFO.
|
| 92 |
+
*/
|
| 93 |
+
size_t av_fifo_can_read(const AVFifo *f);
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* @return Number of elements that can be written into the given FIFO without
|
| 97 |
+
* growing it.
|
| 98 |
+
*
|
| 99 |
+
* In other words, this number of elements or less is guaranteed to fit
|
| 100 |
+
* into the FIFO. More data may be written when the
|
| 101 |
+
* AV_FIFO_FLAG_AUTO_GROW flag was specified at FIFO creation, but this
|
| 102 |
+
* may involve memory allocation, which can fail.
|
| 103 |
+
*/
|
| 104 |
+
size_t av_fifo_can_write(const AVFifo *f);
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* Enlarge an AVFifo.
|
| 108 |
+
*
|
| 109 |
+
* On success, the FIFO will be large enough to hold exactly
|
| 110 |
+
* inc + av_fifo_can_read() + av_fifo_can_write()
|
| 111 |
+
* elements. In case of failure, the old FIFO is kept unchanged.
|
| 112 |
+
*
|
| 113 |
+
* @param f AVFifo to resize
|
| 114 |
+
* @param inc number of elements to allocate for, in addition to the current
|
| 115 |
+
* allocated size
|
| 116 |
+
* @return a non-negative number on success, a negative error code on failure
|
| 117 |
+
*/
|
| 118 |
+
int av_fifo_grow2(AVFifo *f, size_t inc);
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Write data into a FIFO.
|
| 122 |
+
*
|
| 123 |
+
* In case nb_elems > av_fifo_can_write(f) and the AV_FIFO_FLAG_AUTO_GROW flag
|
| 124 |
+
* was not specified at FIFO creation, nothing is written and an error
|
| 125 |
+
* is returned.
|
| 126 |
+
*
|
| 127 |
+
* Calling function is guaranteed to succeed if nb_elems <= av_fifo_can_write(f).
|
| 128 |
+
*
|
| 129 |
+
* @param f the FIFO buffer
|
| 130 |
+
* @param buf Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be
|
| 131 |
+
* read from buf on success.
|
| 132 |
+
* @param nb_elems number of elements to write into FIFO
|
| 133 |
+
*
|
| 134 |
+
* @return a non-negative number on success, a negative error code on failure
|
| 135 |
+
*/
|
| 136 |
+
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems);
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* Write data from a user-provided callback into a FIFO.
|
| 140 |
+
*
|
| 141 |
+
* @param f the FIFO buffer
|
| 142 |
+
* @param read_cb Callback supplying the data to the FIFO. May be called
|
| 143 |
+
* multiple times.
|
| 144 |
+
* @param opaque opaque user data to be provided to read_cb
|
| 145 |
+
* @param nb_elems Should point to the maximum number of elements that can be
|
| 146 |
+
* written. Will be updated to contain the number of elements
|
| 147 |
+
* actually written.
|
| 148 |
+
*
|
| 149 |
+
* @return non-negative number on success, a negative error code on failure
|
| 150 |
+
*/
|
| 151 |
+
int av_fifo_write_from_cb(AVFifo *f, AVFifoCB read_cb,
|
| 152 |
+
void *opaque, size_t *nb_elems);
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Read data from a FIFO.
|
| 156 |
+
*
|
| 157 |
+
* In case nb_elems > av_fifo_can_read(f), nothing is read and an error
|
| 158 |
+
* is returned.
|
| 159 |
+
*
|
| 160 |
+
* @param f the FIFO buffer
|
| 161 |
+
* @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes
|
| 162 |
+
* will be written into buf on success.
|
| 163 |
+
* @param nb_elems number of elements to read from FIFO
|
| 164 |
+
*
|
| 165 |
+
* @return a non-negative number on success, a negative error code on failure
|
| 166 |
+
*/
|
| 167 |
+
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems);
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Feed data from a FIFO into a user-provided callback.
|
| 171 |
+
*
|
| 172 |
+
* @param f the FIFO buffer
|
| 173 |
+
* @param write_cb Callback the data will be supplied to. May be called
|
| 174 |
+
* multiple times.
|
| 175 |
+
* @param opaque opaque user data to be provided to write_cb
|
| 176 |
+
* @param nb_elems Should point to the maximum number of elements that can be
|
| 177 |
+
* read. Will be updated to contain the total number of elements
|
| 178 |
+
* actually sent to the callback.
|
| 179 |
+
*
|
| 180 |
+
* @return non-negative number on success, a negative error code on failure
|
| 181 |
+
*/
|
| 182 |
+
int av_fifo_read_to_cb(AVFifo *f, AVFifoCB write_cb,
|
| 183 |
+
void *opaque, size_t *nb_elems);
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* Read data from a FIFO without modifying FIFO state.
|
| 187 |
+
*
|
| 188 |
+
* Returns an error if an attempt is made to peek to nonexistent elements
|
| 189 |
+
* (i.e. if offset + nb_elems is larger than av_fifo_can_read(f)).
|
| 190 |
+
*
|
| 191 |
+
* @param f the FIFO buffer
|
| 192 |
+
* @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes
|
| 193 |
+
* will be written into buf.
|
| 194 |
+
* @param nb_elems number of elements to read from FIFO
|
| 195 |
+
* @param offset number of initial elements to skip.
|
| 196 |
+
*
|
| 197 |
+
* @return a non-negative number on success, a negative error code on failure
|
| 198 |
+
*/
|
| 199 |
+
int av_fifo_peek(const AVFifo *f, void *buf, size_t nb_elems, size_t offset);
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Feed data from a FIFO into a user-provided callback.
|
| 203 |
+
*
|
| 204 |
+
* @param f the FIFO buffer
|
| 205 |
+
* @param write_cb Callback the data will be supplied to. May be called
|
| 206 |
+
* multiple times.
|
| 207 |
+
* @param opaque opaque user data to be provided to write_cb
|
| 208 |
+
* @param nb_elems Should point to the maximum number of elements that can be
|
| 209 |
+
* read. Will be updated to contain the total number of elements
|
| 210 |
+
* actually sent to the callback.
|
| 211 |
+
* @param offset number of initial elements to skip; offset + *nb_elems must not
|
| 212 |
+
* be larger than av_fifo_can_read(f).
|
| 213 |
+
*
|
| 214 |
+
* @return a non-negative number on success, a negative error code on failure
|
| 215 |
+
*/
|
| 216 |
+
int av_fifo_peek_to_cb(const AVFifo *f, AVFifoCB write_cb, void *opaque,
|
| 217 |
+
size_t *nb_elems, size_t offset);
|
| 218 |
+
|
| 219 |
+
/**
|
| 220 |
+
* Discard the specified amount of data from an AVFifo.
|
| 221 |
+
* @param size number of elements to discard, MUST NOT be larger than
|
| 222 |
+
* av_fifo_can_read(f)
|
| 223 |
+
*/
|
| 224 |
+
void av_fifo_drain2(AVFifo *f, size_t size);
|
| 225 |
+
|
| 226 |
+
/*
|
| 227 |
+
* Empty the AVFifo.
|
| 228 |
+
* @param f AVFifo to reset
|
| 229 |
+
*/
|
| 230 |
+
void av_fifo_reset2(AVFifo *f);
|
| 231 |
+
|
| 232 |
+
/**
|
| 233 |
+
* Free an AVFifo and reset pointer to NULL.
|
| 234 |
+
* @param f Pointer to an AVFifo to free. *f == NULL is allowed.
|
| 235 |
+
*/
|
| 236 |
+
void av_fifo_freep2(AVFifo **f);
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* @}
|
| 240 |
+
*/
|
| 241 |
+
|
| 242 |
+
#endif /* AVUTIL_FIFO_H */
|
ffmpeg/include/libavutil/file.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_FILE_H
|
| 20 |
+
#define AVUTIL_FILE_H
|
| 21 |
+
|
| 22 |
+
#include <stddef.h>
|
| 23 |
+
#include <stdint.h>
|
| 24 |
+
|
| 25 |
+
#include "attributes.h"
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @file
|
| 29 |
+
* Misc file utilities.
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Read the file with name filename, and put its content in a newly
|
| 34 |
+
* allocated buffer or map it with mmap() when available.
|
| 35 |
+
* In case of success set *bufptr to the read or mmapped buffer, and
|
| 36 |
+
* *size to the size in bytes of the buffer in *bufptr.
|
| 37 |
+
* Unlike mmap this function succeeds with zero sized files, in this
|
| 38 |
+
* case *bufptr will be set to NULL and *size will be set to 0.
|
| 39 |
+
* The returned buffer must be released with av_file_unmap().
|
| 40 |
+
*
|
| 41 |
+
* @param filename path to the file
|
| 42 |
+
* @param[out] bufptr pointee is set to the mapped or allocated buffer
|
| 43 |
+
* @param[out] size pointee is set to the size in bytes of the buffer
|
| 44 |
+
* @param log_offset loglevel offset used for logging
|
| 45 |
+
* @param log_ctx context used for logging
|
| 46 |
+
* @return a non negative number in case of success, a negative value
|
| 47 |
+
* corresponding to an AVERROR error code in case of failure
|
| 48 |
+
*/
|
| 49 |
+
av_warn_unused_result
|
| 50 |
+
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
| 51 |
+
int log_offset, void *log_ctx);
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Unmap or free the buffer bufptr created by av_file_map().
|
| 55 |
+
*
|
| 56 |
+
* @param bufptr the buffer previously created with av_file_map()
|
| 57 |
+
* @param size size in bytes of bufptr, must be the same as returned
|
| 58 |
+
* by av_file_map()
|
| 59 |
+
*/
|
| 60 |
+
void av_file_unmap(uint8_t *bufptr, size_t size);
|
| 61 |
+
|
| 62 |
+
#endif /* AVUTIL_FILE_H */
|
ffmpeg/include/libavutil/film_grain_params.h
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_FILM_GRAIN_PARAMS_H
|
| 20 |
+
#define AVUTIL_FILM_GRAIN_PARAMS_H
|
| 21 |
+
|
| 22 |
+
#include "frame.h"
|
| 23 |
+
|
| 24 |
+
enum AVFilmGrainParamsType {
|
| 25 |
+
AV_FILM_GRAIN_PARAMS_NONE = 0,
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
|
| 29 |
+
*/
|
| 30 |
+
AV_FILM_GRAIN_PARAMS_AV1,
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* The union is valid when interpreted as AVFilmGrainH274Params (codec.h274)
|
| 34 |
+
*/
|
| 35 |
+
AV_FILM_GRAIN_PARAMS_H274,
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* This structure describes how to handle film grain synthesis for AOM codecs.
|
| 40 |
+
*
|
| 41 |
+
* @note The struct must be allocated as part of AVFilmGrainParams using
|
| 42 |
+
* av_film_grain_params_alloc(). Its size is not a part of the public ABI.
|
| 43 |
+
*/
|
| 44 |
+
typedef struct AVFilmGrainAOMParams {
|
| 45 |
+
/**
|
| 46 |
+
* Number of points, and the scale and value for each point of the
|
| 47 |
+
* piecewise linear scaling function for the uma plane.
|
| 48 |
+
*/
|
| 49 |
+
int num_y_points;
|
| 50 |
+
uint8_t y_points[14][2 /* value, scaling */];
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* Signals whether to derive the chroma scaling function from the luma.
|
| 54 |
+
* Not equivalent to copying the luma values and scales.
|
| 55 |
+
*/
|
| 56 |
+
int chroma_scaling_from_luma;
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* If chroma_scaling_from_luma is set to 0, signals the chroma scaling
|
| 60 |
+
* function parameters.
|
| 61 |
+
*/
|
| 62 |
+
int num_uv_points[2 /* cb, cr */];
|
| 63 |
+
uint8_t uv_points[2 /* cb, cr */][10][2 /* value, scaling */];
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Specifies the shift applied to the chroma components. For AV1, its within
|
| 67 |
+
* [8; 11] and determines the range and quantization of the film grain.
|
| 68 |
+
*/
|
| 69 |
+
int scaling_shift;
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Specifies the auto-regression lag.
|
| 73 |
+
*/
|
| 74 |
+
int ar_coeff_lag;
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Luma auto-regression coefficients. The number of coefficients is given by
|
| 78 |
+
* 2 * ar_coeff_lag * (ar_coeff_lag + 1).
|
| 79 |
+
*/
|
| 80 |
+
int8_t ar_coeffs_y[24];
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Chroma auto-regression coefficients. The number of coefficients is given by
|
| 84 |
+
* 2 * ar_coeff_lag * (ar_coeff_lag + 1) + !!num_y_points.
|
| 85 |
+
*/
|
| 86 |
+
int8_t ar_coeffs_uv[2 /* cb, cr */][25];
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Specifies the range of the auto-regressive coefficients. Values of 6,
|
| 90 |
+
* 7, 8 and so on represent a range of [-2, 2), [-1, 1), [-0.5, 0.5) and
|
| 91 |
+
* so on. For AV1 must be between 6 and 9.
|
| 92 |
+
*/
|
| 93 |
+
int ar_coeff_shift;
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Signals the down shift applied to the generated gaussian numbers during
|
| 97 |
+
* synthesis.
|
| 98 |
+
*/
|
| 99 |
+
int grain_scale_shift;
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Specifies the luma/chroma multipliers for the index to the component
|
| 103 |
+
* scaling function.
|
| 104 |
+
*/
|
| 105 |
+
int uv_mult[2 /* cb, cr */];
|
| 106 |
+
int uv_mult_luma[2 /* cb, cr */];
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Offset used for component scaling function. For AV1 its a 9-bit value
|
| 110 |
+
* with a range [-256, 255]
|
| 111 |
+
*/
|
| 112 |
+
int uv_offset[2 /* cb, cr */];
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* Signals whether to overlap film grain blocks.
|
| 116 |
+
*/
|
| 117 |
+
int overlap_flag;
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* Signals to clip to limited color levels after film grain application.
|
| 121 |
+
*/
|
| 122 |
+
int limit_output_range;
|
| 123 |
+
} AVFilmGrainAOMParams;
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* This structure describes how to handle film grain synthesis for codecs using
|
| 127 |
+
* the ITU-T H.274 Versatile suplemental enhancement information message.
|
| 128 |
+
*
|
| 129 |
+
* @note The struct must be allocated as part of AVFilmGrainParams using
|
| 130 |
+
* av_film_grain_params_alloc(). Its size is not a part of the public ABI.
|
| 131 |
+
*/
|
| 132 |
+
typedef struct AVFilmGrainH274Params {
|
| 133 |
+
/**
|
| 134 |
+
* Specifies the film grain simulation mode.
|
| 135 |
+
* 0 = Frequency filtering, 1 = Auto-regression
|
| 136 |
+
*/
|
| 137 |
+
int model_id;
|
| 138 |
+
|
| 139 |
+
#if FF_API_H274_FILM_GRAIN_VCS
|
| 140 |
+
/**
|
| 141 |
+
* TODO: On this ABI bump, please also re-order the fields in
|
| 142 |
+
* AVFilmGrainParams (see below)
|
| 143 |
+
*/
|
| 144 |
+
|
| 145 |
+
/**
|
| 146 |
+
* Specifies the bit depth used for the luma component.
|
| 147 |
+
*
|
| 148 |
+
* @deprecated use AVFilmGrainParams.bit_depth_luma.
|
| 149 |
+
*/
|
| 150 |
+
attribute_deprecated
|
| 151 |
+
int bit_depth_luma;
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Specifies the bit depth used for the chroma components.
|
| 155 |
+
*
|
| 156 |
+
* @deprecated use AVFilmGrainParams.bit_depth_chroma.
|
| 157 |
+
*/
|
| 158 |
+
attribute_deprecated
|
| 159 |
+
int bit_depth_chroma;
|
| 160 |
+
|
| 161 |
+
/**
|
| 162 |
+
* Specifies the video signal characteristics.
|
| 163 |
+
*
|
| 164 |
+
* @deprecated use AVFilmGrainParams.color_{range,primaries,trc,space}.
|
| 165 |
+
*/
|
| 166 |
+
attribute_deprecated
|
| 167 |
+
enum AVColorRange color_range;
|
| 168 |
+
attribute_deprecated
|
| 169 |
+
enum AVColorPrimaries color_primaries;
|
| 170 |
+
attribute_deprecated
|
| 171 |
+
enum AVColorTransferCharacteristic color_trc;
|
| 172 |
+
attribute_deprecated
|
| 173 |
+
enum AVColorSpace color_space;
|
| 174 |
+
#endif
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Specifies the blending mode used to blend the simulated film grain
|
| 178 |
+
* with the decoded images.
|
| 179 |
+
*
|
| 180 |
+
* 0 = Additive, 1 = Multiplicative
|
| 181 |
+
*/
|
| 182 |
+
int blending_mode_id;
|
| 183 |
+
|
| 184 |
+
/**
|
| 185 |
+
* Specifies a scale factor used in the film grain characterization equations.
|
| 186 |
+
*/
|
| 187 |
+
int log2_scale_factor;
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* Indicates if the modelling of film grain for a given component is present.
|
| 191 |
+
*/
|
| 192 |
+
int component_model_present[3 /* y, cb, cr */];
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* Specifies the number of intensity intervals for which a specific set of
|
| 196 |
+
* model values has been estimated, with a range of [1, 256].
|
| 197 |
+
*/
|
| 198 |
+
uint16_t num_intensity_intervals[3 /* y, cb, cr */];
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* Specifies the number of model values present for each intensity interval
|
| 202 |
+
* in which the film grain has been modelled, with a range of [1, 6].
|
| 203 |
+
*/
|
| 204 |
+
uint8_t num_model_values[3 /* y, cb, cr */];
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Specifies the lower ounds of each intensity interval for whichthe set of
|
| 208 |
+
* model values applies for the component.
|
| 209 |
+
*/
|
| 210 |
+
uint8_t intensity_interval_lower_bound[3 /* y, cb, cr */][256 /* intensity interval */];
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* Specifies the upper bound of each intensity interval for which the set of
|
| 214 |
+
* model values applies for the component.
|
| 215 |
+
*/
|
| 216 |
+
uint8_t intensity_interval_upper_bound[3 /* y, cb, cr */][256 /* intensity interval */];
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* Specifies the model values for the component for each intensity interval.
|
| 220 |
+
* - When model_id == 0, the following applies:
|
| 221 |
+
* For comp_model_value[y], the range of values is [0, 2^bit_depth_luma - 1]
|
| 222 |
+
* For comp_model_value[cb..cr], the range of values is [0, 2^bit_depth_chroma - 1]
|
| 223 |
+
* - Otherwise, the following applies:
|
| 224 |
+
* For comp_model_value[y], the range of values is [-2^(bit_depth_luma - 1), 2^(bit_depth_luma - 1) - 1]
|
| 225 |
+
* For comp_model_value[cb..cr], the range of values is [-2^(bit_depth_chroma - 1), 2^(bit_depth_chroma - 1) - 1]
|
| 226 |
+
*/
|
| 227 |
+
int16_t comp_model_value[3 /* y, cb, cr */][256 /* intensity interval */][6 /* model value */];
|
| 228 |
+
} AVFilmGrainH274Params;
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* This structure describes how to handle film grain synthesis in video
|
| 232 |
+
* for specific codecs. Must be present on every frame where film grain is
|
| 233 |
+
* meant to be synthesised for correct presentation.
|
| 234 |
+
*
|
| 235 |
+
* @note The struct must be allocated with av_film_grain_params_alloc() and
|
| 236 |
+
* its size is not a part of the public ABI.
|
| 237 |
+
*/
|
| 238 |
+
typedef struct AVFilmGrainParams {
|
| 239 |
+
/**
|
| 240 |
+
* Specifies the codec for which this structure is valid.
|
| 241 |
+
*/
|
| 242 |
+
enum AVFilmGrainParamsType type;
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* Seed to use for the synthesis process, if the codec allows for it.
|
| 246 |
+
*
|
| 247 |
+
* @note For H.264, this refers to `pic_offset` as defined in
|
| 248 |
+
* SMPTE RDD 5-2006.
|
| 249 |
+
*/
|
| 250 |
+
uint64_t seed;
|
| 251 |
+
|
| 252 |
+
/**
|
| 253 |
+
* Additional fields may be added both here and in any structure included.
|
| 254 |
+
* If a codec's film grain structure differs slightly over another
|
| 255 |
+
* codec's, fields within may change meaning depending on the type.
|
| 256 |
+
*
|
| 257 |
+
* TODO: Move this to the end of the structure, at the next ABI bump.
|
| 258 |
+
*/
|
| 259 |
+
union {
|
| 260 |
+
AVFilmGrainAOMParams aom;
|
| 261 |
+
AVFilmGrainH274Params h274;
|
| 262 |
+
} codec;
|
| 263 |
+
|
| 264 |
+
/**
|
| 265 |
+
* Intended display resolution. May be 0 if the codec does not specify
|
| 266 |
+
* any restrictions.
|
| 267 |
+
*/
|
| 268 |
+
|
| 269 |
+
int width, height;
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
* Intended subsampling ratio, or 0 for luma-only streams.
|
| 273 |
+
*/
|
| 274 |
+
int subsampling_x, subsampling_y;
|
| 275 |
+
|
| 276 |
+
/**
|
| 277 |
+
* Intended video signal characteristics.
|
| 278 |
+
*/
|
| 279 |
+
enum AVColorRange color_range;
|
| 280 |
+
enum AVColorPrimaries color_primaries;
|
| 281 |
+
enum AVColorTransferCharacteristic color_trc;
|
| 282 |
+
enum AVColorSpace color_space;
|
| 283 |
+
|
| 284 |
+
/**
|
| 285 |
+
* Intended bit depth, or 0 for unknown/unspecified.
|
| 286 |
+
*/
|
| 287 |
+
int bit_depth_luma;
|
| 288 |
+
int bit_depth_chroma;
|
| 289 |
+
|
| 290 |
+
} AVFilmGrainParams;
|
| 291 |
+
|
| 292 |
+
/**
|
| 293 |
+
* Allocate an AVFilmGrainParams structure and set its fields to
|
| 294 |
+
* default values. The resulting struct can be freed using av_freep().
|
| 295 |
+
* If size is not NULL it will be set to the number of bytes allocated.
|
| 296 |
+
*
|
| 297 |
+
* @return An AVFilmGrainParams filled with default values or NULL
|
| 298 |
+
* on failure.
|
| 299 |
+
*/
|
| 300 |
+
AVFilmGrainParams *av_film_grain_params_alloc(size_t *size);
|
| 301 |
+
|
| 302 |
+
/**
|
| 303 |
+
* Allocate a complete AVFilmGrainParams and add it to the frame.
|
| 304 |
+
*
|
| 305 |
+
* @param frame The frame which side data is added to.
|
| 306 |
+
*
|
| 307 |
+
* @return The AVFilmGrainParams structure to be filled by caller.
|
| 308 |
+
*/
|
| 309 |
+
AVFilmGrainParams *av_film_grain_params_create_side_data(AVFrame *frame);
|
| 310 |
+
|
| 311 |
+
/**
|
| 312 |
+
* Select the most appropriate film grain parameters set for the frame,
|
| 313 |
+
* taking into account the frame's format, resolution and video signal
|
| 314 |
+
* characteristics.
|
| 315 |
+
*
|
| 316 |
+
* @note, for H.274, this may select a film grain parameter set with
|
| 317 |
+
* greater chroma resolution than the frame. Users should take care to
|
| 318 |
+
* correctly adjust the chroma grain frequency to the frame.
|
| 319 |
+
*/
|
| 320 |
+
const AVFilmGrainParams *av_film_grain_params_select(const AVFrame *frame);
|
| 321 |
+
|
| 322 |
+
#endif /* AVUTIL_FILM_GRAIN_PARAMS_H */
|
ffmpeg/include/libavutil/frame.h
ADDED
|
@@ -0,0 +1,1202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/**
|
| 20 |
+
* @file
|
| 21 |
+
* @ingroup lavu_frame
|
| 22 |
+
* reference-counted frame API
|
| 23 |
+
*/
|
| 24 |
+
|
| 25 |
+
#ifndef AVUTIL_FRAME_H
|
| 26 |
+
#define AVUTIL_FRAME_H
|
| 27 |
+
|
| 28 |
+
#include <stddef.h>
|
| 29 |
+
#include <stdint.h>
|
| 30 |
+
|
| 31 |
+
#include "avutil.h"
|
| 32 |
+
#include "buffer.h"
|
| 33 |
+
#include "channel_layout.h"
|
| 34 |
+
#include "dict.h"
|
| 35 |
+
#include "rational.h"
|
| 36 |
+
#include "samplefmt.h"
|
| 37 |
+
#include "pixfmt.h"
|
| 38 |
+
#include "version.h"
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @defgroup lavu_frame AVFrame
|
| 43 |
+
* @ingroup lavu_data
|
| 44 |
+
*
|
| 45 |
+
* @{
|
| 46 |
+
* AVFrame is an abstraction for reference-counted raw multimedia data.
|
| 47 |
+
*/
|
| 48 |
+
|
| 49 |
+
enum AVFrameSideDataType {
|
| 50 |
+
/**
|
| 51 |
+
* The data is the AVPanScan struct defined in libavcodec.
|
| 52 |
+
*/
|
| 53 |
+
AV_FRAME_DATA_PANSCAN,
|
| 54 |
+
/**
|
| 55 |
+
* ATSC A53 Part 4 Closed Captions.
|
| 56 |
+
* A53 CC bitstream is stored as uint8_t in AVFrameSideData.data.
|
| 57 |
+
* The number of bytes of CC data is AVFrameSideData.size.
|
| 58 |
+
*/
|
| 59 |
+
AV_FRAME_DATA_A53_CC,
|
| 60 |
+
/**
|
| 61 |
+
* Stereoscopic 3d metadata.
|
| 62 |
+
* The data is the AVStereo3D struct defined in libavutil/stereo3d.h.
|
| 63 |
+
*/
|
| 64 |
+
AV_FRAME_DATA_STEREO3D,
|
| 65 |
+
/**
|
| 66 |
+
* The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
|
| 67 |
+
*/
|
| 68 |
+
AV_FRAME_DATA_MATRIXENCODING,
|
| 69 |
+
/**
|
| 70 |
+
* Metadata relevant to a downmix procedure.
|
| 71 |
+
* The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h.
|
| 72 |
+
*/
|
| 73 |
+
AV_FRAME_DATA_DOWNMIX_INFO,
|
| 74 |
+
/**
|
| 75 |
+
* ReplayGain information in the form of the AVReplayGain struct.
|
| 76 |
+
*/
|
| 77 |
+
AV_FRAME_DATA_REPLAYGAIN,
|
| 78 |
+
/**
|
| 79 |
+
* This side data contains a 3x3 transformation matrix describing an affine
|
| 80 |
+
* transformation that needs to be applied to the frame for correct
|
| 81 |
+
* presentation.
|
| 82 |
+
*
|
| 83 |
+
* See libavutil/display.h for a detailed description of the data.
|
| 84 |
+
*/
|
| 85 |
+
AV_FRAME_DATA_DISPLAYMATRIX,
|
| 86 |
+
/**
|
| 87 |
+
* Active Format Description data consisting of a single byte as specified
|
| 88 |
+
* in ETSI TS 101 154 using AVActiveFormatDescription enum.
|
| 89 |
+
*/
|
| 90 |
+
AV_FRAME_DATA_AFD,
|
| 91 |
+
/**
|
| 92 |
+
* Motion vectors exported by some codecs (on demand through the export_mvs
|
| 93 |
+
* flag set in the libavcodec AVCodecContext flags2 option).
|
| 94 |
+
* The data is the AVMotionVector struct defined in
|
| 95 |
+
* libavutil/motion_vector.h.
|
| 96 |
+
*/
|
| 97 |
+
AV_FRAME_DATA_MOTION_VECTORS,
|
| 98 |
+
/**
|
| 99 |
+
* Recommmends skipping the specified number of samples. This is exported
|
| 100 |
+
* only if the "skip_manual" AVOption is set in libavcodec.
|
| 101 |
+
* This has the same format as AV_PKT_DATA_SKIP_SAMPLES.
|
| 102 |
+
* @code
|
| 103 |
+
* u32le number of samples to skip from start of this packet
|
| 104 |
+
* u32le number of samples to skip from end of this packet
|
| 105 |
+
* u8 reason for start skip
|
| 106 |
+
* u8 reason for end skip (0=padding silence, 1=convergence)
|
| 107 |
+
* @endcode
|
| 108 |
+
*/
|
| 109 |
+
AV_FRAME_DATA_SKIP_SAMPLES,
|
| 110 |
+
/**
|
| 111 |
+
* This side data must be associated with an audio frame and corresponds to
|
| 112 |
+
* enum AVAudioServiceType defined in avcodec.h.
|
| 113 |
+
*/
|
| 114 |
+
AV_FRAME_DATA_AUDIO_SERVICE_TYPE,
|
| 115 |
+
/**
|
| 116 |
+
* Mastering display metadata associated with a video frame. The payload is
|
| 117 |
+
* an AVMasteringDisplayMetadata type and contains information about the
|
| 118 |
+
* mastering display color volume.
|
| 119 |
+
*/
|
| 120 |
+
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
|
| 121 |
+
/**
|
| 122 |
+
* The GOP timecode in 25 bit timecode format. Data format is 64-bit integer.
|
| 123 |
+
* This is set on the first frame of a GOP that has a temporal reference of 0.
|
| 124 |
+
*/
|
| 125 |
+
AV_FRAME_DATA_GOP_TIMECODE,
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* The data represents the AVSphericalMapping structure defined in
|
| 129 |
+
* libavutil/spherical.h.
|
| 130 |
+
*/
|
| 131 |
+
AV_FRAME_DATA_SPHERICAL,
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Content light level (based on CTA-861.3). This payload contains data in
|
| 135 |
+
* the form of the AVContentLightMetadata struct.
|
| 136 |
+
*/
|
| 137 |
+
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* The data contains an ICC profile as an opaque octet buffer following the
|
| 141 |
+
* format described by ISO 15076-1 with an optional name defined in the
|
| 142 |
+
* metadata key entry "name".
|
| 143 |
+
*/
|
| 144 |
+
AV_FRAME_DATA_ICC_PROFILE,
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t
|
| 148 |
+
* where the first uint32_t describes how many (1-3) of the other timecodes are used.
|
| 149 |
+
* The timecode format is described in the documentation of av_timecode_get_smpte_from_framenum()
|
| 150 |
+
* function in libavutil/timecode.h.
|
| 151 |
+
*/
|
| 152 |
+
AV_FRAME_DATA_S12M_TIMECODE,
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* HDR dynamic metadata associated with a video frame. The payload is
|
| 156 |
+
* an AVDynamicHDRPlus type and contains information for color
|
| 157 |
+
* volume transform - application 4 of SMPTE 2094-40:2016 standard.
|
| 158 |
+
*/
|
| 159 |
+
AV_FRAME_DATA_DYNAMIC_HDR_PLUS,
|
| 160 |
+
|
| 161 |
+
/**
|
| 162 |
+
* Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of
|
| 163 |
+
* array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size.
|
| 164 |
+
*/
|
| 165 |
+
AV_FRAME_DATA_REGIONS_OF_INTEREST,
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Encoding parameters for a video frame, as described by AVVideoEncParams.
|
| 169 |
+
*/
|
| 170 |
+
AV_FRAME_DATA_VIDEO_ENC_PARAMS,
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* User data unregistered metadata associated with a video frame.
|
| 174 |
+
* This is the H.26[45] UDU SEI message, and shouldn't be used for any other purpose
|
| 175 |
+
* The data is stored as uint8_t in AVFrameSideData.data which is 16 bytes of
|
| 176 |
+
* uuid_iso_iec_11578 followed by AVFrameSideData.size - 16 bytes of user_data_payload_byte.
|
| 177 |
+
*/
|
| 178 |
+
AV_FRAME_DATA_SEI_UNREGISTERED,
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* Film grain parameters for a frame, described by AVFilmGrainParams.
|
| 182 |
+
* Must be present for every frame which should have film grain applied.
|
| 183 |
+
*
|
| 184 |
+
* May be present multiple times, for example when there are multiple
|
| 185 |
+
* alternative parameter sets for different video signal characteristics.
|
| 186 |
+
* The user should select the most appropriate set for the application.
|
| 187 |
+
*/
|
| 188 |
+
AV_FRAME_DATA_FILM_GRAIN_PARAMS,
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* Bounding boxes for object detection and classification,
|
| 192 |
+
* as described by AVDetectionBBoxHeader.
|
| 193 |
+
*/
|
| 194 |
+
AV_FRAME_DATA_DETECTION_BBOXES,
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* Dolby Vision RPU raw data, suitable for passing to x265
|
| 198 |
+
* or other libraries. Array of uint8_t, with NAL emulation
|
| 199 |
+
* bytes intact.
|
| 200 |
+
*/
|
| 201 |
+
AV_FRAME_DATA_DOVI_RPU_BUFFER,
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* Parsed Dolby Vision metadata, suitable for passing to a software
|
| 205 |
+
* implementation. The payload is the AVDOVIMetadata struct defined in
|
| 206 |
+
* libavutil/dovi_meta.h.
|
| 207 |
+
*/
|
| 208 |
+
AV_FRAME_DATA_DOVI_METADATA,
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* HDR Vivid dynamic metadata associated with a video frame. The payload is
|
| 212 |
+
* an AVDynamicHDRVivid type and contains information for color
|
| 213 |
+
* volume transform - CUVA 005.1-2021.
|
| 214 |
+
*/
|
| 215 |
+
AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* Ambient viewing environment metadata, as defined by H.274.
|
| 219 |
+
*/
|
| 220 |
+
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
|
| 221 |
+
|
| 222 |
+
/**
|
| 223 |
+
* Provide encoder-specific hinting information about changed/unchanged
|
| 224 |
+
* portions of a frame. It can be used to pass information about which
|
| 225 |
+
* macroblocks can be skipped because they didn't change from the
|
| 226 |
+
* corresponding ones in the previous frame. This could be useful for
|
| 227 |
+
* applications which know this information in advance to speed up
|
| 228 |
+
* encoding.
|
| 229 |
+
*/
|
| 230 |
+
AV_FRAME_DATA_VIDEO_HINT,
|
| 231 |
+
|
| 232 |
+
/**
|
| 233 |
+
* Raw LCEVC payload data, as a uint8_t array, with NAL emulation
|
| 234 |
+
* bytes intact.
|
| 235 |
+
*/
|
| 236 |
+
AV_FRAME_DATA_LCEVC,
|
| 237 |
+
|
| 238 |
+
/**
|
| 239 |
+
* This side data must be associated with a video frame.
|
| 240 |
+
* The presence of this side data indicates that the video stream is
|
| 241 |
+
* composed of multiple views (e.g. stereoscopic 3D content,
|
| 242 |
+
* cf. H.264 Annex H or H.265 Annex G).
|
| 243 |
+
* The data is an int storing the view ID.
|
| 244 |
+
*/
|
| 245 |
+
AV_FRAME_DATA_VIEW_ID,
|
| 246 |
+
};
|
| 247 |
+
|
| 248 |
+
enum AVActiveFormatDescription {
|
| 249 |
+
AV_AFD_SAME = 8,
|
| 250 |
+
AV_AFD_4_3 = 9,
|
| 251 |
+
AV_AFD_16_9 = 10,
|
| 252 |
+
AV_AFD_14_9 = 11,
|
| 253 |
+
AV_AFD_4_3_SP_14_9 = 13,
|
| 254 |
+
AV_AFD_16_9_SP_14_9 = 14,
|
| 255 |
+
AV_AFD_SP_4_3 = 15,
|
| 256 |
+
};
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
* Structure to hold side data for an AVFrame.
|
| 261 |
+
*
|
| 262 |
+
* sizeof(AVFrameSideData) is not a part of the public ABI, so new fields may be added
|
| 263 |
+
* to the end with a minor bump.
|
| 264 |
+
*/
|
| 265 |
+
typedef struct AVFrameSideData {
|
| 266 |
+
enum AVFrameSideDataType type;
|
| 267 |
+
uint8_t *data;
|
| 268 |
+
size_t size;
|
| 269 |
+
AVDictionary *metadata;
|
| 270 |
+
AVBufferRef *buf;
|
| 271 |
+
} AVFrameSideData;
|
| 272 |
+
|
| 273 |
+
enum AVSideDataProps {
|
| 274 |
+
/**
|
| 275 |
+
* The side data type can be used in stream-global structures.
|
| 276 |
+
* Side data types without this property are only meaningful on per-frame
|
| 277 |
+
* basis.
|
| 278 |
+
*/
|
| 279 |
+
AV_SIDE_DATA_PROP_GLOBAL = (1 << 0),
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* Multiple instances of this side data type can be meaningfully present in
|
| 283 |
+
* a single side data array.
|
| 284 |
+
*/
|
| 285 |
+
AV_SIDE_DATA_PROP_MULTI = (1 << 1),
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* Side data depends on the video dimensions. Side data with this property
|
| 289 |
+
* loses its meaning when rescaling or cropping the image, unless
|
| 290 |
+
* either recomputed or adjusted to the new resolution.
|
| 291 |
+
*/
|
| 292 |
+
AV_SIDE_DATA_PROP_SIZE_DEPENDENT = (1 << 2),
|
| 293 |
+
|
| 294 |
+
/**
|
| 295 |
+
* Side data depends on the video color space. Side data with this property
|
| 296 |
+
* loses its meaning when changing the video color encoding, e.g. by
|
| 297 |
+
* adapting to a different set of primaries or transfer characteristics.
|
| 298 |
+
*/
|
| 299 |
+
AV_SIDE_DATA_PROP_COLOR_DEPENDENT = (1 << 3),
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
/**
|
| 303 |
+
* This struct describes the properties of a side data type. Its instance
|
| 304 |
+
* corresponding to a given type can be obtained from av_frame_side_data_desc().
|
| 305 |
+
*/
|
| 306 |
+
typedef struct AVSideDataDescriptor {
|
| 307 |
+
/**
|
| 308 |
+
* Human-readable side data description.
|
| 309 |
+
*/
|
| 310 |
+
const char *name;
|
| 311 |
+
|
| 312 |
+
/**
|
| 313 |
+
* Side data property flags, a combination of AVSideDataProps values.
|
| 314 |
+
*/
|
| 315 |
+
unsigned props;
|
| 316 |
+
} AVSideDataDescriptor;
|
| 317 |
+
|
| 318 |
+
/**
|
| 319 |
+
* Structure describing a single Region Of Interest.
|
| 320 |
+
*
|
| 321 |
+
* When multiple regions are defined in a single side-data block, they
|
| 322 |
+
* should be ordered from most to least important - some encoders are only
|
| 323 |
+
* capable of supporting a limited number of distinct regions, so will have
|
| 324 |
+
* to truncate the list.
|
| 325 |
+
*
|
| 326 |
+
* When overlapping regions are defined, the first region containing a given
|
| 327 |
+
* area of the frame applies.
|
| 328 |
+
*/
|
| 329 |
+
typedef struct AVRegionOfInterest {
|
| 330 |
+
/**
|
| 331 |
+
* Must be set to the size of this data structure (that is,
|
| 332 |
+
* sizeof(AVRegionOfInterest)).
|
| 333 |
+
*/
|
| 334 |
+
uint32_t self_size;
|
| 335 |
+
/**
|
| 336 |
+
* Distance in pixels from the top edge of the frame to the top and
|
| 337 |
+
* bottom edges and from the left edge of the frame to the left and
|
| 338 |
+
* right edges of the rectangle defining this region of interest.
|
| 339 |
+
*
|
| 340 |
+
* The constraints on a region are encoder dependent, so the region
|
| 341 |
+
* actually affected may be slightly larger for alignment or other
|
| 342 |
+
* reasons.
|
| 343 |
+
*/
|
| 344 |
+
int top;
|
| 345 |
+
int bottom;
|
| 346 |
+
int left;
|
| 347 |
+
int right;
|
| 348 |
+
/**
|
| 349 |
+
* Quantisation offset.
|
| 350 |
+
*
|
| 351 |
+
* Must be in the range -1 to +1. A value of zero indicates no quality
|
| 352 |
+
* change. A negative value asks for better quality (less quantisation),
|
| 353 |
+
* while a positive value asks for worse quality (greater quantisation).
|
| 354 |
+
*
|
| 355 |
+
* The range is calibrated so that the extreme values indicate the
|
| 356 |
+
* largest possible offset - if the rest of the frame is encoded with the
|
| 357 |
+
* worst possible quality, an offset of -1 indicates that this region
|
| 358 |
+
* should be encoded with the best possible quality anyway. Intermediate
|
| 359 |
+
* values are then interpolated in some codec-dependent way.
|
| 360 |
+
*
|
| 361 |
+
* For example, in 10-bit H.264 the quantisation parameter varies between
|
| 362 |
+
* -12 and 51. A typical qoffset value of -1/10 therefore indicates that
|
| 363 |
+
* this region should be encoded with a QP around one-tenth of the full
|
| 364 |
+
* range better than the rest of the frame. So, if most of the frame
|
| 365 |
+
* were to be encoded with a QP of around 30, this region would get a QP
|
| 366 |
+
* of around 24 (an offset of approximately -1/10 * (51 - -12) = -6.3).
|
| 367 |
+
* An extreme value of -1 would indicate that this region should be
|
| 368 |
+
* encoded with the best possible quality regardless of the treatment of
|
| 369 |
+
* the rest of the frame - that is, should be encoded at a QP of -12.
|
| 370 |
+
*/
|
| 371 |
+
AVRational qoffset;
|
| 372 |
+
} AVRegionOfInterest;
|
| 373 |
+
|
| 374 |
+
/**
|
| 375 |
+
* This structure describes decoded (raw) audio or video data.
|
| 376 |
+
*
|
| 377 |
+
* AVFrame must be allocated using av_frame_alloc(). Note that this only
|
| 378 |
+
* allocates the AVFrame itself, the buffers for the data must be managed
|
| 379 |
+
* through other means (see below).
|
| 380 |
+
* AVFrame must be freed with av_frame_free().
|
| 381 |
+
*
|
| 382 |
+
* AVFrame is typically allocated once and then reused multiple times to hold
|
| 383 |
+
* different data (e.g. a single AVFrame to hold frames received from a
|
| 384 |
+
* decoder). In such a case, av_frame_unref() will free any references held by
|
| 385 |
+
* the frame and reset it to its original clean state before it
|
| 386 |
+
* is reused again.
|
| 387 |
+
*
|
| 388 |
+
* The data described by an AVFrame is usually reference counted through the
|
| 389 |
+
* AVBuffer API. The underlying buffer references are stored in AVFrame.buf /
|
| 390 |
+
* AVFrame.extended_buf. An AVFrame is considered to be reference counted if at
|
| 391 |
+
* least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case,
|
| 392 |
+
* every single data plane must be contained in one of the buffers in
|
| 393 |
+
* AVFrame.buf or AVFrame.extended_buf.
|
| 394 |
+
* There may be a single buffer for all the data, or one separate buffer for
|
| 395 |
+
* each plane, or anything in between.
|
| 396 |
+
*
|
| 397 |
+
* sizeof(AVFrame) is not a part of the public ABI, so new fields may be added
|
| 398 |
+
* to the end with a minor bump.
|
| 399 |
+
*
|
| 400 |
+
* Fields can be accessed through AVOptions, the name string used, matches the
|
| 401 |
+
* C structure field name for fields accessible through AVOptions.
|
| 402 |
+
*/
|
| 403 |
+
typedef struct AVFrame {
|
| 404 |
+
#define AV_NUM_DATA_POINTERS 8
|
| 405 |
+
/**
|
| 406 |
+
* pointer to the picture/channel planes.
|
| 407 |
+
* This might be different from the first allocated byte. For video,
|
| 408 |
+
* it could even point to the end of the image data.
|
| 409 |
+
*
|
| 410 |
+
* All pointers in data and extended_data must point into one of the
|
| 411 |
+
* AVBufferRef in buf or extended_buf.
|
| 412 |
+
*
|
| 413 |
+
* Some decoders access areas outside 0,0 - width,height, please
|
| 414 |
+
* see avcodec_align_dimensions2(). Some filters and swscale can read
|
| 415 |
+
* up to 16 bytes beyond the planes, if these filters are to be used,
|
| 416 |
+
* then 16 extra bytes must be allocated.
|
| 417 |
+
*
|
| 418 |
+
* NOTE: Pointers not needed by the format MUST be set to NULL.
|
| 419 |
+
*
|
| 420 |
+
* @attention In case of video, the data[] pointers can point to the
|
| 421 |
+
* end of image data in order to reverse line order, when used in
|
| 422 |
+
* combination with negative values in the linesize[] array.
|
| 423 |
+
*/
|
| 424 |
+
uint8_t *data[AV_NUM_DATA_POINTERS];
|
| 425 |
+
|
| 426 |
+
/**
|
| 427 |
+
* For video, a positive or negative value, which is typically indicating
|
| 428 |
+
* the size in bytes of each picture line, but it can also be:
|
| 429 |
+
* - the negative byte size of lines for vertical flipping
|
| 430 |
+
* (with data[n] pointing to the end of the data
|
| 431 |
+
* - a positive or negative multiple of the byte size as for accessing
|
| 432 |
+
* even and odd fields of a frame (possibly flipped)
|
| 433 |
+
*
|
| 434 |
+
* For audio, only linesize[0] may be set. For planar audio, each channel
|
| 435 |
+
* plane must be the same size.
|
| 436 |
+
*
|
| 437 |
+
* For video the linesizes should be multiples of the CPUs alignment
|
| 438 |
+
* preference, this is 16 or 32 for modern desktop CPUs.
|
| 439 |
+
* Some code requires such alignment other code can be slower without
|
| 440 |
+
* correct alignment, for yet other it makes no difference.
|
| 441 |
+
*
|
| 442 |
+
* @note The linesize may be larger than the size of usable data -- there
|
| 443 |
+
* may be extra padding present for performance reasons.
|
| 444 |
+
*
|
| 445 |
+
* @attention In case of video, line size values can be negative to achieve
|
| 446 |
+
* a vertically inverted iteration over image lines.
|
| 447 |
+
*/
|
| 448 |
+
int linesize[AV_NUM_DATA_POINTERS];
|
| 449 |
+
|
| 450 |
+
/**
|
| 451 |
+
* pointers to the data planes/channels.
|
| 452 |
+
*
|
| 453 |
+
* For video, this should simply point to data[].
|
| 454 |
+
*
|
| 455 |
+
* For planar audio, each channel has a separate data pointer, and
|
| 456 |
+
* linesize[0] contains the size of each channel buffer.
|
| 457 |
+
* For packed audio, there is just one data pointer, and linesize[0]
|
| 458 |
+
* contains the total size of the buffer for all channels.
|
| 459 |
+
*
|
| 460 |
+
* Note: Both data and extended_data should always be set in a valid frame,
|
| 461 |
+
* but for planar audio with more channels that can fit in data,
|
| 462 |
+
* extended_data must be used in order to access all channels.
|
| 463 |
+
*/
|
| 464 |
+
uint8_t **extended_data;
|
| 465 |
+
|
| 466 |
+
/**
|
| 467 |
+
* @name Video dimensions
|
| 468 |
+
* Video frames only. The coded dimensions (in pixels) of the video frame,
|
| 469 |
+
* i.e. the size of the rectangle that contains some well-defined values.
|
| 470 |
+
*
|
| 471 |
+
* @note The part of the frame intended for display/presentation is further
|
| 472 |
+
* restricted by the @ref cropping "Cropping rectangle".
|
| 473 |
+
* @{
|
| 474 |
+
*/
|
| 475 |
+
int width, height;
|
| 476 |
+
/**
|
| 477 |
+
* @}
|
| 478 |
+
*/
|
| 479 |
+
|
| 480 |
+
/**
|
| 481 |
+
* number of audio samples (per channel) described by this frame
|
| 482 |
+
*/
|
| 483 |
+
int nb_samples;
|
| 484 |
+
|
| 485 |
+
/**
|
| 486 |
+
* format of the frame, -1 if unknown or unset
|
| 487 |
+
* Values correspond to enum AVPixelFormat for video frames,
|
| 488 |
+
* enum AVSampleFormat for audio)
|
| 489 |
+
*/
|
| 490 |
+
int format;
|
| 491 |
+
|
| 492 |
+
#if FF_API_FRAME_KEY
|
| 493 |
+
/**
|
| 494 |
+
* 1 -> keyframe, 0-> not
|
| 495 |
+
*
|
| 496 |
+
* @deprecated Use AV_FRAME_FLAG_KEY instead
|
| 497 |
+
*/
|
| 498 |
+
attribute_deprecated
|
| 499 |
+
int key_frame;
|
| 500 |
+
#endif
|
| 501 |
+
|
| 502 |
+
/**
|
| 503 |
+
* Picture type of the frame.
|
| 504 |
+
*/
|
| 505 |
+
enum AVPictureType pict_type;
|
| 506 |
+
|
| 507 |
+
/**
|
| 508 |
+
* Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
|
| 509 |
+
*/
|
| 510 |
+
AVRational sample_aspect_ratio;
|
| 511 |
+
|
| 512 |
+
/**
|
| 513 |
+
* Presentation timestamp in time_base units (time when frame should be shown to user).
|
| 514 |
+
*/
|
| 515 |
+
int64_t pts;
|
| 516 |
+
|
| 517 |
+
/**
|
| 518 |
+
* DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used)
|
| 519 |
+
* This is also the Presentation time of this AVFrame calculated from
|
| 520 |
+
* only AVPacket.dts values without pts values.
|
| 521 |
+
*/
|
| 522 |
+
int64_t pkt_dts;
|
| 523 |
+
|
| 524 |
+
/**
|
| 525 |
+
* Time base for the timestamps in this frame.
|
| 526 |
+
* In the future, this field may be set on frames output by decoders or
|
| 527 |
+
* filters, but its value will be by default ignored on input to encoders
|
| 528 |
+
* or filters.
|
| 529 |
+
*/
|
| 530 |
+
AVRational time_base;
|
| 531 |
+
|
| 532 |
+
/**
|
| 533 |
+
* quality (between 1 (good) and FF_LAMBDA_MAX (bad))
|
| 534 |
+
*/
|
| 535 |
+
int quality;
|
| 536 |
+
|
| 537 |
+
/**
|
| 538 |
+
* Frame owner's private data.
|
| 539 |
+
*
|
| 540 |
+
* This field may be set by the code that allocates/owns the frame data.
|
| 541 |
+
* It is then not touched by any library functions, except:
|
| 542 |
+
* - it is copied to other references by av_frame_copy_props() (and hence by
|
| 543 |
+
* av_frame_ref());
|
| 544 |
+
* - it is set to NULL when the frame is cleared by av_frame_unref()
|
| 545 |
+
* - on the caller's explicit request. E.g. libavcodec encoders/decoders
|
| 546 |
+
* will copy this field to/from @ref AVPacket "AVPackets" if the caller sets
|
| 547 |
+
* @ref AV_CODEC_FLAG_COPY_OPAQUE.
|
| 548 |
+
*
|
| 549 |
+
* @see opaque_ref the reference-counted analogue
|
| 550 |
+
*/
|
| 551 |
+
void *opaque;
|
| 552 |
+
|
| 553 |
+
/**
|
| 554 |
+
* Number of fields in this frame which should be repeated, i.e. the total
|
| 555 |
+
* duration of this frame should be repeat_pict + 2 normal field durations.
|
| 556 |
+
*
|
| 557 |
+
* For interlaced frames this field may be set to 1, which signals that this
|
| 558 |
+
* frame should be presented as 3 fields: beginning with the first field (as
|
| 559 |
+
* determined by AV_FRAME_FLAG_TOP_FIELD_FIRST being set or not), followed
|
| 560 |
+
* by the second field, and then the first field again.
|
| 561 |
+
*
|
| 562 |
+
* For progressive frames this field may be set to a multiple of 2, which
|
| 563 |
+
* signals that this frame's duration should be (repeat_pict + 2) / 2
|
| 564 |
+
* normal frame durations.
|
| 565 |
+
*
|
| 566 |
+
* @note This field is computed from MPEG2 repeat_first_field flag and its
|
| 567 |
+
* associated flags, H.264 pic_struct from picture timing SEI, and
|
| 568 |
+
* their analogues in other codecs. Typically it should only be used when
|
| 569 |
+
* higher-layer timing information is not available.
|
| 570 |
+
*/
|
| 571 |
+
int repeat_pict;
|
| 572 |
+
|
| 573 |
+
#if FF_API_INTERLACED_FRAME
|
| 574 |
+
/**
|
| 575 |
+
* The content of the picture is interlaced.
|
| 576 |
+
*
|
| 577 |
+
* @deprecated Use AV_FRAME_FLAG_INTERLACED instead
|
| 578 |
+
*/
|
| 579 |
+
attribute_deprecated
|
| 580 |
+
int interlaced_frame;
|
| 581 |
+
|
| 582 |
+
/**
|
| 583 |
+
* If the content is interlaced, is top field displayed first.
|
| 584 |
+
*
|
| 585 |
+
* @deprecated Use AV_FRAME_FLAG_TOP_FIELD_FIRST instead
|
| 586 |
+
*/
|
| 587 |
+
attribute_deprecated
|
| 588 |
+
int top_field_first;
|
| 589 |
+
#endif
|
| 590 |
+
|
| 591 |
+
#if FF_API_PALETTE_HAS_CHANGED
|
| 592 |
+
/**
|
| 593 |
+
* Tell user application that palette has changed from previous frame.
|
| 594 |
+
*/
|
| 595 |
+
attribute_deprecated
|
| 596 |
+
int palette_has_changed;
|
| 597 |
+
#endif
|
| 598 |
+
|
| 599 |
+
/**
|
| 600 |
+
* Sample rate of the audio data.
|
| 601 |
+
*/
|
| 602 |
+
int sample_rate;
|
| 603 |
+
|
| 604 |
+
/**
|
| 605 |
+
* AVBuffer references backing the data for this frame. All the pointers in
|
| 606 |
+
* data and extended_data must point inside one of the buffers in buf or
|
| 607 |
+
* extended_buf. This array must be filled contiguously -- if buf[i] is
|
| 608 |
+
* non-NULL then buf[j] must also be non-NULL for all j < i.
|
| 609 |
+
*
|
| 610 |
+
* There may be at most one AVBuffer per data plane, so for video this array
|
| 611 |
+
* always contains all the references. For planar audio with more than
|
| 612 |
+
* AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in
|
| 613 |
+
* this array. Then the extra AVBufferRef pointers are stored in the
|
| 614 |
+
* extended_buf array.
|
| 615 |
+
*/
|
| 616 |
+
AVBufferRef *buf[AV_NUM_DATA_POINTERS];
|
| 617 |
+
|
| 618 |
+
/**
|
| 619 |
+
* For planar audio which requires more than AV_NUM_DATA_POINTERS
|
| 620 |
+
* AVBufferRef pointers, this array will hold all the references which
|
| 621 |
+
* cannot fit into AVFrame.buf.
|
| 622 |
+
*
|
| 623 |
+
* Note that this is different from AVFrame.extended_data, which always
|
| 624 |
+
* contains all the pointers. This array only contains the extra pointers,
|
| 625 |
+
* which cannot fit into AVFrame.buf.
|
| 626 |
+
*
|
| 627 |
+
* This array is always allocated using av_malloc() by whoever constructs
|
| 628 |
+
* the frame. It is freed in av_frame_unref().
|
| 629 |
+
*/
|
| 630 |
+
AVBufferRef **extended_buf;
|
| 631 |
+
/**
|
| 632 |
+
* Number of elements in extended_buf.
|
| 633 |
+
*/
|
| 634 |
+
int nb_extended_buf;
|
| 635 |
+
|
| 636 |
+
AVFrameSideData **side_data;
|
| 637 |
+
int nb_side_data;
|
| 638 |
+
|
| 639 |
+
/**
|
| 640 |
+
* @defgroup lavu_frame_flags AV_FRAME_FLAGS
|
| 641 |
+
* @ingroup lavu_frame
|
| 642 |
+
* Flags describing additional frame properties.
|
| 643 |
+
*
|
| 644 |
+
* @{
|
| 645 |
+
*/
|
| 646 |
+
|
| 647 |
+
/**
|
| 648 |
+
* The frame data may be corrupted, e.g. due to decoding errors.
|
| 649 |
+
*/
|
| 650 |
+
#define AV_FRAME_FLAG_CORRUPT (1 << 0)
|
| 651 |
+
/**
|
| 652 |
+
* A flag to mark frames that are keyframes.
|
| 653 |
+
*/
|
| 654 |
+
#define AV_FRAME_FLAG_KEY (1 << 1)
|
| 655 |
+
/**
|
| 656 |
+
* A flag to mark the frames which need to be decoded, but shouldn't be output.
|
| 657 |
+
*/
|
| 658 |
+
#define AV_FRAME_FLAG_DISCARD (1 << 2)
|
| 659 |
+
/**
|
| 660 |
+
* A flag to mark frames whose content is interlaced.
|
| 661 |
+
*/
|
| 662 |
+
#define AV_FRAME_FLAG_INTERLACED (1 << 3)
|
| 663 |
+
/**
|
| 664 |
+
* A flag to mark frames where the top field is displayed first if the content
|
| 665 |
+
* is interlaced.
|
| 666 |
+
*/
|
| 667 |
+
#define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4)
|
| 668 |
+
/**
|
| 669 |
+
* A flag to mark frames which were encoded losslessly from the input.
|
| 670 |
+
*/
|
| 671 |
+
#define AV_FRAME_FLAG_LOSSLESS (1 << 5)
|
| 672 |
+
/**
|
| 673 |
+
* @}
|
| 674 |
+
*/
|
| 675 |
+
|
| 676 |
+
/**
|
| 677 |
+
* Frame flags, a combination of @ref lavu_frame_flags
|
| 678 |
+
*/
|
| 679 |
+
int flags;
|
| 680 |
+
|
| 681 |
+
/**
|
| 682 |
+
* MPEG vs JPEG YUV range.
|
| 683 |
+
* - encoding: Set by user
|
| 684 |
+
* - decoding: Set by libavcodec
|
| 685 |
+
*/
|
| 686 |
+
enum AVColorRange color_range;
|
| 687 |
+
|
| 688 |
+
enum AVColorPrimaries color_primaries;
|
| 689 |
+
|
| 690 |
+
enum AVColorTransferCharacteristic color_trc;
|
| 691 |
+
|
| 692 |
+
/**
|
| 693 |
+
* YUV colorspace type.
|
| 694 |
+
* - encoding: Set by user
|
| 695 |
+
* - decoding: Set by libavcodec
|
| 696 |
+
*/
|
| 697 |
+
enum AVColorSpace colorspace;
|
| 698 |
+
|
| 699 |
+
enum AVChromaLocation chroma_location;
|
| 700 |
+
|
| 701 |
+
/**
|
| 702 |
+
* frame timestamp estimated using various heuristics, in stream time base
|
| 703 |
+
* - encoding: unused
|
| 704 |
+
* - decoding: set by libavcodec, read by user.
|
| 705 |
+
*/
|
| 706 |
+
int64_t best_effort_timestamp;
|
| 707 |
+
|
| 708 |
+
#if FF_API_FRAME_PKT
|
| 709 |
+
/**
|
| 710 |
+
* reordered pos from the last AVPacket that has been input into the decoder
|
| 711 |
+
* - encoding: unused
|
| 712 |
+
* - decoding: Read by user.
|
| 713 |
+
* @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user
|
| 714 |
+
* data from packets to frames
|
| 715 |
+
*/
|
| 716 |
+
attribute_deprecated
|
| 717 |
+
int64_t pkt_pos;
|
| 718 |
+
#endif
|
| 719 |
+
|
| 720 |
+
/**
|
| 721 |
+
* metadata.
|
| 722 |
+
* - encoding: Set by user.
|
| 723 |
+
* - decoding: Set by libavcodec.
|
| 724 |
+
*/
|
| 725 |
+
AVDictionary *metadata;
|
| 726 |
+
|
| 727 |
+
/**
|
| 728 |
+
* decode error flags of the frame, set to a combination of
|
| 729 |
+
* FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
|
| 730 |
+
* were errors during the decoding.
|
| 731 |
+
* - encoding: unused
|
| 732 |
+
* - decoding: set by libavcodec, read by user.
|
| 733 |
+
*/
|
| 734 |
+
int decode_error_flags;
|
| 735 |
+
#define FF_DECODE_ERROR_INVALID_BITSTREAM 1
|
| 736 |
+
#define FF_DECODE_ERROR_MISSING_REFERENCE 2
|
| 737 |
+
#define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4
|
| 738 |
+
#define FF_DECODE_ERROR_DECODE_SLICES 8
|
| 739 |
+
|
| 740 |
+
#if FF_API_FRAME_PKT
|
| 741 |
+
/**
|
| 742 |
+
* size of the corresponding packet containing the compressed
|
| 743 |
+
* frame.
|
| 744 |
+
* It is set to a negative value if unknown.
|
| 745 |
+
* - encoding: unused
|
| 746 |
+
* - decoding: set by libavcodec, read by user.
|
| 747 |
+
* @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user
|
| 748 |
+
* data from packets to frames
|
| 749 |
+
*/
|
| 750 |
+
attribute_deprecated
|
| 751 |
+
int pkt_size;
|
| 752 |
+
#endif
|
| 753 |
+
|
| 754 |
+
/**
|
| 755 |
+
* For hwaccel-format frames, this should be a reference to the
|
| 756 |
+
* AVHWFramesContext describing the frame.
|
| 757 |
+
*/
|
| 758 |
+
AVBufferRef *hw_frames_ctx;
|
| 759 |
+
|
| 760 |
+
/**
|
| 761 |
+
* Frame owner's private data.
|
| 762 |
+
*
|
| 763 |
+
* This field may be set by the code that allocates/owns the frame data.
|
| 764 |
+
* It is then not touched by any library functions, except:
|
| 765 |
+
* - a new reference to the underlying buffer is propagated by
|
| 766 |
+
* av_frame_copy_props() (and hence by av_frame_ref());
|
| 767 |
+
* - it is unreferenced in av_frame_unref();
|
| 768 |
+
* - on the caller's explicit request. E.g. libavcodec encoders/decoders
|
| 769 |
+
* will propagate a new reference to/from @ref AVPacket "AVPackets" if the
|
| 770 |
+
* caller sets @ref AV_CODEC_FLAG_COPY_OPAQUE.
|
| 771 |
+
*
|
| 772 |
+
* @see opaque the plain pointer analogue
|
| 773 |
+
*/
|
| 774 |
+
AVBufferRef *opaque_ref;
|
| 775 |
+
|
| 776 |
+
/**
|
| 777 |
+
* @anchor cropping
|
| 778 |
+
* @name Cropping
|
| 779 |
+
* Video frames only. The number of pixels to discard from the the
|
| 780 |
+
* top/bottom/left/right border of the frame to obtain the sub-rectangle of
|
| 781 |
+
* the frame intended for presentation.
|
| 782 |
+
* @{
|
| 783 |
+
*/
|
| 784 |
+
size_t crop_top;
|
| 785 |
+
size_t crop_bottom;
|
| 786 |
+
size_t crop_left;
|
| 787 |
+
size_t crop_right;
|
| 788 |
+
/**
|
| 789 |
+
* @}
|
| 790 |
+
*/
|
| 791 |
+
|
| 792 |
+
/**
|
| 793 |
+
* AVBufferRef for internal use by a single libav* library.
|
| 794 |
+
* Must not be used to transfer data between libraries.
|
| 795 |
+
* Has to be NULL when ownership of the frame leaves the respective library.
|
| 796 |
+
*
|
| 797 |
+
* Code outside the FFmpeg libs should never check or change the contents of the buffer ref.
|
| 798 |
+
*
|
| 799 |
+
* FFmpeg calls av_buffer_unref() on it when the frame is unreferenced.
|
| 800 |
+
* av_frame_copy_props() calls create a new reference with av_buffer_ref()
|
| 801 |
+
* for the target frame's private_ref field.
|
| 802 |
+
*/
|
| 803 |
+
AVBufferRef *private_ref;
|
| 804 |
+
|
| 805 |
+
/**
|
| 806 |
+
* Channel layout of the audio data.
|
| 807 |
+
*/
|
| 808 |
+
AVChannelLayout ch_layout;
|
| 809 |
+
|
| 810 |
+
/**
|
| 811 |
+
* Duration of the frame, in the same units as pts. 0 if unknown.
|
| 812 |
+
*/
|
| 813 |
+
int64_t duration;
|
| 814 |
+
} AVFrame;
|
| 815 |
+
|
| 816 |
+
|
| 817 |
+
/**
|
| 818 |
+
* Allocate an AVFrame and set its fields to default values. The resulting
|
| 819 |
+
* struct must be freed using av_frame_free().
|
| 820 |
+
*
|
| 821 |
+
* @return An AVFrame filled with default values or NULL on failure.
|
| 822 |
+
*
|
| 823 |
+
* @note this only allocates the AVFrame itself, not the data buffers. Those
|
| 824 |
+
* must be allocated through other means, e.g. with av_frame_get_buffer() or
|
| 825 |
+
* manually.
|
| 826 |
+
*/
|
| 827 |
+
AVFrame *av_frame_alloc(void);
|
| 828 |
+
|
| 829 |
+
/**
|
| 830 |
+
* Free the frame and any dynamically allocated objects in it,
|
| 831 |
+
* e.g. extended_data. If the frame is reference counted, it will be
|
| 832 |
+
* unreferenced first.
|
| 833 |
+
*
|
| 834 |
+
* @param frame frame to be freed. The pointer will be set to NULL.
|
| 835 |
+
*/
|
| 836 |
+
void av_frame_free(AVFrame **frame);
|
| 837 |
+
|
| 838 |
+
/**
|
| 839 |
+
* Set up a new reference to the data described by the source frame.
|
| 840 |
+
*
|
| 841 |
+
* Copy frame properties from src to dst and create a new reference for each
|
| 842 |
+
* AVBufferRef from src.
|
| 843 |
+
*
|
| 844 |
+
* If src is not reference counted, new buffers are allocated and the data is
|
| 845 |
+
* copied.
|
| 846 |
+
*
|
| 847 |
+
* @warning: dst MUST have been either unreferenced with av_frame_unref(dst),
|
| 848 |
+
* or newly allocated with av_frame_alloc() before calling this
|
| 849 |
+
* function, or undefined behavior will occur.
|
| 850 |
+
*
|
| 851 |
+
* @return 0 on success, a negative AVERROR on error
|
| 852 |
+
*/
|
| 853 |
+
int av_frame_ref(AVFrame *dst, const AVFrame *src);
|
| 854 |
+
|
| 855 |
+
/**
|
| 856 |
+
* Ensure the destination frame refers to the same data described by the source
|
| 857 |
+
* frame, either by creating a new reference for each AVBufferRef from src if
|
| 858 |
+
* they differ from those in dst, by allocating new buffers and copying data if
|
| 859 |
+
* src is not reference counted, or by unrefencing it if src is empty.
|
| 860 |
+
*
|
| 861 |
+
* Frame properties on dst will be replaced by those from src.
|
| 862 |
+
*
|
| 863 |
+
* @return 0 on success, a negative AVERROR on error. On error, dst is
|
| 864 |
+
* unreferenced.
|
| 865 |
+
*/
|
| 866 |
+
int av_frame_replace(AVFrame *dst, const AVFrame *src);
|
| 867 |
+
|
| 868 |
+
/**
|
| 869 |
+
* Create a new frame that references the same data as src.
|
| 870 |
+
*
|
| 871 |
+
* This is a shortcut for av_frame_alloc()+av_frame_ref().
|
| 872 |
+
*
|
| 873 |
+
* @return newly created AVFrame on success, NULL on error.
|
| 874 |
+
*/
|
| 875 |
+
AVFrame *av_frame_clone(const AVFrame *src);
|
| 876 |
+
|
| 877 |
+
/**
|
| 878 |
+
* Unreference all the buffers referenced by frame and reset the frame fields.
|
| 879 |
+
*/
|
| 880 |
+
void av_frame_unref(AVFrame *frame);
|
| 881 |
+
|
| 882 |
+
/**
|
| 883 |
+
* Move everything contained in src to dst and reset src.
|
| 884 |
+
*
|
| 885 |
+
* @warning: dst is not unreferenced, but directly overwritten without reading
|
| 886 |
+
* or deallocating its contents. Call av_frame_unref(dst) manually
|
| 887 |
+
* before calling this function to ensure that no memory is leaked.
|
| 888 |
+
*/
|
| 889 |
+
void av_frame_move_ref(AVFrame *dst, AVFrame *src);
|
| 890 |
+
|
| 891 |
+
/**
|
| 892 |
+
* Allocate new buffer(s) for audio or video data.
|
| 893 |
+
*
|
| 894 |
+
* The following fields must be set on frame before calling this function:
|
| 895 |
+
* - format (pixel format for video, sample format for audio)
|
| 896 |
+
* - width and height for video
|
| 897 |
+
* - nb_samples and ch_layout for audio
|
| 898 |
+
*
|
| 899 |
+
* This function will fill AVFrame.data and AVFrame.buf arrays and, if
|
| 900 |
+
* necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf.
|
| 901 |
+
* For planar formats, one buffer will be allocated for each plane.
|
| 902 |
+
*
|
| 903 |
+
* @warning: if frame already has been allocated, calling this function will
|
| 904 |
+
* leak memory. In addition, undefined behavior can occur in certain
|
| 905 |
+
* cases.
|
| 906 |
+
*
|
| 907 |
+
* @param frame frame in which to store the new buffers.
|
| 908 |
+
* @param align Required buffer size and data pointer alignment. If equal to 0,
|
| 909 |
+
* alignment will be chosen automatically for the current CPU.
|
| 910 |
+
* It is highly recommended to pass 0 here unless you know what
|
| 911 |
+
* you are doing.
|
| 912 |
+
*
|
| 913 |
+
* @return 0 on success, a negative AVERROR on error.
|
| 914 |
+
*/
|
| 915 |
+
int av_frame_get_buffer(AVFrame *frame, int align);
|
| 916 |
+
|
| 917 |
+
/**
|
| 918 |
+
* Check if the frame data is writable.
|
| 919 |
+
*
|
| 920 |
+
* @return A positive value if the frame data is writable (which is true if and
|
| 921 |
+
* only if each of the underlying buffers has only one reference, namely the one
|
| 922 |
+
* stored in this frame). Return 0 otherwise.
|
| 923 |
+
*
|
| 924 |
+
* If 1 is returned the answer is valid until av_buffer_ref() is called on any
|
| 925 |
+
* of the underlying AVBufferRefs (e.g. through av_frame_ref() or directly).
|
| 926 |
+
*
|
| 927 |
+
* @see av_frame_make_writable(), av_buffer_is_writable()
|
| 928 |
+
*/
|
| 929 |
+
int av_frame_is_writable(AVFrame *frame);
|
| 930 |
+
|
| 931 |
+
/**
|
| 932 |
+
* Ensure that the frame data is writable, avoiding data copy if possible.
|
| 933 |
+
*
|
| 934 |
+
* Do nothing if the frame is writable, allocate new buffers and copy the data
|
| 935 |
+
* if it is not. Non-refcounted frames behave as non-writable, i.e. a copy
|
| 936 |
+
* is always made.
|
| 937 |
+
*
|
| 938 |
+
* @return 0 on success, a negative AVERROR on error.
|
| 939 |
+
*
|
| 940 |
+
* @see av_frame_is_writable(), av_buffer_is_writable(),
|
| 941 |
+
* av_buffer_make_writable()
|
| 942 |
+
*/
|
| 943 |
+
int av_frame_make_writable(AVFrame *frame);
|
| 944 |
+
|
| 945 |
+
/**
|
| 946 |
+
* Copy the frame data from src to dst.
|
| 947 |
+
*
|
| 948 |
+
* This function does not allocate anything, dst must be already initialized and
|
| 949 |
+
* allocated with the same parameters as src.
|
| 950 |
+
*
|
| 951 |
+
* This function only copies the frame data (i.e. the contents of the data /
|
| 952 |
+
* extended data arrays), not any other properties.
|
| 953 |
+
*
|
| 954 |
+
* @return >= 0 on success, a negative AVERROR on error.
|
| 955 |
+
*/
|
| 956 |
+
int av_frame_copy(AVFrame *dst, const AVFrame *src);
|
| 957 |
+
|
| 958 |
+
/**
|
| 959 |
+
* Copy only "metadata" fields from src to dst.
|
| 960 |
+
*
|
| 961 |
+
* Metadata for the purpose of this function are those fields that do not affect
|
| 962 |
+
* the data layout in the buffers. E.g. pts, sample rate (for audio) or sample
|
| 963 |
+
* aspect ratio (for video), but not width/height or channel layout.
|
| 964 |
+
* Side data is also copied.
|
| 965 |
+
*/
|
| 966 |
+
int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
|
| 967 |
+
|
| 968 |
+
/**
|
| 969 |
+
* Get the buffer reference a given data plane is stored in.
|
| 970 |
+
*
|
| 971 |
+
* @param frame the frame to get the plane's buffer from
|
| 972 |
+
* @param plane index of the data plane of interest in frame->extended_data.
|
| 973 |
+
*
|
| 974 |
+
* @return the buffer reference that contains the plane or NULL if the input
|
| 975 |
+
* frame is not valid.
|
| 976 |
+
*/
|
| 977 |
+
AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane);
|
| 978 |
+
|
| 979 |
+
/**
|
| 980 |
+
* Add a new side data to a frame.
|
| 981 |
+
*
|
| 982 |
+
* @param frame a frame to which the side data should be added
|
| 983 |
+
* @param type type of the added side data
|
| 984 |
+
* @param size size of the side data
|
| 985 |
+
*
|
| 986 |
+
* @return newly added side data on success, NULL on error
|
| 987 |
+
*/
|
| 988 |
+
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
|
| 989 |
+
enum AVFrameSideDataType type,
|
| 990 |
+
size_t size);
|
| 991 |
+
|
| 992 |
+
/**
|
| 993 |
+
* Add a new side data to a frame from an existing AVBufferRef
|
| 994 |
+
*
|
| 995 |
+
* @param frame a frame to which the side data should be added
|
| 996 |
+
* @param type the type of the added side data
|
| 997 |
+
* @param buf an AVBufferRef to add as side data. The ownership of
|
| 998 |
+
* the reference is transferred to the frame.
|
| 999 |
+
*
|
| 1000 |
+
* @return newly added side data on success, NULL on error. On failure
|
| 1001 |
+
* the frame is unchanged and the AVBufferRef remains owned by
|
| 1002 |
+
* the caller.
|
| 1003 |
+
*/
|
| 1004 |
+
AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
|
| 1005 |
+
enum AVFrameSideDataType type,
|
| 1006 |
+
AVBufferRef *buf);
|
| 1007 |
+
|
| 1008 |
+
/**
|
| 1009 |
+
* @return a pointer to the side data of a given type on success, NULL if there
|
| 1010 |
+
* is no side data with such type in this frame.
|
| 1011 |
+
*/
|
| 1012 |
+
AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
|
| 1013 |
+
enum AVFrameSideDataType type);
|
| 1014 |
+
|
| 1015 |
+
/**
|
| 1016 |
+
* Remove and free all side data instances of the given type.
|
| 1017 |
+
*/
|
| 1018 |
+
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type);
|
| 1019 |
+
|
| 1020 |
+
|
| 1021 |
+
/**
|
| 1022 |
+
* Flags for frame cropping.
|
| 1023 |
+
*/
|
| 1024 |
+
enum {
|
| 1025 |
+
/**
|
| 1026 |
+
* Apply the maximum possible cropping, even if it requires setting the
|
| 1027 |
+
* AVFrame.data[] entries to unaligned pointers. Passing unaligned data
|
| 1028 |
+
* to FFmpeg API is generally not allowed, and causes undefined behavior
|
| 1029 |
+
* (such as crashes). You can pass unaligned data only to FFmpeg APIs that
|
| 1030 |
+
* are explicitly documented to accept it. Use this flag only if you
|
| 1031 |
+
* absolutely know what you are doing.
|
| 1032 |
+
*/
|
| 1033 |
+
AV_FRAME_CROP_UNALIGNED = 1 << 0,
|
| 1034 |
+
};
|
| 1035 |
+
|
| 1036 |
+
/**
|
| 1037 |
+
* Crop the given video AVFrame according to its crop_left/crop_top/crop_right/
|
| 1038 |
+
* crop_bottom fields. If cropping is successful, the function will adjust the
|
| 1039 |
+
* data pointers and the width/height fields, and set the crop fields to 0.
|
| 1040 |
+
*
|
| 1041 |
+
* In all cases, the cropping boundaries will be rounded to the inherent
|
| 1042 |
+
* alignment of the pixel format. In some cases, such as for opaque hwaccel
|
| 1043 |
+
* formats, the left/top cropping is ignored. The crop fields are set to 0 even
|
| 1044 |
+
* if the cropping was rounded or ignored.
|
| 1045 |
+
*
|
| 1046 |
+
* @param frame the frame which should be cropped
|
| 1047 |
+
* @param flags Some combination of AV_FRAME_CROP_* flags, or 0.
|
| 1048 |
+
*
|
| 1049 |
+
* @return >= 0 on success, a negative AVERROR on error. If the cropping fields
|
| 1050 |
+
* were invalid, AVERROR(ERANGE) is returned, and nothing is changed.
|
| 1051 |
+
*/
|
| 1052 |
+
int av_frame_apply_cropping(AVFrame *frame, int flags);
|
| 1053 |
+
|
| 1054 |
+
/**
|
| 1055 |
+
* @return a string identifying the side data type
|
| 1056 |
+
*/
|
| 1057 |
+
const char *av_frame_side_data_name(enum AVFrameSideDataType type);
|
| 1058 |
+
|
| 1059 |
+
/**
|
| 1060 |
+
* @return side data descriptor corresponding to a given side data type, NULL
|
| 1061 |
+
* when not available.
|
| 1062 |
+
*/
|
| 1063 |
+
const AVSideDataDescriptor *av_frame_side_data_desc(enum AVFrameSideDataType type);
|
| 1064 |
+
|
| 1065 |
+
/**
|
| 1066 |
+
* Free all side data entries and their contents, then zeroes out the
|
| 1067 |
+
* values which the pointers are pointing to.
|
| 1068 |
+
*
|
| 1069 |
+
* @param sd pointer to array of side data to free. Will be set to NULL
|
| 1070 |
+
* upon return.
|
| 1071 |
+
* @param nb_sd pointer to an integer containing the number of entries in
|
| 1072 |
+
* the array. Will be set to 0 upon return.
|
| 1073 |
+
*/
|
| 1074 |
+
void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd);
|
| 1075 |
+
|
| 1076 |
+
/**
|
| 1077 |
+
* Remove existing entries before adding new ones.
|
| 1078 |
+
*/
|
| 1079 |
+
#define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0)
|
| 1080 |
+
/**
|
| 1081 |
+
* Don't add a new entry if another of the same type exists.
|
| 1082 |
+
* Applies only for side data types without the AV_SIDE_DATA_PROP_MULTI prop.
|
| 1083 |
+
*/
|
| 1084 |
+
#define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1)
|
| 1085 |
+
|
| 1086 |
+
/**
|
| 1087 |
+
* Add new side data entry to an array.
|
| 1088 |
+
*
|
| 1089 |
+
* @param sd pointer to array of side data to which to add another entry,
|
| 1090 |
+
* or to NULL in order to start a new array.
|
| 1091 |
+
* @param nb_sd pointer to an integer containing the number of entries in
|
| 1092 |
+
* the array.
|
| 1093 |
+
* @param type type of the added side data
|
| 1094 |
+
* @param size size of the side data
|
| 1095 |
+
* @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
|
| 1096 |
+
*
|
| 1097 |
+
* @return newly added side data on success, NULL on error.
|
| 1098 |
+
* @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
|
| 1099 |
+
* matching AVFrameSideDataType will be removed before the addition
|
| 1100 |
+
* is attempted.
|
| 1101 |
+
* @note In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an
|
| 1102 |
+
* entry of the same type already exists, it will be replaced instead.
|
| 1103 |
+
*/
|
| 1104 |
+
AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd,
|
| 1105 |
+
enum AVFrameSideDataType type,
|
| 1106 |
+
size_t size, unsigned int flags);
|
| 1107 |
+
|
| 1108 |
+
/**
|
| 1109 |
+
* Add a new side data entry to an array from an existing AVBufferRef.
|
| 1110 |
+
*
|
| 1111 |
+
* @param sd pointer to array of side data to which to add another entry,
|
| 1112 |
+
* or to NULL in order to start a new array.
|
| 1113 |
+
* @param nb_sd pointer to an integer containing the number of entries in
|
| 1114 |
+
* the array.
|
| 1115 |
+
* @param type type of the added side data
|
| 1116 |
+
* @param buf Pointer to AVBufferRef to add to the array. On success,
|
| 1117 |
+
* the function takes ownership of the AVBufferRef and *buf is
|
| 1118 |
+
* set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set
|
| 1119 |
+
* in which case the ownership will remain with the caller.
|
| 1120 |
+
* @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
|
| 1121 |
+
*
|
| 1122 |
+
* @return newly added side data on success, NULL on error.
|
| 1123 |
+
* @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
|
| 1124 |
+
* matching AVFrameSideDataType will be removed before the addition
|
| 1125 |
+
* is attempted.
|
| 1126 |
+
* @note In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an
|
| 1127 |
+
* entry of the same type already exists, it will be replaced instead.
|
| 1128 |
+
*
|
| 1129 |
+
*/
|
| 1130 |
+
AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd,
|
| 1131 |
+
enum AVFrameSideDataType type,
|
| 1132 |
+
AVBufferRef **buf, unsigned int flags);
|
| 1133 |
+
|
| 1134 |
+
/**
|
| 1135 |
+
* Add a new side data entry to an array based on existing side data, taking
|
| 1136 |
+
* a reference towards the contained AVBufferRef.
|
| 1137 |
+
*
|
| 1138 |
+
* @param sd pointer to array of side data to which to add another entry,
|
| 1139 |
+
* or to NULL in order to start a new array.
|
| 1140 |
+
* @param nb_sd pointer to an integer containing the number of entries in
|
| 1141 |
+
* the array.
|
| 1142 |
+
* @param src side data to be cloned, with a new reference utilized
|
| 1143 |
+
* for the buffer.
|
| 1144 |
+
* @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.
|
| 1145 |
+
*
|
| 1146 |
+
* @return negative error code on failure, >=0 on success.
|
| 1147 |
+
* @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of
|
| 1148 |
+
* matching AVFrameSideDataType will be removed before the addition
|
| 1149 |
+
* is attempted.
|
| 1150 |
+
* @note In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an
|
| 1151 |
+
* entry of the same type already exists, it will be replaced instead.
|
| 1152 |
+
*/
|
| 1153 |
+
int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd,
|
| 1154 |
+
const AVFrameSideData *src, unsigned int flags);
|
| 1155 |
+
|
| 1156 |
+
/**
|
| 1157 |
+
* Get a side data entry of a specific type from an array.
|
| 1158 |
+
*
|
| 1159 |
+
* @param sd array of side data.
|
| 1160 |
+
* @param nb_sd integer containing the number of entries in the array.
|
| 1161 |
+
* @param type type of side data to be queried
|
| 1162 |
+
*
|
| 1163 |
+
* @return a pointer to the side data of a given type on success, NULL if there
|
| 1164 |
+
* is no side data with such type in this set.
|
| 1165 |
+
*/
|
| 1166 |
+
const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd,
|
| 1167 |
+
const int nb_sd,
|
| 1168 |
+
enum AVFrameSideDataType type);
|
| 1169 |
+
|
| 1170 |
+
/**
|
| 1171 |
+
* Wrapper around av_frame_side_data_get_c() to workaround the limitation
|
| 1172 |
+
* that for any type T the conversion from T * const * to const T * const *
|
| 1173 |
+
* is not performed automatically in C.
|
| 1174 |
+
* @see av_frame_side_data_get_c()
|
| 1175 |
+
*/
|
| 1176 |
+
static inline
|
| 1177 |
+
const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd,
|
| 1178 |
+
const int nb_sd,
|
| 1179 |
+
enum AVFrameSideDataType type)
|
| 1180 |
+
{
|
| 1181 |
+
return av_frame_side_data_get_c((const AVFrameSideData * const *)sd,
|
| 1182 |
+
nb_sd, type);
|
| 1183 |
+
}
|
| 1184 |
+
|
| 1185 |
+
/**
|
| 1186 |
+
* Remove and free all side data instances of the given type from an array.
|
| 1187 |
+
*/
|
| 1188 |
+
void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd,
|
| 1189 |
+
enum AVFrameSideDataType type);
|
| 1190 |
+
|
| 1191 |
+
/**
|
| 1192 |
+
* Remove and free all side data instances that match any of the given
|
| 1193 |
+
* side data properties. (See enum AVSideDataProps)
|
| 1194 |
+
*/
|
| 1195 |
+
void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd,
|
| 1196 |
+
int props);
|
| 1197 |
+
|
| 1198 |
+
/**
|
| 1199 |
+
* @}
|
| 1200 |
+
*/
|
| 1201 |
+
|
| 1202 |
+
#endif /* AVUTIL_FRAME_H */
|
ffmpeg/include/libavutil/hash.h
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @file
|
| 23 |
+
* @ingroup lavu_hash_generic
|
| 24 |
+
* Generic hashing API
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
#ifndef AVUTIL_HASH_H
|
| 28 |
+
#define AVUTIL_HASH_H
|
| 29 |
+
|
| 30 |
+
#include <stddef.h>
|
| 31 |
+
#include <stdint.h>
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* @defgroup lavu_hash Hash Functions
|
| 35 |
+
* @ingroup lavu_crypto
|
| 36 |
+
* Hash functions useful in multimedia.
|
| 37 |
+
*
|
| 38 |
+
* Hash functions are widely used in multimedia, from error checking and
|
| 39 |
+
* concealment to internal regression testing. libavutil has efficient
|
| 40 |
+
* implementations of a variety of hash functions that may be useful for
|
| 41 |
+
* FFmpeg and other multimedia applications.
|
| 42 |
+
*
|
| 43 |
+
* @{
|
| 44 |
+
*
|
| 45 |
+
* @defgroup lavu_hash_generic Generic Hashing API
|
| 46 |
+
* An abstraction layer for all hash functions supported by libavutil.
|
| 47 |
+
*
|
| 48 |
+
* If your application needs to support a wide range of different hash
|
| 49 |
+
* functions, then the Generic Hashing API is for you. It provides a generic,
|
| 50 |
+
* reusable API for @ref lavu_hash "all hash functions" implemented in libavutil.
|
| 51 |
+
* If you just need to use one particular hash function, use the @ref lavu_hash
|
| 52 |
+
* "individual hash" directly.
|
| 53 |
+
*
|
| 54 |
+
* @section Sample Code
|
| 55 |
+
*
|
| 56 |
+
* A basic template for using the Generic Hashing API follows:
|
| 57 |
+
*
|
| 58 |
+
* @code
|
| 59 |
+
* struct AVHashContext *ctx = NULL;
|
| 60 |
+
* const char *hash_name = NULL;
|
| 61 |
+
* uint8_t *output_buf = NULL;
|
| 62 |
+
*
|
| 63 |
+
* // Select from a string returned by av_hash_names()
|
| 64 |
+
* hash_name = ...;
|
| 65 |
+
*
|
| 66 |
+
* // Allocate a hash context
|
| 67 |
+
* ret = av_hash_alloc(&ctx, hash_name);
|
| 68 |
+
* if (ret < 0)
|
| 69 |
+
* return ret;
|
| 70 |
+
*
|
| 71 |
+
* // Initialize the hash context
|
| 72 |
+
* av_hash_init(ctx);
|
| 73 |
+
*
|
| 74 |
+
* // Update the hash context with data
|
| 75 |
+
* while (data_left) {
|
| 76 |
+
* av_hash_update(ctx, data, size);
|
| 77 |
+
* }
|
| 78 |
+
*
|
| 79 |
+
* // Now we have no more data, so it is time to finalize the hash and get the
|
| 80 |
+
* // output. But we need to first allocate an output buffer. Note that you can
|
| 81 |
+
* // use any memory allocation function, including malloc(), not just
|
| 82 |
+
* // av_malloc().
|
| 83 |
+
* output_buf = av_malloc(av_hash_get_size(ctx));
|
| 84 |
+
* if (!output_buf)
|
| 85 |
+
* return AVERROR(ENOMEM);
|
| 86 |
+
*
|
| 87 |
+
* // Finalize the hash context.
|
| 88 |
+
* // You can use any of the av_hash_final*() functions provided, for other
|
| 89 |
+
* // output formats. If you do so, be sure to adjust the memory allocation
|
| 90 |
+
* // above. See the function documentation below for the exact amount of extra
|
| 91 |
+
* // memory needed.
|
| 92 |
+
* av_hash_final(ctx, output_buffer);
|
| 93 |
+
*
|
| 94 |
+
* // Free the context
|
| 95 |
+
* av_hash_freep(&ctx);
|
| 96 |
+
* @endcode
|
| 97 |
+
*
|
| 98 |
+
* @section Hash Function-Specific Information
|
| 99 |
+
* If the CRC32 hash is selected, the #AV_CRC_32_IEEE polynomial will be
|
| 100 |
+
* used.
|
| 101 |
+
*
|
| 102 |
+
* If the Murmur3 hash is selected, the default seed will be used. See @ref
|
| 103 |
+
* lavu_murmur3_seedinfo "Murmur3" for more information.
|
| 104 |
+
*
|
| 105 |
+
* @{
|
| 106 |
+
*/
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* @example ffhash.c
|
| 110 |
+
* This example is a simple command line application that takes one or more
|
| 111 |
+
* arguments. It demonstrates a typical use of the hashing API with allocation,
|
| 112 |
+
* initialization, updating, and finalizing.
|
| 113 |
+
*/
|
| 114 |
+
|
| 115 |
+
struct AVHashContext;
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Allocate a hash context for the algorithm specified by name.
|
| 119 |
+
*
|
| 120 |
+
* @return >= 0 for success, a negative error code for failure
|
| 121 |
+
*
|
| 122 |
+
* @note The context is not initialized after a call to this function; you must
|
| 123 |
+
* call av_hash_init() to do so.
|
| 124 |
+
*/
|
| 125 |
+
int av_hash_alloc(struct AVHashContext **ctx, const char *name);
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* Get the names of available hash algorithms.
|
| 129 |
+
*
|
| 130 |
+
* This function can be used to enumerate the algorithms.
|
| 131 |
+
*
|
| 132 |
+
* @param[in] i Index of the hash algorithm, starting from 0
|
| 133 |
+
* @return Pointer to a static string or `NULL` if `i` is out of range
|
| 134 |
+
*/
|
| 135 |
+
const char *av_hash_names(int i);
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* Get the name of the algorithm corresponding to the given hash context.
|
| 139 |
+
*/
|
| 140 |
+
const char *av_hash_get_name(const struct AVHashContext *ctx);
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Maximum value that av_hash_get_size() will currently return.
|
| 144 |
+
*
|
| 145 |
+
* You can use this if you absolutely want or need to use static allocation for
|
| 146 |
+
* the output buffer and are fine with not supporting hashes newly added to
|
| 147 |
+
* libavutil without recompilation.
|
| 148 |
+
*
|
| 149 |
+
* @warning
|
| 150 |
+
* Adding new hashes with larger sizes, and increasing the macro while doing
|
| 151 |
+
* so, will not be considered an ABI change. To prevent your code from
|
| 152 |
+
* overflowing a buffer, either dynamically allocate the output buffer with
|
| 153 |
+
* av_hash_get_size(), or limit your use of the Hashing API to hashes that are
|
| 154 |
+
* already in FFmpeg during the time of compilation.
|
| 155 |
+
*/
|
| 156 |
+
#define AV_HASH_MAX_SIZE 64
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* Get the size of the resulting hash value in bytes.
|
| 160 |
+
*
|
| 161 |
+
* The maximum value this function will currently return is available as macro
|
| 162 |
+
* #AV_HASH_MAX_SIZE.
|
| 163 |
+
*
|
| 164 |
+
* @param[in] ctx Hash context
|
| 165 |
+
* @return Size of the hash value in bytes
|
| 166 |
+
*/
|
| 167 |
+
int av_hash_get_size(const struct AVHashContext *ctx);
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Initialize or reset a hash context.
|
| 171 |
+
*
|
| 172 |
+
* @param[in,out] ctx Hash context
|
| 173 |
+
*/
|
| 174 |
+
void av_hash_init(struct AVHashContext *ctx);
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Update a hash context with additional data.
|
| 178 |
+
*
|
| 179 |
+
* @param[in,out] ctx Hash context
|
| 180 |
+
* @param[in] src Data to be added to the hash context
|
| 181 |
+
* @param[in] len Size of the additional data
|
| 182 |
+
*/
|
| 183 |
+
void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, size_t len);
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* Finalize a hash context and compute the actual hash value.
|
| 187 |
+
*
|
| 188 |
+
* The minimum size of `dst` buffer is given by av_hash_get_size() or
|
| 189 |
+
* #AV_HASH_MAX_SIZE. The use of the latter macro is discouraged.
|
| 190 |
+
*
|
| 191 |
+
* It is not safe to update or finalize a hash context again, if it has already
|
| 192 |
+
* been finalized.
|
| 193 |
+
*
|
| 194 |
+
* @param[in,out] ctx Hash context
|
| 195 |
+
* @param[out] dst Where the final hash value will be stored
|
| 196 |
+
*
|
| 197 |
+
* @see av_hash_final_bin() provides an alternative API
|
| 198 |
+
*/
|
| 199 |
+
void av_hash_final(struct AVHashContext *ctx, uint8_t *dst);
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Finalize a hash context and store the actual hash value in a buffer.
|
| 203 |
+
*
|
| 204 |
+
* It is not safe to update or finalize a hash context again, if it has already
|
| 205 |
+
* been finalized.
|
| 206 |
+
*
|
| 207 |
+
* If `size` is smaller than the hash size (given by av_hash_get_size()), the
|
| 208 |
+
* hash is truncated; if size is larger, the buffer is padded with 0.
|
| 209 |
+
*
|
| 210 |
+
* @param[in,out] ctx Hash context
|
| 211 |
+
* @param[out] dst Where the final hash value will be stored
|
| 212 |
+
* @param[in] size Number of bytes to write to `dst`
|
| 213 |
+
*/
|
| 214 |
+
void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size);
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* Finalize a hash context and store the hexadecimal representation of the
|
| 218 |
+
* actual hash value as a string.
|
| 219 |
+
*
|
| 220 |
+
* It is not safe to update or finalize a hash context again, if it has already
|
| 221 |
+
* been finalized.
|
| 222 |
+
*
|
| 223 |
+
* The string is always 0-terminated.
|
| 224 |
+
*
|
| 225 |
+
* If `size` is smaller than `2 * hash_size + 1`, where `hash_size` is the
|
| 226 |
+
* value returned by av_hash_get_size(), the string will be truncated.
|
| 227 |
+
*
|
| 228 |
+
* @param[in,out] ctx Hash context
|
| 229 |
+
* @param[out] dst Where the string will be stored
|
| 230 |
+
* @param[in] size Maximum number of bytes to write to `dst`
|
| 231 |
+
*/
|
| 232 |
+
void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size);
|
| 233 |
+
|
| 234 |
+
/**
|
| 235 |
+
* Finalize a hash context and store the Base64 representation of the
|
| 236 |
+
* actual hash value as a string.
|
| 237 |
+
*
|
| 238 |
+
* It is not safe to update or finalize a hash context again, if it has already
|
| 239 |
+
* been finalized.
|
| 240 |
+
*
|
| 241 |
+
* The string is always 0-terminated.
|
| 242 |
+
*
|
| 243 |
+
* If `size` is smaller than AV_BASE64_SIZE(hash_size), where `hash_size` is
|
| 244 |
+
* the value returned by av_hash_get_size(), the string will be truncated.
|
| 245 |
+
*
|
| 246 |
+
* @param[in,out] ctx Hash context
|
| 247 |
+
* @param[out] dst Where the final hash value will be stored
|
| 248 |
+
* @param[in] size Maximum number of bytes to write to `dst`
|
| 249 |
+
*/
|
| 250 |
+
void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size);
|
| 251 |
+
|
| 252 |
+
/**
|
| 253 |
+
* Free hash context and set hash context pointer to `NULL`.
|
| 254 |
+
*
|
| 255 |
+
* @param[in,out] ctx Pointer to hash context
|
| 256 |
+
*/
|
| 257 |
+
void av_hash_freep(struct AVHashContext **ctx);
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
* @}
|
| 261 |
+
* @}
|
| 262 |
+
*/
|
| 263 |
+
|
| 264 |
+
#endif /* AVUTIL_HASH_H */
|
ffmpeg/include/libavutil/hdr_dynamic_metadata.h
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2018 Mohammad Izadi <moh.izadi at gmail.com>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_HDR_DYNAMIC_METADATA_H
|
| 22 |
+
#define AVUTIL_HDR_DYNAMIC_METADATA_H
|
| 23 |
+
|
| 24 |
+
#include "frame.h"
|
| 25 |
+
#include "rational.h"
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Option for overlapping elliptical pixel selectors in an image.
|
| 29 |
+
*/
|
| 30 |
+
enum AVHDRPlusOverlapProcessOption {
|
| 31 |
+
AV_HDR_PLUS_OVERLAP_PROCESS_WEIGHTED_AVERAGING = 0,
|
| 32 |
+
AV_HDR_PLUS_OVERLAP_PROCESS_LAYERING = 1,
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* Represents the percentile at a specific percentage in
|
| 37 |
+
* a distribution.
|
| 38 |
+
*/
|
| 39 |
+
typedef struct AVHDRPlusPercentile {
|
| 40 |
+
/**
|
| 41 |
+
* The percentage value corresponding to a specific percentile linearized
|
| 42 |
+
* RGB value in the processing window in the scene. The value shall be in
|
| 43 |
+
* the range of 0 to100, inclusive.
|
| 44 |
+
*/
|
| 45 |
+
uint8_t percentage;
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* The linearized maxRGB value at a specific percentile in the processing
|
| 49 |
+
* window in the scene. The value shall be in the range of 0 to 1, inclusive
|
| 50 |
+
* and in multiples of 0.00001.
|
| 51 |
+
*/
|
| 52 |
+
AVRational percentile;
|
| 53 |
+
} AVHDRPlusPercentile;
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Color transform parameters at a processing window in a dynamic metadata for
|
| 57 |
+
* SMPTE 2094-40.
|
| 58 |
+
*/
|
| 59 |
+
typedef struct AVHDRPlusColorTransformParams {
|
| 60 |
+
/**
|
| 61 |
+
* The relative x coordinate of the top left pixel of the processing
|
| 62 |
+
* window. The value shall be in the range of 0 and 1, inclusive and
|
| 63 |
+
* in multiples of 1/(width of Picture - 1). The value 1 corresponds
|
| 64 |
+
* to the absolute coordinate of width of Picture - 1. The value for
|
| 65 |
+
* first processing window shall be 0.
|
| 66 |
+
*/
|
| 67 |
+
AVRational window_upper_left_corner_x;
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* The relative y coordinate of the top left pixel of the processing
|
| 71 |
+
* window. The value shall be in the range of 0 and 1, inclusive and
|
| 72 |
+
* in multiples of 1/(height of Picture - 1). The value 1 corresponds
|
| 73 |
+
* to the absolute coordinate of height of Picture - 1. The value for
|
| 74 |
+
* first processing window shall be 0.
|
| 75 |
+
*/
|
| 76 |
+
AVRational window_upper_left_corner_y;
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* The relative x coordinate of the bottom right pixel of the processing
|
| 80 |
+
* window. The value shall be in the range of 0 and 1, inclusive and
|
| 81 |
+
* in multiples of 1/(width of Picture - 1). The value 1 corresponds
|
| 82 |
+
* to the absolute coordinate of width of Picture - 1. The value for
|
| 83 |
+
* first processing window shall be 1.
|
| 84 |
+
*/
|
| 85 |
+
AVRational window_lower_right_corner_x;
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* The relative y coordinate of the bottom right pixel of the processing
|
| 89 |
+
* window. The value shall be in the range of 0 and 1, inclusive and
|
| 90 |
+
* in multiples of 1/(height of Picture - 1). The value 1 corresponds
|
| 91 |
+
* to the absolute coordinate of height of Picture - 1. The value for
|
| 92 |
+
* first processing window shall be 1.
|
| 93 |
+
*/
|
| 94 |
+
AVRational window_lower_right_corner_y;
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* The x coordinate of the center position of the concentric internal and
|
| 98 |
+
* external ellipses of the elliptical pixel selector in the processing
|
| 99 |
+
* window. The value shall be in the range of 0 to (width of Picture - 1),
|
| 100 |
+
* inclusive and in multiples of 1 pixel.
|
| 101 |
+
*/
|
| 102 |
+
uint16_t center_of_ellipse_x;
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* The y coordinate of the center position of the concentric internal and
|
| 106 |
+
* external ellipses of the elliptical pixel selector in the processing
|
| 107 |
+
* window. The value shall be in the range of 0 to (height of Picture - 1),
|
| 108 |
+
* inclusive and in multiples of 1 pixel.
|
| 109 |
+
*/
|
| 110 |
+
uint16_t center_of_ellipse_y;
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* The clockwise rotation angle in degree of arc with respect to the
|
| 114 |
+
* positive direction of the x-axis of the concentric internal and external
|
| 115 |
+
* ellipses of the elliptical pixel selector in the processing window. The
|
| 116 |
+
* value shall be in the range of 0 to 180, inclusive and in multiples of 1.
|
| 117 |
+
*/
|
| 118 |
+
uint8_t rotation_angle;
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* The semi-major axis value of the internal ellipse of the elliptical pixel
|
| 122 |
+
* selector in amount of pixels in the processing window. The value shall be
|
| 123 |
+
* in the range of 1 to 65535, inclusive and in multiples of 1 pixel.
|
| 124 |
+
*/
|
| 125 |
+
uint16_t semimajor_axis_internal_ellipse;
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* The semi-major axis value of the external ellipse of the elliptical pixel
|
| 129 |
+
* selector in amount of pixels in the processing window. The value
|
| 130 |
+
* shall not be less than semimajor_axis_internal_ellipse of the current
|
| 131 |
+
* processing window. The value shall be in the range of 1 to 65535,
|
| 132 |
+
* inclusive and in multiples of 1 pixel.
|
| 133 |
+
*/
|
| 134 |
+
uint16_t semimajor_axis_external_ellipse;
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* The semi-minor axis value of the external ellipse of the elliptical pixel
|
| 138 |
+
* selector in amount of pixels in the processing window. The value shall be
|
| 139 |
+
* in the range of 1 to 65535, inclusive and in multiples of 1 pixel.
|
| 140 |
+
*/
|
| 141 |
+
uint16_t semiminor_axis_external_ellipse;
|
| 142 |
+
|
| 143 |
+
/**
|
| 144 |
+
* Overlap process option indicates one of the two methods of combining
|
| 145 |
+
* rendered pixels in the processing window in an image with at least one
|
| 146 |
+
* elliptical pixel selector. For overlapping elliptical pixel selectors
|
| 147 |
+
* in an image, overlap_process_option shall have the same value.
|
| 148 |
+
*/
|
| 149 |
+
enum AVHDRPlusOverlapProcessOption overlap_process_option;
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* The maximum of the color components of linearized RGB values in the
|
| 153 |
+
* processing window in the scene. The values should be in the range of 0 to
|
| 154 |
+
* 1, inclusive and in multiples of 0.00001. maxscl[ 0 ], maxscl[ 1 ], and
|
| 155 |
+
* maxscl[ 2 ] are corresponding to R, G, B color components respectively.
|
| 156 |
+
*/
|
| 157 |
+
AVRational maxscl[3];
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* The average of linearized maxRGB values in the processing window in the
|
| 161 |
+
* scene. The value should be in the range of 0 to 1, inclusive and in
|
| 162 |
+
* multiples of 0.00001.
|
| 163 |
+
*/
|
| 164 |
+
AVRational average_maxrgb;
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* The number of linearized maxRGB values at given percentiles in the
|
| 168 |
+
* processing window in the scene. The maximum value shall be 15.
|
| 169 |
+
*/
|
| 170 |
+
uint8_t num_distribution_maxrgb_percentiles;
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* The linearized maxRGB values at given percentiles in the
|
| 174 |
+
* processing window in the scene.
|
| 175 |
+
*/
|
| 176 |
+
AVHDRPlusPercentile distribution_maxrgb[15];
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* The fraction of selected pixels in the image that contains the brightest
|
| 180 |
+
* pixel in the scene. The value shall be in the range of 0 to 1, inclusive
|
| 181 |
+
* and in multiples of 0.001.
|
| 182 |
+
*/
|
| 183 |
+
AVRational fraction_bright_pixels;
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* This flag indicates that the metadata for the tone mapping function in
|
| 187 |
+
* the processing window is present (for value of 1).
|
| 188 |
+
*/
|
| 189 |
+
uint8_t tone_mapping_flag;
|
| 190 |
+
|
| 191 |
+
/**
|
| 192 |
+
* The x coordinate of the separation point between the linear part and the
|
| 193 |
+
* curved part of the tone mapping function. The value shall be in the range
|
| 194 |
+
* of 0 to 1, excluding 0 and in multiples of 1/4095.
|
| 195 |
+
*/
|
| 196 |
+
AVRational knee_point_x;
|
| 197 |
+
|
| 198 |
+
/**
|
| 199 |
+
* The y coordinate of the separation point between the linear part and the
|
| 200 |
+
* curved part of the tone mapping function. The value shall be in the range
|
| 201 |
+
* of 0 to 1, excluding 0 and in multiples of 1/4095.
|
| 202 |
+
*/
|
| 203 |
+
AVRational knee_point_y;
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
* The number of the intermediate anchor parameters of the tone mapping
|
| 207 |
+
* function in the processing window. The maximum value shall be 15.
|
| 208 |
+
*/
|
| 209 |
+
uint8_t num_bezier_curve_anchors;
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* The intermediate anchor parameters of the tone mapping function in the
|
| 213 |
+
* processing window in the scene. The values should be in the range of 0
|
| 214 |
+
* to 1, inclusive and in multiples of 1/1023.
|
| 215 |
+
*/
|
| 216 |
+
AVRational bezier_curve_anchors[15];
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* This flag shall be equal to 0 in bitstreams conforming to this version of
|
| 220 |
+
* this Specification. Other values are reserved for future use.
|
| 221 |
+
*/
|
| 222 |
+
uint8_t color_saturation_mapping_flag;
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
* The color saturation gain in the processing window in the scene. The
|
| 226 |
+
* value shall be in the range of 0 to 63/8, inclusive and in multiples of
|
| 227 |
+
* 1/8. The default value shall be 1.
|
| 228 |
+
*/
|
| 229 |
+
AVRational color_saturation_weight;
|
| 230 |
+
} AVHDRPlusColorTransformParams;
|
| 231 |
+
|
| 232 |
+
/**
|
| 233 |
+
* This struct represents dynamic metadata for color volume transform -
|
| 234 |
+
* application 4 of SMPTE 2094-40:2016 standard.
|
| 235 |
+
*
|
| 236 |
+
* To be used as payload of a AVFrameSideData or AVPacketSideData with the
|
| 237 |
+
* appropriate type.
|
| 238 |
+
*
|
| 239 |
+
* @note The struct should be allocated with
|
| 240 |
+
* av_dynamic_hdr_plus_alloc() and its size is not a part of
|
| 241 |
+
* the public ABI.
|
| 242 |
+
*/
|
| 243 |
+
typedef struct AVDynamicHDRPlus {
|
| 244 |
+
/**
|
| 245 |
+
* Country code by Rec. ITU-T T.35 Annex A. The value shall be 0xB5.
|
| 246 |
+
*/
|
| 247 |
+
uint8_t itu_t_t35_country_code;
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* Application version in the application defining document in ST-2094
|
| 251 |
+
* suite. The value shall be set to 0.
|
| 252 |
+
*/
|
| 253 |
+
uint8_t application_version;
|
| 254 |
+
|
| 255 |
+
/**
|
| 256 |
+
* The number of processing windows. The value shall be in the range
|
| 257 |
+
* of 1 to 3, inclusive.
|
| 258 |
+
*/
|
| 259 |
+
uint8_t num_windows;
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
* The color transform parameters for every processing window.
|
| 263 |
+
*/
|
| 264 |
+
AVHDRPlusColorTransformParams params[3];
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* The nominal maximum display luminance of the targeted system display,
|
| 268 |
+
* in units of 0.0001 candelas per square metre. The value shall be in
|
| 269 |
+
* the range of 0 to 10000, inclusive.
|
| 270 |
+
*/
|
| 271 |
+
AVRational targeted_system_display_maximum_luminance;
|
| 272 |
+
|
| 273 |
+
/**
|
| 274 |
+
* This flag shall be equal to 0 in bit streams conforming to this version
|
| 275 |
+
* of this Specification. The value 1 is reserved for future use.
|
| 276 |
+
*/
|
| 277 |
+
uint8_t targeted_system_display_actual_peak_luminance_flag;
|
| 278 |
+
|
| 279 |
+
/**
|
| 280 |
+
* The number of rows in the targeted system_display_actual_peak_luminance
|
| 281 |
+
* array. The value shall be in the range of 2 to 25, inclusive.
|
| 282 |
+
*/
|
| 283 |
+
uint8_t num_rows_targeted_system_display_actual_peak_luminance;
|
| 284 |
+
|
| 285 |
+
/**
|
| 286 |
+
* The number of columns in the
|
| 287 |
+
* targeted_system_display_actual_peak_luminance array. The value shall be
|
| 288 |
+
* in the range of 2 to 25, inclusive.
|
| 289 |
+
*/
|
| 290 |
+
uint8_t num_cols_targeted_system_display_actual_peak_luminance;
|
| 291 |
+
|
| 292 |
+
/**
|
| 293 |
+
* The normalized actual peak luminance of the targeted system display. The
|
| 294 |
+
* values should be in the range of 0 to 1, inclusive and in multiples of
|
| 295 |
+
* 1/15.
|
| 296 |
+
*/
|
| 297 |
+
AVRational targeted_system_display_actual_peak_luminance[25][25];
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* This flag shall be equal to 0 in bitstreams conforming to this version of
|
| 301 |
+
* this Specification. The value 1 is reserved for future use.
|
| 302 |
+
*/
|
| 303 |
+
uint8_t mastering_display_actual_peak_luminance_flag;
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
* The number of rows in the mastering_display_actual_peak_luminance array.
|
| 307 |
+
* The value shall be in the range of 2 to 25, inclusive.
|
| 308 |
+
*/
|
| 309 |
+
uint8_t num_rows_mastering_display_actual_peak_luminance;
|
| 310 |
+
|
| 311 |
+
/**
|
| 312 |
+
* The number of columns in the mastering_display_actual_peak_luminance
|
| 313 |
+
* array. The value shall be in the range of 2 to 25, inclusive.
|
| 314 |
+
*/
|
| 315 |
+
uint8_t num_cols_mastering_display_actual_peak_luminance;
|
| 316 |
+
|
| 317 |
+
/**
|
| 318 |
+
* The normalized actual peak luminance of the mastering display used for
|
| 319 |
+
* mastering the image essence. The values should be in the range of 0 to 1,
|
| 320 |
+
* inclusive and in multiples of 1/15.
|
| 321 |
+
*/
|
| 322 |
+
AVRational mastering_display_actual_peak_luminance[25][25];
|
| 323 |
+
} AVDynamicHDRPlus;
|
| 324 |
+
|
| 325 |
+
/**
|
| 326 |
+
* Allocate an AVDynamicHDRPlus structure and set its fields to
|
| 327 |
+
* default values. The resulting struct can be freed using av_freep().
|
| 328 |
+
*
|
| 329 |
+
* @return An AVDynamicHDRPlus filled with default values or NULL
|
| 330 |
+
* on failure.
|
| 331 |
+
*/
|
| 332 |
+
AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size);
|
| 333 |
+
|
| 334 |
+
/**
|
| 335 |
+
* Allocate a complete AVDynamicHDRPlus and add it to the frame.
|
| 336 |
+
* @param frame The frame which side data is added to.
|
| 337 |
+
*
|
| 338 |
+
* @return The AVDynamicHDRPlus structure to be filled by caller or NULL
|
| 339 |
+
* on failure.
|
| 340 |
+
*/
|
| 341 |
+
AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame);
|
| 342 |
+
|
| 343 |
+
/**
|
| 344 |
+
* Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
|
| 345 |
+
* The T.35 buffer must begin with the application mode, skipping the
|
| 346 |
+
* country code, terminal provider codes, and application identifier.
|
| 347 |
+
* @param s A pointer containing the decoded AVDynamicHDRPlus structure.
|
| 348 |
+
* @param data The byte array containing the raw ITU-T T.35 data.
|
| 349 |
+
* @param size Size of the data array in bytes.
|
| 350 |
+
*
|
| 351 |
+
* @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
|
| 352 |
+
*/
|
| 353 |
+
int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data,
|
| 354 |
+
size_t size);
|
| 355 |
+
|
| 356 |
+
#define AV_HDR_PLUS_MAX_PAYLOAD_SIZE 907
|
| 357 |
+
|
| 358 |
+
/**
|
| 359 |
+
* Serialize dynamic HDR10+ metadata to a user data registered ITU-T T.35 buffer,
|
| 360 |
+
* excluding the first 48 bytes of the header, and beginning with the application mode.
|
| 361 |
+
* @param s A pointer containing the decoded AVDynamicHDRPlus structure.
|
| 362 |
+
* @param[in,out] data A pointer to pointer to a byte buffer to be filled with the
|
| 363 |
+
* serialized metadata.
|
| 364 |
+
* If *data is NULL, a buffer be will be allocated and a pointer to
|
| 365 |
+
* it stored in its place. The caller assumes ownership of the buffer.
|
| 366 |
+
* May be NULL, in which case the function will only store the
|
| 367 |
+
* required buffer size in *size.
|
| 368 |
+
* @param[in,out] size A pointer to a size to be set to the returned buffer's size.
|
| 369 |
+
* If *data is not NULL, *size must contain the size of the input
|
| 370 |
+
* buffer. May be NULL only if *data is NULL.
|
| 371 |
+
*
|
| 372 |
+
* @return >= 0 on success. Otherwise, returns the appropriate AVERROR.
|
| 373 |
+
*/
|
| 374 |
+
int av_dynamic_hdr_plus_to_t35(const AVDynamicHDRPlus *s, uint8_t **data, size_t *size);
|
| 375 |
+
|
| 376 |
+
#endif /* AVUTIL_HDR_DYNAMIC_METADATA_H */
|
ffmpeg/include/libavutil/hdr_dynamic_vivid_metadata.h
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H
|
| 22 |
+
#define AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H
|
| 23 |
+
|
| 24 |
+
#include "frame.h"
|
| 25 |
+
#include "rational.h"
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* HDR Vivid three spline params.
|
| 29 |
+
*/
|
| 30 |
+
typedef struct AVHDRVivid3SplineParams {
|
| 31 |
+
/**
|
| 32 |
+
* The mode of three Spline. the value shall be in the range
|
| 33 |
+
* of 0 to 3, inclusive.
|
| 34 |
+
*/
|
| 35 |
+
int th_mode;
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
|
| 39 |
+
* and in multiples of 1.0/255.
|
| 40 |
+
*
|
| 41 |
+
*/
|
| 42 |
+
AVRational th_enable_mb;
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* 3Spline_TH_enable of three Spline.
|
| 46 |
+
* The value shall be in the range of 0.0 to 1.0, inclusive.
|
| 47 |
+
* and in multiples of 1.0/4095.
|
| 48 |
+
*/
|
| 49 |
+
AVRational th_enable;
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* 3Spline_TH_Delta1 of three Spline.
|
| 53 |
+
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
| 54 |
+
* and in multiples of 0.25/1023.
|
| 55 |
+
*/
|
| 56 |
+
AVRational th_delta1;
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* 3Spline_TH_Delta2 of three Spline.
|
| 60 |
+
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
| 61 |
+
* and in multiples of 0.25/1023.
|
| 62 |
+
*/
|
| 63 |
+
AVRational th_delta2;
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* 3Spline_enable_Strength of three Spline.
|
| 67 |
+
* The value shall be in the range of 0.0 to 1.0, inclusive,
|
| 68 |
+
* and in multiples of 1.0/255.
|
| 69 |
+
*/
|
| 70 |
+
AVRational enable_strength;
|
| 71 |
+
} AVHDRVivid3SplineParams;
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Color tone mapping parameters at a processing window in a dynamic metadata for
|
| 75 |
+
* CUVA 005.1:2021.
|
| 76 |
+
*/
|
| 77 |
+
typedef struct AVHDRVividColorToneMappingParams {
|
| 78 |
+
/**
|
| 79 |
+
* The nominal maximum display luminance of the targeted system display,
|
| 80 |
+
* in multiples of 1.0/4095 candelas per square metre. The value shall be in
|
| 81 |
+
* the range of 0.0 to 1.0, inclusive.
|
| 82 |
+
*/
|
| 83 |
+
AVRational targeted_system_display_maximum_luminance;
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* This flag indicates that transfer the base paramter(for value of 1)
|
| 87 |
+
*/
|
| 88 |
+
int base_enable_flag;
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* base_param_m_p in the base parameter,
|
| 92 |
+
* in multiples of 1.0/16383. The value shall be in
|
| 93 |
+
* the range of 0.0 to 1.0, inclusive.
|
| 94 |
+
*/
|
| 95 |
+
AVRational base_param_m_p;
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* base_param_m_m in the base parameter,
|
| 99 |
+
* in multiples of 1.0/10. The value shall be in
|
| 100 |
+
* the range of 0.0 to 6.3, inclusive.
|
| 101 |
+
*/
|
| 102 |
+
AVRational base_param_m_m;
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* base_param_m_a in the base parameter,
|
| 106 |
+
* in multiples of 1.0/1023. The value shall be in
|
| 107 |
+
* the range of 0.0 to 1.0 inclusive.
|
| 108 |
+
*/
|
| 109 |
+
AVRational base_param_m_a;
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* base_param_m_b in the base parameter,
|
| 113 |
+
* in multiples of 1/1023. The value shall be in
|
| 114 |
+
* the range of 0.0 to 1.0, inclusive.
|
| 115 |
+
*/
|
| 116 |
+
AVRational base_param_m_b;
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* base_param_m_n in the base parameter,
|
| 120 |
+
* in multiples of 1.0/10. The value shall be in
|
| 121 |
+
* the range of 0.0 to 6.3, inclusive.
|
| 122 |
+
*/
|
| 123 |
+
AVRational base_param_m_n;
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* indicates k1_0 in the base parameter,
|
| 127 |
+
* base_param_k1 <= 1: k1_0 = base_param_k1
|
| 128 |
+
* base_param_k1 > 1: reserved
|
| 129 |
+
*/
|
| 130 |
+
int base_param_k1;
|
| 131 |
+
|
| 132 |
+
/**
|
| 133 |
+
* indicates k2_0 in the base parameter,
|
| 134 |
+
* base_param_k2 <= 1: k2_0 = base_param_k2
|
| 135 |
+
* base_param_k2 > 1: reserved
|
| 136 |
+
*/
|
| 137 |
+
int base_param_k2;
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* indicates k3_0 in the base parameter,
|
| 141 |
+
* base_param_k3 == 1: k3_0 = base_param_k3
|
| 142 |
+
* base_param_k3 == 2: k3_0 = maximum_maxrgb
|
| 143 |
+
* base_param_k3 > 2: reserved
|
| 144 |
+
*/
|
| 145 |
+
int base_param_k3;
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* This flag indicates that delta mode of base paramter(for value of 1)
|
| 149 |
+
*/
|
| 150 |
+
int base_param_Delta_enable_mode;
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* base_param_Delta in the base parameter,
|
| 154 |
+
* in multiples of 1.0/127. The value shall be in
|
| 155 |
+
* the range of 0.0 to 1.0, inclusive.
|
| 156 |
+
*/
|
| 157 |
+
AVRational base_param_Delta;
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* indicates 3Spline_enable_flag in the base parameter,
|
| 161 |
+
* This flag indicates that transfer three Spline of base paramter(for value of 1)
|
| 162 |
+
*/
|
| 163 |
+
int three_Spline_enable_flag;
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* The number of three Spline. The value shall be in the range
|
| 167 |
+
* of 1 to 2, inclusive.
|
| 168 |
+
*/
|
| 169 |
+
int three_Spline_num;
|
| 170 |
+
|
| 171 |
+
#if FF_API_HDR_VIVID_THREE_SPLINE
|
| 172 |
+
/**
|
| 173 |
+
* The mode of three Spline. the value shall be in the range
|
| 174 |
+
* of 0 to 3, inclusive.
|
| 175 |
+
* @deprecated Use three_spline instead
|
| 176 |
+
*/
|
| 177 |
+
attribute_deprecated
|
| 178 |
+
int three_Spline_TH_mode;
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive
|
| 182 |
+
* and in multiples of 1.0/255.
|
| 183 |
+
* @deprecated Use three_spline instead
|
| 184 |
+
*/
|
| 185 |
+
attribute_deprecated
|
| 186 |
+
AVRational three_Spline_TH_enable_MB;
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* 3Spline_TH_enable of three Spline.
|
| 190 |
+
* The value shall be in the range of 0.0 to 1.0, inclusive.
|
| 191 |
+
* and in multiples of 1.0/4095.
|
| 192 |
+
* @deprecated Use three_spline instead
|
| 193 |
+
*/
|
| 194 |
+
attribute_deprecated
|
| 195 |
+
AVRational three_Spline_TH_enable;
|
| 196 |
+
|
| 197 |
+
/**
|
| 198 |
+
* 3Spline_TH_Delta1 of three Spline.
|
| 199 |
+
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
| 200 |
+
* and in multiples of 0.25/1023.
|
| 201 |
+
* @deprecated Use three_spline instead
|
| 202 |
+
*/
|
| 203 |
+
attribute_deprecated
|
| 204 |
+
AVRational three_Spline_TH_Delta1;
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* 3Spline_TH_Delta2 of three Spline.
|
| 208 |
+
* The value shall be in the range of 0.0 to 0.25, inclusive,
|
| 209 |
+
* and in multiples of 0.25/1023.
|
| 210 |
+
* @deprecated Use three_spline instead
|
| 211 |
+
*/
|
| 212 |
+
attribute_deprecated
|
| 213 |
+
AVRational three_Spline_TH_Delta2;
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
* 3Spline_enable_Strength of three Spline.
|
| 217 |
+
* The value shall be in the range of 0.0 to 1.0, inclusive,
|
| 218 |
+
* and in multiples of 1.0/255.
|
| 219 |
+
* @deprecated Use three_spline instead
|
| 220 |
+
*/
|
| 221 |
+
attribute_deprecated
|
| 222 |
+
AVRational three_Spline_enable_Strength;
|
| 223 |
+
#endif
|
| 224 |
+
|
| 225 |
+
AVHDRVivid3SplineParams three_spline[2];
|
| 226 |
+
} AVHDRVividColorToneMappingParams;
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* Color transform parameters at a processing window in a dynamic metadata for
|
| 231 |
+
* CUVA 005.1:2021.
|
| 232 |
+
*/
|
| 233 |
+
typedef struct AVHDRVividColorTransformParams {
|
| 234 |
+
/**
|
| 235 |
+
* Indicates the minimum brightness of the displayed content.
|
| 236 |
+
* The values should be in the range of 0.0 to 1.0,
|
| 237 |
+
* inclusive and in multiples of 1/4095.
|
| 238 |
+
*/
|
| 239 |
+
AVRational minimum_maxrgb;
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
* Indicates the average brightness of the displayed content.
|
| 243 |
+
* The values should be in the range of 0.0 to 1.0,
|
| 244 |
+
* inclusive and in multiples of 1/4095.
|
| 245 |
+
*/
|
| 246 |
+
AVRational average_maxrgb;
|
| 247 |
+
|
| 248 |
+
/**
|
| 249 |
+
* Indicates the variance brightness of the displayed content.
|
| 250 |
+
* The values should be in the range of 0.0 to 1.0,
|
| 251 |
+
* inclusive and in multiples of 1/4095.
|
| 252 |
+
*/
|
| 253 |
+
AVRational variance_maxrgb;
|
| 254 |
+
|
| 255 |
+
/**
|
| 256 |
+
* Indicates the maximum brightness of the displayed content.
|
| 257 |
+
* The values should be in the range of 0.0 to 1.0, inclusive
|
| 258 |
+
* and in multiples of 1/4095.
|
| 259 |
+
*/
|
| 260 |
+
AVRational maximum_maxrgb;
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* This flag indicates that the metadata for the tone mapping function in
|
| 264 |
+
* the processing window is present (for value of 1).
|
| 265 |
+
*/
|
| 266 |
+
int tone_mapping_mode_flag;
|
| 267 |
+
|
| 268 |
+
/**
|
| 269 |
+
* The number of tone mapping param. The value shall be in the range
|
| 270 |
+
* of 1 to 2, inclusive.
|
| 271 |
+
*/
|
| 272 |
+
int tone_mapping_param_num;
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
* The color tone mapping parameters.
|
| 276 |
+
*/
|
| 277 |
+
AVHDRVividColorToneMappingParams tm_params[2];
|
| 278 |
+
|
| 279 |
+
/**
|
| 280 |
+
* This flag indicates that the metadata for the color saturation mapping in
|
| 281 |
+
* the processing window is present (for value of 1).
|
| 282 |
+
*/
|
| 283 |
+
int color_saturation_mapping_flag;
|
| 284 |
+
|
| 285 |
+
/**
|
| 286 |
+
* The number of color saturation param. The value shall be in the range
|
| 287 |
+
* of 0 to 7, inclusive.
|
| 288 |
+
*/
|
| 289 |
+
int color_saturation_num;
|
| 290 |
+
|
| 291 |
+
/**
|
| 292 |
+
* Indicates the color correction strength parameter.
|
| 293 |
+
* The values should be in the range of 0.0 to 2.0, inclusive
|
| 294 |
+
* and in multiples of 1/128.
|
| 295 |
+
*/
|
| 296 |
+
AVRational color_saturation_gain[8];
|
| 297 |
+
} AVHDRVividColorTransformParams;
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* This struct represents dynamic metadata for color volume transform -
|
| 301 |
+
* CUVA 005.1:2021 standard
|
| 302 |
+
*
|
| 303 |
+
* To be used as payload of a AVFrameSideData or AVPacketSideData with the
|
| 304 |
+
* appropriate type.
|
| 305 |
+
*
|
| 306 |
+
* @note The struct should be allocated with
|
| 307 |
+
* av_dynamic_hdr_vivid_alloc() and its size is not a part of
|
| 308 |
+
* the public ABI.
|
| 309 |
+
*/
|
| 310 |
+
typedef struct AVDynamicHDRVivid {
|
| 311 |
+
/**
|
| 312 |
+
* The system start code. The value shall be set to 0x01.
|
| 313 |
+
*/
|
| 314 |
+
uint8_t system_start_code;
|
| 315 |
+
|
| 316 |
+
/**
|
| 317 |
+
* The number of processing windows. The value shall be set to 0x01
|
| 318 |
+
* if the system_start_code is 0x01.
|
| 319 |
+
*/
|
| 320 |
+
uint8_t num_windows;
|
| 321 |
+
|
| 322 |
+
/**
|
| 323 |
+
* The color transform parameters for every processing window.
|
| 324 |
+
*/
|
| 325 |
+
AVHDRVividColorTransformParams params[3];
|
| 326 |
+
} AVDynamicHDRVivid;
|
| 327 |
+
|
| 328 |
+
/**
|
| 329 |
+
* Allocate an AVDynamicHDRVivid structure and set its fields to
|
| 330 |
+
* default values. The resulting struct can be freed using av_freep().
|
| 331 |
+
*
|
| 332 |
+
* @return An AVDynamicHDRVivid filled with default values or NULL
|
| 333 |
+
* on failure.
|
| 334 |
+
*/
|
| 335 |
+
AVDynamicHDRVivid *av_dynamic_hdr_vivid_alloc(size_t *size);
|
| 336 |
+
|
| 337 |
+
/**
|
| 338 |
+
* Allocate a complete AVDynamicHDRVivid and add it to the frame.
|
| 339 |
+
* @param frame The frame which side data is added to.
|
| 340 |
+
*
|
| 341 |
+
* @return The AVDynamicHDRVivid structure to be filled by caller or NULL
|
| 342 |
+
* on failure.
|
| 343 |
+
*/
|
| 344 |
+
AVDynamicHDRVivid *av_dynamic_hdr_vivid_create_side_data(AVFrame *frame);
|
| 345 |
+
|
| 346 |
+
#endif /* AVUTIL_HDR_DYNAMIC_VIVID_METADATA_H */
|
ffmpeg/include/libavutil/hmac.h
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (C) 2012 Martin Storsjo
|
| 3 |
+
*
|
| 4 |
+
* This file is part of FFmpeg.
|
| 5 |
+
*
|
| 6 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 7 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 8 |
+
* License as published by the Free Software Foundation; either
|
| 9 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 10 |
+
*
|
| 11 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
+
* Lesser General Public License for more details.
|
| 15 |
+
*
|
| 16 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 17 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 18 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#ifndef AVUTIL_HMAC_H
|
| 22 |
+
#define AVUTIL_HMAC_H
|
| 23 |
+
|
| 24 |
+
#include <stdint.h>
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @defgroup lavu_hmac HMAC
|
| 28 |
+
* @ingroup lavu_crypto
|
| 29 |
+
* @{
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
enum AVHMACType {
|
| 33 |
+
AV_HMAC_MD5,
|
| 34 |
+
AV_HMAC_SHA1,
|
| 35 |
+
AV_HMAC_SHA224,
|
| 36 |
+
AV_HMAC_SHA256,
|
| 37 |
+
AV_HMAC_SHA384,
|
| 38 |
+
AV_HMAC_SHA512,
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
typedef struct AVHMAC AVHMAC;
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Allocate an AVHMAC context.
|
| 45 |
+
* @param type The hash function used for the HMAC.
|
| 46 |
+
*/
|
| 47 |
+
AVHMAC *av_hmac_alloc(enum AVHMACType type);
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Free an AVHMAC context.
|
| 51 |
+
* @param ctx The context to free, may be NULL
|
| 52 |
+
*/
|
| 53 |
+
void av_hmac_free(AVHMAC *ctx);
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Initialize an AVHMAC context with an authentication key.
|
| 57 |
+
* @param ctx The HMAC context
|
| 58 |
+
* @param key The authentication key
|
| 59 |
+
* @param keylen The length of the key, in bytes
|
| 60 |
+
*/
|
| 61 |
+
void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen);
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Hash data with the HMAC.
|
| 65 |
+
* @param ctx The HMAC context
|
| 66 |
+
* @param data The data to hash
|
| 67 |
+
* @param len The length of the data, in bytes
|
| 68 |
+
*/
|
| 69 |
+
void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len);
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Finish hashing and output the HMAC digest.
|
| 73 |
+
* @param ctx The HMAC context
|
| 74 |
+
* @param out The output buffer to write the digest into
|
| 75 |
+
* @param outlen The length of the out buffer, in bytes
|
| 76 |
+
* @return The number of bytes written to out, or a negative error code.
|
| 77 |
+
*/
|
| 78 |
+
int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen);
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* Hash an array of data with a key.
|
| 82 |
+
* @param ctx The HMAC context
|
| 83 |
+
* @param data The data to hash
|
| 84 |
+
* @param len The length of the data, in bytes
|
| 85 |
+
* @param key The authentication key
|
| 86 |
+
* @param keylen The length of the key, in bytes
|
| 87 |
+
* @param out The output buffer to write the digest into
|
| 88 |
+
* @param outlen The length of the out buffer, in bytes
|
| 89 |
+
* @return The number of bytes written to out, or a negative error code.
|
| 90 |
+
*/
|
| 91 |
+
int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len,
|
| 92 |
+
const uint8_t *key, unsigned int keylen,
|
| 93 |
+
uint8_t *out, unsigned int outlen);
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* @}
|
| 97 |
+
*/
|
| 98 |
+
|
| 99 |
+
#endif /* AVUTIL_HMAC_H */
|
ffmpeg/include/libavutil/hwcontext.h
ADDED
|
@@ -0,0 +1,598 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_HWCONTEXT_H
|
| 20 |
+
#define AVUTIL_HWCONTEXT_H
|
| 21 |
+
|
| 22 |
+
#include "buffer.h"
|
| 23 |
+
#include "frame.h"
|
| 24 |
+
#include "log.h"
|
| 25 |
+
#include "pixfmt.h"
|
| 26 |
+
|
| 27 |
+
enum AVHWDeviceType {
|
| 28 |
+
AV_HWDEVICE_TYPE_NONE,
|
| 29 |
+
AV_HWDEVICE_TYPE_VDPAU,
|
| 30 |
+
AV_HWDEVICE_TYPE_CUDA,
|
| 31 |
+
AV_HWDEVICE_TYPE_VAAPI,
|
| 32 |
+
AV_HWDEVICE_TYPE_DXVA2,
|
| 33 |
+
AV_HWDEVICE_TYPE_QSV,
|
| 34 |
+
AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
|
| 35 |
+
AV_HWDEVICE_TYPE_D3D11VA,
|
| 36 |
+
AV_HWDEVICE_TYPE_DRM,
|
| 37 |
+
AV_HWDEVICE_TYPE_OPENCL,
|
| 38 |
+
AV_HWDEVICE_TYPE_MEDIACODEC,
|
| 39 |
+
AV_HWDEVICE_TYPE_VULKAN,
|
| 40 |
+
AV_HWDEVICE_TYPE_D3D12VA,
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* This struct aggregates all the (hardware/vendor-specific) "high-level" state,
|
| 45 |
+
* i.e. state that is not tied to a concrete processing configuration.
|
| 46 |
+
* E.g., in an API that supports hardware-accelerated encoding and decoding,
|
| 47 |
+
* this struct will (if possible) wrap the state that is common to both encoding
|
| 48 |
+
* and decoding and from which specific instances of encoders or decoders can be
|
| 49 |
+
* derived.
|
| 50 |
+
*
|
| 51 |
+
* This struct is reference-counted with the AVBuffer mechanism. The
|
| 52 |
+
* av_hwdevice_ctx_alloc() constructor yields a reference, whose data field
|
| 53 |
+
* points to the actual AVHWDeviceContext. Further objects derived from
|
| 54 |
+
* AVHWDeviceContext (such as AVHWFramesContext, describing a frame pool with
|
| 55 |
+
* specific properties) will hold an internal reference to it. After all the
|
| 56 |
+
* references are released, the AVHWDeviceContext itself will be freed,
|
| 57 |
+
* optionally invoking a user-specified callback for uninitializing the hardware
|
| 58 |
+
* state.
|
| 59 |
+
*/
|
| 60 |
+
typedef struct AVHWDeviceContext {
|
| 61 |
+
/**
|
| 62 |
+
* A class for logging. Set by av_hwdevice_ctx_alloc().
|
| 63 |
+
*/
|
| 64 |
+
const AVClass *av_class;
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* This field identifies the underlying API used for hardware access.
|
| 68 |
+
*
|
| 69 |
+
* This field is set when this struct is allocated and never changed
|
| 70 |
+
* afterwards.
|
| 71 |
+
*/
|
| 72 |
+
enum AVHWDeviceType type;
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* The format-specific data, allocated and freed by libavutil along with
|
| 76 |
+
* this context.
|
| 77 |
+
*
|
| 78 |
+
* Should be cast by the user to the format-specific context defined in the
|
| 79 |
+
* corresponding header (hwcontext_*.h) and filled as described in the
|
| 80 |
+
* documentation before calling av_hwdevice_ctx_init().
|
| 81 |
+
*
|
| 82 |
+
* After calling av_hwdevice_ctx_init() this struct should not be modified
|
| 83 |
+
* by the caller.
|
| 84 |
+
*/
|
| 85 |
+
void *hwctx;
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* This field may be set by the caller before calling av_hwdevice_ctx_init().
|
| 89 |
+
*
|
| 90 |
+
* If non-NULL, this callback will be called when the last reference to
|
| 91 |
+
* this context is unreferenced, immediately before it is freed.
|
| 92 |
+
*
|
| 93 |
+
* @note when other objects (e.g an AVHWFramesContext) are derived from this
|
| 94 |
+
* struct, this callback will be invoked after all such child objects
|
| 95 |
+
* are fully uninitialized and their respective destructors invoked.
|
| 96 |
+
*/
|
| 97 |
+
void (*free)(struct AVHWDeviceContext *ctx);
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Arbitrary user data, to be used e.g. by the free() callback.
|
| 101 |
+
*/
|
| 102 |
+
void *user_opaque;
|
| 103 |
+
} AVHWDeviceContext;
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* This struct describes a set or pool of "hardware" frames (i.e. those with
|
| 107 |
+
* data not located in normal system memory). All the frames in the pool are
|
| 108 |
+
* assumed to be allocated in the same way and interchangeable.
|
| 109 |
+
*
|
| 110 |
+
* This struct is reference-counted with the AVBuffer mechanism and tied to a
|
| 111 |
+
* given AVHWDeviceContext instance. The av_hwframe_ctx_alloc() constructor
|
| 112 |
+
* yields a reference, whose data field points to the actual AVHWFramesContext
|
| 113 |
+
* struct.
|
| 114 |
+
*/
|
| 115 |
+
typedef struct AVHWFramesContext {
|
| 116 |
+
/**
|
| 117 |
+
* A class for logging.
|
| 118 |
+
*/
|
| 119 |
+
const AVClass *av_class;
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* A reference to the parent AVHWDeviceContext. This reference is owned and
|
| 123 |
+
* managed by the enclosing AVHWFramesContext, but the caller may derive
|
| 124 |
+
* additional references from it.
|
| 125 |
+
*/
|
| 126 |
+
AVBufferRef *device_ref;
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* The parent AVHWDeviceContext. This is simply a pointer to
|
| 130 |
+
* device_ref->data provided for convenience.
|
| 131 |
+
*
|
| 132 |
+
* Set by libavutil in av_hwframe_ctx_init().
|
| 133 |
+
*/
|
| 134 |
+
AVHWDeviceContext *device_ctx;
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* The format-specific data, allocated and freed automatically along with
|
| 138 |
+
* this context.
|
| 139 |
+
*
|
| 140 |
+
* The user shall ignore this field if the corresponding format-specific
|
| 141 |
+
* header (hwcontext_*.h) does not define a context to be used as
|
| 142 |
+
* AVHWFramesContext.hwctx.
|
| 143 |
+
*
|
| 144 |
+
* Otherwise, it should be cast by the user to said context and filled
|
| 145 |
+
* as described in the documentation before calling av_hwframe_ctx_init().
|
| 146 |
+
*
|
| 147 |
+
* After any frames using this context are created, the contents of this
|
| 148 |
+
* struct should not be modified by the caller.
|
| 149 |
+
*/
|
| 150 |
+
void *hwctx;
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* This field may be set by the caller before calling av_hwframe_ctx_init().
|
| 154 |
+
*
|
| 155 |
+
* If non-NULL, this callback will be called when the last reference to
|
| 156 |
+
* this context is unreferenced, immediately before it is freed.
|
| 157 |
+
*/
|
| 158 |
+
void (*free)(struct AVHWFramesContext *ctx);
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* Arbitrary user data, to be used e.g. by the free() callback.
|
| 162 |
+
*/
|
| 163 |
+
void *user_opaque;
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* A pool from which the frames are allocated by av_hwframe_get_buffer().
|
| 167 |
+
* This field may be set by the caller before calling av_hwframe_ctx_init().
|
| 168 |
+
* The buffers returned by calling av_buffer_pool_get() on this pool must
|
| 169 |
+
* have the properties described in the documentation in the corresponding hw
|
| 170 |
+
* type's header (hwcontext_*.h). The pool will be freed strictly before
|
| 171 |
+
* this struct's free() callback is invoked.
|
| 172 |
+
*
|
| 173 |
+
* This field may be NULL, then libavutil will attempt to allocate a pool
|
| 174 |
+
* internally. Note that certain device types enforce pools allocated at
|
| 175 |
+
* fixed size (frame count), which cannot be extended dynamically. In such a
|
| 176 |
+
* case, initial_pool_size must be set appropriately.
|
| 177 |
+
*/
|
| 178 |
+
AVBufferPool *pool;
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* Initial size of the frame pool. If a device type does not support
|
| 182 |
+
* dynamically resizing the pool, then this is also the maximum pool size.
|
| 183 |
+
*
|
| 184 |
+
* May be set by the caller before calling av_hwframe_ctx_init(). Must be
|
| 185 |
+
* set if pool is NULL and the device type does not support dynamic pools.
|
| 186 |
+
*/
|
| 187 |
+
int initial_pool_size;
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* The pixel format identifying the underlying HW surface type.
|
| 191 |
+
*
|
| 192 |
+
* Must be a hwaccel format, i.e. the corresponding descriptor must have the
|
| 193 |
+
* AV_PIX_FMT_FLAG_HWACCEL flag set.
|
| 194 |
+
*
|
| 195 |
+
* Must be set by the user before calling av_hwframe_ctx_init().
|
| 196 |
+
*/
|
| 197 |
+
enum AVPixelFormat format;
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* The pixel format identifying the actual data layout of the hardware
|
| 201 |
+
* frames.
|
| 202 |
+
*
|
| 203 |
+
* Must be set by the caller before calling av_hwframe_ctx_init().
|
| 204 |
+
*
|
| 205 |
+
* @note when the underlying API does not provide the exact data layout, but
|
| 206 |
+
* only the colorspace/bit depth, this field should be set to the fully
|
| 207 |
+
* planar version of that format (e.g. for 8-bit 420 YUV it should be
|
| 208 |
+
* AV_PIX_FMT_YUV420P, not AV_PIX_FMT_NV12 or anything else).
|
| 209 |
+
*/
|
| 210 |
+
enum AVPixelFormat sw_format;
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* The allocated dimensions of the frames in this pool.
|
| 214 |
+
*
|
| 215 |
+
* Must be set by the user before calling av_hwframe_ctx_init().
|
| 216 |
+
*/
|
| 217 |
+
int width, height;
|
| 218 |
+
} AVHWFramesContext;
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Look up an AVHWDeviceType by name.
|
| 222 |
+
*
|
| 223 |
+
* @param name String name of the device type (case-insensitive).
|
| 224 |
+
* @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if
|
| 225 |
+
* not found.
|
| 226 |
+
*/
|
| 227 |
+
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name);
|
| 228 |
+
|
| 229 |
+
/** Get the string name of an AVHWDeviceType.
|
| 230 |
+
*
|
| 231 |
+
* @param type Type from enum AVHWDeviceType.
|
| 232 |
+
* @return Pointer to a static string containing the name, or NULL if the type
|
| 233 |
+
* is not valid.
|
| 234 |
+
*/
|
| 235 |
+
const char *av_hwdevice_get_type_name(enum AVHWDeviceType type);
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* Iterate over supported device types.
|
| 239 |
+
*
|
| 240 |
+
* @param prev AV_HWDEVICE_TYPE_NONE initially, then the previous type
|
| 241 |
+
* returned by this function in subsequent iterations.
|
| 242 |
+
* @return The next usable device type from enum AVHWDeviceType, or
|
| 243 |
+
* AV_HWDEVICE_TYPE_NONE if there are no more.
|
| 244 |
+
*/
|
| 245 |
+
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev);
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
* Allocate an AVHWDeviceContext for a given hardware type.
|
| 249 |
+
*
|
| 250 |
+
* @param type the type of the hardware device to allocate.
|
| 251 |
+
* @return a reference to the newly created AVHWDeviceContext on success or NULL
|
| 252 |
+
* on failure.
|
| 253 |
+
*/
|
| 254 |
+
AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type);
|
| 255 |
+
|
| 256 |
+
/**
|
| 257 |
+
* Finalize the device context before use. This function must be called after
|
| 258 |
+
* the context is filled with all the required information and before it is
|
| 259 |
+
* used in any way.
|
| 260 |
+
*
|
| 261 |
+
* @param ref a reference to the AVHWDeviceContext
|
| 262 |
+
* @return 0 on success, a negative AVERROR code on failure
|
| 263 |
+
*/
|
| 264 |
+
int av_hwdevice_ctx_init(AVBufferRef *ref);
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* Open a device of the specified type and create an AVHWDeviceContext for it.
|
| 268 |
+
*
|
| 269 |
+
* This is a convenience function intended to cover the simple cases. Callers
|
| 270 |
+
* who need to fine-tune device creation/management should open the device
|
| 271 |
+
* manually and then wrap it in an AVHWDeviceContext using
|
| 272 |
+
* av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().
|
| 273 |
+
*
|
| 274 |
+
* The returned context is already initialized and ready for use, the caller
|
| 275 |
+
* should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of
|
| 276 |
+
* the created AVHWDeviceContext are set by this function and should not be
|
| 277 |
+
* touched by the caller.
|
| 278 |
+
*
|
| 279 |
+
* @param device_ctx On success, a reference to the newly-created device context
|
| 280 |
+
* will be written here. The reference is owned by the caller
|
| 281 |
+
* and must be released with av_buffer_unref() when no longer
|
| 282 |
+
* needed. On failure, NULL will be written to this pointer.
|
| 283 |
+
* @param type The type of the device to create.
|
| 284 |
+
* @param device A type-specific string identifying the device to open.
|
| 285 |
+
* @param opts A dictionary of additional (type-specific) options to use in
|
| 286 |
+
* opening the device. The dictionary remains owned by the caller.
|
| 287 |
+
* @param flags currently unused
|
| 288 |
+
*
|
| 289 |
+
* @return 0 on success, a negative AVERROR code on failure.
|
| 290 |
+
*/
|
| 291 |
+
int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type,
|
| 292 |
+
const char *device, AVDictionary *opts, int flags);
|
| 293 |
+
|
| 294 |
+
/**
|
| 295 |
+
* Create a new device of the specified type from an existing device.
|
| 296 |
+
*
|
| 297 |
+
* If the source device is a device of the target type or was originally
|
| 298 |
+
* derived from such a device (possibly through one or more intermediate
|
| 299 |
+
* devices of other types), then this will return a reference to the
|
| 300 |
+
* existing device of the same type as is requested.
|
| 301 |
+
*
|
| 302 |
+
* Otherwise, it will attempt to derive a new device from the given source
|
| 303 |
+
* device. If direct derivation to the new type is not implemented, it will
|
| 304 |
+
* attempt the same derivation from each ancestor of the source device in
|
| 305 |
+
* turn looking for an implemented derivation method.
|
| 306 |
+
*
|
| 307 |
+
* @param dst_ctx On success, a reference to the newly-created
|
| 308 |
+
* AVHWDeviceContext.
|
| 309 |
+
* @param type The type of the new device to create.
|
| 310 |
+
* @param src_ctx A reference to an existing AVHWDeviceContext which will be
|
| 311 |
+
* used to create the new device.
|
| 312 |
+
* @param flags Currently unused; should be set to zero.
|
| 313 |
+
* @return Zero on success, a negative AVERROR code on failure.
|
| 314 |
+
*/
|
| 315 |
+
int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ctx,
|
| 316 |
+
enum AVHWDeviceType type,
|
| 317 |
+
AVBufferRef *src_ctx, int flags);
|
| 318 |
+
|
| 319 |
+
/**
|
| 320 |
+
* Create a new device of the specified type from an existing device.
|
| 321 |
+
*
|
| 322 |
+
* This function performs the same action as av_hwdevice_ctx_create_derived,
|
| 323 |
+
* however, it is able to set options for the new device to be derived.
|
| 324 |
+
*
|
| 325 |
+
* @param dst_ctx On success, a reference to the newly-created
|
| 326 |
+
* AVHWDeviceContext.
|
| 327 |
+
* @param type The type of the new device to create.
|
| 328 |
+
* @param src_ctx A reference to an existing AVHWDeviceContext which will be
|
| 329 |
+
* used to create the new device.
|
| 330 |
+
* @param options Options for the new device to create, same format as in
|
| 331 |
+
* av_hwdevice_ctx_create.
|
| 332 |
+
* @param flags Currently unused; should be set to zero.
|
| 333 |
+
* @return Zero on success, a negative AVERROR code on failure.
|
| 334 |
+
*/
|
| 335 |
+
int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ctx,
|
| 336 |
+
enum AVHWDeviceType type,
|
| 337 |
+
AVBufferRef *src_ctx,
|
| 338 |
+
AVDictionary *options, int flags);
|
| 339 |
+
|
| 340 |
+
/**
|
| 341 |
+
* Allocate an AVHWFramesContext tied to a given device context.
|
| 342 |
+
*
|
| 343 |
+
* @param device_ctx a reference to a AVHWDeviceContext. This function will make
|
| 344 |
+
* a new reference for internal use, the one passed to the
|
| 345 |
+
* function remains owned by the caller.
|
| 346 |
+
* @return a reference to the newly created AVHWFramesContext on success or NULL
|
| 347 |
+
* on failure.
|
| 348 |
+
*/
|
| 349 |
+
AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ctx);
|
| 350 |
+
|
| 351 |
+
/**
|
| 352 |
+
* Finalize the context before use. This function must be called after the
|
| 353 |
+
* context is filled with all the required information and before it is attached
|
| 354 |
+
* to any frames.
|
| 355 |
+
*
|
| 356 |
+
* @param ref a reference to the AVHWFramesContext
|
| 357 |
+
* @return 0 on success, a negative AVERROR code on failure
|
| 358 |
+
*/
|
| 359 |
+
int av_hwframe_ctx_init(AVBufferRef *ref);
|
| 360 |
+
|
| 361 |
+
/**
|
| 362 |
+
* Allocate a new frame attached to the given AVHWFramesContext.
|
| 363 |
+
*
|
| 364 |
+
* @param hwframe_ctx a reference to an AVHWFramesContext
|
| 365 |
+
* @param frame an empty (freshly allocated or unreffed) frame to be filled with
|
| 366 |
+
* newly allocated buffers.
|
| 367 |
+
* @param flags currently unused, should be set to zero
|
| 368 |
+
* @return 0 on success, a negative AVERROR code on failure
|
| 369 |
+
*/
|
| 370 |
+
int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags);
|
| 371 |
+
|
| 372 |
+
/**
|
| 373 |
+
* Copy data to or from a hw surface. At least one of dst/src must have an
|
| 374 |
+
* AVHWFramesContext attached.
|
| 375 |
+
*
|
| 376 |
+
* If src has an AVHWFramesContext attached, then the format of dst (if set)
|
| 377 |
+
* must use one of the formats returned by av_hwframe_transfer_get_formats(src,
|
| 378 |
+
* AV_HWFRAME_TRANSFER_DIRECTION_FROM).
|
| 379 |
+
* If dst has an AVHWFramesContext attached, then the format of src must use one
|
| 380 |
+
* of the formats returned by av_hwframe_transfer_get_formats(dst,
|
| 381 |
+
* AV_HWFRAME_TRANSFER_DIRECTION_TO)
|
| 382 |
+
*
|
| 383 |
+
* dst may be "clean" (i.e. with data/buf pointers unset), in which case the
|
| 384 |
+
* data buffers will be allocated by this function using av_frame_get_buffer().
|
| 385 |
+
* If dst->format is set, then this format will be used, otherwise (when
|
| 386 |
+
* dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen.
|
| 387 |
+
*
|
| 388 |
+
* The two frames must have matching allocated dimensions (i.e. equal to
|
| 389 |
+
* AVHWFramesContext.width/height), since not all device types support
|
| 390 |
+
* transferring a sub-rectangle of the whole surface. The display dimensions
|
| 391 |
+
* (i.e. AVFrame.width/height) may be smaller than the allocated dimensions, but
|
| 392 |
+
* also have to be equal for both frames. When the display dimensions are
|
| 393 |
+
* smaller than the allocated dimensions, the content of the padding in the
|
| 394 |
+
* destination frame is unspecified.
|
| 395 |
+
*
|
| 396 |
+
* @param dst the destination frame. dst is not touched on failure.
|
| 397 |
+
* @param src the source frame.
|
| 398 |
+
* @param flags currently unused, should be set to zero
|
| 399 |
+
* @return 0 on success, a negative AVERROR error code on failure.
|
| 400 |
+
*/
|
| 401 |
+
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags);
|
| 402 |
+
|
| 403 |
+
enum AVHWFrameTransferDirection {
|
| 404 |
+
/**
|
| 405 |
+
* Transfer the data from the queried hw frame.
|
| 406 |
+
*/
|
| 407 |
+
AV_HWFRAME_TRANSFER_DIRECTION_FROM,
|
| 408 |
+
|
| 409 |
+
/**
|
| 410 |
+
* Transfer the data to the queried hw frame.
|
| 411 |
+
*/
|
| 412 |
+
AV_HWFRAME_TRANSFER_DIRECTION_TO,
|
| 413 |
+
};
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
* Get a list of possible source or target formats usable in
|
| 417 |
+
* av_hwframe_transfer_data().
|
| 418 |
+
*
|
| 419 |
+
* @param hwframe_ctx the frame context to obtain the information for
|
| 420 |
+
* @param dir the direction of the transfer
|
| 421 |
+
* @param formats the pointer to the output format list will be written here.
|
| 422 |
+
* The list is terminated with AV_PIX_FMT_NONE and must be freed
|
| 423 |
+
* by the caller when no longer needed using av_free().
|
| 424 |
+
* If this function returns successfully, the format list will
|
| 425 |
+
* have at least one item (not counting the terminator).
|
| 426 |
+
* On failure, the contents of this pointer are unspecified.
|
| 427 |
+
* @param flags currently unused, should be set to zero
|
| 428 |
+
* @return 0 on success, a negative AVERROR code on failure.
|
| 429 |
+
*/
|
| 430 |
+
int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ctx,
|
| 431 |
+
enum AVHWFrameTransferDirection dir,
|
| 432 |
+
enum AVPixelFormat **formats, int flags);
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
/**
|
| 436 |
+
* This struct describes the constraints on hardware frames attached to
|
| 437 |
+
* a given device with a hardware-specific configuration. This is returned
|
| 438 |
+
* by av_hwdevice_get_hwframe_constraints() and must be freed by
|
| 439 |
+
* av_hwframe_constraints_free() after use.
|
| 440 |
+
*/
|
| 441 |
+
typedef struct AVHWFramesConstraints {
|
| 442 |
+
/**
|
| 443 |
+
* A list of possible values for format in the hw_frames_ctx,
|
| 444 |
+
* terminated by AV_PIX_FMT_NONE. This member will always be filled.
|
| 445 |
+
*/
|
| 446 |
+
enum AVPixelFormat *valid_hw_formats;
|
| 447 |
+
|
| 448 |
+
/**
|
| 449 |
+
* A list of possible values for sw_format in the hw_frames_ctx,
|
| 450 |
+
* terminated by AV_PIX_FMT_NONE. Can be NULL if this information is
|
| 451 |
+
* not known.
|
| 452 |
+
*/
|
| 453 |
+
enum AVPixelFormat *valid_sw_formats;
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* The minimum size of frames in this hw_frames_ctx.
|
| 457 |
+
* (Zero if not known.)
|
| 458 |
+
*/
|
| 459 |
+
int min_width;
|
| 460 |
+
int min_height;
|
| 461 |
+
|
| 462 |
+
/**
|
| 463 |
+
* The maximum size of frames in this hw_frames_ctx.
|
| 464 |
+
* (INT_MAX if not known / no limit.)
|
| 465 |
+
*/
|
| 466 |
+
int max_width;
|
| 467 |
+
int max_height;
|
| 468 |
+
} AVHWFramesConstraints;
|
| 469 |
+
|
| 470 |
+
/**
|
| 471 |
+
* Allocate a HW-specific configuration structure for a given HW device.
|
| 472 |
+
* After use, the user must free all members as required by the specific
|
| 473 |
+
* hardware structure being used, then free the structure itself with
|
| 474 |
+
* av_free().
|
| 475 |
+
*
|
| 476 |
+
* @param device_ctx a reference to the associated AVHWDeviceContext.
|
| 477 |
+
* @return The newly created HW-specific configuration structure on
|
| 478 |
+
* success or NULL on failure.
|
| 479 |
+
*/
|
| 480 |
+
void *av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx);
|
| 481 |
+
|
| 482 |
+
/**
|
| 483 |
+
* Get the constraints on HW frames given a device and the HW-specific
|
| 484 |
+
* configuration to be used with that device. If no HW-specific
|
| 485 |
+
* configuration is provided, returns the maximum possible capabilities
|
| 486 |
+
* of the device.
|
| 487 |
+
*
|
| 488 |
+
* @param ref a reference to the associated AVHWDeviceContext.
|
| 489 |
+
* @param hwconfig a filled HW-specific configuration structure, or NULL
|
| 490 |
+
* to return the maximum possible capabilities of the device.
|
| 491 |
+
* @return AVHWFramesConstraints structure describing the constraints
|
| 492 |
+
* on the device, or NULL if not available.
|
| 493 |
+
*/
|
| 494 |
+
AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref,
|
| 495 |
+
const void *hwconfig);
|
| 496 |
+
|
| 497 |
+
/**
|
| 498 |
+
* Free an AVHWFrameConstraints structure.
|
| 499 |
+
*
|
| 500 |
+
* @param constraints The (filled or unfilled) AVHWFrameConstraints structure.
|
| 501 |
+
*/
|
| 502 |
+
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints);
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
/**
|
| 506 |
+
* Flags to apply to frame mappings.
|
| 507 |
+
*/
|
| 508 |
+
enum {
|
| 509 |
+
/**
|
| 510 |
+
* The mapping must be readable.
|
| 511 |
+
*/
|
| 512 |
+
AV_HWFRAME_MAP_READ = 1 << 0,
|
| 513 |
+
/**
|
| 514 |
+
* The mapping must be writeable.
|
| 515 |
+
*/
|
| 516 |
+
AV_HWFRAME_MAP_WRITE = 1 << 1,
|
| 517 |
+
/**
|
| 518 |
+
* The mapped frame will be overwritten completely in subsequent
|
| 519 |
+
* operations, so the current frame data need not be loaded. Any values
|
| 520 |
+
* which are not overwritten are unspecified.
|
| 521 |
+
*/
|
| 522 |
+
AV_HWFRAME_MAP_OVERWRITE = 1 << 2,
|
| 523 |
+
/**
|
| 524 |
+
* The mapping must be direct. That is, there must not be any copying in
|
| 525 |
+
* the map or unmap steps. Note that performance of direct mappings may
|
| 526 |
+
* be much lower than normal memory.
|
| 527 |
+
*/
|
| 528 |
+
AV_HWFRAME_MAP_DIRECT = 1 << 3,
|
| 529 |
+
};
|
| 530 |
+
|
| 531 |
+
/**
|
| 532 |
+
* Map a hardware frame.
|
| 533 |
+
*
|
| 534 |
+
* This has a number of different possible effects, depending on the format
|
| 535 |
+
* and origin of the src and dst frames. On input, src should be a usable
|
| 536 |
+
* frame with valid buffers and dst should be blank (typically as just created
|
| 537 |
+
* by av_frame_alloc()). src should have an associated hwframe context, and
|
| 538 |
+
* dst may optionally have a format and associated hwframe context.
|
| 539 |
+
*
|
| 540 |
+
* If src was created by mapping a frame from the hwframe context of dst,
|
| 541 |
+
* then this function undoes the mapping - dst is replaced by a reference to
|
| 542 |
+
* the frame that src was originally mapped from.
|
| 543 |
+
*
|
| 544 |
+
* If both src and dst have an associated hwframe context, then this function
|
| 545 |
+
* attempts to map the src frame from its hardware context to that of dst and
|
| 546 |
+
* then fill dst with appropriate data to be usable there. This will only be
|
| 547 |
+
* possible if the hwframe contexts and associated devices are compatible -
|
| 548 |
+
* given compatible devices, av_hwframe_ctx_create_derived() can be used to
|
| 549 |
+
* create a hwframe context for dst in which mapping should be possible.
|
| 550 |
+
*
|
| 551 |
+
* If src has a hwframe context but dst does not, then the src frame is
|
| 552 |
+
* mapped to normal memory and should thereafter be usable as a normal frame.
|
| 553 |
+
* If the format is set on dst, then the mapping will attempt to create dst
|
| 554 |
+
* with that format and fail if it is not possible. If format is unset (is
|
| 555 |
+
* AV_PIX_FMT_NONE) then dst will be mapped with whatever the most appropriate
|
| 556 |
+
* format to use is (probably the sw_format of the src hwframe context).
|
| 557 |
+
*
|
| 558 |
+
* A return value of AVERROR(ENOSYS) indicates that the mapping is not
|
| 559 |
+
* possible with the given arguments and hwframe setup, while other return
|
| 560 |
+
* values indicate that it failed somehow.
|
| 561 |
+
*
|
| 562 |
+
* On failure, the destination frame will be left blank, except for the
|
| 563 |
+
* hw_frames_ctx/format fields thay may have been set by the caller - those will
|
| 564 |
+
* be preserved as they were.
|
| 565 |
+
*
|
| 566 |
+
* @param dst Destination frame, to contain the mapping.
|
| 567 |
+
* @param src Source frame, to be mapped.
|
| 568 |
+
* @param flags Some combination of AV_HWFRAME_MAP_* flags.
|
| 569 |
+
* @return Zero on success, negative AVERROR code on failure.
|
| 570 |
+
*/
|
| 571 |
+
int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags);
|
| 572 |
+
|
| 573 |
+
|
| 574 |
+
/**
|
| 575 |
+
* Create and initialise an AVHWFramesContext as a mapping of another existing
|
| 576 |
+
* AVHWFramesContext on a different device.
|
| 577 |
+
*
|
| 578 |
+
* av_hwframe_ctx_init() should not be called after this.
|
| 579 |
+
*
|
| 580 |
+
* @param derived_frame_ctx On success, a reference to the newly created
|
| 581 |
+
* AVHWFramesContext.
|
| 582 |
+
* @param format The AVPixelFormat for the derived context.
|
| 583 |
+
* @param derived_device_ctx A reference to the device to create the new
|
| 584 |
+
* AVHWFramesContext on.
|
| 585 |
+
* @param source_frame_ctx A reference to an existing AVHWFramesContext
|
| 586 |
+
* which will be mapped to the derived context.
|
| 587 |
+
* @param flags Some combination of AV_HWFRAME_MAP_* flags, defining the
|
| 588 |
+
* mapping parameters to apply to frames which are allocated
|
| 589 |
+
* in the derived device.
|
| 590 |
+
* @return Zero on success, negative AVERROR code on failure.
|
| 591 |
+
*/
|
| 592 |
+
int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx,
|
| 593 |
+
enum AVPixelFormat format,
|
| 594 |
+
AVBufferRef *derived_device_ctx,
|
| 595 |
+
AVBufferRef *source_frame_ctx,
|
| 596 |
+
int flags);
|
| 597 |
+
|
| 598 |
+
#endif /* AVUTIL_HWCONTEXT_H */
|
ffmpeg/include/libavutil/hwcontext_cuda.h
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 20 |
+
#ifndef AVUTIL_HWCONTEXT_CUDA_H
|
| 21 |
+
#define AVUTIL_HWCONTEXT_CUDA_H
|
| 22 |
+
|
| 23 |
+
#ifndef CUDA_VERSION
|
| 24 |
+
#include <cuda.h>
|
| 25 |
+
#endif
|
| 26 |
+
|
| 27 |
+
#include "pixfmt.h"
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @file
|
| 31 |
+
* An API-specific header for AV_HWDEVICE_TYPE_CUDA.
|
| 32 |
+
*
|
| 33 |
+
* This API supports dynamic frame pools. AVHWFramesContext.pool must return
|
| 34 |
+
* AVBufferRefs whose data pointer is a CUdeviceptr.
|
| 35 |
+
*/
|
| 36 |
+
|
| 37 |
+
typedef struct AVCUDADeviceContextInternal AVCUDADeviceContextInternal;
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* This struct is allocated as AVHWDeviceContext.hwctx
|
| 41 |
+
*/
|
| 42 |
+
typedef struct AVCUDADeviceContext {
|
| 43 |
+
CUcontext cuda_ctx;
|
| 44 |
+
CUstream stream;
|
| 45 |
+
AVCUDADeviceContextInternal *internal;
|
| 46 |
+
} AVCUDADeviceContext;
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* AVHWFramesContext.hwctx is currently not used
|
| 50 |
+
*/
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* @defgroup hwcontext_cuda Device context creation flags
|
| 54 |
+
*
|
| 55 |
+
* Flags for av_hwdevice_ctx_create.
|
| 56 |
+
*
|
| 57 |
+
* @{
|
| 58 |
+
*/
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Use primary device context instead of creating a new one.
|
| 62 |
+
*/
|
| 63 |
+
#define AV_CUDA_USE_PRIMARY_CONTEXT (1 << 0)
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* Use current device context instead of creating a new one.
|
| 67 |
+
*/
|
| 68 |
+
#define AV_CUDA_USE_CURRENT_CONTEXT (1 << 1)
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* @}
|
| 72 |
+
*/
|
| 73 |
+
|
| 74 |
+
#endif /* AVUTIL_HWCONTEXT_CUDA_H */
|
ffmpeg/include/libavutil/hwcontext_d3d11va.h
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_HWCONTEXT_D3D11VA_H
|
| 20 |
+
#define AVUTIL_HWCONTEXT_D3D11VA_H
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* @file
|
| 24 |
+
* An API-specific header for AV_HWDEVICE_TYPE_D3D11VA.
|
| 25 |
+
*
|
| 26 |
+
* The default pool implementation will be fixed-size if initial_pool_size is
|
| 27 |
+
* set (and allocate elements from an array texture). Otherwise it will allocate
|
| 28 |
+
* individual textures. Be aware that decoding requires a single array texture.
|
| 29 |
+
*
|
| 30 |
+
* Using sw_format==AV_PIX_FMT_YUV420P has special semantics, and maps to
|
| 31 |
+
* DXGI_FORMAT_420_OPAQUE. av_hwframe_transfer_data() is not supported for
|
| 32 |
+
* this format. Refer to MSDN for details.
|
| 33 |
+
*
|
| 34 |
+
* av_hwdevice_ctx_create() for this device type supports a key named "debug"
|
| 35 |
+
* for the AVDictionary entry. If this is set to any value, the device creation
|
| 36 |
+
* code will try to load various supported D3D debugging layers.
|
| 37 |
+
*/
|
| 38 |
+
|
| 39 |
+
#include <d3d11.h>
|
| 40 |
+
#include <stdint.h>
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* This struct is allocated as AVHWDeviceContext.hwctx
|
| 44 |
+
*/
|
| 45 |
+
typedef struct AVD3D11VADeviceContext {
|
| 46 |
+
/**
|
| 47 |
+
* Device used for texture creation and access. This can also be used to
|
| 48 |
+
* set the libavcodec decoding device.
|
| 49 |
+
*
|
| 50 |
+
* Must be set by the user. This is the only mandatory field - the other
|
| 51 |
+
* device context fields are set from this and are available for convenience.
|
| 52 |
+
*
|
| 53 |
+
* Deallocating the AVHWDeviceContext will always release this interface,
|
| 54 |
+
* and it does not matter whether it was user-allocated.
|
| 55 |
+
*/
|
| 56 |
+
ID3D11Device *device;
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* If unset, this will be set from the device field on init.
|
| 60 |
+
*
|
| 61 |
+
* Deallocating the AVHWDeviceContext will always release this interface,
|
| 62 |
+
* and it does not matter whether it was user-allocated.
|
| 63 |
+
*/
|
| 64 |
+
ID3D11DeviceContext *device_context;
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* If unset, this will be set from the device field on init.
|
| 68 |
+
*
|
| 69 |
+
* Deallocating the AVHWDeviceContext will always release this interface,
|
| 70 |
+
* and it does not matter whether it was user-allocated.
|
| 71 |
+
*/
|
| 72 |
+
ID3D11VideoDevice *video_device;
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* If unset, this will be set from the device_context field on init.
|
| 76 |
+
*
|
| 77 |
+
* Deallocating the AVHWDeviceContext will always release this interface,
|
| 78 |
+
* and it does not matter whether it was user-allocated.
|
| 79 |
+
*/
|
| 80 |
+
ID3D11VideoContext *video_context;
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Callbacks for locking. They protect accesses to device_context and
|
| 84 |
+
* video_context calls. They also protect access to the internal staging
|
| 85 |
+
* texture (for av_hwframe_transfer_data() calls). They do NOT protect
|
| 86 |
+
* access to hwcontext or decoder state in general.
|
| 87 |
+
*
|
| 88 |
+
* If unset on init, the hwcontext implementation will set them to use an
|
| 89 |
+
* internal mutex.
|
| 90 |
+
*
|
| 91 |
+
* The underlying lock must be recursive. lock_ctx is for free use by the
|
| 92 |
+
* locking implementation.
|
| 93 |
+
*/
|
| 94 |
+
void (*lock)(void *lock_ctx);
|
| 95 |
+
void (*unlock)(void *lock_ctx);
|
| 96 |
+
void *lock_ctx;
|
| 97 |
+
} AVD3D11VADeviceContext;
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* D3D11 frame descriptor for pool allocation.
|
| 101 |
+
*
|
| 102 |
+
* In user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs
|
| 103 |
+
* with the data pointer pointing at an object of this type describing the
|
| 104 |
+
* planes of the frame.
|
| 105 |
+
*
|
| 106 |
+
* This has no use outside of custom allocation, and AVFrame AVBufferRef do not
|
| 107 |
+
* necessarily point to an instance of this struct.
|
| 108 |
+
*/
|
| 109 |
+
typedef struct AVD3D11FrameDescriptor {
|
| 110 |
+
/**
|
| 111 |
+
* The texture in which the frame is located. The reference count is
|
| 112 |
+
* managed by the AVBufferRef, and destroying the reference will release
|
| 113 |
+
* the interface.
|
| 114 |
+
*
|
| 115 |
+
* Normally stored in AVFrame.data[0].
|
| 116 |
+
*/
|
| 117 |
+
ID3D11Texture2D *texture;
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* The index into the array texture element representing the frame, or 0
|
| 121 |
+
* if the texture is not an array texture.
|
| 122 |
+
*
|
| 123 |
+
* Normally stored in AVFrame.data[1] (cast from intptr_t).
|
| 124 |
+
*/
|
| 125 |
+
intptr_t index;
|
| 126 |
+
} AVD3D11FrameDescriptor;
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* This struct is allocated as AVHWFramesContext.hwctx
|
| 130 |
+
*/
|
| 131 |
+
typedef struct AVD3D11VAFramesContext {
|
| 132 |
+
/**
|
| 133 |
+
* The canonical texture used for pool allocation. If this is set to NULL
|
| 134 |
+
* on init, the hwframes implementation will allocate and set an array
|
| 135 |
+
* texture if initial_pool_size > 0.
|
| 136 |
+
*
|
| 137 |
+
* The only situation when the API user should set this is:
|
| 138 |
+
* - the user wants to do manual pool allocation (setting
|
| 139 |
+
* AVHWFramesContext.pool), instead of letting AVHWFramesContext
|
| 140 |
+
* allocate the pool
|
| 141 |
+
* - of an array texture
|
| 142 |
+
* - and wants it to use it for decoding
|
| 143 |
+
* - this has to be done before calling av_hwframe_ctx_init()
|
| 144 |
+
*
|
| 145 |
+
* Deallocating the AVHWFramesContext will always release this interface,
|
| 146 |
+
* and it does not matter whether it was user-allocated.
|
| 147 |
+
*
|
| 148 |
+
* This is in particular used by the libavcodec D3D11VA hwaccel, which
|
| 149 |
+
* requires a single array texture. It will create ID3D11VideoDecoderOutputView
|
| 150 |
+
* objects for each array texture element on decoder initialization.
|
| 151 |
+
*/
|
| 152 |
+
ID3D11Texture2D *texture;
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* D3D11_TEXTURE2D_DESC.BindFlags used for texture creation. The user must
|
| 156 |
+
* at least set D3D11_BIND_DECODER if the frames context is to be used for
|
| 157 |
+
* video decoding.
|
| 158 |
+
* This field is ignored/invalid if a user-allocated texture is provided.
|
| 159 |
+
*/
|
| 160 |
+
UINT BindFlags;
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* D3D11_TEXTURE2D_DESC.MiscFlags used for texture creation.
|
| 164 |
+
* This field is ignored/invalid if a user-allocated texture is provided.
|
| 165 |
+
*/
|
| 166 |
+
UINT MiscFlags;
|
| 167 |
+
|
| 168 |
+
/**
|
| 169 |
+
* In case if texture structure member above is not NULL contains the same texture
|
| 170 |
+
* pointer for all elements and different indexes into the array texture.
|
| 171 |
+
* In case if texture structure member above is NULL, all elements contains
|
| 172 |
+
* pointers to separate non-array textures and 0 indexes.
|
| 173 |
+
* This field is ignored/invalid if a user-allocated texture is provided.
|
| 174 |
+
*/
|
| 175 |
+
AVD3D11FrameDescriptor *texture_infos;
|
| 176 |
+
} AVD3D11VAFramesContext;
|
| 177 |
+
|
| 178 |
+
#endif /* AVUTIL_HWCONTEXT_D3D11VA_H */
|
ffmpeg/include/libavutil/hwcontext_d3d12va.h
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Direct3D 12 HW acceleration.
|
| 3 |
+
*
|
| 4 |
+
* copyright (c) 2022-2023 Wu Jianhua <toqsxw@outlook.com>
|
| 5 |
+
*
|
| 6 |
+
* This file is part of FFmpeg.
|
| 7 |
+
*
|
| 8 |
+
* FFmpeg is free software; you can redistribute it and/or
|
| 9 |
+
* modify it under the terms of the GNU Lesser General Public
|
| 10 |
+
* License as published by the Free Software Foundation; either
|
| 11 |
+
* version 2.1 of the License, or (at your option) any later version.
|
| 12 |
+
*
|
| 13 |
+
* FFmpeg is distributed in the hope that it will be useful,
|
| 14 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 16 |
+
* Lesser General Public License for more details.
|
| 17 |
+
*
|
| 18 |
+
* You should have received a copy of the GNU Lesser General Public
|
| 19 |
+
* License along with FFmpeg; if not, write to the Free Software
|
| 20 |
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
#ifndef AVUTIL_HWCONTEXT_D3D12VA_H
|
| 24 |
+
#define AVUTIL_HWCONTEXT_D3D12VA_H
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @file
|
| 28 |
+
* An API-specific header for AV_HWDEVICE_TYPE_D3D12VA.
|
| 29 |
+
*
|
| 30 |
+
* AVHWFramesContext.pool must contain AVBufferRefs whose
|
| 31 |
+
* data pointer points to an AVD3D12VAFrame struct.
|
| 32 |
+
*/
|
| 33 |
+
#include <stdint.h>
|
| 34 |
+
#include <initguid.h>
|
| 35 |
+
#include <d3d12.h>
|
| 36 |
+
#include <d3d12sdklayers.h>
|
| 37 |
+
#include <d3d12video.h>
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* @brief This struct is allocated as AVHWDeviceContext.hwctx
|
| 41 |
+
*
|
| 42 |
+
*/
|
| 43 |
+
typedef struct AVD3D12VADeviceContext {
|
| 44 |
+
/**
|
| 45 |
+
* Device used for objects creation and access. This can also be
|
| 46 |
+
* used to set the libavcodec decoding device.
|
| 47 |
+
*
|
| 48 |
+
* Can be set by the user. This is the only mandatory field - the other
|
| 49 |
+
* device context fields are set from this and are available for convenience.
|
| 50 |
+
*
|
| 51 |
+
* Deallocating the AVHWDeviceContext will always release this interface,
|
| 52 |
+
* and it does not matter whether it was user-allocated.
|
| 53 |
+
*/
|
| 54 |
+
ID3D12Device *device;
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* If unset, this will be set from the device field on init.
|
| 58 |
+
*
|
| 59 |
+
* Deallocating the AVHWDeviceContext will always release this interface,
|
| 60 |
+
* and it does not matter whether it was user-allocated.
|
| 61 |
+
*/
|
| 62 |
+
ID3D12VideoDevice *video_device;
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Callbacks for locking. They protect access to the internal staging
|
| 66 |
+
* texture (for av_hwframe_transfer_data() calls). They do NOT protect
|
| 67 |
+
* access to hwcontext or decoder state in general.
|
| 68 |
+
*
|
| 69 |
+
* If unset on init, the hwcontext implementation will set them to use an
|
| 70 |
+
* internal mutex.
|
| 71 |
+
*
|
| 72 |
+
* The underlying lock must be recursive. lock_ctx is for free use by the
|
| 73 |
+
* locking implementation.
|
| 74 |
+
*/
|
| 75 |
+
void (*lock)(void *lock_ctx);
|
| 76 |
+
void (*unlock)(void *lock_ctx);
|
| 77 |
+
void *lock_ctx;
|
| 78 |
+
} AVD3D12VADeviceContext;
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* @brief This struct is used to sync d3d12 execution
|
| 82 |
+
*
|
| 83 |
+
*/
|
| 84 |
+
typedef struct AVD3D12VASyncContext {
|
| 85 |
+
/**
|
| 86 |
+
* D3D12 fence object
|
| 87 |
+
*/
|
| 88 |
+
ID3D12Fence *fence;
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* A handle to the event object that's raised when the fence
|
| 92 |
+
* reaches a certain value.
|
| 93 |
+
*/
|
| 94 |
+
HANDLE event;
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* The fence value used for sync
|
| 98 |
+
*/
|
| 99 |
+
uint64_t fence_value;
|
| 100 |
+
} AVD3D12VASyncContext;
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* @brief D3D12VA frame descriptor for pool allocation.
|
| 104 |
+
*
|
| 105 |
+
*/
|
| 106 |
+
typedef struct AVD3D12VAFrame {
|
| 107 |
+
/**
|
| 108 |
+
* The texture in which the frame is located. The reference count is
|
| 109 |
+
* managed by the AVBufferRef, and destroying the reference will release
|
| 110 |
+
* the interface.
|
| 111 |
+
*/
|
| 112 |
+
ID3D12Resource *texture;
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* The sync context for the texture
|
| 116 |
+
*
|
| 117 |
+
* @see: https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-video-overview#directx-12-fences
|
| 118 |
+
*/
|
| 119 |
+
AVD3D12VASyncContext sync_ctx;
|
| 120 |
+
} AVD3D12VAFrame;
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* @brief This struct is allocated as AVHWFramesContext.hwctx
|
| 124 |
+
*
|
| 125 |
+
*/
|
| 126 |
+
typedef struct AVD3D12VAFramesContext {
|
| 127 |
+
/**
|
| 128 |
+
* DXGI_FORMAT format. MUST be compatible with the pixel format.
|
| 129 |
+
* If unset, will be automatically set.
|
| 130 |
+
*/
|
| 131 |
+
DXGI_FORMAT format;
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* Options for working with resources.
|
| 135 |
+
* If unset, this will be D3D12_RESOURCE_FLAG_NONE.
|
| 136 |
+
*
|
| 137 |
+
* @see https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags
|
| 138 |
+
*/
|
| 139 |
+
D3D12_RESOURCE_FLAGS flags;
|
| 140 |
+
} AVD3D12VAFramesContext;
|
| 141 |
+
|
| 142 |
+
#endif /* AVUTIL_HWCONTEXT_D3D12VA_H */
|
ffmpeg/include/libavutil/hwcontext_drm.h
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#ifndef AVUTIL_HWCONTEXT_DRM_H
|
| 20 |
+
#define AVUTIL_HWCONTEXT_DRM_H
|
| 21 |
+
|
| 22 |
+
#include <stddef.h>
|
| 23 |
+
#include <stdint.h>
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* @file
|
| 27 |
+
* API-specific header for AV_HWDEVICE_TYPE_DRM.
|
| 28 |
+
*
|
| 29 |
+
* Internal frame allocation is not currently supported - all frames
|
| 30 |
+
* must be allocated by the user. Thus AVHWFramesContext is always
|
| 31 |
+
* NULL, though this may change if support for frame allocation is
|
| 32 |
+
* added in future.
|
| 33 |
+
*/
|
| 34 |
+
|
| 35 |
+
enum {
|
| 36 |
+
/**
|
| 37 |
+
* The maximum number of layers/planes in a DRM frame.
|
| 38 |
+
*/
|
| 39 |
+
AV_DRM_MAX_PLANES = 4
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* DRM object descriptor.
|
| 44 |
+
*
|
| 45 |
+
* Describes a single DRM object, addressing it as a PRIME file
|
| 46 |
+
* descriptor.
|
| 47 |
+
*/
|
| 48 |
+
typedef struct AVDRMObjectDescriptor {
|
| 49 |
+
/**
|
| 50 |
+
* DRM PRIME fd for the object.
|
| 51 |
+
*/
|
| 52 |
+
int fd;
|
| 53 |
+
/**
|
| 54 |
+
* Total size of the object.
|
| 55 |
+
*
|
| 56 |
+
* (This includes any parts not which do not contain image data.)
|
| 57 |
+
*/
|
| 58 |
+
size_t size;
|
| 59 |
+
/**
|
| 60 |
+
* Format modifier applied to the object (DRM_FORMAT_MOD_*).
|
| 61 |
+
*
|
| 62 |
+
* If the format modifier is unknown then this should be set to
|
| 63 |
+
* DRM_FORMAT_MOD_INVALID.
|
| 64 |
+
*/
|
| 65 |
+
uint64_t format_modifier;
|
| 66 |
+
} AVDRMObjectDescriptor;
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* DRM plane descriptor.
|
| 70 |
+
*
|
| 71 |
+
* Describes a single plane of a layer, which is contained within
|
| 72 |
+
* a single object.
|
| 73 |
+
*/
|
| 74 |
+
typedef struct AVDRMPlaneDescriptor {
|
| 75 |
+
/**
|
| 76 |
+
* Index of the object containing this plane in the objects
|
| 77 |
+
* array of the enclosing frame descriptor.
|
| 78 |
+
*/
|
| 79 |
+
int object_index;
|
| 80 |
+
/**
|
| 81 |
+
* Offset within that object of this plane.
|
| 82 |
+
*/
|
| 83 |
+
ptrdiff_t offset;
|
| 84 |
+
/**
|
| 85 |
+
* Pitch (linesize) of this plane.
|
| 86 |
+
*/
|
| 87 |
+
ptrdiff_t pitch;
|
| 88 |
+
} AVDRMPlaneDescriptor;
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* DRM layer descriptor.
|
| 92 |
+
*
|
| 93 |
+
* Describes a single layer within a frame. This has the structure
|
| 94 |
+
* defined by its format, and will contain one or more planes.
|
| 95 |
+
*/
|
| 96 |
+
typedef struct AVDRMLayerDescriptor {
|
| 97 |
+
/**
|
| 98 |
+
* Format of the layer (DRM_FORMAT_*).
|
| 99 |
+
*/
|
| 100 |
+
uint32_t format;
|
| 101 |
+
/**
|
| 102 |
+
* Number of planes in the layer.
|
| 103 |
+
*
|
| 104 |
+
* This must match the number of planes required by format.
|
| 105 |
+
*/
|
| 106 |
+
int nb_planes;
|
| 107 |
+
/**
|
| 108 |
+
* Array of planes in this layer.
|
| 109 |
+
*/
|
| 110 |
+
AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES];
|
| 111 |
+
} AVDRMLayerDescriptor;
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* DRM frame descriptor.
|
| 115 |
+
*
|
| 116 |
+
* This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames.
|
| 117 |
+
* It is also used by user-allocated frame pools - allocating in
|
| 118 |
+
* AVHWFramesContext.pool must return AVBufferRefs which contain
|
| 119 |
+
* an object of this type.
|
| 120 |
+
*
|
| 121 |
+
* The fields of this structure should be set such it can be
|
| 122 |
+
* imported directly by EGL using the EGL_EXT_image_dma_buf_import
|
| 123 |
+
* and EGL_EXT_image_dma_buf_import_modifiers extensions.
|
| 124 |
+
* (Note that the exact layout of a particular format may vary between
|
| 125 |
+
* platforms - we only specify that the same platform should be able
|
| 126 |
+
* to import it.)
|
| 127 |
+
*
|
| 128 |
+
* The total number of planes must not exceed AV_DRM_MAX_PLANES, and
|
| 129 |
+
* the order of the planes by increasing layer index followed by
|
| 130 |
+
* increasing plane index must be the same as the order which would
|
| 131 |
+
* be used for the data pointers in the equivalent software format.
|
| 132 |
+
*/
|
| 133 |
+
typedef struct AVDRMFrameDescriptor {
|
| 134 |
+
/**
|
| 135 |
+
* Number of DRM objects making up this frame.
|
| 136 |
+
*/
|
| 137 |
+
int nb_objects;
|
| 138 |
+
/**
|
| 139 |
+
* Array of objects making up the frame.
|
| 140 |
+
*/
|
| 141 |
+
AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES];
|
| 142 |
+
/**
|
| 143 |
+
* Number of layers in the frame.
|
| 144 |
+
*/
|
| 145 |
+
int nb_layers;
|
| 146 |
+
/**
|
| 147 |
+
* Array of layers in the frame.
|
| 148 |
+
*/
|
| 149 |
+
AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES];
|
| 150 |
+
} AVDRMFrameDescriptor;
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* DRM device.
|
| 154 |
+
*
|
| 155 |
+
* Allocated as AVHWDeviceContext.hwctx.
|
| 156 |
+
*/
|
| 157 |
+
typedef struct AVDRMDeviceContext {
|
| 158 |
+
/**
|
| 159 |
+
* File descriptor of DRM device.
|
| 160 |
+
*
|
| 161 |
+
* This is used as the device to create frames on, and may also be
|
| 162 |
+
* used in some derivation and mapping operations.
|
| 163 |
+
*
|
| 164 |
+
* If no device is required, set to -1.
|
| 165 |
+
*/
|
| 166 |
+
int fd;
|
| 167 |
+
} AVDRMDeviceContext;
|
| 168 |
+
|
| 169 |
+
#endif /* AVUTIL_HWCONTEXT_DRM_H */
|
ffmpeg/include/libavutil/hwcontext_dxva2.h
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 20 |
+
#ifndef AVUTIL_HWCONTEXT_DXVA2_H
|
| 21 |
+
#define AVUTIL_HWCONTEXT_DXVA2_H
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* @file
|
| 25 |
+
* An API-specific header for AV_HWDEVICE_TYPE_DXVA2.
|
| 26 |
+
*
|
| 27 |
+
* Only fixed-size pools are supported.
|
| 28 |
+
*
|
| 29 |
+
* For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs
|
| 30 |
+
* with the data pointer set to a pointer to IDirect3DSurface9.
|
| 31 |
+
*/
|
| 32 |
+
|
| 33 |
+
#include <d3d9.h>
|
| 34 |
+
#include <dxva2api.h>
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* This struct is allocated as AVHWDeviceContext.hwctx
|
| 38 |
+
*/
|
| 39 |
+
typedef struct AVDXVA2DeviceContext {
|
| 40 |
+
IDirect3DDeviceManager9 *devmgr;
|
| 41 |
+
} AVDXVA2DeviceContext;
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* This struct is allocated as AVHWFramesContext.hwctx
|
| 45 |
+
*/
|
| 46 |
+
typedef struct AVDXVA2FramesContext {
|
| 47 |
+
/**
|
| 48 |
+
* The surface type (e.g. DXVA2_VideoProcessorRenderTarget or
|
| 49 |
+
* DXVA2_VideoDecoderRenderTarget). Must be set by the caller.
|
| 50 |
+
*/
|
| 51 |
+
DWORD surface_type;
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* The surface pool. When an external pool is not provided by the caller,
|
| 55 |
+
* this will be managed (allocated and filled on init, freed on uninit) by
|
| 56 |
+
* libavutil.
|
| 57 |
+
*/
|
| 58 |
+
IDirect3DSurface9 **surfaces;
|
| 59 |
+
int nb_surfaces;
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Certain drivers require the decoder to be destroyed before the surfaces.
|
| 63 |
+
* To allow internally managed pools to work properly in such cases, this
|
| 64 |
+
* field is provided.
|
| 65 |
+
*
|
| 66 |
+
* If it is non-NULL, libavutil will call IDirectXVideoDecoder_Release() on
|
| 67 |
+
* it just before the internal surface pool is freed.
|
| 68 |
+
*
|
| 69 |
+
* This is for convenience only. Some code uses other methods to manage the
|
| 70 |
+
* decoder reference.
|
| 71 |
+
*/
|
| 72 |
+
IDirectXVideoDecoder *decoder_to_release;
|
| 73 |
+
} AVDXVA2FramesContext;
|
| 74 |
+
|
| 75 |
+
#endif /* AVUTIL_HWCONTEXT_DXVA2_H */
|