annotate libmpcodecs/vd_lcl.c @ 8661:660ca8757810

Lots of small corrections and rewordings, words capitalized and sentences ended in a '.'. Originally based on a patch by seru <seru@gmx.net>.
author diego
date Mon, 30 Dec 2002 20:40:15 +0000
parents fb88ccbc5ccc
children 2ed9b2143f94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7222
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
1 /*
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
2 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
3 * LCL (LossLess Codec Library) Decoder for Mplayer
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
4 * (c) 2002 Roberto Togni
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
5 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
6 * Fourcc: MSZH, ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
7 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
8 * Win32 dll:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
9 * Ver2.23 By Kenji Oshima 2000.09.20
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
10 * avimszh.dll, avizlib.dll
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
11 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
12 * A description of the decoding algorithm can be found here:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
13 * http://www.pcisys.net/~melanson/codecs
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
14 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
15 */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
16
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
17 #include <stdio.h>
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
18 #include <stdlib.h>
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
19
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
20 #include "config.h"
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
21
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
22 #ifdef HAVE_ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
23 #include <zlib.h>
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
24 #endif
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
25
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
26 #include "mp_msg.h"
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
27
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
28 #include "vd_internal.h"
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
29
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
30
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
31 static vd_info_t info = {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
32 "LCL Video decoder",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
33 "lcl",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
34 "Roberto Togni",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
35 "Roberto Togni",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
36 "native codec"
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
37 };
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
38
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
39 LIBVD_EXTERN(lcl)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
40
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
41
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
42 #define BMPTYPE_YUV 1
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
43 #define BMPTYPE_RGB 2
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
44
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
45 #define IMGTYPE_YUV111 0
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
46 #define IMGTYPE_YUV422 1
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
47 #define IMGTYPE_RGB24 2
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
48 #define IMGTYPE_YUV411 3
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
49 #define IMGTYPE_YUV211 4
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
50 #define IMGTYPE_YUV420 5
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
51
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
52 #define COMP_MSZH 0
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
53 #define COMP_MSZH_NOCOMP 1
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
54 #define COMP_ZLIB_HISPEED 1
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
55 #define COMP_ZLIB_HICOMP 9
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
56 #define COMP_ZLIB_NORMAL -1
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
57
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
58 #define FLAG_MULTITHREAD 1
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
59 #define FLAG_NULLFRAME 2
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
60 #define FLAG_PNGFILTER 4
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
61 #define FLAGMASK_UNUSED 0xf8
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
62
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
63 #define CODEC_MSZH 1
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
64 #define CODEC_ZLIB 3
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
65
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
66 #define FOURCC_MSZH mmioFOURCC('M','S','Z','H')
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
67 #define FOURCC_ZLIB mmioFOURCC('Z','L','I','B')
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
68
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
69 /*
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
70 * Decoder context
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
71 */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
72 typedef struct {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
73 // Image type
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
74 int imgtype;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
75 // Compression type
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
76 int compression;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
77 // Flags
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
78 int flags;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
79 // Codec type
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
80 int codec;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
81 // Decompressed data size
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
82 unsigned int decomp_size;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
83 // Decompression buffer
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
84 unsigned char* decomp_buf;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
85 #ifdef HAVE_ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
86 z_stream zstream;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
87 #endif
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
88 } lcl_context_t;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
89
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
90
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
91 /*
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
92 * Internal function prototypes
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
93 */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
94
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
95
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
96 // to set/get/query special features/parameters
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
97 static int control(sh_video_t *sh,int cmd,void* arg,...)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
98 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
99 return CONTROL_UNKNOWN;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
100 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
101
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
102
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
103 /*
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
104 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
105 * Init LCL decoder
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
106 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
107 */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
108 static int init(sh_video_t *sh)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
109 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
110 int vo_ret; // Video output init ret value
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
111 int zret; // Zlib return code
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
112 lcl_context_t *hc; // Decoder context
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
113 BITMAPINFOHEADER *bih = sh->bih;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
114 int basesize = bih->biWidth * bih->biHeight;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
115
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
116 if ((hc = malloc(sizeof(lcl_context_t))) == NULL) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
117 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate memory for LCL decoder context.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
118 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
119 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
120
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
121 sh->context = (void *)hc;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
122
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
123 #ifdef HAVE_ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
124 // Needed if zlib unused or init aborted before inflateInit
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
125 memset(&(hc->zstream), 0, sizeof(z_stream));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
126 #endif
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
127
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
128 if ((bih->biCompression != FOURCC_MSZH) && (bih->biCompression != FOURCC_ZLIB)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
129 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] Unknown BITMAPHEADER fourcc.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
130 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
131 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
132
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
133 if (bih->biSize < sizeof(BITMAPINFOHEADER) + 8) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
134 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BITMAPHEADER size too small.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
135 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
136 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
137
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
138 /* Detect codec type */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
139 switch (hc->codec = *((char *)bih + sizeof(BITMAPINFOHEADER) + 7)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
140 case CODEC_MSZH:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
141 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Codec is MSZH.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
142 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
143 case CODEC_ZLIB:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
144 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Codec is ZLIB.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
145 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
146 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
147 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] Unknown codec id %d. Trusting fourcc.\n", hc->codec);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
148 switch (bih->biCompression) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
149 case FOURCC_MSZH:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
150 hc->codec = CODEC_MSZH;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
151 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
152 case FOURCC_ZLIB:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
153 hc->codec = CODEC_ZLIB;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
154 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
155 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
156 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] BUG! Unknown coded id and fourcc. Why am I here?.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
157 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
158 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
159 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
160
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
161
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
162 /* Detect image type */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
163 switch (hc->imgtype = *((char *)bih + sizeof(BITMAPINFOHEADER) + 4)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
164 case IMGTYPE_YUV111:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
165 hc->decomp_size = basesize * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
166 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 1:1:1.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
167 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
168 case IMGTYPE_YUV422:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
169 hc->decomp_size = basesize * 2;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
170 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 4:2:2.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
171 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
172 case IMGTYPE_RGB24:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
173 hc->decomp_size = basesize * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
174 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is RGB 24.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
175 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
176 case IMGTYPE_YUV411:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
177 hc->decomp_size = basesize / 2 * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
178 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 4:1:1.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
179 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
180 case IMGTYPE_YUV211:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
181 hc->decomp_size = basesize * 2;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
182 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 2:1:1.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
183 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
184 case IMGTYPE_YUV420:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
185 hc->decomp_size = basesize / 2 * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
186 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 4:2:0.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
187 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
188 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
189 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Unsupported image format %d.\n", hc->imgtype);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
190 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
191 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
192
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
193 /* Detect compression method */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
194 hc->compression = *((char *)bih + sizeof(BITMAPINFOHEADER) + 5);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
195 switch (hc->codec) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
196 case CODEC_MSZH:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
197 switch (hc->compression) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
198 case COMP_MSZH:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
199 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Compression enabled.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
200 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
201 case COMP_MSZH_NOCOMP:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
202 hc->decomp_size = 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
203 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] No compression.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
204 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
205 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
206 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Unsupported compression format for MSZH (%d).\n", hc->compression);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
207 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
208 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
209 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
210 case CODEC_ZLIB:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
211 switch (hc->compression) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
212 case COMP_ZLIB_HISPEED:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
213 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] High speed compression.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
214 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
215 case COMP_ZLIB_HICOMP:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
216 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] High compression.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
217 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
218 case COMP_ZLIB_NORMAL:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
219 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Normal compression.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
220 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
221 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
222 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Unsupported compression format for ZLIB (%d).\n", hc->compression);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
223 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
224 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
225 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
226 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
227 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown codec in compression switch.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
228 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
229 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
230
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
231 /* Allocate decompression buffer */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
232 /* 4*8 max oveflow space for mszh decomp algorithm */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
233 if (hc->decomp_size) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
234 if ((hc->decomp_buf = malloc(hc->decomp_size+4*8)) == NULL) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
235 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Can't allocate decompression buffer.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
236 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
237 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
238 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
239
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
240 /* Detect flags */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
241 hc->flags = *((char *)bih + sizeof(BITMAPINFOHEADER) + 6);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
242 if (hc->flags & FLAG_MULTITHREAD)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
243 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Multithread encoder flag set.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
244 if (hc->flags & FLAG_NULLFRAME)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
245 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Nullframe insertion flag set.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
246 if ((hc->codec == CODEC_ZLIB) && (hc->flags & FLAG_PNGFILTER))
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
247 mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] PNG filter flag set.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
248 if (hc->flags & FLAGMASK_UNUSED)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
249 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] Unknown flag set (%d).\n", hc->flags);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
250
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
251 /* If needed init zlib */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
252 if (hc->codec == CODEC_ZLIB) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
253 #ifdef HAVE_ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
254 hc->zstream.zalloc = Z_NULL;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
255 hc->zstream.zfree = Z_NULL;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
256 hc->zstream.opaque = Z_NULL;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
257 zret = inflateInit(&(hc->zstream));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
258 if (zret != Z_OK) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
259 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Inflate init error: %d\n", zret);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
260 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
261 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
262 #else
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
263 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Zlib support not compiled.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
264 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
265 #endif
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
266 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
267
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
268 /*
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
269 * Initialize video output device
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
270 */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
271 vo_ret = mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
272
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
273 return vo_ret;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
274 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
275
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
276
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
277
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
278
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
279 /*
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
280 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
281 * Uninit LCL decoder
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
282 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
283 */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
284 static void uninit(sh_video_t *sh)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
285 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
286 lcl_context_t *hc = (lcl_context_t *) sh->context; // Decoder context
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
287
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
288 if (sh->context) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
289 #ifdef HAVE_ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
290 inflateEnd(&hc->zstream);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
291 #endif
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
292 free(sh->context);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
293 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
294 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
295
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
296
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
297
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
298 inline unsigned char fix (int pix14)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
299 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
300 int tmp;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
301
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
302 tmp = (pix14 + 0x80000) >> 20;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
303 if (tmp < 0)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
304 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
305 if (tmp > 255)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
306 return 255;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
307 return tmp;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
308 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
309
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
310
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
311
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
312 inline unsigned char get_b (unsigned char yq, signed char bq)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
313 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
314 return fix((yq << 20) + bq * 1858076);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
315 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
316
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
317
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
318
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
319 inline unsigned char get_g (unsigned char yq, signed char bq, signed char rq)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
320 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
321 return fix((yq << 20) - bq * 360857 - rq * 748830);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
322 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
323
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
324
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
325
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
326 inline unsigned char get_r (unsigned char yq, signed char rq)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
327 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
328 return fix((yq << 20) + rq * 1470103);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
329 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
330
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
331
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
332 int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
333
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
334 /*
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
335 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
336 * Decode a frame
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
337 *
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
338 */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
339 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
340 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
341 mp_image_t* mpi;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
342 int pixel_ptr;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
343 int row, col;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
344 unsigned char *encoded = (unsigned char *)data;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
345 lcl_context_t *hc = (lcl_context_t *) sh->context; // Decoder context
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
346 unsigned char *outptr;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
347 int width = sh->disp_w; // Real image width
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
348 int height = sh->disp_h; // Real image height
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
349 #ifdef HAVE_ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
350 int zret; // Zlib return code
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
351 #endif
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
352 unsigned int mszh_dlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
353 unsigned char yq, y1q, uq, vq;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
354 int uqvq;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
355 unsigned int mthread_inlen, mthread_outlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
356
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
357 // Skipped frame
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
358 if(len <= 0)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
359 return NULL;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
360
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
361 /* Get output image buffer */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
362 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0, sh->disp_w, sh->disp_h);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
363 if (!mpi) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
364 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate mpi image for lcl codec.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
365 return NULL;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
366 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
367
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
368 outptr = mpi->planes[0]; // Output image pointer
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
369
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
370
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
371 /* Decompress frame */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
372 switch (hc->codec) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
373 case CODEC_MSZH:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
374 switch (hc->compression) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
375 case COMP_MSZH:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
376 if (hc->flags & FLAG_MULTITHREAD) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
377 mthread_inlen = *((unsigned int*)encoded);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
378 mthread_outlen = *((unsigned int*)(encoded+4));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
379 mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, hc->decomp_buf);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
380 if (mthread_outlen != mszh_dlen) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
381 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] MSZH: mthread1 decoded size differs (%d != %d)\n",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
382 mthread_outlen, mszh_dlen);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
383 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
384 mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - mthread_inlen,
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
385 hc->decomp_buf + mthread_outlen);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
386 if ((hc->decomp_size - mthread_outlen) != mszh_dlen) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
387 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] MSZH: mthread2 decoded size differs (%d != %d)\n",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
388 hc->decomp_size - mthread_outlen, mszh_dlen);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
389 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
390 encoded = hc->decomp_buf;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
391 len = hc->decomp_size;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
392 } else {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
393 mszh_dlen = mszh_decomp(encoded, len, hc->decomp_buf);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
394 if (hc->decomp_size != mszh_dlen) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
395 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] MSZH: decoded size differs (%d != %d)\n",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
396 hc->decomp_size, mszh_dlen);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
397 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
398 encoded = hc->decomp_buf;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
399 len = mszh_dlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
400 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
401 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
402 case COMP_MSZH_NOCOMP:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
403 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
404 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
405 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown MSZH compression in frame decoder.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
406 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
407 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
408 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
409 case CODEC_ZLIB:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
410 switch (hc->compression) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
411 case COMP_ZLIB_HISPEED:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
412 case COMP_ZLIB_HICOMP:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
413 case COMP_ZLIB_NORMAL:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
414 #ifdef HAVE_ZLIB
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
415 zret = inflateReset(&(hc->zstream));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
416 if (zret != Z_OK) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
417 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: inflate reset error: %d\n", zret);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
418 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
419 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
420 if (hc->flags & FLAG_MULTITHREAD) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
421 mthread_inlen = *((unsigned int*)encoded);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
422 mthread_outlen = *((unsigned int*)(encoded+4));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
423 hc->zstream.next_in = encoded + 8;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
424 hc->zstream.avail_in = mthread_inlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
425 hc->zstream.next_out = hc->decomp_buf;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
426 hc->zstream.avail_out = mthread_outlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
427 zret = inflate(&(hc->zstream), Z_FINISH);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
428 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
429 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: mthread1 inflate error: %d\n", zret);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
430 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
431 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
432 if (mthread_outlen != (unsigned int)(hc->zstream.total_out)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
433 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] ZLIB: mthread1 decoded size differs (%d != %d)\n",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
434 mthread_outlen, hc->zstream.total_out);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
435 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
436 zret = inflateReset(&(hc->zstream));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
437 if (zret != Z_OK) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
438 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: mthread2 inflate reset error: %d\n", zret);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
439 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
440 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
441 hc->zstream.next_in = encoded + 8 + mthread_inlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
442 hc->zstream.avail_in = len - mthread_inlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
443 hc->zstream.next_out = hc->decomp_buf + mthread_outlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
444 hc->zstream.avail_out = mthread_outlen;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
445 zret = inflate(&(hc->zstream), Z_FINISH);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
446 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
447 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: mthread2 inflate error: %d\n", zret);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
448 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
449 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
450 if ((hc->decomp_size - mthread_outlen) != (unsigned int)(hc->zstream.total_out)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
451 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] ZLIB: mthread2 decoded size differs (%d != %d)\n",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
452 hc->decomp_size - mthread_outlen, hc->zstream.total_out);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
453 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
454 } else {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
455 hc->zstream.next_in = data;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
456 hc->zstream.avail_in = len;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
457 hc->zstream.next_out = hc->decomp_buf;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
458 hc->zstream.avail_out = hc->decomp_size;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
459 zret = inflate(&(hc->zstream), Z_FINISH);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
460 if ((zret != Z_OK) && (zret != Z_STREAM_END)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
461 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: inflate error: %d\n", zret);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
462 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
463 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
464 if (hc->decomp_size != (unsigned int)(hc->zstream.total_out)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
465 mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] ZLIB: decoded size differs (%d != %d)\n",
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
466 hc->decomp_size, hc->zstream.total_out);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
467 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
468 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
469 encoded = hc->decomp_buf;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
470 len = hc->decomp_size;;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
471 #else
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
472 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Zlib support not compiled in frame decoder.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
473 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
474 #endif
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
475 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
476 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
477 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown ZLIB compression in frame decoder.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
478 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
479 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
480 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
481 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
482 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown codec in frame decoder compression switch.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
483 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
484 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
485
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
486
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
487 /* Apply PNG filter */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
488 if ((hc->codec == CODEC_ZLIB) && (hc->flags & FLAG_PNGFILTER)) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
489 switch (hc->imgtype) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
490 case IMGTYPE_YUV111:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
491 for (row = 0; row < height; row++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
492 pixel_ptr = row * width * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
493 yq = encoded[pixel_ptr++];
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7247
diff changeset
494 uqvq = encoded[pixel_ptr++];
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7247
diff changeset
495 uqvq+=(encoded[pixel_ptr++] << 8);
7222
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
496 for (col = 1; col < width; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
497 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
498 uqvq -= (encoded[pixel_ptr+1] | (encoded[pixel_ptr+2]<<8));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
499 encoded[pixel_ptr+1] = (uqvq) & 0xff;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
500 encoded[pixel_ptr+2] = ((uqvq)>>8) & 0xff;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
501 pixel_ptr += 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
502 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
503 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
504 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
505 case IMGTYPE_RGB24: // No
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
506 for (row = 0; row < height; row++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
507 pixel_ptr = row * width * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
508 yq = encoded[pixel_ptr++];
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7247
diff changeset
509 uqvq = encoded[pixel_ptr++];
fb88ccbc5ccc compiler warning fixes
arpi
parents: 7247
diff changeset
510 uqvq+=(encoded[pixel_ptr++] << 8);
7222
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
511 for (col = 1; col < width; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
512 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
513 uqvq -= (encoded[pixel_ptr+1] | (encoded[pixel_ptr+2]<<8));
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
514 encoded[pixel_ptr+1] = (uqvq) & 0xff;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
515 encoded[pixel_ptr+2] = ((uqvq)>>8) & 0xff;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
516 pixel_ptr += 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
517 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
518 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
519 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
520 case IMGTYPE_YUV422:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
521 for (row = 0; row < height; row++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
522 pixel_ptr = row * width * 2;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
523 yq = uq = vq =0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
524 for (col = 0; col < width/4; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
525 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
526 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
527 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
528 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
529 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
530 encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
531 encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
532 encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
533 pixel_ptr += 8;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
534 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
535 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
536 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
537 case IMGTYPE_YUV411:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
538 for (row = 0; row < height; row++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
539 pixel_ptr = row * width / 2 * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
540 yq = uq = vq =0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
541 for (col = 0; col < width/4; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
542 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
543 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
544 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
545 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
546 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
547 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
548 pixel_ptr += 6;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
549 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
550 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
551 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
552 case IMGTYPE_YUV211:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
553 for (row = 0; row < height; row++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
554 pixel_ptr = row * width * 2;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
555 yq = uq = vq =0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
556 for (col = 0; col < width/2; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
557 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
558 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
559 encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
560 encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
561 pixel_ptr += 4;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
562 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
563 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
564 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
565 case IMGTYPE_YUV420:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
566 for (row = 0; row < height/2; row++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
567 pixel_ptr = row * width * 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
568 yq = y1q = uq = vq =0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
569 for (col = 0; col < width/2; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
570 encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
571 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
572 encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
573 encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
574 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
575 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
576 pixel_ptr += 6;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
577 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
578 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
579 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
580 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
581 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
582 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown imagetype in pngfilter switch.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
583 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
584 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
585 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
586
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
587 /* Convert colorspace */
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
588 switch (hc->imgtype) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
589 case IMGTYPE_YUV111:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
590 for (row = height - 1; row >= 0; row--) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
591 pixel_ptr = row * mpi->stride[0];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
592 for (col = 0; col < width; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
593 outptr[pixel_ptr++] = get_b(encoded[0], encoded[1]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
594 outptr[pixel_ptr++] = get_g(encoded[0], encoded[1], encoded[2]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
595 outptr[pixel_ptr++] = get_r(encoded[0], encoded[2]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
596 encoded += 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
597 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
598 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
599 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
600 case IMGTYPE_YUV422:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
601 for (row = height - 1; row >= 0; row--) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
602 pixel_ptr = row * mpi->stride[0];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
603 for (col = 0; col < width/4; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
604 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
605 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[6]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
606 outptr[pixel_ptr++] = get_r(encoded[0], encoded[6]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
607 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
608 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[6]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
609 outptr[pixel_ptr++] = get_r(encoded[1], encoded[6]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
610 outptr[pixel_ptr++] = get_b(encoded[2], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
611 outptr[pixel_ptr++] = get_g(encoded[2], encoded[5], encoded[7]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
612 outptr[pixel_ptr++] = get_r(encoded[2], encoded[7]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
613 outptr[pixel_ptr++] = get_b(encoded[3], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
614 outptr[pixel_ptr++] = get_g(encoded[3], encoded[5], encoded[7]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
615 outptr[pixel_ptr++] = get_r(encoded[3], encoded[7]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
616 encoded += 8;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
617 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
618 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
619 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
620 case IMGTYPE_RGB24:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
621 for (row = height - 1; row >= 0; row--) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
622 pixel_ptr = row * mpi->stride[0];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
623 for (col = 0; col < width; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
624 outptr[pixel_ptr++] = encoded[0];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
625 outptr[pixel_ptr++] = encoded[1];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
626 outptr[pixel_ptr++] = encoded[2];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
627 encoded += 3;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
628 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
629 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
630 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
631 case IMGTYPE_YUV411:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
632 for (row = height - 1; row >= 0; row--) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
633 pixel_ptr = row * mpi->stride[0];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
634 for (col = 0; col < width/4; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
635 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
636 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
637 outptr[pixel_ptr++] = get_r(encoded[0], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
638 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
639 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
640 outptr[pixel_ptr++] = get_r(encoded[1], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
641 outptr[pixel_ptr++] = get_b(encoded[2], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
642 outptr[pixel_ptr++] = get_g(encoded[2], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
643 outptr[pixel_ptr++] = get_r(encoded[2], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
644 outptr[pixel_ptr++] = get_b(encoded[3], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
645 outptr[pixel_ptr++] = get_g(encoded[3], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
646 outptr[pixel_ptr++] = get_r(encoded[3], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
647 encoded += 6;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
648 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
649 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
650 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
651 case IMGTYPE_YUV211:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
652 for (row = height - 1; row >= 0; row--) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
653 pixel_ptr = row * mpi->stride[0];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
654 for (col = 0; col < width/2; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
655 outptr[pixel_ptr++] = get_b(encoded[0], encoded[2]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
656 outptr[pixel_ptr++] = get_g(encoded[0], encoded[2], encoded[3]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
657 outptr[pixel_ptr++] = get_r(encoded[0], encoded[3]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
658 outptr[pixel_ptr++] = get_b(encoded[1], encoded[2]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
659 outptr[pixel_ptr++] = get_g(encoded[1], encoded[2], encoded[3]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
660 outptr[pixel_ptr++] = get_r(encoded[1], encoded[3]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
661 encoded += 4;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
662 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
663 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
664 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
665 case IMGTYPE_YUV420:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
666 for (row = height / 2 - 1; row >= 0; row--) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
667 pixel_ptr = 2 * row * mpi->stride[0];
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
668 for (col = 0; col < width/2; col++) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
669 outptr[pixel_ptr] = get_b(encoded[0], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
670 outptr[pixel_ptr+1] = get_g(encoded[0], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
671 outptr[pixel_ptr+2] = get_r(encoded[0], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
672 outptr[pixel_ptr+3] = get_b(encoded[1], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
673 outptr[pixel_ptr+4] = get_g(encoded[1], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
674 outptr[pixel_ptr+5] = get_r(encoded[1], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
675 outptr[pixel_ptr-mpi->stride[0]] = get_b(encoded[2], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
676 outptr[pixel_ptr-mpi->stride[0]+1] = get_g(encoded[2], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
677 outptr[pixel_ptr-mpi->stride[0]+2] = get_r(encoded[2], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
678 outptr[pixel_ptr-mpi->stride[0]+3] = get_b(encoded[3], encoded[4]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
679 outptr[pixel_ptr-mpi->stride[0]+4] = get_g(encoded[3], encoded[4], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
680 outptr[pixel_ptr-mpi->stride[0]+5] = get_r(encoded[3], encoded[5]);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
681 pixel_ptr += 6;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
682 encoded += 6;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
683 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
684 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
685 break;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
686 default:
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
687 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown imagetype in image decoder.\n");
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
688 return 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
689 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
690
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
691 return mpi;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
692 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
693
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
694
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
695
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
696 int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr)
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
697 {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
698 unsigned char *destptr_bak = destptr;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
699 unsigned char mask = 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
700 unsigned char maskbit = 0;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
701 unsigned int ofs, cnt;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
702
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
703 while (srclen > 0) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
704 if (maskbit == 0) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
705 mask = *(srcptr++);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
706 maskbit = 8;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
707 srclen--;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
708 continue;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
709 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
710 if ((mask & (1 << (--maskbit))) == 0) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
711 *(destptr++) = *(srcptr++);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
712 *(destptr++) = *(srcptr++);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
713 *(destptr++) = *(srcptr++);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
714 *(destptr++) = *(srcptr++);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
715 srclen -= 4;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
716 } else {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
717 ofs = *(srcptr++);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
718 cnt = *(srcptr++);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
719 ofs += cnt * 256;;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
720 cnt = ((cnt >> 3) & 0x1f) + 1;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
721 ofs &= 0x7ff;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
722 srclen -= 2;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
723 cnt *= 4;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
724 for (; cnt > 0; cnt--) {
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
725 *(destptr) = *(destptr - ofs);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
726 destptr++;
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
727 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
728 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
729 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
730
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
731 return (destptr - destptr_bak);
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
732 }
81f720e51821 added LCL decoder by Roberto Togni <r_togni@libero.it>, removed my old vd_zlib
alex
parents:
diff changeset
733