annotate libmpcodecs/native/nuppelvideo.c @ 8001:f02197bd1409

some docs about video filter api
author arpi
date Thu, 31 Oct 2002 14:25:41 +0000
parents 1e47c2e7aa8e
children 9ddae5897422
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
1 /*
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
2 * NuppelVideo 0.05 file parser
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
3 * for MPlayer
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
4 * by Panagiotis Issaris <takis@lumumba.luc.ac.be>
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
5 *
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
6 * Reworked by alex
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
7 */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
8
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
9 #include <stdio.h>
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
10 #include <stdlib.h>
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
11 #include <unistd.h>
6238
594d2ffe9f1d warning fix (strings.h > string.h)
pl
parents: 6131
diff changeset
12 #include <string.h>
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
13
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
14 #include "config.h"
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
15 #include "mp_msg.h"
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
16
5604
5bd00421d251 fastmemcpy path fixed
arpi
parents: 5602
diff changeset
17 #include "../../libvo/fastmemcpy.h"
3810
007b3992c6b5 fixed RTjpeg and removed one memcpy
alex
parents: 3804
diff changeset
18
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
19 #include "libmpdemux/nuppelvideo.h"
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
20 #include "RTjpegN.h"
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
21 #include "minilzo.h"
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
22
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
23 #define KEEP_BUFFER
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
24
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
25 void decode_nuv( unsigned char *encoded, int encoded_size,
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
26 unsigned char *decoded, int width, int height)
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
27 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
28 int r;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
29 unsigned int out_len;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
30 struct rtframeheader *encodedh = ( struct rtframeheader* ) encoded;
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
31 static unsigned char *buffer = 0; /* for RTJpeg with LZO decompress */
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
32 #ifdef KEEP_BUFFER
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
33 static unsigned char *previous_buffer = 0; /* to support Last-frame-copy */
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
34 #endif
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
35 static int is_lzo_inited = 0;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
36
3810
007b3992c6b5 fixed RTjpeg and removed one memcpy
alex
parents: 3804
diff changeset
37 // printf("frametype: %c, comtype: %c, encoded_size: %d, width: %d, height: %d\n",
007b3992c6b5 fixed RTjpeg and removed one memcpy
alex
parents: 3804
diff changeset
38 // encodedh->frametype, encodedh->comptype, encoded_size, width, height);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
39
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
40 switch(encodedh->frametype)
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
41 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
42 case 'D': /* additional data for compressors */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
43 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
44 /* tables are in encoded */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
45 if (encodedh->comptype == 'R')
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
46 {
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6238
diff changeset
47 RTjpeg_init_decompress ( (unsigned long *)(encoded+12), width, height );
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
48 mp_msg(MSGT_DECVIDEO, MSGL_V, "Found RTjpeg tables (size: %d, width: %d, height: %d)\n",
3810
007b3992c6b5 fixed RTjpeg and removed one memcpy
alex
parents: 3804
diff changeset
49 encoded_size-12, width, height);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
50 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
51 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
52 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
53 case 'V':
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
54 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
55 #ifdef KEEP_BUFFER
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
56 if (!previous_buffer)
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
57 previous_buffer = ( unsigned char * ) malloc ( width * height + ( width * height ) / 2 );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
58 #endif
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
59
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
60 if (((encodedh->comptype == '2') ||
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
61 (encodedh->comptype == '3')) && !is_lzo_inited)
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
62 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
63 /* frame using lzo, init lzo first if not inited */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
64 if ( lzo_init() != LZO_E_OK )
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
65 {
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
66 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "LZO init failed\n");
4384
a1d27234018f avoids warnings
pl
parents: 3810
diff changeset
67 return;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
68 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
69 is_lzo_inited = 1;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
70 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
71
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
72 switch(encodedh->comptype)
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
73 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
74 case '0': /* raw YUV420 */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
75 memcpy(decoded, encoded + 12, width*height*3/2);
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
76 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
77 case '1': /* RTJpeg */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
78 RTjpeg_decompressYUV420 ( ( __s8 * ) encoded + 12, decoded );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
79 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
80 case '2': /* RTJpeg with LZO */
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
81 if (!buffer)
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
82 buffer = ( unsigned char * ) malloc ( width * height + ( width * height ) / 2 );
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
83 if (!buffer)
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
84 {
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
85 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n");
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
86 break;
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
87 }
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
88 r = lzo1x_decompress ( encoded + 12, encodedh->packetlength, buffer, &out_len, NULL );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
89 if ( r != LZO_E_OK )
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
90 {
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
91 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n");
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
92 break;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
93 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
94 RTjpeg_decompressYUV420 ( ( __s8 * ) buffer, decoded );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
95 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
96 case '3': /* raw YUV420 with LZO */
3810
007b3992c6b5 fixed RTjpeg and removed one memcpy
alex
parents: 3804
diff changeset
97 r = lzo1x_decompress ( encoded + 12, encodedh->packetlength, decoded, &out_len, NULL );
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
98 if ( r != LZO_E_OK )
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
99 {
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
100 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n");
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
101 break;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
102 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
103 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
104 case 'N': /* black frame */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
105 memset ( decoded, 0, width * height );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
106 memset ( decoded + width * height, 127, width * height / 2);
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
107 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
108 case 'L': /* copy last frame */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
109 #ifdef KEEP_BUFFER
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
110 memcpy ( decoded, previous_buffer, width*height*3/2);
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
111 #endif
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
112 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
113 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
114
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
115 #ifdef KEEP_BUFFER
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
116 memcpy(previous_buffer, decoded, width*height*3/2);
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
117 #endif
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
118 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
119 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
120 default:
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
121 mp_msg(MSGT_DECVIDEO, MSGL_V, "Nuppelvideo: unknwon frametype: %c\n",
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
122 encodedh->frametype);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
123 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
124 }