Mercurial > libavcodec.hg
annotate xan.c @ 2562:d0a58dca5ad2 libavcodec
slice-based idwt (10% faster decoding)
author | lorenm |
---|---|
date | Tue, 15 Mar 2005 21:05:34 +0000 |
parents | 18b8b2dcc037 |
children | ad9d121cc6e9 |
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 /* RGB -> YUV conversion stuff */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
62 #define SCALEFACTOR 65536 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
63 #define CENTERSAMPLE 128 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
64 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
65 #define COMPUTE_Y(r, g, b) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
66 (unsigned char) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
67 ((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
|
68 #define COMPUTE_U(r, g, b) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
69 (unsigned char) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
70 ((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
|
71 #define COMPUTE_V(r, g, b) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
72 (unsigned char) \ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
73 ((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
|
74 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
75 #define Y_R (SCALEFACTOR * 0.29900) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
76 #define Y_G (SCALEFACTOR * 0.58700) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
77 #define Y_B (SCALEFACTOR * 0.11400) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
78 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
79 #define U_R (SCALEFACTOR * -0.16874) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
80 #define U_G (SCALEFACTOR * -0.33126) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
81 #define U_B (SCALEFACTOR * 0.50000) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
82 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
83 #define V_R (SCALEFACTOR * 0.50000) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
84 #define V_G (SCALEFACTOR * -0.41869) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
85 #define V_B (SCALEFACTOR * -0.08131) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
86 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
87 /* |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
88 * 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
|
89 * 10 kilobytes to store them. |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
90 */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
91 static int y_r_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
92 static int y_g_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
93 static int y_b_table[256]; |
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 static int u_r_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
96 static int u_g_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
97 static int u_b_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
98 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
99 static int v_r_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
100 static int v_g_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
101 static int v_b_table[256]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
102 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
103 static int xan_decode_init(AVCodecContext *avctx) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
104 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
105 XanContext *s = avctx->priv_data; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
106 int i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
107 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
108 s->avctx = avctx; |
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 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
|
111 (s->avctx->palctrl == NULL)) { |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
112 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
|
113 return -1; |
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 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
116 avctx->pix_fmt = PIX_FMT_PAL8; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
117 avctx->has_b_frames = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
118 dsputil_init(&s->dsp, avctx); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
119 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
120 /* initialize the RGB -> YUV tables */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
121 for (i = 0; i < 256; i++) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
122 y_r_table[i] = Y_R * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
123 y_g_table[i] = Y_G * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
124 y_b_table[i] = Y_B * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
125 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
126 u_r_table[i] = U_R * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
127 u_g_table[i] = U_G * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
128 u_b_table[i] = U_B * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
129 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
130 v_r_table[i] = V_R * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
131 v_g_table[i] = V_G * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
132 v_b_table[i] = V_B * i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
133 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
134 |
2422 | 135 if(avcodec_check_dimensions(avctx, avctx->width, avctx->height)) |
136 return -1; | |
137 | |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
138 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
|
139 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
|
140 if (!s->buffer1 || !s->buffer2) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
141 return -1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
142 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
143 return 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
144 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
145 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
146 /* 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
|
147 * memcpy because the memory locations often overlap and |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
148 * 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
|
149 * 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
|
150 * 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
|
151 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
|
152 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
153 int i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
154 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
155 for (i = 0; i < count; i++) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
156 dest[i] = src[i]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
157 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
158 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
159 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
|
160 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
161 unsigned char byte = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
162 unsigned char ival = byte + 0x16; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
163 unsigned char * ptr = src + byte*2; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
164 unsigned char val = ival; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
165 int counter = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
166 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
167 unsigned char bits = *ptr++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
168 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
169 while ( val != 0x16 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
170 if ( (1 << counter) & bits ) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
171 val = src[byte + val - 0x17]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
172 else |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
173 val = src[val - 0x17]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
174 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
175 if ( val < 0x16 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
176 *dest++ = val; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
177 val = ival; |
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 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
180 if (counter++ == 7) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
181 counter = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
182 bits = *ptr++; |
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 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
185 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
186 return 0; |
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 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
189 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
|
190 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
191 unsigned char opcode; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
192 int size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
193 int offset; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
194 int byte1, byte2, byte3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
195 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
196 for (;;) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
197 opcode = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
198 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
199 if ( (opcode & 0x80) == 0 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
200 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
201 offset = *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 size = opcode & 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
204 bytecopy(dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
205 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
206 size = ((opcode & 0x1c) >> 2) + 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
207 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
|
208 dest += 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 } else if ( (opcode & 0x40) == 0 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
211 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
212 byte1 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
213 byte2 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
214 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
215 size = byte1 >> 6; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
216 bytecopy (dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
217 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
218 size = (opcode & 0x3f) + 4; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
219 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
|
220 dest += 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 } else if ( (opcode & 0x20) == 0 ) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
223 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
224 byte1 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
225 byte2 = *src++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
226 byte3 = *src++; |
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 size = opcode & 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
229 bytecopy (dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
230 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
231 size = byte3 + 5 + ((opcode & 0xc) << 6); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
232 bytecopy (dest, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
233 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
|
234 size); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
235 dest += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
236 } else { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
237 size = ((opcode & 0x1f) << 2) + 4; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
238 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
239 if (size > 0x70) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
240 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
241 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
242 bytecopy (dest, src, size); dest += size; src += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
243 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
244 } |
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 size = opcode & 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
247 bytecopy(dest, src, size); dest += size; src += size; |
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 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
|
251 unsigned int *palette_data) |
1443
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 int i; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
254 unsigned char r, g, b; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
255 unsigned short *palette16; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
256 unsigned int *palette32; |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
257 unsigned int pal_elem; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
258 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
259 /* 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
|
260 * into the necessary internal format depending on colorspace */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
261 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
262 switch (s->avctx->pix_fmt) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
263 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
264 case PIX_FMT_RGB555: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
265 palette16 = (unsigned short *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
266 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
|
267 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
268 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
269 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
270 b = pal_elem & 0xff; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
271 palette16[i] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
272 ((r >> 3) << 10) | |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
273 ((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
|
274 ((b >> 3) << 0); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
275 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
276 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
277 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
278 case PIX_FMT_RGB565: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
279 palette16 = (unsigned short *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
280 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
|
281 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
282 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
283 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
284 b = pal_elem & 0xff; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
285 palette16[i] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
286 ((r >> 3) << 11) | |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
287 ((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
|
288 ((b >> 3) << 0); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
289 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
290 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
291 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
292 case PIX_FMT_RGB24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
293 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
|
294 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
295 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
296 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
297 b = pal_elem & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
298 s->palette[i * 4 + 0] = r; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
299 s->palette[i * 4 + 1] = g; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
300 s->palette[i * 4 + 2] = b; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
301 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
302 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
303 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
304 case PIX_FMT_BGR24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
305 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
|
306 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
307 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
308 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
309 b = pal_elem & 0xff; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
310 s->palette[i * 4 + 0] = b; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
311 s->palette[i * 4 + 1] = g; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
312 s->palette[i * 4 + 2] = r; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
313 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
314 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
315 |
1464 | 316 case PIX_FMT_PAL8: |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
317 case PIX_FMT_RGBA32: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
318 palette32 = (unsigned int *)s->palette; |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
319 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
|
320 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
321 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
322 case PIX_FMT_YUV444P: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
323 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
|
324 pal_elem = palette_data[i]; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
325 r = (pal_elem >> 16) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
326 g = (pal_elem >> 8) & 0xff; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
327 b = pal_elem & 0xff; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
332 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
333 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
334 default: |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
335 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
|
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 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
339 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
340 /* 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
|
341 * moves beyond width */ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
342 #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
|
343 current_x++; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
344 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
|
345 index += line_inc; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
346 current_x = 0; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
347 } |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
348 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
349 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
|
350 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
|
351 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
352 int stride; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
353 int line_inc; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
354 int index; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
355 int current_x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
356 int width = s->avctx->width; |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
357 unsigned char pix; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
358 unsigned char *palette_plane; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
359 unsigned char *y_plane; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
360 unsigned char *u_plane; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
361 unsigned char *v_plane; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
362 unsigned char *rgb_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
363 unsigned short *rgb16_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
364 unsigned short *palette16; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
365 unsigned int *rgb32_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
366 unsigned int *palette32; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
367 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
368 switch (s->avctx->pix_fmt) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
369 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
370 case PIX_FMT_PAL8: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
371 palette_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
372 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
373 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
374 index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
375 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
376 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
377 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
378 /* 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
|
379 * 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
|
380 palette_plane[index++] = *pixel_buffer++; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
381 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
382 ADVANCE_CURRENT_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
383 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
384 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
385 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
386 case PIX_FMT_RGB555: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
387 case PIX_FMT_RGB565: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
388 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
|
389 palette16 = (unsigned short *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
390 stride = s->current_frame.linesize[0] / 2; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
391 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
392 index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
393 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
394 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
395 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
396 rgb16_plane[index++] = palette16[*pixel_buffer++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
397 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
398 ADVANCE_CURRENT_X(); |
1459
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 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
401 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
402 case PIX_FMT_RGB24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
403 case PIX_FMT_BGR24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
404 rgb_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
405 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
406 line_inc = stride - width * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
407 index = y * stride + x * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
408 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
409 while(pixel_count--) { |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
410 pix = *pixel_buffer++; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
411 |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
412 rgb_plane[index++] = s->palette[pix * 4 + 0]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
413 rgb_plane[index++] = s->palette[pix * 4 + 1]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
414 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
|
415 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
416 ADVANCE_CURRENT_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
417 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
418 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
419 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
420 case PIX_FMT_RGBA32: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
421 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
|
422 palette32 = (unsigned int *)s->palette; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
423 stride = s->current_frame.linesize[0] / 4; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
424 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
425 index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
426 current_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
427 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
428 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
429 rgb32_plane[index++] = palette32[*pixel_buffer++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
430 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
431 ADVANCE_CURRENT_X(); |
1459
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 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
434 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
435 case PIX_FMT_YUV444P: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
436 y_plane = s->current_frame.data[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
437 u_plane = s->current_frame.data[1]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
438 v_plane = s->current_frame.data[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
439 stride = s->current_frame.linesize[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
440 line_inc = stride - width; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
441 index = y * stride + x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
442 current_x = x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
443 while(pixel_count--) { |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
444 pix = *pixel_buffer++; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
445 |
1466
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
446 y_plane[index] = s->palette[pix * 4 + 0]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
447 u_plane[index] = s->palette[pix * 4 + 1]; |
618b148f6b76
change pixel identifier conflict with AltiVec headers (patch courtesy of
tmmm
parents:
1464
diff
changeset
|
448 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
|
449 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
450 index++; |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
451 ADVANCE_CURRENT_X(); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
452 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
453 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
454 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
455 default: |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
456 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
|
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 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
460 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
461 #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
|
462 curframe_x++; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
463 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
|
464 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
|
465 curframe_x = 0; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
466 } |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
467 |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
468 #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
|
469 prevframe_x++; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
470 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
|
471 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
|
472 prevframe_x = 0; \ |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
473 } |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
474 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
475 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
|
476 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
|
477 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
478 int stride; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
479 int line_inc; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
480 int curframe_index, prevframe_index; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
481 int curframe_x, prevframe_x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
482 int width = s->avctx->width; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
483 unsigned char *palette_plane, *prev_palette_plane; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
484 unsigned char *y_plane, *u_plane, *v_plane; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
485 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
|
486 unsigned char *rgb_plane, *prev_rgb_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
487 unsigned short *rgb16_plane, *prev_rgb16_plane; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
488 unsigned int *rgb32_plane, *prev_rgb32_plane; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
489 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
490 switch (s->avctx->pix_fmt) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
491 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
492 case PIX_FMT_PAL8: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
493 palette_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
494 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
|
495 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
496 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
497 curframe_index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
498 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
499 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
|
500 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
501 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
502 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
503 palette_plane[curframe_index++] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
504 prev_palette_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
505 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
506 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
507 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
508 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
509 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
510 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
511 case PIX_FMT_RGB555: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
512 case PIX_FMT_RGB565: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
513 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
|
514 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
|
515 stride = s->current_frame.linesize[0] / 2; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
516 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
517 curframe_index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
518 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
519 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
|
520 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
521 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
522 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
523 rgb16_plane[curframe_index++] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
524 prev_rgb16_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
525 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
526 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
527 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
528 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
529 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
530 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
531 case PIX_FMT_RGB24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
532 case PIX_FMT_BGR24: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
533 rgb_plane = s->current_frame.data[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
534 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
|
535 stride = s->current_frame.linesize[0]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
536 line_inc = stride - width * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
537 curframe_index = y * stride + x * 3; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
538 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
539 prevframe_index = (y + motion_y) * stride + |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
540 (3 * (x + motion_x)); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
541 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
542 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
543 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
544 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
|
545 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
|
546 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
|
547 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
548 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
549 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
550 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
551 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
552 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
553 case PIX_FMT_RGBA32: |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
554 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
|
555 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
|
556 stride = s->current_frame.linesize[0] / 4; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
557 line_inc = stride - width; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
558 curframe_index = y * stride + x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
559 curframe_x = x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
560 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
|
561 prevframe_x = x + motion_x; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
562 while(pixel_count--) { |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
563 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
564 rgb32_plane[curframe_index++] = |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
565 prev_rgb32_plane[prevframe_index++]; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
566 |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
567 ADVANCE_CURFRAME_X(); |
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
568 ADVANCE_PREVFRAME_X(); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
569 } |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
570 break; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
571 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
572 case PIX_FMT_YUV444P: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
573 y_plane = s->current_frame.data[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
574 u_plane = s->current_frame.data[1]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
575 v_plane = s->current_frame.data[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
576 prev_y_plane = s->last_frame.data[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
577 prev_u_plane = s->last_frame.data[1]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
578 prev_v_plane = s->last_frame.data[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
579 stride = s->current_frame.linesize[0]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
580 line_inc = stride - width; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
581 curframe_index = y * stride + x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
582 curframe_x = x; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
583 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
|
584 prevframe_x = x + motion_x; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
585 while(pixel_count--) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
586 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
587 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
|
588 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
|
589 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
|
590 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
591 curframe_index++; |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
592 ADVANCE_CURFRAME_X(); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
593 prevframe_index++; |
1476
72e115e94673
MACRO-ize a bunch of redundant code blocks; fix 16-bit RGB modes (it's
tmmm
parents:
1466
diff
changeset
|
594 ADVANCE_PREVFRAME_X(); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
595 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
596 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
597 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
598 default: |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1585
diff
changeset
|
599 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
|
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 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
603 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
604 static void xan_wc3_decode_frame(XanContext *s) { |
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 int width = s->avctx->width; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
607 int height = s->avctx->height; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
608 int total_pixels = width * height; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
609 unsigned char opcode; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
610 unsigned char flag = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
611 int size = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
612 int motion_x, motion_y; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
613 int x, y; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
614 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
615 unsigned char *opcode_buffer = s->buffer1; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
616 unsigned char *imagedata_buffer = s->buffer2; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
617 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
618 /* 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
|
619 unsigned char *huffman_segment; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
620 unsigned char *size_segment; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
621 unsigned char *vector_segment; |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
622 unsigned char *imagedata_segment; |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
623 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
624 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
|
625 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
|
626 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
|
627 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
|
628 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
629 xan_huffman_decode(opcode_buffer, huffman_segment); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
630 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
631 if (imagedata_segment[0] == 2) |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
632 xan_unpack(imagedata_buffer, &imagedata_segment[1]); |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
633 else |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
634 imagedata_buffer = &imagedata_segment[1]; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
635 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
636 /* 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
|
637 x = y = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
638 while (total_pixels) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
639 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
640 opcode = *opcode_buffer++; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
641 size = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
642 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
643 switch (opcode) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
644 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
645 case 0: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
646 flag ^= 1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
647 continue; |
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 1: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
650 case 2: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
651 case 3: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
652 case 4: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
653 case 5: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
654 case 6: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
655 case 7: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
656 case 8: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
657 size = opcode; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
658 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
659 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
660 case 12: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
661 case 13: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
662 case 14: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
663 case 15: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
664 case 16: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
665 case 17: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
666 case 18: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
667 size += (opcode - 10); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
668 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
669 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
670 case 9: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
671 case 19: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
672 size = *size_segment++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
673 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
674 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
675 case 10: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
676 case 20: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
677 size = BE_16(&size_segment[0]); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
678 size_segment += 2; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
679 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
680 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
681 case 11: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
682 case 21: |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
683 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
|
684 size_segment[2]; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
685 size_segment += 3; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
686 break; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
687 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
688 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
689 if (opcode < 12) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
690 flag ^= 1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
691 if (flag) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
692 /* 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
|
693 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
|
694 } else { |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
695 /* 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
|
696 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
|
697 imagedata_buffer += size; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
698 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
699 } else { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
700 /* run-based motion compensation from last frame */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
701 motion_x = (*vector_segment >> 4) & 0xF; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
702 motion_y = *vector_segment & 0xF; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
703 vector_segment++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
704 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
705 /* sign extension */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
706 if (motion_x & 0x8) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
707 motion_x |= 0xFFFFFFF0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
708 if (motion_y & 0x8) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
709 motion_y |= 0xFFFFFFF0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
710 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
711 /* 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
|
712 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
|
713 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
714 flag = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
715 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
716 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
717 /* coordinate accounting */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
718 total_pixels -= size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
719 while (size) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
720 if (x + size >= width) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
721 y++; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
722 size -= (width - x); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
723 x = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
724 } else { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
725 x += size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
726 size = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
727 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
728 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
729 } |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
730 |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
731 /* 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
|
732 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
|
733 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
|
734 s->current_frame.palette_has_changed = 1; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
735 s->avctx->palctrl->palette_changed = 0; |
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
736 } |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
737 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
738 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
739 static void xan_wc4_decode_frame(XanContext *s) { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
740 } |
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 static int xan_decode_frame(AVCodecContext *avctx, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
743 void *data, int *data_size, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
744 uint8_t *buf, int buf_size) |
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 XanContext *s = avctx->priv_data; |
1585
6b224ca24033
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
melanson
parents:
1476
diff
changeset
|
747 AVPaletteControl *palette_control = avctx->palctrl; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
748 int keyframe = 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
749 |
1462 | 750 if (palette_control->palette_changed) { |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
751 /* load the new palette and reset the palette control */ |
1462 | 752 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
|
753 /* 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
|
754 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
|
755 palette_control->palette_changed = 0; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
756 keyframe = 1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
757 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
758 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
759 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
|
760 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
|
761 return -1; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
762 } |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
763 s->current_frame.reference = 3; |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
764 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
765 s->buf = buf; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
766 s->size = buf_size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
767 |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
768 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
|
769 xan_wc3_decode_frame(s); |
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
770 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
|
771 xan_wc4_decode_frame(s); |
1459
201d4e25c207
xan_wc3 decoder now works correctly; added a bunch of output
tmmm
parents:
1443
diff
changeset
|
772 |
1443
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
773 /* release the last frame if it is allocated */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
774 if (s->last_frame.data[0]) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
775 avctx->release_buffer(avctx, &s->last_frame); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
776 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
777 /* shuffle frames */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
778 s->last_frame = s->current_frame; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
779 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
780 *data_size = sizeof(AVFrame); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
781 *(AVFrame*)data = s->current_frame; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
782 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
783 /* always report that the buffer was completely consumed */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
784 return buf_size; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
785 } |
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 static int xan_decode_end(AVCodecContext *avctx) |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
788 { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
789 XanContext *s = avctx->priv_data; |
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 /* release the last frame */ |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
792 avctx->release_buffer(avctx, &s->last_frame); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
793 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
794 av_free(s->buffer1); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
795 av_free(s->buffer2); |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
796 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
797 return 0; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
798 } |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
799 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
800 AVCodec xan_wc3_decoder = { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
801 "xan_wc3", |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
802 CODEC_TYPE_VIDEO, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
803 CODEC_ID_XAN_WC3, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
804 sizeof(XanContext), |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
805 xan_decode_init, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
806 NULL, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
807 xan_decode_end, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
808 xan_decode_frame, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
809 CODEC_CAP_DR1, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
810 }; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
811 |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
812 /* |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
813 AVCodec xan_wc4_decoder = { |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
814 "xan_wc4", |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
815 CODEC_TYPE_VIDEO, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
816 CODEC_ID_XAN_WC4, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
817 sizeof(XanContext), |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
818 xan_decode_init, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
819 NULL, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
820 xan_decode_end, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
821 xan_decode_frame, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
822 CODEC_CAP_DR1, |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
823 }; |
47f4c8a5a7fc
New fringe codecs: WC3/Xan video, Xan DPCM, DK3 & DK4 ADPCM
tmmm
parents:
diff
changeset
|
824 */ |