From 12ee84143f92a685fcc5a9ff4a675214891779c9 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 17 Jan 2022 13:50:05 +0100 Subject: [PATCH] lavc: issue hwacc compat warning for any non-4:2:0 Display warning for every non-4:2:0 subsampling (previously was displayed for 4:2:2 but also 4:4:4 is now normally supported). --- src/libavcodec_common.h | 6 +++--- src/video_compress/libavcodec.cpp | 4 ++-- src/video_decompress/libavcodec.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libavcodec_common.h b/src/libavcodec_common.h index 3252774ac..a14f957ee 100644 --- a/src/libavcodec_common.h +++ b/src/libavcodec_common.h @@ -195,16 +195,16 @@ static void print_decoder_error(const char *mod_name, int rc) { } } -inline static bool pixfmt_has_422_subsampling(enum AVPixelFormat fmt){ +inline static bool pixfmt_has_420_subsampling(enum AVPixelFormat fmt){ const AVPixFmtDescriptor *fmt_desc = av_pix_fmt_desc_get(fmt); return fmt_desc && !(fmt_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) && fmt_desc->log2_chroma_w == 1 && fmt_desc->log2_chroma_h == 0; } -inline static bool pixfmt_list_has_422_subsasmpling(const enum AVPixelFormat *fmt){ +inline static bool pixfmt_list_has_420_subsampling(const enum AVPixelFormat *fmt){ for(const enum AVPixelFormat *it = fmt; *it != AV_PIX_FMT_NONE; it++){ - if(pixfmt_has_422_subsampling(*it)) + if(pixfmt_has_420_subsampling(*it)) return true; } diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 9bd9e3872..cc714b74e 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -1241,8 +1241,8 @@ static bool configure_with(struct state_video_compress_libav *s, struct video_de log_msg(LOG_LEVEL_INFO, "[lavc] Selected pixfmt: %s\n", av_get_pix_fmt_name(pix_fmt)); s->selected_pixfmt = pix_fmt; - if(pixfmt_has_422_subsampling(pix_fmt)){ - log_msg(LOG_LEVEL_WARNING, "[lavc] Selected pixfmt has 4:2:2 subsampling, " + if (!pixfmt_has_420_subsampling(pix_fmt)) { + log_msg(LOG_LEVEL_WARNING, "[lavc] Selected pixfmt has not 4:2:0 subsampling, " "which is usually not supported by hw. decoders\n"); } diff --git a/src/video_decompress/libavcodec.c b/src/video_decompress/libavcodec.c index 16ee75b56..0a139b7cd 100644 --- a/src/video_decompress/libavcodec.c +++ b/src/video_decompress/libavcodec.c @@ -547,9 +547,9 @@ static enum AVPixelFormat get_format_callback(struct AVCodecContext *s __attribu if (hwaccel && state->out_codec != VIDEO_CODEC_NONE) { // not probing internal format struct state_libavcodec_decompress *state = (struct state_libavcodec_decompress *) s->opaque; - if(pixfmt_list_has_422_subsasmpling(fmt)){ + if (pixfmt_list_has_420_subsampling(fmt)){ log_msg(LOG_LEVEL_WARNING, "[lavd] Hw. acceleration requested " - "but incoming video has 4:2:2 subsampling, " + "but incoming video has not 4:2:0 subsampling, " "which is usually not supported by hw. accelerators\n"); } for(const enum AVPixelFormat *it = fmt; *it != AV_PIX_FMT_NONE; it++){