Commit ca2b450c authored by Michael Niedermayer's avatar Michael Niedermayer

vf_idet: use enum to represent the type.

This will simplify future code.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent bd603494
...@@ -26,14 +26,19 @@ ...@@ -26,14 +26,19 @@
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
typedef enum {
TFF,
BFF,
PROGRSSIVE,
UNDETERMINED,
} Type;
typedef struct { typedef struct {
float interlace_threshold; float interlace_threshold;
float progressive_threshold; float progressive_threshold;
int stat_tff;
int stat_bff; Type prestat[4];
int stat_progressive;
int stat_undetermined;
AVFilterBufferRef *cur; AVFilterBufferRef *cur;
AVFilterBufferRef *next; AVFilterBufferRef *next;
...@@ -75,6 +80,7 @@ static void filter(AVFilterContext *ctx) ...@@ -75,6 +80,7 @@ static void filter(AVFilterContext *ctx)
int y, i; int y, i;
int64_t alpha[2]={0}; int64_t alpha[2]={0};
int64_t delta=0; int64_t delta=0;
Type type;
for (i = 0; i < idet->csp->nb_components; i++) { for (i = 0; i < idet->csp->nb_components; i++) {
int w = idet->cur->video->w; int w = idet->cur->video->w;
...@@ -101,22 +107,30 @@ static void filter(AVFilterContext *ctx) ...@@ -101,22 +107,30 @@ static void filter(AVFilterContext *ctx)
#endif #endif
if (alpha[0] / (float)alpha[1] > idet->interlace_threshold){ if (alpha[0] / (float)alpha[1] > idet->interlace_threshold){
type = TFF;
}else if(alpha[1] / (float)alpha[0] > idet->interlace_threshold){
type = BFF;
}else if(alpha[1] / (float)delta > idet->progressive_threshold){
type = PROGRSSIVE;
}else{
type = UNDETERMINED;
}
idet->prestat[type] ++;
if (type == TFF){
av_log(ctx, AV_LOG_INFO, "Interlaced, top field first\n"); av_log(ctx, AV_LOG_INFO, "Interlaced, top field first\n");
idet->stat_tff++;
idet->cur->video->top_field_first = 1; idet->cur->video->top_field_first = 1;
idet->cur->video->interlaced = 1; idet->cur->video->interlaced = 1;
}else if(alpha[1] / (float)alpha[0] > idet->interlace_threshold){ }else if(type == BFF){
av_log(ctx, AV_LOG_INFO, "Interlaced, bottom field first\n"); av_log(ctx, AV_LOG_INFO, "Interlaced, bottom field first\n");
idet->stat_bff++;
idet->cur->video->top_field_first = 0; idet->cur->video->top_field_first = 0;
idet->cur->video->interlaced = 1; idet->cur->video->interlaced = 1;
}else if(alpha[1] / (float)delta > idet->progressive_threshold){ }else if(type == PROGRSSIVE){
av_log(ctx, AV_LOG_INFO, "Progressive\n"); av_log(ctx, AV_LOG_INFO, "Progressive\n");
idet->stat_progressive++;
idet->cur->video->interlaced = 0; idet->cur->video->interlaced = 0;
}else{ }else{
av_log(ctx, AV_LOG_INFO, "Undetermined\n"); av_log(ctx, AV_LOG_INFO, "Undetermined\n");
idet->stat_undetermined++;
idet->cur->video->interlaced = idet->prev->video->interlaced; idet->cur->video->interlaced = idet->prev->video->interlaced;
idet->cur->video->top_field_first = idet->prev->video->top_field_first; idet->cur->video->top_field_first = idet->prev->video->top_field_first;
} }
...@@ -198,10 +212,10 @@ static av_cold void uninit(AVFilterContext *ctx) ...@@ -198,10 +212,10 @@ static av_cold void uninit(AVFilterContext *ctx)
IDETContext *idet = ctx->priv; IDETContext *idet = ctx->priv;
av_log(ctx, AV_LOG_INFO, "TFF:%d BFF:%d Progressive:%d Undetermined:%d\n", av_log(ctx, AV_LOG_INFO, "TFF:%d BFF:%d Progressive:%d Undetermined:%d\n",
idet->stat_tff, idet->prestat[TFF],
idet->stat_bff, idet->prestat[BFF],
idet->stat_progressive, idet->prestat[PROGRSSIVE],
idet->stat_undetermined idet->prestat[UNDETERMINED]
); );
if (idet->prev) avfilter_unref_buffer(idet->prev); if (idet->prev) avfilter_unref_buffer(idet->prev);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment