Commit 9d892697 authored by AlexandrX Konovalov's avatar AlexandrX Konovalov Committed by Oleg Nabiullin

Add SW fallback for jpeg encoders

parent abbcc8b4
......@@ -22,6 +22,7 @@ add_subdirectory(shared/mfx_trace)
add_subdirectory(shared/umc)
add_subdirectory(shared/asc)
add_subdirectory(mfx_lib/decode)
add_subdirectory(mfx_lib/encode)
add_subdirectory(mfx_lib/encode_hw)
add_subdirectory(mfx_lib/fei)
add_subdirectory(mfx_lib/genx)
......
......@@ -75,6 +75,7 @@ list( APPEND mdirs
scheduler vpp decode/vc1
decode/mjpeg decode/h264 decode/mpeg2 cmrt_cross_platform
encode_hw/vp9 encode_hw/h265 encode_hw/h264 encode_hw/mpeg2 encode_hw/mjpeg
encode/mjpeg
decode/h265 decode/vp8 decode/vp9 mctf_package/mctf
)
include_directories( ${MSDK_LIB_ROOT}/fei/h264_common )
......@@ -90,7 +91,7 @@ include_directories( ${MSDK_LIB_ROOT}/genx/copy_kernels/isa )
include_directories( ${MSDK_STUDIO_ROOT}/shared/asc/include )
list( APPEND cdirs
brc h264_enc mpeg2_dec vc1_dec vp9_dec vc1_common
brc h264_enc mpeg2_dec vc1_dec vp9_dec vc1_common jpeg_enc
)
foreach( dir ${cdirs} )
include_directories( ${MSDK_UMC_ROOT}/codec/${dir}/include )
......@@ -174,7 +175,7 @@ else()
endif()
if( MFX_ENABLE_SW_FALLBACK )
set(SW_FALLBACK_LIBS "color_space_converter_hw;ipp")
set(SW_FALLBACK_LIBS "jpeg_enc;color_space_converter_hw;ipp;encode")
else()
set(SW_FALLBACK_LIBS "")
endif()
......
......@@ -29,6 +29,7 @@ foreach( dir ${Decoders} )
endforeach()
include_directories( ${MSDK_LIB_ROOT}/vpp/include )
include_directories( ${MSDK_UMC_ROOT}/codec/jpeg_dec/include )
include_directories( ${MSDK_UMC_ROOT}/codec/jpeg_enc/include )
include_directories( ${MSDK_UMC_ROOT}/codec/jpeg_common/include )
include_directories( ${MSDK_UMC_ROOT}/codec/vc1_common/include )
include_directories( ${MSDK_UMC_ROOT}/codec/color_space_converter/include )
......@@ -61,6 +62,14 @@ file( GLOB_RECURSE srcs "${SRC_DIR}/*.c" "${SRC_DIR}/*.cpp" )
list( APPEND sources ${srcs})
make_library( jpeg_common none static )
### JPEG Encoder
set( SRC_DIR "${MSDK_UMC_ROOT}/codec/jpeg_enc/src" )
set( sources "" )
set( defs "" )
file( GLOB_RECURSE srcs "${SRC_DIR}/*.cpp" )
list( APPEND sources ${srcs})
make_library( jpeg_enc none static )
set( SRC_DIR "${MSDK_UMC_ROOT}/codec/jpeg_dec/src" )
set( defs "" )
set( sources "" )
......
set(MFX_ORIG_LDFLAGS "${MFX_LDFLAGS}" )
list( APPEND vdirs
mjpeg
)
list( APPEND cdirs
jpeg_enc color_space_converter
)
mfx_include_dirs( )
foreach( dir ${vdirs} )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/include )
endforeach()
foreach( dir ${cdirs} )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../shared/umc/codec/${dir}/include )
endforeach( )
set( defs "${API_FLAGS} ${WARNING_FLAGS}" )
set( sources "" )
set( sources.plus "" )
foreach( dir ${vdirs} )
file( GLOB_RECURSE srcs "${dir}/src/*.c" "${dir}/src/*.cpp" )
list( APPEND sources ${srcs})
endforeach()
make_library( encode none static )
set( defs "" )
// Copyright (c) 2018 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "mfx_common.h"
#if defined (MFX_ENABLE_MJPEG_VIDEO_ENCODE)
#ifndef _MFX_MPJEG_ENC_ENCODE_H_
#define _MFX_MPJEG_ENC_ENCODE_H_
#include "mfx_common_int.h"
#include "mfxvideo++int.h"
#include "mfxvideo.h"
#include "umc_mjpeg_video_encoder.h"
#include <mutex>
#include <queue>
class MJPEGEncodeTask
{
public:
// Default constructor
MJPEGEncodeTask(void);
// Destructor
~MJPEGEncodeTask(void);
// Initialize the task object
mfxStatus Initialize(UMC::VideoEncoderParams* params);
// Add a picture to the task
mfxStatus AddSource(mfxFrameSurface1* surface, mfxFrameInfo* frameInfo, bool useAuxInput);
// Calculate number of pieces to split the task between threads
mfxU32 CalculateNumPieces(mfxFrameSurface1* surface, mfxFrameInfo* frameInfo);
// Get the number of pictures collected
mfxU32 NumPicsCollected(void);
// Get the number of pieces collected
mfxU32 NumPiecesCollected(void);
// Reset the task, drop all counters
void Reset(void);
mfxEncodeCtrl *ctrl;
mfxFrameSurface1 *surface;
mfxBitstream *bs;
mfxFrameSurface1 auxInput;
mfxU32 m_initialDataLength;
std::unique_ptr<UMC::MJPEGVideoEncoder> m_pMJPEGVideoEncoder;
mfxStatus EncodePiece(const mfxU32 threadNumber);
protected:
// Close the object, release all resources
void Close(void);
std::mutex m_guard;
mfxU32 encodedPieces;
};
class MFXVideoENCODEMJPEG : public VideoENCODE
{
public:
static mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out);
static mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest *request);
mfxTaskThreadingPolicy GetThreadingPolicy(void) override
{
return MFX_TASK_THREADING_INTRA;
}
MFXVideoENCODEMJPEG(VideoCORE *core, mfxStatus *sts);
~MFXVideoENCODEMJPEG() override;
mfxStatus Init(mfxVideoParam *par) override;
mfxStatus Reset(mfxVideoParam *par) override;
mfxStatus Close(void) override;
mfxStatus GetVideoParam(mfxVideoParam *par) override;
mfxStatus GetFrameParam(mfxFrameParam *par) override;
mfxStatus GetEncodeStat(mfxEncodeStat *stat) override;
mfxStatus EncodeFrame(mfxEncodeCtrl *ctrl, mfxEncodeInternalParams *pInternalParams, mfxFrameSurface1 *surface, mfxBitstream *bs) override;
mfxStatus EncodeFrameCheck(mfxEncodeCtrl *ctrl, mfxFrameSurface1 *surface, mfxBitstream *bs, mfxFrameSurface1 **reordered_surface, mfxEncodeInternalParams *pInternalParams) override;
mfxStatus EncodeFrameCheck(mfxEncodeCtrl *ctrl, mfxFrameSurface1 *surface, mfxBitstream *bs, mfxFrameSurface1 **reordered_surface, mfxEncodeInternalParams *pInternalParams, MFX_ENTRY_POINT *pEntryPoint) override;
mfxStatus CancelFrame(mfxEncodeCtrl * /*ctrl*/, mfxEncodeInternalParams * /*pInternalParams*/, mfxFrameSurface1 * /*surface*/, mfxBitstream * /*bs*/) override {return MFX_ERR_UNSUPPORTED;}
mfxFrameSurface1 *GetOriginalSurface(mfxFrameSurface1 *surface);
mfxStatus RunThread(MJPEGEncodeTask &task, mfxU32 threadNumber, mfxU32 callNumber);
protected:
VideoCORE *m_core;
mfxVideoParamWrapper m_vFirstParam;
mfxVideoParamWrapper m_vParam;
mfxFrameParam m_mfxFrameParam;
mfxFrameAllocResponse m_response;
//mfxFrameAllocResponse m_response_alien;
// Free tasks queue guard (if SW is used)
std::mutex m_guard;
// Free tasks queue (if SW is used)
std::queue<MJPEGEncodeTask *> m_freeTasks;
// Count of created tasks (if SW is used)
mfxU16 m_tasksCount;
MJPEGEncodeTask *pLastTask;
std::unique_ptr<UMC::MJPEGEncoderParams> m_pUmcVideoParams;
mfxU32 m_totalBits;
mfxU32 m_frameCountSync; // counter for sync. part
mfxU32 m_frameCount; // counter for Async. part
mfxU32 m_encodedFrames;
bool m_useAuxInput;
//bool m_useSysOpaq;
//bool m_useVideoOpaq;
bool m_isOpaque;
bool m_isInitialized;
mfxExtJPEGQuantTables m_checkedJpegQT;
mfxExtJPEGHuffmanTables m_checkedJpegHT;
mfxExtOpaqueSurfaceAlloc m_checkedOpaqAllocReq;
mfxExtBuffer* m_pCheckedExt[3];
//
// Asynchronous processing functions
//
static
mfxStatus MJPEGENCODERoutine(void *pState, void *pParam, mfxU32 threadNumber, mfxU32 callNumber);
static
mfxStatus MJPEGENCODECompleteProc(void *pState, void *pParam, mfxStatus taskRes);
};
#endif //_MFX_MPJEG_ENC_ENCODE_H_
#endif // MFX_ENABLE_MJPEG_VIDEO_ENCODE
This diff is collapsed.
// Copyright (c) 2018 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef __ENCHTBL_H__
#define __ENCHTBL_H__
#include "umc_defs.h"
#if defined (MFX_ENABLE_MJPEG_VIDEO_ENCODE)
#include "ippj.h"
#include "jpegbase.h"
class CJPEGEncoderHuffmanTable
{
private:
IppiEncodeHuffmanSpec* m_table;
bool m_bValid;
public:
int m_id;
int m_hclass;
uint8_t m_bits[16];
uint8_t m_vals[256];
CJPEGEncoderHuffmanTable(void);
virtual ~CJPEGEncoderHuffmanTable(void);
JERRCODE Create(void);
JERRCODE Destroy(void);
JERRCODE Init(int id,int hclass,uint8_t* bits,uint8_t* vals);
bool IsValid(void) { return m_bValid; }
operator IppiEncodeHuffmanSpec*(void) { return m_table; }
};
class CJPEGEncoderHuffmanState
{
private:
IppiEncodeHuffmanState* m_state;
public:
CJPEGEncoderHuffmanState(void);
virtual ~CJPEGEncoderHuffmanState(void);
JERRCODE Create(void);
JERRCODE Destroy(void);
JERRCODE Init(void);
operator IppiEncodeHuffmanState*(void) { return m_state; }
};
#endif // MFX_ENABLE_MJPEG_VIDEO_ENCODE
#endif // __ENCHTBL_H__
// Copyright (c) 2018 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef __ENCQTBL_H__
#define __ENCQTBL_H__
#include "umc_defs.h"
#if defined (MFX_ENABLE_MJPEG_VIDEO_ENCODE)
#include "ippj.h"
#include "jpegbase.h"
class CJPEGEncoderQuantTable
{
private:
uint8_t m_rbf[DCTSIZE2*sizeof(uint16_t)+(CPU_CACHE_LINE-1)];
uint8_t m_qbf[DCTSIZE2*sizeof(float)+(CPU_CACHE_LINE-1)];
uint16_t* m_qnt16u;
float* m_qnt32f;
public:
int m_id;
bool m_initialized;
int m_precision;
uint8_t* m_raw8u;
uint16_t* m_raw16u;
CJPEGEncoderQuantTable(void);
virtual ~CJPEGEncoderQuantTable(void);
JERRCODE Init(int id,uint8_t raw[DCTSIZE2],int quality);
JERRCODE Init(int id,uint16_t raw[DCTSIZE2],int quality);
operator uint16_t*() { return m_precision == 0 ? m_qnt16u : 0; }
operator float*() { return m_precision == 1 ? m_qnt32f : 0; }
};
#endif // MFX_ENABLE_MJPEG_VIDEO_ENCODE
#endif // __ENCQTBL_H__
// Copyright (c) 2018 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef __JPEGENC_H__
#define __JPEGENC_H__
#include "umc_defs.h"
#if defined (MFX_ENABLE_MJPEG_VIDEO_ENCODE)
#include "umc_defs.h"
#include "ippdefs.h"
#include "ippcore.h"
#include "ipps.h"
#include "ippi.h"
#include "ippj.h"
#include "basestreamout.h"
#include "jpegbase.h"
#include "encqtbl.h"
#include "enchtbl.h"
#include "colorcomp.h"
#include "bitstreamout.h"
class CBaseStreamOutput;
typedef struct _JPEG_SCAN
{
int ncomp;
int id[MAX_COMPS_PER_SCAN];
int Ss;
int Se;
int Ah;
int Al;
} JPEG_SCAN;
class CJPEGEncoder
{
public:
CJPEGEncoder(void);
virtual ~CJPEGEncoder(void);
JERRCODE SetSource(
uint8_t* pSrc,
int srcStep,
mfxSize srcSize,
int srcChannels,
JCOLOR srcColor,
JSS srcSampling = JS_444,
int srcPrecision = 8);
JERRCODE SetSource(
int16_t* pSrc,
int srcStep,
mfxSize srcSize,
int srcChannels,
JCOLOR srcColor,
JSS srcSampling = JS_444,
int srcPrecision = 16);
JERRCODE SetSource(
uint8_t* pSrc[4],
int srcStep[4],
mfxSize srcSize,
int srcChannels,
JCOLOR srcColor,
JSS srcSampling = JS_411,
int srcPrecision = 8);
JERRCODE SetSource(
int16_t* pSrc[4],
int srcStep[4],
mfxSize srcSize,
int srcChannels,
JCOLOR srcColor,
JSS srcSampling = JS_444,
int srcPrecision = 16);
JERRCODE SetDestination(
CBaseStreamOutput* pStreamOut);
JERRCODE SetParams(
JMODE mode,
JCOLOR color,
JSS sampling,
int restart_interval,
int interleaved,
int piecesCountInField,
int piecePosInField,
int numScan,
int piecePosInScan,
int huff_opt,
int quality,
JTMODE threading_mode = JT_OLD);
JERRCODE SetParams(
JMODE mode,
JCOLOR color,
JSS sampling,
int restart_interval,
int huff_opt,
int point_transform,
int predictor);
JERRCODE InitHuffmanTable(uint8_t bits[16], uint8_t vals[256], int tbl_id, HTBL_CLASS tbl_class);
JERRCODE InitQuantTable(uint8_t qnt[64], int tbl_id, int quality);
JERRCODE InitQuantTable(uint16_t qnt[64], int tbl_id, int quality);
JERRCODE AttachHuffmanTable(int tbl_id, HTBL_CLASS tbl_class, int comp_no);
JERRCODE AttachQuantTable(int tbl_id, int comp_no);
JERRCODE WriteHeader(void);
JERRCODE WriteData(void);
int NumOfBytes(void) { return m_BitStreamOut.NumOfBytes(); }
JERRCODE SetComment( int comment_size, char* comment = 0);
JERRCODE SetJFIFApp0Resolution( JRESUNITS units, int xdensity, int ydensity);
uint16_t GetNumQuantTables(void);
JERRCODE FillQuantTable(int numTable, uint16_t* pTable);
uint16_t GetNumACTables(void);
JERRCODE FillACTable(int numTable, uint8_t* pBits, uint8_t* pValues);
uint16_t GetNumDCTables(void);
JERRCODE FillDCTable(int numTable, uint8_t* pBits, uint8_t* pValues);
JERRCODE SetQuantTable(int numTable, uint16_t* pTable);
JERRCODE SetACTable(int numTable, uint8_t* pBits, uint8_t* pValues);
JERRCODE SetDCTable(int numTable, uint8_t* pBits, uint8_t* pValues);
JERRCODE SetDefaultQuantTable(uint16_t quality);
JERRCODE SetDefaultACTable();
JERRCODE SetDefaultDCTable();
bool IsQuantTableInited();
bool IsACTableInited();
bool IsDCTableInited();
protected:
IMAGE m_src;
CBitStreamOutput m_BitStreamOut;
CBitStreamOutput* m_BitStreamOutT;
int m_jpeg_ncomp;
int m_jpeg_precision;
JSS m_jpeg_sampling;
JCOLOR m_jpeg_color;
int m_jpeg_quality;
int m_jpeg_restart_interval;
JMODE m_jpeg_mode;
char* m_jpeg_comment;
int m_numxMCU;
int m_numyMCU;
int m_mcuWidth;
int m_mcuHeight;
int m_ccWidth;
int m_ccHeight;
int m_xPadding;
int m_yPadding;
int m_num_scans;
JSCAN m_curr_scan;
int m_ss;
int m_se;
int m_al;
int m_ah;
int m_predictor;
int m_pt;
int m_optimal_htbl;
JPEG_SCAN* m_scan_script;
// Number of MCU already encoded
uint32_t m_mcu_encoded;
// Number of MCU remain in the current VLC unit
uint32_t m_mcu_to_encode;
int16_t* m_block_buffer;
int m_block_buffer_size;
int m_num_threads;
int m_nblock;
int m_jfif_app0_xDensity;
int m_jfif_app0_yDensity;
JRESUNITS m_jfif_app0_units;
int m_num_rsti;
int m_rstiHeight;
JTMODE m_threading_mode;
int m_piecesCountInField;
int m_piecePosInField;
int m_piecePosInScan;
bool m_externalQuantTable;
bool m_externalHuffmanTable;
int16_t** m_lastDC;
CJPEGEncoderHuffmanState* m_state_t;
CJPEGColorComponent m_ccomp[MAX_COMPS_PER_SCAN];
CJPEGEncoderQuantTable m_qntbl[MAX_QUANT_TABLES];
CJPEGEncoderHuffmanTable m_dctbl[MAX_HUFF_TABLES];
CJPEGEncoderHuffmanTable m_actbl[MAX_HUFF_TABLES];
CJPEGEncoderHuffmanState m_state;
JERRCODE Init(void);
JERRCODE Clean(void);
JERRCODE ColorConvert(uint32_t rowMCU, uint32_t colMCU, uint32_t maxMCU/*int nMCURow, int thread_id = 0*/);
JERRCODE DownSampling(uint32_t rowMCU, uint32_t colMCU, uint32_t maxMCU/*int nMCURow, int thread_id = 0*/);
JERRCODE WriteSOI(void);
JERRCODE WriteEOI(void);
JERRCODE WriteAPP0(void);
JERRCODE WriteAPP14(void);
JERRCODE WriteSOF0(void);
JERRCODE WriteSOF1(void);
JERRCODE WriteSOF2(void);
JERRCODE WriteSOF3(void);
JERRCODE WriteDRI(int restart_interval);
JERRCODE WriteRST(int next_restart_num);
JERRCODE WriteSOS(void);
JERRCODE WriteSOS(int ncomp,int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al);
JERRCODE WriteDQT(CJPEGEncoderQuantTable* tbl);
JERRCODE WriteDHT(CJPEGEncoderHuffmanTable* tbl);
JERRCODE WriteCOM(char* comment = 0);
JERRCODE EncodeScanBaseline(void);
JERRCODE EncodeScanBaselineRSTI(void);
JERRCODE EncodeScanBaselineRSTI_P(void);
JERRCODE EncodeHuffmanMCURowBL_RSTI(int16_t* pMCUBuf, int thread_id = 0);
JERRCODE ProcessRestart(int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al, int nRSTI, int thread_id);
JERRCODE WriteRST_T(int next_restart_num, int thread_id = 0);
JERRCODE EncodeScanExtended(void);
JERRCODE EncodeScanExtended_P(void);
JERRCODE EncodeScanLossless(void);
JERRCODE EncodeScanProgressive(void);
JERRCODE EncodeScan(int ncomp,int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al);
JERRCODE SelectScanScripts(void);
JERRCODE GenerateHuffmanTables(int ncomp,int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al);
JERRCODE GenerateHuffmanTables(void);
JERRCODE GenerateHuffmanTablesEX(void);
JERRCODE ProcessRestart(int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al);
JERRCODE ProcessRestart(int stat[2][256],int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al);
JERRCODE EncodeHuffmanMCURowBL(int16_t* pMCUBuf, uint32_t colMCU, uint32_t maxMCU);
JERRCODE EncodeHuffmanMCURowLS(int16_t* pMCUBuf);
JERRCODE TransformMCURowBL(int16_t* pMCUBuf, uint32_t colMCU, uint32_t maxMCU/*int16_t* pMCUBuf, int thread_id = 0*/);
JERRCODE ProcessBuffer(uint32_t rowMCU, uint32_t colMCU, uint32_t maxMCU);//(int nMCURow, int thread_id = 0);
JERRCODE EncodeScanProgressive_P(void);
JERRCODE TransformMCURowEX(int16_t* pMCUBuf, int thread_id = 0);
JERRCODE TransformMCURowLS(int16_t* pMCUBuf, int nMCURow, int thread_id = 0);
};
#endif // MFX_ENABLE_MJPEG_VIDEO_ENCODE
#endif // __JPEGENC_H__
// Copyright (c) 2018 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef __UMC_MJPEG_VIDEO_ENCODER_H
#define __UMC_MJPEG_VIDEO_ENCODER_H
#include "umc_defs.h"
#if defined (MFX_ENABLE_MJPEG_VIDEO_ENCODE)
#include <vector>
#include <memory>
#include <mutex>
#include "umc_defs.h"
#include "umc_structures.h"
#include "umc_video_encoder.h"
#include "umc_video_data.h"
#include "mfxvideo++int.h"
// internal JPEG decoder object forward declaration
class CBaseStreamOutput;
class CJPEGEncoder;
namespace UMC
{
enum
{
JPEG_ENC_MAX_THREADS_HW = 1,
JPEG_ENC_MAX_THREADS = 4