summaryrefslogtreecommitdiffstats
path: root/libhb/reader.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2012-11-12 08:22:07 +0000
committerjstebbins <[email protected]>2012-11-12 08:22:07 +0000
commitab5445d6f279a3477c08f069ff3329b696cb9ac8 (patch)
tree28b1f1aa52db4f2f0d35a35950f6486955703426 /libhb/reader.c
parentcf1f034f914348d0f0bfcd5f8902f0a3fb519273 (diff)
Improve management of titles and jobs
Cleans up several several unavoidable memory leaks caused by old api. Clearly separates titles from jobs. Titles are set during scan and never modified now. Since titles are immutable, this lead to API some changes. For example, We were setting chapter names in the title from the front ends. Now these get set in the job. These new APIs allow us to start moving away from our use of title->job. Eventually, I would like to eliminate title->job completely, but the mac ui is too tightly tied to using this field to allow removing it at this time. So there is temporarily a convenience function used only by the mac ui that allows it to continue using title->job and also use the new APIs. New APIs: typedef struct hb_title_set_s hb_title_set_t; struct hb_title_set_s { hb_list_t * list_title; int feature; // Detected DVD feature title }; hb_title_set_t * hb_get_title_set( hb_handle_t * ); This is just something I added to clean up how "feature title" info is passed. hb_job_t * hb_job_init( hb_title_t * title ); Initializes a new job with default settings from the title. hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index ); Same as hb_job_init(). For use by win Interop lib. void hb_job_reset( hb_job_t * job ); Convenience function for the MacUi. Clears audio, subtitle, and filter lists. The macui still uses title->job because it is so intricately tied to it. So I created this convenience function that it can call after adding a job. void hb_job_close( hb_job_t ** job ); Releases the job an all resources it contains. void hb_job_set_advanced_opts( hb_job_t *job, const char *advanced_opts ); Makes a copy of "advanced_opts" and stores in job. Freed by hb_job_close(). void hb_job_set_file( hb_job_t *job, const char *file ); Makes a copy of "file" and stores in job. Freed by hb_job_close(). void hb_chapter_set_title(hb_chapter_t *chapter, const char *title); Makes a copy of "title" and stores in chapter. Freed by hb_chapter_close(). Recommended usage (cli and lingui are updated to do this): job = hb_job_init( title ); // set job settings ... hb_add(h, job); hb_job_close( &job ); I have also added new APIs for managing metadata. These are used to add metadata to a job. void hb_metadata_set_name( hb_metadata_t *metadata, const char *name ); void hb_metadata_set_artist( hb_metadata_t *metadata, const char *artist ); void hb_metadata_set_composer( hb_metadata_t *metadata, const char *composer ); void hb_metadata_set_release_date( hb_metadata_t *metadata, const char *release_date ); void hb_metadata_set_comment( hb_metadata_t *metadata, const char *comment ); void hb_metadata_set_genre( hb_metadata_t *metadata, const char *genre ); void hb_metadata_set_album( hb_metadata_t *metadata, const char *album ); void hb_metadata_set_coverart( hb_metadata_t *metadata, const uint8_t *coverart, int size ); Example: job = hb_job_init( &job ); // set job settings ... hb_metadata_set_artist( job->metadata, "Danny Elfman" ); hb_add(h, job); hb_job_close( &job ); Some APIs have changed in order to avoid using title incorrectly and use the new hb_title_set_t. -void hb_autopassthru_apply_settings( hb_job_t * job, hb_title_t * title ); +void hb_autopassthru_apply_settings( hb_job_t * job ); -void hb_get_preview( hb_handle_t *, hb_title_t *, int, uint8_t * ); +void hb_get_preview( hb_handle_t *, hb_job_t *, int, uint8_t * ); hb_thread_t * hb_scan_init( hb_handle_t *, volatile int * die, const char * path, int title_index, - hb_list_t * list_title, int preview_count, + hb_title_set_t * title_set, int preview_count, int store_previews, uint64_t min_duration ); These APIs have been removed. Win Interop will need some changes. I think what I've provided will be suffecient, but let me know if it's not. -void hb_get_preview_by_index( hb_handle_t *, int, int, uint8_t * ); -void hb_set_anamorphic_size_by_index( hb_handle_t *, int, - int *output_width, int *output_height, - int *output_par_width, int *output_par_height ); git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5058 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/reader.c')
-rw-r--r--libhb/reader.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/libhb/reader.c b/libhb/reader.c
index 8148e6590..d5c937422 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -386,12 +386,12 @@ void ReadLoop( void * _w )
* a media chapter that got merged, we'll stop ripping too early.
*/
int start = r->job->chapter_start;
- hb_chapter_t *chap = hb_list_item( r->title->list_chapter, chapter_end - 1 );
+ hb_chapter_t *chap = hb_list_item( r->job->list_chapter, chapter_end - 1 );
chapter_end = chap->index;
if (start > 1)
{
- chap = hb_list_item( r->title->list_chapter, start - 1 );
+ chap = hb_list_item( r->job->list_chapter, start - 1 );
start = chap->index;
}
/* end chapter mapping XXX */
@@ -453,12 +453,12 @@ void ReadLoop( void * _w )
* end chapter so that we end at the right time.
*/
int start = r->job->chapter_start;
- hb_chapter_t *chap = hb_list_item( r->title->list_chapter, chapter_end - 1 );
+ hb_chapter_t *chap = hb_list_item( r->job->list_chapter, chapter_end - 1 );
chapter_end = chap->index;
if (start > 1)
{
- chap = hb_list_item( r->title->list_chapter, start - 1 );
+ chap = hb_list_item( r->job->list_chapter, start - 1 );
start = chap->index;
}
@@ -670,14 +670,14 @@ void ReadLoop( void * _w )
push_buf( r, r->job->fifo_mpeg2, hb_buffer_init(0) );
hb_audio_t *audio;
- for( n = 0; (audio = hb_list_item( r->job->title->list_audio, n)); ++n )
+ for( n = 0; (audio = hb_list_item( r->job->list_audio, n)); ++n )
{
if ( audio->priv.fifo_in )
push_buf( r, audio->priv.fifo_in, hb_buffer_init(0) );
}
hb_subtitle_t *subtitle;
- for( n = 0; (subtitle = hb_list_item( r->job->title->list_subtitle, n)); ++n )
+ for( n = 0; (subtitle = hb_list_item( r->job->list_subtitle, n)); ++n )
{
if ( subtitle->fifo_in && subtitle->source == VOBSUB)
push_buf( r, subtitle->fifo_in, hb_buffer_init(0) );
@@ -780,11 +780,11 @@ static hb_fifo_t ** GetFifoForId( hb_work_private_t * r, int id )
}
}
- count = hb_list_count( title->list_subtitle );
+ count = hb_list_count( job->list_subtitle );
count = count > 99 ? 99 : count;
for( i = n = 0; i < count; i++ )
{
- subtitle = hb_list_item( title->list_subtitle, i );
+ subtitle = hb_list_item( job->list_subtitle, i );
if (id == subtitle->id)
{
/* pass the subtitles to be processed */
@@ -798,9 +798,9 @@ static hb_fifo_t ** GetFifoForId( hb_work_private_t * r, int id )
if( !job->indepth_scan )
{
- for( i = n = 0; i < hb_list_count( title->list_audio ); i++ )
+ for( i = n = 0; i < hb_list_count( job->list_audio ); i++ )
{
- audio = hb_list_item( title->list_audio, i );
+ audio = hb_list_item( job->list_audio, i );
if( id == audio->id )
{
r->fifos[n++] = audio->priv.fifo_in;