Originally committed as revision 22622 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -626,6 +626,12 @@ $(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=15 |
| 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,6 +640,7 @@ $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) |
| 634 | 634 |
|
| 635 | 635 |
ifdef CONFIG_HARDCODED_TABLES |
| 636 | 636 |
$(SUBDIR)aac.o: $(SUBDIR)cbrt_tables.h |
| 637 |
+$(SUBDIR)dv.o: $(SUBDIR)dv_tables.h |
|
| 637 | 638 |
$(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h |
| 638 | 639 |
$(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h |
| 639 | 640 |
$(SUBDIR)motionpixels.o: $(SUBDIR)motionpixels_tables.h |
| ... | ... |
@@ -44,7 +44,7 @@ |
| 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,21 +65,8 @@ typedef struct DVVideoContext {
|
| 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,47 +313,7 @@ static av_cold int dvvideo_init(AVCodecContext *avctx) |
| 326 | 326 |
} |
| 327 | 327 |
free_vlc(&dv_vlc); |
| 328 | 328 |
|
| 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 |
- } |
|
| 329 |
+ dv_vlc_map_tableinit(); |
|
| 370 | 330 |
} |
| 371 | 331 |
|
| 372 | 332 |
/* Generic DSP setup */ |
| 373 | 333 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,50 @@ |
| 0 |
+/* |
|
| 1 |
+ * Generate a header file for hardcoded DV tables |
|
| 2 |
+ * |
|
| 3 |
+ * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> |
|
| 4 |
+ * |
|
| 5 |
+ * This file is part of FFmpeg. |
|
| 6 |
+ * |
|
| 7 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
| 8 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 9 |
+ * License as published by the Free Software Foundation; either |
|
| 10 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 11 |
+ * |
|
| 12 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
| 13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 15 |
+ * Lesser General Public License for more details. |
|
| 16 |
+ * |
|
| 17 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 18 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
| 19 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 20 |
+ */ |
|
| 21 |
+ |
|
| 22 |
+#include <stdlib.h> |
|
| 23 |
+#define CONFIG_HARDCODED_TABLES 0 |
|
| 24 |
+#ifndef CONFIG_SMALL |
|
| 25 |
+#error CONFIG_SMALL must be defined to generate tables |
|
| 26 |
+#endif |
|
| 27 |
+#include "dv_tablegen.h" |
|
| 28 |
+#include "tableprint.h" |
|
| 29 |
+#include <inttypes.h> |
|
| 30 |
+ |
|
| 31 |
+WRITE_1D_FUNC_ARGV(vlc_pair, struct dv_vlc_pair, 7, |
|
| 32 |
+ "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size)
|
|
| 33 |
+WRITE_2D_FUNC(vlc_pair, struct dv_vlc_pair) |
|
| 34 |
+ |
|
| 35 |
+void tableinit(void) |
|
| 36 |
+{
|
|
| 37 |
+ dv_vlc_map_tableinit(); |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+const struct tabledef tables[] = {
|
|
| 41 |
+ {
|
|
| 42 |
+ "static const struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]", |
|
| 43 |
+ write_vlc_pair_2d_array, |
|
| 44 |
+ dv_vlc_map, |
|
| 45 |
+ DV_VLC_MAP_RUN_SIZE, |
|
| 46 |
+ DV_VLC_MAP_LEV_SIZE |
|
| 47 |
+ }, |
|
| 48 |
+ { NULL }
|
|
| 49 |
+}; |
| 0 | 50 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,96 @@ |
| 0 |
+/* |
|
| 1 |
+ * Header file for hardcoded DV tables |
|
| 2 |
+ * |
|
| 3 |
+ * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de> |
|
| 4 |
+ * |
|
| 5 |
+ * This file is part of FFmpeg. |
|
| 6 |
+ * |
|
| 7 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
| 8 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 9 |
+ * License as published by the Free Software Foundation; either |
|
| 10 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 11 |
+ * |
|
| 12 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
| 13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 15 |
+ * Lesser General Public License for more details. |
|
| 16 |
+ * |
|
| 17 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 18 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
| 19 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 20 |
+ */ |
|
| 21 |
+ |
|
| 22 |
+#ifndef DV_TABLEGEN_H |
|
| 23 |
+#define DV_TABLEGEN_H |
|
| 24 |
+ |
|
| 25 |
+#include <stdint.h> |
|
| 26 |
+#include "dv_vlc_data.h" |
|
| 27 |
+ |
|
| 28 |
+#if CONFIG_SMALL |
|
| 29 |
+#define DV_VLC_MAP_RUN_SIZE 15 |
|
| 30 |
+#define DV_VLC_MAP_LEV_SIZE 23 |
|
| 31 |
+#else |
|
| 32 |
+#define DV_VLC_MAP_RUN_SIZE 64 |
|
| 33 |
+#define DV_VLC_MAP_LEV_SIZE 512 //FIXME sign was removed so this should be /2 but needs check |
|
| 34 |
+#endif |
|
| 35 |
+ |
|
| 36 |
+/* VLC encoding lookup table */ |
|
| 37 |
+struct dv_vlc_pair {
|
|
| 38 |
+ uint32_t vlc; |
|
| 39 |
+ uint32_t size; |
|
| 40 |
+}; |
|
| 41 |
+ |
|
| 42 |
+#if CONFIG_HARDCODED_TABLES |
|
| 43 |
+#define dv_vlc_map_tableinit() |
|
| 44 |
+#include "libavcodec/dv_tables.h" |
|
| 45 |
+#else |
|
| 46 |
+static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]; |
|
| 47 |
+ |
|
| 48 |
+static void dv_vlc_map_tableinit(void) |
|
| 49 |
+{
|
|
| 50 |
+ int i, j; |
|
| 51 |
+ for (i = 0; i < NB_DV_VLC - 1; i++) {
|
|
| 52 |
+ if (dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE) |
|
| 53 |
+ continue; |
|
| 54 |
+#if CONFIG_SMALL |
|
| 55 |
+ if (dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE) |
|
| 56 |
+ continue; |
|
| 57 |
+#endif |
|
| 58 |
+ |
|
| 59 |
+ if (dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size != 0) |
|
| 60 |
+ continue; |
|
| 61 |
+ |
|
| 62 |
+ dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].vlc = |
|
| 63 |
+ dv_vlc_bits[i] << (!!dv_vlc_level[i]); |
|
| 64 |
+ dv_vlc_map[dv_vlc_run[i]][dv_vlc_level[i]].size = |
|
| 65 |
+ dv_vlc_len[i] + (!!dv_vlc_level[i]); |
|
| 66 |
+ } |
|
| 67 |
+ for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
|
|
| 68 |
+#if CONFIG_SMALL |
|
| 69 |
+ for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
|
|
| 70 |
+ if (dv_vlc_map[i][j].size == 0) {
|
|
| 71 |
+ dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | |
|
| 72 |
+ (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); |
|
| 73 |
+ dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + |
|
| 74 |
+ dv_vlc_map[0][j].size; |
|
| 75 |
+ } |
|
| 76 |
+ } |
|
| 77 |
+#else |
|
| 78 |
+ for (j = 1; j < DV_VLC_MAP_LEV_SIZE/2; j++) {
|
|
| 79 |
+ if (dv_vlc_map[i][j].size == 0) {
|
|
| 80 |
+ dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc | |
|
| 81 |
+ (dv_vlc_map[i-1][0].vlc << (dv_vlc_map[0][j].size)); |
|
| 82 |
+ dv_vlc_map[i][j].size = dv_vlc_map[i-1][0].size + |
|
| 83 |
+ dv_vlc_map[0][j].size; |
|
| 84 |
+ } |
|
| 85 |
+ dv_vlc_map[i][((uint16_t)(-j))&0x1ff].vlc = |
|
| 86 |
+ dv_vlc_map[i][j].vlc | 1; |
|
| 87 |
+ dv_vlc_map[i][((uint16_t)(-j))&0x1ff].size = |
|
| 88 |
+ dv_vlc_map[i][j].size; |
|
| 89 |
+ } |
|
| 90 |
+#endif |
|
| 91 |
+ } |
|
| 92 |
+} |
|
| 93 |
+#endif /* CONFIG_HARDCODED_TABLES */ |
|
| 94 |
+ |
|
| 95 |
+#endif /* DV_TABLEGEN_H */ |