diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-10-04 17:20:42 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-10-04 17:20:42 +0200 |
commit | 1e4da6031ca8784448a8fec15ec108d44c57d41d (patch) | |
tree | 2240798988b19c05843011ed6aa635bf25c872b2 /libavfilter | |
parent | 171a5b5d36a7e45c05c80a0147484a741b37e0eb (diff) | |
download | ffmpeg-1e4da6031ca8784448a8fec15ec108d44c57d41d.tar.gz |
deshake: Allow specifying the filename for statistics and disable them by default.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_deshake.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index b8206e6325..d010389e4c 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -78,6 +78,7 @@ typedef struct { } Transform; typedef struct { + AVClass av_class; AVFilterBufferRef *ref; ///< Previous frame int rx; ///< Maximum horizontal shift int ry; ///< Maximum vertical shift @@ -331,6 +332,7 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2, static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) { DeshakeContext *deshake = ctx->priv; + char filename[256]={0}; deshake->rx = 16; deshake->ry = 16; @@ -339,12 +341,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) deshake->contrast = 125; deshake->search = EXHAUSTIVE; deshake->refcount = 20; - deshake->fp = fopen("stats.txt", "w"); - fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", sizeof(char), 104, deshake->fp); if (args) { - sscanf(args, "%d:%d:%d:%d:%d:%d", &deshake->rx, &deshake->ry, (int *)&deshake->edge, - &deshake->blocksize, &deshake->contrast, (int *)&deshake->search); + sscanf(args, "%d:%d:%d:%d:%d:%d:%255s", &deshake->rx, &deshake->ry, (int *)&deshake->edge, + &deshake->blocksize, &deshake->contrast, (int *)&deshake->search, filename); deshake->blocksize /= 2; @@ -355,6 +355,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) deshake->contrast = av_clip(deshake->contrast, 1, 255); deshake->search = av_clip(deshake->search, EXHAUSTIVE, SEARCH_COUNT - 1); } + if(strlen(filename)) + deshake->fp = fopen(filename, "w"); + if(deshake->fp) + fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", sizeof(char), 104, deshake->fp); av_log(ctx, AV_LOG_INFO, "rx: %d, ry: %d, edge: %d blocksize: %d contrast: %d search: %d\n", deshake->rx, deshake->ry, deshake->edge, deshake->blocksize * 2, deshake->contrast, deshake->search); @@ -396,7 +400,8 @@ static av_cold void uninit(AVFilterContext *ctx) DeshakeContext *deshake = ctx->priv; avfilter_unref_buffer(deshake->ref); - fclose(deshake->fp); + if(deshake->fp) + fclose(deshake->fp); } static void end_frame(AVFilterLink *link) @@ -438,8 +443,10 @@ static void end_frame(AVFilterLink *link) t.angle *= -1; // Write statistics to file - snprintf(tmp, 256, "%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", orig.vector.x, deshake->avg.vector.x, t.vector.x, orig.vector.y, deshake->avg.vector.y, t.vector.y, orig.angle, deshake->avg.angle, t.angle, orig.zoom, deshake->avg.zoom, t.zoom); - fwrite(tmp, sizeof(char), strlen(tmp), deshake->fp); + if(deshake->fp){ + snprintf(tmp, 256, "%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", orig.vector.x, deshake->avg.vector.x, t.vector.x, orig.vector.y, deshake->avg.vector.y, t.vector.y, orig.angle, deshake->avg.angle, t.angle, orig.zoom, deshake->avg.zoom, t.zoom); + fwrite(tmp, sizeof(char), strlen(tmp), deshake->fp); + } // Turn relative current frame motion into absolute by adding it to the // last absolute motion |