mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 13:14:36 +00:00
video/fmt-conversion.c: remove unknown pixel format messages
This removes the messages printed on unknown pixel format messages. Passing a mp_log to them would be too messy. Actually, this is a good change, because in the past we often had trouble with these messages printed too often (causing terminal spam etc.), and printing warnings or error messages on the caller sides is much cleaner. vd_lavc.c had a change earlier to print an error message if a decoder outputs an unsupported pixel format.
This commit is contained in:
parent
5beedf1967
commit
64278128d8
@ -20,7 +20,6 @@
|
||||
#include <libavutil/avutil.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "common/msg.h"
|
||||
#include "video/img_format.h"
|
||||
#include "fmt-conversion.h"
|
||||
|
||||
@ -203,15 +202,11 @@ enum AVPixelFormat imgfmt2pixfmt(int fmt)
|
||||
if (fmt == IMGFMT_NONE)
|
||||
return AV_PIX_FMT_NONE;
|
||||
|
||||
int i;
|
||||
enum AVPixelFormat pix_fmt;
|
||||
for (i = 0; conversion_map[i].fmt; i++)
|
||||
for (int i = 0; conversion_map[i].fmt; i++) {
|
||||
if (conversion_map[i].fmt == fmt)
|
||||
break;
|
||||
pix_fmt = conversion_map[i].pix_fmt;
|
||||
if (pix_fmt == AV_PIX_FMT_NONE)
|
||||
mp_msg(MSGT_GLOBAL, MSGL_V, "Unsupported format %s\n", vo_format_name(fmt));
|
||||
return pix_fmt;
|
||||
return conversion_map[i].pix_fmt;
|
||||
}
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
int pixfmt2imgfmt(enum AVPixelFormat pix_fmt)
|
||||
@ -219,15 +214,9 @@ int pixfmt2imgfmt(enum AVPixelFormat pix_fmt)
|
||||
if (pix_fmt == AV_PIX_FMT_NONE)
|
||||
return IMGFMT_NONE;
|
||||
|
||||
int i;
|
||||
for (i = 0; conversion_map[i].pix_fmt != AV_PIX_FMT_NONE; i++)
|
||||
for (int i = 0; conversion_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
|
||||
if (conversion_map[i].pix_fmt == pix_fmt)
|
||||
break;
|
||||
int fmt = conversion_map[i].fmt;
|
||||
if (!fmt) {
|
||||
const char *fmtname = av_get_pix_fmt_name(pix_fmt);
|
||||
mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unsupported PixelFormat %s (%d)\n",
|
||||
fmtname ? fmtname : "INVALID", pix_fmt);
|
||||
return conversion_map[i].fmt;
|
||||
}
|
||||
return fmt;
|
||||
return 0;
|
||||
}
|
||||
|
@ -107,6 +107,11 @@ static int write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp)
|
||||
avctx->width = image->w;
|
||||
avctx->height = image->h;
|
||||
avctx->pix_fmt = imgfmt2pixfmt(image->imgfmt);
|
||||
if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
|
||||
MP_ERR(ctx, "Image format %s not supported by lavc.\n",
|
||||
mp_imgfmt_to_name(image->imgfmt));
|
||||
goto error_exit;
|
||||
}
|
||||
if (ctx->writer->lavc_codec == AV_CODEC_ID_PNG) {
|
||||
avctx->compression_level = ctx->opts->png_compression;
|
||||
avctx->prediction_method = ctx->opts->png_filter;
|
||||
|
@ -135,8 +135,11 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
vc->lastframeipts = MP_NOPTS_VALUE;
|
||||
vc->lastencodedipts = MP_NOPTS_VALUE;
|
||||
|
||||
if (pix_fmt == AV_PIX_FMT_NONE)
|
||||
goto error; /* imgfmt2pixfmt already prints something */
|
||||
if (pix_fmt == AV_PIX_FMT_NONE) {
|
||||
MP_FATAL(vo, "Format %s not supported by lavc.\n",
|
||||
mp_imgfmt_to_name(format));
|
||||
goto error;
|
||||
}
|
||||
|
||||
vc->stream = encode_lavc_alloc_stream(vo->encode_lavc_ctx,
|
||||
AVMEDIA_TYPE_VIDEO);
|
||||
|
Loading…
Reference in New Issue
Block a user