avfilter/f_select.c: add support for iw and ih variables

Fixes ticket #10509.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
PoorvaGaikar 2024-03-09 00:27:25 +05:30 committed by Marton Balint
parent 9e674b3160
commit 8b6e66d0f0
2 changed files with 18 additions and 0 deletions

View File

@ -30882,6 +30882,12 @@ missing.
That basically means that an input frame is selected if its pts is within the That basically means that an input frame is selected if its pts is within the
interval set by the concat demuxer. interval set by the concat demuxer.
@item iw @emph{(video only)}
Represents the width of the input video frame.
@item ih @emph{(video only)}
Represents the height of the input video frame.
@end table @end table
The default value of the select expression is "1". The default value of the select expression is "1".

View File

@ -90,6 +90,9 @@ static const char *const var_names[] = {
"concatdec_select", ///< frame is within the interval set by the concat demuxer "concatdec_select", ///< frame is within the interval set by the concat demuxer
"ih", ///< ih: Represents the height of the input video frame.
"iw", ///< iw: Represents the width of the input video frame.
NULL NULL
}; };
@ -144,6 +147,9 @@ enum var_name {
VAR_CONCATDEC_SELECT, VAR_CONCATDEC_SELECT,
VAR_IH,
VAR_IW,
VAR_VARS_NB VAR_VARS_NB
}; };
@ -264,6 +270,9 @@ static int config_input(AVFilterLink *inlink)
select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN; select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN;
select->var_values[VAR_SAMPLES_N] = NAN; select->var_values[VAR_SAMPLES_N] = NAN;
select->var_values[VAR_IH] = NAN;
select->var_values[VAR_IW] = NAN;
select->var_values[VAR_SAMPLE_RATE] = select->var_values[VAR_SAMPLE_RATE] =
inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN;
@ -357,6 +366,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
break; break;
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
select->var_values[VAR_IH] = frame->height;
select->var_values[VAR_IW] = frame->width;
select->var_values[VAR_INTERLACE_TYPE] = select->var_values[VAR_INTERLACE_TYPE] =
!(frame->flags & AV_FRAME_FLAG_INTERLACED) ? INTERLACE_TYPE_P : !(frame->flags & AV_FRAME_FLAG_INTERLACED) ? INTERLACE_TYPE_P :
(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? INTERLACE_TYPE_T : INTERLACE_TYPE_B; (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;