Skip to content

Commit

Permalink
VideoPlayer: drop PreInit, move supported pix formats to PprocessInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and popcornmix committed Jun 13, 2017
1 parent 9c8d23f commit 3622826
Show file tree
Hide file tree
Showing 25 changed files with 32 additions and 139 deletions.
1 change: 0 additions & 1 deletion xbmc/cores/RetroPlayer/PixelConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#pragma once

#include "IPixelConverter.h"
#include "cores/VideoPlayer/VideoRenderers/RenderFormats.h"

#include <stdint.h>

Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/RetroPlayer/RetroPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ void CRetroPlayer::UpdateClockSync(bool enabled)
m_processInfo->SetRenderClockSync(enabled);
}

void CRetroPlayer::UpdateRenderInfo(CRenderInfo &info)
{
m_processInfo->UpdateRenderInfo(info);
}
//void CRetroPlayer::UpdateRenderInfo(CRenderInfo &info)
//{
// m_processInfo->UpdateRenderInfo(info);
//}

void CRetroPlayer::PrintGameInfo(const CFileItem &file) const
{
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/RetroPlayer/RetroPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace RETRO
virtual void VideoParamsChange() override { }
virtual void GetDebugInfo(std::string &audio, std::string &video, std::string &general) override { }
virtual void UpdateClockSync(bool enabled) override;
virtual void UpdateRenderInfo(CRenderInfo &info) override;
//virtual void UpdateRenderInfo(CRenderInfo &info) override;
virtual void UpdateRenderBuffers(int queued, int discard, int free) override {}

private:
Expand Down
1 change: 0 additions & 1 deletion xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

#include "Video/DVDVideoCodec.h"
#include "cores/VideoPlayer/VideoRenderers/RenderFormats.h"

class CDVDCodecUtils
{
Expand Down
3 changes: 0 additions & 3 deletions xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <string>
#include <vector>
#include "cores/VideoPlayer/VideoRenderers/RenderFormats.h"

// special options that can be passed to a codec
class CDVDCodecOption
Expand All @@ -37,6 +36,4 @@ class CDVDCodecOptions
{
public:
std::vector<CDVDCodecOption> m_keys;
std::vector<AVPixelFormat> m_formats;
const void *m_opaque_pointer;
};
17 changes: 1 addition & 16 deletions xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,13 @@

CCriticalSection videoCodecSection;

CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CProcessInfo &processInfo, const CRenderInfo &info)
CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CProcessInfo &processInfo)
{
CSingleLock lock(videoCodecSection);

std::unique_ptr<CDVDVideoCodec> pCodec;
CDVDCodecOptions options;

if (info.formats.empty())
options.m_formats.push_back(AV_PIX_FMT_YUV420P);
else
options.m_formats = info.formats;

options.m_opaque_pointer = info.opaque_pointer;

// platform specifig video decoders
if (!(hint.codecOptions & CODEC_FORCE_SOFTWARE))
{
Expand All @@ -79,8 +72,6 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CProces
return nullptr;
}

std::string value = StringUtils::Format("%d", info.max_buffer_size);
options.m_keys.push_back(CDVDCodecOption("surfaces", value));
pCodec.reset(new CDVDVideoCodecFFmpeg(processInfo));
if (pCodec->Open(hint, options))
{
Expand All @@ -90,12 +81,6 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CProces
return nullptr;
}

CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CProcessInfo &processInfo)
{
CRenderInfo renderInfo;
return CreateVideoCodec(hint, processInfo, renderInfo);
}

//------------------------------------------------------------------------------
// Audio
//------------------------------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*
*/

#include "cores/VideoPlayer/VideoRenderers/RenderFormats.h"
#include "cores/VideoPlayer/VideoRenderers/BaseRenderer.h"
#include "cores/VideoPlayer/Process/ProcessInfo.h"
#include "cores/AudioEngine/Utils/AEStreamInfo.h"

Expand All @@ -40,10 +38,6 @@ class CDVDFactoryCodec
friend class CDVDVideoCodecFFmpeg;

public:
static CDVDVideoCodec* CreateVideoCodec(CDVDStreamInfo &hint,
CProcessInfo &processInfo,
const CRenderInfo &info);

static CDVDVideoCodec* CreateVideoCodec(CDVDStreamInfo &hint,
CProcessInfo &processInfo);

Expand Down
3 changes: 1 addition & 2 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

#include "system.h"
#include "cores/VideoPlayer/VideoRenderers/RenderFormats.h"
#include "cores/VideoPlayer/Process/ProcessInfo.h"
#include "cores/VideoPlayer/Process/VideoBuffer.h"
#include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h"
Expand Down Expand Up @@ -257,7 +256,7 @@ class IHardwareDecoder : public IDVDResourceCounted<IHardwareDecoder>
public:
IHardwareDecoder() = default;
virtual ~IHardwareDecoder() = default;
virtual bool Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum AVPixelFormat, unsigned int surfaces) = 0;
virtual bool Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum AVPixelFormat) = 0;
virtual CDVDVideoCodec::VCReturn Decode(AVCodecContext* avctx, AVFrame* frame) = 0;
virtual bool GetPicture(AVCodecContext* avctx, VideoPicture* picture) = 0;
virtual CDVDVideoCodec::VCReturn Check(AVCodecContext* avctx) = 0;
Expand Down
21 changes: 4 additions & 17 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "settings/MediaSettings.h"
#include "utils/log.h"
#include "cores/VideoPlayer/VideoRenderers/RenderManager.h"
#include "cores/VideoPlayer/VideoRenderers/RenderFormats.h"
#include "cores/VideoPlayer/VideoRenderers/RenderInfo.h"
#include "utils/StringUtils.h"
#include <memory>

Expand Down Expand Up @@ -293,7 +293,7 @@ enum AVPixelFormat CDVDVideoCodecFFmpeg::GetFormat(struct AVCodecContext * avctx

if (pDecoder)
{
if (pDecoder->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
if (pDecoder->Open(avctx, ctx->m_pCodecContext, *cur))
{
ctx->m_processInfo.SetVideoPixelFormat(pixFmtName ? pixFmtName : "");
ctx->SetHardware(pDecoder);
Expand Down Expand Up @@ -325,9 +325,6 @@ CDVDVideoCodecFFmpeg::CDVDVideoCodecFFmpeg(CProcessInfo &processInfo)

m_iPictureWidth = 0;
m_iPictureHeight = 0;

m_uSurfacesCount = 0;

m_iScreenWidth = 0;
m_iScreenHeight = 0;
m_iOrientation = 0;
Expand Down Expand Up @@ -361,14 +358,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
m_iOrientation = hints.orientation;

m_formats.clear();
for(std::vector<AVPixelFormat>::iterator it = options.m_formats.begin(); it != options.m_formats.end(); ++it)
{
if (*it != AV_PIX_FMT_NONE)
m_formats.push_back(*it);

if(*it == AV_PIX_FMT_YUV420P)
m_formats.push_back(AV_PIX_FMT_YUVJ420P);
}
m_formats = m_processInfo.GetRenderFormats();
m_formats.push_back(AV_PIX_FMT_NONE); /* always add none to get a terminated list in ffmpeg world */

pCodec = avcodec_find_decoder(hints.codec);
Expand Down Expand Up @@ -444,10 +434,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
// set any special options
for(std::vector<CDVDCodecOption>::iterator it = options.m_keys.begin(); it != options.m_keys.end(); ++it)
{
if (it->m_name == "surfaces")
m_uSurfacesCount = atoi(it->m_value.c_str());
else
av_opt_set(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0);
av_opt_set(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0);
}

// If non-zero, the decoded audio and video frames returned from avcodec_decode_video2() are reference-counted and are valid indefinitely.
Expand Down
2 changes: 0 additions & 2 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec, public ICallbackHWAccel
int m_iScreenHeight;
int m_iOrientation;// orientation of the video in degrees counter clockwise

unsigned int m_uSurfacesCount;

std::string m_name;
int m_decoderState;
IHardwareDecoder *m_pHardware;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void CDecoder::Close()
}
}

bool CDecoder::Open(AVCodecContext *avctx, AVCodecContext* mainctx, enum AVPixelFormat fmt, unsigned int surfaces)
bool CDecoder::Open(AVCodecContext *avctx, AVCodecContext* mainctx, enum AVPixelFormat fmt)
{
if (!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVTB))
return false;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CDecoder: public IHardwareDecoder
CDecoder(CProcessInfo& processInfo);
~CDecoder();
virtual bool Open(AVCodecContext* avctx, AVCodecContext* mainctx,
const enum AVPixelFormat, unsigned int surfaces = 0) override;
const enum AVPixelFormat) override;
virtual CDVDVideoCodec::VCReturn Decode(AVCodecContext* avctx, AVFrame* frame) override;
virtual bool GetPicture(AVCodecContext* avctx, VideoPicture* picture) override;
virtual CDVDVideoCodec::VCReturn Check(AVCodecContext* avctx) override;
Expand Down
8 changes: 7 additions & 1 deletion xbmc/cores/VideoPlayer/Process/ProcessInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ void CProcessInfo::ResetVideoCodecInfo()
m_deintMethods.clear();
m_deintMethods.push_back(EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE);
m_deintMethodDefault = EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE;
m_renderInfo.Reset();
m_stateSeeking = false;

CServiceBroker::GetDataCacheCore().SetVideoDecoderName(m_videoDecoderName, m_videoIsHWDecoder);
Expand Down Expand Up @@ -375,6 +374,13 @@ void CProcessInfo::GetRenderBuffers(int &queued, int &discard, int &free)
free = m_renderBufFree;
}

std::vector<AVPixelFormat> CProcessInfo::GetRenderFormats()
{
std::vector<AVPixelFormat> formats;
formats.push_back(AV_PIX_FMT_YUV420P);
return formats;
}

// player states
void CProcessInfo::SetStateSeeking(bool active)
{
Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/VideoPlayer/Process/ProcessInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "VideoBuffer.h"
#include "cores/IPlayer.h"
#include "cores/VideoPlayer/VideoRenderers/RenderFormats.h"
#include "cores/VideoPlayer/VideoRenderers/RenderInfo.h"
#include "threads/CriticalSection.h"
#include <atomic>
#include <list>
Expand Down Expand Up @@ -74,6 +74,7 @@ class CProcessInfo
void UpdateRenderInfo(CRenderInfo &info);
void UpdateRenderBuffers(int queued, int discard, int free);
void GetRenderBuffers(int &queued, int &discard, int &free);
virtual std::vector<AVPixelFormat> GetRenderFormats();

// player states
void SetStateSeeking(bool active);
Expand Down
11 changes: 3 additions & 8 deletions xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ double CVideoPlayerVideo::GetOutputDelay()

bool CVideoPlayerVideo::OpenStream(CDVDStreamInfo hint)
{
CRenderInfo info;
info = m_renderManager.GetRenderInfo();

if (hint.flags & AV_DISPOSITION_ATTACHED_PIC)
return false;
if (hint.extrasize == 0)
Expand All @@ -146,7 +143,7 @@ bool CVideoPlayerVideo::OpenStream(CDVDStreamInfo hint)
{
hint.codecOptions |= CODEC_ALLOW_FALLBACK;
}
CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo, info);
CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo);
if (!codec)
{
CLog::Log(LOGINFO, "CVideoPlayerVideo::OpenStream - could not open video codec");
Expand All @@ -157,7 +154,7 @@ bool CVideoPlayerVideo::OpenStream(CDVDStreamInfo hint)
{
m_processInfo.ResetVideoCodecInfo();
hint.codecOptions |= CODEC_ALLOW_FALLBACK;
CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo, info);
CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo);
if (!codec)
{
CLog::Log(LOGERROR, "CVideoPlayerVideo::OpenStream - could not open video codec");
Expand Down Expand Up @@ -223,10 +220,8 @@ void CVideoPlayerVideo::OpenStream(CDVDStreamInfo &hint, CDVDVideoCodec* codec)
if (!codec)
{
CLog::Log(LOGNOTICE, "Creating video codec with codec id: %i", hint.codec);
CRenderInfo info;
info = m_renderManager.GetRenderInfo();
hint.codecOptions |= CODEC_ALLOW_FALLBACK;
codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo, info);
codec = CDVDFactoryCodec::CreateVideoCodec(hint, m_processInfo);
if (!codec)
{
CLog::Log(LOGERROR, "CVideoPlayerVideo::OpenStream - could not open video codec");
Expand Down
3 changes: 1 addition & 2 deletions xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <utility>
#include <vector>

#include "RenderInfo.h"
#include "guilib/Resolution.h"
#include "guilib/Geometry.h"
#include "RenderFormats.h"
#include "VideoShaders/ShaderFormats.h"
#include "cores/IPlayer.h"
#include "cores/VideoPlayer/Process/VideoBuffer.h"
Expand Down Expand Up @@ -69,7 +69,6 @@ class CBaseRenderer
virtual void AddVideoPicture(const VideoPicture &picture, int index) = 0;
virtual bool IsPictureHW(const VideoPicture &picture) { return false; };
virtual void FlipPage(int source) = 0;
virtual void PreInit() = 0;
virtual void UnInit() = 0;
virtual void Reset() = 0;
virtual void Flush() {};
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/VideoPlayer/VideoRenderers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(HEADERS BaseRenderer.h
OverlayRendererUtil.h
RenderCapture.h
RenderFlags.h
RenderFormats.h
RenderInfo.h
RenderManager.h
DebugRenderer.h)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class CRendererVAAPI : public CLinuxRendererGL
// Player functions
virtual void AddVideoPicture(const VideoPicture &picture, int index) override;
virtual void ReleaseBuffer(int idx) override;
virtual CRenderInfo GetRenderInfo() override;
virtual bool ConfigChanged(const VideoPicture &picture) override;

static bool HandlesVideoBuffer(const VideoPicture &picture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ CRendererVTB::~CRendererVTB()
}
}

CRenderInfo CRendererVTB::GetRenderInfo()
{
CRenderInfo info;
info.formats = m_formats;
info.max_buffer_size = NUM_BUFFERS;
info.optimal_buffer_size = 5;
return info;
}

bool CRendererVTB::HandlesVideoBuffer(CVideoBuffer *buffer)
{
VTB::CVideoBufferVTB *vb = dynamic_cast<VTB::CVideoBufferVTB*>(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CRendererVTB : public CLinuxRendererGL
// Player functions
virtual void ReleaseBuffer(int idx) override;
virtual bool NeedBuffer(int idx) override;
virtual CRenderInfo GetRenderInfo() override;
static bool HandlesVideoBuffer(CVideoBuffer *buffer);

protected:
Expand Down
Loading

0 comments on commit 3622826

Please sign in to comment.