diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cd91bae..e3f3d3d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,7 @@ jobs: run: | export VS160COMNTOOLS="C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/Tools/" bash ./build_vsfilter.sh -platform "${{ matrix.vsfplat }}" -compiler VS2019 + cp License.txt bin/ - name: Prune incompatible files if: steps.config.outputs.delete != '' @@ -89,3 +90,4 @@ jobs: name: xy-${{ steps.config.outputs.name }}_nightly_${{ matrix.namesuf }} path: | bin/lib*/*/Release + bin/License.txt diff --git a/src/filters/transform/vsfilter/VSFilter.rc b/src/filters/transform/vsfilter/VSFilter.rc index c6f8351d..af43b928 100644 --- a/src/filters/transform/vsfilter/VSFilter.rc +++ b/src/filters/transform/vsfilter/VSFilter.rc @@ -374,7 +374,7 @@ BEGIN RTEXT "Cache LV2",IDC_LABEL_OVERLAY_NO_BLUR,20,56,57,8 PUSHBUTTON "caches info",IDC_CACHES_INFO_BTN,147,21,50,14 COMBOBOX IDC_COMBO_LAYOUT_SIZE_OPT,27,106,74,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Renderer Layout Options",IDC_STATIC,7,97,233,27 + GROUPBOX "Renderer Layout Default",IDC_STATIC,7,97,233,27 LTEXT "H:",IDC_STATIC,112,107,9,8 LTEXT "V:",IDC_STATIC,157,107,8,8 EDITTEXT IDC_EDIT_LAYOUT_SIZE_X,122,107,32,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER diff --git a/src/filters/transform/vsfilter/csriapi.cpp b/src/filters/transform/vsfilter/csriapi.cpp index 83a24a94..b967ac6a 100644 --- a/src/filters/transform/vsfilter/csriapi.cpp +++ b/src/filters/transform/vsfilter/csriapi.cpp @@ -107,10 +107,9 @@ CSRIAPI void csri_close(csri_inst *inst) CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt) { - if (!inst) return -1; - - if (!fmt->width || !fmt->height) + if (!inst || !fmt->width || !fmt->height) { return -1; + } // Check if pixel format is supported switch (fmt->pixfmt) { @@ -159,51 +158,22 @@ CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame, double time) // No extensions supported -CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname) -{ - return 0; -} +CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname) { return 0; } // Get info for renderer static struct csri_info csri_vsfilter_info = { #ifdef _DEBUG - "vsfilter_textsub_debug", // name - "2.39", // version (assumed version number, svn revision, patchlevel) + "pf-xy-vsfilter_textsub_debug", // name #else - "vsfilter_textsub", // name - "2.39", // version (assumed version number, svn revision, patchlevel) + "pf-xy-vsfilter_textsub", // name #endif - // 2.38-0611 is base svn 611 - // 2.38-0611-1 is with clipfix and fax/fay patch - // 2.38-0611-2 adds CSRI - // 2.38-0611-3 fixes a bug in CSRI and adds fontcrash-fix and float-pos - // 2.38-0611-4 fixes be1-dots and ugly-fade bugs and adds xbord/ybord/xshad/yshad/blur tags and extends be - // 2.39 merges with guliverkli2 fork - "VSFilter/TextSub (guliverkli2)", // longname + "3.2", // version + "xy-VSFilter/TextSub", // longname "Gabest", // author - "Copyright (c) 2003-2008 by Gabest and others" // copyright + "Copyright (c) 2003-2014 by Gabest et al." // copyright }; -CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend) -{ - return &csri_vsfilter_info; -} -// Only one supported, obviously -CSRIAPI csri_rend *csri_renderer_byname(const char *name, const char *specific) -{ - if (strcmp(name, csri_vsfilter_info.name)) - return 0; - if (specific && strcmp(specific, csri_vsfilter_info.specific)) - return 0; - return &csri_vsfilter; -} -// Still just one -CSRIAPI csri_rend *csri_renderer_default() -{ - return &csri_vsfilter; -} -// And no further -CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev) -{ - return 0; -} +CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend) { return &csri_vsfilter_info; } +CSRIAPI csri_rend *csri_renderer_byname(const char *name, const char *specific) { return &csri_vsfilter; } +CSRIAPI csri_rend *csri_renderer_default() { return &csri_vsfilter; } +CSRIAPI csri_rend *csri_renderer_next(csri_rend *prev) { return 0; } diff --git a/src/subtitles/HdmvSub.cpp b/src/subtitles/HdmvSub.cpp index 87dd406a..fefeb4f7 100644 --- a/src/subtitles/HdmvSub.cpp +++ b/src/subtitles/HdmvSub.cpp @@ -208,6 +208,10 @@ HRESULT CHdmvSub::ParseSample(BYTE* pData, int lSampleLen, REFERENCE_TIME rtStar int CHdmvSub::ParsePresentationSegment(REFERENCE_TIME rt, CGolombBuffer* pGBuffer) { + if (pGBuffer->RemainingSize() < 11) { + return 0; + } + m_pCurrentPresentationSegment = DEBUG_NEW HDMV_PRESENTATION_SEGMENT(); m_pCurrentPresentationSegment->rtStart = rt; @@ -222,6 +226,10 @@ int CHdmvSub::ParsePresentationSegment(REFERENCE_TIME rt, CGolombBuffer* pGBuffe TRACE_HDMVSUB( (_T("CHdmvSub::ParsePresentationSegment Size = %d, state = %#x, nObjectNumber = %d\n"), pGBuffer->GetSize(), m_pCurrentPresentationSegment->composition_descriptor.bState, m_pCurrentPresentationSegment->objectCount) ); + if (pGBuffer->RemainingSize() < (m_pCurrentPresentationSegment->objectCount * 8)) { + return 0; + } + for (int i = 0; i < m_pCurrentPresentationSegment->objectCount; i++) { CompositionObject* pCompositionObject = DEBUG_NEW CompositionObject(); ParseCompositionObject(pGBuffer, pCompositionObject); @@ -287,7 +295,11 @@ void CHdmvSub::ParsePalette(CGolombBuffer* pGBuffer, unsigned short nSize) // # void CHdmvSub::ParseObject(CGolombBuffer* pGBuffer, unsigned short nUnitSize) // #498 { short object_id = pGBuffer->ReadShort(); - ASSERT(object_id < _countof(m_compositionObjects)); + + if (object_id >= _countof(m_compositionObjects)) { + TRACE_HDMVSUB((_T("CHdmvSub::ParseObject() : FAILED, object_id - %d"), object_id)); + return; + } CompositionObject& pObject = m_compositionObjects[object_id]; diff --git a/src/subtitles/RTS.cpp b/src/subtitles/RTS.cpp index 9fae771f..e1a958ad 100644 --- a/src/subtitles/RTS.cpp +++ b/src/subtitles/RTS.cpp @@ -2415,6 +2415,7 @@ bool CRenderedTextSubtitle::ParseSSATag( CSubtitle* sub, const AssTagList& assTa case CMD_fe: { int n = wcstol(p, NULL, 10); + if (n < 0) n = DEFAULT_CHARSET; style.charSet = !p.IsEmpty() ? n : org.charSet; diff --git a/src/subtitles/STS.cpp b/src/subtitles/STS.cpp index a1a4c9cb..b8650cb5 100644 --- a/src/subtitles/STS.cpp +++ b/src/subtitles/STS.cpp @@ -1978,6 +1978,7 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C { CString StyleName; int alpha; + int encoding; CRect tmp_rect; StyleName = GetStr(buff); @@ -2002,9 +2003,11 @@ if(sver >= 4) style->borderStyle = GetInt(buff); if(sver >= 6) tmp_rect.bottom = GetInt(buff); style->marginRect = tmp_rect; if(sver <= 4) alpha = GetInt(buff); - style->charSet = GetInt(buff); + encoding = GetInt(buff); if(sver >= 6) style->relativeTo = GetInt(buff); + // Map unsupported extension to the most permissive charSet + style->charSet = encoding < 0 ? DEFAULT_CHARSET : encoding; if(sver <= 4) style->colors[2] = style->colors[3]; // style->colors[2] is used for drawing the outline if(sver <= 4) alpha = max(min(alpha, 0xff), 0); if(sver <= 4) {for(size_t i = 0; i < 3; i++) style->alpha[i] = alpha; style->alpha[3] = 0x80;} diff --git a/src/subtitles/hdmv_subtitle_provider.cpp b/src/subtitles/hdmv_subtitle_provider.cpp index ba0f44ea..9ca9f6b9 100644 --- a/src/subtitles/hdmv_subtitle_provider.cpp +++ b/src/subtitles/hdmv_subtitle_provider.cpp @@ -472,22 +472,25 @@ DWORD SupFileSubtitleProvider::ThreadProc() while ((len = f.Read(buff, sizeof(buff))) > 0) { sub.Write(buff, len); } + f.Close(); sub.SeekToBegin(); WORD sync = 0; USHORT size = 0; REFERENCE_TIME rtStart = 0; + REFERENCE_TIME rtStop = 0; CAutoLock cAutoLock(&m_csCritSec); while (sub.GetPosition() < (sub.GetLength() - 10)) { sync = (WORD)ReadByte(&sub, 2); if (sync == 'PG') { - rtStart = UINT64(ReadByte(&sub, 4) * (1000 / 9)); - sub.Seek(4 + 1, CFile::current); // rtStop + Segment type + rtStart = UINT64(ReadByte(&sub, 4) * 1000 / 9); + rtStop = UINT64(ReadByte(&sub, 4) * 1000 / 9); + sub.Seek(1, CFile::current); // Segment type size = ReadByte(&sub, 2) + 3; // Segment size sub.Seek(-3, CFile::current); sub.Read(buff, size); - m_pSub->ParseSample(buff, size, rtStart, 0); + m_pSub->ParseSample(buff, size, rtStart, rtStop); } else { break; }