📄 umc_h264_npf.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) 2004 - 2005 Intel Corporation. All Rights Reserved.//// This file defines the CNoiseReductionFilter class that encapsulates a// noise reduction spatio-temporal filter.#include "umc_h264_pub.h"#ifndef NOISEPF_H__#define NOISEPF_H__namespace UMC{// Bit masks indicating the operation modes of the noise reduction// filter. There are currently two modes available: impulse noise// reduction (INR), noisy edge removal (NER), and temporal noise// reduction (TNR).const Ipp32u H264_Noise_Reduction_INR_Mode = 0x01;const Ipp32u H264_Noise_Reduction_NER_Mode = 0x02;const Ipp32u H264_Noise_Reduction_TNR_Mode = 0x04;// Upper and lower limits on threshold settings#define H264_Noise_Reduction_Min_Thres 0#define H264_Noise_Reduction_Max_Thres 256#define H264_Noise_Reduction_Max_Thres_TF 128// Structure that contains the noise reduction filter options.// Note that these options are not currently exposed to end users.// They are intended for developers, for purposes of tuning the filter.// Thus we have the freedom to change this interface as needed.typedef struct{ bool y; // Filter y plane? bool u; // Filter u plane? bool v; // Filter v plane? bool mf_simple; // Apply simplified median filter? Ipp32u mf_thres_s; // Median filter spatial diff threshold Ipp32u mf_thres_t; // Median filter temporal diff threshold Ipp32u tf_thres1; // Temporal filter threshold 1 Ipp32u tf_thres2; // Temporal filter threshold 2 Ipp32u tf_thres3; // Temporal filter threshold 3} H264_Noise_Reduction_Options;// The H264_I_Noise_Reduction interface defines the interface that// controls the underlying prefilter. Only this interface, not the// filter implementation, are exposed to the controlling entity.class H264_I_Noise_Reduction{public: // Enable or disable the noise reduction filter // Set enable to true to enable, false to disable. // Return true if successful, else false. virtual bool EnableNoiseReduction(const bool enable) = 0; // Determine whether noise reduction is on, or on by default. virtual bool IsNoiseReductionEnabled() = 0; virtual bool IsNoiseReductionEnabledByDefault() = 0; // Set the noise reduction filter operation mode by ORing the // flags specified above. For example, to select both the impulse // noise reduction and the noisy edge removal, pass in the parameter // as (H264_Noise_Reduction_INR_Mode | H264_Noise_Reduction_INR_Mode). // Return true if successful, else false. virtual bool PutNoiseReductionMode(const Ipp32u mode) = 0; // Get the current/default noise reduction filter operation mode. virtual Ipp32u GetNoiseReductionMode() = 0; virtual Ipp32u GetDefaultNoiseReductionMode() = 0; // Replace the current noise reduction options with what are given // in the parameter opt. virtual void PutNoiseReductionOptions( const H264_Noise_Reduction_Options& opt) = 0; // Get the current/default noise reduction options into opt. virtual void GetNoiseReductionOptions( H264_Noise_Reduction_Options& opt) = 0; virtual void GetDefaultNoiseReductionOptions( H264_Noise_Reduction_Options& opt) = 0; // Perform noise reduction filtering // Return true if succeeded, false if failed // x: pointer to the input buffer (IYUV/I420 format) // y: pointer to the output buffer (IYUV/I420 format) // w: picture width // h: picture height virtual bool DoFiltering( Ipp8u* y, Ipp8u* u, Ipp8u* v, Ipp32u y_pitch, Ipp32u uv_pitch, Ipp32u width, Ipp32u height) = 0; // Start_Sequence informs the filter that a new video sequence is // about to be filtered. It thus forgets about any state it may // have maintained. virtual bool Start_Sequence(const Ipp32u width, const Ipp32u height) = 0;};#define H264_DECLARE_H264_I_Noise_Reduction \ virtual bool EnableNoiseReduction(const bool); \ virtual bool IsNoiseReductionEnabled(); \ virtual bool IsNoiseReductionEnabledByDefault(); \ virtual bool PutNoiseReductionMode(const Ipp32u mode); \ virtual Ipp32u GetNoiseReductionMode(); \ virtual Ipp32u GetDefaultNoiseReductionMode(); \ virtual void GetNoiseReductionOptions(H264_Noise_Reduction_Options&); \ virtual void PutNoiseReductionOptions(const H264_Noise_Reduction_Options&); \ virtual void GetDefaultNoiseReductionOptions(H264_Noise_Reduction_Options&); \ virtual bool DoFiltering(Ipp8u* y, Ipp8u* u, Ipp8u* v, Ipp32u y_pitch, Ipp32u uv_pitch, Ipp32u width, Ipp32u height); \ virtual bool Start_Sequence(const Ipp32u, const Ipp32u)// Noise reduction filter classclass CNoiseReductionFilter : public H264_I_Noise_Reduction{public: // Constructor CNoiseReductionFilter( const bool bIsMMX, const bool bIsKNI, const bool bIs7BitPel); // Destructor virtual ~CNoiseReductionFilter(); // Support H264_I_Noise_Reduction interface H264_DECLARE_H264_I_Noise_Reduction;private: // Update data used by the MMX routine with the current options void UpdateAndScaleThresholds(); // Check local buffer bool CheckBuffer( const Ipp32u y_pitch, const Ipp32u uv_pitch, const Ipp32u width, const Ipp32u height); // Calls setup to filter a single plane void FilterPlane( Ipp8u* x, Ipp8u* xp, const Ipp32u pitch, const Ipp32u width, const Ipp32u height); // Perform spatio-temporal filtering void SpatioTemporalFilter( Ipp8u* y, Ipp8u* yp, const Ipp32u pitch, const Ipp32u width, const Ipp32u height); // Perform median filtering Ipp8u MedianFilter( Ipp8u* y, const Ipp32u pitch, const Ipp32u k); // Sort 5 points static void Sort5( Ipp8u* v); // General sorting static void Sort( Ipp8u* v, const Ipp32u n); // Perform weighted average temporal filtering Ipp32u WeightedAvg( register Ipp32u x, register Ipp32u y); // Detect and replace noisy edges along the borders void RemoveNoisyEdges( Ipp8u* y, Ipp8u* u, Ipp8u* v, const Ipp32u y_pitch, const Ipp32u uv_pitch, const Ipp32u width, const Ipp32u height); // Perform temporal filtering void TemporalFilter( Ipp8u* y, Ipp8u* yp, const Ipp32u pitch, const Ipp32u width, const Ipp32u height); // Variables H264_Noise_Reduction_Options m_options; // Filter options bool m_bEnabled; // Filter enabled? bool m_b7BitPel; // 7-bit pel flag bool m_bFirstFrame; // First frame flag bool m_bFirstFrame_MF; // Median filter first frame flag bool m_bIsMMX; // MMX flag Ipp32u m_uMode; // Filter mode (bitmask) Ipp32u m_uBadEdge_Top; // Number of bad rows on top Ipp32u m_uBadEdge_Left; // Number of bad cols to the left Ipp32u m_uBadEdge_Bottom; // Number of bad rows at the bottom Ipp8u* m_pLocalBuffer; // Pointer to pre-aligned buffer Ipp32u m_uLocalBufferSize; // Buffer size Ipp8s* m_pTFtaps; // Pointer to temporal filter taps Ipp8s* m_pTFtapsBuffer; // Pointer to pre-aligned filter taps Ipp8u* m_pLastFrame; // Pointer to previous frame buffer Ipp8u* m_pLastFrameY; // Pointer to previous frame Y buffer Ipp8u* m_pLastFrameU; // Pointer to previous frame U buffer Ipp8u* m_pLastFrameV; // Pointer to previous frame V buffer // Scaled thresholds Ipp32u m_mf_thres_s; // Median flt spatial diff threshold Ipp32u m_mf_thres_t; // Median flt temporal diff threshold Ipp32u m_tf_thres1; // Temporal flt threshold 1 Ipp32u m_tf_thres2; // Temporal flt threshold 2 Ipp32u m_tf_thres3; // Temporal flt threshold 3}; // CNoiseReductionFilter} //namespace UMC#endif // NOISEPF_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -