diff mbox

[FFmpeg-devel,RFC] avutil/reverse: make ff_reverse shared

Message ID 20171201011936.11144-1-jamrial@gmail.com
State Rejected
Headers show

Commit Message

James Almer Dec. 1, 2017, 1:19 a.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
Pros:
Removes duplicate arrays and ugly c file including c files

Cons:
Makes the array in libavutil effectively part of the ABI.
Might not be worth doing for 256 bytes


Something like this was probably sent before, so i guess it
will be rejected again.

 libavcodec/Makefile          |  2 +-
 libavcodec/asvdec.c          |  4 ++--
 libavcodec/asvenc.c          |  4 ++--
 libavcodec/dcaenc.c          |  2 +-
 libavcodec/dsd.c             |  4 ++--
 libavcodec/dsddec.c          |  2 +-
 libavcodec/dstdec.c          |  2 +-
 libavcodec/indeo2.c          |  2 +-
 libavcodec/ivi.c             |  6 +++---
 libavcodec/mathops.h         |  8 ++++----
 libavcodec/mpeg12dec.c       |  4 ++--
 libavcodec/pcm.c             |  8 ++++----
 libavcodec/reverse.c         |  1 -
 libavcodec/s302m.c           | 36 ++++++++++++++++++------------------
 libavcodec/s302menc.c        | 36 ++++++++++++++++++------------------
 libavcodec/tiff.c            | 10 +++++-----
 libavcodec/webp.c            |  4 ++--
 libavcodec/wnv1.c            |  4 ++--
 libavcodec/xbmdec.c          |  4 ++--
 libavcodec/xbmenc.c          |  2 +-
 libavdevice/Makefile         |  1 -
 libavdevice/decklink_dec.cpp |  2 +-
 libavdevice/reverse.c        |  1 -
 libavutil/eval.c             |  2 +-
 libavutil/reverse.c          |  3 ++-
 libavutil/reverse.h          |  3 ++-
 26 files changed, 78 insertions(+), 79 deletions(-)
 delete mode 100644 libavcodec/reverse.c
 delete mode 100644 libavdevice/reverse.c

Comments

Steven Liu Dec. 1, 2017, 2:37 a.m. UTC | #1
2017-12-01 9:19 GMT+08:00 James Almer <jamrial@gmail.com>:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Pros:
> Removes duplicate arrays and ugly c file including c files
>
> Cons:
> Makes the array in libavutil effectively part of the ABI.
> Might not be worth doing for 256 bytes
>
>
> Something like this was probably sent before, so i guess it
> will be rejected again.
>
>  libavcodec/Makefile          |  2 +-
>  libavcodec/asvdec.c          |  4 ++--
>  libavcodec/asvenc.c          |  4 ++--
>  libavcodec/dcaenc.c          |  2 +-
>  libavcodec/dsd.c             |  4 ++--
>  libavcodec/dsddec.c          |  2 +-
>  libavcodec/dstdec.c          |  2 +-
>  libavcodec/indeo2.c          |  2 +-
>  libavcodec/ivi.c             |  6 +++---
>  libavcodec/mathops.h         |  8 ++++----
>  libavcodec/mpeg12dec.c       |  4 ++--
>  libavcodec/pcm.c             |  8 ++++----
>  libavcodec/reverse.c         |  1 -
>  libavcodec/s302m.c           | 36 ++++++++++++++++++------------------
>  libavcodec/s302menc.c        | 36 ++++++++++++++++++------------------
>  libavcodec/tiff.c            | 10 +++++-----
>  libavcodec/webp.c            |  4 ++--
>  libavcodec/wnv1.c            |  4 ++--
>  libavcodec/xbmdec.c          |  4 ++--
>  libavcodec/xbmenc.c          |  2 +-
>  libavdevice/Makefile         |  1 -
>  libavdevice/decklink_dec.cpp |  2 +-
>  libavdevice/reverse.c        |  1 -
>  libavutil/eval.c             |  2 +-
>  libavutil/reverse.c          |  3 ++-
>  libavutil/reverse.h          |  3 ++-
>  26 files changed, 78 insertions(+), 79 deletions(-)
>  delete mode 100644 libavcodec/reverse.c
>  delete mode 100644 libavdevice/reverse.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index ab7893f560..6942b2c926 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -129,7 +129,7 @@ OBJS-$(CONFIG_QSVENC)                  += qsvenc.o
>  OBJS-$(CONFIG_RANGECODER)              += rangecoder.o
>  OBJS-$(CONFIG_RDFT)                    += rdft.o
>  OBJS-$(CONFIG_RV34DSP)                 += rv34dsp.o
> -OBJS-$(CONFIG_SHARED)                  += log2_tab.o reverse.o
> +OBJS-$(CONFIG_SHARED)                  += log2_tab.o
>  OBJS-$(CONFIG_SINEWIN)                 += sinewin.o sinewin_fixed.o
>  OBJS-$(CONFIG_SNAPPY)                  += snappy.o
>  OBJS-$(CONFIG_STARTCODE)               += startcode.o
> diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
> index 9a11446f52..11d1564db3 100644
> --- a/libavcodec/asvdec.c
> +++ b/libavcodec/asvdec.c
> @@ -71,7 +71,7 @@ static av_cold void init_vlcs(ASV1Context *a)
>  // FIXME write a reversed bitstream reader to avoid the double reverse
>  static inline int asv2_get_bits(GetBitContext *gb, int n)
>  {
> -    return ff_reverse[get_bits(gb, n) << (8 - n)];
> +    return avpriv_reverse[get_bits(gb, n) << (8 - n)];
>  }
>
>  static inline int asv1_get_level(GetBitContext *gb)
> @@ -229,7 +229,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
>      } else {
>          int i;
>          for (i = 0; i < buf_size; i++)
> -            a->bitstream_buffer[i] = ff_reverse[buf[i]];
> +            a->bitstream_buffer[i] = avpriv_reverse[buf[i]];
>      }
>
>      init_get_bits(&a->gb, a->bitstream_buffer, buf_size * 8);
> diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
> index c4eca2a13d..7ed932c934 100644
> --- a/libavcodec/asvenc.c
> +++ b/libavcodec/asvenc.c
> @@ -37,7 +37,7 @@
>
>  static inline void asv2_put_bits(PutBitContext *pb, int n, int v)
>  {
> -    put_bits(pb, n, ff_reverse[v << (8 - n)]);
> +    put_bits(pb, n, avpriv_reverse[v << (8 - n)]);
>  }
>
>  static inline void asv1_put_level(PutBitContext *pb, int level)
> @@ -306,7 +306,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>      } else {
>          int i;
>          for (i = 0; i < 4 * size; i++)
> -            pkt->data[i] = ff_reverse[pkt->data[i]];
> +            pkt->data[i] = avpriv_reverse[pkt->data[i]];
>      }
>
>      pkt->size   = size * 4;
> diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
> index dd601ffae0..b111fe98ba 100644
> --- a/libavcodec/dcaenc.c
> +++ b/libavcodec/dcaenc.c
> @@ -446,7 +446,7 @@ static void fft(const int32_t in[2 * 256], cplx32 out[256])
>      }
>      /* post-rotation */
>      for (i = 0; i < 256; i++) {
> -        int b = ff_reverse[i];
> +        int b = avpriv_reverse[i];
>          rout[i].re = mul32(buf[b].re, cos_t(4 * i))
>                     - mul32(buf[b].im, sin_t(4 * i));
>          rout[i].im = mul32(buf[b].im, cos_t(4 * i))
> diff --git a/libavcodec/dsd.c b/libavcodec/dsd.c
> index 9104f38476..2233adf349 100644
> --- a/libavcodec/dsd.c
> +++ b/libavcodec/dsd.c
> @@ -63,11 +63,11 @@ void ff_dsd2pcm_translate(DSDContext* s, size_t samples, int lsbf,
>      pos = s->pos;
>
>      while (samples-- > 0) {
> -        s->buf[pos] = lsbf ? ff_reverse[*src] : *src;
> +        s->buf[pos] = lsbf ? avpriv_reverse[*src] : *src;
>          src += src_stride;
>
>          p = s->buf + ((pos - CTABLES) & FIFOMASK);
> -        *p = ff_reverse[*p];
> +        *p = avpriv_reverse[*p];
>
>          sum = 0.0;
>          for (i = 0; i < CTABLES; i++) {
> diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c
> index 2c5c357acc..3974bdeeb2 100644
> --- a/libavcodec/dsddec.c
> +++ b/libavcodec/dsddec.c
> @@ -50,7 +50,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>      if (!s)
>          return AVERROR(ENOMEM);
>
> -    silence = avctx->codec_id == AV_CODEC_ID_DSD_LSBF || avctx->codec_id == AV_CODEC_ID_DSD_LSBF_PLANAR ? ff_reverse[DSD_SILENCE] : DSD_SILENCE;
> +    silence = avctx->codec_id == AV_CODEC_ID_DSD_LSBF || avctx->codec_id == AV_CODEC_ID_DSD_LSBF_PLANAR ? avpriv_reverse[DSD_SILENCE] : DSD_SILENCE;
>      for (i = 0; i < avctx->channels; i++) {
>          s[i].pos = 0;
>          memset(s[i].buf, silence, sizeof(s[i].buf));
> diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
> index 368cb64931..d9c4734209 100644
> --- a/libavcodec/dstdec.c
> +++ b/libavcodec/dstdec.c
> @@ -197,7 +197,7 @@ static av_always_inline void ac_get(ArithCoder *ac, GetBitContext *gb, int p, in
>
>  static uint8_t prob_dst_x_bit(int c)
>  {
> -    return (ff_reverse[c & 127] >> 1) + 1;
> +    return (avpriv_reverse[c & 127] >> 1) + 1;
>  }
>
>  static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets)
> diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c
> index 4971b84308..39c2a23279 100644
> --- a/libavcodec/indeo2.c
> +++ b/libavcodec/indeo2.c
> @@ -175,7 +175,7 @@ static int ir2_decode_frame(AVCodecContext *avctx,
>      /* decide whether frame uses deltas or not */
>  #ifndef BITSTREAM_READER_LE
>      for (i = 0; i < buf_size; i++)
> -        buf[i] = ff_reverse[buf[i]];
> +        buf[i] = avpriv_reverse[buf[i]];
>  #endif
>
>      if ((ret = init_get_bits8(&s->gb, buf + start, buf_size - start)) < 0)
> diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
> index cea40d82ca..76cf04f0a1 100644
> --- a/libavcodec/ivi.c
> +++ b/libavcodec/ivi.c
> @@ -125,10 +125,10 @@ static uint16_t inv_bits(uint16_t val, int nbits)
>      uint16_t res;
>
>      if (nbits <= 8) {
> -        res = ff_reverse[val] >> (8 - nbits);
> +        res = avpriv_reverse[val] >> (8 - nbits);
>      } else
> -        res = ((ff_reverse[val & 0xFF] << 8) +
> -               (ff_reverse[val >> 8])) >> (16 - nbits);
> +        res = ((avpriv_reverse[val & 0xFF] << 8) +
> +               (avpriv_reverse[val >> 8])) >> (16 - nbits);
>
>      return res;
>  }
> diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
> index 1c35664318..c038cb5cd9 100644
> --- a/libavcodec/mathops.h
> +++ b/libavcodec/mathops.h
> @@ -242,10 +242,10 @@ static inline int8_t ff_u8_to_s8(uint8_t a)
>
>  static av_always_inline uint32_t bitswap_32(uint32_t x)
>  {
> -    return (uint32_t)ff_reverse[ x        & 0xFF] << 24 |
> -           (uint32_t)ff_reverse[(x >> 8)  & 0xFF] << 16 |
> -           (uint32_t)ff_reverse[(x >> 16) & 0xFF] << 8  |
> -           (uint32_t)ff_reverse[ x >> 24];
> +    return (uint32_t)avpriv_reverse[ x        & 0xFF] << 24 |
> +           (uint32_t)avpriv_reverse[(x >> 8)  & 0xFF] << 16 |
> +           (uint32_t)avpriv_reverse[(x >> 16) & 0xFF] << 8  |
> +           (uint32_t)avpriv_reverse[ x >> 24];
>  }
>
>  #endif /* AVCODEC_MATHOPS_H */
> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> index ac5ac4bca4..eda097cd3d 100644
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -2282,8 +2282,8 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
>                          field = (field == 2 ? 1 : 0);
>                          if (!s1->mpeg_enc_ctx.top_field_first) field = !field;
>                          cap[0] = 0x04 | field;
> -                        cap[1] = ff_reverse[cc1];
> -                        cap[2] = ff_reverse[cc2];
> +                        cap[1] = avpriv_reverse[cc1];
> +                        cap[2] = avpriv_reverse[cc2];
>                      }
>                      cap += 3;
>                  }
> diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
> index 8c326c6829..ffb5253e4f 100644
> --- a/libavcodec/pcm.c
> +++ b/libavcodec/pcm.c
> @@ -126,8 +126,8 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
>          break;
>      case AV_CODEC_ID_PCM_S24DAUD:
>          for (; n > 0; n--) {
> -            uint32_t tmp = ff_reverse[(*samples >> 8) & 0xff] +
> -                           (ff_reverse[*samples & 0xff] << 8);
> +            uint32_t tmp = avpriv_reverse[(*samples >> 8) & 0xff] +
> +                           (avpriv_reverse[*samples & 0xff] << 8);
>              tmp <<= 4; // sync flags would go here
>              bytestream_put_be24(&dst, tmp);
>              samples++;
> @@ -388,8 +388,8 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
>          for (; n > 0; n--) {
>              uint32_t v = bytestream_get_be24(&src);
>              v >>= 4; // sync flags are here
> -            AV_WN16A(samples, ff_reverse[(v >> 8) & 0xff] +
> -                             (ff_reverse[v        & 0xff] << 8));
> +            AV_WN16A(samples, avpriv_reverse[(v >> 8) & 0xff] +
> +                             (avpriv_reverse[v        & 0xff] << 8));
>              samples += 2;
>          }
>          break;
> diff --git a/libavcodec/reverse.c b/libavcodec/reverse.c
> deleted file mode 100644
> index 440badaf34..0000000000
> --- a/libavcodec/reverse.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "libavutil/reverse.c"
> diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
> index 584b58e28e..d14ee45aa2 100644
> --- a/libavcodec/s302m.c
> +++ b/libavcodec/s302m.c
> @@ -120,13 +120,13 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
>      if (avctx->bits_per_raw_sample == 24) {
>          uint32_t *o = (uint32_t *)frame->data[0];
>          for (; buf_size > 6; buf_size -= 7) {
> -            *o++ = ((unsigned)ff_reverse[buf[2]]        << 24) |
> -                   (ff_reverse[buf[1]]        << 16) |
> -                   (ff_reverse[buf[0]]        <<  8);
> -            *o++ = ((unsigned)ff_reverse[buf[6] & 0xf0] << 28) |
> -                   (ff_reverse[buf[5]]        << 20) |
> -                   (ff_reverse[buf[4]]        << 12) |
> -                   (ff_reverse[buf[3] & 0x0f] <<  4);
> +            *o++ = ((unsigned)avpriv_reverse[buf[2]]        << 24) |
> +                   (avpriv_reverse[buf[1]]        << 16) |
> +                   (avpriv_reverse[buf[0]]        <<  8);
> +            *o++ = ((unsigned)avpriv_reverse[buf[6] & 0xf0] << 28) |
> +                   (avpriv_reverse[buf[5]]        << 20) |
> +                   (avpriv_reverse[buf[4]]        << 12) |
> +                   (avpriv_reverse[buf[3] & 0x0f] <<  4);
>              buf += 7;
>          }
>          o = (uint32_t *)frame->data[0];
> @@ -142,12 +142,12 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
>      } else if (avctx->bits_per_raw_sample == 20) {
>          uint32_t *o = (uint32_t *)frame->data[0];
>          for (; buf_size > 5; buf_size -= 6) {
> -            *o++ = ((unsigned)ff_reverse[buf[2] & 0xf0] << 28) |
> -                   (ff_reverse[buf[1]]        << 20) |
> -                   (ff_reverse[buf[0]]        << 12);
> -            *o++ = ((unsigned)ff_reverse[buf[5] & 0xf0] << 28) |
> -                   (ff_reverse[buf[4]]        << 20) |
> -                   (ff_reverse[buf[3]]        << 12);
> +            *o++ = ((unsigned)avpriv_reverse[buf[2] & 0xf0] << 28) |
> +                   (avpriv_reverse[buf[1]]        << 20) |
> +                   (avpriv_reverse[buf[0]]        << 12);
> +            *o++ = ((unsigned)avpriv_reverse[buf[5] & 0xf0] << 28) |
> +                   (avpriv_reverse[buf[4]]        << 20) |
> +                   (avpriv_reverse[buf[3]]        << 12);
>              buf += 6;
>          }
>          o = (uint32_t *)frame->data[0];
> @@ -163,11 +163,11 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
>      } else {
>          uint16_t *o = (uint16_t *)frame->data[0];
>          for (; buf_size > 4; buf_size -= 5) {
> -            *o++ = (ff_reverse[buf[1]]        <<  8) |
> -                    ff_reverse[buf[0]];
> -            *o++ = (ff_reverse[buf[4] & 0xf0] << 12) |
> -                   (ff_reverse[buf[3]]        <<  4) |
> -                   (ff_reverse[buf[2]]        >>  4);
> +            *o++ = (avpriv_reverse[buf[1]]        <<  8) |
> +                    avpriv_reverse[buf[0]];
> +            *o++ = (avpriv_reverse[buf[4] & 0xf0] << 12) |
> +                   (avpriv_reverse[buf[3]]        <<  4) |
> +                   (avpriv_reverse[buf[2]]        >>  4);
>              buf += 5;
>          }
>          o = (uint16_t *)frame->data[0];
> diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c
> index b04a54e482..c5634b09bf 100644
> --- a/libavcodec/s302menc.c
> +++ b/libavcodec/s302menc.c
> @@ -103,13 +103,13 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt,
>              uint8_t vucf = s->framing_index == 0 ? 0x10: 0;
>
>              for (channels = 0; channels < avctx->channels; channels += 2) {
> -                o[0] = ff_reverse[(samples[0] & 0x0000FF00) >> 8];
> -                o[1] = ff_reverse[(samples[0] & 0x00FF0000) >> 16];
> -                o[2] = ff_reverse[(samples[0] & 0xFF000000) >> 24];
> -                o[3] = ff_reverse[(samples[1] & 0x00000F00) >> 4] | vucf;
> -                o[4] = ff_reverse[(samples[1] & 0x000FF000) >> 12];
> -                o[5] = ff_reverse[(samples[1] & 0x0FF00000) >> 20];
> -                o[6] = ff_reverse[(samples[1] & 0xF0000000) >> 28];
> +                o[0] = avpriv_reverse[(samples[0] & 0x0000FF00) >> 8];
> +                o[1] = avpriv_reverse[(samples[0] & 0x00FF0000) >> 16];
> +                o[2] = avpriv_reverse[(samples[0] & 0xFF000000) >> 24];
> +                o[3] = avpriv_reverse[(samples[1] & 0x00000F00) >> 4] | vucf;
> +                o[4] = avpriv_reverse[(samples[1] & 0x000FF000) >> 12];
> +                o[5] = avpriv_reverse[(samples[1] & 0x0FF00000) >> 20];
> +                o[6] = avpriv_reverse[(samples[1] & 0xF0000000) >> 28];
>                  o += 7;
>                  samples += 2;
>              }
> @@ -125,12 +125,12 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt,
>              uint8_t vucf = s->framing_index == 0 ? 0x80: 0;
>
>              for (channels = 0; channels < avctx->channels; channels += 2) {
> -                o[0] = ff_reverse[ (samples[0] & 0x000FF000) >> 12];
> -                o[1] = ff_reverse[ (samples[0] & 0x0FF00000) >> 20];
> -                o[2] = ff_reverse[((samples[0] & 0xF0000000) >> 28) | vucf];
> -                o[3] = ff_reverse[ (samples[1] & 0x000FF000) >> 12];
> -                o[4] = ff_reverse[ (samples[1] & 0x0FF00000) >> 20];
> -                o[5] = ff_reverse[ (samples[1] & 0xF0000000) >> 28];
> +                o[0] = avpriv_reverse[ (samples[0] & 0x000FF000) >> 12];
> +                o[1] = avpriv_reverse[ (samples[0] & 0x0FF00000) >> 20];
> +                o[2] = avpriv_reverse[((samples[0] & 0xF0000000) >> 28) | vucf];
> +                o[3] = avpriv_reverse[ (samples[1] & 0x000FF000) >> 12];
> +                o[4] = avpriv_reverse[ (samples[1] & 0x0FF00000) >> 20];
> +                o[5] = avpriv_reverse[ (samples[1] & 0xF0000000) >> 28];
>                  o += 6;
>                  samples += 2;
>              }
> @@ -146,11 +146,11 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt,
>              uint8_t vucf = s->framing_index == 0 ? 0x10 : 0;
>
>              for (channels = 0; channels < avctx->channels; channels += 2) {
> -                o[0] = ff_reverse[ samples[0] & 0xFF];
> -                o[1] = ff_reverse[(samples[0] & 0xFF00) >>  8];
> -                o[2] = ff_reverse[(samples[1] & 0x0F)   <<  4] | vucf;
> -                o[3] = ff_reverse[(samples[1] & 0x0FF0) >>  4];
> -                o[4] = ff_reverse[(samples[1] & 0xF000) >> 12];
> +                o[0] = avpriv_reverse[ samples[0] & 0xFF];
> +                o[1] = avpriv_reverse[(samples[0] & 0xFF00) >>  8];
> +                o[2] = avpriv_reverse[(samples[1] & 0x0F)   <<  4] | vucf;
> +                o[3] = avpriv_reverse[(samples[1] & 0x0FF0) >>  4];
> +                o[4] = avpriv_reverse[(samples[1] & 0xF000) >> 12];
>                  o += 5;
>                  samples += 2;
>
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index 1b332a754d..1537dfac97 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -284,7 +284,7 @@ static int deinvert_buffer(TiffContext *s, const uint8_t *src, int size)
>      if (!s->deinvert_buf)
>          return AVERROR(ENOMEM);
>      for (i = 0; i < size; i++)
> -        s->deinvert_buf[i] = ff_reverse[src[i]];
> +        s->deinvert_buf[i] = avpriv_reverse[src[i]];
>
>      return 0;
>  }
> @@ -469,7 +469,7 @@ static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride,
>          memcpy(src2, src, size);
>      } else {
>          for (i = 0; i < size; i++)
> -            src2[i] = ff_reverse[src[i]];
> +            src2[i] = avpriv_reverse[src[i]];
>      }
>      memset(src2 + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>      ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride,
> @@ -600,7 +600,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
>              } else {
>                  int i;
>                  for (i = 0; i < width; i++)
> -                    dst[i] = ff_reverse[src[i]];
> +                    dst[i] = avpriv_reverse[src[i]];
>              }
>              src += width;
>              break;
> @@ -610,7 +610,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
>                      av_log(s->avctx, AV_LOG_ERROR, "Read went out of bounds\n");
>                      return AVERROR_INVALIDDATA;
>                  }
> -                code = s->fill_order ? (int8_t) ff_reverse[*src++]: (int8_t) *src++;
> +                code = s->fill_order ? (int8_t) avpriv_reverse[*src++]: (int8_t) *src++;
>                  if (code >= 0) {
>                      code++;
>                      if (pixels + code > width ||
> @@ -639,7 +639,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
>              if (s->fill_order) {
>                  int i;
>                  for (i = 0; i < width; i++)
> -                    dst[i] = ff_reverse[dst[i]];
> +                    dst[i] = avpriv_reverse[dst[i]];
>              }
>              break;
>          }
> diff --git a/libavcodec/webp.c b/libavcodec/webp.c
> index 077bb06f85..c885d48901 100644
> --- a/libavcodec/webp.c
> +++ b/libavcodec/webp.c
> @@ -248,7 +248,7 @@ static av_always_inline int webp_get_vlc(GetBitContext *gb, VLC_TYPE (*table)[2]
>      UPDATE_CACHE(re, gb);
>
>      index = SHOW_UBITS(re, gb, 8);
> -    index = ff_reverse[index];
> +    index = avpriv_reverse[index];
>      code  = table[index][0];
>      n     = table[index][1];
>
> @@ -259,7 +259,7 @@ static av_always_inline int webp_get_vlc(GetBitContext *gb, VLC_TYPE (*table)[2]
>          nb_bits = -n;
>
>          index = SHOW_UBITS(re, gb, nb_bits);
> -        index = (ff_reverse[index] >> (8 - nb_bits)) + code;
> +        index = (avpriv_reverse[index] >> (8 - nb_bits)) + code;
>          code  = table[index][0];
>          n     = table[index][1];
>      }
> diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c
> index 915e9c7dc9..4ec7b3626e 100644
> --- a/libavcodec/wnv1.c
> +++ b/libavcodec/wnv1.c
> @@ -50,7 +50,7 @@ static inline int wnv1_get_code(WNV1Context *w, int base_value)
>      int v = get_vlc2(&w->gb, code_vlc.table, CODE_VLC_BITS, 1);
>
>      if (v == 15)
> -        return ff_reverse[get_bits(&w->gb, 8 - w->shift)];
> +        return avpriv_reverse[get_bits(&w->gb, 8 - w->shift)];
>      else
>          return base_value + ((v - 7U) << w->shift);
>  }
> @@ -87,7 +87,7 @@ static int decode_frame(AVCodecContext *avctx,
>      p->key_frame = 1;
>
>      for (i = 8; i < buf_size; i++)
> -        rbuf[i] = ff_reverse[buf[i]];
> +        rbuf[i] = avpriv_reverse[buf[i]];
>
>      if ((ret = init_get_bits8(&l->gb, rbuf + 8, buf_size - 8)) < 0)
>          return ret;
> diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c
> index d19bdaee23..28bffa7229 100644
> --- a/libavcodec/xbmdec.c
> +++ b/libavcodec/xbmdec.c
> @@ -103,13 +103,13 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data,
>                  val = convert(*ptr++);
>                  if (av_isxdigit(*ptr))
>                      val = (val << 4) + convert(*ptr++);
> -                *dst++ = ff_reverse[val];
> +                *dst++ = avpriv_reverse[val];
>                  if (av_isxdigit(*ptr) && j+1 < linesize) {
>                      j++;
>                      val = convert(*ptr++);
>                      if (av_isxdigit(*ptr))
>                          val = (val << 4) + convert(*ptr++);
> -                    *dst++ = ff_reverse[val];
> +                    *dst++ = avpriv_reverse[val];
>                  }
>              } else {
>                  av_log(avctx, AV_LOG_ERROR,
> diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
> index b25615f2a4..6449400456 100644
> --- a/libavcodec/xbmenc.c
> +++ b/libavcodec/xbmenc.c
> @@ -43,7 +43,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>      buf += snprintf(buf, 40, "static unsigned char image_bits[] = {\n");
>      for (i = 0; i < avctx->height; i++) {
>          for (j = 0; j < linesize; j++)
> -            buf += snprintf(buf, 7, " 0x%02X,", ff_reverse[*ptr++]);
> +            buf += snprintf(buf, 7, " 0x%02X,", avpriv_reverse[*ptr++]);
>          ptr += p->linesize[0] - linesize;
>          buf += snprintf(buf, 2, "\n");
>      }
> diff --git a/libavdevice/Makefile b/libavdevice/Makefile
> index 8228d62147..53b5f90b29 100644
> --- a/libavdevice/Makefile
> +++ b/libavdevice/Makefile
> @@ -9,7 +9,6 @@ OBJS    = alldevices.o                                                  \
>            utils.o                                                       \
>
>  OBJS-$(HAVE_LIBC_MSVCRT)                 += file_open.o
> -OBJS-$(CONFIG_SHARED)                    += reverse.o
>
>  # input/output devices
>  OBJS-$(CONFIG_ALSA_INDEV)                += alsa_dec.o alsa.o timefilter.o
> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
> index 94dae26003..4cf7c654b4 100644
> --- a/libavdevice/decklink_dec.cpp
> +++ b/libavdevice/decklink_dec.cpp
> @@ -213,7 +213,7 @@ static uint8_t* teletext_data_unit_from_op47_vbi_packet(int line, uint16_t *py,
>      tgt += 4;
>
>      for (i = 0; i < 42; i++)
> -       *tgt++ = ff_reverse[py[i] & 255];
> +       *tgt++ = avpriv_reverse[py[i] & 255];
>
>      return tgt;
>  }
> diff --git a/libavdevice/reverse.c b/libavdevice/reverse.c
> deleted file mode 100644
> index 440badaf34..0000000000
> --- a/libavdevice/reverse.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include "libavutil/reverse.c"
> diff --git a/libavutil/eval.c b/libavutil/eval.c
> index 5da9a6d83b..95495356f4 100644
> --- a/libavutil/eval.c
> +++ b/libavutil/eval.c
> @@ -265,7 +265,7 @@ static double eval_expr(Parser *p, AVExpr *e)
>              double x_max = eval_expr(p, e->param[1]);
>              for(i=-1; i<1024; i++) {
>                  if(i<255) {
> -                    p->var[0] = ff_reverse[i&255]*x_max/255;
> +                    p->var[0] = avpriv_reverse[i&255]*x_max/255;
>                  } else {
>                      p->var[0] = x_max*pow(0.9, i-255);
>                      if (i&1) p->var[0] *= -1;
> diff --git a/libavutil/reverse.c b/libavutil/reverse.c
> index 105eb03dda..1d46940c41 100644
> --- a/libavutil/reverse.c
> +++ b/libavutil/reverse.c
> @@ -19,8 +19,9 @@
>   */
>
>  #include <stdint.h>
> +#include "reverse.h"
>
> -const uint8_t ff_reverse[256] = {
> +const uint8_t avpriv_reverse[256] = {
>  0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
>  0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
>  0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
> diff --git a/libavutil/reverse.h b/libavutil/reverse.h
> index 4eb6123932..7bbaea7673 100644
> --- a/libavutil/reverse.h
> +++ b/libavutil/reverse.h
> @@ -22,7 +22,8 @@
>  #define AVUTIL_REVERSE_H
>
>  #include <stdint.h>
> +#include "internal.h"
>
> -extern const uint8_t ff_reverse[256];
> +extern av_export_avutil const uint8_t avpriv_reverse[256];
>
>  #endif /* AVUTIL_REVERSE_H */
> --
> 2.15.0


LGTM


Thanks
Nicolas George Dec. 1, 2017, 8:42 a.m. UTC | #2
James Almer (2017-11-30):
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Pros:
> Removes duplicate arrays and ugly c file including c files
> 
> Cons:
> Makes the array in libavutil effectively part of the ABI.
> Might not be worth doing for 256 bytes
> 
> 
> Something like this was probably sent before, so i guess it
> will be rejected again.

I think it is worse than that: the opposite was done on purpose.

I believe the rationale was that shared data object do not work
correctly with shared libraries on windows.

IMHO, it is yet another argument for merging the libraries.

(And to drop windows support. Only kidding.)

Regards,
Hendrik Leppkes Dec. 1, 2017, 8:49 a.m. UTC | #3
On Fri, Dec 1, 2017 at 9:42 AM, Nicolas George <george@nsup.org> wrote:
> James Almer (2017-11-30):
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> Pros:
>> Removes duplicate arrays and ugly c file including c files
>>
>> Cons:
>> Makes the array in libavutil effectively part of the ABI.
>> Might not be worth doing for 256 bytes
>>
>>
>> Something like this was probably sent before, so i guess it
>> will be rejected again.
>
> I think it is worse than that: the opposite was done on purpose.
>
> I believe the rationale was that shared data object do not work
> correctly with shared libraries on windows.
>

That problem was fixed recently.

But in any case,  this creates a lot of noise for very marginal gains,
not sure its really worth it.

- Hendrik
Michael Niedermayer Dec. 2, 2017, 12:56 a.m. UTC | #4
On Thu, Nov 30, 2017 at 10:19:36PM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Pros:
> Removes duplicate arrays and ugly c file including c files
> 

> Cons:
> Makes the array in libavutil effectively part of the ABI.
> Might not be worth doing for 256 bytes

if iam not mistaken
Accessing symbols accross libs cannot avoid indirection easily.
within a lib one can point to the table directly
so depending on platform this should be slower with shared libs

(this is all of course not strictly unavoidable, it could be done
 differently but its the way it works on linux if i dont misremember)

[...]
diff mbox

Patch

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ab7893f560..6942b2c926 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -129,7 +129,7 @@  OBJS-$(CONFIG_QSVENC)                  += qsvenc.o
 OBJS-$(CONFIG_RANGECODER)              += rangecoder.o
 OBJS-$(CONFIG_RDFT)                    += rdft.o
 OBJS-$(CONFIG_RV34DSP)                 += rv34dsp.o
-OBJS-$(CONFIG_SHARED)                  += log2_tab.o reverse.o
+OBJS-$(CONFIG_SHARED)                  += log2_tab.o
 OBJS-$(CONFIG_SINEWIN)                 += sinewin.o sinewin_fixed.o
 OBJS-$(CONFIG_SNAPPY)                  += snappy.o
 OBJS-$(CONFIG_STARTCODE)               += startcode.o
diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
index 9a11446f52..11d1564db3 100644
--- a/libavcodec/asvdec.c
+++ b/libavcodec/asvdec.c
@@ -71,7 +71,7 @@  static av_cold void init_vlcs(ASV1Context *a)
 // FIXME write a reversed bitstream reader to avoid the double reverse
 static inline int asv2_get_bits(GetBitContext *gb, int n)
 {
-    return ff_reverse[get_bits(gb, n) << (8 - n)];
+    return avpriv_reverse[get_bits(gb, n) << (8 - n)];
 }
 
 static inline int asv1_get_level(GetBitContext *gb)
@@ -229,7 +229,7 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     } else {
         int i;
         for (i = 0; i < buf_size; i++)
-            a->bitstream_buffer[i] = ff_reverse[buf[i]];
+            a->bitstream_buffer[i] = avpriv_reverse[buf[i]];
     }
 
     init_get_bits(&a->gb, a->bitstream_buffer, buf_size * 8);
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index c4eca2a13d..7ed932c934 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -37,7 +37,7 @@ 
 
 static inline void asv2_put_bits(PutBitContext *pb, int n, int v)
 {
-    put_bits(pb, n, ff_reverse[v << (8 - n)]);
+    put_bits(pb, n, avpriv_reverse[v << (8 - n)]);
 }
 
 static inline void asv1_put_level(PutBitContext *pb, int level)
@@ -306,7 +306,7 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     } else {
         int i;
         for (i = 0; i < 4 * size; i++)
-            pkt->data[i] = ff_reverse[pkt->data[i]];
+            pkt->data[i] = avpriv_reverse[pkt->data[i]];
     }
 
     pkt->size   = size * 4;
diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index dd601ffae0..b111fe98ba 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -446,7 +446,7 @@  static void fft(const int32_t in[2 * 256], cplx32 out[256])
     }
     /* post-rotation */
     for (i = 0; i < 256; i++) {
-        int b = ff_reverse[i];
+        int b = avpriv_reverse[i];
         rout[i].re = mul32(buf[b].re, cos_t(4 * i))
                    - mul32(buf[b].im, sin_t(4 * i));
         rout[i].im = mul32(buf[b].im, cos_t(4 * i))
diff --git a/libavcodec/dsd.c b/libavcodec/dsd.c
index 9104f38476..2233adf349 100644
--- a/libavcodec/dsd.c
+++ b/libavcodec/dsd.c
@@ -63,11 +63,11 @@  void ff_dsd2pcm_translate(DSDContext* s, size_t samples, int lsbf,
     pos = s->pos;
 
     while (samples-- > 0) {
-        s->buf[pos] = lsbf ? ff_reverse[*src] : *src;
+        s->buf[pos] = lsbf ? avpriv_reverse[*src] : *src;
         src += src_stride;
 
         p = s->buf + ((pos - CTABLES) & FIFOMASK);
-        *p = ff_reverse[*p];
+        *p = avpriv_reverse[*p];
 
         sum = 0.0;
         for (i = 0; i < CTABLES; i++) {
diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c
index 2c5c357acc..3974bdeeb2 100644
--- a/libavcodec/dsddec.c
+++ b/libavcodec/dsddec.c
@@ -50,7 +50,7 @@  static av_cold int decode_init(AVCodecContext *avctx)
     if (!s)
         return AVERROR(ENOMEM);
 
-    silence = avctx->codec_id == AV_CODEC_ID_DSD_LSBF || avctx->codec_id == AV_CODEC_ID_DSD_LSBF_PLANAR ? ff_reverse[DSD_SILENCE] : DSD_SILENCE;
+    silence = avctx->codec_id == AV_CODEC_ID_DSD_LSBF || avctx->codec_id == AV_CODEC_ID_DSD_LSBF_PLANAR ? avpriv_reverse[DSD_SILENCE] : DSD_SILENCE;
     for (i = 0; i < avctx->channels; i++) {
         s[i].pos = 0;
         memset(s[i].buf, silence, sizeof(s[i].buf));
diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c
index 368cb64931..d9c4734209 100644
--- a/libavcodec/dstdec.c
+++ b/libavcodec/dstdec.c
@@ -197,7 +197,7 @@  static av_always_inline void ac_get(ArithCoder *ac, GetBitContext *gb, int p, in
 
 static uint8_t prob_dst_x_bit(int c)
 {
-    return (ff_reverse[c & 127] >> 1) + 1;
+    return (avpriv_reverse[c & 127] >> 1) + 1;
 }
 
 static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets)
diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c
index 4971b84308..39c2a23279 100644
--- a/libavcodec/indeo2.c
+++ b/libavcodec/indeo2.c
@@ -175,7 +175,7 @@  static int ir2_decode_frame(AVCodecContext *avctx,
     /* decide whether frame uses deltas or not */
 #ifndef BITSTREAM_READER_LE
     for (i = 0; i < buf_size; i++)
-        buf[i] = ff_reverse[buf[i]];
+        buf[i] = avpriv_reverse[buf[i]];
 #endif
 
     if ((ret = init_get_bits8(&s->gb, buf + start, buf_size - start)) < 0)
diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
index cea40d82ca..76cf04f0a1 100644
--- a/libavcodec/ivi.c
+++ b/libavcodec/ivi.c
@@ -125,10 +125,10 @@  static uint16_t inv_bits(uint16_t val, int nbits)
     uint16_t res;
 
     if (nbits <= 8) {
-        res = ff_reverse[val] >> (8 - nbits);
+        res = avpriv_reverse[val] >> (8 - nbits);
     } else
-        res = ((ff_reverse[val & 0xFF] << 8) +
-               (ff_reverse[val >> 8])) >> (16 - nbits);
+        res = ((avpriv_reverse[val & 0xFF] << 8) +
+               (avpriv_reverse[val >> 8])) >> (16 - nbits);
 
     return res;
 }
diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 1c35664318..c038cb5cd9 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -242,10 +242,10 @@  static inline int8_t ff_u8_to_s8(uint8_t a)
 
 static av_always_inline uint32_t bitswap_32(uint32_t x)
 {
-    return (uint32_t)ff_reverse[ x        & 0xFF] << 24 |
-           (uint32_t)ff_reverse[(x >> 8)  & 0xFF] << 16 |
-           (uint32_t)ff_reverse[(x >> 16) & 0xFF] << 8  |
-           (uint32_t)ff_reverse[ x >> 24];
+    return (uint32_t)avpriv_reverse[ x        & 0xFF] << 24 |
+           (uint32_t)avpriv_reverse[(x >> 8)  & 0xFF] << 16 |
+           (uint32_t)avpriv_reverse[(x >> 16) & 0xFF] << 8  |
+           (uint32_t)avpriv_reverse[ x >> 24];
 }
 
 #endif /* AVCODEC_MATHOPS_H */
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index ac5ac4bca4..eda097cd3d 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2282,8 +2282,8 @@  static int mpeg_decode_a53_cc(AVCodecContext *avctx,
                         field = (field == 2 ? 1 : 0);
                         if (!s1->mpeg_enc_ctx.top_field_first) field = !field;
                         cap[0] = 0x04 | field;
-                        cap[1] = ff_reverse[cc1];
-                        cap[2] = ff_reverse[cc2];
+                        cap[1] = avpriv_reverse[cc1];
+                        cap[2] = avpriv_reverse[cc2];
                     }
                     cap += 3;
                 }
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 8c326c6829..ffb5253e4f 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -126,8 +126,8 @@  static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
         break;
     case AV_CODEC_ID_PCM_S24DAUD:
         for (; n > 0; n--) {
-            uint32_t tmp = ff_reverse[(*samples >> 8) & 0xff] +
-                           (ff_reverse[*samples & 0xff] << 8);
+            uint32_t tmp = avpriv_reverse[(*samples >> 8) & 0xff] +
+                           (avpriv_reverse[*samples & 0xff] << 8);
             tmp <<= 4; // sync flags would go here
             bytestream_put_be24(&dst, tmp);
             samples++;
@@ -388,8 +388,8 @@  static int pcm_decode_frame(AVCodecContext *avctx, void *data,
         for (; n > 0; n--) {
             uint32_t v = bytestream_get_be24(&src);
             v >>= 4; // sync flags are here
-            AV_WN16A(samples, ff_reverse[(v >> 8) & 0xff] +
-                             (ff_reverse[v        & 0xff] << 8));
+            AV_WN16A(samples, avpriv_reverse[(v >> 8) & 0xff] +
+                             (avpriv_reverse[v        & 0xff] << 8));
             samples += 2;
         }
         break;
diff --git a/libavcodec/reverse.c b/libavcodec/reverse.c
deleted file mode 100644
index 440badaf34..0000000000
--- a/libavcodec/reverse.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include "libavutil/reverse.c"
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
index 584b58e28e..d14ee45aa2 100644
--- a/libavcodec/s302m.c
+++ b/libavcodec/s302m.c
@@ -120,13 +120,13 @@  static int s302m_decode_frame(AVCodecContext *avctx, void *data,
     if (avctx->bits_per_raw_sample == 24) {
         uint32_t *o = (uint32_t *)frame->data[0];
         for (; buf_size > 6; buf_size -= 7) {
-            *o++ = ((unsigned)ff_reverse[buf[2]]        << 24) |
-                   (ff_reverse[buf[1]]        << 16) |
-                   (ff_reverse[buf[0]]        <<  8);
-            *o++ = ((unsigned)ff_reverse[buf[6] & 0xf0] << 28) |
-                   (ff_reverse[buf[5]]        << 20) |
-                   (ff_reverse[buf[4]]        << 12) |
-                   (ff_reverse[buf[3] & 0x0f] <<  4);
+            *o++ = ((unsigned)avpriv_reverse[buf[2]]        << 24) |
+                   (avpriv_reverse[buf[1]]        << 16) |
+                   (avpriv_reverse[buf[0]]        <<  8);
+            *o++ = ((unsigned)avpriv_reverse[buf[6] & 0xf0] << 28) |
+                   (avpriv_reverse[buf[5]]        << 20) |
+                   (avpriv_reverse[buf[4]]        << 12) |
+                   (avpriv_reverse[buf[3] & 0x0f] <<  4);
             buf += 7;
         }
         o = (uint32_t *)frame->data[0];
@@ -142,12 +142,12 @@  static int s302m_decode_frame(AVCodecContext *avctx, void *data,
     } else if (avctx->bits_per_raw_sample == 20) {
         uint32_t *o = (uint32_t *)frame->data[0];
         for (; buf_size > 5; buf_size -= 6) {
-            *o++ = ((unsigned)ff_reverse[buf[2] & 0xf0] << 28) |
-                   (ff_reverse[buf[1]]        << 20) |
-                   (ff_reverse[buf[0]]        << 12);
-            *o++ = ((unsigned)ff_reverse[buf[5] & 0xf0] << 28) |
-                   (ff_reverse[buf[4]]        << 20) |
-                   (ff_reverse[buf[3]]        << 12);
+            *o++ = ((unsigned)avpriv_reverse[buf[2] & 0xf0] << 28) |
+                   (avpriv_reverse[buf[1]]        << 20) |
+                   (avpriv_reverse[buf[0]]        << 12);
+            *o++ = ((unsigned)avpriv_reverse[buf[5] & 0xf0] << 28) |
+                   (avpriv_reverse[buf[4]]        << 20) |
+                   (avpriv_reverse[buf[3]]        << 12);
             buf += 6;
         }
         o = (uint32_t *)frame->data[0];
@@ -163,11 +163,11 @@  static int s302m_decode_frame(AVCodecContext *avctx, void *data,
     } else {
         uint16_t *o = (uint16_t *)frame->data[0];
         for (; buf_size > 4; buf_size -= 5) {
-            *o++ = (ff_reverse[buf[1]]        <<  8) |
-                    ff_reverse[buf[0]];
-            *o++ = (ff_reverse[buf[4] & 0xf0] << 12) |
-                   (ff_reverse[buf[3]]        <<  4) |
-                   (ff_reverse[buf[2]]        >>  4);
+            *o++ = (avpriv_reverse[buf[1]]        <<  8) |
+                    avpriv_reverse[buf[0]];
+            *o++ = (avpriv_reverse[buf[4] & 0xf0] << 12) |
+                   (avpriv_reverse[buf[3]]        <<  4) |
+                   (avpriv_reverse[buf[2]]        >>  4);
             buf += 5;
         }
         o = (uint16_t *)frame->data[0];
diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c
index b04a54e482..c5634b09bf 100644
--- a/libavcodec/s302menc.c
+++ b/libavcodec/s302menc.c
@@ -103,13 +103,13 @@  static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt,
             uint8_t vucf = s->framing_index == 0 ? 0x10: 0;
 
             for (channels = 0; channels < avctx->channels; channels += 2) {
-                o[0] = ff_reverse[(samples[0] & 0x0000FF00) >> 8];
-                o[1] = ff_reverse[(samples[0] & 0x00FF0000) >> 16];
-                o[2] = ff_reverse[(samples[0] & 0xFF000000) >> 24];
-                o[3] = ff_reverse[(samples[1] & 0x00000F00) >> 4] | vucf;
-                o[4] = ff_reverse[(samples[1] & 0x000FF000) >> 12];
-                o[5] = ff_reverse[(samples[1] & 0x0FF00000) >> 20];
-                o[6] = ff_reverse[(samples[1] & 0xF0000000) >> 28];
+                o[0] = avpriv_reverse[(samples[0] & 0x0000FF00) >> 8];
+                o[1] = avpriv_reverse[(samples[0] & 0x00FF0000) >> 16];
+                o[2] = avpriv_reverse[(samples[0] & 0xFF000000) >> 24];
+                o[3] = avpriv_reverse[(samples[1] & 0x00000F00) >> 4] | vucf;
+                o[4] = avpriv_reverse[(samples[1] & 0x000FF000) >> 12];
+                o[5] = avpriv_reverse[(samples[1] & 0x0FF00000) >> 20];
+                o[6] = avpriv_reverse[(samples[1] & 0xF0000000) >> 28];
                 o += 7;
                 samples += 2;
             }
@@ -125,12 +125,12 @@  static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt,
             uint8_t vucf = s->framing_index == 0 ? 0x80: 0;
 
             for (channels = 0; channels < avctx->channels; channels += 2) {
-                o[0] = ff_reverse[ (samples[0] & 0x000FF000) >> 12];
-                o[1] = ff_reverse[ (samples[0] & 0x0FF00000) >> 20];
-                o[2] = ff_reverse[((samples[0] & 0xF0000000) >> 28) | vucf];
-                o[3] = ff_reverse[ (samples[1] & 0x000FF000) >> 12];
-                o[4] = ff_reverse[ (samples[1] & 0x0FF00000) >> 20];
-                o[5] = ff_reverse[ (samples[1] & 0xF0000000) >> 28];
+                o[0] = avpriv_reverse[ (samples[0] & 0x000FF000) >> 12];
+                o[1] = avpriv_reverse[ (samples[0] & 0x0FF00000) >> 20];
+                o[2] = avpriv_reverse[((samples[0] & 0xF0000000) >> 28) | vucf];
+                o[3] = avpriv_reverse[ (samples[1] & 0x000FF000) >> 12];
+                o[4] = avpriv_reverse[ (samples[1] & 0x0FF00000) >> 20];
+                o[5] = avpriv_reverse[ (samples[1] & 0xF0000000) >> 28];
                 o += 6;
                 samples += 2;
             }
@@ -146,11 +146,11 @@  static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt,
             uint8_t vucf = s->framing_index == 0 ? 0x10 : 0;
 
             for (channels = 0; channels < avctx->channels; channels += 2) {
-                o[0] = ff_reverse[ samples[0] & 0xFF];
-                o[1] = ff_reverse[(samples[0] & 0xFF00) >>  8];
-                o[2] = ff_reverse[(samples[1] & 0x0F)   <<  4] | vucf;
-                o[3] = ff_reverse[(samples[1] & 0x0FF0) >>  4];
-                o[4] = ff_reverse[(samples[1] & 0xF000) >> 12];
+                o[0] = avpriv_reverse[ samples[0] & 0xFF];
+                o[1] = avpriv_reverse[(samples[0] & 0xFF00) >>  8];
+                o[2] = avpriv_reverse[(samples[1] & 0x0F)   <<  4] | vucf;
+                o[3] = avpriv_reverse[(samples[1] & 0x0FF0) >>  4];
+                o[4] = avpriv_reverse[(samples[1] & 0xF000) >> 12];
                 o += 5;
                 samples += 2;
 
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 1b332a754d..1537dfac97 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -284,7 +284,7 @@  static int deinvert_buffer(TiffContext *s, const uint8_t *src, int size)
     if (!s->deinvert_buf)
         return AVERROR(ENOMEM);
     for (i = 0; i < size; i++)
-        s->deinvert_buf[i] = ff_reverse[src[i]];
+        s->deinvert_buf[i] = avpriv_reverse[src[i]];
 
     return 0;
 }
@@ -469,7 +469,7 @@  static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride,
         memcpy(src2, src, size);
     } else {
         for (i = 0; i < size; i++)
-            src2[i] = ff_reverse[src[i]];
+            src2[i] = avpriv_reverse[src[i]];
     }
     memset(src2 + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
     ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride,
@@ -600,7 +600,7 @@  static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
             } else {
                 int i;
                 for (i = 0; i < width; i++)
-                    dst[i] = ff_reverse[src[i]];
+                    dst[i] = avpriv_reverse[src[i]];
             }
             src += width;
             break;
@@ -610,7 +610,7 @@  static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
                     av_log(s->avctx, AV_LOG_ERROR, "Read went out of bounds\n");
                     return AVERROR_INVALIDDATA;
                 }
-                code = s->fill_order ? (int8_t) ff_reverse[*src++]: (int8_t) *src++;
+                code = s->fill_order ? (int8_t) avpriv_reverse[*src++]: (int8_t) *src++;
                 if (code >= 0) {
                     code++;
                     if (pixels + code > width ||
@@ -639,7 +639,7 @@  static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
             if (s->fill_order) {
                 int i;
                 for (i = 0; i < width; i++)
-                    dst[i] = ff_reverse[dst[i]];
+                    dst[i] = avpriv_reverse[dst[i]];
             }
             break;
         }
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 077bb06f85..c885d48901 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -248,7 +248,7 @@  static av_always_inline int webp_get_vlc(GetBitContext *gb, VLC_TYPE (*table)[2]
     UPDATE_CACHE(re, gb);
 
     index = SHOW_UBITS(re, gb, 8);
-    index = ff_reverse[index];
+    index = avpriv_reverse[index];
     code  = table[index][0];
     n     = table[index][1];
 
@@ -259,7 +259,7 @@  static av_always_inline int webp_get_vlc(GetBitContext *gb, VLC_TYPE (*table)[2]
         nb_bits = -n;
 
         index = SHOW_UBITS(re, gb, nb_bits);
-        index = (ff_reverse[index] >> (8 - nb_bits)) + code;
+        index = (avpriv_reverse[index] >> (8 - nb_bits)) + code;
         code  = table[index][0];
         n     = table[index][1];
     }
diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c
index 915e9c7dc9..4ec7b3626e 100644
--- a/libavcodec/wnv1.c
+++ b/libavcodec/wnv1.c
@@ -50,7 +50,7 @@  static inline int wnv1_get_code(WNV1Context *w, int base_value)
     int v = get_vlc2(&w->gb, code_vlc.table, CODE_VLC_BITS, 1);
 
     if (v == 15)
-        return ff_reverse[get_bits(&w->gb, 8 - w->shift)];
+        return avpriv_reverse[get_bits(&w->gb, 8 - w->shift)];
     else
         return base_value + ((v - 7U) << w->shift);
 }
@@ -87,7 +87,7 @@  static int decode_frame(AVCodecContext *avctx,
     p->key_frame = 1;
 
     for (i = 8; i < buf_size; i++)
-        rbuf[i] = ff_reverse[buf[i]];
+        rbuf[i] = avpriv_reverse[buf[i]];
 
     if ((ret = init_get_bits8(&l->gb, rbuf + 8, buf_size - 8)) < 0)
         return ret;
diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c
index d19bdaee23..28bffa7229 100644
--- a/libavcodec/xbmdec.c
+++ b/libavcodec/xbmdec.c
@@ -103,13 +103,13 @@  static int xbm_decode_frame(AVCodecContext *avctx, void *data,
                 val = convert(*ptr++);
                 if (av_isxdigit(*ptr))
                     val = (val << 4) + convert(*ptr++);
-                *dst++ = ff_reverse[val];
+                *dst++ = avpriv_reverse[val];
                 if (av_isxdigit(*ptr) && j+1 < linesize) {
                     j++;
                     val = convert(*ptr++);
                     if (av_isxdigit(*ptr))
                         val = (val << 4) + convert(*ptr++);
-                    *dst++ = ff_reverse[val];
+                    *dst++ = avpriv_reverse[val];
                 }
             } else {
                 av_log(avctx, AV_LOG_ERROR,
diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index b25615f2a4..6449400456 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -43,7 +43,7 @@  static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     buf += snprintf(buf, 40, "static unsigned char image_bits[] = {\n");
     for (i = 0; i < avctx->height; i++) {
         for (j = 0; j < linesize; j++)
-            buf += snprintf(buf, 7, " 0x%02X,", ff_reverse[*ptr++]);
+            buf += snprintf(buf, 7, " 0x%02X,", avpriv_reverse[*ptr++]);
         ptr += p->linesize[0] - linesize;
         buf += snprintf(buf, 2, "\n");
     }
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 8228d62147..53b5f90b29 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -9,7 +9,6 @@  OBJS    = alldevices.o                                                  \
           utils.o                                                       \
 
 OBJS-$(HAVE_LIBC_MSVCRT)                 += file_open.o
-OBJS-$(CONFIG_SHARED)                    += reverse.o
 
 # input/output devices
 OBJS-$(CONFIG_ALSA_INDEV)                += alsa_dec.o alsa.o timefilter.o
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 94dae26003..4cf7c654b4 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -213,7 +213,7 @@  static uint8_t* teletext_data_unit_from_op47_vbi_packet(int line, uint16_t *py,
     tgt += 4;
 
     for (i = 0; i < 42; i++)
-       *tgt++ = ff_reverse[py[i] & 255];
+       *tgt++ = avpriv_reverse[py[i] & 255];
 
     return tgt;
 }
diff --git a/libavdevice/reverse.c b/libavdevice/reverse.c
deleted file mode 100644
index 440badaf34..0000000000
--- a/libavdevice/reverse.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include "libavutil/reverse.c"
diff --git a/libavutil/eval.c b/libavutil/eval.c
index 5da9a6d83b..95495356f4 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -265,7 +265,7 @@  static double eval_expr(Parser *p, AVExpr *e)
             double x_max = eval_expr(p, e->param[1]);
             for(i=-1; i<1024; i++) {
                 if(i<255) {
-                    p->var[0] = ff_reverse[i&255]*x_max/255;
+                    p->var[0] = avpriv_reverse[i&255]*x_max/255;
                 } else {
                     p->var[0] = x_max*pow(0.9, i-255);
                     if (i&1) p->var[0] *= -1;
diff --git a/libavutil/reverse.c b/libavutil/reverse.c
index 105eb03dda..1d46940c41 100644
--- a/libavutil/reverse.c
+++ b/libavutil/reverse.c
@@ -19,8 +19,9 @@ 
  */
 
 #include <stdint.h>
+#include "reverse.h"
 
-const uint8_t ff_reverse[256] = {
+const uint8_t avpriv_reverse[256] = {
 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
diff --git a/libavutil/reverse.h b/libavutil/reverse.h
index 4eb6123932..7bbaea7673 100644
--- a/libavutil/reverse.h
+++ b/libavutil/reverse.h
@@ -22,7 +22,8 @@ 
 #define AVUTIL_REVERSE_H
 
 #include <stdint.h>
+#include "internal.h"
 
-extern const uint8_t ff_reverse[256];
+extern av_export_avutil const uint8_t avpriv_reverse[256];
 
 #endif /* AVUTIL_REVERSE_H */