| 948 | } |
| 949 | |
| 950 | static 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 || |
no test coverage detected