Ejemplo n.º 1
0
/* Derives the profile supported by the underlying hardware */
static gboolean
ensure_hw_profile (GstVaapiEncoderVP8 * encoder)
{
  GstVaapiDisplay *const display = GST_VAAPI_ENCODER_DISPLAY (encoder);
  GstVaapiEntrypoint entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
  GstVaapiProfile profile, profiles[2];
  guint i, num_profiles = 0;

  profiles[num_profiles++] = encoder->profile;

  profile = GST_VAAPI_PROFILE_UNKNOWN;
  for (i = 0; i < num_profiles; i++) {
    if (gst_vaapi_display_has_encoder (display, profiles[i], entrypoint)) {
      profile = profiles[i];
      break;
    }
  }
  if (profile == GST_VAAPI_PROFILE_UNKNOWN)
    goto error_unsupported_profile;

  GST_VAAPI_ENCODER_CAST (encoder)->profile = profile;
  return TRUE;

  /* ERRORS */
error_unsupported_profile:
  {
    GST_ERROR ("unsupported HW profile %s",
        gst_vaapi_profile_get_name (encoder->profile));
    return FALSE;
  }
}
Ejemplo n.º 2
0
static void
gst_vaapiencode_register (GstPlugin * plugin, GstVaapiDisplay * display)
{
  guint i, j;
  GArray *codecs;
  GstVaapiCodec codec;

  codecs = display_get_encoder_codecs (display);
  if (!codecs)
    return;

  for (i = 0; i < codecs->len; i++) {
    codec = g_array_index (codecs, GstVaapiCodec, i);
    for (j = 0; j < G_N_ELEMENTS (vaapi_encode_map); j++) {
      if (vaapi_encode_map[j].codec == codec) {
        gst_element_register (plugin, vaapi_encode_map[j].name,
            vaapi_encode_map[j].rank, vaapi_encode_map[j].get_type ());
        break;
      }
    }
  }

#if USE_H264_FEI_ENCODER
  if (gst_vaapi_display_has_encoder (display,
          GST_VAAPI_PROFILE_H264_MAIN, GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI)) {
    gst_element_register (plugin, "vaapih264feienc",
        GST_RANK_SECONDARY, GST_TYPE_VAAPIENCODE_H264_FEI);
  }
#endif

  g_array_unref (codecs);
}
/* Derives the profile supported by the underlying hardware */
static gboolean
ensure_hw_profile (GstVaapiEncoderMpeg2 * encoder)
{
  GstVaapiDisplay *const display = GST_VAAPI_ENCODER_DISPLAY (encoder);
  GstVaapiEntrypoint entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
  GstVaapiProfile profile, profiles[2];
  guint i, num_profiles = 0;

  profiles[num_profiles++] = encoder->profile;
  switch (encoder->profile) {
    case GST_VAAPI_PROFILE_MPEG2_SIMPLE:
      profiles[num_profiles++] = GST_VAAPI_PROFILE_MPEG2_MAIN;
      break;
    default:
      break;
  }

  profile = GST_VAAPI_PROFILE_UNKNOWN;
  for (i = 0; i < num_profiles; i++) {
    if (gst_vaapi_display_has_encoder (display, profiles[i], entrypoint)) {
      profile = profiles[i];
      break;
    }
  }
  if (profile == GST_VAAPI_PROFILE_UNKNOWN)
    goto error_unsupported_profile;

  GST_VAAPI_ENCODER_CAST (encoder)->profile = profile;
  return TRUE;

  /* ERRORS */
error_unsupported_profile:
  {
    GST_ERROR ("unsupported HW profile (0x%08x)", encoder->profile);
    return FALSE;
  }
}