[FFmpeg-devel] [PATCH 2/4] softfloat: use av_normalize1_sf in av_int2sf

Michael Niedermayer michael at niedermayer.cc
Sun Nov 8 19:40:56 CET 2015


On Sun, Nov 08, 2015 at 05:23:32PM +0100, Andreas Cadhalpun wrote:
> Updated variant attached.
> 
> Best regards,
> Andreas

>  softfloat.h |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 1621ecf24466d8c1ad8cb394a079a59f39a98e4d  0001-softfloat-handle-INT_MIN-correctly-in-av_int2sf.patch
> From 50000b9a0ebd17d046d7a99f6388f7fb30ff66e6 Mon Sep 17 00:00:00 2001
> From: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> Date: Sun, 8 Nov 2015 17:19:10 +0100
> Subject: [PATCH] softfloat: handle INT_MIN correctly in av_int2sf
> 
> Otherwise v=INT_MIN doesn't get normalized and thus triggers av_assert2
> in other functions.
> 
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> ---
>  libavutil/softfloat.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h
> index 4cc3ceb..5b285e3 100644
> --- a/libavutil/softfloat.h
> +++ b/libavutil/softfloat.h
> @@ -153,7 +153,12 @@ static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){
>   * @returns a SoftFloat with value v * 2^frac_bits
>   */
>  static inline av_const SoftFloat av_int2sf(int v, int frac_bits){
> -    return av_normalize_sf((SoftFloat){v, ONE_BITS + 1 - frac_bits});
> +    int exp_offset = 0;
> +    if(v == INT_MIN){
> +        exp_offset = 1;
> +        v>>=1;
> +    }
> +    return av_normalize_sf(av_normalize1_sf((SoftFloat){v, ONE_BITS + 1 - frac_bits + exp_offset}));

should be ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151108/7131a675/attachment.sig>


More information about the ffmpeg-devel mailing list