diff options
author | jstebbins <[email protected]> | 2015-05-11 15:45:25 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-05-11 15:45:25 +0000 |
commit | 7d0f528cb5a168bba6306458f904e21e156901c9 (patch) | |
tree | 68e2314cdd38e6abadf2c92116e681fbaf2edc71 /test/test.c | |
parent | 6e59c5d576fc695f59bf661e752c7f004ac6133b (diff) |
cli: fix missing subtitle "Default" flag when --all-subtitles is used
Also fix case that can cause all subtitles to be added twice.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7169 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'test/test.c')
-rw-r--r-- | test/test.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/test.c b/test/test.c index a32970e23..33624dafb 100644 --- a/test/test.c +++ b/test/test.c @@ -4077,6 +4077,42 @@ PrepareJob(hb_handle_t *h, hb_title_t *title, hb_dict_t *preset_dict) } } } + else + { + if (subdefault > 0) + { + // "Default" flag can not be applied till after subtitles have + // been selected. Apply it here if subtitle selection was + // made by the preset. + hb_value_t *sub_dict = hb_dict_get(job_dict, "Subtitle"); + hb_value_t *sub_list = hb_dict_get(sub_dict, "SubtitleList"); + if (hb_value_array_len(sub_list) >= subdefault) + { + hb_value_t *sub = hb_value_array_get(sub_list, subdefault - 1); + hb_dict_set(sub, "Default", hb_value_bool(1)); + } + } + + if (subforce != NULL) + { + // "Forced" flag is not set during preset initialization except + // for "foreign audio" subtitles. Set additional request forced + // subtitle tracks here. + hb_value_t *sub_dict = hb_dict_get(job_dict, "Subtitle"); + hb_value_t *sub_list = hb_dict_get(sub_dict, "SubtitleList"); + + int ii; + for (ii = 0; subforce[ii] != NULL; ii++ ) + { + int idx = strtol(subforce[ii], NULL, 0) - 1; + if (idx >= 0 && hb_value_array_len(sub_list) > idx) + { + hb_value_t *sub = hb_value_array_get(sub_list, idx); + hb_dict_set(sub, "Forced", hb_value_bool(1)); + } + } + } + } if (srtfile != NULL) { |