/* * Various pretty-printing functions for use within FFmpeg * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * 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. * * FFmpeg is distributed in the hope that it will be useful, * 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 * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h>#include <stdint.h> #include "libavutil/avstring.h"#include "libavutil/channel_layout.h"#include "libavutil/display.h"#include "libavutil/iamf.h"#include "libavutil/intreadwrite.h"#include "libavutil/log.h"#include "libavutil/mastering_display_metadata.h"#include "libavutil/ambient_viewing_environment.h"#include "libavutil/dovi_meta.h"#include "libavutil/mathematics.h"#include "libavutil/mem.h"#include "libavutil/opt.h"#include "libavutil/replaygain.h"#include "libavutil/spherical.h"#include "libavutil/stereo3d.h"#include "libavutil/timecode.h" #include "libavcodec/avcodec.h" #include "avformat.h"#include "internal.h" #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);} static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt, 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) hex_dump_internal(avcl, f, level, pkt->data, pkt->size);} void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st){ pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);} void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload, const AVStream *st){ pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);} static void print_fps(double d, const char *postfix, int log_level){ uint64_t v = lrintf(d * 100); if (!v) av_log(NULL, log_level, "%1.4f %s", d, postfix); else if (v % 100) av_log(NULL, log_level, "%3.2f %s", d, postfix); else if (v % (100 * 1000)) av_log(NULL, log_level, "%1.0f %s", d, postfix); else av_log(NULL, log_level, "%1.0fk %s", d / 1000, postfix);} static void dump_dictionary(void *ctx, const AVDictionary *m, const char *name, const char *indent, int log_level){ const AVDictionaryEntry *tag = NULL; if (!m) return; av_log(ctx, log_level, "%s%s:\n", indent, name); while ((tag = av_dict_iterate(m, tag))) if (strcmp("language", tag->key)) { const char *p = tag->value; av_log(ctx, log_level, "%s %-16s: ", indent, tag->key); while (*p) { size_t len = strcspn(p, "\x8\xa\xb\xc\xd"); av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p); p += len; if (*p == 0xd) av_log(ctx, log_level, " "); if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, ""); if (*p) p++; } av_log(ctx, log_level, "\n"); }} static void dump_metadata(void *ctx, const AVDictionary *m, const char *indent, int log_level){ if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) dump_dictionary(ctx, m, "Metadata", indent, log_level);} /* param change side data*/static void dump_paramchange(void *ctx, const AVPacketSideData *sd, int log_level){ int size = sd->size; const uint8_t *data = sd->data; uint32_t flags, sample_rate, width, height; 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; av_log(ctx, log_level, "sample_rate %"PRIu32", ", sample_rate); } 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; av_log(ctx, log_level, "width %"PRIu32" height %"PRIu32, width, height); } return;fail: av_log(ctx, AV_LOG_ERROR, "unknown param\n");} /* replaygain side data*/static void print_gain(void *ctx, const char *str, int32_t gain, int log_level){ av_log(ctx, log_level, "%s - ", str); if (gain == INT32_MIN) av_log(ctx, log_level, "unknown"); else av_log(ctx, log_level, "%f", gain / 100000.0f); av_log(ctx, log_level, ", ");} static void print_peak(void *ctx, const char *str, uint32_t peak, int log_level){ av_log(ctx, log_level, "%s - ", str); if (!peak) av_log(ctx, log_level, "unknown"); else av_log(ctx, log_level, "%f", (float) peak / UINT32_MAX); av_log(ctx, log_level, ", ");} static void dump_replaygain(void *ctx, const AVPacketSideData *sd, int log_level){ const AVReplayGain *rg; if (sd->size < sizeof(*rg)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } rg = (const AVReplayGain *)sd->data; 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);} static void dump_stereo3d(void *ctx, const AVPacketSideData *sd, int log_level){ const AVStereo3D *stereo; if (sd->size < sizeof(*stereo)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } stereo = (const AVStereo3D *)sd->data; 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) av_log(ctx, log_level, ", horizontal_disparity_adjustment: %0.4f", av_q2d(stereo->horizontal_disparity_adjustment)); if (stereo->horizontal_field_of_view.num && stereo->horizontal_field_of_view.den) av_log(ctx, log_level, ", horizontal_field_of_view: %0.3f", av_q2d(stereo->horizontal_field_of_view)); if (stereo->flags & AV_STEREO3D_FLAG_INVERT) av_log(ctx, log_level, " (inverted)");} static void dump_audioservicetype(void *ctx, const AVPacketSideData *sd, int log_level){ const enum AVAudioServiceType *ast = (const enum AVAudioServiceType *)sd->data; if (sd->size < sizeof(*ast)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } switch (*ast) { case AV_AUDIO_SERVICE_TYPE_MAIN: av_log(ctx, log_level, "main"); break; case AV_AUDIO_SERVICE_TYPE_EFFECTS: av_log(ctx, log_level, "effects"); break; case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED: av_log(ctx, log_level, "visually impaired"); break; case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED: av_log(ctx, log_level, "hearing impaired"); break; case AV_AUDIO_SERVICE_TYPE_DIALOGUE: av_log(ctx, log_level, "dialogue"); break; case AV_AUDIO_SERVICE_TYPE_COMMENTARY: av_log(ctx, log_level, "commentary"); break; case AV_AUDIO_SERVICE_TYPE_EMERGENCY: av_log(ctx, log_level, "emergency"); break; case AV_AUDIO_SERVICE_TYPE_VOICE_OVER: av_log(ctx, log_level, "voice over"); break; case AV_AUDIO_SERVICE_TYPE_KARAOKE: av_log(ctx, log_level, "karaoke"); break; default: av_log(ctx, AV_LOG_WARNING, "unknown"); break; }} static void dump_cpb(void *ctx, const AVPacketSideData *sd, int log_level){ const AVCPBProperties *cpb = (const AVCPBProperties *)sd->data; if (sd->size < sizeof(*cpb)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } av_log(ctx, log_level, "bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: %"PRId64" ", cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate, cpb->buffer_size); if (cpb->vbv_delay == UINT64_MAX) av_log(ctx, log_level, "vbv_delay: N/A"); else av_log(ctx, log_level, "vbv_delay: %"PRIu64"", cpb->vbv_delay);} static void dump_mastering_display_metadata(void *ctx, const AVPacketSideData *sd, int log_level){ const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata *)sd->data; av_log(ctx, log_level, "Mastering Display Metadata, " "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) " "min_luminance=%f, max_luminance=%f", 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));} static void dump_content_light_metadata(void *ctx, const AVPacketSideData *sd, int log_level){ const AVContentLightMetadata *metadata = (const AVContentLightMetadata *)sd->data; av_log(ctx, log_level, "Content Light Level Metadata, " "MaxCLL=%d, MaxFALL=%d", metadata->MaxCLL, metadata->MaxFALL);} 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));} static void dump_spherical(void *ctx, int w, int h, const AVPacketSideData *sd, int log_level){ const AVSphericalMapping *spherical = (const AVSphericalMapping *)sd->data; double yaw, pitch, roll; if (sd->size < sizeof(*spherical)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } av_log(ctx, log_level, "%s ", av_spherical_projection_name(spherical->projection)); 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); } if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { size_t l, t, r, b; av_spherical_tile_bounds(spherical, w, h, &l, &t, &r, &b); av_log(ctx, log_level, "[%"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER"] ", l, t, r, b); } else if (spherical->projection == AV_SPHERICAL_CUBEMAP) { av_log(ctx, log_level, "[pad %"PRIu32"] ", spherical->padding); }} static void dump_dovi_conf(void *ctx, const AVPacketSideData *sd, int log_level){ const AVDOVIDecoderConfigurationRecord *dovi = (const AVDOVIDecoderConfigurationRecord *)sd->data; av_log(ctx, log_level, "version: %d.%d, profile: %d, level: %d, " "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d, " "compression: %d", 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, dovi->dv_bl_signal_compatibility_id, dovi->dv_md_compression);} static void dump_s12m_timecode(void *ctx, AVRational avg_frame_rate, const AVPacketSideData *sd, int log_level){ 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]; av_timecode_make_smpte_tc_string2(tcbuf, avg_frame_rate, tc[j], 0, 0); av_log(ctx, log_level, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : ""); }} 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);} static void dump_sidedata(void *ctx, const AVPacketSideData *side_data, int nb_side_data, int w, int h, AVRational avg_frame_rate, const char *indent, int log_level){ int i; if (nb_side_data) av_log(ctx, log_level, "%sSide data:\n", indent); for (i = 0; i < nb_side_data; i++) { const AVPacketSideData *sd = &side_data[i]; av_log(ctx, log_level, "%s ", indent); switch (sd->type) { case AV_PKT_DATA_PALETTE: av_log(ctx, log_level, "palette"); break; case AV_PKT_DATA_NEW_EXTRADATA: av_log(ctx, log_level, "new extradata"); break; case AV_PKT_DATA_PARAM_CHANGE: av_log(ctx, log_level, "paramchange: "); dump_paramchange(ctx, sd, log_level); break; case AV_PKT_DATA_H263_MB_INFO: av_log(ctx, log_level, "H.263 macroblock info"); break; case AV_PKT_DATA_REPLAYGAIN: av_log(ctx, log_level, "replaygain: "); dump_replaygain(ctx, sd, log_level); break; case AV_PKT_DATA_DISPLAYMATRIX: av_log(ctx, log_level, "displaymatrix: rotation of %.2f degrees", av_display_rotation_get((const int32_t *)sd->data)); break; case AV_PKT_DATA_STEREO3D: av_log(ctx, log_level, "stereo3d: ");Lines 1–500 of 935. Load more
/* * Various pretty-printing functions for use within FFmpeg * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * 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. * * FFmpeg is distributed in the hope that it will be useful, * 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 * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> #include <stdint.h> #include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/display.h" #include "libavutil/iamf.h" #include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/ambient_viewing_environment.h" #include "libavutil/dovi_meta.h" #include "libavutil/mathematics.h" #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/replaygain.h" #include "libavutil/spherical.h" #include "libavutil/stereo3d.h" #include "libavutil/timecode.h" #include "libavcodec/avcodec.h" #include "avformat.h" #include "internal.h" #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); } static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt, 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) hex_dump_internal(avcl, f, level, pkt->data, pkt->size); } void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st) { pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base); } void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload, const AVStream *st) { pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base); } static void print_fps(double d, const char *postfix, int log_level) { uint64_t v = lrintf(d * 100); if (!v) av_log(NULL, log_level, "%1.4f %s", d, postfix); else if (v % 100) av_log(NULL, log_level, "%3.2f %s", d, postfix); else if (v % (100 * 1000)) av_log(NULL, log_level, "%1.0f %s", d, postfix); else av_log(NULL, log_level, "%1.0fk %s", d / 1000, postfix); } static void dump_dictionary(void *ctx, const AVDictionary *m, const char *name, const char *indent, int log_level) { const AVDictionaryEntry *tag = NULL; if (!m) return; av_log(ctx, log_level, "%s%s:\n", indent, name); while ((tag = av_dict_iterate(m, tag))) if (strcmp("language", tag->key)) { const char *p = tag->value; av_log(ctx, log_level, "%s %-16s: ", indent, tag->key); while (*p) { size_t len = strcspn(p, "\x8\xa\xb\xc\xd"); av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p); p += len; if (*p == 0xd) av_log(ctx, log_level, " "); if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, ""); if (*p) p++; } av_log(ctx, log_level, "\n"); } } static void dump_metadata(void *ctx, const AVDictionary *m, const char *indent, int log_level) { if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) dump_dictionary(ctx, m, "Metadata", indent, log_level); } /* param change side data*/ static void dump_paramchange(void *ctx, const AVPacketSideData *sd, int log_level) { int size = sd->size; const uint8_t *data = sd->data; uint32_t flags, sample_rate, width, height; 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; av_log(ctx, log_level, "sample_rate %"PRIu32", ", sample_rate); } 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; av_log(ctx, log_level, "width %"PRIu32" height %"PRIu32, width, height); } return; fail: av_log(ctx, AV_LOG_ERROR, "unknown param\n"); } /* replaygain side data*/ static void print_gain(void *ctx, const char *str, int32_t gain, int log_level) { av_log(ctx, log_level, "%s - ", str); if (gain == INT32_MIN) av_log(ctx, log_level, "unknown"); else av_log(ctx, log_level, "%f", gain / 100000.0f); av_log(ctx, log_level, ", "); } static void print_peak(void *ctx, const char *str, uint32_t peak, int log_level) { av_log(ctx, log_level, "%s - ", str); if (!peak) av_log(ctx, log_level, "unknown"); else av_log(ctx, log_level, "%f", (float) peak / UINT32_MAX); av_log(ctx, log_level, ", "); } static void dump_replaygain(void *ctx, const AVPacketSideData *sd, int log_level) { const AVReplayGain *rg; if (sd->size < sizeof(*rg)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } rg = (const AVReplayGain *)sd->data; 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); } static void dump_stereo3d(void *ctx, const AVPacketSideData *sd, int log_level) { const AVStereo3D *stereo; if (sd->size < sizeof(*stereo)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } stereo = (const AVStereo3D *)sd->data; 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) av_log(ctx, log_level, ", horizontal_disparity_adjustment: %0.4f", av_q2d(stereo->horizontal_disparity_adjustment)); if (stereo->horizontal_field_of_view.num && stereo->horizontal_field_of_view.den) av_log(ctx, log_level, ", horizontal_field_of_view: %0.3f", av_q2d(stereo->horizontal_field_of_view)); if (stereo->flags & AV_STEREO3D_FLAG_INVERT) av_log(ctx, log_level, " (inverted)"); } static void dump_audioservicetype(void *ctx, const AVPacketSideData *sd, int log_level) { const enum AVAudioServiceType *ast = (const enum AVAudioServiceType *)sd->data; if (sd->size < sizeof(*ast)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } switch (*ast) { case AV_AUDIO_SERVICE_TYPE_MAIN: av_log(ctx, log_level, "main"); break; case AV_AUDIO_SERVICE_TYPE_EFFECTS: av_log(ctx, log_level, "effects"); break; case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED: av_log(ctx, log_level, "visually impaired"); break; case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED: av_log(ctx, log_level, "hearing impaired"); break; case AV_AUDIO_SERVICE_TYPE_DIALOGUE: av_log(ctx, log_level, "dialogue"); break; case AV_AUDIO_SERVICE_TYPE_COMMENTARY: av_log(ctx, log_level, "commentary"); break; case AV_AUDIO_SERVICE_TYPE_EMERGENCY: av_log(ctx, log_level, "emergency"); break; case AV_AUDIO_SERVICE_TYPE_VOICE_OVER: av_log(ctx, log_level, "voice over"); break; case AV_AUDIO_SERVICE_TYPE_KARAOKE: av_log(ctx, log_level, "karaoke"); break; default: av_log(ctx, AV_LOG_WARNING, "unknown"); break; } } static void dump_cpb(void *ctx, const AVPacketSideData *sd, int log_level) { const AVCPBProperties *cpb = (const AVCPBProperties *)sd->data; if (sd->size < sizeof(*cpb)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } av_log(ctx, log_level, "bitrate max/min/avg: %"PRId64"/%"PRId64"/%"PRId64" buffer size: %"PRId64" ", cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate, cpb->buffer_size); if (cpb->vbv_delay == UINT64_MAX) av_log(ctx, log_level, "vbv_delay: N/A"); else av_log(ctx, log_level, "vbv_delay: %"PRIu64"", cpb->vbv_delay); } static void dump_mastering_display_metadata(void *ctx, const AVPacketSideData *sd, int log_level) { const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata *)sd->data; av_log(ctx, log_level, "Mastering Display Metadata, " "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) " "min_luminance=%f, max_luminance=%f", 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)); } static void dump_content_light_metadata(void *ctx, const AVPacketSideData *sd, int log_level) { const AVContentLightMetadata *metadata = (const AVContentLightMetadata *)sd->data; av_log(ctx, log_level, "Content Light Level Metadata, " "MaxCLL=%d, MaxFALL=%d", metadata->MaxCLL, metadata->MaxFALL); } 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)); } static void dump_spherical(void *ctx, int w, int h, const AVPacketSideData *sd, int log_level) { const AVSphericalMapping *spherical = (const AVSphericalMapping *)sd->data; double yaw, pitch, roll; if (sd->size < sizeof(*spherical)) { av_log(ctx, AV_LOG_ERROR, "invalid data\n"); return; } av_log(ctx, log_level, "%s ", av_spherical_projection_name(spherical->projection)); 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); } if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) { size_t l, t, r, b; av_spherical_tile_bounds(spherical, w, h, &l, &t, &r, &b); av_log(ctx, log_level, "[%"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER", %"SIZE_SPECIFIER"] ", l, t, r, b); } else if (spherical->projection == AV_SPHERICAL_CUBEMAP) { av_log(ctx, log_level, "[pad %"PRIu32"] ", spherical->padding); } } static void dump_dovi_conf(void *ctx, const AVPacketSideData *sd, int log_level) { const AVDOVIDecoderConfigurationRecord *dovi = (const AVDOVIDecoderConfigurationRecord *)sd->data; av_log(ctx, log_level, "version: %d.%d, profile: %d, level: %d, " "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d, " "compression: %d", 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, dovi->dv_bl_signal_compatibility_id, dovi->dv_md_compression); } static void dump_s12m_timecode(void *ctx, AVRational avg_frame_rate, const AVPacketSideData *sd, int log_level) { 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]; av_timecode_make_smpte_tc_string2(tcbuf, avg_frame_rate, tc[j], 0, 0); av_log(ctx, log_level, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : ""); } } 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); } static void dump_sidedata(void *ctx, const AVPacketSideData *side_data, int nb_side_data, int w, int h, AVRational avg_frame_rate, const char *indent, int log_level) { int i; if (nb_side_data) av_log(ctx, log_level, "%sSide data:\n", indent); for (i = 0; i < nb_side_data; i++) { const AVPacketSideData *sd = &side_data[i]; av_log(ctx, log_level, "%s ", indent); switch (sd->type) { case AV_PKT_DATA_PALETTE: av_log(ctx, log_level, "palette"); break; case AV_PKT_DATA_NEW_EXTRADATA: av_log(ctx, log_level, "new extradata"); break; case AV_PKT_DATA_PARAM_CHANGE: av_log(ctx, log_level, "paramchange: "); dump_paramchange(ctx, sd, log_level); break; case AV_PKT_DATA_H263_MB_INFO: av_log(ctx, log_level, "H.263 macroblock info"); break; case AV_PKT_DATA_REPLAYGAIN: av_log(ctx, log_level, "replaygain: "); dump_replaygain(ctx, sd, log_level); break; case AV_PKT_DATA_DISPLAYMATRIX: av_log(ctx, log_level, "displaymatrix: rotation of %.2f degrees", av_display_rotation_get((const int32_t *)sd->data)); break; case AV_PKT_DATA_STEREO3D: av_log(ctx, log_level, "stereo3d: ");