avformat: Skip logging in ff_make_codec_str if logctx == NULL

This is in preparation for reusing the same codepaths for a public
API, where we don't want it to print various diagnostic logging.
This commit is contained in:
Martin Storsjö
2025-12-01 16:22:07 +02:00
parent 0637a28dc0
commit 360fda56cd
2 changed files with 10 additions and 6 deletions

View File

@@ -54,7 +54,8 @@ static void set_vp9_codec_str(void *logctx, const AVCodecParameters *par,
vpcc.profile, vpcc.level, vpcc.bitdepth);
} else {
// Default to just vp9 in case of error while finding out profile or level
av_log(logctx, AV_LOG_WARNING, "Could not find VP9 profile and/or level\n");
if (logctx)
av_log(logctx, AV_LOG_WARNING, "Could not find VP9 profile and/or level\n");
av_bprintf(out, "vp9");
}
}
@@ -194,7 +195,8 @@ int ff_make_codec_str(void *logctx, const AVCodecParameters *par,
// RFC 6381
av_bprintf(out, "mp4v.20");
// Unimplemented, should output ProfileLevelIndication as a decimal number
av_log(logctx, AV_LOG_WARNING, "Incomplete RFC 6381 codec string for mp4v\n");
if (logctx)
av_log(logctx, AV_LOG_WARNING, "Incomplete RFC 6381 codec string for mp4v\n");
} else if (par->codec_id == AV_CODEC_ID_MP2) {
av_bprintf(out, "mp4a.40.33");
} else if (par->codec_id == AV_CODEC_ID_MP3) {

View File

@@ -51,7 +51,8 @@ static int get_vpx_chroma_subsampling(void *logctx,
return VPX_SUBSAMPLING_444;
}
}
av_log(logctx, AV_LOG_ERROR, "Unsupported pixel format (%d)\n", pixel_format);
if (logctx)
av_log(logctx, AV_LOG_ERROR, "Unsupported pixel format (%d)\n", pixel_format);
return -1;
}
@@ -59,8 +60,9 @@ static int get_bit_depth(void *logctx, enum AVPixelFormat pixel_format)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pixel_format);
if (desc == NULL) {
av_log(logctx, AV_LOG_ERROR, "Unsupported pixel format (%d)\n",
pixel_format);
if (logctx)
av_log(logctx, AV_LOG_ERROR, "Unsupported pixel format (%d)\n",
pixel_format);
return -1;
}
return desc->comp[0].depth;
@@ -187,7 +189,7 @@ int ff_isom_get_vpcc_features(void *logctx, const AVCodecParameters *par,
}
}
if (profile == AV_PROFILE_UNKNOWN || !bit_depth)
if ((profile == AV_PROFILE_UNKNOWN || !bit_depth) && logctx)
av_log(logctx, AV_LOG_WARNING, "VP9 profile and/or bit depth not set or could not be derived\n");
vpcc->profile = profile;