diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2009-06-04 21:17:40 +0200 |
---|---|---|
committer | Jan Schmidt <thaytan@noraisin.net> | 2009-06-20 15:21:41 +0100 |
commit | df3c59a48286f242649aa3279b1c522b2b1fb1c7 (patch) | |
tree | 580da8e02eb0e9ab99c031abbbfc6f223f167870 /sys | |
parent | aee19375793395486b07679f30e3bed5e85119ea (diff) | |
download | gst-plugins-bad-df3c59a48286f242649aa3279b1c522b2b1fb1c7.tar.gz gst-plugins-bad-df3c59a48286f242649aa3279b1c522b2b1fb1c7.tar.bz2 gst-plugins-bad-df3c59a48286f242649aa3279b1c522b2b1fb1c7.zip |
vdpaumpegdec: calculate correct duration from data in MPEG_PACKET_EXT_PICTURE_CODING
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vdpau/gstvdpmpegdecoder.c | 40 | ||||
-rw-r--r-- | sys/vdpau/gstvdpmpegdecoder.h | 1 | ||||
-rw-r--r-- | sys/vdpau/mpegutil.c | 8 | ||||
-rw-r--r-- | sys/vdpau/mpegutil.h | 2 |
4 files changed, 48 insertions, 3 deletions
diff --git a/sys/vdpau/gstvdpmpegdecoder.c b/sys/vdpau/gstvdpmpegdecoder.c index dbb87c38..008a2428 100644 --- a/sys/vdpau/gstvdpmpegdecoder.c +++ b/sys/vdpau/gstvdpmpegdecoder.c @@ -182,7 +182,7 @@ gst_vdp_mpeg_decoder_set_caps (GstPad * pad, GstCaps * caps) /* create src_pad caps */ gst_structure_get_int (structure, "width", &width); gst_structure_get_int (structure, "height", &height); - gst_structure_get_fraction (structure, "framerate", &fps_d, &fps_d); + gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d); gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n, &par_d); gst_structure_get_boolean (structure, "interlaced", &interlaced); @@ -278,7 +278,7 @@ gst_vdp_mpeg_decoder_push_video_buffer (GstVdpMpegDecoder * mpeg_dec, } mpeg_dec->next_timestamp = GST_BUFFER_TIMESTAMP (buffer) + - gst_util_uint64_scale_int (GST_SECOND, mpeg_dec->fps_d, mpeg_dec->fps_n); + GST_BUFFER_DURATION (buffer); gst_buffer_set_caps (GST_BUFFER (buffer), GST_PAD_CAPS (mpeg_dec->src)); @@ -327,6 +327,7 @@ gst_vdp_mpeg_decoder_decode (GstVdpMpegDecoder * mpeg_dec, outbuf = gst_vdp_video_buffer_new (mpeg_dec->device, VDP_CHROMA_TYPE_420, mpeg_dec->width, mpeg_dec->height); GST_BUFFER_TIMESTAMP (outbuf) = timestamp; + GST_BUFFER_DURATION (outbuf) = mpeg_dec->duration; if (info->forward_reference != VDP_INVALID_HANDLE && info->picture_coding_type != I_FRAME) @@ -378,6 +379,7 @@ gst_vdp_mpeg_decoder_parse_picture_coding (GstVdpMpegDecoder * mpeg_dec, { MPEGPictureExt pic_ext; VdpPictureInfoMPEG1Or2 *info; + gint fields; info = &mpeg_dec->vdp_info; @@ -395,6 +397,36 @@ gst_vdp_mpeg_decoder_parse_picture_coding (GstVdpMpegDecoder * mpeg_dec, info->intra_vlc_format = pic_ext.intra_vlc_format; info->alternate_scan = pic_ext.alternate_scan; + fields = 0; + 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); + + if (!fields) { + GST_DEBUG ("Invalid Picture Extension packet"); + return FALSE; + } + + mpeg_dec->duration = gst_util_uint64_scale (fields, + GST_SECOND * mpeg_dec->fps_d, 2 * mpeg_dec->fps_n); + return TRUE; } @@ -407,7 +439,6 @@ gst_vdp_mpeg_decoder_parse_sequence (GstVdpMpegDecoder * mpeg_dec, if (!mpeg_util_parse_sequence_hdr (&hdr, buffer)) return FALSE; - g_debug ("här"); memcpy (&mpeg_dec->vdp_info.intra_quantizer_matrix, &hdr.intra_quantizer_matrix, 64); memcpy (&mpeg_dec->vdp_info.non_intra_quantizer_matrix, @@ -448,6 +479,9 @@ gst_vdp_mpeg_decoder_parse_picture (GstVdpMpegDecoder * mpeg_dec, memcpy (&mpeg_dec->vdp_info.f_code, &pic_hdr.f_code, 4); } + mpeg_dec->duration = gst_util_uint64_scale (1, GST_SECOND * mpeg_dec->fps_d, + mpeg_dec->fps_n); + return TRUE; } diff --git a/sys/vdpau/gstvdpmpegdecoder.h b/sys/vdpau/gstvdpmpegdecoder.h index 3e1bc731..facc791b 100644 --- a/sys/vdpau/gstvdpmpegdecoder.h +++ b/sys/vdpau/gstvdpmpegdecoder.h @@ -60,6 +60,7 @@ struct _GstVdpMpegDecoder GstBuffer *b_buffer; gboolean broken_gop; + GstClockTime duration; GstClockTime next_timestamp; GstAdapter *adapter; diff --git a/sys/vdpau/mpegutil.c b/sys/vdpau/mpegutil.c index c35ad9fb..bba84f2b 100644 --- a/sys/vdpau/mpegutil.c +++ b/sys/vdpau/mpegutil.c @@ -333,6 +333,14 @@ mpeg_util_parse_picture_coding_extension (MPEGPictureExt * ext, if (!gst_bit_reader_get_bits_uint8 (&reader, &ext->repeat_first_field, 1)) return FALSE; + /* chroma_420_type */ + if (!gst_bit_reader_get_bits_uint8 (&reader, &ext->chroma_420_type, 1)) + return FALSE; + + /* progressive_frame */ + if (!gst_bit_reader_get_bits_uint8 (&reader, &ext->progressive_frame, 1)) + return FALSE; + return TRUE; } diff --git a/sys/vdpau/mpegutil.h b/sys/vdpau/mpegutil.h index 4e5a656a..08f6cc2f 100644 --- a/sys/vdpau/mpegutil.h +++ b/sys/vdpau/mpegutil.h @@ -111,6 +111,8 @@ struct MPEGPictureExt guint8 intra_vlc_format; guint8 alternate_scan; guint8 repeat_first_field; + guint8 chroma_420_type; + guint8 progressive_frame; }; struct MPEGGop |