2 * NuppelVideo 0.05 file parser
4 * by Panagiotis Issaris <takis@lumumba.luc.ac.be>
18 #include "libvo/fastmemcpy.h"
20 #include "libmpdemux/nuppelvideo.h"
22 #include "libavutil/lzo.h"
26 void decode_nuv( unsigned char *encoded
, int encoded_size
,
27 unsigned char *decoded
, int width
, int height
)
30 unsigned int out_len
= width
* height
+ ( width
* height
) / 2;
31 struct rtframeheader
*encodedh
= ( struct rtframeheader
* ) encoded
;
32 static unsigned char *buffer
= 0; /* for RTJpeg with LZO decompress */
34 static unsigned char *previous_buffer
= 0; /* to support Last-frame-copy */
37 // printf("frametype: %c, comtype: %c, encoded_size: %d, width: %d, height: %d\n",
38 // encodedh->frametype, encodedh->comptype, encoded_size, width, height);
40 le2me_rtframeheader(encodedh
);
41 switch(encodedh
->frametype
)
43 case 'D': /* additional data for compressors */
45 /* tables are in encoded */
46 if (encodedh
->comptype
== 'R')
48 RTjpeg_init_decompress ( (unsigned long *)(encoded
+12), width
, height
);
49 mp_msg(MSGT_DECVIDEO
, MSGL_V
, "Found RTjpeg tables (size: %d, width: %d, height: %d)\n",
50 encoded_size
-12, width
, height
);
56 int in_len
= encodedh
->packetlength
;
59 previous_buffer
= ( unsigned char * ) malloc ( out_len
+ LZO_OUTPUT_PADDING
);
62 switch(encodedh
->comptype
)
64 case '0': /* raw YUV420 */
65 fast_memcpy(decoded
, encoded
+ 12, out_len
);
67 case '1': /* RTJpeg */
68 RTjpeg_decompressYUV420 ( ( __s8
* ) encoded
+ 12, decoded
);
70 case '2': /* RTJpeg with LZO */
72 buffer
= ( unsigned char * ) malloc ( out_len
+ LZO_OUTPUT_PADDING
);
75 mp_msg(MSGT_DECVIDEO
, MSGL_ERR
, "Nuppelvideo: error decompressing\n");
78 r
= lzo1x_decode ( buffer
, &out_len
, encoded
+ 12, &in_len
);
81 mp_msg(MSGT_DECVIDEO
, MSGL_ERR
, "Nuppelvideo: error decompressing\n");
84 RTjpeg_decompressYUV420 ( ( __s8
* ) buffer
, decoded
);
86 case '3': /* raw YUV420 with LZO */
87 r
= lzo1x_decode ( decoded
, &out_len
, encoded
+ 12, &in_len
);
90 mp_msg(MSGT_DECVIDEO
, MSGL_ERR
, "Nuppelvideo: error decompressing\n");
94 case 'N': /* black frame */
95 memset ( decoded
, 0, width
* height
);
96 memset ( decoded
+ width
* height
, 127, width
* height
/ 2);
98 case 'L': /* copy last frame */
100 fast_memcpy ( decoded
, previous_buffer
, width
*height
*3/2);
106 fast_memcpy(previous_buffer
, decoded
, width
*height
*3/2);
111 mp_msg(MSGT_DECVIDEO
, MSGL_V
, "Nuppelvideo: unknwon frametype: %c\n",
112 encodedh
->frametype
);