⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_mpeg2_enc.h

📁 audio-video-codecs.rar语音编解码器
💻 H
📖 第 1 页 / 共 2 页
字号:
/*//////////////////////////////////////////////////////////////////////////////
//
//                  INTEL CORPORATION PROPRIETARY INFORMATION
//     This software is supplied under the terms of a license agreement or
//     nondisclosure agreement with Intel Corporation and may not be copied
//     or disclosed except in accordance with the terms of that agreement.
//          Copyright(c) 2002-2007 Intel Corporation. All Rights Reserved.
//
*/

#include "umc_defs.h"
#if defined (UMC_ENABLE_MPEG2_VIDEO_ENCODER)

#ifndef __UMC_MPEG2_ENC_H
#define __UMC_MPEG2_ENC_H

#include <limits.h>
#include "ippvc.h"
#include "vm_debug.h"
#include "umc_video_processing.h"
#include "umc_mpeg2_video_encoder.h"

namespace UMC
{

typedef struct _MBInfo  // macroblock information
{
  Ipp32s mb_type;               // intra/forward/backward/interpolated
  Ipp32s dct_type;              // field/frame DCT
  Ipp32s prediction_type;       // MC_FRAME/MC_FIELD
  Ipp32s var_sum;               // intra variance
  IppiPoint MV[2][2];           // motion vectors [vecnum][F/B]
  IppiPoint MV_P[2];            // motion vectors from P frame [vecnum]
  Ipp32s mv_field_sel[3][2];    // motion vertical field select:
                                // the first index: 0-top field, 1-bottom field, 2-frame;
                                // the second index:0-forward, 1-backward
  Ipp32s skipped;
} MBInfo;

typedef struct {
  Ipp32s mb_type;
  Ipp32s dct_type;
  Ipp32s pred_type;
  Ipp32s var_sum;
  Ipp32s var[4];
  Ipp32s mean[4];
  Ipp16s *pDiff;
} MB_prediction_info;

typedef struct _IppMotionVector2
{
  Ipp32s x;
  Ipp32s y;
  Ipp32s mctype_l;
  Ipp32s offset_l;
  Ipp32s mctype_c;
  Ipp32s offset_c;
} IppMotionVector2;

typedef struct _VLCode_8u // variable length code
{
    Ipp8u code; // right justified
    Ipp8u len;
} VLCode_8u;

typedef struct _VLCode_16u // VL code longer than 8 bits
{
    Ipp16u code; // right justified
    Ipp8u  len;
} VLCode_16u;

#if defined (_WIN32_WCE) && defined (_M_IX86) && defined (__stdcall)
  #define _IPP_STDCALL_CDECL
  #undef __stdcall
#endif

typedef IppStatus (__STDCALL *functype_getdiff)(
  const Ipp8u*  pSrcCur,
        Ipp32s  srcCurStep,
  const Ipp8u*  pSrcRef,
        Ipp32s  srcRefStep,
        Ipp16s* pDstDiff,
        Ipp32s  dstDiffStep,
        Ipp16s* pDstPredictor,
        Ipp32s  dstPredictorStep,
        Ipp32s  mcType,
        Ipp32s  roundControl);

typedef IppStatus (__STDCALL *functype_getdiffB)(
  const Ipp8u*       pSrcCur,
        Ipp32s       srcCurStep,
  const Ipp8u*       pSrcRefF,
        Ipp32s       srcRefStepF,
        Ipp32s       mcTypeF,
  const Ipp8u*       pSrcRefB,
        Ipp32s       srcRefStepB,
        Ipp32s       mcTypeB,
        Ipp16s*      pDstDiff,
        Ipp32s       dstDiffStep,
        Ipp32s       roundControl);

typedef IppStatus (__STDCALL *functype_mc)(
  const Ipp8u*       pSrcRef,
        Ipp32s       srcStep,
  const Ipp16s*      pSrcYData,
        Ipp32s       srcYDataStep,
        Ipp8u*       pDst,
        Ipp32s       dstStep,
        Ipp32s       mcType,
        Ipp32s       roundControl);

typedef IppStatus (__STDCALL *functype_mcB)(
  const Ipp8u*       pSrcRefF,
        Ipp32s       srcStepF,
        Ipp32s       mcTypeF,
  const Ipp8u*       pSrcRefB,
        Ipp32s       srcStepB,
        Ipp32s       mcTypeB,
  const Ipp16s*      pSrcYData,
        Ipp32s       srcYDataStep,
        Ipp8u*       pDst,
        Ipp32s       dstStep,
        Ipp32s       roundControl);

#if defined (_IPP_STDCALL_CDECL)
  #undef  _IPP_STDCALL_CDECL
  #define __stdcall __cdecl
#endif

#define ME_PARAMS             \
  const Ipp8u* pRefFld,       \
  const Ipp8u* pRecFld,       \
  Ipp32s   RefStep,           \
  const Ipp8u* pBlock,        \
  Ipp32s   BlockStep,         \
  Ipp32s*  pSrcMean,          \
  Ipp32s*  pDstVar,           \
  Ipp32s*  pDstMean,          \
  Ipp32s   limit_left,        \
  Ipp32s   limit_right,       \
  Ipp32s   limit_top,         \
  Ipp32s   limit_bottom,      \
  IppiPoint InitialMV0,       \
  IppiPoint InitialMV1,       \
  IppiPoint InitialMV2,       \
  IppMotionVector2 *vector,   \
  threadSpecificData *th,     \
  Ipp32s   i,                 \
  Ipp32s   j,                 \
  Ipp32s   *vertical_field_select, \
  Ipp32s   *currMAD,          \
  Ipp32s   parity // 0-same

class MPEG2VideoEncoderBase;

typedef struct
{
  Ipp32s bit_offset;
  Ipp32s bytelen;
  Ipp8u  *start_pointer;
  Ipp32u *current_pointer;
} bitBuffer;

typedef struct
{
  bitBuffer bBuf;
  Ipp16s *pMBlock;
  Ipp16s *pDiff;
  Ipp16s *pDiff1;
  IppiPoint PMV[2][2];
  Ipp32s start_row;
  Ipp32s numIntra;
  Ipp32s fieldCount;

  // motion estimation
  Ipp32s me_matrix_size;
  Ipp8u *me_matrix_buff;
  Ipp32s me_matrix_id;
} threadSpecificData;

typedef struct
{
  Ipp32s    numTh;
  MPEG2VideoEncoderBase *m_lpOwner;
  vm_event  start_event;
  vm_event  stop_event;
  vm_event  quit_event;
  vm_thread thread;
} threadInfo;

class MPEG2VideoEncoderBase : public VideoEncoder
{
  DYNAMIC_CAST_DECL(MPEG2VideoEncoderBase, VideoEncoder)
public:
  //constructor
  MPEG2VideoEncoderBase();

  //destructor
  ~MPEG2VideoEncoderBase();

  // Initialize codec with specified parameter(s)
  virtual Status Init(BaseCodecParams *init);
  // Compress (decompress) next frame
  virtual Status GetFrame(MediaData *in, MediaData *out);
  // Get codec working (initialization) parameter(s)
  virtual Status GetInfo(BaseCodecParams *info);
  // Repeat last frame
  Status RepeatLastFrame(Ipp64f PTS, MediaData *out);
  // Close all codec resources
  virtual Status Close();

  virtual Status Reset();

  virtual Status SetParams(BaseCodecParams* params);

  virtual Status SetBitRate(Ipp32s BitRate);

public:

  // Get source frame size (summary size of Y, U and V frames)
  Ipp32s GetYUVFrameSize();

  // Get pointer to internal encoder memory, where
  // next YUV frame can be stored before passing
  // this frame to encode function
  VideoData* GetNextYUVPointer();

  // Get buffer for next frame
  Status GetNextYUVBuffer(VideoData *data);

  // Creates internal frame buffers
  Status CreateInternalBuffers(Ipp32s count);

  // Encode frames (in source order)
  // On first frames the function can return zero encoded_size. This is because
  // of buffering of B frames until the reference P frame comes. After the end of
  // source stream function EncodeFrame() must be called (IPDistance - 1) times
  // with frame == NULL in order to encode the buffered frames.
  Status EncodeFrame(VideoData *frame, MediaData *out, Ipp64f *PTS, Ipp64f *DTS);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -