summaryrefslogtreecommitdiffstats
path: root/libhb/common.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-04-25 15:57:07 +0000
committerjstebbins <[email protected]>2011-04-25 15:57:07 +0000
commite06c1946ddf693572d8f3044daa423462b6bdadc (patch)
treefda10c68e279e9d1193f8339bf657c825a3a6bba /libhb/common.c
parentc9fd57320b601bafaec8178680d689d3e5b75f77 (diff)
Make order of audio tracks found in PS streams more predictable
Since PS streams don't have a directory of streams, we find them by scanning the PES headers for stream types. We were adding them in the order found which is pretty random. This sorts audios by substream id. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3958 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/common.c')
-rw-r--r--libhb/common.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 90bd23cb6..9c06d783b 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -748,6 +748,40 @@ void hb_list_add( hb_list_t * l, void * p )
}
/**********************************************************************
+ * hb_list_insert
+ **********************************************************************
+ * Adds an item at the specifiec position in the list, making it bigger
+ * if necessary.
+ * Can safely be called with a NULL pointer to add, it will be ignored.
+ *********************************************************************/
+void hb_list_insert( hb_list_t * l, int pos, void * p )
+{
+ if( !p )
+ {
+ return;
+ }
+
+ if( l->items_count == l->items_alloc )
+ {
+ /* We need a bigger boat */
+ l->items_alloc += HB_LIST_DEFAULT_SIZE;
+ l->items = realloc( l->items,
+ l->items_alloc * sizeof( void * ) );
+ }
+
+ if ( l->items_count != pos )
+ {
+ /* Shift all items after it sizeof( void * ) bytes earlier */
+ memmove( &l->items[pos+1], &l->items[pos],
+ ( l->items_count - pos ) * sizeof( void * ) );
+ }
+
+
+ l->items[pos] = p;
+ (l->items_count)++;
+}
+
+/**********************************************************************
* hb_list_rem
**********************************************************************
* Remove an item from the list. Bad things will happen if called