📄 sampmp4.h
字号:
/******************************************************************************
// 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) 2003 Intel Corporation. All Rights Reserved.
//
// Description:
// Definitions of MPEG-4 video encoder and decoder sample code for Intel(R)
// Integrated Performance Primitives
//
******************************************************************************/
#ifndef _MP4DECODER_H_
#define _MP4DECODER_H_
#include <stdio.h>
#include "ippdefs.h"
#include "ippVC.h"
#include "sampdefs.h"
#include "sampvc.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ========================== Constant Definition ========================== */
#define MPEG4_NUMBITS_VOP_WIDTH 13
#define MPEG4_NUMBITS_VOP_HEIGHT 13
#define MPEG4_NUMBITS_QMATRIX 8
#define MPEG4_SC_LEN 3 /* in bytes */
#define MPEG4_SUFFIX_VOPSC 0xB6 /* 1 byte */
#define MPEG4_SUFFIX_GOVSC 0xB3 /* 1 byte */
#define MPEG4_SUFFIX_UDSC 0xB2 /* 1 byte */
#define MPEG4_PREFIX_SC 0x000001 /* 3 bytes */
#define MPEG4_VOSC 0x00000100 /* 4 bytes */
#define MPEG4_VOLSC 0x00000120 /* 4 bytes */
#define MPEG4_H263_PSC 0x000020 /* 22 bits */
#define MPEG4_MB_STUFF 12
#define MPEG4_PRED_DISABLE -10000
#define MPEG4_ENCODE_THRESHOLD_Q_H263 20
#define MPEG4_ENCODE_THRESHOLD_Q_MPEG 16
/* ====================== Functional Macro Definition ===================== */
#define ASSERT_MARKER_BIT(pBitStream) \
{ \
if (get_bits_mpeg4(pBitStream, 1) == 0) { \
return SAMPLE_STATUS_ERR; \
} \
}
#define INSERT_MARKER_BIT(pBitStream) \
{ \
put_bits_mpeg4(pBitStream, 1, 1); \
}
#define CLIP_VIDEO_I(valResult, lowThresh, highThresh) \
{ \
if ((valResult) < (lowThresh)) { \
(valResult) = (lowThresh); \
} else if ((valResult) > (highThresh)) { \
(valResult) = (highThresh); \
} \
}
#define ABS_MP4(x) ((x) < 0 ? -(x) : (x))
/* clip value to [0..255] */
#define CLIP_MP4_8U(x) (Ipp8u)(((x)>255) ? 255 : (((x) < 0) ? 0 : (x)))
/* ========================== Structures Definitions ======================= */
/* structures shared by decoder and encoder */
typedef IppStatus (__STDCALL *copy_block_func_ptr)
(const Ipp8u *, int, Ipp8u *, int, int);
typedef IppStatus (__STDCALL *recon_block_func_ptr)
(const Ipp8u *, int, Ipp16s *, Ipp8u *, int, int);
typedef enum _mp4_vop_type{
IVOP,PVOP,BVOP,SVOP /* BVOP and SVOP are not supported */
} mp4_vop_type;
typedef enum _mp4_shape_type {
RECTANGULAR = 0,
BINARY = 1,
BINARYONLY = 2,
GRAYSCALE = 3
} mp4_shape_type;
typedef enum _mp4_quant_mode {
Q_H263 = 0,
Q_MPEG4 = 1
} mp4_quant_mode;
typedef struct _mp4_tree_node
{ Ipp8u c0_end;
Ipp8u c1_end;
Ipp8s next0_node_symbol;
Ipp8s next1_node_symbol;
} mp4_tree_node;
typedef struct _mp4_table_node
{ unsigned char value;
signed char numbit;
} mp4_table_node;
/* decoder related structures */
typedef struct _mp4_dec_vop_infor {
/* vop level */
int vop_time_inc;
int fcode_fwd;
/* MB level */
int mb_indx;
Ipp8u cur_qp;
int mb_not_coded;
int mb_type;
int intra_dc_vlc;
int ac_pred_flag;
int cbpy;
int cbpc;
sample_spacial_ptrset cur_mb;
sample_spacial_ptrset fwd_ref_mb;
/* Block level */
sample_spacial_ptrset cur_bk;
sample_spacial_ptrset fwd_ref_bk;
/* Buffers */
/* dc and ac prediction row buffer */
sample_spectral_ptrset coef_buf_row;
/* dc and ac prediction colume buffer */
sample_spectral_ptrset coef_buf_col;
/* motion vector buffer */
IppMotionVector *mv_buf;
/* transparent infor buffer */
Ipp8u *tranp_buf;
/* quantiser buffer */
Ipp8u *qp_buf;
/* function pointer for motion compensation and reconstruction */
recon_block_func_ptr recon_block_func_ptrer;
copy_block_func_ptr copy_block_func_ptrer;
} mp4_dec_vop_infor;
typedef struct _mp4_dec_state {
int vol_verid; /* video object layer version identification */
int vol_prior; /* video object layer priority */
int short_head; /* MPEG-4 short header stream or not */
int vop_indx; /* Index of VOP */
int vol_typeid; /* video object type identification */
int vol_shape_type; /* video object layer shape type */
int vop_coding_type; /* VOP coding type, eg. I-VOP,P-VOP,B-VOP */
int vol_control_para; /* VOL control parameters included or not */
int chroma_fmt; /* chrominance format */
int low_delay; /* Low Delay chosen or not */
int bit_rate; /* Bit Rate */
int vbv_buf_size; /* VBV Buffer Size */
int vbv_occupancy; /* VBV Occupancy */
int fix_vop_rate; /* Fixed VOP rate */
int interlaced; /* Interlaced mode chosen */
int obmc_disabled; /* Overlapped Block Motion Compensation disabled or
// not */
int scalable; /* Scalable or not */
int sprite_type; /* Sprite Type */
int sadct_disabled; /* shape adaptive DCT disable or not */
int resync_disabled; /* Error resillience Resync mode disable or not */
int data_patitioned; /* Error resillience Data Partition mode enable or
// not */
int new_pred; /* NEWPRED mode enable or not */
int reduced_resolution; /* Reduced resolution VOP tool enable or not */
int complex_est_disable;/* Complexity estimation header disable or not */
int clock_rate; /* VOP time increment resolution */
int numbits_time_incr; /* VOP time increment */
int quater_sample; /* Quarter sample mode selected or not */
int quant_type; /* Quantisation mode */
Ipp8u* qmatrix_intra; /* Pointer to Luminance/Chrominance Intra
// Quantisation Matrix */
Ipp8u* qmatrix_inter; /* Pointer to Luminance/Chrominance Inter
// Quantisation Matrix */
Ipp8u qmatrix_intra_tbl[64]; /* Matrix contain Luminance/Chrominance
// Intra Quantisation from stream */
Ipp8u qmatrix_inter_tbl[64]; /* Matrix contain Luminance/Chrominance
// Inter Quantisation from stream */
int vop_coded; /* VOP coded or not */
int vol_display_width; /* Display width */
int vol_display_height; /* Display height */
int mb_per_row; /* Number of MacroBlock per Row in current VOP */
int mb_per_col; /* Number of MacroBlock per Col in current VOP */
sample_step_set frame_step_set;
sample_dimension frame_dimension;
sample_spacial_ptrset cur_frame; /* Pointer set of current frame */
sample_spacial_ptrset fwd_ref_frame; /* Pointer set of forward reference
// frame */
int cur_frame_no; /* Current referrence frame number,
// used in B-VOP */
int modulo_base_disp; /* Current displayed frame number */
int modulo_base_decd; /* Current decoded frame number */
int hour; /* Time code Hour in Group of VOP header */
int minute; /* Time code Minute in Group of VOP header */
int second; /* Time code Second in Group of VOP header */
int closed_gov; /* Nature of prediction in B-VOP when GOV
// supported */
int broken_link; /* Broken Link */
sample_spectral_ptrset coef_buf_row;/* Row Buffer for Coefficients */
sample_spectral_ptrset coef_buf_col;/* Column Buffer for Coefficients */
IppMotionVector *mv_buf;/* Pointer to forward motion vector buffer */
Ipp8u *tranp_buf; /* Pointer to transparent buffer */
Ipp8u *qp_buf; /* Pointer to Luminance/Chrominance quantisation
// parameter buffer */
sample_picture *info_pic; /* Pointer to picture display information */
int intra_dc_thr; /* Intra DC VLC threshold */
int rounding; /* rounding 0 or 1 */
Ipp8u vop_quant; /* VOP Luminance/Chrominance quantisation
// parameter */
} mp4_dec_state;
/* encoder related structures */
typedef struct _mp4_enc_vop_infor {
/* vop level */
int vop_time_inc;
int fcode_fwd;
int cr_disabled;
/* MB level */
int mb_indx;
Ipp8u cur_qp;
Ipp8u delta_qp;
int mb_not_coded;
int mb_type;
int intra_dc_vlc;
int ac_pred_flag;
int cbpy;
int cbpc;
sample_spacial_ptrset cur_mb;
sample_spacial_ptrset fwd_ref_mb; /* reconstructed macroblock*/
sample_spacial_ptrset rec_mb;
sample_spacial_ptrset fwd_ref_rec_mb; /* ref-reconstructed macroblock */
/* block level */
sample_spacial_ptrset cur_bk;
sample_spacial_ptrset fwd_ref_bk;
sample_spacial_ptrset rec_bk; /* reconstructed block */
sample_spacial_ptrset fwd_ref_rec_bk; /* ref-reconstructed block*/
/* buffers */
/* dc and ac prediction row buffer */
sample_spectral_ptrset coef_buf_row;
/* dc and ac prediction colume buffer */
sample_spectral_ptrset coef_buf_col;
/* motion vector buffer */
IppMotionVector *mv_buf;
/* transparent infor buffer */
Ipp8u *tranp_buf;
/* quantiser buffer */
Ipp8u *qp_buf;
/* prediction direction of each block in one MB */
Ipp8u pred_dir_buf[6];
/* pattern information of each block in one MB */
Ipp8u pattern_buf[6];
/* function pointer for motion compensation */
copy_block_func_ptr copy_block_func_ptrer;
/* point Information used in Motion Estimation */
IppCoordinate cur_point;
IppCoordinate ref_point;
int num_non_trans_blk;
} mp4_enc_vop_infor;
typedef struct _mp4_enc_state {
int vol_verid; /* video object layer version identification */
int vol_prior; /* video object layer priority */
int short_head; /* MPEG-4 short header stream or not */
int vop_indx; /* Index of VOP */
int vol_typeid; /* video object type identification */
int vol_shape_type; /* video object layer shape type */
int vop_coding_type; /* VOP coding type, eg. I-VOP,P-VOP,B-VOP */
int vol_control_para;/* VOL control parameters included or not */
int chroma_fmt; /* chrominance format */
int low_delay; /* Low Delay chosen or not */
int bit_rate; /* Bit Rate */
int vbv_buf_size; /* VBV Buffer Size */
int vbv_occupancy; /* VBV Occupancy */
int fix_vop_rate; /* Fixed VOP rate */
int interlaced; /* Interlaced mode chosen */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -