Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions _studio/mfx_lib/decode/mjpeg/include/mfx_mjpeg_dec_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <queue>

#include "mfx_task.h"
#include "umc_media_data.h"


#include "mfx_vpp_jpeg_d3d9.h"
Expand All @@ -45,6 +46,7 @@ namespace UMC
class JpegFrameConstructor;
class MediaDataEx;
class FrameData;
class MediaData;
};

class VideoDECODEMJPEGBase
Expand All @@ -70,7 +72,11 @@ class VideoDECODEMJPEGBase
virtual mfxStatus RunThread(void *pParam, mfxU32 threadNumber, mfxU32 callNumber) = 0;
virtual mfxStatus CompleteTask(void *pParam, mfxStatus taskRes) = 0;
virtual void ReleaseReservedTask() = 0;
#if (MFX_VERSION >= MFX_VERSION)
virtual mfxStatus AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic, UMC::MediaData *in) = 0;
#else
virtual mfxStatus AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic) = 0;
#endif
virtual mfxStatus AllocateFrameData(UMC::FrameData *&data) = 0;
virtual mfxStatus FillEntryPoint(MFX_ENTRY_POINT *pEntryPoint, mfxFrameSurface1 *surface_work, mfxFrameSurface1 *surface_out) = 0;

Expand Down Expand Up @@ -103,7 +109,11 @@ class VideoDECODEMJPEGBase_HW : public VideoDECODEMJPEGBase
virtual mfxStatus CheckTaskAvailability(mfxU32 maxTaskNumber);
virtual mfxStatus ReserveUMCDecoder(UMC::MJPEGVideoDecoderBaseMFX* &pMJPEGVideoDecoder, mfxFrameSurface1 *surf, bool isOpaq);
virtual void ReleaseReservedTask();
#if (MFX_VERSION >= MFX_VERSION)
virtual mfxStatus AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic, UMC::MediaData *in);
#else
virtual mfxStatus AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic);
#endif
virtual mfxStatus AllocateFrameData(UMC::FrameData *&data);
virtual mfxStatus FillEntryPoint(MFX_ENTRY_POINT *pEntryPoint, mfxFrameSurface1 *surface_work, mfxFrameSurface1 *surface_out);

Expand Down Expand Up @@ -149,7 +159,11 @@ class VideoDECODEMJPEGBase_SW : public VideoDECODEMJPEGBase
mfxStatus CheckTaskAvailability(mfxU32 maxTaskNumber) override;
mfxStatus ReserveUMCDecoder(UMC::MJPEGVideoDecoderBaseMFX* &pMJPEGVideoDecoder, mfxFrameSurface1 *surf, bool isOpaq) override;
void ReleaseReservedTask() override;
#if (MFX_VERSION >= MFX_VERSION)
mfxStatus AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic, UMC::MediaData *in) override;
#else
mfxStatus AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic) override;
#endif
mfxStatus AllocateFrameData(UMC::FrameData *&data) override;
mfxStatus FillEntryPoint(MFX_ENTRY_POINT *pEntryPoint, mfxFrameSurface1 *surface_work, mfxFrameSurface1 *surface_out) override;

Expand Down
40 changes: 40 additions & 0 deletions _studio/mfx_lib/decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ mfxStatus VideoDECODEMJPEG::DecodeHeader(VideoCORE *core, mfxBitstream *bs, mfxV
UMC::Status umcRes = decoder.Init(&umcVideoParams);
MFX_CHECK_INIT(umcRes == UMC::UMC_OK);

#if (MFX_VERSION >= MFX_VERSION)
mfxExtBuffer* extbuf = (bs) ? GetExtendedBuffer(bs->ExtParam, bs->NumExtParam, MFX_EXTBUFF_DECODE_ERROR_REPORT) : NULL;

if (extbuf)
{
reinterpret_cast<mfxExtDecodeErrorReport *>(extbuf)->ErrorTypes = 0;
in.SetExtBuffer(extbuf);
}
#endif

umcRes = decoder.DecodeHeader(&in);

in.Save(bs);
Expand Down Expand Up @@ -783,6 +793,16 @@ mfxStatus VideoDECODEMJPEG::DecodeFrameCheck(mfxBitstream *bs, mfxFrameSurface1
MFXMediaDataAdapter src(bs);
UMC::MediaDataEx *pSrcData;

#if (MFX_VERSION >= MFX_VERSION)
mfxExtBuffer* extbuf = (bs) ? GetExtendedBuffer(bs->ExtParam, bs->NumExtParam, MFX_EXTBUFF_DECODE_ERROR_REPORT) : NULL;

if (extbuf)
{
reinterpret_cast<mfxExtDecodeErrorReport *>(extbuf)->ErrorTypes = 0;
src.SetExtBuffer(extbuf);
}
#endif

if (!m_isHeaderFound && bs)
{
umcRes = pMJPEGVideoDecoder->FindStartOfImage(&src);
Expand All @@ -798,7 +818,11 @@ mfxStatus VideoDECODEMJPEG::DecodeFrameCheck(mfxBitstream *bs, mfxFrameSurface1

if (!m_isHeaderParsed && bs)
{
#if (MFX_VERSION >= MFX_VERSION)
umcRes = pMJPEGVideoDecoder->_GetFrameInfo((uint8_t*)src.GetDataPointer(), src.GetDataSize(), &src);
#else
umcRes = pMJPEGVideoDecoder->_GetFrameInfo((uint8_t*)src.GetDataPointer(), src.GetDataSize());
#endif
if (umcRes != UMC::UMC_OK)
{
if(umcRes != UMC::UMC_ERR_NOT_ENOUGH_DATA)
Expand Down Expand Up @@ -854,7 +878,11 @@ mfxStatus VideoDECODEMJPEG::DecodeFrameCheck(mfxBitstream *bs, mfxFrameSurface1

try
{
#if (MFX_VERSION >= MFX_VERSION)
MFX_SAFE_CALL(decoder->AddPicture(pSrcData, numPic, &src));
#else
MFX_SAFE_CALL(decoder->AddPicture(pSrcData, numPic));
#endif
}
catch(const UMC::eUMC_Status& sts)
{
Expand Down Expand Up @@ -1880,7 +1908,11 @@ void VideoDECODEMJPEGBase_HW::ReleaseReservedTask()
}
}

#if (MFX_VERSION >= MFX_VERSION)
mfxStatus VideoDECODEMJPEGBase_HW::AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic, UMC::MediaData *in)
#else
mfxStatus VideoDECODEMJPEGBase_HW::AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic)
#endif
{
mfxU32 fieldPos = m_numPic;

Expand All @@ -1899,7 +1931,11 @@ mfxStatus VideoDECODEMJPEGBase_HW::AddPicture(UMC::MediaDataEx *pSrcData, mfxU32
return ConvertUMCStatusToMfx(umcRes);
}

#if (MFX_VERSION >= MFX_VERSION)
umcRes = m_pMJPEGVideoDecoder->GetFrame(pSrcData, &m_dst, fieldPos, in);
#else
umcRes = m_pMJPEGVideoDecoder->GetFrame(pSrcData, &m_dst, fieldPos);
#endif

mfxStatus sts = MFX_ERR_NONE;

Expand Down Expand Up @@ -2118,7 +2154,11 @@ void VideoDECODEMJPEGBase_SW::ReleaseReservedTask()
m_freeTasks.front()->Reset();
}

#if (MFX_VERSION >= MFX_VERSION)
mfxStatus VideoDECODEMJPEGBase_SW::AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic, UMC::MediaData *in)
#else
mfxStatus VideoDECODEMJPEGBase_SW::AddPicture(UMC::MediaDataEx *pSrcData, mfxU32 & numPic)
#endif
{
// select the field position. 0 means top, 1 means bottom.
mfxU32 fieldPos = m_freeTasks.front()->NumPicCollected();
Expand Down
1 change: 1 addition & 0 deletions _studio/shared/umc/codec/jpeg_dec/include/jpegdec.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "umc_defs.h"
#if defined (MFX_ENABLE_MJPEG_VIDEO_DECODE)
#include "jpegdec_base.h"
#include "umc_media_data.h"

class CBaseStreamInput;

Expand Down
16 changes: 16 additions & 0 deletions _studio/shared/umc/codec/jpeg_dec/include/jpegdec_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "colorcomp.h"
#include "membuffin.h"
#include "bitstreamin.h"
#include "mfxstructures.h"

class CJPEGDecoderBase
{
Expand All @@ -42,13 +43,24 @@ class CJPEGDecoderBase
JERRCODE SetSource(const uint8_t* pBuf, size_t buflen);
JERRCODE Seek(long offset, int origin);

#if (MFX_VERSION >= MFX_VERSION)
virtual JERRCODE ReadHeader(
int* width,
int* height,
int* nchannels,
JCOLOR* color,
JSS* sampling,
int* precision,
mfxExtDecodeErrorReport* pDecodeErrorReport);
#else
virtual JERRCODE ReadHeader(
int* width,
int* height,
int* nchannels,
JCOLOR* color,
JSS* sampling,
int* precision);
#endif

int GetNumDecodedBytes(void) { return m_BitStreamIn.GetNumUsedBytes(); }

Expand Down Expand Up @@ -131,7 +143,11 @@ class CJPEGDecoderBase

JERRCODE FindSOI();

#if (MFX_VERSION >= MFX_VERSION)
virtual JERRCODE ParseJPEGBitStream(JOPERATION op, mfxExtDecodeErrorReport* pDecodeErrorReport);
#else
virtual JERRCODE ParseJPEGBitStream(JOPERATION op);
#endif
JERRCODE ParseSOI(void);
JERRCODE ParseEOI(void);
JERRCODE ParseAPP0(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ class MJPEGVideoDecoderBaseMFX
Status FindStartOfImage(MediaData * in);

// All memory sizes should come in size_t type
#if (MFX_VERSION >= MFX_VERSION)
Status _GetFrameInfo(const uint8_t* pBitStream, size_t nSize, MediaData *in);
#else
Status _GetFrameInfo(const uint8_t* pBitStream, size_t nSize);
#endif

Status SetRotation(uint16_t rotation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ class MJPEGVideoDecoderMFX_HW : public MJPEGVideoDecoderBaseMFX
Status CloseFrame(UMC::FrameData** in, const mfxU32 fieldPos);

// Get next frame
#if (MFX_VERSION >= MFX_VERSION)
virtual Status GetFrame(UMC::MediaDataEx *pSrcData, UMC::FrameData** out, const mfxU32 fieldPos, UMC::MediaData *in);
#else
virtual Status GetFrame(UMC::MediaDataEx *pSrcData, UMC::FrameData** out, const mfxU32 fieldPos);
#endif

virtual ConvertInfo * GetConvertInfo();

Expand All @@ -97,10 +101,17 @@ class MJPEGVideoDecoderMFX_HW : public MJPEGVideoDecoderBaseMFX

Status _DecodeField();

#if (MFX_VERSION >= MFX_VERSION)
Status _DecodeHeader(int32_t* nUsedBytes, mfxExtDecodeErrorReport* pDecodeErrorReport);
#else
Status _DecodeHeader(int32_t* nUsedBytes);
#endif

#if (MFX_VERSION >= MFX_VERSION)
virtual Status _DecodeField(MediaDataEx* in, mfxExtDecodeErrorReport* pDecodeErrorReport);
#else
virtual Status _DecodeField(MediaDataEx* in);

#endif

Status PackHeaders(MediaData* src, JPEG_DECODE_SCAN_PARAMETER* obtainedScanParams, uint8_t* buffersForUpdate);
Status PackPriorityParams();
Expand Down
Loading