2014-04-15 17:08:58 +03:00
|
|
|
/*
|
2014-06-16 13:24:53 +03:00
|
|
|
* Various pretty-printing functions for use within FFmpeg
|
2014-06-16 13:39:44 +03:00
|
|
|
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
2014-04-15 17:08:58 +03:00
|
|
|
*
|
2014-06-16 13:24:53 +03:00
|
|
|
* This file is part of FFmpeg.
|
2014-04-15 17:08:58 +03:00
|
|
|
*
|
2014-06-16 13:24:53 +03:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2014-04-15 17:08:58 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2014-06-16 13:24:53 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2014-04-15 17:08:58 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2014-06-16 13:24:53 +03:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2014-04-15 17:08:58 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2024-01-22 19:35:33 +02:00
|
|
|
#include "libavutil/avstring.h"
|
2014-04-15 17:55:23 +03:00
|
|
|
#include "libavutil/channel_layout.h"
|
|
|
|
#include "libavutil/display.h"
|
2023-11-25 16:02:11 +02:00
|
|
|
#include "libavutil/iamf.h"
|
2014-04-15 17:55:23 +03:00
|
|
|
#include "libavutil/intreadwrite.h"
|
2014-04-15 17:08:58 +03:00
|
|
|
#include "libavutil/log.h"
|
2016-03-01 03:20:17 +02:00
|
|
|
#include "libavutil/mastering_display_metadata.h"
|
2024-02-04 17:14:12 +02:00
|
|
|
#include "libavutil/ambient_viewing_environment.h"
|
2020-04-11 15:09:03 +02:00
|
|
|
#include "libavutil/dovi_meta.h"
|
2014-04-15 17:08:58 +03:00
|
|
|
#include "libavutil/mathematics.h"
|
2024-03-25 02:30:37 +02:00
|
|
|
#include "libavutil/mem.h"
|
2014-10-09 00:48:32 +03:00
|
|
|
#include "libavutil/opt.h"
|
2014-04-15 17:55:23 +03:00
|
|
|
#include "libavutil/replaygain.h"
|
2016-11-12 00:37:43 +02:00
|
|
|
#include "libavutil/spherical.h"
|
2014-07-23 11:21:28 +03:00
|
|
|
#include "libavutil/stereo3d.h"
|
2020-06-30 17:18:17 +02:00
|
|
|
#include "libavutil/timecode.h"
|
2014-04-15 17:08:58 +03:00
|
|
|
|
2022-09-21 03:03:07 +02:00
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
|
2014-04-15 17:08:58 +03:00
|
|
|
#include "avformat.h"
|
2021-04-18 15:59:35 +02:00
|
|
|
#include "internal.h"
|
2014-04-15 17:08:58 +03:00
|
|
|
|
|
|
|
#define HEXDUMP_PRINT(...) \
|
|
|
|
do { \
|
|
|
|
if (!f) \
|
|
|
|
av_log(avcl, level, __VA_ARGS__); \
|
|
|
|
else \
|
|
|
|
fprintf(f, __VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static void hex_dump_internal(void *avcl, FILE *f, int level,
|
|
|
|
const uint8_t *buf, int size)
|
|
|
|
{
|
|
|
|
int len, i, j, c;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i += 16) {
|
|
|
|
len = size - i;
|
|
|
|
if (len > 16)
|
|
|
|
len = 16;
|
|
|
|
HEXDUMP_PRINT("%08x ", i);
|
|
|
|
for (j = 0; j < 16; j++) {
|
|
|
|
if (j < len)
|
|
|
|
HEXDUMP_PRINT(" %02x", buf[i + j]);
|
|
|
|
else
|
|
|
|
HEXDUMP_PRINT(" ");
|
|
|
|
}
|
|
|
|
HEXDUMP_PRINT(" ");
|
|
|
|
for (j = 0; j < len; j++) {
|
|
|
|
c = buf[i + j];
|
|
|
|
if (c < ' ' || c > '~')
|
|
|
|
c = '.';
|
|
|
|
HEXDUMP_PRINT("%c", c);
|
|
|
|
}
|
|
|
|
HEXDUMP_PRINT("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void av_hex_dump(FILE *f, const uint8_t *buf, int size)
|
|
|
|
{
|
|
|
|
hex_dump_internal(NULL, f, 0, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
|
|
|
|
{
|
|
|
|
hex_dump_internal(avcl, NULL, level, buf, size);
|
|
|
|
}
|
|
|
|
|
2014-06-16 13:24:53 +03:00
|
|
|
static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt,
|
2014-04-15 17:08:58 +03:00
|
|
|
int dump_payload, AVRational time_base)
|
|
|
|
{
|
|
|
|
HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
|
|
|
|
HEXDUMP_PRINT(" keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
|
|
|
|
HEXDUMP_PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
|
|
|
|
/* DTS is _always_ valid after av_read_frame() */
|
|
|
|
HEXDUMP_PRINT(" dts=");
|
|
|
|
if (pkt->dts == AV_NOPTS_VALUE)
|
|
|
|
HEXDUMP_PRINT("N/A");
|
|
|
|
else
|
|
|
|
HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
|
|
|
|
/* PTS may not be known if B-frames are present. */
|
|
|
|
HEXDUMP_PRINT(" pts=");
|
|
|
|
if (pkt->pts == AV_NOPTS_VALUE)
|
|
|
|
HEXDUMP_PRINT("N/A");
|
|
|
|
else
|
|
|
|
HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
|
|
|
|
HEXDUMP_PRINT("\n");
|
|
|
|
HEXDUMP_PRINT(" size=%d\n", pkt->size);
|
|
|
|
if (dump_payload)
|
2016-03-05 19:10:00 +02:00
|
|
|
hex_dump_internal(avcl, f, level, pkt->data, pkt->size);
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
|
2014-06-16 13:24:53 +03:00
|
|
|
void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
|
2014-04-15 17:08:58 +03:00
|
|
|
{
|
|
|
|
pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
|
|
|
|
}
|
|
|
|
|
2014-06-16 13:24:53 +03:00
|
|
|
void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
|
|
|
|
const AVStream *st)
|
2014-04-15 17:08:58 +03:00
|
|
|
{
|
|
|
|
pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void print_fps(double d, const char *postfix, int log_level)
|
2014-04-15 17:08:58 +03:00
|
|
|
{
|
|
|
|
uint64_t v = lrintf(d * 100);
|
2015-04-03 21:07:06 +02:00
|
|
|
if (!v)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "%1.4f %s", d, postfix);
|
2015-04-03 21:07:06 +02:00
|
|
|
else if (v % 100)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "%3.2f %s", d, postfix);
|
2014-04-15 17:08:58 +03:00
|
|
|
else if (v % (100 * 1000))
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "%1.0f %s", d, postfix);
|
2014-04-15 17:08:58 +03:00
|
|
|
else
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "%1.0fk %s", d / 1000, postfix);
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
|
2023-11-25 16:02:11 +02:00
|
|
|
static void dump_dictionary(void *ctx, const AVDictionary *m,
|
2024-01-17 22:28:05 +02:00
|
|
|
const char *name, const char *indent,
|
|
|
|
int log_level)
|
2014-04-15 17:08:58 +03:00
|
|
|
{
|
2023-11-25 16:02:11 +02:00
|
|
|
const AVDictionaryEntry *tag = NULL;
|
|
|
|
|
|
|
|
if (!m)
|
|
|
|
return;
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%s%s:\n", indent, name);
|
2023-11-25 16:02:11 +02:00
|
|
|
while ((tag = av_dict_iterate(m, tag)))
|
|
|
|
if (strcmp("language", tag->key)) {
|
|
|
|
const char *p = tag->value;
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level,
|
2023-11-25 16:02:11 +02:00
|
|
|
"%s %-16s: ", indent, tag->key);
|
|
|
|
while (*p) {
|
|
|
|
size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
|
2023-11-25 16:02:11 +02:00
|
|
|
p += len;
|
2024-01-17 22:28:05 +02:00
|
|
|
if (*p == 0xd) av_log(ctx, log_level, " ");
|
|
|
|
if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, "");
|
2023-11-25 16:02:11 +02:00
|
|
|
if (*p) p++;
|
2014-06-16 13:24:53 +03:00
|
|
|
}
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "\n");
|
2023-11-25 16:02:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_metadata(void *ctx, const AVDictionary *m, const char *indent,
|
|
|
|
int log_level)
|
2023-11-25 16:02:11 +02:00
|
|
|
{
|
|
|
|
if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0)))
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_dictionary(ctx, m, "Metadata", indent, log_level);
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
|
2014-04-15 17:55:23 +03:00
|
|
|
/* param change side data*/
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_paramchange(void *ctx, const AVPacketSideData *sd, int log_level)
|
2014-04-15 17:55:23 +03:00
|
|
|
{
|
|
|
|
int size = sd->size;
|
|
|
|
const uint8_t *data = sd->data;
|
2013-06-05 08:02:53 +03:00
|
|
|
uint32_t flags, sample_rate, width, height;
|
2014-04-15 17:55:23 +03:00
|
|
|
|
|
|
|
if (!data || sd->size < 4)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
flags = AV_RL32(data);
|
|
|
|
data += 4;
|
|
|
|
size -= 4;
|
|
|
|
|
|
|
|
if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
|
|
|
|
if (size < 4)
|
|
|
|
goto fail;
|
|
|
|
sample_rate = AV_RL32(data);
|
|
|
|
data += 4;
|
|
|
|
size -= 4;
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "sample_rate %"PRIu32", ", sample_rate);
|
2014-04-15 17:55:23 +03:00
|
|
|
}
|
|
|
|
if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
|
|
|
|
if (size < 8)
|
|
|
|
goto fail;
|
|
|
|
width = AV_RL32(data);
|
|
|
|
data += 4;
|
|
|
|
size -= 4;
|
|
|
|
height = AV_RL32(data);
|
|
|
|
data += 4;
|
|
|
|
size -= 4;
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "width %"PRIu32" height %"PRIu32, width, height);
|
2014-04-15 17:55:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
fail:
|
2020-07-01 15:51:03 +02:00
|
|
|
av_log(ctx, AV_LOG_ERROR, "unknown param\n");
|
2014-04-15 17:55:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* replaygain side data*/
|
2024-01-17 22:28:05 +02:00
|
|
|
static void print_gain(void *ctx, const char *str, int32_t gain, int log_level)
|
2014-04-15 17:55:23 +03:00
|
|
|
{
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%s - ", str);
|
2014-04-15 17:55:23 +03:00
|
|
|
if (gain == INT32_MIN)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "unknown");
|
2014-04-15 17:55:23 +03:00
|
|
|
else
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%f", gain / 100000.0f);
|
|
|
|
av_log(ctx, log_level, ", ");
|
2014-04-15 17:55:23 +03:00
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void print_peak(void *ctx, const char *str, uint32_t peak, int log_level)
|
2014-04-15 17:55:23 +03:00
|
|
|
{
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%s - ", str);
|
2014-04-15 17:55:23 +03:00
|
|
|
if (!peak)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "unknown");
|
2014-04-15 17:55:23 +03:00
|
|
|
else
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%f", (float) peak / UINT32_MAX);
|
|
|
|
av_log(ctx, log_level, ", ");
|
2014-04-15 17:55:23 +03:00
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_replaygain(void *ctx, const AVPacketSideData *sd, int log_level)
|
2014-04-15 17:55:23 +03:00
|
|
|
{
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVReplayGain *rg;
|
2014-04-15 17:55:23 +03:00
|
|
|
|
|
|
|
if (sd->size < sizeof(*rg)) {
|
2020-07-01 15:51:03 +02:00
|
|
|
av_log(ctx, AV_LOG_ERROR, "invalid data\n");
|
2014-04-15 17:55:23 +03:00
|
|
|
return;
|
|
|
|
}
|
2020-06-30 14:13:39 +02:00
|
|
|
rg = (const AVReplayGain *)sd->data;
|
2014-04-15 17:55:23 +03:00
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
print_gain(ctx, "track gain", rg->track_gain, log_level);
|
|
|
|
print_peak(ctx, "track peak", rg->track_peak, log_level);
|
|
|
|
print_gain(ctx, "album gain", rg->album_gain, log_level);
|
|
|
|
print_peak(ctx, "album peak", rg->album_peak, log_level);
|
2014-04-15 17:55:23 +03:00
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_stereo3d(void *ctx, const AVPacketSideData *sd, int log_level)
|
2014-07-23 11:21:28 +03:00
|
|
|
{
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVStereo3D *stereo;
|
2014-07-23 11:21:28 +03:00
|
|
|
|
|
|
|
if (sd->size < sizeof(*stereo)) {
|
2020-07-01 15:51:03 +02:00
|
|
|
av_log(ctx, AV_LOG_ERROR, "invalid data\n");
|
2014-07-23 11:21:28 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-30 14:13:39 +02:00
|
|
|
stereo = (const AVStereo3D *)sd->data;
|
2014-07-23 11:21:28 +03:00
|
|
|
|
2024-06-18 17:30:54 +02:00
|
|
|
av_log(ctx, log_level, "%s, view: %s, primary eye: %s",
|
|
|
|
av_stereo3d_type_name(stereo->type), av_stereo3d_view_name(stereo->view),
|
|
|
|
av_stereo3d_primary_eye_name(stereo->primary_eye));
|
|
|
|
if (stereo->baseline)
|
|
|
|
av_log(ctx, log_level, ", baseline: %"PRIu32"", stereo->baseline);
|
|
|
|
if (stereo->horizontal_disparity_adjustment.num && stereo->horizontal_disparity_adjustment.den)
|
2024-06-25 00:57:05 +02:00
|
|
|
av_log(ctx, log_level, ", horizontal_disparity_adjustment: %0.4f",
|
|
|
|
av_q2d(stereo->horizontal_disparity_adjustment));
|
2024-06-23 15:58:28 +02:00
|
|
|
if (stereo->horizontal_field_of_view.num && stereo->horizontal_field_of_view.den)
|
2024-06-25 00:57:05 +02:00
|
|
|
av_log(ctx, log_level, ", horizontal_field_of_view: %0.3f", av_q2d(stereo->horizontal_field_of_view));
|
2014-07-23 11:21:28 +03:00
|
|
|
|
|
|
|
if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, " (inverted)");
|
2014-07-23 11:21:28 +03:00
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_audioservicetype(void *ctx, const AVPacketSideData *sd, int log_level)
|
2015-05-01 16:33:50 +02:00
|
|
|
{
|
2020-06-30 14:13:39 +02:00
|
|
|
const enum AVAudioServiceType *ast = (const enum AVAudioServiceType *)sd->data;
|
2015-05-01 16:33:50 +02:00
|
|
|
|
|
|
|
if (sd->size < sizeof(*ast)) {
|
2020-07-01 15:51:03 +02:00
|
|
|
av_log(ctx, AV_LOG_ERROR, "invalid data\n");
|
2015-05-01 16:33:50 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*ast) {
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_MAIN:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "main");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_EFFECTS:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "effects");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "visually impaired");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "hearing impaired");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_DIALOGUE:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "dialogue");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "commentary");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_EMERGENCY:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "emergency");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "voice over");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
case AV_AUDIO_SERVICE_TYPE_KARAOKE:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "karaoke");
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
av_log(ctx, AV_LOG_WARNING, "unknown");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_cpb(void *ctx, const AVPacketSideData *sd, int log_level)
|
2016-01-02 16:34:04 +02:00
|
|
|
{
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVCPBProperties *cpb = (const AVCPBProperties *)sd->data;
|
2016-01-02 16:34:04 +02:00
|
|
|
|
|
|
|
if (sd->size < sizeof(*cpb)) {
|
2020-07-01 15:51:03 +02:00
|
|
|
av_log(ctx, AV_LOG_ERROR, "invalid data\n");
|
2016-01-02 16:34:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level,
|
2021-02-26 12:19:02 +02:00
|
|
|
"bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: %"PRId64" ",
|
2016-01-02 16:34:04 +02:00
|
|
|
cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate,
|
2019-08-27 16:34:54 +02:00
|
|
|
cpb->buffer_size);
|
|
|
|
if (cpb->vbv_delay == UINT64_MAX)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "vbv_delay: N/A");
|
2019-08-27 16:34:54 +02:00
|
|
|
else
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "vbv_delay: %"PRIu64"", cpb->vbv_delay);
|
2016-01-02 16:34:04 +02:00
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_mastering_display_metadata(void *ctx, const AVPacketSideData *sd,
|
|
|
|
int log_level)
|
2020-06-30 14:13:39 +02:00
|
|
|
{
|
|
|
|
const AVMasteringDisplayMetadata *metadata =
|
|
|
|
(const AVMasteringDisplayMetadata *)sd->data;
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "Mastering Display Metadata, "
|
2016-03-01 03:20:17 +02:00
|
|
|
"has_primaries:%d has_luminance:%d "
|
|
|
|
"r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
|
2016-12-06 01:03:16 +02:00
|
|
|
"min_luminance=%f, max_luminance=%f",
|
2016-03-01 03:20:17 +02:00
|
|
|
metadata->has_primaries, metadata->has_luminance,
|
|
|
|
av_q2d(metadata->display_primaries[0][0]),
|
|
|
|
av_q2d(metadata->display_primaries[0][1]),
|
|
|
|
av_q2d(metadata->display_primaries[1][0]),
|
|
|
|
av_q2d(metadata->display_primaries[1][1]),
|
|
|
|
av_q2d(metadata->display_primaries[2][0]),
|
|
|
|
av_q2d(metadata->display_primaries[2][1]),
|
|
|
|
av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]),
|
|
|
|
av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_content_light_metadata(void *ctx, const AVPacketSideData *sd,
|
|
|
|
int log_level)
|
2017-04-02 10:08:25 +02:00
|
|
|
{
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVContentLightMetadata *metadata =
|
|
|
|
(const AVContentLightMetadata *)sd->data;
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "Content Light Level Metadata, "
|
2017-04-02 10:08:25 +02:00
|
|
|
"MaxCLL=%d, MaxFALL=%d",
|
|
|
|
metadata->MaxCLL, metadata->MaxFALL);
|
|
|
|
}
|
|
|
|
|
2024-02-04 17:14:12 +02:00
|
|
|
static void dump_ambient_viewing_environment_metadata(void *ctx, const AVPacketSideData *sd)
|
|
|
|
{
|
|
|
|
const AVAmbientViewingEnvironment *ambient =
|
|
|
|
(const AVAmbientViewingEnvironment *)sd->data;
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Ambient Viewing Environment, "
|
|
|
|
"ambient_illuminance=%f, ambient_light_x=%f, ambient_light_y=%f",
|
|
|
|
av_q2d(ambient->ambient_illuminance),
|
|
|
|
av_q2d(ambient->ambient_light_x),
|
|
|
|
av_q2d(ambient->ambient_light_y));
|
|
|
|
}
|
|
|
|
|
2020-06-30 14:13:39 +02:00
|
|
|
static void dump_spherical(void *ctx, const AVCodecParameters *par,
|
2024-01-17 22:28:05 +02:00
|
|
|
const AVPacketSideData *sd, int log_level)
|
2016-11-12 00:37:43 +02:00
|
|
|
{
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVSphericalMapping *spherical = (const AVSphericalMapping *)sd->data;
|
2016-11-12 00:37:43 +02:00
|
|
|
double yaw, pitch, roll;
|
|
|
|
|
|
|
|
if (sd->size < sizeof(*spherical)) {
|
2020-07-01 15:51:03 +02:00
|
|
|
av_log(ctx, AV_LOG_ERROR, "invalid data\n");
|
2016-11-12 00:37:43 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%s ", av_spherical_projection_name(spherical->projection));
|
2016-11-12 00:37:43 +02:00
|
|
|
|
2024-07-05 04:34:59 +02:00
|
|
|
if (spherical->yaw || spherical->pitch || spherical->roll) {
|
|
|
|
yaw = ((double)spherical->yaw) / (1 << 16);
|
|
|
|
pitch = ((double)spherical->pitch) / (1 << 16);
|
|
|
|
roll = ((double)spherical->roll) / (1 << 16);
|
|
|
|
av_log(ctx, log_level, "(%f/%f/%f) ", yaw, pitch, roll);
|
|
|
|
}
|
2017-02-10 22:26:55 +02:00
|
|
|
|
|
|
|
if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
|
|
|
|
size_t l, t, r, b;
|
|
|
|
av_spherical_tile_bounds(spherical, par->width, par->height,
|
|
|
|
&l, &t, &r, &b);
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level,
|
2017-12-17 19:03:47 +02:00
|
|
|
"[%"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER"] ",
|
|
|
|
l, t, r, b);
|
2017-02-10 22:26:55 +02:00
|
|
|
} else if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "[pad %"PRIu32"] ", spherical->padding);
|
2017-02-10 22:26:55 +02:00
|
|
|
}
|
2016-11-12 00:37:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_dovi_conf(void *ctx, const AVPacketSideData *sd,
|
|
|
|
int log_level)
|
2020-04-11 15:09:03 +02:00
|
|
|
{
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVDOVIDecoderConfigurationRecord *dovi =
|
|
|
|
(const AVDOVIDecoderConfigurationRecord *)sd->data;
|
2020-04-11 15:09:03 +02:00
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "version: %d.%d, profile: %d, level: %d, "
|
2024-07-16 13:20:00 +02:00
|
|
|
"rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d, "
|
|
|
|
"compression: %d",
|
2020-04-11 15:09:03 +02:00
|
|
|
dovi->dv_version_major, dovi->dv_version_minor,
|
|
|
|
dovi->dv_profile, dovi->dv_level,
|
|
|
|
dovi->rpu_present_flag,
|
|
|
|
dovi->el_present_flag,
|
|
|
|
dovi->bl_present_flag,
|
2024-07-16 13:20:00 +02:00
|
|
|
dovi->dv_bl_signal_compatibility_id,
|
|
|
|
dovi->dv_md_compression);
|
2020-04-11 15:09:03 +02:00
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_s12m_timecode(void *ctx, const AVStream *st, const AVPacketSideData *sd,
|
|
|
|
int log_level)
|
2020-06-30 17:18:17 +02:00
|
|
|
{
|
|
|
|
const uint32_t *tc = (const uint32_t *)sd->data;
|
|
|
|
|
|
|
|
if ((sd->size != sizeof(uint32_t) * 4) || (tc[0] > 3)) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "invalid data\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int j = 1; j <= tc[0]; j++) {
|
|
|
|
char tcbuf[AV_TIMECODE_STR_SIZE];
|
2020-07-24 16:26:58 +02:00
|
|
|
av_timecode_make_smpte_tc_string2(tcbuf, st->avg_frame_rate, tc[j], 0, 0);
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : "");
|
2020-06-30 17:18:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-18 20:00:25 +02:00
|
|
|
static void dump_cropping(void *ctx, const AVPacketSideData *sd)
|
|
|
|
{
|
|
|
|
uint32_t top, bottom, left, right;
|
|
|
|
|
|
|
|
if (sd->size < sizeof(uint32_t) * 4) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "invalid data\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
top = AV_RL32(sd->data + 0);
|
|
|
|
bottom = AV_RL32(sd->data + 4);
|
|
|
|
left = AV_RL32(sd->data + 8);
|
|
|
|
right = AV_RL32(sd->data + 12);
|
|
|
|
|
|
|
|
av_log(ctx, AV_LOG_INFO, "%d/%d/%d/%d", left, right, top, bottom);
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
static void dump_sidedata(void *ctx, const AVStream *st, const char *indent,
|
|
|
|
int log_level)
|
2014-04-15 17:55:23 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2023-07-16 22:57:26 +02:00
|
|
|
if (st->codecpar->nb_coded_side_data)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%sSide data:\n", indent);
|
2014-04-15 17:55:23 +03:00
|
|
|
|
2023-07-16 22:57:26 +02:00
|
|
|
for (i = 0; i < st->codecpar->nb_coded_side_data; i++) {
|
|
|
|
const AVPacketSideData *sd = &st->codecpar->coded_side_data[i];
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "%s ", indent);
|
2014-04-15 17:55:23 +03:00
|
|
|
|
2020-06-30 14:13:39 +02:00
|
|
|
switch (sd->type) {
|
2014-04-15 17:55:23 +03:00
|
|
|
case AV_PKT_DATA_PALETTE:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "palette");
|
2014-04-15 17:55:23 +03:00
|
|
|
break;
|
|
|
|
case AV_PKT_DATA_NEW_EXTRADATA:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "new extradata");
|
2014-04-15 17:55:23 +03:00
|
|
|
break;
|
|
|
|
case AV_PKT_DATA_PARAM_CHANGE:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "paramchange: ");
|
|
|
|
dump_paramchange(ctx, sd, log_level);
|
2014-04-15 17:55:23 +03:00
|
|
|
break;
|
|
|
|
case AV_PKT_DATA_H263_MB_INFO:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "H.263 macroblock info");
|
2014-04-15 17:55:23 +03:00
|
|
|
break;
|
|
|
|
case AV_PKT_DATA_REPLAYGAIN:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "replaygain: ");
|
|
|
|
dump_replaygain(ctx, sd, log_level);
|
2014-04-15 17:55:23 +03:00
|
|
|
break;
|
|
|
|
case AV_PKT_DATA_DISPLAYMATRIX:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "displaymatrix: rotation of %.2f degrees",
|
2020-06-30 14:13:39 +02:00
|
|
|
av_display_rotation_get((const int32_t *)sd->data));
|
2014-04-15 17:55:23 +03:00
|
|
|
break;
|
2014-07-23 11:21:28 +03:00
|
|
|
case AV_PKT_DATA_STEREO3D:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "stereo3d: ");
|
|
|
|
dump_stereo3d(ctx, sd, log_level);
|
2014-07-23 11:21:28 +03:00
|
|
|
break;
|
2015-05-01 16:33:50 +02:00
|
|
|
case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "audio service type: ");
|
|
|
|
dump_audioservicetype(ctx, sd, log_level);
|
2015-05-01 16:33:50 +02:00
|
|
|
break;
|
2015-07-21 13:23:29 +02:00
|
|
|
case AV_PKT_DATA_QUALITY_STATS:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "quality factor: %"PRId32", pict_type: %c",
|
2020-06-30 14:13:39 +02:00
|
|
|
AV_RL32(sd->data), av_get_picture_type_char(sd->data[4]));
|
2015-07-15 19:41:21 +02:00
|
|
|
break;
|
2016-01-02 16:34:04 +02:00
|
|
|
case AV_PKT_DATA_CPB_PROPERTIES:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "cpb: ");
|
|
|
|
dump_cpb(ctx, sd, log_level);
|
2016-01-02 16:34:04 +02:00
|
|
|
break;
|
2016-03-01 03:20:17 +02:00
|
|
|
case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_mastering_display_metadata(ctx, sd, log_level);
|
2016-03-01 03:20:17 +02:00
|
|
|
break;
|
2016-11-12 00:37:43 +02:00
|
|
|
case AV_PKT_DATA_SPHERICAL:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "spherical: ");
|
|
|
|
dump_spherical(ctx, st->codecpar, sd, log_level);
|
2016-11-12 00:37:43 +02:00
|
|
|
break;
|
2017-04-02 10:08:25 +02:00
|
|
|
case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_content_light_metadata(ctx, sd, log_level);
|
2017-04-02 10:08:25 +02:00
|
|
|
break;
|
2019-09-23 22:43:02 +02:00
|
|
|
case AV_PKT_DATA_ICC_PROFILE:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "ICC Profile");
|
2019-09-23 22:43:02 +02:00
|
|
|
break;
|
2020-04-11 15:09:03 +02:00
|
|
|
case AV_PKT_DATA_DOVI_CONF:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "DOVI configuration record: ");
|
|
|
|
dump_dovi_conf(ctx, sd, log_level);
|
2020-04-11 15:09:03 +02:00
|
|
|
break;
|
2020-06-30 17:18:17 +02:00
|
|
|
case AV_PKT_DATA_S12M_TIMECODE:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "SMPTE ST 12-1:2014: ");
|
|
|
|
dump_s12m_timecode(ctx, st, sd, log_level);
|
2020-06-30 17:18:17 +02:00
|
|
|
break;
|
2024-02-04 17:14:12 +02:00
|
|
|
case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT:
|
|
|
|
dump_ambient_viewing_environment_metadata(ctx, sd);
|
|
|
|
break;
|
2023-07-18 20:00:25 +02:00
|
|
|
case AV_PKT_DATA_FRAME_CROPPING:
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Frame cropping: ");
|
|
|
|
dump_cropping(ctx, sd);
|
|
|
|
break;
|
2014-04-15 17:55:23 +03:00
|
|
|
default:
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "unknown side data type %d "
|
2021-04-14 14:59:32 +02:00
|
|
|
"(%"SIZE_SPECIFIER" bytes)", sd->type, sd->size);
|
2014-04-15 17:55:23 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(ctx, log_level, "\n");
|
2014-04-15 17:55:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-11 01:05:08 +02:00
|
|
|
static void dump_disposition(int disposition, int log_level)
|
|
|
|
{
|
|
|
|
if (disposition & AV_DISPOSITION_DEFAULT)
|
|
|
|
av_log(NULL, log_level, " (default)");
|
|
|
|
if (disposition & AV_DISPOSITION_DUB)
|
|
|
|
av_log(NULL, log_level, " (dub)");
|
|
|
|
if (disposition & AV_DISPOSITION_ORIGINAL)
|
|
|
|
av_log(NULL, log_level, " (original)");
|
|
|
|
if (disposition & AV_DISPOSITION_COMMENT)
|
|
|
|
av_log(NULL, log_level, " (comment)");
|
|
|
|
if (disposition & AV_DISPOSITION_LYRICS)
|
|
|
|
av_log(NULL, log_level, " (lyrics)");
|
|
|
|
if (disposition & AV_DISPOSITION_KARAOKE)
|
|
|
|
av_log(NULL, log_level, " (karaoke)");
|
|
|
|
if (disposition & AV_DISPOSITION_FORCED)
|
|
|
|
av_log(NULL, log_level, " (forced)");
|
|
|
|
if (disposition & AV_DISPOSITION_HEARING_IMPAIRED)
|
|
|
|
av_log(NULL, log_level, " (hearing impaired)");
|
|
|
|
if (disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
|
|
|
|
av_log(NULL, log_level, " (visual impaired)");
|
|
|
|
if (disposition & AV_DISPOSITION_CLEAN_EFFECTS)
|
|
|
|
av_log(NULL, log_level, " (clean effects)");
|
|
|
|
if (disposition & AV_DISPOSITION_ATTACHED_PIC)
|
|
|
|
av_log(NULL, log_level, " (attached pic)");
|
|
|
|
if (disposition & AV_DISPOSITION_TIMED_THUMBNAILS)
|
|
|
|
av_log(NULL, log_level, " (timed thumbnails)");
|
|
|
|
if (disposition & AV_DISPOSITION_CAPTIONS)
|
|
|
|
av_log(NULL, log_level, " (captions)");
|
|
|
|
if (disposition & AV_DISPOSITION_DESCRIPTIONS)
|
|
|
|
av_log(NULL, log_level, " (descriptions)");
|
|
|
|
if (disposition & AV_DISPOSITION_METADATA)
|
|
|
|
av_log(NULL, log_level, " (metadata)");
|
|
|
|
if (disposition & AV_DISPOSITION_DEPENDENT)
|
|
|
|
av_log(NULL, log_level, " (dependent)");
|
|
|
|
if (disposition & AV_DISPOSITION_STILL_IMAGE)
|
|
|
|
av_log(NULL, log_level, " (still image)");
|
|
|
|
if (disposition & AV_DISPOSITION_NON_DIEGETIC)
|
|
|
|
av_log(NULL, log_level, " (non-diegetic)");
|
2024-06-11 17:23:00 +02:00
|
|
|
if (disposition & AV_DISPOSITION_MULTILAYER)
|
|
|
|
av_log(NULL, log_level, " (multilayer)");
|
2024-02-11 01:05:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-15 17:08:58 +03:00
|
|
|
/* "user interface" functions */
|
2020-06-30 14:13:39 +02:00
|
|
|
static void dump_stream_format(const AVFormatContext *ic, int i,
|
2024-01-17 22:28:05 +02:00
|
|
|
int group_index, int index, int is_output,
|
|
|
|
int log_level)
|
2014-04-15 17:08:58 +03:00
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVStream *st = ic->streams[i];
|
2021-08-24 19:41:16 +02:00
|
|
|
const FFStream *const sti = cffstream(st);
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
|
|
|
|
const char *separator = ic->dump_separator;
|
2023-11-25 16:02:11 +02:00
|
|
|
const char *group_indent = group_index >= 0 ? " " : "";
|
|
|
|
const char *extra_indent = group_index >= 0 ? " " : " ";
|
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2014-06-18 21:42:52 +03:00
|
|
|
AVCodecContext *avctx;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
avctx = avcodec_alloc_context3(NULL);
|
|
|
|
if (!avctx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ret = avcodec_parameters_to_context(avctx, st->codecpar);
|
|
|
|
if (ret < 0) {
|
|
|
|
avcodec_free_context(&avctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-30 14:00:53 +02:00
|
|
|
// Fields which are missing from AVCodecParameters need to be taken from the AVCodecContext
|
2024-02-03 03:57:52 +02:00
|
|
|
if (sti->avctx) {
|
|
|
|
avctx->properties = sti->avctx->properties;
|
|
|
|
avctx->codec = sti->avctx->codec;
|
|
|
|
avctx->qmin = sti->avctx->qmin;
|
|
|
|
avctx->qmax = sti->avctx->qmax;
|
|
|
|
avctx->coded_width = sti->avctx->coded_width;
|
|
|
|
avctx->coded_height = sti->avctx->coded_height;
|
|
|
|
}
|
2016-05-30 14:00:53 +02:00
|
|
|
|
2016-04-10 21:58:15 +02:00
|
|
|
if (separator)
|
|
|
|
av_opt_set(avctx, "dump_separator", separator, 0);
|
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2014-06-18 21:42:52 +03:00
|
|
|
avcodec_string(buf, sizeof(buf), avctx, is_output);
|
|
|
|
avcodec_free_context(&avctx);
|
2014-04-15 17:08:58 +03:00
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "%s Stream #%d", group_indent, index);
|
|
|
|
av_log(NULL, log_level, ":%d", i);
|
2014-04-15 17:08:58 +03:00
|
|
|
|
|
|
|
/* the pid is an important information, so we display it */
|
|
|
|
/* XXX: add a generic system */
|
|
|
|
if (flags & AVFMT_SHOW_IDS)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "[0x%x]", st->id);
|
2014-04-15 17:08:58 +03:00
|
|
|
if (lang)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "(%s)", lang->value);
|
2021-08-24 19:41:16 +02:00
|
|
|
av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", sti->codec_info_nb_frames,
|
2014-06-24 08:39:35 +03:00
|
|
|
st->time_base.num, st->time_base.den);
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, ": %s", buf);
|
2014-04-15 17:08:58 +03:00
|
|
|
|
2016-04-10 21:58:15 +02:00
|
|
|
if (st->sample_aspect_ratio.num &&
|
|
|
|
av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) {
|
2014-04-15 17:08:58 +03:00
|
|
|
AVRational display_aspect_ratio;
|
|
|
|
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
|
2016-04-10 21:58:15 +02:00
|
|
|
st->codecpar->width * (int64_t)st->sample_aspect_ratio.num,
|
|
|
|
st->codecpar->height * (int64_t)st->sample_aspect_ratio.den,
|
2014-04-15 17:08:58 +03:00
|
|
|
1024 * 1024);
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, ", SAR %d:%d DAR %d:%d",
|
2014-04-15 17:08:58 +03:00
|
|
|
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
|
|
|
|
display_aspect_ratio.num, display_aspect_ratio.den);
|
|
|
|
}
|
|
|
|
|
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.
In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.
There are multiple important problems with this approach:
- the fields in AVCodecContext are in general one of
* stream parameters
* codec options
* codec state
However, it's not clear which ones are which. It is consequently
unclear which fields are a demuxer allowed to set or a muxer allowed to
read. This leads to erratic behaviour depending on whether decoding or
encoding is being performed or not (and whether it uses the AVStream
embedded codec context).
- various synchronization issues arising from the fact that the same
context is used by several different APIs (muxers/demuxers,
parsers, bitstream filters and encoders/decoders) simultaneously, with
there being no clear rules for who can modify what and the different
processes being typically delayed with respect to each other.
- avformat_find_stream_info() making it necessary to support opening
and closing a single codec context multiple times, thus
complicating the semantics of freeing various allocated objects in the
codec context.
Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2014-06-18 21:42:52 +03:00
|
|
|
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
2014-09-26 16:37:40 +03:00
|
|
|
int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
|
2014-10-09 00:33:24 +03:00
|
|
|
int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
|
2014-09-26 16:37:40 +03:00
|
|
|
int tbn = st->time_base.den && st->time_base.num;
|
|
|
|
|
2021-04-30 02:41:57 +02:00
|
|
|
if (fps || tbr || tbn)
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "%s", separator);
|
2014-10-09 00:33:24 +03:00
|
|
|
|
2014-09-26 16:37:40 +03:00
|
|
|
if (fps)
|
2024-01-17 22:28:05 +02:00
|
|
|
print_fps(av_q2d(st->avg_frame_rate), tbr || tbn ? "fps, " : "fps", log_level);
|
2014-10-09 00:33:24 +03:00
|
|
|
if (tbr)
|
2024-01-17 22:28:05 +02:00
|
|
|
print_fps(av_q2d(st->r_frame_rate), tbn ? "tbr, " : "tbr", log_level);
|
2014-09-26 16:37:40 +03:00
|
|
|
if (tbn)
|
2024-01-17 22:28:05 +02:00
|
|
|
print_fps(1 / av_q2d(st->time_base), "tbn", log_level);
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
|
2024-02-11 01:05:08 +02:00
|
|
|
dump_disposition(st->disposition, log_level);
|
2024-01-17 22:28:05 +02:00
|
|
|
av_log(NULL, log_level, "\n");
|
2014-04-15 17:08:58 +03:00
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_metadata(NULL, st->metadata, extra_indent, log_level);
|
2023-11-25 16:02:11 +02:00
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_sidedata(NULL, st, extra_indent, log_level);
|
2023-11-25 16:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_stream_group(const AVFormatContext *ic, uint8_t *printed,
|
|
|
|
int i, int index, int is_output)
|
|
|
|
{
|
|
|
|
const AVStreamGroup *stg = ic->stream_groups[i];
|
|
|
|
int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
|
|
|
|
char buf[512];
|
|
|
|
int ret;
|
2014-04-15 17:55:23 +03:00
|
|
|
|
2023-11-25 16:02:11 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, " Stream group #%d:%d", index, i);
|
|
|
|
if (flags & AVFMT_SHOW_IDS)
|
|
|
|
av_log(NULL, AV_LOG_INFO, "[0x%"PRIx64"]", stg->id);
|
|
|
|
av_log(NULL, AV_LOG_INFO, ":");
|
|
|
|
|
|
|
|
switch (stg->type) {
|
|
|
|
case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT: {
|
|
|
|
const AVIAMFAudioElement *audio_element = stg->params.iamf_audio_element;
|
2024-02-11 01:05:08 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, " IAMF Audio Element:");
|
2024-02-13 15:04:32 +02:00
|
|
|
dump_disposition(stg->disposition, AV_LOG_INFO);
|
2024-02-11 01:05:08 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_metadata(NULL, stg->metadata, " ", AV_LOG_INFO);
|
2023-11-25 16:02:11 +02:00
|
|
|
for (int j = 0; j < audio_element->nb_layers; j++) {
|
|
|
|
const AVIAMFLayer *layer = audio_element->layers[j];
|
|
|
|
int channel_count = layer->ch_layout.nb_channels;
|
|
|
|
av_log(NULL, AV_LOG_INFO, " Layer %d:", j);
|
|
|
|
ret = av_channel_layout_describe(&layer->ch_layout, buf, sizeof(buf));
|
|
|
|
if (ret >= 0)
|
|
|
|
av_log(NULL, AV_LOG_INFO, " %s", buf);
|
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
|
|
|
for (int k = 0; channel_count > 0 && k < stg->nb_streams; k++) {
|
|
|
|
AVStream *st = stg->streams[k];
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE);
|
2023-11-25 16:02:11 +02:00
|
|
|
printed[st->index] = 1;
|
|
|
|
channel_count -= st->codecpar->ch_layout.nb_channels;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: {
|
|
|
|
const AVIAMFMixPresentation *mix_presentation = stg->params.iamf_mix_presentation;
|
2024-02-11 01:05:08 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, " IAMF Mix Presentation:");
|
2024-02-13 15:04:32 +02:00
|
|
|
dump_disposition(stg->disposition, AV_LOG_INFO);
|
2024-02-11 01:05:08 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_metadata(NULL, stg->metadata, " ", AV_LOG_INFO);
|
|
|
|
dump_dictionary(NULL, mix_presentation->annotations, "Annotations", " ", AV_LOG_INFO);
|
2023-11-25 16:02:11 +02:00
|
|
|
for (int j = 0; j < mix_presentation->nb_submixes; j++) {
|
|
|
|
AVIAMFSubmix *sub_mix = mix_presentation->submixes[j];
|
|
|
|
av_log(NULL, AV_LOG_INFO, " Submix %d:\n", j);
|
|
|
|
for (int k = 0; k < sub_mix->nb_elements; k++) {
|
|
|
|
const AVIAMFSubmixElement *submix_element = sub_mix->elements[k];
|
|
|
|
const AVStreamGroup *audio_element = NULL;
|
|
|
|
for (int l = 0; l < ic->nb_stream_groups; l++)
|
|
|
|
if (ic->stream_groups[l]->type == AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT &&
|
|
|
|
ic->stream_groups[l]->id == submix_element->audio_element_id) {
|
|
|
|
audio_element = ic->stream_groups[l];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (audio_element) {
|
|
|
|
av_log(NULL, AV_LOG_INFO, " IAMF Audio Element #%d:%d",
|
|
|
|
index, audio_element->index);
|
|
|
|
if (flags & AVFMT_SHOW_IDS)
|
|
|
|
av_log(NULL, AV_LOG_INFO, "[0x%"PRIx64"]", audio_element->id);
|
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_dictionary(NULL, submix_element->annotations, "Annotations", " ", AV_LOG_INFO);
|
2023-11-25 16:02:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int k = 0; k < sub_mix->nb_layouts; k++) {
|
|
|
|
const AVIAMFSubmixLayout *submix_layout = sub_mix->layouts[k];
|
|
|
|
av_log(NULL, AV_LOG_INFO, " Layout #%d:", k);
|
|
|
|
if (submix_layout->layout_type == 2) {
|
|
|
|
ret = av_channel_layout_describe(&submix_layout->sound_system, buf, sizeof(buf));
|
|
|
|
if (ret >= 0)
|
|
|
|
av_log(NULL, AV_LOG_INFO, " %s", buf);
|
|
|
|
} else if (submix_layout->layout_type == 3)
|
|
|
|
av_log(NULL, AV_LOG_INFO, " Binaural");
|
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2024-01-22 19:35:33 +02:00
|
|
|
case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
|
|
|
|
const AVStreamGroupTileGrid *tile_grid = stg->params.tile_grid;
|
|
|
|
AVCodecContext *avctx = avcodec_alloc_context3(NULL);
|
|
|
|
const char *ptr = NULL;
|
|
|
|
av_log(NULL, AV_LOG_INFO, " Tile Grid:");
|
|
|
|
if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, stg->streams[0]->codecpar)) {
|
|
|
|
avctx->width = tile_grid->width;
|
|
|
|
avctx->height = tile_grid->height;
|
|
|
|
avctx->coded_width = tile_grid->coded_width;
|
|
|
|
avctx->coded_height = tile_grid->coded_height;
|
|
|
|
if (ic->dump_separator)
|
|
|
|
av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
|
|
|
|
buf[0] = 0;
|
|
|
|
avcodec_string(buf, sizeof(buf), avctx, is_output);
|
|
|
|
ptr = av_stristr(buf, " ");
|
|
|
|
}
|
|
|
|
avcodec_free_context(&avctx);
|
|
|
|
if (ptr)
|
|
|
|
av_log(NULL, AV_LOG_INFO, "%s", ptr);
|
|
|
|
dump_disposition(stg->disposition, AV_LOG_INFO);
|
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
|
|
|
dump_metadata(NULL, stg->metadata, " ", AV_LOG_INFO);
|
|
|
|
for (int i = 0; i < stg->nb_streams; i++) {
|
|
|
|
const AVStream *st = stg->streams[i];
|
|
|
|
dump_stream_format(ic, st->index, i, index, is_output, AV_LOG_VERBOSE);
|
|
|
|
printed[st->index] = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2023-11-25 16:02:11 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void av_dump_format(AVFormatContext *ic, int index,
|
|
|
|
const char *url, int is_output)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
|
|
|
|
if (ic->nb_streams && !printed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
|
|
|
|
is_output ? "Output" : "Input",
|
|
|
|
index,
|
|
|
|
is_output ? ic->oformat->name : ic->iformat->name,
|
|
|
|
is_output ? "to" : "from", url);
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_metadata(NULL, ic->metadata, " ", AV_LOG_INFO);
|
2014-04-15 17:08:58 +03:00
|
|
|
|
|
|
|
if (!is_output) {
|
|
|
|
av_log(NULL, AV_LOG_INFO, " Duration: ");
|
|
|
|
if (ic->duration != AV_NOPTS_VALUE) {
|
2020-05-16 16:06:09 +02:00
|
|
|
int64_t hours, mins, secs, us;
|
2015-12-01 13:40:32 +02:00
|
|
|
int64_t duration = ic->duration + (ic->duration <= INT64_MAX - 5000 ? 5000 : 0);
|
2014-06-16 13:24:53 +03:00
|
|
|
secs = duration / AV_TIME_BASE;
|
|
|
|
us = duration % AV_TIME_BASE;
|
2014-04-15 17:08:58 +03:00
|
|
|
mins = secs / 60;
|
|
|
|
secs %= 60;
|
|
|
|
hours = mins / 60;
|
|
|
|
mins %= 60;
|
2020-05-16 16:06:09 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, "%02"PRId64":%02"PRId64":%02"PRId64".%02"PRId64"", hours, mins, secs,
|
2014-04-15 17:08:58 +03:00
|
|
|
(100 * us) / AV_TIME_BASE);
|
|
|
|
} else {
|
|
|
|
av_log(NULL, AV_LOG_INFO, "N/A");
|
|
|
|
}
|
|
|
|
if (ic->start_time != AV_NOPTS_VALUE) {
|
|
|
|
int secs, us;
|
|
|
|
av_log(NULL, AV_LOG_INFO, ", start: ");
|
2016-04-13 06:49:27 +02:00
|
|
|
secs = llabs(ic->start_time / AV_TIME_BASE);
|
2015-06-30 15:38:46 +02:00
|
|
|
us = llabs(ic->start_time % AV_TIME_BASE);
|
2016-04-13 06:49:27 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, "%s%d.%06d",
|
|
|
|
ic->start_time >= 0 ? "" : "-",
|
|
|
|
secs,
|
|
|
|
(int) av_rescale(us, 1000000, AV_TIME_BASE));
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
av_log(NULL, AV_LOG_INFO, ", bitrate: ");
|
|
|
|
if (ic->bit_rate)
|
2017-08-29 01:33:47 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, "%"PRId64" kb/s", ic->bit_rate / 1000);
|
2014-04-15 17:08:58 +03:00
|
|
|
else
|
|
|
|
av_log(NULL, AV_LOG_INFO, "N/A");
|
|
|
|
av_log(NULL, AV_LOG_INFO, "\n");
|
|
|
|
}
|
|
|
|
|
2021-01-27 18:39:26 +02:00
|
|
|
if (ic->nb_chapters)
|
|
|
|
av_log(NULL, AV_LOG_INFO, " Chapters:\n");
|
2014-04-15 17:08:58 +03:00
|
|
|
for (i = 0; i < ic->nb_chapters; i++) {
|
2020-06-30 14:13:39 +02:00
|
|
|
const AVChapter *ch = ic->chapters[i];
|
2014-09-30 12:26:06 +03:00
|
|
|
av_log(NULL, AV_LOG_INFO, " Chapter #%d:%d: ", index, i);
|
2014-04-15 17:08:58 +03:00
|
|
|
av_log(NULL, AV_LOG_INFO,
|
|
|
|
"start %f, ", ch->start * av_q2d(ch->time_base));
|
|
|
|
av_log(NULL, AV_LOG_INFO,
|
|
|
|
"end %f\n", ch->end * av_q2d(ch->time_base));
|
|
|
|
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_metadata(NULL, ch->metadata, " ", AV_LOG_INFO);
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ic->nb_programs) {
|
|
|
|
int j, k, total = 0;
|
|
|
|
for (j = 0; j < ic->nb_programs; j++) {
|
2020-06-30 14:26:40 +02:00
|
|
|
const AVProgram *program = ic->programs[j];
|
|
|
|
const AVDictionaryEntry *name = av_dict_get(program->metadata,
|
2020-06-30 14:13:39 +02:00
|
|
|
"name", NULL, 0);
|
2020-06-30 14:26:40 +02:00
|
|
|
av_log(NULL, AV_LOG_INFO, " Program %d %s\n", program->id,
|
2014-04-15 17:08:58 +03:00
|
|
|
name ? name->value : "");
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_metadata(NULL, program->metadata, " ", AV_LOG_INFO);
|
2020-06-30 14:26:40 +02:00
|
|
|
for (k = 0; k < program->nb_stream_indexes; k++) {
|
|
|
|
dump_stream_format(ic, program->stream_index[k],
|
2024-01-17 22:28:05 +02:00
|
|
|
-1, index, is_output, AV_LOG_INFO);
|
2020-06-30 14:26:40 +02:00
|
|
|
printed[program->stream_index[k]] = 1;
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
2020-06-30 14:26:40 +02:00
|
|
|
total += program->nb_stream_indexes;
|
2014-04-15 17:08:58 +03:00
|
|
|
}
|
|
|
|
if (total < ic->nb_streams)
|
|
|
|
av_log(NULL, AV_LOG_INFO, " No Program\n");
|
|
|
|
}
|
|
|
|
|
2023-11-25 16:02:11 +02:00
|
|
|
for (i = 0; i < ic->nb_stream_groups; i++)
|
|
|
|
dump_stream_group(ic, printed, i, index, is_output);
|
|
|
|
|
2014-04-15 17:08:58 +03:00
|
|
|
for (i = 0; i < ic->nb_streams; i++)
|
|
|
|
if (!printed[i])
|
2024-01-17 22:28:05 +02:00
|
|
|
dump_stream_format(ic, i, -1, index, is_output, AV_LOG_INFO);
|
2014-04-15 17:08:58 +03:00
|
|
|
|
|
|
|
av_free(printed);
|
|
|
|
}
|