Skip to content

Commit

Permalink
CDVDVideoCodecDRMPRIME: Support decoding to DRMPRIME with sw deinterlace
Browse files Browse the repository at this point in the history
We can map a YUV style DRM_PRIME buffer back to AV_PIX_FMT_YUV420P
to allow subsquent sw deinterlace
  • Loading branch information
popcornmix committed Feb 21, 2024
1 parent 9af7f41 commit 29a1a59
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,9 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, AVPixelForma
if (filters.find("deinterlace") != std::string::npos && pix_fmt == AV_PIX_FMT_YUV420P)
pix_fmt = AV_PIX_FMT_DRM_PRIME;

if (filters.find("bwdif") != std::string::npos && pix_fmt == AV_PIX_FMT_DRM_PRIME)
pix_fmt = AV_PIX_FMT_YUV420P;

if (m_pFilterGraph)
FilterClose();

Expand Down Expand Up @@ -867,6 +870,25 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn()
m_pFrame->data[0] = reinterpret_cast<uint8_t*>(descriptor);
m_pFrame->format = AV_PIX_FMT_DRM_PRIME;
}
// hw decoded buffers submitted to sw decoder need mapping of planes for cpu to access
else if (m_pFrame->format == AV_PIX_FMT_DRM_PRIME && m_pFilterGraph && m_pFilterIn->outputs[0]->format == AV_PIX_FMT_YUV420P)
{
AVFrame *frame = av_frame_alloc();
frame->width = m_pFrame->width;
frame->height = m_pFrame->height;
frame->format = AV_PIX_FMT_YUV420P;
int ret = av_hwframe_map(frame, m_pFrame, (int)AV_HWFRAME_MAP_READ);
if (ret < 0)
{
char err[AV_ERROR_MAX_STRING_SIZE] = {};
av_strerror(ret, err, AV_ERROR_MAX_STRING_SIZE);
CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::{} - av_hwframe_map failed: {} ({})",
__FUNCTION__, err, ret);
return VC_ERROR;
}
av_frame_unref(m_pFrame);
av_frame_move_ref(m_pFrame, frame);
}

int ret = av_buffersrc_add_frame(m_pFilterIn, m_pFrame);
if (ret < 0)
Expand Down

0 comments on commit 29a1a59

Please sign in to comment.