[FFmpeg-devel] [PATCH 2/2] lavc/pcm_tablegen: always generate tables at runtime.

Ganesh Ajjanagadde gajjanagadde at gmail.com
Tue Jan 5 02:27:39 CET 2016


On Wed, Dec 30, 2015 at 8:34 PM, Ganesh Ajjanagadde
<gajjanagadde at gmail.com> wrote:
> Previous commit has sped up pcm_tablegen slightly, and table generation
> of the alaw and mulaw tables is ~ 20k cycles. Thus, these tables can
> always be generated at runtime.
>
> Tested with/without --enable-hardcoded-tables.
>
> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> ---
>  libavcodec/Makefile       |  4 +---
>  libavcodec/pcm_tablegen.c | 39 ---------------------------------------
>  libavcodec/pcm_tablegen.h |  6 ------
>  3 files changed, 1 insertion(+), 48 deletions(-)
>  delete mode 100644 libavcodec/pcm_tablegen.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 0717d0a..568bc8a 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -978,7 +978,6 @@ HOSTPROGS = aacps_tablegen                                              \
>              dv_tablegen                                                 \
>              motionpixels_tablegen                                       \
>              mpegaudio_tablegen                                          \
> -            pcm_tablegen                                                \
>              qdm2_tablegen                                               \
>              sinewin_tablegen                                            \
>              sinewin_fixed_tablegen                                      \
> @@ -1003,7 +1002,7 @@ endif
>  GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacps_fixed_tables.h \
>                dv_tables.h     \
>                sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h motionpixels_tables.h \
> -              pcm_tables.h qdm2_tables.h
> +              qdm2_tables.h
>  GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS))
>
>  $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF)
> @@ -1021,6 +1020,5 @@ $(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h
>  $(SUBDIR)mpegaudiodec_fixed.o: $(SUBDIR)mpegaudio_tables.h
>  $(SUBDIR)mpegaudiodec_float.o: $(SUBDIR)mpegaudio_tables.h
>  $(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
> -$(SUBDIR)pcm.o: $(SUBDIR)pcm_tables.h
>  $(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h
>  endif
> diff --git a/libavcodec/pcm_tablegen.c b/libavcodec/pcm_tablegen.c
> deleted file mode 100644
> index bf8e7fb..0000000
> --- a/libavcodec/pcm_tablegen.c
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/*
> - * Generate a header file for hardcoded PCM tables
> - *
> - * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> - *
> - * This file is part of FFmpeg.
> - *
> - * FFmpeg is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2.1 of the License, or (at your option) any later version.
> - *
> - * FFmpeg is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with FFmpeg; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> - */
> -
> -#include <stdlib.h>
> -#define CONFIG_HARDCODED_TABLES 0
> -#include "pcm_tablegen.h"
> -#include "tableprint.h"
> -
> -int main(void)
> -{
> -    pcm_alaw_tableinit();
> -    pcm_ulaw_tableinit();
> -
> -    write_fileheader();
> -
> -    WRITE_ARRAY("static const", uint8_t, linear_to_alaw);
> -    WRITE_ARRAY("static const", uint8_t, linear_to_ulaw);
> -
> -    return 0;
> -}
> diff --git a/libavcodec/pcm_tablegen.h b/libavcodec/pcm_tablegen.h
> index 7269977..d73a14e 100644
> --- a/libavcodec/pcm_tablegen.h
> +++ b/libavcodec/pcm_tablegen.h
> @@ -72,11 +72,6 @@ static av_cold int ulaw2linear(unsigned char u_val)
>          return (u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS);
>  }
>
> -#if CONFIG_HARDCODED_TABLES
> -#define pcm_alaw_tableinit()
> -#define pcm_ulaw_tableinit()
> -#include "libavcodec/pcm_tables.h"
> -#else
>  /* 16384 entries per table */
>  static uint8_t linear_to_alaw[16384];
>  static uint8_t linear_to_ulaw[16384];
> @@ -114,6 +109,5 @@ static void pcm_ulaw_tableinit(void)
>  {
>      build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);
>  }
> -#endif /* CONFIG_HARDCODED_TABLES */
>
>  #endif /* AVCODEC_PCM_TABLEGEN_H */
> --
> 2.6.4
>

dropped, some have reservations about this.


More information about the ffmpeg-devel mailing list