vo_glamo: sub.h was moved to sub directory in c9026cb3210205b07e2e068467a18ee40f9259a3
[mplayer/glamo.git] / DOCS / tech / realcodecs / video-codecs.txt
blobaf2152061a0bc96604ea59dcd82774e270e42261
1 The work has been based on the RV30 codec, but since RV20 has the same
2 interface, it might work for it as well.
7 error codes (the software uses redmond originated error codes)
9 1. internal code (1-10)
10 2. result
12 0    00000000 success
13 1    80004005 E_FAIL
14 2    8007000E E_OUTOFMEMORY
15 3,9  80004001 E_NOTIMPL
16 4,5  80070005 E_ACCESSDENIED
17 6    80004003 E_POINTER
18 7,10 80070057 E_INVALIDREG
19 8    80040FC1 (or 1FC?: CO_E_OBJISREG) - never occurred here
25 I think the only relevant file is the decoder drv[23].so.6.0
26 The rv[23]0 ones are just for streaming. We do this ourselves.
29 The codec consists of several functions. The relevant ones are:
31 RV20toYUV420Init()
32 RV20toYUV420Transform()
33 RV20toYUV420CustomMessage()
34 RV20toYUV420Free()
37 The others are irrelevant (seems to me). HiveMessage doesn't manipulate
38 anything and is only called in the beginning.
40 result=RV20toYUV420Init(struct init_data *, struct rvyuvMain **);
42 struct init_data {
43         short constant=0xb;
44         short width, height;
45         short 0, 0, 0;
46         ulong format1;
47         long  1;
48         ulong format2;
51 format1 and format2 are stored in the .rm file's stream headers.
52 (format1>>16)&3 seems to be a sub-codec id/selector, at least for rv30
53 it's the only difference between low and high bitrate files.
55 result=RV20toYUV420Transform(char *input_stream, char *output_data,
56         struct transin *, struct transout *, struct rvyuvMain *);
58 struct transin {
59         ulong length_of_input_data;
60         ulong null;
61         ulong num_sub_packets_in_block_minus_one;
62         ulong *sub_packets_list;
63         ulong another_null;
64         ulong timestamp_from_stream;
67 struct transout {
68         ulong flag1; // ((var_94&2!=0)&&(result==0))?1:0
69         ulong flag2; // 4 LBS from var_94
70         ulong zero;
71         ulong width, height;
74 The length of output_stream is 1.5*width*height (I420 planar yuv 4:2:0).
75 input_stream is the exact data from the data block for one frame.
77 sub_packets_list is a list of num_sub_packets pairs of long values, in form:
78 1, 0,
79 1, offset_2nd,
80 1, offset_3rd,
81 1, offset_4th,
82 ...
84 where offset_* are the offsets or sub-packets relative to input_stream.
87 result=RV20toYUV420CustomMessage(ulong *msg, struct rvyuvMain *);
89 Messages used by RV30:
91 A message is a triplet (cmd,val,ext) of ulong.
93 NOTE:
94 rv30 only requires the (0x24,2|3,{w,h,w,h}) message. others can be left out!
95 rv20 only requires the (0x11,2,0) message in rp8, before each transform call.
97 (3,2,0)
98 returns always(?) an error, since a global variable inside the codec
99 (which points to a function similar to custommessage), is always NULL
101 (0x11,0|1|2,0)
102 val=0|1: sets intern2 to val, when intern1 is non-zero
103          return 3 when intern1 is zero and val is 1
104          else returns 0
105 val=2:   return intern2
106 what does intern[1,2] mean?
108 (0x12,...)
109 used by rv20, function unknown, can be ignored
111 (0x1e,2|3,1)
112 calls a subroutine and returns the result, purpose has to be detemined
114 (0x24,subcodec,{...})
115 copies 4 dwords to rvyuvMain+07c: { width, height, 0, 0 }
116 subcodec must be 2 (low-bitrate) or 3 (high-bitrate) for rv30.
117 the codec type (low vs high) can be determined from 1+((format1>>16)&3)
118 for rv20, this call should be ignored! (makes codec crashing)
120 (0x1c,a,b) - called inside transform
121 to be analyzed
123 (105,...)
124 used by rv20, function unknown, can be ignored
127 structure of rvyuvMain:
128 -----------------------
130 DWORDS (the entries are not always constant)
131 there are two w/h pairs at 05C. the first is the size of the
132 unscaled video stream, the second possibly image size
134 000     1       6       3       1
135 010     1       0       AEBFC0D1(magic) 0
136 020     0       ptr->?  0       0
137 030     0       0       ->rvyuvMain+0x050       ?
138 040     width   height  0x17    0x479
139 050     ->rvyuvMain     0x17    0x17    width
140 060     height  width   height  0
141 070     0       1       0       0
142 080     0       0xb     w       h
143 090     w       h       0       0
144 0A0     1       0xb0(w?)        0x58    0x58
145 0B0     ptr->?  0       0       1
146 0C0     0x32    1       0       0
147 0D0     0       0       0       0
148 0E0     0       0       0       0
149 0F0     0       0       0       0
150 100     0       0       0       0
151 110     p       p       p       p p are pointers to several function, for
152 120     p       p       p       p example to the actual public functions
153 130     p       p       p       p (except init, the others are some kind of
154 140     p       p       p       p interfaces)
155 150     p       0       0       0
156 160     0       0x2000  1       0
157 170     0       0       0       0
158 180     1       1       0       0
159 190     0       0       0       0
160 1A0     0       0       0       0
161 1B0     1       0       ptr->?  ptr->?
162 1C0     1       0       0       0
163 1D0     0       0       0       0
164 1E0     0       0       0       0
170 Order of calls:
171 ---------------
173 Init
174 (0x11,0,0)
175 (0x24,2,{...})
178 (3,2,0)->80004001
179 (0x11,1,0)
180 (0x1e,3,1)
181 Transform (internally calls (0x1c,x,y))
182 (11,2,0)
185 Free