From 578d7c72a11425cb8a8f83a38a56fb26a9e3bfbd Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 31 Mar 2006 23:12:03 +0000 Subject: [PATCH] Better PRS progress bar, added a function to do glyph separation optimization (which doesn't work yet) Originally committed to SVN as r270. --- core/subtitle_format_prs.cpp | 38 ++++++++++++++++++++++++++++++------ core/subtitle_format_prs.h | 1 + 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/core/subtitle_format_prs.cpp b/core/subtitle_format_prs.cpp index 4fe22192e..683f2bcc2 100644 --- a/core/subtitle_format_prs.cpp +++ b/core/subtitle_format_prs.cpp @@ -106,26 +106,32 @@ void PRSSubtitleFormat::WriteFile(wxString filename,wxString encoding) { // Get range std::vector frames = GetFrameRanges(); + int totalFrames = frames.size(); + int toDraw = 0; + for (int i=0;iShow(); - progress->SetProgress(0,totalFrames); + progress->SetProgress(0,toDraw); // Render all frames that were detected to contain subtitles + int drawn = 0; for (int framen=0;framenSetProgress(framen,totalFrames); + progress->SetProgress(drawn,toDraw); progress->SetText(wxString::Format(_T("Writing PRS file. Line: %i/%i"),framen,totalFrames)); + drawn++; // Read the frame image PVideoFrame frame1 = clip1->GetFrame(framen,env1); @@ -139,8 +145,21 @@ void PRSSubtitleFormat::WriteFile(wxString filename,wxString encoding) { wxImage bmp = CalculateAlpha(frame1->GetReadPtr(),frame2->GetReadPtr(),frame1->GetRowSize(),frame1->GetHeight(),frame1->GetPitch(),&x,&y,&maxalpha); if (!bmp.Ok()) continue; - // Add image to file - InsertFrame(file,framen,frames,bmp,x,y,maxalpha); + // Get the list of rectangles + std::vector rects; + GetSubPictureRectangles(bmp,rects); + + // Add each sub-image to file + int nrects = rects.size(); + for (int i=0;i & } +/////////////////////////////////// +// Get rectangles of useful glyphs +void PRSSubtitleFormat::GetSubPictureRectangles(wxImage image,std::vector &rects) { + rects.push_back(wxRect(0,0,image.GetWidth(),image.GetHeight())); +} + + //////////////////// // Get frame ranges std::vector PRSSubtitleFormat::GetFrameRanges() { diff --git a/core/subtitle_format_prs.h b/core/subtitle_format_prs.h index b80a52517..377d95be4 100644 --- a/core/subtitle_format_prs.h +++ b/core/subtitle_format_prs.h @@ -61,6 +61,7 @@ private: void InsertFrame(PRSFile &file,int &framen,std::vector &frames,wxImage &bmp,int x,int y,int maxalpha); wxImage SubImageWithAlpha(wxImage src,const wxRect &area); wxImage CalculateAlpha(const unsigned char* frame1, const unsigned char* frame2, int w, int h, int pitch, int *x=NULL, int *y=NULL, int *maxalpha=NULL); + void GetSubPictureRectangles(wxImage image,std::vector &rects); std::vector GetFrameRanges(); public: