[FFmpeg-devel] [PATCH] Electronic Arts TGV decoder

Reimar Döffinger Reimar.Doeffinger
Sat Jul 19 11:30:38 CEST 2008


Hello,
>  /**
> - * \brief copy previously decoded bytes to current position
> - * \param back how many bytes back we start
> + * \brief deliberate overlapping memcpy implementation
> + * \param dst destination buffer; must be padded by 12 bytes
> + * \param back how many bytes back we start (the initial size of the overlapping window)
>   * \param cnt number of bytes to copy, must be >= 0
>   *
>   * cnt > back is valid, this will copy the bytes we just copied,
>   * thus creating a repeating pattern with a period length of back.
>   */
> -static inline void copy_backptr(LZOContext *c, int back, int cnt) {
> -    register const uint8_t *src = &c->out[-back];
> -    register uint8_t *dst = c->out;
> -    if (src < c->out_start || src > dst) {
> -        c->error |= LZO_INVALID_BACKPTR;
> -        return;
> -    }
> -    if (cnt > c->out_end - dst) {
> -        cnt = FFMAX(c->out_end - dst, 0);
> -        c->error |= LZO_OUTPUT_FULL;
> -    }
> +void av_memcpy_backptr(uint8_t *dst, int back, int cnt) {
> +    const uint8_t *src = dst-back;
>      if (back == 1) {
>          memset(dst, *src, cnt);
>          dst += cnt;
> @@ -157,10 +149,32 @@
>          }
>          dst += cnt;
>      }
> -    c->out = dst;
>  }
>  
>  /**
> + * \brief copy previously decoded bytes to current position
> + * \param back how many bytes back we start
> + * \param cnt number of bytes to copy, must be >= 0
> + *
> + * cnt > back is valid, this will copy the bytes we just copied,
> + * thus creating a repeating pattern with a period length of back.
> + */
> +static inline void copy_backptr(LZOContext *c, int back, int cnt) {

The diff should be smaller if you change the order of these two
functions.

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list