mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Add support for hard-coding the 256kB large dv_vlc_map table.
Originally committed as revision 22622 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
8de0859bcb
commit
c787cb339e
@ -626,6 +626,12 @@ $(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=15
|
||||
$(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=15
|
||||
endif
|
||||
|
||||
ifdef CONFIG_SMALL
|
||||
$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=1
|
||||
else
|
||||
$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0
|
||||
endif
|
||||
|
||||
$(SUBDIR)%_tablegen$(HOSTEXESUF): $(SUBDIR)%_tablegen.c $(SUBDIR)tableprint.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
|
||||
|
||||
@ -634,6 +640,7 @@ $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF)
|
||||
|
||||
ifdef CONFIG_HARDCODED_TABLES
|
||||
$(SUBDIR)aac.o: $(SUBDIR)cbrt_tables.h
|
||||
$(SUBDIR)dv.o: $(SUBDIR)dv_tables.h
|
||||
$(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h
|
||||
$(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h
|
||||
$(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "put_bits.h"
|
||||
#include "simple_idct.h"
|
||||
#include "dvdata.h"
|
||||
#include "dv_vlc_data.h"
|
||||
#include "dv_tablegen.h"
|
||||
|
||||
//#undef NDEBUG
|
||||
//#include <assert.h>
|
||||
@ -65,21 +65,8 @@ typedef struct DVVideoContext {
|
||||
|
||||
#define TEX_VLC_BITS 9
|
||||
|
||||
#if CONFIG_SMALL
|
||||
#define DV_VLC_MAP_RUN_SIZE 15
|
||||
#define DV_VLC_MAP_LEV_SIZE 23
|
||||
#else
|
||||
#define DV_VLC_MAP_RUN_SIZE 64
|
||||
#define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check
|
||||
#endif
|
||||
|
||||
/* XXX: also include quantization */
|
||||
static RL_VLC_ELEM dv_rl_vlc[1184];
|
||||
/* VLC encoding lookup table */
|
||||
static struct dv_vlc_pair {
|
||||
uint32_t vlc;
|
||||
uint8_t size;
|
||||
} dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
|
||||
|
||||
static inline int dv_work_pool_size(const DVprofile *d)
|
||||
{
|
||||
@ -326,47 +313,7 @@ static av_cold int dvvideo_init(AVCodecContext *avctx)
|
||||
}
|
||||
free_vlc(&dv_vlc);
|
||||
|
||||
for (i = 0; i < NB_DV_VLC - 1; i++) {
|
||||
if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
|
||||
continue;
|
||||
#if CONFIG_SMALL
|
||||
if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0)
|
||||
continue;
|
||||
|
||||
dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc =
|
||||
dv_vlc_bits[i] << (!!dv_vlc_level[i]);
|
||||
dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size =
|
||||
dv_vlc_len[i] + (!!dv_vlc_level[i]);
|
||||
}
|
||||
for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
|
||||
#if CONFIG_SMALL
|
||||
for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
|
||||
if (dv_vlc_map[i][j].size == 0) {
|
||||
dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
|
||||
(dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
|
||||
dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
|
||||
dv_vlc_map[0][j].size;
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) {
|
||||
if (dv_vlc_map[i][j].size == 0) {
|
||||
dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
|
||||
(dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
|
||||
dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
|
||||
dv_vlc_map[0][j].size;
|
||||
}
|
||||
dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc =
|
||||
dv_vlc_map[i][j].vlc | 1;
|
||||
dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size =
|
||||
dv_vlc_map[i][j].size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
dv_vlc_map_tableinit();
|
||||
}
|
||||
|
||||
/* Generic DSP setup */
|
||||
|
50
libavcodec/dv_tablegen.c
Normal file
50
libavcodec/dv_tablegen.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Generate a header file for hardcoded DV tables
|
||||
*
|
||||
* Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@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
|
||||
#ifndef CONFIG_SMALL
|
||||
#error CONFIG_SMALL must be defined to generate tables
|
||||
#endif
|
||||
#include "dv_tablegen.h"
|
||||
#include "tableprint.h"
|
||||
#include <inttypes.h>
|
||||
|
||||
WRITE_1D_FUNC_ARGV(vlc_pair, struct dv_vlc_pair, 7,
|
||||
"{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
|
||||
WRITE_2D_FUNC(vlc_pair, struct dv_vlc_pair)
|
||||
|
||||
void tableinit(void)
|
||||
{
|
||||
dv_vlc_map_tableinit();
|
||||
}
|
||||
|
||||
const struct tabledef tables[] = {
|
||||
{
|
||||
"static const struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]",
|
||||
write_vlc_pair_2d_array,
|
||||
dv_vlc_map,
|
||||
DV_VLC_MAP_RUN_SIZE,
|
||||
DV_VLC_MAP_LEV_SIZE
|
||||
},
|
||||
{ NULL }
|
||||
};
|
96
libavcodec/dv_tablegen.h
Normal file
96
libavcodec/dv_tablegen.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Header file for hardcoded DV tables
|
||||
*
|
||||
* Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@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
|
||||
*/
|
||||
|
||||
#ifndef DV_TABLEGEN_H
|
||||
#define DV_TABLEGEN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "dv_vlc_data.h"
|
||||
|
||||
#if CONFIG_SMALL
|
||||
#define DV_VLC_MAP_RUN_SIZE 15
|
||||
#define DV_VLC_MAP_LEV_SIZE 23
|
||||
#else
|
||||
#define DV_VLC_MAP_RUN_SIZE 64
|
||||
#define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check
|
||||
#endif
|
||||
|
||||
/* VLC encoding lookup table */
|
||||
struct dv_vlc_pair {
|
||||
uint32_t vlc;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
#define dv_vlc_map_tableinit()
|
||||
#include "libavcodec/dv_tables.h"
|
||||
#else
|
||||
static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
|
||||
|
||||
static void dv_vlc_map_tableinit(void)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < NB_DV_VLC - 1; i++) {
|
||||
if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
|
||||
continue;
|
||||
#if CONFIG_SMALL
|
||||
if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0)
|
||||
continue;
|
||||
|
||||
dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc =
|
||||
dv_vlc_bits[i] << (!!dv_vlc_level[i]);
|
||||
dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size =
|
||||
dv_vlc_len[i] + (!!dv_vlc_level[i]);
|
||||
}
|
||||
for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
|
||||
#if CONFIG_SMALL
|
||||
for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
|
||||
if (dv_vlc_map[i][j].size == 0) {
|
||||
dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
|
||||
(dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
|
||||
dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
|
||||
dv_vlc_map[0][j].size;
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) {
|
||||
if (dv_vlc_map[i][j].size == 0) {
|
||||
dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
|
||||
(dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
|
||||
dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
|
||||
dv_vlc_map[0][j].size;
|
||||
}
|
||||
dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc =
|
||||
dv_vlc_map[i][j].vlc | 1;
|
||||
dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size =
|
||||
dv_vlc_map[i][j].size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_HARDCODED_TABLES */
|
||||
|
||||
#endif /* DV_TABLEGEN_H */
|
Loading…
Reference in New Issue
Block a user