annotate libmpcodecs/native/nuppelvideo.c @ 22173:7a98ceca1330

removed ages-old and insane #if0-ed and commented code
author nicodvb
date Sat, 10 Feb 2007 12:19:36 +0000
parents fc27312ae599
children a124f3abc1ec
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"
21372
1767c271d710 Remove bswap.h, use libavutil/bswap.h instead.
diego
parents: 18068
diff changeset
16 #include "libavutil/common.h"
21507
fa99b3d31d13 Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents: 21372
diff changeset
17 #include "mpbswap.h"
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
18
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14896
diff changeset
19 #include "../libvo/fastmemcpy.h"
3810
007b3992c6b5 fixed RTjpeg and removed one memcpy
alex
parents: 3804
diff changeset
20
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
21 #include "libmpdemux/nuppelvideo.h"
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
22 #include "RTjpegN.h"
22080
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
23 #ifdef USE_LIBAVUTIL_SO
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
24 #include <ffmpeg/lzo.h>
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
25 #else
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
26 #include "libavutil/lzo.h"
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
27 #endif
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
28
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
29 #define KEEP_BUFFER
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
30
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
31 void decode_nuv( unsigned char *encoded, int encoded_size,
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
32 unsigned char *decoded, int width, int height)
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
33 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
34 int r;
18068
c34ffa6f5fa8 10l, we should really, really use lzo1x_decompress_safe instead of lzo1x_decompress
reimar
parents: 17012
diff changeset
35 unsigned int out_len = width * height + ( width * height ) / 2;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
36 struct rtframeheader *encodedh = ( struct rtframeheader* ) encoded;
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
37 static unsigned char *buffer = 0; /* for RTJpeg with LZO decompress */
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
38 #ifdef KEEP_BUFFER
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
39 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
40 #endif
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
41
3810
007b3992c6b5 fixed RTjpeg and removed one memcpy
alex
parents: 3804
diff changeset
42 // 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
43 // encodedh->frametype, encodedh->comptype, encoded_size, width, height);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
44
14896
9ddae5897422 Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents: 7127
diff changeset
45 le2me_rtframeheader(encodedh);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
46 switch(encodedh->frametype)
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
47 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
48 case 'D': /* additional data for compressors */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
49 {
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
50 /* tables are in encoded */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
51 if (encodedh->comptype == 'R')
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
52 {
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6238
diff changeset
53 RTjpeg_init_decompress ( (unsigned long *)(encoded+12), width, height );
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
54 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
55 encoded_size-12, width, height);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
56 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
57 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
58 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
59 case 'V':
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
60 {
22080
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
61 int in_len = encodedh->packetlength;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
62 #ifdef KEEP_BUFFER
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
63 if (!previous_buffer)
22080
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
64 previous_buffer = ( unsigned char * ) malloc ( out_len + LZO_OUTPUT_PADDING );
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
65 #endif
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
66
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
67 switch(encodedh->comptype)
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 case '0': /* raw YUV420 */
18068
c34ffa6f5fa8 10l, we should really, really use lzo1x_decompress_safe instead of lzo1x_decompress
reimar
parents: 17012
diff changeset
70 memcpy(decoded, encoded + 12, out_len);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
71 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
72 case '1': /* RTJpeg */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
73 RTjpeg_decompressYUV420 ( ( __s8 * ) encoded + 12, decoded );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
74 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
75 case '2': /* RTJpeg with LZO */
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
76 if (!buffer)
22080
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
77 buffer = ( unsigned char * ) malloc ( out_len + LZO_OUTPUT_PADDING );
4644
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
78 if (!buffer)
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
79 {
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
80 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
81 break;
c19fe4030bd4 break if error in decompressing, moved buffer allocating
alex
parents: 4384
diff changeset
82 }
22080
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
83 r = lzo1x_decode ( buffer, &out_len, encoded + 12, &in_len );
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
84 if ( r )
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
85 {
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
86 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n");
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
87 break;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
88 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
89 RTjpeg_decompressYUV420 ( ( __s8 * ) buffer, decoded );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
90 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
91 case '3': /* raw YUV420 with LZO */
22080
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
92 r = lzo1x_decode ( decoded, &out_len, encoded + 12, &in_len );
fc27312ae599 Use ffmpeg lzo instead of (also quite outdated) minlzo in nuppelvideo.
reimar
parents: 21507
diff changeset
93 if ( r )
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
94 {
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
95 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Nuppelvideo: error decompressing\n");
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
96 break;
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
97 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
98 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
99 case 'N': /* black frame */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
100 memset ( decoded, 0, width * height );
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
101 memset ( decoded + width * height, 127, width * height / 2);
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
102 break;
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
103 case 'L': /* copy last frame */
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
104 #ifdef KEEP_BUFFER
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
105 memcpy ( decoded, previous_buffer, width*height*3/2);
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
106 #endif
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 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
109
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
110 #ifdef KEEP_BUFFER
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
111 memcpy(previous_buffer, decoded, width*height*3/2);
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
112 #endif
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
113 break;
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 default:
5104
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
116 mp_msg(MSGT_DECVIDEO, MSGL_V, "Nuppelvideo: unknwon frametype: %c\n",
d60dcc0223ac changed to mp_msg
alex
parents: 4644
diff changeset
117 encodedh->frametype);
3804
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
118 }
53ed66a4f0bf NuppelVideo decoder added, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
119 }