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

Function add_subtitle

libhb/dvd.c:168–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168static void add_subtitle( hb_list_t * list_subtitle, int position,
169 iso639_lang_t * lang, int lang_extension,
170 uint8_t * palette, int style )
171{
172 hb_subtitle_t * subtitle;
173 int ii, count;
174
175 count = hb_list_count(list_subtitle);
176 for (ii = 0; ii < count; ii++)
177 {
178 subtitle = hb_list_item(list_subtitle, ii);
179 if (((subtitle->id >> 8) & 0x1f) == position)
180 {
181 // The subtitle is already in the list
182 return;
183 }
184 }
185
186 subtitle = calloc(sizeof(hb_subtitle_t), 1);
187 subtitle->track = count;
188 subtitle->id = ((0x20 + position) << 8) | 0xbd;
189 snprintf(subtitle->lang, sizeof( subtitle->lang ), "%s",
190 strlen(lang->native_name) ? lang->native_name : lang->eng_name);
191 snprintf(subtitle->iso639_2, sizeof( subtitle->iso639_2 ), "%s",
192 lang->iso639_2);
193 subtitle->format = PICTURESUB;
194 subtitle->source = VOBSUB;
195 subtitle->config.dest = RENDERSUB;
196 subtitle->stream_type = 0xbd;
197 subtitle->substream_type = 0x20 + position;
198 subtitle->codec = WORK_DECAVSUB;
199 subtitle->codec_param = AV_CODEC_ID_DVD_SUBTITLE;
200 subtitle->timebase.num = 1;
201 subtitle->timebase.den = 90000;
202
203 memcpy(subtitle->palette, palette, 16 * sizeof(uint32_t));
204 subtitle->palette_set = 1;
205
206 const char * name = NULL;
207 switch (lang_extension)
208 {
209 case 1:
210 subtitle->attributes = HB_SUBTITLE_ATTR_NORMAL;
211 break;
212 case 2:
213 subtitle->attributes = HB_SUBTITLE_ATTR_LARGE;
214 strcat(subtitle->lang, " Large Type");
215 name = "Large Type";
216 break;
217 case 3:
218 subtitle->attributes = HB_SUBTITLE_ATTR_CHILDREN;
219 strcat(subtitle->lang, " Children");
220 name = "Children";
221 break;
222 case 5:
223 subtitle->attributes = HB_SUBTITLE_ATTR_CC;
224 strcat(subtitle->lang, " Closed Caption");
225 name = "Closed Caption";

Callers 1

hb_dvdread_title_scanFunction · 0.70

Calls 5

hb_list_countFunction · 0.85
hb_list_itemFunction · 0.85
hb_subsource_nameFunction · 0.85
hb_logFunction · 0.85
hb_list_addFunction · 0.85

Tested by

no test coverage detected