vpx: Support GST_VIDEO_FORMAT_I420_10LE

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/705>
This commit is contained in:
Jakub Adam 2020-03-24 17:16:59 +01:00 committed by GStreamer Merge Bot
parent 5ed50669cf
commit 87d0464259
3 changed files with 22 additions and 5 deletions

View file

@ -73,7 +73,8 @@ static GstStaticPadTemplate gst_vp9_dec_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12, Y42B, Y444, GBR }"))
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
("{ I420, YV12, Y42B, Y444, GBR, I420_10LE }"))
);
#define parent_class gst_vp9_dec_parent_class
@ -157,14 +158,16 @@ gst_vp9_dec_get_valid_format (GstVPXDec * dec, vpx_image_t * img,
(NULL), ("Unsupported frame format - 4:4:0 planar"));
return FALSE;
#endif
#ifdef VPX_IMG_FMT_I42016
case VPX_IMG_FMT_I42016:
/* VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH */
if (img->bit_depth == 10) {
*fmt = GST_VIDEO_FORMAT_I420_10LE;
return TRUE;
}
GST_FIXME_OBJECT (dec, "Please add 16-bit I420 format");
GST_ELEMENT_WARNING (dec, STREAM, NOT_IMPLEMENTED,
(NULL), ("Unsupported frame format - 16-bit 4:2:0 planar"));
return FALSE;
#endif
#ifdef VPX_IMG_FMT_I42216
case VPX_IMG_FMT_I42216:
/* VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH */

View file

@ -75,7 +75,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
/*GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12, Y42B, Y444 }")) */
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12, Y444 }"))
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12, Y444, I420_10LE }"))
);
static GstStaticPadTemplate gst_vp9_enc_src_template =
@ -194,6 +194,11 @@ gst_vp9_enc_set_image_format (GstVPXEnc * enc, vpx_image_t * image)
image->bps = 24;
image->x_chroma_shift = image->y_chroma_shift = 0;
break;
case GST_VIDEO_FORMAT_I420_10LE:
image->fmt = VPX_IMG_FMT_I42016;
image->bps = 15;
image->x_chroma_shift = image->y_chroma_shift = 1;
break;
default:
g_assert_not_reached ();
break;

View file

@ -1522,6 +1522,9 @@ gst_vpx_enc_get_downstream_profile (GstVPXEnc * encoder, GstVideoInfo * info)
case GST_VIDEO_FORMAT_Y444:
min_profile = 1;
break;
case GST_VIDEO_FORMAT_I420_10LE:
min_profile = 2;
break;
default:
min_profile = 0;
}
@ -1572,6 +1575,7 @@ gst_vpx_enc_set_format (GstVideoEncoder * video_encoder,
GstVPXEnc *encoder;
vpx_codec_err_t status;
vpx_image_t *image;
vpx_codec_flags_t flags = 0;
GstCaps *caps;
gboolean ret = TRUE;
GstVideoInfo *info = &state->info;
@ -1593,6 +1597,11 @@ gst_vpx_enc_set_format (GstVideoEncoder * video_encoder,
g_mutex_lock (&encoder->encoder_lock);
}
encoder->cfg.g_bit_depth = encoder->cfg.g_input_bit_depth = info->finfo->bits;
if (encoder->cfg.g_bit_depth > 8) {
flags |= VPX_CODEC_USE_HIGHBITDEPTH;
}
encoder->cfg.g_profile = gst_vpx_enc_get_downstream_profile (encoder, info);
if (encoder->cfg.g_profile == INVALID_PROFILE) {
GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,
@ -1666,7 +1675,7 @@ gst_vpx_enc_set_format (GstVideoEncoder * video_encoder,
status =
vpx_codec_enc_init (&encoder->encoder, vpx_enc_class->get_algo (encoder),
&encoder->cfg, 0);
&encoder->cfg, flags);
if (status != VPX_CODEC_OK) {
GST_ELEMENT_ERROR (encoder, LIBRARY, INIT,
("Failed to initialize encoder"), ("%s", gst_vpx_error_name (status)));