Skip to content

Commit a1a5b76

Browse files
committed
upipe_avcodec_encode: allow more input hardware formats
1 parent bd629d4 commit a1a5b76

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/upipe-av/upipe_avcodec_encode.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,10 +1746,18 @@ static int _upipe_avcenc_provide_flow_format(struct upipe *upipe,
17461746

17471747
enum AVPixelFormat hw_pix_fmt = upipe_avcenc_get_hw_pix_fmt(codec);
17481748
if (hw_pix_fmt != AV_PIX_FMT_NONE) {
1749-
uref_pic_flow_clear_format(flow_format);
1750-
if (unlikely(!ubase_check(upipe_av_pixfmt_to_flow_def(
1751-
AV_PIX_FMT_NV12, flow_format))))
1752-
goto upipe_avcenc_provide_flow_format_err;
1749+
const char *chroma_map[UPIPE_AV_MAX_PLANES];
1750+
enum AVPixelFormat pix_fmt = upipe_av_sw_pixfmt_from_flow_def(
1751+
flow_format, codec->pix_fmts, chroma_map);
1752+
if (pix_fmt == AV_PIX_FMT_NONE) {
1753+
int bit_depth = 0;
1754+
uref_pic_flow_get_bit_depth(flow_format, &bit_depth);
1755+
uref_pic_flow_clear_format(flow_format);
1756+
if (unlikely(!ubase_check(upipe_av_pixfmt_to_flow_def(
1757+
bit_depth == 10 ? AV_PIX_FMT_P010 :
1758+
AV_PIX_FMT_NV12, flow_format))))
1759+
goto upipe_avcenc_provide_flow_format_err;
1760+
}
17531761
uref_pic_flow_set_surface_type_va(flow_format, "av.%s",
17541762
av_get_pix_fmt_name(hw_pix_fmt));
17551763
} else {

0 commit comments

Comments
 (0)