[FFmpeg-devel] [PATCH 2/2] avcodec: add bink2 video decoder

Peter Ross pross at xvid.org
Sun Apr 7 13:47:42 EEST 2019


On Sun, Apr 07, 2019 at 10:00:09AM +0200, Paul B Mahol wrote:
> On 4/7/19, Peter Ross <pross at xvid.org> wrote:
> > On Wed, Mar 27, 2019 at 09:21:47PM +0100, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> ---
> >> Missing deblocking.
> >> ---
> >>  configure               |    1 +
> >>  libavcodec/Makefile     |    1 +
> >>  libavcodec/allcodecs.c  |    1 +
> >>  libavcodec/avcodec.h    |    1 +
> >>  libavcodec/bink2.c      |  787 +++++++++++++++++++++++
> >>  libavcodec/bink2f.c     | 1139 +++++++++++++++++++++++++++++++++
> >>  libavcodec/bink2g.c     | 1342 +++++++++++++++++++++++++++++++++++++++

> >> +static int bink2g_get_type(GetBitContext *gb, int *lru)
> >> +{
> >> +    int val;
> >> +
> >> +    ff_dlog(NULL, " type show %X @ %d\n", show_bits(gb, 4),
> >> get_bits_count(gb));
> >> +    switch (get_unary(gb, 1, 3)) {
> >> +    case 0:
> >> +        val = lru[0];
> >> +        break;
> >> +    case 1:
> >> +        val = lru[1];
> >> +        FFSWAP(int, lru[0], lru[1]);
> >> +        break;
> >> +    case 2:
> >> +        val = lru[3];
> >> +        FFSWAP(int, lru[2], lru[3]);
> >> +        break;
> >> +    case 3:
> >> +        val = lru[2];
> >> +        FFSWAP(int, lru[1], lru[2]);
> >> +        break;
> >> +    }
> >
> > cases 1-3 could be collapsed.
> 
> I do not see how.

reorder the second and third elements in bink2g_decode_slice types_lru[].
that at least removes the val = lru[x] statement from each switch case.

as for the swaps, there is some (probably unintentional) symetry going on there.

the result could be:

int n = get_unary(gb, 1, 3)
int v = lru[n];
if (n) {
    int n2 = n == 1 ? 1 : 3;
    FFSWAP(int, lru[n - 1], lru[n2]);
}
return v;

this is a minor cleanup and in the scheme of things, may not even be worth it.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190407/7cb81dfb/attachment.sig>


More information about the ffmpeg-devel mailing list