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

Function hb_import_subtitle_add

libhb/common.c:6101–6142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6099}
6100
6101int hb_import_subtitle_add( const hb_job_t * job,
6102 const hb_subtitle_config_t * subtitlecfg,
6103 const char *lang_code, int source )
6104{
6105 hb_subtitle_t *subtitle;
6106 iso639_lang_t *lang = NULL;
6107
6108 subtitle = calloc( 1, sizeof( *subtitle ) );
6109 if (subtitle == NULL)
6110 {
6111 hb_error("hb_srt_add: malloc failed");
6112 return 0;
6113 }
6114
6115 subtitle->id = (hb_list_count(job->list_subtitle) << 8) |
6116 HB_SUBTITLE_IMPORT_TAG;
6117 subtitle->format = TEXTSUB;
6118 subtitle->source = source;
6119 subtitle->codec = WORK_DECSRTSUB;
6120 subtitle->codec = source == IMPORTSRT ? WORK_DECSRTSUB :
6121 WORK_DECSSASUB;
6122 subtitle->codec_param = source == IMPORTSRT ? AV_CODEC_ID_SUBRIP :
6123 AV_CODEC_ID_ASS;
6124 subtitle->timebase.num = 1;
6125 subtitle->timebase.den = 90000;
6126
6127 lang = lang_for_code2(lang_code);
6128 if (lang == NULL)
6129 {
6130 hb_log("hb_srt_add: unknown language code (%s)", lang_code);
6131 lang = lang_for_code2("und");
6132 }
6133 snprintf(subtitle->lang, sizeof(subtitle->lang), "%s (%s)",
6134 strlen(lang->native_name) ? lang->native_name : lang->eng_name,
6135 hb_subsource_name(subtitle->source));
6136 strcpy(subtitle->iso639_2, lang->iso639_2);
6137
6138 hb_subtitle_config_copy(&subtitle->config, subtitlecfg);
6139 hb_list_add(job->list_subtitle, subtitle);
6140
6141 return 1;
6142}
6143
6144int hb_srt_add( const hb_job_t * job,
6145 const hb_subtitle_config_t * subtitlecfg,

Callers 2

hb_dict_to_jobFunction · 0.85
hb_srt_addFunction · 0.85

Calls 7

hb_errorFunction · 0.85
hb_list_countFunction · 0.85
lang_for_code2Function · 0.85
hb_logFunction · 0.85
hb_subsource_nameFunction · 0.85
hb_subtitle_config_copyFunction · 0.85
hb_list_addFunction · 0.85

Tested by

no test coverage detected