Lavc: print warning about 422 subsampling hwaccel support

This commit is contained in:
Martin Piatka
2021-08-11 14:13:59 +02:00
parent e27060ac05
commit fab71806eb
3 changed files with 21 additions and 14 deletions

View File

@@ -195,6 +195,22 @@ static void print_decoder_error(const char *mod_name, int rc) {
}
}
inline static bool pixfmt_has_422_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){
for(const enum AVPixelFormat *it = fmt; *it != AV_PIX_FMT_NONE; it++){
if(pixfmt_has_422_subsampling(*it))
return true;
}
return false;
}
void print_libav_error(int verbosity, const char *msg, int rc);
bool libav_codec_has_extradata(codec_t codec);

View File

@@ -1242,6 +1242,10 @@ 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, "
"which is usually not supported by hw. decoders\n");
}
if(!find_decoder(desc, s->selected_pixfmt, &s->decoded_codec, &s->decoder)){
log_msg(LOG_LEVEL_ERROR, "[lavc] Failed to find a way to convert %s to %s\n",

View File

@@ -494,19 +494,6 @@ fail:
}
#endif
static bool is_422_subsasmpling(const enum AVPixelFormat *fmt){
for(const enum AVPixelFormat *it = fmt; *it != AV_PIX_FMT_NONE; it++){
const AVPixFmtDescriptor *fmt_desc = av_pix_fmt_desc_get(*it);
if(!fmt_desc || fmt_desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
continue;
if(fmt_desc->log2_chroma_w == 1 && fmt_desc->log2_chroma_h == 0)
return true;
}
return false;
}
static enum AVPixelFormat get_format_callback(struct AVCodecContext *s __attribute__((unused)), const enum AVPixelFormat *fmt)
{
if (log_level >= LOG_LEVEL_VERBOSE) {
@@ -542,7 +529,7 @@ 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(is_422_subsasmpling(fmt)){
if(pixfmt_list_has_422_subsasmpling(fmt)){
log_msg(LOG_LEVEL_WARNING, "[lavd] Hw. acceleration requested "
"but incoming video has 4:2:2 subsampling, "
"which is usually not supported by hw. accelerators\n");