/* Determines the set of supported packed headers */ static guint get_packed_headers (GstVaapiEncoder * encoder) { const GstVaapiEncoderClassData *const cdata = GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data; guint value; if (encoder->got_packed_headers) return encoder->packed_headers; if (!get_config_attribute (encoder, VAConfigAttribEncPackedHeaders, &value)) value = 0; GST_INFO ("supported packed headers: 0x%08x", value); encoder->got_packed_headers = TRUE; encoder->packed_headers = cdata->packed_headers & value; if (cdata->codec == GST_VAAPI_CODEC_JPEG) { #if !VA_CHECK_VERSION(0,37,1) encoder->packed_headers = VA_ENC_PACKED_HEADER_RAW_DATA; GST_DEBUG ("Hard coding the packed header flag value to VA_ENC_PACKED_HEADER_RAW_DATA," "This is a work around for the driver bug"); #endif } return encoder->packed_headers; }
static inline gboolean is_chroma_type_supported (GstVaapiEncoder * encoder) { GstVaapiContextInfo *const cip = &encoder->context_info; const GstVideoFormat fmt = GST_VIDEO_INFO_FORMAT (GST_VAAPI_ENCODER_VIDEO_INFO (encoder)); guint format = 0; if (fmt == GST_VIDEO_FORMAT_ENCODED) return TRUE; if (cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV420 && cip->chroma_type != GST_VAAPI_CHROMA_TYPE_YUV422) goto unsupported; if (!get_config_attribute (encoder, VAConfigAttribRTFormat, &format)) return FALSE; if (!(format & from_GstVaapiChromaType (cip->chroma_type))) goto unsupported; return TRUE; unsupported: { GST_ERROR ("We only support YUV 4:2:0 and YUV 4:2:2 for encoding. " "Please try to use vaapipostproc to convert the input format."); return FALSE; } }
/* Determine the supported rate control modes */ static guint get_rate_control_mask (GstVaapiEncoder * encoder) { const GstVaapiEncoderClassData *const cdata = GST_VAAPI_ENCODER_GET_CLASS (encoder)->class_data; guint i, value, rate_control_mask = 0; if (encoder->got_rate_control_mask) return encoder->rate_control_mask; if (get_config_attribute (encoder, VAConfigAttribRateControl, &value)) { for (i = 0; i < 32; i++) { if (!(value & (1U << i))) continue; rate_control_mask |= 1 << to_GstVaapiRateControl (1 << i); } } GST_INFO ("supported rate controls: 0x%08x", rate_control_mask); encoder->got_rate_control_mask = TRUE; encoder->rate_control_mask = cdata->rate_control_mask & rate_control_mask; return encoder->rate_control_mask; }