smartencoder: Force reencoding of vp9 for profiles can't support

If the input file is in a profile we won't be able to output (1 or 3 in BGR
format), simply reencode everything for now.

Once we add support for that case we can remove that code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1062>
This commit is contained in:
Thibault Saunier 2021-10-14 23:02:36 -03:00
parent fec6270205
commit 156f2543ca

View file

@ -356,11 +356,38 @@ done:
return res;
}
static gboolean
gst_smart_encoder_force_reencoding_for_caps (GstSmartEncoder * self)
{
const gchar *profile;
GstStructure *structure = gst_caps_get_structure (self->original_caps, 0);
if (!gst_structure_has_name (structure, "video/x-vp9"))
return FALSE;
if (!(profile = gst_structure_get_string (structure, "profile"))) {
GST_WARNING_OBJECT (self,
"No profile set on `vp9` stream, force reencoding");
return TRUE;
}
if (g_strcmp0 (profile, "0") && g_strcmp0 (profile, "2")) {
GST_INFO_OBJECT (self, "vp9 profile %s not supported for smart reencoding"
" as it might be using RGB stream which we can't handle properly"
" force reencoding", profile);
return TRUE;
}
return FALSE;
}
static GstFlowReturn
gst_smart_encoder_push_pending_gop (GstSmartEncoder * self)
{
guint64 cstart, cstop;
GList *tmp;
gboolean force_reencoding = FALSE;
GstFlowReturn res = GST_FLOW_OK;
GST_DEBUG ("Pushing pending GOP (%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT
@ -386,8 +413,10 @@ gst_smart_encoder_push_pending_gop (GstSmartEncoder * self)
goto done;
}
force_reencoding = gst_smart_encoder_force_reencoding_for_caps (self);
if ((cstart != self->gop_start)
|| (cstop != self->gop_stop)) {
|| (cstop != self->gop_stop)
|| force_reencoding) {
GST_INFO_OBJECT (self,
"GOP needs to be re-encoded from %" GST_TIME_FORMAT " to %"
GST_TIME_FORMAT " - %" GST_SEGMENT_FORMAT, GST_TIME_ARGS (cstart),
@ -395,6 +424,7 @@ gst_smart_encoder_push_pending_gop (GstSmartEncoder * self)
res = gst_smart_encoder_reencode_gop (self);
/* Make sure we push the original caps when resuming the original stream */
if (!force_reencoding)
self->push_original_caps = TRUE;
} else {
if (self->push_original_caps) {