Exemplo n.º 1
0
static gboolean
gst_vdp_mpeg4_dec_flush (GstBaseVideoDecoder * base_video_decoder)
{
  GstVdpMpeg4Dec *mpeg4_dec = GST_VDP_MPEG4_DEC (base_video_decoder);

  if (mpeg4_dec->b_frame) {
    gst_video_frame_unref (GST_VIDEO_FRAME_CAST (mpeg4_dec->b_frame));
    mpeg4_dec->b_frame = NULL;
  }

  if (mpeg4_dec->f_frame) {
    gst_video_frame_unref (GST_VIDEO_FRAME_CAST (mpeg4_dec->f_frame));
    mpeg4_dec->f_frame = NULL;
  }

  return TRUE;
}
Exemplo n.º 2
0
static GstFlowReturn
gst_vdp_h264_dec_output (GstH264DPB * dpb, GstH264Frame * h264_frame,
    gpointer user_data)
{
  GstBaseVideoDecoder *base_video_decoder = (GstBaseVideoDecoder *) user_data;

  GST_DEBUG ("poc: %d", h264_frame->poc);

  return gst_base_video_decoder_finish_frame (base_video_decoder,
      GST_VIDEO_FRAME_CAST (h264_frame));
}
Exemplo n.º 3
0
static GstVideoFrame *
gst_vdp_h264_dec_create_frame (GstBaseVideoDecoder * base_video_decoder)
{
  return GST_VIDEO_FRAME_CAST (gst_h264_frame_new ());
}
Exemplo n.º 4
0
static GstFlowReturn
gst_vdp_mpeg4_dec_handle_frame (GstBaseVideoDecoder * base_video_decoder,
    GstVideoFrame * frame, GstClockTimeDiff deadline)
{
  GstVdpMpeg4Dec *mpeg4_dec = GST_VDP_MPEG4_DEC (base_video_decoder);

  GstMpeg4Frame *mpeg4_frame;
  GstFlowReturn ret;

  Mpeg4VideoObjectLayer *vol;
  Mpeg4VideoObjectPlane vop;

  VdpPictureInfoMPEG4Part2 info;
  VdpBitstreamBuffer bufs[1];
  GstVdpVideoBuffer *video_buf;

  mpeg4_frame = GST_MPEG4_FRAME (frame);

  ret = gst_vdp_mpeg4_dec_handle_configuration (mpeg4_dec, mpeg4_frame);
  if (ret != GST_FLOW_OK)
    return ret;

  vol = &mpeg4_dec->vol;
  if (!mpeg4_util_parse_VOP (mpeg4_frame->vop_buf, vol, &vop)) {
    gst_base_video_decoder_skip_frame (base_video_decoder, frame);
    return GST_FLOW_CUSTOM_ERROR;
  }

  /* calculate vop time */
  mpeg4_frame->vop_time =
      vop.modulo_time_base * vol->vop_time_increment_resolution +
      vop.time_increment;

  if (mpeg4_dec->tframe == -1 && vop.coding_type == B_VOP)
    mpeg4_dec->tframe = mpeg4_frame->vop_time - mpeg4_dec->f_frame->vop_time;

  if (vop.coding_type != B_VOP) {
    if (mpeg4_dec->b_frame) {

      ret = gst_base_video_decoder_finish_frame (base_video_decoder,
          GST_VIDEO_FRAME_CAST (mpeg4_dec->b_frame));

      if (mpeg4_dec->f_frame)
        gst_video_frame_unref (GST_VIDEO_FRAME_CAST (mpeg4_dec->f_frame));

      mpeg4_dec->f_frame = mpeg4_dec->b_frame;
      mpeg4_dec->b_frame = NULL;
    }
  }

  info = gst_vdp_mpeg4_dec_fill_info (mpeg4_dec, mpeg4_frame, &vop);
  bufs[0].struct_version = VDP_BITSTREAM_BUFFER_VERSION;
  bufs[0].bitstream = GST_BUFFER_DATA (mpeg4_frame->vop_buf);
  bufs[0].bitstream_bytes = GST_BUFFER_SIZE (mpeg4_frame->vop_buf);

  ret = gst_vdp_decoder_render (GST_VDP_DECODER (base_video_decoder),
      (VdpPictureInfo *) & info, 1, bufs, &video_buf);
  if (ret != GST_FLOW_OK) {
    gst_base_video_decoder_skip_frame (base_video_decoder, frame);
    return ret;
  }

  frame->src_buffer = GST_BUFFER_CAST (video_buf);

  if (vop.coding_type == B_VOP)
    ret = gst_base_video_decoder_finish_frame (base_video_decoder, frame);
  else {
    gst_video_frame_ref (GST_VIDEO_FRAME_CAST (mpeg4_frame));
    mpeg4_dec->b_frame = mpeg4_frame;
    ret = GST_FLOW_OK;
  }

  return ret;
}