mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
lavc/encode: print separate messages for unknown and unsupported formats
The former is typically a bug in the calling program, while the latter will more often be a user configuration issue.
This commit is contained in:
parent
2bbb6cf74e
commit
160fefacd3
@ -24,6 +24,7 @@
|
|||||||
#include "libavutil/frame.h"
|
#include "libavutil/frame.h"
|
||||||
#include "libavutil/imgutils.h"
|
#include "libavutil/imgutils.h"
|
||||||
#include "libavutil/internal.h"
|
#include "libavutil/internal.h"
|
||||||
|
#include "libavutil/pixdesc.h"
|
||||||
#include "libavutil/samplefmt.h"
|
#include "libavutil/samplefmt.h"
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
@ -576,15 +577,19 @@ static int encode_preinit_video(AVCodecContext *avctx)
|
|||||||
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
|
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!av_get_pix_fmt_name(avctx->pix_fmt)) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Invalid video pixel format: %d\n",
|
||||||
|
avctx->pix_fmt);
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (avctx->codec->pix_fmts) {
|
if (avctx->codec->pix_fmts) {
|
||||||
for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
|
for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
|
||||||
if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
|
if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
|
||||||
break;
|
break;
|
||||||
if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE) {
|
if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE) {
|
||||||
char buf[128];
|
av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is not supported\n",
|
||||||
snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);
|
av_get_pix_fmt_name(avctx->pix_fmt));
|
||||||
av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid or not supported\n",
|
|
||||||
(char *)av_x_if_null(av_get_pix_fmt_name(avctx->pix_fmt), buf));
|
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
|
if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
|
||||||
@ -646,6 +651,12 @@ static int encode_preinit_audio(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!av_get_sample_fmt_name(avctx->sample_fmt)) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Invalid audio sample format: %d\n",
|
||||||
|
avctx->sample_fmt);
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (avctx->codec->sample_fmts) {
|
if (avctx->codec->sample_fmts) {
|
||||||
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
|
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
|
||||||
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
|
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
|
||||||
@ -658,10 +669,8 @@ static int encode_preinit_audio(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
|
if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
|
||||||
char buf[128];
|
av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is not supported\n",
|
||||||
snprintf(buf, sizeof(buf), "%d", avctx->sample_fmt);
|
av_get_sample_fmt_name(avctx->sample_fmt));
|
||||||
av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is invalid or not supported\n",
|
|
||||||
(char *)av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), buf));
|
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user