summaryrefslogtreecommitdiffstats
path: root/sys/vdpau
diff options
context:
space:
mode:
authorCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>2009-06-05 21:16:48 +0200
committerJan Schmidt <thaytan@noraisin.net>2009-06-20 15:21:43 +0100
commitc4276ae568934f5f14beab02199849f6aeb757ac (patch)
tree1bd1ae3f48da4ab395c72c81270cb703a6440370 /sys/vdpau
parentc9464b98604dd6023f5985f4d29e1bb4051d58ee (diff)
downloadgst-plugins-bad-c4276ae568934f5f14beab02199849f6aeb757ac.tar.gz
gst-plugins-bad-c4276ae568934f5f14beab02199849f6aeb757ac.tar.bz2
gst-plugins-bad-c4276ae568934f5f14beab02199849f6aeb757ac.zip
vdpaumpegdec: calculate byterate from the size of the incoming data
Diffstat (limited to 'sys/vdpau')
-rw-r--r--sys/vdpau/gstvdpmpegdecoder.c16
-rw-r--r--sys/vdpau/gstvdpmpegdecoder.h34
2 files changed, 38 insertions, 12 deletions
diff --git a/sys/vdpau/gstvdpmpegdecoder.c b/sys/vdpau/gstvdpmpegdecoder.c
index 04bebb8a..53e99a5f 100644
--- a/sys/vdpau/gstvdpmpegdecoder.c
+++ b/sys/vdpau/gstvdpmpegdecoder.c
@@ -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);
diff --git a/sys/vdpau/gstvdpmpegdecoder.h b/sys/vdpau/gstvdpmpegdecoder.h
index 9a57e283..3cd521ba 100644
--- a/sys/vdpau/gstvdpmpegdecoder.h
+++ b/sys/vdpau/gstvdpmpegdecoder.h
@@ -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;
- GstBuffer *f_buffer;
- GstBuffer *b_buffer;
-
+ guint64 size;
+ guint64 frame_nr;
GstClockTime duration;
- GstClockTime next_timestamp;
+ /* frame_nr from GOP */
guint64 gop_frame;
- guint64 frame_nr;
+
+ /* forward and backward reference */
+ GstBuffer *f_buffer;
+ GstBuffer *b_buffer;
+ /* calculated timestamp, size and duration */
+ GstClockTime next_timestamp;
+ guint64 accumulated_size;
+ guint64 accumulated_duration;
+
+ /* seek data */
GstSegment segment;
gboolean seeking;
gint64 byterate;
- GstAdapter *adapter;
};
struct _GstVdpMpegDecoderClass