Browse code

Miro VideoXL (VIXL) decoder, courtesy of Konstantin Shishkov

Originally committed as revision 3641 to svn://svn.ffmpeg.org/ffmpeg/trunk

Mike Melanson authored on 2004/10/27 13:30:48
Showing 7 changed files
... ...
@@ -5,6 +5,7 @@ version <next>
5 5
 - Apple QuickDraw (qdrw) video decoder
6 6
 - Creative ADPCM audio decoder
7 7
 - Electronic Arts Multimedia (WVE/UV2/etc.) file demuxer
8
+- Miro VideoXL (VIXL) video decoder
8 9
 
9 10
 version 0.4.9-pre1:
10 11
 
... ...
@@ -767,6 +767,7 @@ following image formats are supported:
767 767
 @item ZLIB                   @tab  X  @tab  X @tab Part of LCL, encoder experimental
768 768
 @item TechSmith Camtasia     @tab     @tab  X @tab fourcc: TSCC
769 769
 @item IBM Ultimotion         @tab     @tab  X @tab fourcc: ULTI
770
+@item Miro VideoXL           @tab     @tab  X @tab fourcc: VIXL
770 771
 @end multitable
771 772
 
772 773
 @code{X} means that the encoding (resp. decoding) is supported.
... ...
@@ -21,7 +21,7 @@ OBJS= common.o utils.o mem.o allcodecs.o \
21 21
       msvideo1.o vqavideo.o idcinvideo.o adx.o rational.o faandct.o 8bps.o \
22 22
       smc.o parser.o flicvideo.o truemotion1.o vmdav.o lcl.o qtrle.o g726.o \
23 23
       flac.o vp3dsp.o integer.o snow.o tscc.o sonic.o ulti.o h264idct.o \
24
-      qdrw.o
24
+      qdrw.o xl.o
25 25
 
26 26
 ifeq ($(AMR_NB),yes)
27 27
 ifeq ($(AMR_NB_FIXED),yes)
... ...
@@ -109,6 +109,7 @@ void avcodec_register_all(void)
109 109
     register_avcodec(&tscc_decoder);
110 110
     register_avcodec(&ulti_decoder);
111 111
     register_avcodec(&qdraw_decoder);
112
+    register_avcodec(&xl_decoder);
112 113
 #ifdef CONFIG_FAAD
113 114
     register_avcodec(&aac_decoder);
114 115
     register_avcodec(&mpeg4aac_decoder);
... ...
@@ -17,7 +17,7 @@ extern "C" {
17 17
 
18 18
 #define FFMPEG_VERSION_INT     0x000409
19 19
 #define FFMPEG_VERSION         "0.4.9-pre1"
20
-#define LIBAVCODEC_BUILD       4727
20
+#define LIBAVCODEC_BUILD       4728
21 21
 
22 22
 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
23 23
 #define LIBAVCODEC_VERSION     FFMPEG_VERSION
... ...
@@ -104,6 +104,7 @@ enum CodecID {
104 104
     CODEC_ID_TSCC,
105 105
     CODEC_ID_ULTI,
106 106
     CODEC_ID_QDRAW,
107
+    CODEC_ID_VIXL,
107 108
 
108 109
     /* various pcm "codecs" */
109 110
     CODEC_ID_PCM_S16LE,
... ...
@@ -1890,6 +1891,7 @@ extern AVCodec flac_decoder;
1890 1890
 extern AVCodec tscc_decoder;
1891 1891
 extern AVCodec ulti_decoder;
1892 1892
 extern AVCodec qdraw_decoder;
1893
+extern AVCodec xl_decoder;
1893 1894
 
1894 1895
 /* pcm codecs */
1895 1896
 #define PCM_CODEC(id, name) \
1896 1897
new file mode 100644
... ...
@@ -0,0 +1,144 @@
0
+/*
1
+ * Miro VideoXL codec
2
+ * Copyright (c) 2004 Konstantin Shishkov
3
+ *
4
+ * This library is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2 of the License, or (at your option) any later version.
8
+ *
9
+ * This library is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License along with this library; if not, write to the Free Software
16
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
+ *
18
+ */
19
+ 
20
+/**
21
+ * @file xl.c
22
+ * Miro VideoXL codec.
23
+ */
24
+ 
25
+#include "avcodec.h"
26
+#include "mpegvideo.h"
27
+
28
+typedef struct VideoXLContext{
29
+    AVCodecContext *avctx;
30
+    AVFrame pic;
31
+} VideoXLContext;
32
+
33
+const int xl_table[32] = {
34
+   0,   1,   2,   3,   4,   5,   6,   7,
35
+   8,   9,  12,  15,  20,  25,  34,  46,
36
+  64,  82,  94, 103, 108, 113, 116, 119,
37
+ 120, 121, 122, 123, 124, 125, 126, 127};
38
+
39
+static int decode_frame(AVCodecContext *avctx, 
40
+                        void *data, int *data_size,
41
+                        uint8_t *buf, int buf_size)
42
+{
43
+    VideoXLContext * const a = avctx->priv_data;
44
+    AVFrame * const p= (AVFrame*)&a->pic;
45
+    uint8_t *Y, *U, *V;
46
+    int i, j;
47
+    int stride;
48
+    uint32_t val;
49
+    int y0, y1, y2, y3, c0, c1;
50
+        
51
+    
52
+    /* special case for last picture */
53
+    if (buf_size == 0) {
54
+        return 0;
55
+    }
56
+
57
+    if(p->data[0])
58
+        avctx->release_buffer(avctx, p);
59
+
60
+    p->reference = 0;
61
+    if(avctx->get_buffer(avctx, p) < 0){
62
+        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
63
+        return -1;
64
+    }
65
+    p->pict_type= I_TYPE;
66
+    p->key_frame= 1;
67
+
68
+    Y = a->pic.data[0];
69
+    U = a->pic.data[1];
70
+    V = a->pic.data[2];
71
+    
72
+    stride = avctx->width - 4;
73
+    for (i = 0; i < avctx->height; i++) {
74
+        /* lines are stored in reversed order */
75
+        buf += stride;
76
+        
77
+        for (j = 0; j < avctx->width; j += 4) {
78
+            /* value is stored in LE dword with word swapped */
79
+            val = LE_32(buf);
80
+            buf -= 4;
81
+            val = ((val >> 16) & 0xFFFF) | ((val & 0xFFFF) << 16);
82
+    
83
+            if(!j)
84
+                y0 = (val & 0x1F) << 2;
85
+            else
86
+                y0 = y3 + xl_table[val & 0x1F];
87
+            val >>= 5;
88
+            y1 = y0 + xl_table[val & 0x1F];
89
+            val >>= 5;
90
+            y2 = y1 + xl_table[val & 0x1F];
91
+            val >>= 6; /* align to word */
92
+            y3 = y2 + xl_table[val & 0x1F];
93
+            val >>= 5;
94
+            if(!j)
95
+                c0 = (val & 0x1F) << 2;
96
+            else
97
+                c0 += xl_table[val & 0x1F];
98
+            val >>= 5;
99
+            if(!j)
100
+                c1 = (val & 0x1F) << 2;
101
+            else
102
+                c1 += xl_table[val & 0x1F];
103
+            
104
+            Y[j + 0] = y0 << 1;
105
+            Y[j + 1] = y1 << 1;
106
+            Y[j + 2] = y2 << 1;
107
+            Y[j + 3] = y3 << 1;
108
+            
109
+            U[j >> 2] = c0 << 1;
110
+            V[j >> 2] = c1 << 1;
111
+        }
112
+        
113
+        buf += avctx->width + 4;
114
+        Y += a->pic.linesize[0];
115
+        U += a->pic.linesize[1];
116
+        V += a->pic.linesize[2];
117
+    }
118
+
119
+    *data_size = sizeof(AVFrame);
120
+    *(AVFrame*)data = a->pic;
121
+    
122
+    return buf_size;
123
+}
124
+
125
+static int decode_init(AVCodecContext *avctx){
126
+//    VideoXLContext * const a = avctx->priv_data;
127
+
128
+    avctx->pix_fmt= PIX_FMT_YUV411P;
129
+
130
+    return 0;
131
+}
132
+
133
+AVCodec xl_decoder = {
134
+    "xl",
135
+    CODEC_TYPE_VIDEO,
136
+    CODEC_ID_VIXL,
137
+    sizeof(VideoXLContext),
138
+    decode_init,
139
+    NULL,
140
+    NULL,
141
+    decode_frame,
142
+    CODEC_CAP_DR1,
143
+};
... ...
@@ -169,6 +169,7 @@ const CodecTag codec_bmp_tags[] = {
169 169
     { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
170 170
     { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
171 171
     { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
172
+    { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
172 173
     { CODEC_ID_RAWVIDEO, 0 },
173 174
     { 0, 0 },
174 175
 };