aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Rector <rmrector@gmail.com>2023-08-19 16:35:32 -0600
committerRyan Rector <rmrector@gmail.com>2023-09-13 16:59:02 -0600
commit0586131fb17c44346504b45f7e3176d7cf83510a (patch)
tree6617e8cf69afbd500680b753fbfcc8860c24a0a6
parente6ba91067dde60d5564fbd5cecd29841e958e2c7 (diff)
remove old chapter thumb generator
-rw-r--r--xbmc/cores/VideoPlayer/DVDFileInfo.cpp183
-rw-r--r--xbmc/cores/VideoPlayer/DVDFileInfo.h3
-rw-r--r--xbmc/video/VideoThumbLoader.cpp50
-rw-r--r--xbmc/video/VideoThumbLoader.h36
-rw-r--r--xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp54
-rw-r--r--xbmc/video/dialogs/GUIDialogVideoBookmarks.h11
6 files changed, 2 insertions, 335 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
index cdd5736970..450d2cd482 100644
--- a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
+++ b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
@@ -87,189 +87,6 @@ int DegreeToOrientation(int degrees)
}
}
-bool CDVDFileInfo::ExtractThumb(const CFileItem& fileItem, CTextureDetails& details, int64_t pos)
-{
- const std::string redactPath = CURL::GetRedacted(fileItem.GetPath());
- auto start = std::chrono::steady_clock::now();
-
- CFileItem item(fileItem);
- item.SetMimeTypeForInternetFile();
- auto pInputStream = CDVDFactoryInputStream::CreateInputStream(NULL, item);
- if (!pInputStream)
- {
- CLog::Log(LOGERROR, "InputStream: Error creating stream for {}", redactPath);
- return false;
- }
-
- if (!pInputStream->Open())
- {
- CLog::Log(LOGERROR, "InputStream: Error opening, {}", redactPath);
- return false;
- }
-
- CDVDDemux *pDemuxer = NULL;
-
- try
- {
- pDemuxer = CDVDFactoryDemuxer::CreateDemuxer(pInputStream, true);
- if(!pDemuxer)
- {
- CLog::Log(LOGERROR, "{} - Error creating demuxer", __FUNCTION__);
- return false;
- }
- }
- catch(...)
- {
- CLog::Log(LOGERROR, "{} - Exception thrown when opening demuxer", __FUNCTION__);
- if (pDemuxer)
- delete pDemuxer;
-
- return false;
- }
-
- int nVideoStream = -1;
- int64_t demuxerId = -1;
- for (CDemuxStream* pStream : pDemuxer->GetStreams())
- {
- if (pStream)
- {
- // ignore if it's a picture attachment (e.g. jpeg artwork)
- if (pStream->type == STREAM_VIDEO && !(pStream->flags & AV_DISPOSITION_ATTACHED_PIC))
- {
- nVideoStream = pStream->uniqueId;
- demuxerId = pStream->demuxerId;
- }
- else
- pDemuxer->EnableStream(pStream->demuxerId, pStream->uniqueId, false);
- }
- }
-
- bool bOk = false;
- int packetsTried = 0;
-
- if (nVideoStream != -1)
- {
- std::unique_ptr<CProcessInfo> pProcessInfo(CProcessInfo::CreateInstance());
- std::vector<AVPixelFormat> pixFmts;
- pixFmts.push_back(AV_PIX_FMT_YUV420P);
- pProcessInfo->SetPixFormats(pixFmts);
-
- CDVDStreamInfo hint(*pDemuxer->GetStream(demuxerId, nVideoStream), true);
- hint.codecOptions = CODEC_FORCE_SOFTWARE;
-
- std::unique_ptr<CDVDVideoCodec> pVideoCodec =
- CDVDFactoryCodec::CreateVideoCodec(hint, *pProcessInfo);
-
- if (pVideoCodec)
- {
- int nTotalLen = pDemuxer->GetStreamLength();
- int64_t nSeekTo = (pos == -1) ? nTotalLen / 3 : pos;
-
- CLog::Log(LOGDEBUG, "{} - seeking to pos {}ms (total: {}ms) in {}", __FUNCTION__, nSeekTo,
- nTotalLen, redactPath);
-
- if (pDemuxer->SeekTime(static_cast<double>(nSeekTo), true))
- {
- CDVDVideoCodec::VCReturn iDecoderState = CDVDVideoCodec::VC_NONE;
- VideoPicture picture = {};
-
- // num streams * 160 frames, should get a valid frame, if not abort.
- int abort_index = pDemuxer->GetNrOfStreams() * 160;
- do
- {
- DemuxPacket* pPacket = pDemuxer->Read();
- packetsTried++;
-
- if (!pPacket)
- break;
-
- if (pPacket->iStreamId != nVideoStream)
- {
- CDVDDemuxUtils::FreeDemuxPacket(pPacket);
- continue;
- }
-
- pVideoCodec->AddData(*pPacket);
- CDVDDemuxUtils::FreeDemuxPacket(pPacket);
-
- iDecoderState = CDVDVideoCodec::VC_NONE;
- while (iDecoderState == CDVDVideoCodec::VC_NONE)
- {
- iDecoderState = pVideoCodec->GetPicture(&picture);
- }
-
- if (iDecoderState == CDVDVideoCodec::VC_PICTURE)
- {
- if(!(picture.iFlags & DVP_FLAG_DROPPED))
- break;
- }
-
- } while (abort_index--);
-
- if (iDecoderState == CDVDVideoCodec::VC_PICTURE && !(picture.iFlags & DVP_FLAG_DROPPED))
- {
- {
- unsigned int nWidth = std::min(picture.iDisplayWidth, CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_imageRes);
- double aspect = (double)picture.iDisplayWidth / (double)picture.iDisplayHeight;
- if(hint.forced_aspect && hint.aspect != 0)
- aspect = hint.aspect;
- unsigned int nHeight = (unsigned int)((double)nWidth / aspect);
-
- // We pass the buffers to sws_scale uses 16 aligned widths when using intrinsics
- int sizeNeeded = FFALIGN(nWidth, 16) * nHeight * 4;
- uint8_t *pOutBuf = static_cast<uint8_t*>(av_malloc(sizeNeeded));
- struct SwsContext *context = sws_getContext(picture.iWidth, picture.iHeight,
- AV_PIX_FMT_YUV420P, nWidth, nHeight, AV_PIX_FMT_BGRA, SWS_FAST_BILINEAR, NULL, NULL, NULL);
-
- if (context)
- {
- uint8_t *planes[YuvImage::MAX_PLANES];
- int stride[YuvImage::MAX_PLANES];
- picture.videoBuffer->GetPlanes(planes);
- picture.videoBuffer->GetStrides(stride);
- uint8_t *src[4]= { planes[0], planes[1], planes[2], 0 };
- int srcStride[] = { stride[0], stride[1], stride[2], 0 };
- uint8_t *dst[] = { pOutBuf, 0, 0, 0 };
- int dstStride[] = { (int)nWidth*4, 0, 0, 0 };
- int orientation = DegreeToOrientation(hint.orientation);
- sws_scale(context, src, srcStride, 0, picture.iHeight, dst, dstStride);
- sws_freeContext(context);
-
- details.width = nWidth;
- details.height = nHeight;
- CPicture::CacheTexture(pOutBuf, nWidth, nHeight, nWidth * 4, orientation, nWidth, nHeight, CTextureCache::GetCachedPath(details.file));
- bOk = true;
- }
- av_free(pOutBuf);
- }
- }
- else
- {
- CLog::Log(LOGDEBUG, "{} - decode failed in {} after {} packets.", __FUNCTION__,
- redactPath, packetsTried);
- }
- }
- }
- }
-
- if (pDemuxer)
- delete pDemuxer;
-
- if(!bOk)
- {
- XFILE::CFile file;
- if(file.OpenForWrite(CTextureCache::GetCachedPath(details.file)))
- file.Close();
- }
-
- auto end = std::chrono::steady_clock::now();
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
- CLog::Log(LOGDEBUG, "{} - measured {} ms to extract thumb from file <{}> in {} packets. ",
- __FUNCTION__, duration.count(), redactPath, packetsTried);
-
- return bOk;
-}
-
std::unique_ptr<CTexture> CDVDFileInfo::ExtractThumbToTexture(const CFileItem& fileItem,
int chapterNumber)
{
diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.h b/xbmc/cores/VideoPlayer/DVDFileInfo.h
index 0c306e50e8..0129d6ac4c 100644
--- a/xbmc/cores/VideoPlayer/DVDFileInfo.h
+++ b/xbmc/cores/VideoPlayer/DVDFileInfo.h
@@ -23,9 +23,6 @@ class CTextureDetails;
class CDVDFileInfo
{
public:
- // Extract a thumbnail image from the media referenced by fileItem
- static bool ExtractThumb(const CFileItem& fileItem, CTextureDetails& details, int64_t pos);
-
static std::unique_ptr<CTexture> ExtractThumbToTexture(const CFileItem& fileItem,
int chapterNumber = 0);
diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp
index 7bce9f300e..91d1e7a436 100644
--- a/xbmc/video/VideoThumbLoader.cpp
+++ b/xbmc/video/VideoThumbLoader.cpp
@@ -37,56 +37,6 @@
using namespace XFILE;
using namespace VIDEO;
-CChapterThumbExtractor::CChapterThumbExtractor(const CFileItem& item,
- const std::string& listpath,
- const std::string& target,
- int64_t pos)
- : m_target(target), m_listpath(listpath), m_item(item)
-{
- m_pos = pos;
-
- if (item.IsVideoDb() && item.HasVideoInfoTag())
- m_item.SetPath(item.GetVideoInfoTag()->m_strFileNameAndPath);
-
- if (m_item.IsStack())
- m_item.SetPath(CStackDirectory::GetFirstStackedFile(m_item.GetPath()));
-}
-
-CChapterThumbExtractor::~CChapterThumbExtractor() = default;
-
-bool CChapterThumbExtractor::operator==(const CJob* job) const
-{
- if (strcmp(job->GetType(),GetType()) == 0)
- {
- const CChapterThumbExtractor* jobExtract = dynamic_cast<const CChapterThumbExtractor*>(job);
- if (jobExtract && jobExtract->m_listpath == m_listpath
- && jobExtract->m_target == m_target)
- return true;
- }
- return false;
-}
-
-bool CChapterThumbExtractor::DoWork()
-{
- if (!CDVDFileInfo::CanExtract(m_item))
- return false;
-
- bool result=false;
- CLog::LogF(LOGDEBUG, "trying to extract thumb from video file {}",
- CURL::GetRedacted(m_item.GetPath()));
- // construct the thumb cache file
- CTextureDetails details;
- details.file = CTextureCache::GetCacheFile(m_target) + ".jpg";
- result = CDVDFileInfo::ExtractThumb(m_item, details, m_pos);
- if (!result)
- return false;
-
- CServiceBroker::GetTextureCache()->AddCachedTexture(m_target, details);
- m_item.SetArt("thumb", m_target);
-
- return true;
-}
-
CVideoThumbLoader::CVideoThumbLoader() : CThumbLoader()
{
m_videoDatabase = new CVideoDatabase();
diff --git a/xbmc/video/VideoThumbLoader.h b/xbmc/video/VideoThumbLoader.h
index 9cf0a9482f..f5505fe860 100644
--- a/xbmc/video/VideoThumbLoader.h
+++ b/xbmc/video/VideoThumbLoader.h
@@ -10,7 +10,6 @@
#include "FileItem.h"
#include "ThumbLoader.h"
-#include "utils/JobManager.h"
#include <map>
#include <vector>
@@ -22,41 +21,6 @@ class EmbeddedArt;
using ArtMap = std::map<std::string, std::string>;
using ArtCache = std::map<std::pair<MediaType, int>, ArtMap>;
-/*!
- \ingroup thumbs,jobs
- \brief Thumb extractor job class
-
- Used by the "chapter browser" GUI window to generate chapter thumbs.
-
- \sa CVideoThumbLoader and CJob
- */
-class CChapterThumbExtractor : public CJob
-{
-public:
- CChapterThumbExtractor(const CFileItem& item,
- const std::string& listpath,
- const std::string& strTarget = "",
- int64_t pos = -1);
- ~CChapterThumbExtractor() override;
-
- /*!
- \brief Work function that extracts thumb.
- */
- bool DoWork() override;
-
- const char* GetType() const override
- {
- return kJobTypeMediaFlags;
- }
-
- bool operator==(const CJob* job) const override;
-
- std::string m_target; ///< thumbpath
- std::string m_listpath; ///< path used in fileitem list
- CFileItem m_item;
- int64_t m_pos; ///< position to extract thumb from
-};
-
class CVideoThumbLoader : public CThumbLoader
{
public:
diff --git a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
index 86f545fa12..425344219e 100644
--- a/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
+++ b/xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
@@ -35,7 +35,6 @@
#include "utils/Variant.h"
#include "utils/log.h"
#include "video/VideoDatabase.h"
-#include "video/VideoThumbLoader.h"
#include "view/ViewState.h"
#include <mutex>
@@ -51,12 +50,10 @@
#define CONTROL_THUMBS 11
CGUIDialogVideoBookmarks::CGUIDialogVideoBookmarks()
- : CGUIDialog(WINDOW_DIALOG_VIDEO_BOOKMARKS, "VideoOSDBookmarks.xml"),
- CJobQueue(false, 1, CJob::PRIORITY_NORMAL)
+ : CGUIDialog(WINDOW_DIALOG_VIDEO_BOOKMARKS, "VideoOSDBookmarks.xml")
{
m_vecItems = new CFileItemList;
m_loadType = LOAD_EVERY_TIME;
- m_jobsStarted = 0;
}
CGUIDialogVideoBookmarks::~CGUIDialogVideoBookmarks()
@@ -137,9 +134,6 @@ bool CGUIDialogVideoBookmarks::OnMessage(CGUIMessage& message)
case 0:
OnRefreshList();
break;
- case 1:
- UpdateItem(message.GetParam2());
- break;
default:
break;
}
@@ -202,30 +196,6 @@ void CGUIDialogVideoBookmarks::Delete(int item)
Update();
}
-void CGUIDialogVideoBookmarks::UpdateItem(unsigned int chapterIdx)
-{
- std::unique_lock<CCriticalSection> lock(m_refreshSection);
-
- int itemPos = 0;
- for (const auto& item : *m_vecItems)
- {
- if (chapterIdx == item->GetProperty("chapter").asInteger())
- break;
- itemPos++;
- }
-
- if (itemPos < m_vecItems->Size())
- {
- std::string time = StringUtils::Format("chapter://{}/{}", m_filePath, chapterIdx);
- std::string cachefile = CServiceBroker::GetTextureCache()->GetCachedPath(
- CServiceBroker::GetTextureCache()->GetCacheFile(time) + ".jpg");
- if (CFileUtils::Exists(cachefile))
- {
- (*m_vecItems)[itemPos]->SetArt("thumb", cachefile);
- }
- }
-}
-
void CGUIDialogVideoBookmarks::OnRefreshList()
{
m_bookmarks.clear();
@@ -471,16 +441,11 @@ void CGUIDialogVideoBookmarks::OnWindowLoaded()
m_viewControl.Reset();
m_viewControl.SetParentWindow(GetID());
m_viewControl.AddView(GetControl(CONTROL_THUMBS));
- m_jobsStarted = 0;
- m_mapJobsChapter.clear();
m_vecItems->Clear();
}
void CGUIDialogVideoBookmarks::OnWindowUnload()
{
- //stop running thumb extraction jobs
- CancelJobs();
- m_mapJobsChapter.clear();
m_vecItems->Clear();
CGUIDialog::OnWindowUnload();
m_viewControl.Reset();
@@ -564,20 +529,3 @@ bool CGUIDialogVideoBookmarks::OnAddEpisodeBookmark()
}
return bReturn;
}
-
-void CGUIDialogVideoBookmarks::OnJobComplete(unsigned int jobID,
- bool success, CJob* job)
-{
- if (success && IsActive())
- {
- MAPJOBSCHAPS::iterator iter = m_mapJobsChapter.find(job);
- if (iter != m_mapJobsChapter.end())
- {
- unsigned int chapterIdx = (*iter).second;
- CGUIMessage m(GUI_MSG_REFRESH_LIST, GetID(), 0, 1, chapterIdx);
- CServiceBroker::GetAppMessenger()->SendGUIMessage(m);
- m_mapJobsChapter.erase(iter);
- }
- }
- CJobQueue::OnJobComplete(jobID, success, job);
-}
diff --git a/xbmc/video/dialogs/GUIDialogVideoBookmarks.h b/xbmc/video/dialogs/GUIDialogVideoBookmarks.h
index 801afcdd37..09fa5e3e98 100644
--- a/xbmc/video/dialogs/GUIDialogVideoBookmarks.h
+++ b/xbmc/video/dialogs/GUIDialogVideoBookmarks.h
@@ -9,16 +9,13 @@
#pragma once
#include "guilib/GUIDialog.h"
-#include "utils/JobManager.h"
#include "video/VideoDatabase.h"
#include "view/GUIViewControl.h"
class CFileItemList;
-class CGUIDialogVideoBookmarks : public CGUIDialog, public CJobQueue
+class CGUIDialogVideoBookmarks : public CGUIDialog
{
- typedef std::map<CJob*, unsigned int> MAPJOBSCHAPS;
-
public:
CGUIDialogVideoBookmarks(void);
~CGUIDialogVideoBookmarks(void) override;
@@ -60,17 +57,11 @@ protected:
void OnPopupMenu(int item);
CGUIControl *GetFirstFocusableControl(int id) override;
- void OnJobComplete(unsigned int jobID, bool success, CJob* job) override;
-
CFileItemList* m_vecItems;
CGUIViewControl m_viewControl;
VECBOOKMARKS m_bookmarks;
private:
- void UpdateItem(unsigned int chapterIdx);
-
- int m_jobsStarted;
std::string m_filePath;
CCriticalSection m_refreshSection;
- MAPJOBSCHAPS m_mapJobsChapter;
};