MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / get_shear_params_valid

Function get_shear_params_valid

libavcodec/av1dec.c:179–205  ·  view source on GitHub ↗

* check if global motion params is valid. * see spec 7.11.3.6 */

Source from the content-addressed store, hash-verified

177 * see spec 7.11.3.6
178 */
179static uint8_t get_shear_params_valid(AV1DecContext *s, int idx)
180{
181 int16_t alpha, beta, gamma, delta, divf, divs;
182 int64_t v, w;
183 int32_t *param = &s->cur_frame.gm_params[idx][0];
184 if (param[2] <= 0)
185 return 0;
186
187 alpha = av_clip_int16(param[2] - (1 << AV1_WARPEDMODEL_PREC_BITS));
188 beta = av_clip_int16(param[3]);
189 divf = resolve_divisor(abs(param[2]), &divs);
190 v = (int64_t)param[4] * (1 << AV1_WARPEDMODEL_PREC_BITS);
191 w = (int64_t)param[3] * param[4];
192 gamma = av_clip_int16((int)round_two_signed((v * divf), divs));
193 delta = av_clip_int16(param[5] - (int)round_two_signed((w * divf), divs) - (1 << AV1_WARPEDMODEL_PREC_BITS));
194
195 alpha = round_two_signed(alpha, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS;
196 beta = round_two_signed(beta, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS;
197 gamma = round_two_signed(gamma, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS;
198 delta = round_two_signed(delta, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS;
199
200 if ((4 * abs(alpha) + 7 * abs(beta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS) ||
201 (4 * abs(gamma) + 4 * abs(delta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS))
202 return 0;
203
204 return 1;
205}
206
207/**
208* update gm type/params, since cbs already implemented part of this function,

Callers 1

global_motion_paramsFunction · 0.85

Calls 2

resolve_divisorFunction · 0.85
round_two_signedFunction · 0.85

Tested by

no test coverage detected