Revision c787cb33

View differences:

libavcodec/Makefile
626 626
$(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=15
627 627
endif
628 628

  
629
ifdef CONFIG_SMALL
630
$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=1
631
else
632
$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0
633
endif
634

  
629 635
$(SUBDIR)%_tablegen$(HOSTEXESUF): $(SUBDIR)%_tablegen.c $(SUBDIR)tableprint.c
630 636
	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
631 637

  
......
634 640

  
635 641
ifdef CONFIG_HARDCODED_TABLES
636 642
$(SUBDIR)aac.o: $(SUBDIR)cbrt_tables.h
643
$(SUBDIR)dv.o: $(SUBDIR)dv_tables.h
637 644
$(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h
638 645
$(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h
639 646
$(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h
libavcodec/dv.c
44 44
#include "put_bits.h"
45 45
#include "simple_idct.h"
46 46
#include "dvdata.h"
47
#include "dv_vlc_data.h"
47
#include "dv_tablegen.h"
48 48

  
49 49
//#undef NDEBUG
50 50
//#include <assert.h>
......
65 65

  
66 66
#define TEX_VLC_BITS 9
67 67

  
68
#if CONFIG_SMALL
69
#define DV_VLC_MAP_RUN_SIZE 15
70
#define DV_VLC_MAP_LEV_SIZE 23
71
#else
72
#define DV_VLC_MAP_RUN_SIZE  64
73
#define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check
74
#endif
75

  
76 68
/* XXX: also include quantization */
77 69
static RL_VLC_ELEM dv_rl_vlc[1184];
78
/* VLC encoding lookup table */
79
static struct dv_vlc_pair {
80
   uint32_t vlc;
81
   uint8_t  size;
82
} dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
83 70

  
84 71
static inline int dv_work_pool_size(const DVprofile *d)
85 72
{
......
326 313
        }
327 314
        free_vlc(&dv_vlc);
328 315

  
329
        for (i = 0; i < NB_DV_VLC - 1; i++) {
330
           if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
331
               continue;
332
#if CONFIG_SMALL
333
           if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE)
334
               continue;
335
#endif
336

  
337
           if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0)
338
               continue;
339

  
340
           dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc  =
341
               dv_vlc_bits[i] << (!!dv_vlc_level[i]);
342
           dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size =
343
               dv_vlc_len[i] + (!!dv_vlc_level[i]);
344
        }
345
        for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
346
#if CONFIG_SMALL
347
           for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
348
              if (dv_vlc_map[i][j].size == 0) {
349
                  dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
350
                            (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
351
                  dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
352
                                          dv_vlc_map[0][j].size;
353
              }
354
           }
355
#else
356
           for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) {
357
              if (dv_vlc_map[i][j].size == 0) {
358
                  dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
359
                            (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
360
                  dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
361
                                          dv_vlc_map[0][j].size;
362
              }
363
              dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc =
364
                                            dv_vlc_map[i][j].vlc | 1;
365
              dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size =
366
                                            dv_vlc_map[i][j].size;
367
           }
368
#endif
369
        }
316
        dv_vlc_map_tableinit();
370 317
    }
371 318

  
372 319
    /* Generic DSP setup */
libavcodec/dv_tablegen.c
1
/*
2
 * Generate a header file for hardcoded DV tables
3
 *
4
 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
#include <stdlib.h>
24
#define CONFIG_HARDCODED_TABLES 0
25
#ifndef CONFIG_SMALL
26
#error CONFIG_SMALL must be defined to generate tables
27
#endif
28
#include "dv_tablegen.h"
29
#include "tableprint.h"
30
#include <inttypes.h>
31

  
32
WRITE_1D_FUNC_ARGV(vlc_pair, struct dv_vlc_pair, 7,
33
                   "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
34
WRITE_2D_FUNC(vlc_pair, struct dv_vlc_pair)
35

  
36
void tableinit(void)
37
{
38
    dv_vlc_map_tableinit();
39
}
40

  
41
const struct tabledef tables[] = {
42
    {
43
        "static const struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]",
44
        write_vlc_pair_2d_array,
45
        dv_vlc_map,
46
        DV_VLC_MAP_RUN_SIZE,
47
        DV_VLC_MAP_LEV_SIZE
48
    },
49
    { NULL }
50
};
libavcodec/dv_tablegen.h
1
/*
2
 * Header file for hardcoded DV tables
3
 *
4
 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
#ifndef DV_TABLEGEN_H
24
#define DV_TABLEGEN_H
25

  
26
#include <stdint.h>
27
#include "dv_vlc_data.h"
28

  
29
#if CONFIG_SMALL
30
#define DV_VLC_MAP_RUN_SIZE 15
31
#define DV_VLC_MAP_LEV_SIZE 23
32
#else
33
#define DV_VLC_MAP_RUN_SIZE  64
34
#define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check
35
#endif
36

  
37
/* VLC encoding lookup table */
38
struct dv_vlc_pair {
39
   uint32_t vlc;
40
   uint32_t size;
41
};
42

  
43
#if CONFIG_HARDCODED_TABLES
44
#define dv_vlc_map_tableinit()
45
#include "libavcodec/dv_tables.h"
46
#else
47
static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
48

  
49
static void dv_vlc_map_tableinit(void)
50
{
51
    int i, j;
52
    for (i = 0; i < NB_DV_VLC - 1; i++) {
53
       if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
54
           continue;
55
#if CONFIG_SMALL
56
       if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE)
57
           continue;
58
#endif
59

  
60
       if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0)
61
           continue;
62

  
63
       dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc  =
64
           dv_vlc_bits[i] << (!!dv_vlc_level[i]);
65
       dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size =
66
           dv_vlc_len[i] + (!!dv_vlc_level[i]);
67
    }
68
    for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
69
#if CONFIG_SMALL
70
       for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
71
          if (dv_vlc_map[i][j].size == 0) {
72
              dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
73
                        (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
74
              dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
75
                                      dv_vlc_map[0][j].size;
76
          }
77
       }
78
#else
79
       for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) {
80
          if (dv_vlc_map[i][j].size == 0) {
81
              dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
82
                        (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size));
83
              dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size +
84
                                      dv_vlc_map[0][j].size;
85
          }
86
          dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc =
87
                                        dv_vlc_map[i][j].vlc | 1;
88
          dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size =
89
                                        dv_vlc_map[i][j].size;
90
       }
91
#endif
92
    }
93
}
94
#endif /* CONFIG_HARDCODED_TABLES */
95

  
96
#endif /* DV_TABLEGEN_H */

Also available in: Unified diff