summaryrefslogtreecommitdiffstats
path: root/libhb/fifo.c
diff options
context:
space:
mode:
authordavidfstr <[email protected]>2011-02-25 01:08:33 +0000
committerdavidfstr <[email protected]>2011-02-25 01:08:33 +0000
commit565e8b19462d5d3183ff922bc062f52262b49b49 (patch)
tree646a4e3bfa22ca28722409bd4cd4d6e0bbf96757 /libhb/fifo.c
parent26e7f602344af0d873950778a582bffb2cb26741 (diff)
Add temporally overlapping subtitle support.
* New subtitle sync algorithm added to sync work-object ("simultaneous"). Classic algorithm preserved but disabled. * Render work-object now supports queueing a /list/ of subtitles. * FIFOs have been extended to support pushing/popping buffer-lists as single elements. * Added SUBSYNC_VERBOSE_TIMING flag to debug timing issues related to subtitle display. Observable behaviors changed in the new subtitle sync algorithm: * Temporally overlapping subtitles are no longer trimmed to be non-overlapping. * Subtitles less than two seconds long are no longer artificially extended. Sorry, Indochine fans. * Subtitles that stop before they start will never be displayed. The old algorithm will display such subtitles if they begin in the future (relative to the current video frame being processed). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3804 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/fifo.c')
-rw-r--r--libhb/fifo.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/libhb/fifo.c b/libhb/fifo.c
index 755a6d164..cd348c863 100644
--- a/libhb/fifo.c
+++ b/libhb/fifo.c
@@ -190,6 +190,7 @@ void hb_buffer_realloc( hb_buffer_t * b, int size )
}
}
+// Frees the specified buffer list.
void hb_buffer_close( hb_buffer_t ** _b )
{
hb_buffer_t * b = *_b;
@@ -294,6 +295,8 @@ float hb_fifo_percent_full( hb_fifo_t * f )
return ret;
}
+// Pulls the first packet out of this FIFO, blocking until such a packet is available.
+// Returns NULL if this FIFO has been closed or flushed.
hb_buffer_t * hb_fifo_get_wait( hb_fifo_t * f )
{
hb_buffer_t * b;
@@ -323,6 +326,7 @@ hb_buffer_t * hb_fifo_get_wait( hb_fifo_t * f )
return b;
}
+// Pulls a packet out of this FIFO, or returns NULL if no packet is available.
hb_buffer_t * hb_fifo_get( hb_fifo_t * f )
{
hb_buffer_t * b;
@@ -368,6 +372,8 @@ hb_buffer_t * hb_fifo_see_wait( hb_fifo_t * f )
return b;
}
+// Returns the first packet in the specified FIFO.
+// If the FIFO is empty, returns NULL.
hb_buffer_t * hb_fifo_see( hb_fifo_t * f )
{
hb_buffer_t * b;
@@ -400,6 +406,8 @@ hb_buffer_t * hb_fifo_see2( hb_fifo_t * f )
return b;
}
+// Waits until the specified FIFO is no longer full or until FIFO_TIMEOUT milliseconds have elapsed.
+// Returns whether the FIFO is non-full upon return.
int hb_fifo_full_wait( hb_fifo_t * f )
{
int result;
@@ -415,6 +423,8 @@ int hb_fifo_full_wait( hb_fifo_t * f )
return result;
}
+// Pushes the specified buffer onto the specified FIFO,
+// blocking until the FIFO has space available.
void hb_fifo_push_wait( hb_fifo_t * f, hb_buffer_t * b )
{
if( !b )
@@ -451,6 +461,7 @@ void hb_fifo_push_wait( hb_fifo_t * f, hb_buffer_t * b )
hb_unlock( f->lock );
}
+// Appends the specified packet list to the end of the specified FIFO.
void hb_fifo_push( hb_fifo_t * f, hb_buffer_t * b )
{
if( !b )
@@ -482,6 +493,7 @@ void hb_fifo_push( hb_fifo_t * f, hb_buffer_t * b )
hb_unlock( f->lock );
}
+// Prepends the specified packet list to the start of the specified FIFO.
void hb_fifo_push_head( hb_fifo_t * f, hb_buffer_t * b )
{
hb_buffer_t * tmp;
@@ -519,6 +531,29 @@ void hb_fifo_push_head( hb_fifo_t * f, hb_buffer_t * b )
hb_unlock( f->lock );
}
+// Pushes a list of packets onto the specified FIFO as a single element.
+void hb_fifo_push_list_element( hb_fifo_t *fifo, hb_buffer_t *buffer_list )
+{
+ hb_buffer_t *container = hb_buffer_init( 0 );
+ // XXX: Using an arbitrary hb_buffer_t pointer (other than 'next')
+ // to carry the list inside a single "container" buffer
+ container->next_subpicture = buffer_list;
+
+ hb_fifo_push( fifo, container );
+}
+
+// Removes a list of packets from the specified FIFO that were stored as a single element.
+hb_buffer_t *hb_fifo_get_list_element( hb_fifo_t *fifo )
+{
+ hb_buffer_t *container = hb_fifo_get( fifo );
+ // XXX: Using an arbitrary hb_buffer_t pointer (other than 'next')
+ // to carry the list inside a single "container" buffer
+ hb_buffer_t *buffer_list = container->next_subpicture;
+ hb_buffer_close( &container );
+
+ return buffer_list;
+}
+
void hb_fifo_close( hb_fifo_t ** _f )
{
hb_fifo_t * f = *_f;