vdpaumpegdec: calculate byterate from the size of the incoming data

This commit is contained in:
Carl-Anton Ingmarsson 2009-06-05 21:16:48 +02:00 committed by Jan Schmidt
parent c9464b9860
commit c4276ae568
2 changed files with 38 additions and 12 deletions

View file

@ -283,6 +283,8 @@ GstFlowReturn
gst_vdp_mpeg_decoder_push_video_buffer (GstVdpMpegDecoder * mpeg_dec,
GstVdpVideoBuffer * buffer)
{
gint64 byterate;
if (GST_BUFFER_TIMESTAMP (buffer) == GST_CLOCK_TIME_NONE
&& GST_CLOCK_TIME_IS_VALID (mpeg_dec->next_timestamp)) {
GST_BUFFER_TIMESTAMP (buffer) = mpeg_dec->next_timestamp;
@ -305,6 +307,14 @@ gst_vdp_mpeg_decoder_push_video_buffer (GstVdpMpegDecoder * mpeg_dec,
mpeg_dec->next_timestamp = GST_BUFFER_TIMESTAMP (buffer) +
GST_BUFFER_DURATION (buffer);
mpeg_dec->accumulated_duration += GST_BUFFER_DURATION (buffer);
mpeg_dec->accumulated_size += GST_BUFFER_SIZE (buffer);
byterate = gst_util_uint64_scale (mpeg_dec->accumulated_size, GST_SECOND,
mpeg_dec->accumulated_duration);
GST_DEBUG ("byterate: %" G_GINT64_FORMAT, mpeg_dec->byterate);
mpeg_dec->byterate = (mpeg_dec->byterate + byterate) / 2;
gst_buffer_set_caps (GST_BUFFER (buffer), GST_PAD_CAPS (mpeg_dec->src));
GST_DEBUG_OBJECT (mpeg_dec,
@ -356,6 +366,8 @@ gst_vdp_mpeg_decoder_decode (GstVdpMpegDecoder * mpeg_dec,
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = mpeg_dec->duration;
GST_BUFFER_OFFSET (outbuf) = mpeg_dec->frame_nr;
GST_BUFFER_SIZE (outbuf) = mpeg_dec->size;
if (info->top_field_first)
GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_TFF);
@ -575,6 +587,9 @@ gst_vdp_mpeg_decoder_reset (GstVdpMpegDecoder * mpeg_dec)
gst_segment_init (&mpeg_dec->segment, GST_FORMAT_TIME);
mpeg_dec->seeking = FALSE;
mpeg_dec->accumulated_size = 0;
mpeg_dec->accumulated_duration = 0;
}
static GstFlowReturn
@ -592,6 +607,7 @@ gst_vdp_mpeg_decoder_chain (GstPad * pad, GstBuffer * buffer)
gst_vdp_mpeg_decoder_flush (mpeg_dec);
}
mpeg_dec->size = GST_BUFFER_SIZE (buffer);
gst_vdp_mpeg_packetizer_init (&packetizer, buffer);
while ((buf = gst_vdp_mpeg_packetizer_get_next_packet (&packetizer))) {
GstBitReader b_reader = GST_BIT_READER_INIT_FROM_BUFFER (buf);

View file

@ -42,34 +42,44 @@ struct _GstVdpMpegDecoder
{
GstElement element;
gchar *display_name;
GstVdpDevice *device;
/* pads */
GstPad *src;
GstPad *sink;
gchar *display_name;
GstVdpDevice *device;
VdpDecoder decoder;
/* stream info */
gint width, height;
gint fps_n, fps_d;
gboolean interlaced;
gint version;
VdpDecoder decoder;
/* currently decoded frame info */
GstAdapter *adapter;
VdpPictureInfoMPEG1Or2 vdp_info;
guint64 size;
guint64 frame_nr;
GstClockTime duration;
/* frame_nr from GOP */
guint64 gop_frame;
/* forward and backward reference */
GstBuffer *f_buffer;
GstBuffer *b_buffer;
GstClockTime duration;
/* calculated timestamp, size and duration */
GstClockTime next_timestamp;
guint64 accumulated_size;
guint64 accumulated_duration;
guint64 gop_frame;
guint64 frame_nr;
/* seek data */
GstSegment segment;
gboolean seeking;
gint64 byterate;
GstAdapter *adapter;
};
struct _GstVdpMpegDecoderClass