[FFmpeg-cvslog] lavfi: tweak display aspect ratio variables in pad and scale filters
Stefano Sabatini
git at videolan.org
Sat Jul 30 19:00:45 CEST 2011
ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Wed Jul 27 10:58:24 2011 +0200| [61d55fda2b513caf18e37b27aba680a87840904a] | committer: Stefano Sabatini
lavfi: tweak display aspect ratio variables in pad and scale filters
Previously, "dar" and "a" were documented like "input display aspect
ratio", but their actual value was "in_w/in_h".
In order to avoid to break scripts which rely on the "a" variable, the
patch keeps the same semantics but fixes the corresponding docs, and
fixes the semantics of the recently added "dar" variable, which
now correctly expresses the input Display Aspect Ratio value as
"(inw_w/in_h)*sar".
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=61d55fda2b513caf18e37b27aba680a87840904a
---
doc/filters.texi | 14 ++++++++++----
libavfilter/avfilter.h | 2 +-
libavfilter/vf_pad.c | 9 ++++++---
libavfilter/vf_scale.c | 9 ++++++---
4 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 8054bff..2e419a8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1184,12 +1184,15 @@ same as @var{out_w} and @var{out_h}
x and y offsets as specified by the @var{x} and @var{y}
expressions, or NAN if not yet specified
- at item dar, a
-input display aspect ratio, same as @var{iw} / @var{ih}
+ at item a
+same as @var{iw} / @var{ih}
@item sar
input sample aspect ratio
+ at item dar
+input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
+
@item hsub, vsub
horizontal and vertical chroma subsample values. For example for the
pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
@@ -1289,12 +1292,15 @@ the output (cropped) width and heigth
@item ow, oh
same as @var{out_w} and @var{out_h}
- at item dar, a
-input display aspect ratio, same as @var{iw} / @var{ih}
+ at item a
+same as @var{iw} / @var{ih}
@item sar
input sample aspect ratio
+ at item dar
+input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
+
@item hsub, vsub
horizontal and vertical chroma subsample values. For example for the
pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 913a52b..6746176 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 27
-#define LIBAVFILTER_VERSION_MICRO 3
+#define LIBAVFILTER_VERSION_MICRO 4
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index e01a750..c4edc23 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -45,8 +45,9 @@ static const char *var_names[] = {
"out_h", "oh",
"x",
"y",
- "a", "dar",
+ "a",
"sar",
+ "dar",
"hsub",
"vsub",
NULL
@@ -62,8 +63,9 @@ enum var_name {
VAR_OUT_H, VAR_OH,
VAR_X,
VAR_Y,
- VAR_A, VAR_DAR,
+ VAR_A,
VAR_SAR,
+ VAR_DAR,
VAR_HSUB,
VAR_VSUB,
VARS_NB
@@ -158,9 +160,10 @@ static int config_input(AVFilterLink *inlink)
var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
- var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h;
+ var_values[VAR_A] = (float) inlink->w / inlink->h;
var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
(float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
+ var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
var_values[VAR_HSUB] = 1<<pad->hsub;
var_values[VAR_VSUB] = 1<<pad->vsub;
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 3be5d99..044b284 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -39,8 +39,9 @@ static const char *var_names[] = {
"in_h", "ih",
"out_w", "ow",
"out_h", "oh",
- "a", "dar",
+ "a",
"sar",
+ "dar",
"hsub",
"vsub",
NULL
@@ -54,8 +55,9 @@ enum var_name {
VAR_IN_H, VAR_IH,
VAR_OUT_W, VAR_OW,
VAR_OUT_H, VAR_OH,
- VAR_A, VAR_DAR,
+ VAR_A,
VAR_SAR,
+ VAR_DAR,
VAR_HSUB,
VAR_VSUB,
VARS_NB
@@ -160,9 +162,10 @@ static int config_props(AVFilterLink *outlink)
var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
- var_values[VAR_DAR] = var_values[VAR_A] = (float) inlink->w / inlink->h;
+ var_values[VAR_A] = (float) inlink->w / inlink->h;
var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
(float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
+ var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
var_values[VAR_HSUB] = 1<<av_pix_fmt_descriptors[inlink->format].log2_chroma_w;
var_values[VAR_VSUB] = 1<<av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
More information about the ffmpeg-cvslog
mailing list