diff mbox series

[FFmpeg-devel] avcodec/mpc8: Unobfuscate sign-extension

Message ID 20201030160704.606904-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 1c430f60454acbf6f288058d971a44d6bb3d48e7
Headers show
Series [FFmpeg-devel] avcodec/mpc8: Unobfuscate sign-extension | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 30, 2020, 4:07 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/mpc8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt Oct. 31, 2020, 10:56 p.m. UTC | #1
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/mpc8.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
> index 03838a9351..631bac2753 100644
> --- a/libavcodec/mpc8.c
> +++ b/libavcodec/mpc8.c
> @@ -384,7 +384,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
>                  for(j = 0; j < SAMPLES_PER_BAND; j += 2){
>                      t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];
>                      c->Q[ch][off + j + 1] = t >> 4;
> -                    c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
> +                    c->Q[ch][off + j + 0] = sign_extend(t, 4);
>                  }
>                  break;
>              case 5:
> 
Will apply this tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
index 03838a9351..631bac2753 100644
--- a/libavcodec/mpc8.c
+++ b/libavcodec/mpc8.c
@@ -384,7 +384,7 @@  static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
                 for(j = 0; j < SAMPLES_PER_BAND; j += 2){
                     t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];
                     c->Q[ch][off + j + 1] = t >> 4;
-                    c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
+                    c->Q[ch][off + j + 0] = sign_extend(t, 4);
                 }
                 break;
             case 5: