コード例 #1
0
static gboolean
fill_picture (GstVaapiEncoderVP8 * encoder,
    GstVaapiEncPicture * picture,
    GstVaapiCodedBuffer * codedbuf, GstVaapiSurfaceProxy * surface)
{
  VAEncPictureParameterBufferVP8 *const pic_param = picture->param;
  int i;

  memset (pic_param, 0, sizeof (VAEncPictureParameterBufferVP8));

  pic_param->reconstructed_frame = GST_VAAPI_SURFACE_PROXY_SURFACE_ID (surface);
  pic_param->coded_buf = GST_VAAPI_OBJECT_ID (codedbuf);

  if (picture->type == GST_VAAPI_PICTURE_TYPE_P) {
    pic_param->pic_flags.bits.frame_type = 1;
    pic_param->ref_arf_frame =
        GST_VAAPI_SURFACE_PROXY_SURFACE_ID (encoder->alt_ref);
    pic_param->ref_gf_frame =
        GST_VAAPI_SURFACE_PROXY_SURFACE_ID (encoder->golden_ref);
    pic_param->ref_last_frame =
        GST_VAAPI_SURFACE_PROXY_SURFACE_ID (encoder->last_ref);
    pic_param->pic_flags.bits.refresh_last = 1;
    pic_param->pic_flags.bits.refresh_golden_frame = 0;
    pic_param->pic_flags.bits.copy_buffer_to_golden = 1;
    pic_param->pic_flags.bits.refresh_alternate_frame = 0;
    pic_param->pic_flags.bits.copy_buffer_to_alternate = 2;
  } else {
    pic_param->ref_last_frame = VA_INVALID_SURFACE;
    pic_param->ref_gf_frame = VA_INVALID_SURFACE;
    pic_param->ref_arf_frame = VA_INVALID_SURFACE;
    pic_param->pic_flags.bits.refresh_last = 1;
    pic_param->pic_flags.bits.refresh_golden_frame = 1;
    pic_param->pic_flags.bits.refresh_alternate_frame = 1;
  }

  pic_param->pic_flags.bits.show_frame = 1;

  if (encoder->loop_filter_level) {
    pic_param->pic_flags.bits.version = 1;
    pic_param->pic_flags.bits.loop_filter_type = 1;     /* Enable simple loop filter */
    /* Disabled segmentation, so what matters is only loop_filter_level[0] */
    for (i = 0; i < 4; i++)
      pic_param->loop_filter_level[i] = encoder->loop_filter_level;
  }

  pic_param->sharpness_level = encoder->sharpness_level;

  /* Used for CBR */
  pic_param->clamp_qindex_low = 0;
  pic_param->clamp_qindex_high = 127;

  return TRUE;
}
コード例 #2
0
static gboolean
fill_picture (GstVaapiEncoderJpeg * encoder,
    GstVaapiEncPicture * picture,
    GstVaapiCodedBuffer * codedbuf, GstVaapiSurfaceProxy * surface)
{
  VAEncPictureParameterBufferJPEG *const pic_param = picture->param;

  memset (pic_param, 0, sizeof (VAEncPictureParameterBufferJPEG));

  pic_param->reconstructed_picture =
      GST_VAAPI_SURFACE_PROXY_SURFACE_ID (surface);
  pic_param->picture_width = GST_VAAPI_ENCODER_WIDTH (encoder);
  pic_param->picture_height = GST_VAAPI_ENCODER_HEIGHT (encoder);
  pic_param->coded_buf = GST_VAAPI_OBJECT_ID (codedbuf);

  pic_param->pic_flags.bits.profile = 0;        /* Profile = Baseline */
  pic_param->pic_flags.bits.progressive = 0;    /* Sequential encoding */
  pic_param->pic_flags.bits.huffman = 1;        /* Uses Huffman coding */
  pic_param->pic_flags.bits.interleaved = 0;    /* Input format is non interleaved (YUV) */
  pic_param->pic_flags.bits.differential = 0;   /* non-Differential Encoding */
  pic_param->sample_bit_depth = 8;
  pic_param->num_scan = 1;
  pic_param->num_components = encoder->n_components;
  pic_param->quality = encoder->quality;
  return TRUE;
}
コード例 #3
0
/**
 * gst_vaapi_surface_proxy_get_surface_id:
 * @proxy: a #GstVaapiSurfaceProxy
 *
 * Returns the VA surface ID stored in the @proxy.
 *
 * Return value: the #GstVaapiID
 */
GstVaapiID
gst_vaapi_surface_proxy_get_surface_id (GstVaapiSurfaceProxy * proxy)
{
  g_return_val_if_fail (proxy != NULL, VA_INVALID_ID);
  g_return_val_if_fail (proxy->surface != NULL, VA_INVALID_ID);

  return GST_VAAPI_SURFACE_PROXY_SURFACE_ID (proxy);
}
コード例 #4
0
static inline void
push_frame (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame)
{
  GstVaapiSurfaceProxy *const proxy = frame->user_data;

  GST_DEBUG ("push frame %d (surface 0x%08x)", frame->system_frame_number,
      (guint32) GST_VAAPI_SURFACE_PROXY_SURFACE_ID (proxy));

  g_async_queue_push (decoder->frames, gst_video_codec_frame_ref (frame));
}
コード例 #5
0
static inline GstVideoCodecFrame *
pop_frame (GstVaapiDecoder * decoder, guint64 timeout)
{
  GstVideoCodecFrame *frame;
  GstVaapiSurfaceProxy *proxy;

  if (G_LIKELY (timeout > 0))
    frame = g_async_queue_timeout_pop (decoder->frames, timeout);
  else
    frame = g_async_queue_try_pop (decoder->frames);
  if (!frame)
    return NULL;

  proxy = frame->user_data;
  GST_DEBUG ("pop frame %d (surface 0x%08x)", frame->system_frame_number,
      (proxy ? (guint32) GST_VAAPI_SURFACE_PROXY_SURFACE_ID (proxy) :
          VA_INVALID_ID));

  return frame;
}
コード例 #6
0
static gboolean
fill_picture (GstVaapiEncoderMpeg2 * encoder,
    GstVaapiEncPicture * picture,
    GstVaapiCodedBuffer * codedbuf, GstVaapiSurfaceProxy * surface)
{
  VAEncPictureParameterBufferMPEG2 *const pic_param = picture->param;
  guint8 f_code_x, f_code_y;

  memset (pic_param, 0, sizeof (VAEncPictureParameterBufferMPEG2));

  pic_param->reconstructed_picture =
      GST_VAAPI_SURFACE_PROXY_SURFACE_ID (surface);
  pic_param->coded_buf = GST_VAAPI_OBJECT_ID (codedbuf);
  pic_param->picture_type = get_va_enc_picture_type (picture->type);
  pic_param->temporal_reference = picture->frame_num & (1024 - 1);
  pic_param->vbv_delay = 0xFFFF;

  f_code_x = 0xf;
  f_code_y = 0xf;
  if (pic_param->picture_type != VAEncPictureTypeIntra) {
    switch (encoder->level) {
      case GST_VAAPI_LEVEL_MPEG2_LOW:
        f_code_x = 7;
        f_code_y = 4;
        break;
      case GST_VAAPI_LEVEL_MPEG2_MAIN:
        f_code_x = 8;
        f_code_y = 5;
        break;
      default:                 /* High-1440 and High levels */
        f_code_x = 9;
        f_code_y = 5;
        break;
    }
  }

  if (pic_param->picture_type == VAEncPictureTypeIntra) {
    pic_param->f_code[0][0] = 0xf;
    pic_param->f_code[0][1] = 0xf;
    pic_param->f_code[1][0] = 0xf;
    pic_param->f_code[1][1] = 0xf;
    pic_param->forward_reference_picture = VA_INVALID_SURFACE;
    pic_param->backward_reference_picture = VA_INVALID_SURFACE;
  } else if (pic_param->picture_type == VAEncPictureTypePredictive) {
    pic_param->f_code[0][0] = f_code_x;
    pic_param->f_code[0][1] = f_code_y;
    pic_param->f_code[1][0] = 0xf;
    pic_param->f_code[1][1] = 0xf;
    pic_param->forward_reference_picture =
        GST_VAAPI_SURFACE_PROXY_SURFACE_ID (encoder->forward);
    pic_param->backward_reference_picture = VA_INVALID_SURFACE;
  } else if (pic_param->picture_type == VAEncPictureTypeBidirectional) {
    pic_param->f_code[0][0] = f_code_x;
    pic_param->f_code[0][1] = f_code_y;
    pic_param->f_code[1][0] = f_code_x;
    pic_param->f_code[1][1] = f_code_y;
    pic_param->forward_reference_picture =
        GST_VAAPI_SURFACE_PROXY_SURFACE_ID (encoder->forward);
    pic_param->backward_reference_picture =
        GST_VAAPI_SURFACE_PROXY_SURFACE_ID (encoder->backward);
  } else {
    g_assert (0);
  }

  pic_param->picture_coding_extension.bits.intra_dc_precision = 0;      /* 8bits */
  pic_param->picture_coding_extension.bits.picture_structure = 3;       /* frame picture */
  pic_param->picture_coding_extension.bits.top_field_first = 0;
  pic_param->picture_coding_extension.bits.frame_pred_frame_dct = 1;    /* FIXME */
  pic_param->picture_coding_extension.bits.concealment_motion_vectors = 0;
  pic_param->picture_coding_extension.bits.q_scale_type = 0;
  pic_param->picture_coding_extension.bits.intra_vlc_format = 0;
  pic_param->picture_coding_extension.bits.alternate_scan = 0;
  pic_param->picture_coding_extension.bits.repeat_first_field = 0;
  pic_param->picture_coding_extension.bits.progressive_frame = 1;
  pic_param->picture_coding_extension.bits.composite_display_flag = 0;

  return TRUE;
}