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
34
36
37 #define HEXDUMP_PRINT(...) \
38 do { \
39 if (!f) \
40 av_log(avcl, level, __VA_ARGS__); \
41 else \
42 fprintf(f, __VA_ARGS__); \
43 } while (0)
44
47 {
49
50 for (i = 0; i <
size; i += 16) {
51 len = size - i;
52 if (len > 16)
53 len = 16;
55 for (j = 0; j < 16; j++) {
56 if (j < len)
58 else
60 }
62 for (j = 0; j <
len; j++) {
63 c = buf[i + j];
64 if (c < ' ' || c > '~')
65 c = '.';
67 }
69 }
70 }
71
73 {
75 }
76
78 {
80 }
81
84 {
88 /* DTS is _always_ valid after av_read_frame() */
92 else
94 /* PTS may not be known if B-frames are present. */
98 else
102 if (dump_payload)
104 }
105
107 {
109 }
110
113 {
115 }
116
117
119 {
121 if (!v)
123 else if (v % 100)
125 else if (v % (100 * 1000))
127 else
129 }
130
132 {
135
138 if (strcmp(
"language", tag->
key)) {
139 const char *p = tag->
value;
141 "%s %-16s: ", indent, tag->
key);
142 while (*p) {
143 char tmp[256];
144 size_t len = strcspn(p,
"\x8\xa\xb\xc\xd");
150 if (*p) p++;
151 }
153 }
154 }
155 }
156
157 /* param change side data*/
159 {
164
165 if (!data || sd->
size < 4)
166 goto fail;
167
169 data += 4;
170 size -= 4;
171
173 if (size < 4)
174 goto fail;
176 data += 4;
177 size -= 4;
179 }
181 if (size < 8)
182 goto fail;
184 data += 8;
185 size -= 8;
188 }
190 if (size < 4)
191 goto fail;
193 data += 4;
194 size -= 4;
196 }
198 if (size < 8)
199 goto fail;
201 data += 4;
202 size -= 4;
204 data += 4;
205 size -= 4;
207 }
208
209 return;
210 fail:
212 }
213
214 /* replaygain side data*/
216 {
218 if (gain == INT32_MIN)
220 else
223 }
224
225 static void print_peak(
void *ctx,
const char *str, uint32_t peak)
226 {
228 if (!peak)
230 else
233 }
234
236 {
238
239 if (sd->
size <
sizeof(*rg)) {
241 return;
242 }
244
249 }
250
252 {
254
255 if (sd->
size <
sizeof(*stereo)) {
257 return;
258 }
259
261
262 switch (stereo->
type) {
265 break;
268 break;
271 break;
274 break;
277 break;
280 break;
283 break;
286 break;
287 default:
289 break;
290 }
291
294 }
295
297 {
299
300 if (sd->
size <
sizeof(*ast)) {
302 return;
303 }
304
305 switch (*ast) {
308 break;
311 break;
314 break;
317 break;
320 break;
323 break;
326 break;
329 break;
332 break;
333 default:
335 break;
336 }
337 }
338
340 {
341 int i;
342
345
349
353 break;
356 break;
360 break;
363 break;
367 break;
371 break;
375 break;
379 break;
380 default:
382 "unknown side data type %d (%d bytes)", sd.
type, sd.
size);
383 break;
384 }
385
387 }
388 }
389
390 /* "user interface" functions */
392 int index,
int is_output)
393 {
400 int use_format_separator = !*codec_separator;
401
402 if (use_format_separator)
405 if (use_format_separator)
408
409 /* the pid is an important information, so we display it */
410 /* XXX: add a generic system */
413 if (lang)
418
425 1024 * 1024);
428 display_aspect_ratio.
num, display_aspect_ratio.
den);
429 }
430
436
437 if (fps || tbr || tbn || tbc)
439
440 if (fps)
442 if (tbr)
444 if (tbn)
446 if (tbc)
448 }
449
471
473
475 }
476
478 const char *url, int is_output)
479 {
480 int i;
483 return;
484
486 is_output ? "Output" : "Input",
487 index,
489 is_output ? "to" : "from", url);
491
492 if (!is_output) {
495 int hours, mins, secs, us;
499 mins = secs / 60;
500 secs %= 60;
501 hours = mins / 60;
502 mins %= 60;
505 } else {
507 }
509 int secs, us;
515 }
519 else
522 }
523
531
533 }
534
536 int j, k, total = 0;
541 name ? name->
value :
"");
545 index, is_output);
547 }
549 }
552 }
553
555 if (!printed[i])
557
559 }
unsigned int nb_chapters
Number of chapters in AVChapter array.
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.
Views are packed per line, as if interlaced.
ptrdiff_t const GLvoid * data
Views are alternated temporally.
Views are next to each other, but when upscaling apply a checkerboard pattern.
#define AV_LOG_WARNING
Something somehow does not look correct.
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
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.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
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...
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt, int dump_payload, AVRational time_base)
unsigned int nb_stream_indexes
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int id
Format-specific stream ID.
int nb_side_data
The number of elements in the AVStream.side_data array.
const AVClass * av_class
information on struct for av_log
AVStream ** streams
A list of all streams in the file.
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.
static double av_q2d(AVRational a)
Convert rational to double.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
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.
AVDictionary * metadata
Metadata that applies to the whole file.
int flags
Additional information about the frame packing.
void * av_opt_ptr(const AVClass *class, void *obj, const char *name)
Gets a pointer to the requested field in a struct.
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:
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVPacketSideDataType type
Video is not stereoscopic (and metadata has to be there).
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.
AVCodecContext * codec
Codec context associated with this stream.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
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.
#define HEXDUMP_PRINT(...)
int width
picture width / height.
static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
static void dump_paramchange(void *ctx, AVPacketSideData *sd)
int64_t end
chapter start/end time in time_base units
enum AVStereo3DType type
How views are packed within the video.
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate the string s.
static void dump_replaygain(void *ctx, AVPacketSideData *sd)
BYTE int const BYTE int int int height
rational number numerator/denominator
static void hex_dump_internal(void *avcl, FILE *f, int level, const uint8_t *buf, int size)
Views are on top of each other.
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. ...
Views are next to each other.
static void print_peak(void *ctx, const char *str, uint32_t peak)
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
struct AVInputFormat * iformat
The input container format.
double av_display_rotation_get(const int32_t matrix[9])
The display transformation matrix specifies an affine transformation that should be applied to video ...
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.
Views are packed in a checkerboard-like structure per pixel.
int codec_info_nb_frames
Number of frames that have been demuxed during av_find_stream_info()
Views are packed per column.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
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).
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
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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.
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.