Mercurial > libavcodec.hg
annotate xan.c @ 1662:64c370fe6e88 libavcodec
slice flush / position fix
author | michael |
---|---|
date | Sun, 07 Dec 2003 02:10:30 +0000 |
parents | 932d306bf1dc |
children | 39ad6cd5d4a6 |
rev | line source |
---|---|
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
1 /* |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
2 * Wing Commander/Xan Video Decoder |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
3 * Copyright (C) 2003 the ffmpeg project |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
4 * |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
9 * |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
14 * |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
18 * |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
19 */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
20 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
21 /** |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
22 * @file xan.c |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
23 * Xan video decoder for Wing Commander III & IV computer games |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
24 * by Mario Brito (mbrito@student.dei.uc.pt) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
25 * and Mike Melanson (melanson@pcisys.net) |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
26 * |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
27 * The xan_wc3 decoder outputs the following colorspaces natively: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
28 * PAL8 (default), RGB555, RGB565, RGB24, BGR24, RGBA32, YUV444P |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
29 */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
30 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
31 #include <stdio.h> |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
32 #include <stdlib.h> |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
33 #include <string.h> |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
34 #include <unistd.h> |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
35 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
36 #include "common.h" |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
37 #include "avcodec.h" |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
38 #include "dsputil.h" |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
39 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
40 #define PALETTE_COUNT 256 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
41 #define PALETTE_CONTROL_SIZE ((256 * 3) + 1) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
42 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
43 typedef struct XanContext { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
44 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
45 AVCodecContext *avctx; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
46 DSPContext dsp; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
47 AVFrame last_frame; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
48 AVFrame current_frame; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
49 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
50 unsigned char *buf; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
51 int size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
52 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
53 unsigned char palette[PALETTE_COUNT * 4]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
54 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
55 /* scratch space */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
56 unsigned char *buffer1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
57 unsigned char *buffer2; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
58 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
59 } XanContext; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
60 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
61 #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
62 #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
63 #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
64 (((uint8_t*)(x))[2] << 16) | \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
65 (((uint8_t*)(x))[1] << 8) | \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
66 ((uint8_t*)(x))[0]) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
67 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
68 /* RGB -> YUV conversion stuff */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
69 #define SCALEFACTOR 65536 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
70 #define CENTERSAMPLE 128 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
71 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
72 #define COMPUTE_Y(r, g, b) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
73 (unsigned char) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
74 ((y_r_table[r] + y_g_table[g] + y_b_table[b]) / SCALEFACTOR) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
75 #define COMPUTE_U(r, g, b) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
76 (unsigned char) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
77 ((u_r_table[r] + u_g_table[g] + u_b_table[b]) / SCALEFACTOR + CENTERSAMPLE) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
78 #define COMPUTE_V(r, g, b) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
79 (unsigned char) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
80 ((v_r_table[r] + v_g_table[g] + v_b_table[b]) / SCALEFACTOR + CENTERSAMPLE) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
81 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
82 #define Y_R (SCALEFACTOR * 0.29900) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
83 #define Y_G (SCALEFACTOR * 0.58700) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
84 #define Y_B (SCALEFACTOR * 0.11400) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
85 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
86 #define U_R (SCALEFACTOR * -0.16874) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
87 #define U_G (SCALEFACTOR * -0.33126) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
88 #define U_B (SCALEFACTOR * 0.50000) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
89 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
90 #define V_R (SCALEFACTOR * 0.50000) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
91 #define V_G (SCALEFACTOR * -0.41869) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
92 #define V_B (SCALEFACTOR * -0.08131) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
93 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
94 /* |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
95 * Precalculate all of the YUV tables since it requires fewer than |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
96 * 10 kilobytes to store them. |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
97 */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
98 static int y_r_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
99 static int y_g_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
100 static int y_b_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
101 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
102 static int u_r_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
103 static int u_g_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
104 static int u_b_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
105 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
106 static int v_r_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
107 static int v_g_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
108 static int v_b_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
109 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
110 static int xan_decode_init(AVCodecContext *avctx) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
111 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
112 XanContext *s = avctx->priv_data; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
113 int i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
114 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
115 s->avctx = avctx; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
116 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
117 if ((avctx->codec->id == CODEC_ID_XAN_WC3) && |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
118 (s->avctx->palctrl == NULL)) { |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
119 av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n"); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
120 return -1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
121 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
122 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
123 avctx->pix_fmt = PIX_FMT_PAL8; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
124 avctx->has_b_frames = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
125 dsputil_init(&s->dsp, avctx); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
126 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
127 /* initialize the RGB -> YUV tables */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
128 for (i = 0; i < 256; i++) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
129 y_r_table[i] = Y_R * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
130 y_g_table[i] = Y_G * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
131 y_b_table[i] = Y_B * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
132 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
133 u_r_table[i] = U_R * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
134 u_g_table[i] = U_G * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
135 u_b_table[i] = U_B * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
136 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
137 v_r_table[i] = V_R * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
138 v_g_table[i] = V_G * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
139 v_b_table[i] = V_B * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
140 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
141 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
142 s->buffer1 = av_malloc(avctx->width * avctx->height); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
143 s->buffer2 = av_malloc(avctx->width * avctx->height); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
144 if (!s->buffer1 || !s->buffer2) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
145 return -1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
146 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
147 return 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
148 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
149 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
150 /* This function is used in lieu of memcpy(). This decoder can not use |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
151 * memcpy because the memory locations often overlap and |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
152 * memcpy doesn't like that; it's not uncommon, for example, for |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
153 * dest = src+1, to turn byte A into pattern AAAAAAAA. |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
154 * This was originally repz movsb in Intel x86 ASM. */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
155 static inline void bytecopy(unsigned char *dest, unsigned char *src, int count) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
156 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
157 int i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
158 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
159 for (i = 0; i < count; i++) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
160 dest[i] = src[i]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
161 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
162 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
163 static int xan_huffman_decode(unsigned char *dest, unsigned char *src) |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
164 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
165 unsigned char byte = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
166 unsigned char ival = byte + 0x16; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
167 unsigned char * ptr = src + byte*2; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
168 unsigned char val = ival; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
169 int counter = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
170 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
171 unsigned char bits = *ptr++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
172 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
173 while ( val != 0x16 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
174 if ( (1 << counter) & bits ) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
175 val = src[byte + val - 0x17]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
176 else |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
177 val = src[val - 0x17]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
178 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
179 if ( val < 0x16 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
180 *dest++ = val; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
181 val = ival; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
182 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
183 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
184 if (counter++ == 7) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
185 counter = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
186 bits = *ptr++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
187 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
188 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
189 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
190 return 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
191 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
192 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
193 static void xan_unpack(unsigned char *dest, unsigned char *src) |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
194 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
195 unsigned char opcode; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
196 int size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
197 int offset; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
198 int byte1, byte2, byte3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
199 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
200 for (;;) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
201 opcode = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
202 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
203 if ( (opcode & 0x80) == 0 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
204 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
205 offset = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
206 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
207 size = opcode & 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
208 bytecopy(dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
209 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
210 size = ((opcode & 0x1c) >> 2) + 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
211 bytecopy (dest, dest - (((opcode & 0x60) << 3) + offset + 1), size); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
212 dest += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
213 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
214 } else if ( (opcode & 0x40) == 0 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
215 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
216 byte1 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
217 byte2 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
218 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
219 size = byte1 >> 6; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
220 bytecopy (dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
221 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
222 size = (opcode & 0x3f) + 4; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
223 bytecopy (dest, dest - (((byte1 & 0x3f) << 8) + byte2 + 1), size); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
224 dest += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
225 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
226 } else if ( (opcode & 0x20) == 0 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
227 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
228 byte1 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
229 byte2 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
230 byte3 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
231 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
232 size = opcode & 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
233 bytecopy (dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
234 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
235 size = byte3 + 5 + ((opcode & 0xc) << 6); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
236 bytecopy (dest, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
237 dest - ((((opcode & 0x10) >> 4) << 0x10) + 1 + (byte1 << 8) + byte2), |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
238 size); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
239 dest += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
240 } else { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
241 size = ((opcode & 0x1f) << 2) + 4; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
242 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
243 if (size > 0x70) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
244 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
245 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
246 bytecopy (dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
247 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
248 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
249 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
250 size = opcode & 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
251 bytecopy(dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
252 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
253 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
254 static void inline xan_wc3_build_palette(XanContext *s, |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
255 unsigned int *palette_data) |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
256 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
257 int i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
258 unsigned char r, g, b; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
259 unsigned short *palette16; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
260 unsigned int *palette32; |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
261 unsigned int pal_elem; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
262 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
263 /* transform the palette passed through the palette control structure |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
264 * into the necessary internal format depending on colorspace */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
265 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
266 switch (s->avctx->pix_fmt) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
267 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
268 case PIX_FMT_RGB555: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
269 palette16 = (unsigned short *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
270 for (i = 0; i < PALETTE_COUNT; i++) { |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
271 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
272 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
273 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
274 b = pal_elem & 0xff; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
275 palette16[i] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
276 ((r >> 3) << 10) | |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
277 ((g >> 3) << 5) | |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
278 ((b >> 3) << 0); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
279 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
280 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
281 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
282 case PIX_FMT_RGB565: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
283 palette16 = (unsigned short *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
284 for (i = 0; i < PALETTE_COUNT; i++) { |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
285 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
286 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
287 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
288 b = pal_elem & 0xff; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
289 palette16[i] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
290 ((r >> 3) << 11) | |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
291 ((g >> 2) << 5) | |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
292 ((b >> 3) << 0); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
293 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
294 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
295 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
296 case PIX_FMT_RGB24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
297 for (i = 0; i < PALETTE_COUNT; i++) { |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
298 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
299 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
300 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
301 b = pal_elem & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
302 s->palette[i * 4 + 0] = r; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
303 s->palette[i * 4 + 1] = g; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
304 s->palette[i * 4 + 2] = b; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
305 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
306 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
307 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
308 case PIX_FMT_BGR24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
309 for (i = 0; i < PALETTE_COUNT; i++) { |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
310 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
311 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
312 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
313 b = pal_elem & 0xff; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
314 s->palette[i * 4 + 0] = b; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
315 s->palette[i * 4 + 1] = g; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
316 s->palette[i * 4 + 2] = r; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
317 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
318 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
319 |
1464 | 320 case PIX_FMT_PAL8: |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
321 case PIX_FMT_RGBA32: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
322 palette32 = (unsigned int *)s->palette; |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
323 memcpy (palette32, palette_data, PALETTE_COUNT * sizeof(unsigned int)); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
324 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
325 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
326 case PIX_FMT_YUV444P: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
327 for (i = 0; i < PALETTE_COUNT; i++) { |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
328 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
329 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
330 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
331 b = pal_elem & 0xff; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
332 s->palette[i * 4 + 0] = COMPUTE_Y(r, g, b); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
333 s->palette[i * 4 + 1] = COMPUTE_U(r, g, b); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
334 s->palette[i * 4 + 2] = COMPUTE_V(r, g, b); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
335 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
336 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
337 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
338 default: |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
339 av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n"); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
340 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
341 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
342 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
343 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
344 /* advance current_x variable; reset accounting variables if current_x |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
345 * moves beyond width */ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
346 #define ADVANCE_CURRENT_X() \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
347 current_x++; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
348 if (current_x >= width) { \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
349 index += line_inc; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
350 current_x = 0; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
351 } |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
352 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
353 static void inline xan_wc3_output_pixel_run(XanContext *s, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
354 unsigned char *pixel_buffer, int x, int y, int pixel_count) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
355 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
356 int stride; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
357 int line_inc; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
358 int index; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
359 int current_x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
360 int width = s->avctx->width; |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
361 unsigned char pix; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
362 unsigned char *palette_plane; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
363 unsigned char *y_plane; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
364 unsigned char *u_plane; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
365 unsigned char *v_plane; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
366 unsigned char *rgb_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
367 unsigned short *rgb16_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
368 unsigned short *palette16; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
369 unsigned int *rgb32_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
370 unsigned int *palette32; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
371 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
372 switch (s->avctx->pix_fmt) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
373 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
374 case PIX_FMT_PAL8: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
375 palette_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
376 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
377 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
378 index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
379 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
380 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
381 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
382 /* don't do a memcpy() here; keyframes generally copy an entire |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
383 * frame of data and the stride needs to be accounted for */ |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
384 palette_plane[index++] = *pixel_buffer++; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
385 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
386 ADVANCE_CURRENT_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
387 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
388 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
389 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
390 case PIX_FMT_RGB555: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
391 case PIX_FMT_RGB565: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
392 rgb16_plane = (unsigned short *)s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
393 palette16 = (unsigned short *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
394 stride = s->current_frame.linesize[0] / 2; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
395 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
396 index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
397 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
398 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
399 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
400 rgb16_plane[index++] = palette16[*pixel_buffer++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
401 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
402 ADVANCE_CURRENT_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
403 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
404 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
405 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
406 case PIX_FMT_RGB24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
407 case PIX_FMT_BGR24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
408 rgb_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
409 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
410 line_inc = stride - width * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
411 index = y * stride + x * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
412 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
413 while(pixel_count--) { |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
414 pix = *pixel_buffer++; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
415 |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
416 rgb_plane[index++] = s->palette[pix * 4 + 0]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
417 rgb_plane[index++] = s->palette[pix * 4 + 1]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
418 rgb_plane[index++] = s->palette[pix * 4 + 2]; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
419 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
420 ADVANCE_CURRENT_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
421 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
422 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
423 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
424 case PIX_FMT_RGBA32: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
425 rgb32_plane = (unsigned int *)s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
426 palette32 = (unsigned int *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
427 stride = s->current_frame.linesize[0] / 4; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
428 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
429 index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
430 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
431 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
432 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
433 rgb32_plane[index++] = palette32[*pixel_buffer++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
434 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
435 ADVANCE_CURRENT_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
436 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
437 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
438 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
439 case PIX_FMT_YUV444P: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
440 y_plane = s->current_frame.data[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
441 u_plane = s->current_frame.data[1]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
442 v_plane = s->current_frame.data[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
443 stride = s->current_frame.linesize[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
444 line_inc = stride - width; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
445 index = y * stride + x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
446 current_x = x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
447 while(pixel_count--) { |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
448 pix = *pixel_buffer++; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
449 |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
450 y_plane[index] = s->palette[pix * 4 + 0]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
451 u_plane[index] = s->palette[pix * 4 + 1]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
452 v_plane[index] = s->palette[pix * 4 + 2]; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
453 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
454 index++; |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
455 ADVANCE_CURRENT_X(); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
456 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
457 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
458 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
459 default: |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
460 av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n"); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
461 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
462 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
463 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
464 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
465 #define ADVANCE_CURFRAME_X() \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
466 curframe_x++; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
467 if (curframe_x >= width) { \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
468 curframe_index += line_inc; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
469 curframe_x = 0; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
470 } |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
471 |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
472 #define ADVANCE_PREVFRAME_X() \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
473 prevframe_x++; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
474 if (prevframe_x >= width) { \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
475 prevframe_index += line_inc; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
476 prevframe_x = 0; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
477 } |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
478 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
479 static void inline xan_wc3_copy_pixel_run(XanContext *s, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
480 int x, int y, int pixel_count, int motion_x, int motion_y) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
481 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
482 int stride; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
483 int line_inc; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
484 int curframe_index, prevframe_index; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
485 int curframe_x, prevframe_x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
486 int width = s->avctx->width; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
487 unsigned char *palette_plane, *prev_palette_plane; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
488 unsigned char *y_plane, *u_plane, *v_plane; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
489 unsigned char *prev_y_plane, *prev_u_plane, *prev_v_plane; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
490 unsigned char *rgb_plane, *prev_rgb_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
491 unsigned short *rgb16_plane, *prev_rgb16_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
492 unsigned int *rgb32_plane, *prev_rgb32_plane; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
493 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
494 switch (s->avctx->pix_fmt) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
495 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
496 case PIX_FMT_PAL8: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
497 palette_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
498 prev_palette_plane = s->last_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
499 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
500 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
501 curframe_index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
502 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
503 prevframe_index = (y + motion_y) * stride + x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
504 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
505 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
506 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
507 palette_plane[curframe_index++] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
508 prev_palette_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
509 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
510 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
511 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
512 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
513 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
514 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
515 case PIX_FMT_RGB555: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
516 case PIX_FMT_RGB565: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
517 rgb16_plane = (unsigned short *)s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
518 prev_rgb16_plane = (unsigned short *)s->last_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
519 stride = s->current_frame.linesize[0] / 2; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
520 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
521 curframe_index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
522 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
523 prevframe_index = (y + motion_y) * stride + x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
524 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
525 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
526 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
527 rgb16_plane[curframe_index++] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
528 prev_rgb16_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
529 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
530 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
531 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
532 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
533 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
534 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
535 case PIX_FMT_RGB24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
536 case PIX_FMT_BGR24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
537 rgb_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
538 prev_rgb_plane = s->last_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
539 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
540 line_inc = stride - width * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
541 curframe_index = y * stride + x * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
542 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
543 prevframe_index = (y + motion_y) * stride + |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
544 (3 * (x + motion_x)); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
545 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
546 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
547 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
548 rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
549 rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
550 rgb_plane[curframe_index++] = prev_rgb_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
551 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
552 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
553 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
554 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
555 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
556 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
557 case PIX_FMT_RGBA32: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
558 rgb32_plane = (unsigned int *)s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
559 prev_rgb32_plane = (unsigned int *)s->last_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
560 stride = s->current_frame.linesize[0] / 4; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
561 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
562 curframe_index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
563 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
564 prevframe_index = (y + motion_y) * stride + x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
565 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
566 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
567 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
568 rgb32_plane[curframe_index++] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
569 prev_rgb32_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
570 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
571 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
572 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
573 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
574 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
575 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
576 case PIX_FMT_YUV444P: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
577 y_plane = s->current_frame.data[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
578 u_plane = s->current_frame.data[1]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
579 v_plane = s->current_frame.data[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
580 prev_y_plane = s->last_frame.data[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
581 prev_u_plane = s->last_frame.data[1]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
582 prev_v_plane = s->last_frame.data[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
583 stride = s->current_frame.linesize[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
584 line_inc = stride - width; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
585 curframe_index = y * stride + x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
586 curframe_x = x; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
587 prevframe_index = (y + motion_y) * stride + x + motion_x; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
588 prevframe_x = x + motion_x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
589 while(pixel_count--) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
590 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
591 y_plane[curframe_index] = prev_y_plane[prevframe_index]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
592 u_plane[curframe_index] = prev_u_plane[prevframe_index]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
593 v_plane[curframe_index] = prev_v_plane[prevframe_index]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
594 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
595 curframe_index++; |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
596 ADVANCE_CURFRAME_X(); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
597 prevframe_index++; |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
598 ADVANCE_PREVFRAME_X(); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
599 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
600 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
601 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
602 default: |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
603 av_log(s->avctx, AV_LOG_ERROR, " Xan WC3: Unhandled colorspace\n"); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
604 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
605 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
606 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
607 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
608 static void xan_wc3_decode_frame(XanContext *s) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
609 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
610 int width = s->avctx->width; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
611 int height = s->avctx->height; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
612 int total_pixels = width * height; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
613 unsigned char opcode; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
614 unsigned char flag = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
615 int size = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
616 int motion_x, motion_y; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
617 int x, y; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
618 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
619 unsigned char *opcode_buffer = s->buffer1; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
620 unsigned char *imagedata_buffer = s->buffer2; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
621 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
622 /* pointers to segments inside the compressed chunk */ |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
623 unsigned char *huffman_segment; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
624 unsigned char *size_segment; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
625 unsigned char *vector_segment; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
626 unsigned char *imagedata_segment; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
627 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
628 huffman_segment = s->buf + LE_16(&s->buf[0]); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
629 size_segment = s->buf + LE_16(&s->buf[2]); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
630 vector_segment = s->buf + LE_16(&s->buf[4]); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
631 imagedata_segment = s->buf + LE_16(&s->buf[6]); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
632 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
633 xan_huffman_decode(opcode_buffer, huffman_segment); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
634 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
635 if (imagedata_segment[0] == 2) |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
636 xan_unpack(imagedata_buffer, &imagedata_segment[1]); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
637 else |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
638 imagedata_buffer = &imagedata_segment[1]; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
639 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
640 /* use the decoded data segments to build the frame */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
641 x = y = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
642 while (total_pixels) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
643 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
644 opcode = *opcode_buffer++; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
645 size = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
646 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
647 switch (opcode) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
648 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
649 case 0: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
650 flag ^= 1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
651 continue; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
652 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
653 case 1: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
654 case 2: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
655 case 3: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
656 case 4: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
657 case 5: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
658 case 6: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
659 case 7: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
660 case 8: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
661 size = opcode; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
662 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
663 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
664 case 12: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
665 case 13: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
666 case 14: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
667 case 15: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
668 case 16: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
669 case 17: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
670 case 18: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
671 size += (opcode - 10); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
672 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
673 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
674 case 9: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
675 case 19: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
676 size = *size_segment++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
677 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
678 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
679 case 10: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
680 case 20: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
681 size = BE_16(&size_segment[0]); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
682 size_segment += 2; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
683 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
684 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
685 case 11: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
686 case 21: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
687 size = (size_segment[0] << 16) | (size_segment[1] << 8) | |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
688 size_segment[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
689 size_segment += 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
690 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
691 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
692 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
693 if (opcode < 12) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
694 flag ^= 1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
695 if (flag) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
696 /* run of (size) pixels is unchanged from last frame */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
697 xan_wc3_copy_pixel_run(s, x, y, size, 0, 0); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
698 } else { |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
699 /* output a run of pixels from imagedata_buffer */ |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
700 xan_wc3_output_pixel_run(s, imagedata_buffer, x, y, size); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
701 imagedata_buffer += size; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
702 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
703 } else { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
704 /* run-based motion compensation from last frame */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
705 motion_x = (*vector_segment >> 4) & 0xF; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
706 motion_y = *vector_segment & 0xF; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
707 vector_segment++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
708 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
709 /* sign extension */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
710 if (motion_x & 0x8) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
711 motion_x |= 0xFFFFFFF0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
712 if (motion_y & 0x8) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
713 motion_y |= 0xFFFFFFF0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
714 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
715 /* copy a run of pixels from the previous frame */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
716 xan_wc3_copy_pixel_run(s, x, y, size, motion_x, motion_y); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
717 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
718 flag = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
719 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
720 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
721 /* coordinate accounting */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
722 total_pixels -= size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
723 while (size) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
724 if (x + size >= width) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
725 y++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
726 size -= (width - x); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
727 x = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
728 } else { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
729 x += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
730 size = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
731 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
732 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
733 } |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
734 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
735 /* for PAL8, make the palette available on the way out */ |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
736 if (s->avctx->pix_fmt == PIX_FMT_PAL8) { |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
737 memcpy(s->current_frame.data[1], s->palette, PALETTE_COUNT * 4); |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
738 s->current_frame.palette_has_changed = 1; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
739 s->avctx->palctrl->palette_changed = 0; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
740 } |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
741 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
742 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
743 static void xan_wc4_decode_frame(XanContext *s) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
744 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
745 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
746 static int xan_decode_frame(AVCodecContext *avctx, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
747 void *data, int *data_size, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
748 uint8_t *buf, int buf_size) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
749 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
750 XanContext *s = avctx->priv_data; |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
751 AVPaletteControl *palette_control = avctx->palctrl; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
752 int keyframe = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
753 |
1462 | 754 if (palette_control->palette_changed) { |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
755 /* load the new palette and reset the palette control */ |
1462 | 756 xan_wc3_build_palette(s, palette_control->palette); |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
757 /* If pal8 we clear flag when we copy palette */ |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
758 if (s->avctx->pix_fmt != PIX_FMT_PAL8) |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
759 palette_control->palette_changed = 0; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
760 keyframe = 1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
761 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
762 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
763 if (avctx->get_buffer(avctx, &s->current_frame)) { |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
764 av_log(s->avctx, AV_LOG_ERROR, " Xan Video: get_buffer() failed\n"); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
765 return -1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
766 } |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
767 s->current_frame.reference = 3; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
768 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
769 s->buf = buf; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
770 s->size = buf_size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
771 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
772 if (avctx->codec->id == CODEC_ID_XAN_WC3) |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
773 xan_wc3_decode_frame(s); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
774 else if (avctx->codec->id == CODEC_ID_XAN_WC4) |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
775 xan_wc4_decode_frame(s); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
776 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
777 /* release the last frame if it is allocated */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
778 if (s->last_frame.data[0]) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
779 avctx->release_buffer(avctx, &s->last_frame); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
780 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
781 /* shuffle frames */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
782 s->last_frame = s->current_frame; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
783 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
784 *data_size = sizeof(AVFrame); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
785 *(AVFrame*)data = s->current_frame; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
786 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
787 /* always report that the buffer was completely consumed */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
788 return buf_size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
789 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
790 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
791 static int xan_decode_end(AVCodecContext *avctx) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
792 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
793 XanContext *s = avctx->priv_data; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
794 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
795 /* release the last frame */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
796 avctx->release_buffer(avctx, &s->last_frame); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
797 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
798 av_free(s->buffer1); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
799 av_free(s->buffer2); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
800 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
801 return 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
802 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
803 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
804 AVCodec xan_wc3_decoder = { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
805 "xan_wc3", |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
806 CODEC_TYPE_VIDEO, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
807 CODEC_ID_XAN_WC3, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
808 sizeof(XanContext), |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
809 xan_decode_init, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
810 NULL, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
811 xan_decode_end, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
812 xan_decode_frame, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
813 CODEC_CAP_DR1, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
814 }; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
815 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
816 /* |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
817 AVCodec xan_wc4_decoder = { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
818 "xan_wc4", |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
819 CODEC_TYPE_VIDEO, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
820 CODEC_ID_XAN_WC4, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
821 sizeof(XanContext), |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
822 xan_decode_init, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
823 NULL, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
824 xan_decode_end, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
825 xan_decode_frame, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
826 CODEC_CAP_DR1, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
827 }; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
828 */ |