History

avfilter/vf_waveform: add option to control strechness of waveform

Paul B Mahol committed 5 years ago

Commit ca788d11 parent e0de0aa2 files · +39 −1Browse files

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/vf_waveform.c+26−1
@@ -36,6 +36,12 @@ typedef struct ThreadData { · 35 unmodified lines
3636 int offset_x;
3737 } ThreadData;
3838
39+enum FitMode {
40+ FM_NONE,
41+ FM_SIZE,
42+ NB_FITMODES
43+};
44+
3945 enum FilterType {
4046 LOWPASS,
4147 FLAT,
@@ -113,6 +119,7 @@ typedef struct WaveformContext { · 71 unmodified lines
113119 int rgb;
114120 float ftint[2];
115121 int tint[2];
122+ int fitmode;
116123
117124 int (*waveform_slice)(AVFilterContext *ctx, void *arg,
118125 int jobnr, int nb_jobs);
@@ -184,6 +191,10 @@ static const AVOption waveform_options[] = { · 65 unmodified lines
184191 { "t0", "set 1st tint", OFFSET(ftint[0]), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS},
185192 { "tint1", "set 2nd tint", OFFSET(ftint[1]), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS},
186193 { "t1", "set 2nd tint", OFFSET(ftint[1]), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS},
194+ { "fitmode", "set fit mode", OFFSET(fitmode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_FITMODES-1, FLAGS, "fitmode" },
195+ { "fm", "set fit mode", OFFSET(fitmode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_FITMODES-1, FLAGS, "fitmode" },
196+ { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_NONE}, 0, 0, FLAGS, "fitmode" },
197+ { "size", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_SIZE}, 0, 0, FLAGS, "fitmode" },
187198 { NULL }
188199 };
189200
@@ -3357,7 +3368,20 @@ static int config_output(AVFilterLink *outlink) · 3167 unmodified lines
33573368 }
33583369 }
33593370
3360− outlink->sample_aspect_ratio = (AVRational){1,1};
3371+ switch (s->fitmode) {
3372+ case FM_NONE:
3373+ outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
3374+ break;
3375+ case FM_SIZE:
3376+ if (s->mode)
3377+ outlink->sample_aspect_ratio = (AVRational){ s->size * comp, inlink->h };
3378+ else
3379+ outlink->sample_aspect_ratio = (AVRational){ inlink->w, s->size * comp };
3380+ break;
3381+ }
3382+
3383+ av_reduce(&outlink->sample_aspect_ratio.num, &outlink->sample_aspect_ratio.den,
3384+ outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den, INT_MAX);
33613385
33623386 return 0;
33633387 }
@@ -3461,6 +3485,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 97 unmodified lines
34613485 s->graticulef(s, out);
34623486
34633487 av_frame_free(&in);
3488+ out->sample_aspect_ratio = outlink->sample_aspect_ratio;
34643489 return ff_filter_frame(outlink, out);
34653490 }
34663491

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t