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

Function add_ffmpeg_subtitle

libhb/stream.c:5774–5884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5772}
5773
5774static void add_ffmpeg_subtitle( hb_title_t *title, hb_stream_t *stream, int id )
5775{
5776 AVStream * st = stream->ffmpeg_ic->streams[id];
5777 AVCodecParameters * codecpar = st->codecpar;
5778 AVDictionaryEntry * tag_lang = av_dict_get(st->metadata, "language", NULL, 0 );
5779 iso639_lang_t * lang = lang_for_code2(tag_lang != NULL ?
5780 tag_lang->value : "und");
5781 const char * name = ffmpeg_track_name(st, lang->iso639_2);
5782
5783 hb_subtitle_t *subtitle = calloc( 1, sizeof(*subtitle) );
5784
5785 subtitle->id = id;
5786 // If we ever improve our pipeline to allow other time bases...
5787 // subtitle->timebase.num = st->time_base.num;
5788 // subtitle->timebase.den = st->time_base.den;
5789 subtitle->timebase.num = 1;
5790 subtitle->timebase.den = 90000;
5791
5792 switch ( codecpar->codec_id )
5793 {
5794 case AV_CODEC_ID_DVD_SUBTITLE:
5795 subtitle->format = PICTURESUB;
5796 subtitle->source = VOBSUB;
5797 subtitle->config.dest = RENDERSUB;
5798 subtitle->codec = WORK_DECAVSUB;
5799 subtitle->codec_param = AV_CODEC_ID_DVD_SUBTITLE;
5800 if (ffmpeg_parse_vobsub_extradata(codecpar, subtitle))
5801 {
5802 hb_log( "add_ffmpeg_subtitle: malformed extradata for VOB subtitle track; "
5803 "subtitle colors likely to be wrong" );
5804 }
5805 break;
5806 case AV_CODEC_ID_DVB_SUBTITLE:
5807 subtitle->format = PICTURESUB;
5808 subtitle->source = DVBSUB;
5809 subtitle->config.dest = RENDERSUB;
5810 subtitle->codec = WORK_DECAVSUB;
5811 subtitle->codec_param = codecpar->codec_id;
5812 break;
5813 case AV_CODEC_ID_TEXT:
5814 case AV_CODEC_ID_SUBRIP:
5815 subtitle->format = TEXTSUB;
5816 subtitle->source = UTF8SUB;
5817 subtitle->config.dest = PASSTHRUSUB;
5818 subtitle->codec = WORK_DECAVSUB;
5819 subtitle->codec_param = codecpar->codec_id;
5820 break;
5821 case AV_CODEC_ID_MOV_TEXT: // TX3G
5822 subtitle->format = TEXTSUB;
5823 subtitle->source = TX3GSUB;
5824 subtitle->config.dest = PASSTHRUSUB;
5825 subtitle->codec = WORK_DECTX3GSUB;
5826 break;
5827 case AV_CODEC_ID_ASS:
5828 subtitle->format = TEXTSUB;
5829 subtitle->source = SSASUB;
5830 subtitle->config.dest = PASSTHRUSUB;
5831 subtitle->codec = WORK_DECAVSUB;

Callers 1

ffmpeg_title_scanFunction · 0.85

Calls 8

lang_for_code2Function · 0.85
ffmpeg_track_nameFunction · 0.85
hb_logFunction · 0.85
hb_subsource_nameFunction · 0.85
hb_set_extradataFunction · 0.85
hb_list_countFunction · 0.85
hb_list_addFunction · 0.85

Tested by

no test coverage detected