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

Function textsub_work

libhb/rendersub.c:913–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

911}
912
913static int textsub_work(hb_filter_object_t *filter,
914 hb_buffer_t **buf_in,
915 hb_buffer_t **buf_out)
916{
917 hb_filter_private_t *pv = filter->private_data;
918 hb_buffer_t *in = *buf_in;
919 hb_buffer_t *sub;
920
921 if (!pv->script_initialized)
922 {
923 ssa_work_init(pv, filter->subtitle->extradata);
924 pv->script_initialized = 1;
925 }
926
927 if (in->s.flags & HB_BUF_FLAG_EOF)
928 {
929 *buf_in = NULL;
930 *buf_out = in;
931 return HB_FILTER_DONE;
932 }
933
934 int in_start_ms = in->s.start / 90;
935
936 // Get any pending subtitles and add them to the active
937 // subtitle list
938 while ((sub = hb_fifo_get(filter->subtitle->fifo_out)))
939 {
940 if (sub->s.flags & HB_BUF_FLAG_EOF)
941 {
942 hb_buffer_close(&sub);
943 if (pv->current_sub != NULL)
944 {
945 // Make us some duration for final sub
946 pv->current_sub->s.stop = pv->current_sub->s.start +
947 90000LL * 10;
948 process_sub(pv, pv->current_sub);
949 hb_buffer_close(&pv->current_sub);
950 }
951 break;
952 }
953
954 // libass expects times in ms. So to make the math easy,
955 // convert to ms immediately.
956 sub->s.start /= 90;
957 if (sub->s.stop != AV_NOPTS_VALUE)
958 {
959 sub->s.stop /= 90;
960 }
961
962 // Subtitle formats such as CC can have stop times
963 // that are not known until an "erase display" command
964 // is encountered in the stream. For these formats
965 // current_sub is the currently active subtitle for which
966 // we do not yet know the stop time. We do not currently
967 // support overlapping subtitles of this type.
968 if (pv->current_sub != NULL)
969 {
970 // Next sub start time tells us the stop time of the

Callers 1

hb_rendersub_workFunction · 0.85

Calls 5

ssa_work_initFunction · 0.85
hb_fifo_getFunction · 0.85
hb_buffer_closeFunction · 0.85
process_subFunction · 0.85
render_ssa_subsFunction · 0.85

Tested by

no test coverage detected