diff options
author | jstebbins <[email protected]> | 2012-03-27 20:11:26 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2012-03-27 20:11:26 +0000 |
commit | 45b8f81a2e184e2b7deaf47afc49483766191a27 (patch) | |
tree | 30ed0892995cb4ad3255909f69269c453000800a /libhb/common.c | |
parent | 7eb7737023be00fa0dc9be75a4984b80c0e5ce57 (diff) |
Rework filter pipeline
This patch enhances the filter objects. The 2 key improvements are:
1. A filter can change the image dimensions as frames pass through it.
2. A filter can output more than one frame.
In addition, I have:
Moved cropping & scalling into a filter object
Added 90 degree rotation to the rotate filter
Moved subtitle burn-in rendering to a filter object.
Moved VFR/CFR handling into a framerate shaping filter object.
Removed render.c since all it's responsibilities got moved to filters.
Improves VOBSUB and SSA subtitle handling. Allows subtitle animations.
SSA karaoke support.
My apologies in advance if anything breaks ;)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4546 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/common.c')
-rw-r--r-- | libhb/common.c | 98 |
1 files changed, 79 insertions, 19 deletions
diff --git a/libhb/common.c b/libhb/common.c index adbd5591e..d1d539020 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -1059,15 +1059,14 @@ void hb_list_rem( hb_list_t * l, void * p ) { if( l->items[i] == p ) { + /* Shift all items after it sizeof( void * ) bytes earlier */ + memmove( &l->items[i], &l->items[i+1], + ( l->items_count - i - 1 ) * sizeof( void * ) ); + + (l->items_count)--; break; } } - - /* Shift all items after it sizeof( void * ) bytes earlier */ - memmove( &l->items[i], &l->items[i+1], - ( l->items_count - i - 1 ) * sizeof( void * ) ); - - (l->items_count)--; } /********************************************************************** @@ -1102,7 +1101,7 @@ int hb_list_bytes( hb_list_t * l ) for( i = 0; i < hb_list_count( l ); i++ ) { buf = hb_list_item( l, i ); - ret += buf->size - buf->cur; + ret += buf->size - buf->offset; } return ret; @@ -1124,8 +1123,8 @@ void hb_list_seebytes( hb_list_t * l, uint8_t * dst, int size ) for( i = 0, copied = 0; copied < size; i++ ) { buf = hb_list_item( l, i ); - copying = MIN( buf->size - buf->cur, size - copied ); - memcpy( &dst[copied], &buf->data[buf->cur], copying ); + copying = MIN( buf->size - buf->offset, size - copied ); + memcpy( &dst[copied], &buf->data[buf->offset], copying ); copied += copying; } } @@ -1157,18 +1156,18 @@ void hb_list_getbytes( hb_list_t * l, uint8_t * dst, int size, for( copied = 0, has_pts = 0; copied < size; ) { buf = hb_list_item( l, 0 ); - copying = MIN( buf->size - buf->cur, size - copied ); - memcpy( &dst[copied], &buf->data[buf->cur], copying ); + copying = MIN( buf->size - buf->offset, size - copied ); + memcpy( &dst[copied], &buf->data[buf->offset], copying ); if( !has_pts ) { - *pts = buf->start; - *pos = buf->cur; + *pts = buf->s.start; + *pos = buf->offset; has_pts = 1; } - buf->cur += copying; - if( buf->cur >= buf->size ) + buf->offset += copying; + if( buf->offset >= buf->size ) { hb_list_rem( l, buf ); hb_buffer_close( &buf ); @@ -1501,6 +1500,71 @@ void hb_title_close( hb_title_t ** _t ) *_t = NULL; } +hb_filter_object_t * hb_filter_copy( hb_filter_object_t * filter ) +{ + if( filter == NULL ) + return NULL; + + hb_filter_object_t * filter_copy = malloc( sizeof( hb_filter_object_t ) ); + memcpy( filter_copy, filter, sizeof( hb_filter_object_t ) ); + if( filter->settings ) + filter_copy->settings = strdup( filter->settings ); + return filter_copy; +} + +/** + * Gets a filter object with the given type + * @param filter_id The type of filter to get. + * @returns The requested filter object. + */ +hb_filter_object_t * hb_filter_init( int filter_id ) +{ + hb_filter_object_t * filter; + switch( filter_id ) + { + case HB_FILTER_DETELECINE: + filter = &hb_filter_detelecine; + break; + + case HB_FILTER_DECOMB: + filter = &hb_filter_decomb; + break; + + case HB_FILTER_DEINTERLACE: + filter = &hb_filter_deinterlace; + break; + + case HB_FILTER_VFR: + filter = &hb_filter_vfr; + break; + + case HB_FILTER_DEBLOCK: + filter = &hb_filter_deblock; + break; + + case HB_FILTER_DENOISE: + filter = &hb_filter_denoise; + break; + + case HB_FILTER_RENDER_SUB: + filter = &hb_filter_render_sub; + break; + + case HB_FILTER_CROP_SCALE: + filter = &hb_filter_crop_scale; + break; + + case HB_FILTER_ROTATE: + filter = &hb_filter_rotate; + break; + + default: + filter = NULL; + break; + } + return hb_filter_copy( filter ); +} + /********************************************************************** * hb_filter_close ********************************************************************** @@ -1510,10 +1574,6 @@ void hb_filter_close( hb_filter_object_t ** _f ) { hb_filter_object_t * f = *_f; - f->close( f->private_data ); - - if( f->name ) - free( f->name ); if( f->settings ) free( f->settings ); |