summaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_idet.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-04-05 08:26:09 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-04-05 09:11:15 +0200
commitfa1f92a4f1c0890e501dcafcea8bc9ed5caa53e5 (patch)
tree750f4b1d56abb594b70120526eb33c9e9044aea5 /libavfilter/vf_idet.c
parentc59e73d2c87314f87449b64488001e3153471f64 (diff)
downloadffmpeg-streaming-fa1f92a4f1c0890e501dcafcea8bc9ed5caa53e5.zip
ffmpeg-streaming-fa1f92a4f1c0890e501dcafcea8bc9ed5caa53e5.tar.gz
vf_idet: clean detected frame types based on a 4 frame history.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_idet.c')
-rw-r--r--libavfilter/vf_idet.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c
index 9cf01e6..9376ee8 100644
--- a/libavfilter/vf_idet.c
+++ b/libavfilter/vf_idet.c
@@ -26,6 +26,8 @@
#undef NDEBUG
#include <assert.h>
+#define HIST_SIZE 4
+
typedef enum {
TFF,
BFF,
@@ -41,6 +43,8 @@ typedef struct {
Type prestat[4];
Type poststat[4];
+ uint8_t history[HIST_SIZE];
+
AVFilterBufferRef *cur;
AVFilterBufferRef *next;
AVFilterBufferRef *prev;
@@ -91,7 +95,8 @@ static void filter(AVFilterContext *ctx)
int y, i;
int64_t alpha[2]={0};
int64_t delta=0;
- Type type;
+ Type type, best_type;
+ int match = 0;
for (i = 0; i < idet->csp->nb_components; i++) {
int w = idet->cur->video->w;
@@ -127,8 +132,27 @@ static void filter(AVFilterContext *ctx)
type = UNDETERMINED;
}
- if (type != UNDETERMINED)
- idet->last_type = type;
+ memmove(idet->history+1, idet->history, HIST_SIZE-1);
+ idet->history[0] = type;
+ best_type = UNDETERMINED;
+ for(i=0; i<HIST_SIZE; i++){
+ if(idet->history[i] != UNDETERMINED){
+ if(best_type == UNDETERMINED)
+ best_type = idet->history[i];
+
+ if(idet->history[i] == best_type) {
+ match++;
+ }else{
+ match=0;
+ break;
+ }
+ }
+ }
+ if(idet->last_type == UNDETERMINED){
+ if(match ) idet->last_type = best_type;
+ }else{
+ if(match>2) idet->last_type = best_type;
+ }
if (idet->last_type == TFF){
idet->cur->video->top_field_first = 1;
@@ -281,6 +305,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
if (args) sscanf(args, "%f:%f", &idet->interlace_threshold, &idet->progressive_threshold);
idet->last_type = UNDETERMINED;
+ memset(idet->history, UNDETERMINED, HIST_SIZE);
idet->filter_line = filter_line_c;
OpenPOWER on IntegriCloud