[gst-devel] Opt scheduler modifications in recent days

Andy Wingo wingo at pobox.com
Sun Oct 12 02:56:04 CEST 2003


Yo,

I'm a bit ticked, I just wrote a long email that got lost due to a bad
mutt UI (Postpone this message (y/n)? -- no, i want to go back and send
it NO YOU JUST ERASED IT &*&$%^)...

Anyway a patch is attached. buffer-frames specifies the max size for a
float buffer. If a buffer is smaller than buffer-frames then that pad
will push EOS next time you pull from it. You still have to check the
buffer sizes, though.

Your problem had nothing to do with this, it was just a code path that I
didn't test forever ago when I wrote that code. Hence the g_message
(that would never be there if I knew the code worked properly).

Now, i will not postpone this message but also I will not delete it.
Let's see if me and mutt can cooperate...

Peace, Progress, and Prosperity (the SWAPO party motto),

wingo.

On Tue, 07 Oct 2003, iain wrote:

> Done a bit more investigating and discovered the "buffer-frames"
> property that is supposed to be set on float caps.
> 
> Now, the marlinsink element wasn't paying attention to this and was
> taking the number of frames in a buffer as GST_BUFFER_SIZE (buf)/sizeof
> (float).
> 
> Is this the problem? How should a sink use the buffer-frames property?
-------------- next part --------------
Index: gstint2float.c
--- gstint2float.c
+++ gstint2float.c
@@ -39,6 +39,12 @@
 
 #define GST_INT2FLOAT_DEFAULT_BUFFER_FRAMES 256
 
+#if 0
+#define DEBUG(...) g_message (__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
+
 GST_PAD_TEMPLATE_FACTORY (int2float_src_factory,
   "src%d",
   GST_PAD_SRC,
@@ -319,13 +325,16 @@
   data_out = this->data_out;
   channels = this->channels;
 
+  DEBUG ("chaining a buffer with %d frames",
+         GST_BUFFER_SIZE (buf_in) / channels / sizeof (gint16));
+
   if (!this->frames_to_write)
     fetch_buffers (this);
 
   to_process = this->leftover_frames;
   if (to_process) {
     /* remove this message when we know the code works properly */
-    g_message ("dealing with %d leftover frames", to_process);
+    DEBUG ("dealing with %d leftover frames", to_process);
     /* we are guaranteed that if some frames are left over, they can't fill a
        whole buffer */
     data_in = (gint16*)GST_BUFFER_DATA (this->in_buffer);
@@ -344,15 +353,17 @@
   this->leftover_frames = GST_BUFFER_SIZE (buf_in) / sizeof (gint16) / channels;
   data_in = (gint16*)GST_BUFFER_DATA (this->in_buffer);
   
-  to_process = MIN (this->leftover_frames, this->frames_to_write);
-
   while (1) {
+    to_process = MIN (this->leftover_frames, this->frames_to_write);
+    DEBUG ("processing %d frames", to_process);
+
     for (i=0, srcpads=this->srcpads ; i<this->numsrcpads; i++) {
       for (j=0; j<to_process; j++){
         data_out[i][j] = ((gfloat)data_in[(j*channels) + (i%channels)]) / 32767.0;
       }
       data_out[i] += to_process;
 
+      DEBUG ("if %d == %d then I'm pushing...", this->frames_to_write, to_process);
       if (this->frames_to_write == to_process)
         gst_pad_push (GST_INT2FLOAT_SRCPAD (srcpads), GST_DATA (buffers[i]));
       srcpads = srcpads->next;
@@ -362,6 +373,9 @@
       this->leftover_frames -= to_process;
       data_in += channels * to_process;
       this->frames_to_write = 0;
+
+      DEBUG ("%d frames remaining in input buffer", this->leftover_frames);
+
       if (this->leftover_frames < this->buffer_frames)
         return;
     } else {
@@ -369,6 +383,9 @@
       this->in_buffer = NULL;
       this->frames_to_write -= to_process;
       this->leftover_frames = 0;
+
+      DEBUG ("finished with input buffer, %d frames needed to fill output. returning.",
+             this->frames_to_write);
       return;
     }
     
@@ -429,15 +446,15 @@
 {
   GstElementFactory *factory;
   
-  factory = gst_element_factory_new("int2float",GST_TYPE_INT2FLOAT,
-                                   &int2float_details);
-  g_return_val_if_fail(factory != NULL, FALSE);
+  factory = gst_element_factory_new ("int2float", GST_TYPE_INT2FLOAT,
+                                     &int2float_details);
+  g_return_val_if_fail (factory != NULL, FALSE);
   gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_SECONDARY);
   
-  sinktempl = int2float_sink_factory();
+  sinktempl = int2float_sink_factory ();
   gst_element_factory_add_pad_template (factory, sinktempl);
 
-  srctempl = int2float_src_factory();
+  srctempl = int2float_src_factory ();
   gst_element_factory_add_pad_template (factory, srctempl);
   
   gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));


More information about the gstreamer-devel mailing list