History

lavfi/vf_vpp_qsv: add "a", "dar" and "sar" variables

Also fix the naming style in enum var_name. This is in preparation for reusing the code for other QSV filters.

Haihao Xiang committed 3 years ago

Commit 24a8e1e1 parent 1f88fb81 file · +29 −20Browse files

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

Unified · Split

libavfilter/vf_vpp_qsv.c+29−20
@@ -150,18 +150,22 @@ static const char *const var_names[] = { · 149 unmodified lines
150 "ch",150 "ch",
151 "cx",151 "cx",
152 "cy",152 "cy",
153 "a", "dar",
154 "sar",
153 NULL155 NULL
154};156};
155 157
156enum var_name {158enum var_name {
157 VAR_iW, VAR_IN_W,159 VAR_IW, VAR_IN_W,
158 VAR_iH, VAR_IN_H,160 VAR_IH, VAR_IN_H,
159 VAR_oW, VAR_OUT_W, VAR_W,161 VAR_OW, VAR_OUT_W, VAR_W,
160 VAR_oH, VAR_OUT_H, VAR_H,162 VAR_OH, VAR_OUT_H, VAR_H,
161 CW,163 VAR_CW,
162 CH,164 VAR_CH,
163 CX,165 VAR_CX,
164 CY,166 VAR_CY,
167 VAR_A, VAR_DAR,
168 VAR_SAR,
165 VAR_VARS_NB169 VAR_VARS_NB
166};170};
167 171
@@ -193,39 +197,44 @@ static int eval_expr(AVFilterContext *ctx) · 25 unmodified lines
193 PASS_EXPR(cx_expr, vpp->cx);197 PASS_EXPR(cx_expr, vpp->cx);
194 PASS_EXPR(cy_expr, vpp->cy);198 PASS_EXPR(cy_expr, vpp->cy);
195 199
196 var_values[VAR_iW] =200 var_values[VAR_IW] =
197 var_values[VAR_IN_W] = ctx->inputs[0]->w;201 var_values[VAR_IN_W] = ctx->inputs[0]->w;
198 202
199 var_values[VAR_iH] =203 var_values[VAR_IH] =
200 var_values[VAR_IN_H] = ctx->inputs[0]->h;204 var_values[VAR_IN_H] = ctx->inputs[0]->h;
201 205
206 var_values[VAR_A] = (double)var_values[VAR_IN_W] / var_values[VAR_IN_H];
207 var_values[VAR_SAR] = ctx->inputs[0]->sample_aspect_ratio.num ?
208 (double)ctx->inputs[0]->sample_aspect_ratio.num / ctx->inputs[0]->sample_aspect_ratio.den : 1;
209 var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
210
202 /* crop params */211 /* crop params */
203 CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);212 CALC_EXPR(cw_expr, var_values[VAR_CW], vpp->crop_w);
204 CALC_EXPR(ch_expr, var_values[CH], vpp->crop_h);213 CALC_EXPR(ch_expr, var_values[VAR_CH], vpp->crop_h);
205 214
206 /* calc again in case cw is relative to ch */215 /* calc again in case cw is relative to ch */
207 CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w);216 CALC_EXPR(cw_expr, var_values[VAR_CW], vpp->crop_w);
208 217
209 CALC_EXPR(w_expr,218 CALC_EXPR(w_expr,
210 var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W],219 var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
211 vpp->out_width);220 vpp->out_width);
212 CALC_EXPR(h_expr,221 CALC_EXPR(h_expr,
213 var_values[VAR_OUT_H] = var_values[VAR_oH] = var_values[VAR_H],222 var_values[VAR_OUT_H] = var_values[VAR_OH] = var_values[VAR_H],
214 vpp->out_height);223 vpp->out_height);
215 224
216 /* calc again in case ow is relative to oh */225 /* calc again in case ow is relative to oh */
217 CALC_EXPR(w_expr,226 CALC_EXPR(w_expr,
218 var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W],227 var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W],
219 vpp->out_width);228 vpp->out_width);
220 229
221 230
222 CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x);231 CALC_EXPR(cx_expr, var_values[VAR_CX], vpp->crop_x);
223 CALC_EXPR(cy_expr, var_values[CY], vpp->crop_y);232 CALC_EXPR(cy_expr, var_values[VAR_CY], vpp->crop_y);
224 233
225 /* calc again in case cx is relative to cy */234 /* calc again in case cx is relative to cy */
226 CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x);235 CALC_EXPR(cx_expr, var_values[VAR_CX], vpp->crop_x);
227 236
228 if ((vpp->crop_w != var_values[VAR_iW]) || (vpp->crop_h != var_values[VAR_iH]))237 if ((vpp->crop_w != var_values[VAR_IW]) || (vpp->crop_h != var_values[VAR_IH]))
229 vpp->use_crop = 1;238 vpp->use_crop = 1;
230 239
231release:240release:

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