diff options
author | jstebbins <[email protected]> | 2012-11-12 08:22:07 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2012-11-12 08:22:07 +0000 |
commit | ab5445d6f279a3477c08f069ff3329b696cb9ac8 (patch) | |
tree | 28b1f1aa52db4f2f0d35a35950f6486955703426 /libhb/common.h | |
parent | cf1f034f914348d0f0bfcd5f8902f0a3fb519273 (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/common.h')
-rw-r--r-- | libhb/common.h | 101 |
1 files changed, 83 insertions, 18 deletions
diff --git a/libhb/common.h b/libhb/common.h index f7cc6dfef..41711e954 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -73,6 +73,7 @@ typedef struct hb_rate_s hb_rate_t; typedef struct hb_mixdown_s hb_mixdown_t; typedef struct hb_encoder_s hb_encoder_t; typedef struct hb_job_s hb_job_t; +typedef struct hb_title_set_s hb_title_set_t; typedef struct hb_title_s hb_title_t; typedef struct hb_chapter_s hb_chapter_t; typedef struct hb_audio_s hb_audio_t; @@ -81,6 +82,7 @@ typedef struct hb_subtitle_s hb_subtitle_t; typedef struct hb_subtitle_config_s hb_subtitle_config_t; typedef struct hb_attachment_s hb_attachment_t; typedef struct hb_metadata_s hb_metadata_t; +typedef struct hb_coverart_s hb_coverart_t; typedef struct hb_state_s hb_state_t; typedef union hb_esconfig_u hb_esconfig_t; typedef struct hb_work_private_s hb_work_private_t; @@ -102,11 +104,11 @@ typedef struct hb_lock_s hb_lock_t; #include "libavutil/audioconvert.h" hb_list_t * hb_list_init(); -int hb_list_count( hb_list_t * ); +int hb_list_count( const hb_list_t * ); void hb_list_add( hb_list_t *, void * ); void hb_list_insert( hb_list_t * l, int pos, void * p ); void hb_list_rem( hb_list_t *, void * ); -void * hb_list_item( hb_list_t *, int ); +void * hb_list_item( const hb_list_t *, int ); void hb_list_close( hb_list_t ** ); void hb_reduce( int *x, int *y, int num, int den ); @@ -117,12 +119,19 @@ void hb_limit_rational64( int64_t *x, int64_t *y, int64_t num, int64_t den, int6 #define HB_KEEP_HEIGHT 1 void hb_fix_aspect( hb_job_t * job, int keep ); +void hb_job_set_advanced_opts( hb_job_t *job, const char *advanced_opts ); +void hb_job_set_file( hb_job_t *job, const char *file ); + hb_audio_t *hb_audio_copy(const hb_audio_t *src); +hb_list_t *hb_audio_list_copy(const hb_list_t *src); +void hb_audio_close(hb_audio_t **audio); void hb_audio_config_init(hb_audio_config_t * audiocfg); int hb_audio_add(const hb_job_t * job, const hb_audio_config_t * audiocfg); hb_audio_config_t * hb_list_audio_config_item(hb_list_t * list, int i); hb_subtitle_t *hb_subtitle_copy(const hb_subtitle_t *src); +hb_list_t *hb_subtitle_list_copy(const hb_list_t *src); +void hb_subtitle_close( hb_subtitle_t **sub ); int hb_subtitle_add(const hb_job_t * job, const hb_subtitle_config_t * subtitlecfg, int track); int hb_srt_add(const hb_job_t * job, const hb_subtitle_config_t * subtitlecfg, const char *lang); @@ -131,6 +140,29 @@ int hb_subtitle_can_burn( int source ); int hb_subtitle_can_pass( int source, int mux ); hb_attachment_t *hb_attachment_copy(const hb_attachment_t *src); +hb_list_t *hb_attachment_list_copy(const hb_list_t *src); +void hb_attachment_close(hb_attachment_t **attachment); + +hb_metadata_t * hb_metadata_init(); +hb_metadata_t * hb_metadata_copy(const hb_metadata_t *src); +void hb_metadata_close(hb_metadata_t **metadata); +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_album_artist( hb_metadata_t *metadata, const char *album_artist ); +void hb_metadata_set_description( hb_metadata_t *metadata, const char *description ); +void hb_metadata_set_long_description( hb_metadata_t *metadata, const char *long_description ); +void hb_metadata_add_coverart( hb_metadata_t *metadata, const uint8_t *data, int size, int type ); +void hb_metadata_rem_coverart( hb_metadata_t *metadata, int ii ); + +hb_chapter_t *hb_chapter_copy(const hb_chapter_t *src); +hb_list_t *hb_chapter_list_copy(const hb_list_t *src); +void hb_chapter_close(hb_chapter_t **chapter); +void hb_chapter_set_title(hb_chapter_t *chapter, const char *title); struct hb_rate_s { @@ -205,7 +237,9 @@ int hb_mixdown_get_low_freq_channel_count(int amixdown); int hb_mixdown_get_mixdown_from_short_name(const char *short_name); const char* hb_mixdown_get_short_name_from_mixdown(int amixdown); -void hb_autopassthru_apply_settings( hb_job_t * job, hb_title_t * title ); +int hb_mixdown_get_mixdown_from_short_name( const char * short_name ); +const char * hb_mixdown_get_short_name_from_mixdown( int amixdown ); +void hb_autopassthru_apply_settings( hb_job_t * job ); void hb_autopassthru_print_settings( hb_job_t * job ); int hb_autopassthru_get_encoder( int in_codec, int copy_mask, int fallback, int muxer ); int hb_get_best_mixdown(uint32_t codec, uint64_t layout, int mixdown); @@ -222,6 +256,12 @@ void hb_get_audio_compression_limits(uint32_t codec, float *low, float *high, fl float hb_get_best_audio_compression( uint32_t codec, float compression); float hb_get_default_audio_compression( uint32_t codec ); +struct hb_title_set_s +{ + hb_list_t * list_title; + int feature; // Detected DVD feature title +}; + /****************************************************************************** * hb_job_t: settings to be filled by the UI *****************************************************************************/ @@ -333,6 +373,8 @@ struct hb_job_s #define HB_COLR_MAT_SMPTE240M 7 // 0, 3-5, 8-65535: reserved + hb_list_t * list_chapter; + /* List of audio settings. */ hb_list_t * list_audio; int acodec_copy_mask; // Auto Passthru allowed codecs @@ -341,6 +383,10 @@ struct hb_job_s /* Subtitles */ hb_list_t * list_subtitle; + hb_list_t * list_attachment; + + hb_metadata_t * metadata; + /* Muxer settings mux: output file format file: file path */ @@ -349,7 +395,7 @@ struct hb_job_s #define HB_MUX_MKV 0x200000 int mux; - const char * file; + char * file; /* Allow MP4 files > 4 gigs */ int largeFileSize; @@ -534,7 +580,7 @@ struct hb_chapter_s uint64_t duration; /* Optional chapter title */ - char title[1024]; + char *title; }; /* @@ -615,23 +661,38 @@ struct hb_subtitle_s */ struct hb_attachment_s { - enum attachtype { FONT_TTF_ATTACH } type; + enum attachtype { FONT_TTF_ATTACH, HB_ART_ATTACH } type; char * name; char * data; int size; }; +struct hb_coverart_s +{ + uint8_t *data; + uint32_t size; + enum arttype { + HB_ART_UNDEFINED, + HB_ART_BMP, + HB_ART_GIF, + HB_ART_PNG, + HB_ART_JPEG + } type; +}; + struct hb_metadata_s { - char name[255]; - char artist[255]; - char composer[255]; - char release_date[255]; - char comment[1024]; - char album[255]; - char genre[255]; - uint32_t coverart_size; - uint8_t *coverart; + char *name; + char *artist; // Actors + char *composer; + char *release_date; + char *comment; + char *album; // DVD + char *album_artist; // Director + char *genre; + char *description; + char *long_description; + hb_list_t * list_coverart; }; struct hb_title_s @@ -682,7 +743,7 @@ struct hb_title_s int video_codec_param; /* codec specific config */ char *video_codec_name; int video_bitrate; - const char *container_name; + char *container_name; int data_rate; hb_metadata_t *metadata; @@ -692,12 +753,15 @@ struct hb_title_s hb_list_t * list_subtitle; hb_list_t * list_attachment; - /* Job template for this title */ +#define HB_TITLE_JOBS +#if defined(HB_TITLE_JOBS) hb_job_t * job; +#endif uint32_t flags; // set if video stream doesn't have IDR frames #define HBTF_NO_IDR (1 << 0) +#define HBTF_SCAN_COMPLETE (1 << 0) }; @@ -941,7 +1005,8 @@ enum hb_filter_object_t * hb_filter_init( int filter_id ); hb_filter_object_t * hb_filter_copy( hb_filter_object_t * filter ); -void hb_filter_close( hb_filter_object_t ** ); +hb_list_t *hb_filter_list_copy(const hb_list_t *src); +void hb_filter_close( hb_filter_object_t ** ); typedef void hb_error_handler_t( const char *errmsg ); |