vdpauh264dec: add gst_h264_dpb_set_output_func function
authorCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
Sat, 26 Jun 2010 17:02:00 +0000 (19:02 +0200)
committerCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
Sat, 26 Jun 2010 19:27:32 +0000 (21:27 +0200)
sys/vdpau/h264/gsth264dpb.c
sys/vdpau/h264/gsth264dpb.h
sys/vdpau/h264/gstvdph264dec.c

index 3f61b61..382ac28 100644 (file)
@@ -49,8 +49,8 @@ gst_h264_dpb_fill_reference_frames (GstH264DPB * dpb,
     GstVdpH264Frame *frame = frames[i];
 
     reference_frames[i].surface =
-        GST_VDP_VIDEO_BUFFER (GST_VIDEO_FRAME_CAST (frame)->src_buffer)->
-        surface;
+        GST_VDP_VIDEO_BUFFER (GST_VIDEO_FRAME_CAST (frame)->
+        src_buffer)->surface;
 
     reference_frames[i].is_long_term = frame->is_long_term;
     reference_frames[i].top_is_reference = frame->is_reference;
@@ -87,7 +87,7 @@ gst_h264_dpb_output (GstH264DPB * dpb, guint idx)
   GstVdpH264Frame *frame = dpb->frames[idx];
 
   gst_video_frame_ref (GST_VIDEO_FRAME_CAST (frame));
-  dpb->output (dpb, frame);
+  dpb->output (dpb, frame, dpb->user_data);
   frame->output_needed = FALSE;
 
   if (!frame->is_reference)
@@ -151,7 +151,7 @@ gst_h264_dpb_add (GstH264DPB * dpb, GstVdpH264Frame * h264_frame)
 
   else {
     while (gst_h264_dpb_bump (dpb, h264_frame->poc));
-    dpb->output (dpb, h264_frame);
+    dpb->output (dpb, h264_frame, dpb->user_data);
   }
 
   return TRUE;
@@ -295,6 +295,16 @@ gst_h264_dpb_mark_all_unused (GstH264DPB * dpb)
 
 }
 
+void
+gst_h264_dpb_set_output_func (GstH264DPB * dpb, GstH264DPBOutputFunc func,
+    gpointer user_data)
+{
+  g_return_if_fail (GST_IS_H264_DPB (dpb));
+
+  dpb->output = func;
+  dpb->user_data = user_data;
+}
+
 /* GObject vmethod implementations */
 static void
 gst_h264_dpb_get_property (GObject * object, guint property_id,
index d8962fe..a18be0d 100644 (file)
@@ -42,17 +42,21 @@ G_BEGIN_DECLS
 typedef struct _GstH264DPB GstH264DPB;
 typedef struct _GstH264DPBClass GstH264DPBClass;
 
+typedef void (*GstH264DPBOutputFunc) (GstH264DPB *dpb, GstVdpH264Frame *h264_frame, gpointer user_data);
+
 struct _GstH264DPB
 {
   GObject parent_instance;
 
+       /* private */
   GstVdpH264Frame *frames[MAX_DPB_SIZE];  
   guint n_frames;
   
   guint max_frames;
   gint max_longterm_frame_idx;
 
-  void (*output) (GstH264DPB *dpb, GstVdpH264Frame *h264_frame);
+       GstH264DPBOutputFunc output;
+       gpointer user_data;
 };
 
 struct _GstH264DPBClass
@@ -73,6 +77,9 @@ void gst_h264_dpb_mark_short_term_unused (GstH264DPB *dpb, guint16 pic_num);
 void gst_h264_dpb_mark_all_unused (GstH264DPB *dpb);
 void gst_h264_dpb_mark_long_term (GstH264DPB *dpb, guint16 pic_num, guint16 long_term_frame_idx);
 
+void gst_h264_dpb_set_output_func (GstH264DPB *dpb, GstH264DPBOutputFunc func,
+    gpointer user_data);
+
 GType gst_h264_dpb_get_type (void) G_GNUC_CONST;
 
 G_END_DECLS
index 8227496..1987744 100644 (file)
@@ -181,13 +181,13 @@ gst_vdp_h264_dec_shape_output (GstBaseVideoDecoder * base_video_decoder,
 }
 
 static void
-gst_vdp_h264_dec_output (GstH264DPB * dpb, GstVdpH264Frame * h264_frame)
+gst_vdp_h264_dec_output (GstH264DPB * dpb, GstVdpH264Frame * h264_frame,
+    gpointer user_data)
 {
-  GstBaseVideoDecoder *base_video_decoder;
+  GstBaseVideoDecoder *base_video_decoder = (GstBaseVideoDecoder *) user_data;
 
   GST_DEBUG ("poc: %d", h264_frame->poc);
 
-  base_video_decoder = g_object_get_data (G_OBJECT (dpb), "decoder");
   gst_base_video_decoder_finish_frame (base_video_decoder,
       GST_VIDEO_FRAME_CAST (h264_frame));
 }
@@ -888,8 +888,8 @@ gst_vdp_h264_dec_start (GstBaseVideoDecoder * base_video_decoder)
   h264_dec->parser = g_object_new (GST_TYPE_H264_PARSER, NULL);
 
   h264_dec->dpb = g_object_new (GST_TYPE_H264_DPB, NULL);
-  g_object_set_data (G_OBJECT (h264_dec->dpb), "decoder", h264_dec);
-  h264_dec->dpb->output = gst_vdp_h264_dec_output;
+  gst_h264_dpb_set_output_func (h264_dec->dpb, gst_vdp_h264_dec_output,
+      h264_dec);
 
   return TRUE;
 }