MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / sanitize_subtitles

Function sanitize_subtitles

libhb/work.c:950–1099  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

948}
949
950static int sanitize_subtitles( hb_job_t * job )
951{
952 int i;
953 uint8_t one_burned = 0;
954 hb_interjob_t * interjob = hb_interjob_get(job->h);
955 hb_subtitle_t * subtitle;
956
957 if (job->indepth_scan)
958 {
959 // Subtitles are set by hb_add() during subtitle scan
960 return 0;
961 }
962
963 /* Look for the scanned subtitle in the existing subtitle list
964 * select_subtitle implies that we did a scan. */
965 if (interjob->select_subtitle != NULL)
966 {
967 /* Disable forced subtitles if we didn't find any in the scan, so that
968 * we display normal subtitles instead. */
969 if( interjob->select_subtitle->config.force &&
970 interjob->select_subtitle->forced_hits == 0 )
971 {
972 interjob->select_subtitle->config.force = 0;
973 }
974 for (i = 0; i < hb_list_count( job->list_subtitle );)
975 {
976 subtitle = hb_list_item(job->list_subtitle, i);
977 /* Remove the scanned subtitle from the list if
978 * it would result in:
979 * - an empty track (forced and no forced hits)
980 * - an identical, duplicate subtitle track:
981 * -> both (or neither) are forced
982 * -> subtitle is not forced but all its hits are forced */
983 if( ( interjob->select_subtitle->id == subtitle->id ) &&
984 ( ( subtitle->config.force &&
985 interjob->select_subtitle->forced_hits == 0 ) ||
986 ( subtitle->config.force == interjob->select_subtitle->config.force ) ||
987 ( !subtitle->config.force &&
988 interjob->select_subtitle->hits == interjob->select_subtitle->forced_hits ) ) )
989 {
990 hb_list_rem( job->list_subtitle, subtitle );
991 free( subtitle );
992 continue;
993 }
994 /* Adjust output track number, in case we removed one.
995 * Output tracks sadly still need to be in sequential order.
996 * Note: out.track starts at 1, i starts at 0, and track 1 is
997 * interjob->select_subtitle */
998 subtitle->out_track = ++i + 1;
999 }
1000
1001 /* Add the subtitle that we found on the subtitle scan pass.
1002 *
1003 * Make sure it's the first subtitle in the list so that it becomes the
1004 * first burned subtitle (explicitly or after sanitizing) - which should
1005 * ensure that it doesn't get dropped. */
1006 interjob->select_subtitle->out_track = 1;
1007 if (job->pass_id == HB_PASS_ENCODE ||

Callers 1

do_jobFunction · 0.85

Calls 12

hb_interjob_getFunction · 0.85
hb_list_countFunction · 0.85
hb_list_itemFunction · 0.85
hb_list_remFunction · 0.85
hb_list_insertFunction · 0.85
hb_subtitle_copyFunction · 0.85
hb_subtitle_can_passFunction · 0.85
hb_logFunction · 0.85
hb_subtitle_can_burnFunction · 0.85
hb_subtitle_must_burnFunction · 0.85
hb_filter_initFunction · 0.85
hb_add_filter_dictFunction · 0.85

Tested by

no test coverage detected