2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-28 23:39:31 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef VPM_CONTENT_ANALYSIS_H
|
|
|
|
|
#define VPM_CONTENT_ANALYSIS_H
|
|
|
|
|
|
2013-05-27 14:12:16 +00:00
|
|
|
#include "webrtc/common_video/interface/i420_video_frame.h"
|
|
|
|
|
#include "webrtc/modules/interface/module_common_types.h"
|
|
|
|
|
#include "webrtc/modules/video_processing/main/interface/video_processing_defines.h"
|
|
|
|
|
#include "webrtc/typedefs.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class VPMContentAnalysis
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-01-13 19:43:09 +00:00
|
|
|
// When |runtime_cpu_detection| is true, runtime selection of an optimized
|
|
|
|
|
// code path is allowed.
|
|
|
|
|
VPMContentAnalysis(bool runtime_cpu_detection);
|
2011-07-07 08:21:25 +00:00
|
|
|
~VPMContentAnalysis();
|
|
|
|
|
|
2011-08-15 15:56:23 +00:00
|
|
|
// Initialize ContentAnalysis - should be called prior to
|
|
|
|
|
// extractContentFeature
|
|
|
|
|
// Inputs: width, height
|
|
|
|
|
// Return value: 0 if OK, negative value upon error
|
2013-04-09 13:38:10 +00:00
|
|
|
int32_t Initialize(int width, int height);
|
2011-08-15 15:56:23 +00:00
|
|
|
|
|
|
|
|
// Extract content Feature - main function of ContentAnalysis
|
|
|
|
|
// Input: new frame
|
|
|
|
|
// Return value: pointer to structure containing content Analysis
|
|
|
|
|
// metrics or NULL value upon error
|
2012-10-24 18:33:04 +00:00
|
|
|
VideoContentMetrics* ComputeContentMetrics(const I420VideoFrame&
|
|
|
|
|
inputFrame);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-08-15 15:56:23 +00:00
|
|
|
// Release all allocated memory
|
|
|
|
|
// Output: 0 if OK, negative value upon error
|
2013-04-09 13:38:10 +00:00
|
|
|
int32_t Release();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2011-08-15 15:56:23 +00:00
|
|
|
// return motion metrics
|
2011-07-07 08:21:25 +00:00
|
|
|
VideoContentMetrics* ContentMetrics();
|
|
|
|
|
|
2011-08-15 15:56:23 +00:00
|
|
|
// Normalized temporal difference metric: for motion magnitude
|
2013-04-09 13:38:10 +00:00
|
|
|
typedef int32_t (VPMContentAnalysis::*TemporalDiffMetricFunc)();
|
2011-08-17 22:23:28 +00:00
|
|
|
TemporalDiffMetricFunc TemporalDiffMetric;
|
2013-04-09 13:38:10 +00:00
|
|
|
int32_t TemporalDiffMetric_C();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-08-15 15:56:23 +00:00
|
|
|
// Motion metric method: call 2 metrics (magnitude and size)
|
2013-04-09 13:38:10 +00:00
|
|
|
int32_t ComputeMotionMetrics();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-08-15 15:56:23 +00:00
|
|
|
// Spatial metric method: computes the 3 frame-average spatial
|
|
|
|
|
// prediction errors (1x2,2x1,2x2)
|
2013-04-09 13:38:10 +00:00
|
|
|
typedef int32_t (VPMContentAnalysis::*ComputeSpatialMetricsFunc)();
|
2011-08-15 15:56:23 +00:00
|
|
|
ComputeSpatialMetricsFunc ComputeSpatialMetrics;
|
2013-04-09 13:38:10 +00:00
|
|
|
int32_t ComputeSpatialMetrics_C();
|
2011-08-17 22:23:28 +00:00
|
|
|
|
2012-01-13 19:43:09 +00:00
|
|
|
#if defined(WEBRTC_ARCH_X86_FAMILY)
|
2013-04-09 13:38:10 +00:00
|
|
|
int32_t ComputeSpatialMetrics_SSE2();
|
|
|
|
|
int32_t TemporalDiffMetric_SSE2();
|
2011-08-15 15:56:23 +00:00
|
|
|
#endif
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-09 13:38:10 +00:00
|
|
|
const uint8_t* _origFrame;
|
|
|
|
|
uint8_t* _prevFrame;
|
2012-04-27 15:56:02 +00:00
|
|
|
int _width;
|
|
|
|
|
int _height;
|
|
|
|
|
int _skipNum;
|
|
|
|
|
int _border;
|
2011-08-15 15:56:23 +00:00
|
|
|
|
|
|
|
|
// Content Metrics:
|
|
|
|
|
// stores the local average of the metrics
|
2012-02-28 23:39:31 +00:00
|
|
|
float _motionMagnitude; // motion class
|
2011-08-15 15:56:23 +00:00
|
|
|
float _spatialPredErr; // spatial class
|
|
|
|
|
float _spatialPredErrH; // spatial class
|
|
|
|
|
float _spatialPredErrV; // spatial class
|
2011-07-07 08:21:25 +00:00
|
|
|
bool _firstFrame;
|
|
|
|
|
bool _CAInit;
|
2011-08-15 15:56:23 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
VideoContentMetrics* _cMetrics;
|
|
|
|
|
|
|
|
|
|
}; // end of VPMContentAnalysis class definition
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#endif
|