Message ID | 20190607215619.20992-3-michael@niedermayer.cc |
---|---|
State | New |
Headers | show |
On 07.06.2019, at 23:56, Michael Niedermayer <michael@niedermayer.cc> wrote: > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > --- > libavformat/vividas.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/libavformat/vividas.c b/libavformat/vividas.c > index 5e303b9c52..72f2093d13 100644 > --- a/libavformat/vividas.c > +++ b/libavformat/vividas.c > @@ -78,11 +78,11 @@ static int viv_probe(const AVProbeData *p) > return AVPROBE_SCORE_MAX; > } > > -static const unsigned short keybits[32] = { > - 163, 416, 893, 82, 223, 572, 1137, 430, > - 659, 1104, 13, 626, 695, 972, 1465, 686, > - 843, 1216, 317, 1122, 1383, 92, 513, 1158, > - 1243, 48, 573, 1306, 1495, 396, 1009, 350, > +static const uint8_t keybits[32] = { > + 20, 52, 111, 10, 27, 71, 142, 53, > + 82, 138, 1, 78, 86, 121, 183, 85, > +105, 152, 39, 140, 172, 11, 64, 144, > +155, 6, 71, 163, 186, 49, 126, 43, > }; > > static uint32_t decode_key(uint8_t *buf) > @@ -91,7 +91,7 @@ static uint32_t decode_key(uint8_t *buf) > > for (int i = 0; i < 32; i++) { > unsigned p = keybits[i]; > - key |= (unsigned)!!(buf[p>>3] & (1<<(p&7))) << i; > + key |= (unsigned)!!(buf[p] & (1<<((i*5+3)&7))) << i; If you are changing it anyway, maybe this should just be (((buf[p] >> ((i*5+3)&7)) & 1u) << i; ? Though I feel like there's a few parenthesis too many and maybe an intermediate variable would be best...
On Sat, Jun 08, 2019 at 08:23:22AM +0200, Reimar Döffinger wrote: > > > On 07.06.2019, at 23:56, Michael Niedermayer <michael@niedermayer.cc> wrote: > > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > > --- > > libavformat/vividas.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/libavformat/vividas.c b/libavformat/vividas.c > > index 5e303b9c52..72f2093d13 100644 > > --- a/libavformat/vividas.c > > +++ b/libavformat/vividas.c > > @@ -78,11 +78,11 @@ static int viv_probe(const AVProbeData *p) > > return AVPROBE_SCORE_MAX; > > } > > > > -static const unsigned short keybits[32] = { > > - 163, 416, 893, 82, 223, 572, 1137, 430, > > - 659, 1104, 13, 626, 695, 972, 1465, 686, > > - 843, 1216, 317, 1122, 1383, 92, 513, 1158, > > - 1243, 48, 573, 1306, 1495, 396, 1009, 350, > > +static const uint8_t keybits[32] = { > > + 20, 52, 111, 10, 27, 71, 142, 53, > > + 82, 138, 1, 78, 86, 121, 183, 85, > > +105, 152, 39, 140, 172, 11, 64, 144, > > +155, 6, 71, 163, 186, 49, 126, 43, > > }; > > > > static uint32_t decode_key(uint8_t *buf) > > @@ -91,7 +91,7 @@ static uint32_t decode_key(uint8_t *buf) > > > > for (int i = 0; i < 32; i++) { > > unsigned p = keybits[i]; > > - key |= (unsigned)!!(buf[p>>3] & (1<<(p&7))) << i; > > + key |= (unsigned)!!(buf[p] & (1<<((i*5+3)&7))) << i; > > If you are changing it anyway, maybe this should just be > (((buf[p] >> ((i*5+3)&7)) & 1u) << i; > ? > Though I feel like there's a few parenthesis too many and maybe > an intermediate variable would be best... will apply patchset with this change thx [...]
diff --git a/libavformat/vividas.c b/libavformat/vividas.c index 5e303b9c52..72f2093d13 100644 --- a/libavformat/vividas.c +++ b/libavformat/vividas.c @@ -78,11 +78,11 @@ static int viv_probe(const AVProbeData *p) return AVPROBE_SCORE_MAX; } -static const unsigned short keybits[32] = { - 163, 416, 893, 82, 223, 572, 1137, 430, - 659, 1104, 13, 626, 695, 972, 1465, 686, - 843, 1216, 317, 1122, 1383, 92, 513, 1158, - 1243, 48, 573, 1306, 1495, 396, 1009, 350, +static const uint8_t keybits[32] = { + 20, 52, 111, 10, 27, 71, 142, 53, + 82, 138, 1, 78, 86, 121, 183, 85, +105, 152, 39, 140, 172, 11, 64, 144, +155, 6, 71, 163, 186, 49, 126, 43, }; static uint32_t decode_key(uint8_t *buf) @@ -91,7 +91,7 @@ static uint32_t decode_key(uint8_t *buf) for (int i = 0; i < 32; i++) { unsigned p = keybits[i]; - key |= (unsigned)!!(buf[p>>3] & (1<<(p&7))) << i; + key |= (unsigned)!!(buf[p] & (1<<((i*5+3)&7))) << i; } return key;
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/vividas.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)