mirror of https://github.com/mpv-player/mpv
vo_gpu: add two useful operators to user shader
modulo operator could be used to check if size is multiple of a certain number. equal operator could be used to verify if size of different textures aligns.
This commit is contained in:
parent
b3cbd46509
commit
1d0349d3b5
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "common/msg.h"
|
||||
#include "misc/ctype.h"
|
||||
|
@ -52,9 +53,11 @@ static bool parse_rpn_szexpr(struct bstr line, struct szexp out[MAX_SZEXP_SIZE])
|
|||
case '-': exp->tag = SZEXP_OP2; exp->val.op = SZEXP_OP_SUB; continue;
|
||||
case '*': exp->tag = SZEXP_OP2; exp->val.op = SZEXP_OP_MUL; continue;
|
||||
case '/': exp->tag = SZEXP_OP2; exp->val.op = SZEXP_OP_DIV; continue;
|
||||
case '%': exp->tag = SZEXP_OP2; exp->val.op = SZEXP_OP_MOD; continue;
|
||||
case '!': exp->tag = SZEXP_OP1; exp->val.op = SZEXP_OP_NOT; continue;
|
||||
case '>': exp->tag = SZEXP_OP2; exp->val.op = SZEXP_OP_GT; continue;
|
||||
case '<': exp->tag = SZEXP_OP2; exp->val.op = SZEXP_OP_LT; continue;
|
||||
case '=': exp->tag = SZEXP_OP2; exp->val.op = SZEXP_OP_EQ; continue;
|
||||
}
|
||||
|
||||
if (mp_isdigit(word.start[0])) {
|
||||
|
@ -118,8 +121,10 @@ bool eval_szexpr(struct mp_log *log, void *priv,
|
|||
case SZEXP_OP_SUB: res = op1 - op2; break;
|
||||
case SZEXP_OP_MUL: res = op1 * op2; break;
|
||||
case SZEXP_OP_DIV: res = op1 / op2; break;
|
||||
case SZEXP_OP_MOD: res = fmodf(op1, op2); break;
|
||||
case SZEXP_OP_GT: res = op1 > op2; break;
|
||||
case SZEXP_OP_LT: res = op1 < op2; break;
|
||||
case SZEXP_OP_EQ: res = op1 == op2; break;
|
||||
default: abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,11 @@ enum szexp_op {
|
|||
SZEXP_OP_SUB,
|
||||
SZEXP_OP_MUL,
|
||||
SZEXP_OP_DIV,
|
||||
SZEXP_OP_MOD,
|
||||
SZEXP_OP_NOT,
|
||||
SZEXP_OP_GT,
|
||||
SZEXP_OP_LT,
|
||||
SZEXP_OP_EQ,
|
||||
};
|
||||
|
||||
enum szexp_tag {
|
||||
|
|
Loading…
Reference in New Issue