| 862 | } |
| 863 | |
| 864 | static void analyze_subtitle_scan( hb_job_t * job ) |
| 865 | { |
| 866 | hb_subtitle_t *subtitle; |
| 867 | int subtitle_highest = 0; |
| 868 | int subtitle_lowest = 0; |
| 869 | int subtitle_lowest_id = 0; |
| 870 | int subtitle_forced_id = 0; |
| 871 | int subtitle_forced_hits = 0; |
| 872 | int subtitle_hit = 0; |
| 873 | int i; |
| 874 | |
| 875 | // Before closing the title print out our subtitle stats if we need to |
| 876 | // find the highest and lowest. |
| 877 | for (i = 0; i < hb_list_count(job->list_subtitle); i++) |
| 878 | { |
| 879 | subtitle = hb_list_item(job->list_subtitle, i); |
| 880 | |
| 881 | hb_log("Subtitle track %d (id 0x%x) '%s': %d hits (%d forced)", |
| 882 | subtitle->track, subtitle->id, subtitle->lang, |
| 883 | subtitle->hits, subtitle->forced_hits); |
| 884 | |
| 885 | if (subtitle->hits == 0) |
| 886 | continue; |
| 887 | |
| 888 | if (subtitle_highest < subtitle->hits) |
| 889 | { |
| 890 | subtitle_highest = subtitle->hits; |
| 891 | } |
| 892 | |
| 893 | if (subtitle_lowest == 0 || |
| 894 | subtitle_lowest > subtitle->hits) |
| 895 | { |
| 896 | subtitle_lowest = subtitle->hits; |
| 897 | subtitle_lowest_id = subtitle->id; |
| 898 | } |
| 899 | |
| 900 | // pick the track with fewest forced hits |
| 901 | if (subtitle->forced_hits > 0 && |
| 902 | (subtitle_forced_hits == 0 || |
| 903 | subtitle_forced_hits > subtitle->forced_hits)) |
| 904 | { |
| 905 | subtitle_forced_id = subtitle->id; |
| 906 | subtitle_forced_hits = subtitle->forced_hits; |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | if (subtitle_forced_id && job->select_subtitle_config.force) |
| 911 | { |
| 912 | // If there is a subtitle stream with forced subtitles and forced-only |
| 913 | // is set, then select it in preference to the lowest. |
| 914 | subtitle_hit = subtitle_forced_id; |
| 915 | hb_log("Found a subtitle candidate with id 0x%x (contains forced subs)", |
| 916 | subtitle_hit ); |
| 917 | } |
| 918 | else if (subtitle_lowest > 0 && subtitle_lowest < subtitle_highest * 0.1) |
| 919 | { |
| 920 | // OK we have more than one, and the lowest is lower, |
| 921 | // but how much lower to qualify for turning it on by |
no test coverage detected