[FFmpeg-cvslog] doc/filters: Clarify scale2ref example

2017-05-27 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Sat May 27 10:10:46 
2017 -0400| [114e8716214d414d7965029ae5fe74668ed69e4a] | committer: Michael 
Niedermayer

doc/filters: Clarify scale2ref example

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=114e8716214d414d7965029ae5fe74668ed69e4a
---

 doc/filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index a0ab2fb0c7..107fe61447 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12435,7 +12435,7 @@ uses the reference video instead of the main input as 
basis.
 
 @itemize
 @item
-Scale a subtitle stream to match the main video in size before overlaying
+Scale a subtitle stream (b) to match the main video (a) in size before 
overlaying
 @example
 'scale2ref[b][a];[a][b]overlay'
 @end example

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavfilter/scale2ref: Add constants for the primary input

2017-06-01 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Tue May 30 13:34:29 
2017 -0400| [3385989b98be7940044e4f0a6b431a0a00abf2fa] | committer: Michael 
Niedermayer

libavfilter/scale2ref: Add constants for the primary input

Variables pertaining to the main video are now available when
using the scale2ref filter. This allows, as an example, scaling a
video with another as a reference point while maintaining the
original aspect ratio of the primary/non-reference video.

Consider the following graph: scale2ref=iw/6:-1 [main][ref]
This will scale [main] to 1/6 the width of [ref] while maintaining
the aspect ratio. This works well when the AR of [ref] is equal to
the AR of [main] only. What the above filter really does is
maintain the AR of [ref] when scaling [main]. So in all non-same-AR
situations [main] will appear stretched or compressed to conform to
the same AR of the reference video. Without doing this calculation
externally there is no way to scale in reference to another input
while maintaining AR in libavfilter.

To make this possible, we introduce eight new constants to be used
in the w and h expressions only in the scale2ref filter:

 * main_w/main_h: width/height of the main input video
 * main_a: aspect ratio of the main input video
 * main_sar: sample aspect ratio of the main input video
 * main_dar: display aspect ratio of the main input video
 * main_hsub/main_vsub: horiz/vert chroma subsample vals of main
 * mdar: a shorthand alias of main_dar

Of course, not all of these constants are needed for maintaining the
AR, but adding additional constants in line of what is available for
in/out allows for other scaling possibilities I have not imagined.

So to now scale a video to 1/6 the size of another video using the
width and maintaining its own aspect ratio you can do this:

scale2ref=iw/6:ow/mdar [main][ref]

This is ideal for picture-in-picture configurations where you could
have a square or 4:3 video overlaid on a corner of a larger 16:9
feed all while keeping the scaled video in the corner at its correct
aspect ratio and always the same size relative to the larger video.

I've tried to re-use as much code as possible. I could not find a way
to avoid duplication of the var_names array. It must now be kept in
sync with the other (the normal one and the scale2ref one) for
everything to work which does not seem ideal. For every new variable
introduced/removed into/from the normal scale filter one must be
added/removed to/from the scale2ref version. Suggestions on how to
avoid var_names duplication are welcome.

var_values has been increased to always be large enough for the
additional scale2ref variables. I do not forsee this being a problem
as the names variable will always be the correct size. From my
understanding of av_expr_parse_and_eval it will stop processing
variables when it runs out of names even though there may be
additional (potentially uninitialized) entries in the values array.
The ideal solution here would be using a variable-length array but
that is unsupported in C90.

This patch does not remove any functionality and is strictly a
feature patch. There are no API changes. Behavior does not change for
any previously valid inputs.

The applicable documentation has also been updated.

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3385989b98be7940044e4f0a6b431a0a00abf2fa
---

 doc/filters.texi| 26 ++-
 libavfilter/scale.c | 72 ++---
 2 files changed, 93 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 51fb6cdcee..d4fbb5ac9b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12459,7 +12459,31 @@ Supersampling
 Scale (resize) the input video, based on a reference video.
 
 See the scale filter for available options, scale2ref supports the same but
-uses the reference video instead of the main input as basis.
+uses the reference video instead of the main input as basis. scale2ref also
+supports the following additional constants for the @option{w} and
+@option{h} options:
+
+@table @var
+@item main_w
+@item main_h
+The main input video's width and height
+
+@item main_a
+The same as @var{main_w} / @var{main_h}
+
+@item main_sar
+The main input video's sample aspect ratio
+
+@item main_dar, mdar
+The main input video's display aspect ratio. Calculated from
+@code{(main_w / main_h) * main_sar}.
+
+@item main_hsub
+@item main_vsub
+The main input video's horizontal and vertical chroma subsample values.
+For example for the pixel format "yuv422p" @var{hsub} is 2 and @var{vsub}
+is 1.
+@end table
 
 @subsection Examples
 
diff --git a/libavfilter/scale.c b/libavfilter/scale.c
index 50cd442849..e3a2fb5923 100644
--- a/libavfilter/scale.c
+++ b/libavfilter/scale.c
@@ -60,6 +60,49 @@ enum var_name {
 VARS_NB
 };
 
+/**
+ * This must be kept in sync with var_names so that it is a

[FFmpeg-cvslog] doc/filters: Clarify scale2ref example

2017-06-01 Thread Kevin Mark
ffmpeg | branch: release/3.3 | Kevin Mark  | Sat May 27 
10:10:46 2017 -0400| [573e40e8f1c3b6aabd4e60520e3c6e7a72a7c629] | committer: 
Michael Niedermayer

doc/filters: Clarify scale2ref example

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 114e8716214d414d7965029ae5fe74668ed69e4a)
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=573e40e8f1c3b6aabd4e60520e3c6e7a72a7c629
---

 doc/filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 8e5e21f9ed..b1e063f63b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12077,7 +12077,7 @@ uses the reference video instead of the main input as 
basis.
 
 @itemize
 @item
-Scale a subtitle stream to match the main video in size before overlaying
+Scale a subtitle stream (b) to match the main video (a) in size before 
overlaying
 @example
 'scale2ref[b][a];[a][b]overlay'
 @end example

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavfilter/scale2ref: Fix out-of-bounds array access

2017-06-03 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Sat Jun  3 05:04:19 
2017 -0400| [08213e0b7974b7e75d9031d6e448be49a494c0a1] | committer: Michael 
Niedermayer

libavfilter/scale2ref: Fix out-of-bounds array access

ff_scale_eval_dimensions blindly assumes that two inputs are always
available as of 3385989b98be7940044e4f0a6b431a0a00abf2fa. This is
notably not the case when the function is called for the scale
filter. With the scale filter inputs[1] does not exist.

ff_scale_eval_dimensions now has an updated scale2ref check that
makes certain two inputs are actually available before attempting to
access the second one.

Thanks to James Almer for reporting this bug. This should fix the 820
Valgrind tests I single-handedly managed to break.

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08213e0b7974b7e75d9031d6e448be49a494c0a1
---

 libavfilter/scale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/scale.c b/libavfilter/scale.c
index e3a2fb5923..03745ddcb8 100644
--- a/libavfilter/scale.c
+++ b/libavfilter/scale.c
@@ -115,7 +115,7 @@ int ff_scale_eval_dimensions(void *log_ctx,
 int factor_w, factor_h;
 int eval_w, eval_h;
 int ret;
-const char scale2ref = outlink->src->inputs[1] == inlink;
+const char scale2ref = outlink->src->nb_inputs == 2 && 
outlink->src->inputs[1] == inlink;
 double var_values[VARS_NB + VARS_S2R_NB], res;
 const AVPixFmtDescriptor *main_desc;
 const AVFilterLink *main_link;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] FATE: Add test for libavfilter/scale2ref

2017-06-04 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Sun Jun  4 03:53:31 
2017 -0400| [4af496473a0684b798d5712d8c96357e9b036b43] | committer: Michael 
Niedermayer

FATE: Add test for libavfilter/scale2ref

This new FATE test for the scale2ref filter makes use of the recently
added scale2ref-specific variables to maintain the aspect ratio of a
test input.

Filtergraph explanation:
[main] has an AR of 4:3. [ref] has an AR of 16:9.
640 / 4 = 160. So the new width for [main] is 160.
160 / ((320 / 240) * (1 / 1)) = 160 / (4 / 3) = 120. So the new
height for [main] is 120.
160 / 120 = 4 / 3 so [main]'s aspect ratio has been maintained while
using [ref]'s width as a reference point.

[ref] is nullsink'd since it is left unchanged by scale2ref (and so
shouldn't need to be tested).

If we were to use "iw/4:-1" in place of "iw/4:ow/mdar":
640 / 4 = 160. So the new width for [main] would be 160.
360 / 4 = 90. So the new height for [main] would be 90.
160 / 90 = 16 / 9 so [main] now has the same aspect ratio as [ref]
which is probably what you do not want.

This is currently the only test for scale2ref.

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4af496473a0684b798d5712d8c96357e9b036b43
---

 tests/fate/filter-video.mak |  4 
 tests/filtergraphs/scale2ref_keep_aspect|  5 +
 tests/ref/fate/filter-scale2ref_keep_aspect | 14 ++
 3 files changed, 23 insertions(+)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 1ca29e8d32..53fc7a6528 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -413,6 +413,10 @@ fate-filter-scale200: CMD = video_filter 
"scale=w=200:h=200"
 FATE_FILTER_VSYNTH-$(CONFIG_SCALE_FILTER) += fate-filter-scale500
 fate-filter-scale500: CMD = video_filter "scale=w=500:h=500"
 
+FATE_FILTER_VSYNTH-$(CONFIG_SCALE2REF_FILTER) += 
fate-filter-scale2ref_keep_aspect
+fate-filter-scale2ref_keep_aspect: 
tests/data/filtergraphs/scale2ref_keep_aspect
+fate-filter-scale2ref_keep_aspect: CMD = framemd5 -frames:v 5 
-filter_complex_script 
$(TARGET_PATH)/tests/data/filtergraphs/scale2ref_keep_aspect -map "[main]"
+
 FATE_FILTER_VSYNTH-$(CONFIG_SCALE_FILTER) += fate-filter-scalechroma
 fate-filter-scalechroma: tests/data/vsynth1.yuv
 fate-filter-scalechroma: CMD = framecrc -flags bitexact -s 352x288 -pix_fmt 
yuv444p -i tests/data/vsynth1.yuv -pix_fmt yuv420p -sws_flags +bitexact -vf 
scale=out_v_chr_pos=33:out_h_chr_pos=151
diff --git a/tests/filtergraphs/scale2ref_keep_aspect 
b/tests/filtergraphs/scale2ref_keep_aspect
new file mode 100644
index 00..f407460ec7
--- /dev/null
+++ b/tests/filtergraphs/scale2ref_keep_aspect
@@ -0,0 +1,5 @@
+sws_flags=+accurate_rnd+bitexact;
+testsrc=size=320x240 [main];
+testsrc=size=640x360 [ref];
+[main][ref] scale2ref=iw/4:ow/mdar [main][ref];
+[ref] nullsink
diff --git a/tests/ref/fate/filter-scale2ref_keep_aspect 
b/tests/ref/fate/filter-scale2ref_keep_aspect
new file mode 100644
index 00..ca03277446
--- /dev/null
+++ b/tests/ref/fate/filter-scale2ref_keep_aspect
@@ -0,0 +1,14 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 160x120
+#sar 0: 4/3
+#stream#, dts,pts, duration, size, hash
+0,  0,  0,1,57600, 9a19c23dc3a557786840d0098606d5f1
+0,  1,  1,1,57600, e6fbdabaf1bb0d28afc648ed4d27e9f0
+0,  2,  2,1,57600, 52924ed0a751214c50fb2e7a626c8cc5
+0,  3,  3,1,57600, 67d5fd6ee71793f1cf8794d1c27afdce
+0,  4,  4,1,57600, 85f7775f7b01afd369fc8919dc759d30

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] doc/filters: Clarify scale2ref example

2017-06-05 Thread Kevin Mark
ffmpeg | branch: release/2.8 | Kevin Mark  | Sat May 27 
10:10:46 2017 -0400| [fde04ca718003206667716cb7a39479030efadd9] | committer: 
Michael Niedermayer

doc/filters: Clarify scale2ref example

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 114e8716214d414d7965029ae5fe74668ed69e4a)
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fde04ca718003206667716cb7a39479030efadd9
---

 doc/filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 2a2fab61a0..410608e258 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -9206,7 +9206,7 @@ uses the reference video instead of the main input as 
basis.
 
 @itemize
 @item
-Scale a subtitle stream to match the main video in size before overlaying
+Scale a subtitle stream (b) to match the main video (a) in size before 
overlaying
 @example
 'scale2ref[b][a];[a][b]overlay'
 @end example

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavutil/eval: Add round function to expression parser

2017-06-06 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Tue Jun  6 00:43:13 
2017 -0400| [482566ccc3fdcdbaf0f1e78309bf8ea9ddbce66b] | committer: Michael 
Niedermayer

libavutil/eval: Add round function to expression parser

We have floor, ceil, and trunc. Let's add round.

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=482566ccc3fdcdbaf0f1e78309bf8ea9ddbce66b
---

 doc/utils.texi   | 3 +++
 libavutil/eval.c | 5 -
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/doc/utils.texi b/doc/utils.texi
index 1734439459..d65bdf0b0e 100644
--- a/doc/utils.texi
+++ b/doc/utils.texi
@@ -914,6 +914,9 @@ various input values that the expression can access through
 @code{ld(0)}. When the expression evaluates to 0 then the
 corresponding input value will be returned.
 
+@item round(expr)
+Round the value of expression @var{expr} to the nearest integer. For example, 
"round(1.5)" is "2.0".
+
 @item sin(x)
 Compute sine of @var{x}.
 
diff --git a/libavutil/eval.c b/libavutil/eval.c
index 7e866155db..638259adef 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -153,7 +153,7 @@ struct AVExpr {
 e_squish, e_gauss, e_ld, e_isnan, e_isinf,
 e_mod, e_max, e_min, e_eq, e_gt, e_gte, e_lte, e_lt,
 e_pow, e_mul, e_div, e_add,
-e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc,
+e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc, 
e_round,
 e_sqrt, e_not, e_random, e_hypot, e_gcd,
 e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip, e_atan2
 } type;
@@ -189,6 +189,7 @@ static double eval_expr(Parser *p, AVExpr *e)
 case e_floor:  return e->value * floor(eval_expr(p, e->param[0]));
 case e_ceil :  return e->value * ceil (eval_expr(p, e->param[0]));
 case e_trunc:  return e->value * trunc(eval_expr(p, e->param[0]));
+case e_round:  return e->value * round(eval_expr(p, e->param[0]));
 case e_sqrt:   return e->value * sqrt (eval_expr(p, e->param[0]));
 case e_not:return e->value * (eval_expr(p, e->param[0]) == 0);
 case e_if: return e->value * (eval_expr(p, e->param[0]) ? 
eval_expr(p, e->param[1]) :
@@ -440,6 +441,7 @@ static int parse_primary(AVExpr **e, Parser *p)
 else if (strmatch(next, "floor" )) d->type = e_floor;
 else if (strmatch(next, "ceil"  )) d->type = e_ceil;
 else if (strmatch(next, "trunc" )) d->type = e_trunc;
+else if (strmatch(next, "round" )) d->type = e_round;
 else if (strmatch(next, "sqrt"  )) d->type = e_sqrt;
 else if (strmatch(next, "not"   )) d->type = e_not;
 else if (strmatch(next, "pow"   )) d->type = e_pow;
@@ -637,6 +639,7 @@ static int verify_expr(AVExpr *e)
 case e_floor:
 case e_ceil:
 case e_trunc:
+case e_round:
 case e_sqrt:
 case e_not:
 case e_random:

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] doc/filters: Clarify scale2ref example

2017-06-18 Thread Kevin Mark
ffmpeg | branch: release/3.1 | Kevin Mark  | Sat May 27 
10:10:46 2017 -0400| [5aaec845738ba401a97eae4fb16955610f30b1d8] | committer: 
Michael Niedermayer

doc/filters: Clarify scale2ref example

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 114e8716214d414d7965029ae5fe74668ed69e4a)
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5aaec845738ba401a97eae4fb16955610f30b1d8
---

 doc/filters.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index b482236e10..92f541de93 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11514,7 +11514,7 @@ uses the reference video instead of the main input as 
basis.
 
 @itemize
 @item
-Scale a subtitle stream to match the main video in size before overlaying
+Scale a subtitle stream (b) to match the main video (a) in size before 
overlaying
 @example
 'scale2ref[b][a];[a][b]overlay'
 @end example

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] doc/filters: Correct scale doc regarding w/h <= 0

2017-06-19 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Mon Jun 12 01:59:05 
2017 -0400| [5aea18cbd8828da885d76d528fcbf5b2fd6834ca] | committer: Ronald S. 
Bultje

doc/filters: Correct scale doc regarding w/h <= 0

According to libavfilter/scale.c, if the width and height are both
less than or equal to 0 then the input size is used for both
dimensions. It does not need to be -1. -1:-1 is the same as 0:0 which
is the same as -10:-42, etc.

if (w < 0 && h < 0)
eval_w = eval_h = 0;

The documentation for the zscale filter has also been updated since the
behavior is identical.

Signed-off-by: Kevin Mark 
Signed-off-by: Ronald S. Bultje 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5aea18cbd8828da885d76d528fcbf5b2fd6834ca
---

 doc/filters.texi | 39 ---
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 0e6a896eeb..11092a8d70 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12335,17 +12335,18 @@ the complete list of scaler options.
 Set the output video dimension expression. Default value is the input
 dimension.
 
-If the value is 0, the input width is used for the output.
+If the @var{width} or @var{w} value is 0, the input width is used for
+the output. If the @var{height} or @var{h} value is 0, the input height
+is used for the output.
 
-If one of the values is -1, the scale filter will use a value that
-maintains the aspect ratio of the input image, calculated from the
-other specified dimension. If both of them are -1, the input size is
-used
+If one and only one of the values is -n with n >= 1, the scale filter
+will use a value that maintains the aspect ratio of the input image,
+calculated from the other specified dimension. After that it will,
+however, make sure that the calculated dimension is divisible by n and
+adjust the value if necessary.
 
-If one of the values is -n with n > 1, the scale filter will also use a value
-that maintains the aspect ratio of the input image, calculated from the other
-specified dimension. After that it will, however, make sure that the calculated
-dimension is divisible by n and adjust the value if necessary.
+If both values are -n with n >= 1, the behavior will be identical to
+both values being set to 0 as previously detailed.
 
 See below for the list of accepted constants for use in the dimension
 expression.
@@ -15478,18 +15479,18 @@ The filter accepts the following options.
 Set the output video dimension expression. Default value is the input
 dimension.
 
-If the @var{width} or @var{w} is 0, the input width is used for the output.
-If the @var{height} or @var{h} is 0, the input height is used for the output.
+If the @var{width} or @var{w} value is 0, the input width is used for
+the output. If the @var{height} or @var{h} value is 0, the input height
+is used for the output.
 
-If one of the values is -1, the zscale filter will use a value that
-maintains the aspect ratio of the input image, calculated from the
-other specified dimension. If both of them are -1, the input size is
-used
+If one and only one of the values is -n with n >= 1, the zscale filter
+will use a value that maintains the aspect ratio of the input image,
+calculated from the other specified dimension. After that it will,
+however, make sure that the calculated dimension is divisible by n and
+adjust the value if necessary.
 
-If one of the values is -n with n > 1, the zscale filter will also use a value
-that maintains the aspect ratio of the input image, calculated from the other
-specified dimension. After that it will, however, make sure that the calculated
-dimension is divisible by n and adjust the value if necessary.
+If both values are -n with n >= 1, the behavior will be identical to
+both values being set to 0 as previously detailed.
 
 See below for the list of accepted constants for use in the dimension
 expression.

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavfilter/scale: Populate ow/oh when using 0 as w/h

2017-06-19 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Wed Jun 14 01:03:18 
2017 -0400| [05feeeb813e9f71f69b6b3a7f33856c609237c06] | committer: Ronald S. 
Bultje

libavfilter/scale: Populate ow/oh when using 0 as w/h

The input width and height is known at parse time so there's no
reason ow/oh should not be usable when using 0 as the width or
height expression.

Previously in "scale=0:ow" ow would be set to "0" which works,
conveniently, as "scale=0:0" is perfectly valid input but this breaks
down when you do something like "scale=0:ow/4" which one could
reasonably expect to work as well, but does not as ow is 0 not the
real value.

This change handles the 0 case for w/h immediately so the ow/oh
variables work as expected. Consequently, the rest of the code does
not need to handle 0 input. w/h will always be > 0 or < 0.

The second explicit (int) cast ensures that ow/oh appear as integers
as a user might expect when dealing with pixel dimensions.

Signed-off-by: Kevin Mark 
Signed-off-by: Ronald S. Bultje 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=05feeeb813e9f71f69b6b3a7f33856c609237c06
---

 libavfilter/scale.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libavfilter/scale.c b/libavfilter/scale.c
index 03745ddcb8..eaee95fac6 100644
--- a/libavfilter/scale.c
+++ b/libavfilter/scale.c
@@ -158,19 +158,19 @@ int ff_scale_eval_dimensions(void *log_ctx,
 av_expr_parse_and_eval(&res, (expr = w_expr),
names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, log_ctx);
-eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
+eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = (int) res == 0 ? 
inlink->w : (int) res;
 
 if ((ret = av_expr_parse_and_eval(&res, (expr = h_expr),
   names, var_values,
   NULL, NULL, NULL, NULL, NULL, 0, 
log_ctx)) < 0)
 goto fail;
-eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
+eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = (int) res == 0 ? 
inlink->h : (int) res;
 /* evaluate again the width, as it may depend on the output height */
 if ((ret = av_expr_parse_and_eval(&res, (expr = w_expr),
   names, var_values,
   NULL, NULL, NULL, NULL, NULL, 0, 
log_ctx)) < 0)
 goto fail;
-eval_w = res;
+eval_w = (int) res == 0 ? inlink->w : (int) res;
 
 w = eval_w;
 h = eval_h;
@@ -186,13 +186,10 @@ int ff_scale_eval_dimensions(void *log_ctx,
 factor_h = -h;
 }
 
-if (w < 0 && h < 0)
-eval_w = eval_h = 0;
-
-if (!(w = eval_w))
+if (w < 0 && h < 0) {
 w = inlink->w;
-if (!(h = eval_h))
 h = inlink->h;
+}
 
 /* Make sure that the result is divisible by the factor we determined
  * earlier. If no factor was set, it is nothing will happen as the default

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavfilter/scale2ref: Maintain main input's DAR

2017-07-04 Thread Kevin Mark
ffmpeg | branch: master | Kevin Mark  | Mon Jun  5 06:55:21 
2017 -0400| [d32a6c36e44c4c543786922f5876372662c340e3] | committer: Michael 
Niedermayer

libavfilter/scale2ref: Maintain main input's DAR

The scale2ref filter will now maintain the DAR of the main input and
not the DAR of the reference input. This previous behavior was deemed
counterintuitive for most (all?) use-cases.

Before:
scale2ref=iw/4:ow/mdar
in  w:320 h:240 fmt:rgb24 sar:1/1
ref w:640 h:360 fmt:rgb24 sar:1/1
out w:160 h:120 fmt:rgb24 sar:4/3 flags:0x2
SAR: ((120 * 640) / (160 * 360)) * (1 / 1) = 4 / 3
DAR: (160 / 120) * (4 / 3) = 16 / 9
(main out now same DAR as ref)

Now:
scale2ref=iw/4:ow/mdar
in  w:320 h:240 fmt:rgb24 sar:1/1
ref w:640 h:360 fmt:rgb24 sar:1/1
out w:160 h:120 fmt:rgb24 sar:1/1 flags:0x2
SAR: ((120 * 320) / (160 * 240)) * (1 / 1) = 1 / 1
DAR: (160 / 120) * (1 / 1) = 4 / 3
(main out same DAR as main in)

The scale2ref FATE test has also been updated.

Signed-off-by: Kevin Mark 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d32a6c36e44c4c543786922f5876372662c340e3
---

 libavfilter/vf_scale.c  | 6 +++---
 tests/ref/fate/filter-scale2ref_keep_aspect | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index c59ac6b0ea..3329c12346 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -337,10 +337,10 @@ static int config_props(AVFilterLink *outlink)
 }
 }
 
-if (inlink->sample_aspect_ratio.num){
-outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * 
inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
+if (inlink0->sample_aspect_ratio.num){
+outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * 
inlink0->w, outlink->w * inlink0->h}, inlink0->sample_aspect_ratio);
 } else
-outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
+outlink->sample_aspect_ratio = inlink0->sample_aspect_ratio;
 
 av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d 
fmt:%s sar:%d/%d flags:0x%0x\n",
inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
diff --git a/tests/ref/fate/filter-scale2ref_keep_aspect 
b/tests/ref/fate/filter-scale2ref_keep_aspect
index ca03277446..8dd0dbb13b 100644
--- a/tests/ref/fate/filter-scale2ref_keep_aspect
+++ b/tests/ref/fate/filter-scale2ref_keep_aspect
@@ -5,7 +5,7 @@
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 160x120
-#sar 0: 4/3
+#sar 0: 1/1
 #stream#, dts,pts, duration, size, hash
 0,  0,  0,1,57600, 9a19c23dc3a557786840d0098606d5f1
 0,  1,  1,1,57600, e6fbdabaf1bb0d28afc648ed4d27e9f0

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog