mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-09 14:14:39 +02:00
avutil/integer: Fix av_mod_i() with negative dividend
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 3a9cb18855d29c96a5d9d2f5ad30448cae3a2ddf) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
3d69716bae
commit
4d9999705f
@ -29,6 +29,8 @@
|
|||||||
#include "integer.h"
|
#include "integer.h"
|
||||||
#include "avassert.h"
|
#include "avassert.h"
|
||||||
|
|
||||||
|
static const AVInteger zero_i;
|
||||||
|
|
||||||
AVInteger av_add_i(AVInteger a, AVInteger b){
|
AVInteger av_add_i(AVInteger a, AVInteger b){
|
||||||
int i, carry=0;
|
int i, carry=0;
|
||||||
|
|
||||||
@ -111,6 +113,12 @@ AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b){
|
|||||||
AVInteger quot_temp;
|
AVInteger quot_temp;
|
||||||
if(!quot) quot = "_temp;
|
if(!quot) quot = "_temp;
|
||||||
|
|
||||||
|
if ((int16_t)a.v[AV_INTEGER_SIZE-1] < 0) {
|
||||||
|
a = av_mod_i(quot, av_sub_i(zero_i, a), b);
|
||||||
|
*quot = av_sub_i(zero_i, *quot);
|
||||||
|
return av_sub_i(zero_i, a);
|
||||||
|
}
|
||||||
|
|
||||||
av_assert2((int16_t)a.v[AV_INTEGER_SIZE-1] >= 0 && (int16_t)b.v[AV_INTEGER_SIZE-1] >= 0);
|
av_assert2((int16_t)a.v[AV_INTEGER_SIZE-1] >= 0 && (int16_t)b.v[AV_INTEGER_SIZE-1] >= 0);
|
||||||
av_assert2(av_log2_i(b)>=0);
|
av_assert2(av_log2_i(b)>=0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user