static gboolean
gst_vdp_mpeg_dec_handle_picture_coding (GstVdpMpegDec * mpeg_dec,
    GstBuffer * buffer, GstVideoFrame * frame)
{
  MPEGPictureExt pic_ext;
  VdpPictureInfoMPEG1Or2 *info;
  gint fields;

  info = &mpeg_dec->vdp_info;

  if (!mpeg_util_parse_picture_coding_extension (&pic_ext, buffer))
    return FALSE;

  memcpy (&mpeg_dec->vdp_info.f_code, &pic_ext.f_code, 4);

  info->intra_dc_precision = pic_ext.intra_dc_precision;
  info->picture_structure = pic_ext.picture_structure;
  info->top_field_first = pic_ext.top_field_first;
  info->frame_pred_frame_dct = pic_ext.frame_pred_frame_dct;
  info->concealment_motion_vectors = pic_ext.concealment_motion_vectors;
  info->q_scale_type = pic_ext.q_scale_type;
  info->intra_vlc_format = pic_ext.intra_vlc_format;
  info->alternate_scan = pic_ext.alternate_scan;

  fields = 2;
  if (pic_ext.picture_structure == 3) {
    if (mpeg_dec->stream_info.interlaced) {
      if (pic_ext.progressive_frame == 0)
        fields = 2;
      if (pic_ext.progressive_frame == 0 && pic_ext.repeat_first_field == 0)
        fields = 2;
      if (pic_ext.progressive_frame == 1 && pic_ext.repeat_first_field == 1)
        fields = 3;
    } else {
      if (pic_ext.repeat_first_field == 0)
        fields = 2;
      if (pic_ext.repeat_first_field == 1 && pic_ext.top_field_first == 0)
        fields = 4;
      if (pic_ext.repeat_first_field == 1 && pic_ext.top_field_first == 1)
        fields = 6;
    }
  } else
    fields = 1;

  frame->n_fields = fields;

  if (pic_ext.top_field_first)
    GST_VIDEO_FRAME_FLAG_SET (frame, GST_VIDEO_FRAME_FLAG_TFF);

  return TRUE;
}
Esempio n. 2
0
static gboolean
gst_vdp_mpeg_dec_parse_picture_coding (GstVdpMpegDec * mpeg_dec,
                                       GstBuffer * buffer)
{
    MPEGPictureExt pic_ext;
    VdpPictureInfoMPEG1Or2 *info;
    gint fields;

    info = &mpeg_dec->vdp_info;

    if (!mpeg_util_parse_picture_coding_extension (&pic_ext, buffer))
        return FALSE;

    memcpy (&mpeg_dec->vdp_info.f_code, &pic_ext.f_code, 4);

    info->intra_dc_precision = pic_ext.intra_dc_precision;
    info->picture_structure = pic_ext.picture_structure;
    info->top_field_first = pic_ext.top_field_first;
    info->frame_pred_frame_dct = pic_ext.frame_pred_frame_dct;
    info->concealment_motion_vectors = pic_ext.concealment_motion_vectors;
    info->q_scale_type = pic_ext.q_scale_type;
    info->intra_vlc_format = pic_ext.intra_vlc_format;
    info->alternate_scan = pic_ext.alternate_scan;

    fields = 2;
    if (pic_ext.picture_structure == 3) {
        if (mpeg_dec->interlaced) {
            if (pic_ext.progressive_frame == 0)
                fields = 2;
            if (pic_ext.progressive_frame == 0 && pic_ext.repeat_first_field == 0)
                fields = 2;
            if (pic_ext.progressive_frame == 1 && pic_ext.repeat_first_field == 1)
                fields = 3;
        } else {
            if (pic_ext.repeat_first_field == 0)
                fields = 2;
            if (pic_ext.repeat_first_field == 1 && pic_ext.top_field_first == 0)
                fields = 4;
            if (pic_ext.repeat_first_field == 1 && pic_ext.top_field_first == 1)
                fields = 6;
        }
    } else
        fields = 1;

    GST_DEBUG ("fields: %d", fields);

    mpeg_dec->duration = gst_util_uint64_scale (fields,
                         GST_SECOND * mpeg_dec->fps_d, 2 * mpeg_dec->fps_n);

    return TRUE;
}