1 /*
2 * Various pretty-printing functions for use within FFmpeg
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdio.h>
23 #include <stdint.h>
24
36
38
39 #define HEXDUMP_PRINT(...) \
40 do { \
41 if (!f) \
42 av_log(avcl, level, __VA_ARGS__); \
43 else \
44 fprintf(f, __VA_ARGS__); \
45 } while (0)
46
49 {
51
52 for (i = 0; i <
size; i += 16) {
53 len = size - i;
54 if (len > 16)
55 len = 16;
57 for (j = 0; j < 16; j++) {
58 if (j < len)
60 else
62 }
64 for (j = 0; j <
len; j++) {
65 c = buf[i + j];
66 if (c < ' ' || c > '~')
67 c = '.';
69 }
71 }
72 }
73
75 {
77 }
78
80 {
82 }
83
86 {
90 /* DTS is _always_ valid after av_read_frame() */
94 else
96 /* PTS may not be known if B-frames are present. */
100 else
104 if (dump_payload)
106 }
107
109 {
111 }
112
115 {
117 }
118
119
121 {
122 uint64_t v =
lrintf(d * 100);
123 if (!v)
125 else if (v % 100)
127 else if (v % (100 * 1000))
129 else
131 }
132
134 {
137
140 if (strcmp(
"language", tag->
key)) {
141 const char *p = tag->
value;
143 "%s %-16s: ", indent, tag->
key);
144 while (*p) {
146 size_t len = strcspn(p,
"\x8\xa\xb\xc\xd");
152 if (*p) p++;
153 }
155 }
156 }
157 }
158
159 /* param change side data*/
161 {
166
167 if (!data || sd->
size < 4)
169
171 data += 4;
172 size -= 4;
173
175 if (size < 4)
178 data += 4;
179 size -= 4;
181 }
183 if (size < 8)
186 data += 8;
187 size -= 8;
190 }
192 if (size < 4)
195 data += 4;
196 size -= 4;
198 }
200 if (size < 8)
203 data += 4;
204 size -= 4;
206 data += 4;
207 size -= 4;
209 }
210
211 return;
214 }
215
216 /* replaygain side data*/
218 {
220 if (gain == INT32_MIN)
222 else
225 }
226
228 {
230 if (!peak)
232 else
235 }
236
238 {
240
241 if (sd->
size <
sizeof(*rg)) {
243 return;
244 }
246
251 }
252
254 {
256
257 if (sd->
size <
sizeof(*stereo)) {
259 return;
260 }
261
263
265
268 }
269
271 {
273
274 if (sd->
size <
sizeof(*ast)) {
276 return;
277 }
278
279 switch (*ast) {
282 break;
285 break;
288 break;
291 break;
294 break;
297 break;
300 break;
303 break;
306 break;
307 default:
309 break;
310 }
311 }
312
314 {
316
317 if (sd->
size <
sizeof(*cpb)) {
319 return;
320 }
321
323 "bitrate max/min/avg: %d/%d/%d buffer size: %d vbv_delay: %"PRId64,
327 }
328
332 "has_primaries:%d has_luminance:%d "
333 "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
334 "min_luminance=%f, max_luminance=%f",
344 }
345
347 {
350 "MaxCLL=%d, MaxFALL=%d",
352 }
353
355 {
357 double yaw, pitch, roll;
358
359 if (sd->
size <
sizeof(*spherical)) {
361 return;
362 }
363
365
366 yaw = ((double)spherical->
yaw) / (1 << 16);
367 pitch = ((double)spherical->
pitch) / (1 << 16);
368 roll = ((double)spherical->
roll) / (1 << 16);
370
374 &l, &t, &r, &b);
377 l, t, r, b);
380 }
381 }
382
384 {
385 int i;
386
389
393
397 break;
400 break;
404 break;
407 break;
411 break;
415 break;
419 break;
423 break;
427 break;
431 break;
434 break;
438 break;
441 break;
442 default:
444 "unknown side data type %d (%d bytes)", sd.
type, sd.
size);
445 break;
446 }
447
449 }
450 }
451
452 /* "user interface" functions */
454 int index,
int is_output)
455 {
462 int ret;
463
465 if (!avctx)
466 return;
467
469 if (ret < 0) {
471 return;
472 }
473
474 // Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
476 avctx->
codec = st->codec->codec;
477 avctx->
qmin = st->codec->qmin;
478 avctx->
qmax = st->codec->qmax;
481
482 if (separator)
483 av_opt_set(avctx,
"dump_separator", separator, 0);
486
488
489 /* the pid is an important information, so we display it */
490 /* XXX: add a generic system */
493 if (lang)
498
505 1024 * 1024);
508 display_aspect_ratio.
num, display_aspect_ratio.
den);
509 }
510
516
517 if (fps || tbr || tbn || tbc)
519
520 if (fps)
522 if (tbr)
524 if (tbn)
526 if (tbc)
528 }
529
555
557
559 }
560
562 const char *url, int is_output)
563 {
564 int i;
567 return;
568
570 is_output ? "Output" : "Input",
571 index,
573 is_output ? "to" : "from", url);
575
576 if (!is_output) {
579 int hours, mins, secs, us;
583 mins = secs / 60;
584 secs %= 60;
585 hours = mins / 60;
586 mins %= 60;
589 } else {
591 }
593 int secs, us;
599 secs,
601 }
605 else
608 }
609
617
619 }
620
622 int j, k, total = 0;
627 name ? name->
value :
"");
631 index, is_output);
633 }
635 }
638 }
639
641 if (!printed[i])
643
645 }
unsigned int nb_chapters
Number of chapters in AVChapter array.
int32_t pitch
Rotation around the right vector [-90, 90].
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
const struct AVCodec * codec
void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
Send a nice dump of a packet to the specified file stream.
unsigned MaxCLL
Max content light level (cd/m^2).
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
#define AV_LOG_WARNING
Something somehow does not look correct.
static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData *sd)
int max_bitrate
Maximum bitrate of the stream, in bits per second.
AVRational sample_aspect_ratio
Video only.
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection...
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
uint8_t * dump_separator
dump format separator.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
static void dump_audioservicetype(void *ctx, AVPacketSideData *sd)
An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of structures with info about macroblo...
This struct describes the properties of an encoded stream.
int min_bitrate
Minimum bitrate of the stream, in bits per second.
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
Mastering display metadata (based on SMPTE-2086:2014).
static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt, int dump_payload, AVRational time_base)
uint64_t vbv_delay
The delay between the time the packet this structure is associated with is received and the time when...
unsigned int nb_stream_indexes
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int id
Format-specific stream ID.
void av_spherical_tile_bounds(const AVSphericalMapping *map, size_t width, size_t height, size_t *left, size_t *top, size_t *right, size_t *bottom)
Convert the bounding fields from an AVSphericalVideo from 0.32 fixed point to pixels.
int nb_side_data
The number of elements in the AVStream.side_data array.
AVStream ** streams
A list of all streams in the file.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload, const AVStream *st)
Send a nice dump of a packet to the log.
const char * av_stereo3d_type_name(unsigned int type)
Provide a human-readable name of a given stereo3d type.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
int buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned int * stream_index
int32_t album_gain
Same as track_gain, but for the whole album.
static void print_fps(double d, const char *postfix)
struct AVOutputFormat * oformat
The output container format.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
AVDictionary * metadata
Metadata that applies to the whole file.
int flags
Additional information about the frame packing.
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette...
void av_hex_dump(FILE *f, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the specified file stream.
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
int qmax
maximum quantizer
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVMediaType codec_type
General type of the encoded data.
enum AVPacketSideDataType type
static void dump_cpb(void *ctx, AVPacketSideData *sd)
AVRational avg_frame_rate
Average framerate.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int flags
A combination of AV_PKT_FLAG values.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
audio channel layout utility functions
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
This side data contains quality related information from the encoder.
#define HEXDUMP_PRINT(...)
static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
static void dump_paramchange(void *ctx, AVPacketSideData *sd)
int32_t yaw
Rotation around the up vector [-180, 180].
uint32_t padding
Number of pixels to pad from the edge of each cube face.
int64_t end
chapter start/end time in time_base units
Content light level (based on CTA-861.3).
This structure describes the bitrate properties of an encoded bitstream.
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
enum AVStereo3DType type
How views are packed within the video.
#define AV_LOG_INFO
Standard information.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
static void dump_replaygain(void *ctx, AVPacketSideData *sd)
main external API structure.
int qmin
minimum quantizer
int32_t roll
Rotation around the forward vector [-180, 180].
Rational number (pair of numerator and denominator).
static void dump_content_light_metadata(void *ctx, AVPacketSideData *sd)
static void hex_dump_internal(void *avcl, FILE *f, int level, const uint8_t *buf, int size)
This structure describes how to handle spherical videos, outlining information about projection...
This side data should be associated with an audio stream and contains ReplayGain information in form ...
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static void print_peak(void *ctx, const char *str, uint32_t peak)
enum AVSphericalProjection projection
Projection type.
static void print_gain(void *ctx, const char *str, int32_t gain)
int disposition
AV_DISPOSITION_* bit field.
AVRational time_base
time base in which the start/end timestamps are specified
unsigned properties
Properties of the stream that gets decoded.
struct AVInputFormat * iformat
The input container format.
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
uint32_t album_peak
Same as track_peak, but for the whole album,.
const char * av_get_channel_name(uint64_t channel)
Get the name of a given channel.
int avg_bitrate
Average bitrate of the stream, in bits per second.
int codec_info_nb_frames
Number of frames that have been demuxed during avformat_find_stream_info()
This side data corresponds to the AVCPBProperties struct.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
static void dump_stereo3d(void *ctx, AVPacketSideData *sd)
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
int32_t track_gain
Track replay gain in microbels (divide by 100000 to get the value in dB).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static void dump_mastering_display_metadata(void *ctx, AVPacketSideData *sd)
void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
AVRational r_frame_rate
Real base framerate of the stream.
ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification).
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
unsigned MaxFALL
Max average light level per frame (cd/m^2).
This structure stores compressed data.
const char * av_spherical_projection_name(enum AVSphericalProjection projection)
Provide a human-readable name of a given AVSphericalProjection.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.