Mercurial > mplayer.hg
annotate libmpcodecs/native/roqav.c @ 11726:2caf85a35827
documented changes since pre3
author | alex |
---|---|
date | Fri, 02 Jan 2004 15:53:45 +0000 |
parents | 3cf6b963d08b |
children |
rev | line source |
---|---|
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
1 /* |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
2 RoQ A/V decoder for the MPlayer program |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
3 by Mike Melanson |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
4 based on Dr. Tim Ferguson's RoQ document and accompanying source |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
5 code found at: |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
6 http://www.csse.monash.edu.au/~timf/videocodec.html |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
7 */ |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
8 |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
9 #include <stdio.h> |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
10 #include <stdlib.h> |
6131
e6c8285a4bd8
memset and memcpy were used without #include <string.h> in a few places.
arpi
parents:
5684
diff
changeset
|
11 #include <string.h> |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
12 #include "config.h" |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
13 #include "bswap.h" |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
14 #include "mp_msg.h" |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
15 #include "mp_image.h" |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
16 |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
17 #define LE_16(x) (le2me_16(*(unsigned short *)(x))) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
18 #define LE_32(x) (le2me_32(*(unsigned int *)(x))) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
19 |
4486 | 20 #define CLAMP_S16(x) if (x < -32768) x = -32768; \ |
21 else if (x > 32767) x = 32767; | |
22 #define SE_16BIT(x) if (x & 0x8000) x -= 0x10000; | |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
23 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
24 // RoQ chunk types |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
25 #define RoQ_INFO 0x1001 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
26 #define RoQ_QUAD_CODEBOOK 0x1002 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
27 #define RoQ_QUAD_VQ 0x1011 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
28 #define RoQ_SOUND_MONO 0x1020 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
29 #define RoQ_SOUND_STEREO 0x1021 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
30 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
31 #define MAX_ROQ_CODEBOOK_SIZE 256 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
32 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
33 // codebook entry for 2x2 vector |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
34 typedef struct |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
35 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
36 // upper and lower luminance value pairs of 2x2 vector: [y0 y1], [y2 y3] |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
37 unsigned short v2_y_u; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
38 unsigned short v2_y_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
39 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
40 // chrominance components |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
41 unsigned char u, v; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
42 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
43 // these variables are for rendering a doublesized 8x8 block; e.g.: |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
44 // v2_y_rows12 = [y0 y0 y1 y1] |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
45 // v2_y_rows34 = [y2 y2 y3 y3] |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
46 unsigned long v2d_y_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
47 unsigned long v2d_y_rows_34; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
48 // ex: v2_u_row1 = [u u] |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
49 // v2_v_row2 = [v v] |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
50 unsigned short v2d_u_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
51 unsigned short v2d_v_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
52 |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
53 // maintain separate bytes for the luminance values as well |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
54 unsigned char y0, y1, y2, y3; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
55 } roq_v2_codebook; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
56 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
57 // codebook entry for 4x4 vector |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
58 typedef struct |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
59 { |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
60 unsigned char v2_index[4]; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
61 } roq_v4_codebook; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
62 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
63 typedef struct |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
64 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
65 roq_v2_codebook v2[MAX_ROQ_CODEBOOK_SIZE]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
66 roq_v4_codebook v4[MAX_ROQ_CODEBOOK_SIZE]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
67 mp_image_t *prev_frame; |
5684 | 68 uint32_t numframe; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
69 } roqvideo_info; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
70 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
71 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
72 // This function fills in the missing information for a v2 vector after |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
73 // loading the Y, U and V values. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
74 inline void prep_v2(roq_v2_codebook *v2) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
75 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
76 v2->v2_y_u = be2me_16((v2->y0 << 8) | v2->y1); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
77 v2->v2_y_l = be2me_16((v2->y2 << 8) | v2->y3); |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
78 |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
79 v2->v2d_y_rows_12 = be2me_32((v2->y0 << 24) | (v2->y0 << 16) | |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
80 (v2->y1 << 8) | v2->y1); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
81 v2->v2d_y_rows_34 = be2me_32((v2->y2 << 24) | (v2->y2 << 16) | |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
82 (v2->y3 << 8) | v2->y3); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
83 |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
84 // no reason to swap these for endianness since they're the same bytes |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
85 v2->v2d_u_rows_12 = (v2->u << 8) | v2->u; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
86 v2->v2d_v_rows_12 = (v2->v << 8) | v2->v; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
87 } |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
88 |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
89 inline void paint_v2double_block( |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
90 unsigned char *y_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
91 unsigned char *u_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
92 unsigned char *v_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
93 roq_v2_codebook *v2, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
94 unsigned int y_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
95 unsigned int u_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
96 unsigned int v_stride) |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
97 { |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
98 // render the luminance components |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
99 *(unsigned int *)y_plane = v2->v2d_y_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
100 y_plane += y_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
101 *(unsigned int *)y_plane = v2->v2d_y_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
102 y_plane += y_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
103 *(unsigned int *)y_plane = v2->v2d_y_rows_34; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
104 y_plane += y_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
105 *(unsigned int *)y_plane = v2->v2d_y_rows_34; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
106 |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
107 // render the color planes |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
108 *(unsigned short *)u_plane = v2->v2d_u_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
109 u_plane += u_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
110 *(unsigned short *)u_plane = v2->v2d_u_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
111 |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
112 *(unsigned short *)v_plane = v2->v2d_v_rows_12; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
113 v_plane += v_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
114 *(unsigned short *)v_plane = v2->v2d_v_rows_12; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
115 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
116 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
117 inline void paint_v4_block( |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
118 unsigned char *y_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
119 unsigned char *u_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
120 unsigned char *v_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
121 unsigned int y_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
122 unsigned int u_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
123 unsigned int v_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
124 roq_v2_codebook *v2_a, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
125 roq_v2_codebook *v2_b, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
126 roq_v2_codebook *v2_c, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
127 roq_v2_codebook *v2_d) |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
128 { |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
129 // render luminance components |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
130 ((unsigned short *)y_plane)[0] = v2_a->v2_y_u; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
131 ((unsigned short *)y_plane)[1] = v2_b->v2_y_u; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
132 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
133 y_plane += y_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
134 ((unsigned short *)y_plane)[0] = v2_a->v2_y_l; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
135 ((unsigned short *)y_plane)[1] = v2_b->v2_y_l; |
4486 | 136 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
137 y_plane += y_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
138 ((unsigned short *)y_plane)[0] = v2_c->v2_y_u; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
139 ((unsigned short *)y_plane)[1] = v2_d->v2_y_u; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
140 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
141 y_plane += y_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
142 ((unsigned short *)y_plane)[0] = v2_c->v2_y_l; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
143 ((unsigned short *)y_plane)[1] = v2_d->v2_y_l; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
144 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
145 // render the color planes |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
146 u_plane[0] = v2_a->u; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
147 u_plane[1] = v2_b->u; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
148 u_plane += u_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
149 u_plane[0] = v2_c->u; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
150 u_plane[1] = v2_d->u; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
151 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
152 v_plane[0] = v2_a->v; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
153 v_plane[1] = v2_b->v; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
154 v_plane += v_stride; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
155 v_plane[0] = v2_c->v; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
156 v_plane[1] = v2_d->v; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
157 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
158 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
159 // This function copies the 4x4 block from the prev_*_planes to the |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
160 // current *_planes. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
161 inline void copy_4x4_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
162 unsigned char *y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
163 unsigned char *u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
164 unsigned char *v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
165 unsigned char *prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
166 unsigned char *prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
167 unsigned char *prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
168 unsigned int y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
169 unsigned int u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
170 unsigned int v_stride) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
171 { |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
172 int i; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
173 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
174 // copy over the luminance components (4 rows, 1 uint each) |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
175 for (i = 0; i < 4; i++) |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
176 { |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
177 *(unsigned int *)y_plane = *(unsigned int *)prev_y_plane; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
178 y_plane += y_stride; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
179 prev_y_plane += y_stride; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
180 } |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
181 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
182 // copy the chrominance values |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
183 for (i = 0; i < 2; i++) |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
184 { |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
185 *(unsigned short*)u_plane = *(unsigned short*)prev_u_plane; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
186 u_plane += u_stride; |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
187 prev_u_plane += u_stride; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
188 *(unsigned short*)v_plane = *(unsigned short*)prev_v_plane; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
189 v_plane += v_stride; |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
190 prev_v_plane += v_stride; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
191 } |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
192 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
193 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
194 // This function copies the 8x8 block from the prev_*_planes to the |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
195 // current *_planes. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
196 inline void copy_8x8_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
197 unsigned char *y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
198 unsigned char *u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
199 unsigned char *v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
200 unsigned char *prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
201 unsigned char *prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
202 unsigned char *prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
203 unsigned int y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
204 unsigned int u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
205 unsigned int v_stride) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
206 { |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
207 int i; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
208 |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
209 // copy over the luminance components (8 rows, 2 uints each) |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
210 for (i = 0; i < 8; i++) |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
211 { |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
212 ((unsigned int *)y_plane)[0] = ((unsigned int *)prev_y_plane)[0]; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
213 ((unsigned int *)y_plane)[1] = ((unsigned int *)prev_y_plane)[1]; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
214 y_plane += y_stride; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
215 prev_y_plane += y_stride; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
216 } |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
217 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
218 // copy the chrominance values |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
219 for (i = 0; i < 4; i++) |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
220 { |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
221 *(unsigned int*)u_plane = *(unsigned int*)prev_u_plane; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
222 u_plane += u_stride; |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
223 prev_u_plane += u_stride; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
224 *(unsigned int*)v_plane = *(unsigned int*)prev_v_plane; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
225 v_plane += v_stride; |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
226 prev_v_plane += v_stride; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
227 } |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
228 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
229 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
230 // This function creates storage space for the vector codebooks. |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
231 void *roq_decode_video_init(void) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
232 { |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
233 roqvideo_info *info = |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
234 (roqvideo_info *)calloc(sizeof(roqvideo_info), 1); |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
235 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
236 info->prev_frame = NULL; |
5684 | 237 info->numframe=0; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
238 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
239 return info; |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
240 } |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
241 |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
242 #define EMPTY_ROQ_CODEWORD 0xFFFF0000 |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
243 |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
244 #define FETCH_NEXT_CODE() \ |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
245 if (current_roq_codeword == EMPTY_ROQ_CODEWORD) \ |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
246 { \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
247 if (stream_ptr + 2 > encoded_size) \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
248 { \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
249 mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
250 "RoQ video: stream pointer just went out of bounds (1)\n"); \ |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
251 return; \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
252 } \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
253 current_roq_codeword = (0x0000FFFF) | \ |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
254 (encoded[stream_ptr + 0] << 16) | \ |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
255 (encoded[stream_ptr + 1] << 24); \ |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
256 stream_ptr += 2; \ |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
257 } \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
258 roq_code = ((current_roq_codeword >> 30) & 0x03); \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
259 current_roq_codeword <<= 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
260 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
261 #define FETCH_NEXT_ARGUMENT() \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
262 if (stream_ptr + 1 > encoded_size) \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
263 { \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
264 mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
265 "RoQ video: stream pointer just went out of bounds (2)\n"); \ |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
266 return; \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
267 } \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
268 argument = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
269 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
270 #define CHECK_PREV_FRAME() \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
271 if (!info->prev_frame) \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
272 { \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
273 mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
274 "RoQ video: can't handle motion vector when there's no previous frame\n"); \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
275 return; \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
276 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
277 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
278 void roq_decode_video(void *context, unsigned char *encoded, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
279 int encoded_size, mp_image_t *mpi) |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
280 { |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
281 roqvideo_info *info = (roqvideo_info *)context; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
282 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
283 int stream_ptr = 0; |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
284 int i, j; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
285 int chunk_length; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
286 int v2_count; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
287 int v4_count; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
288 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
289 int roq_code; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
290 unsigned int current_roq_codeword = EMPTY_ROQ_CODEWORD; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
291 unsigned char argument = 0; |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
292 char mean_motion_x; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
293 char mean_motion_y; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
294 int mx, my; // for calculating the motion vector |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
295 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
296 int mblock_x = 0; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
297 int mblock_y = 0; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
298 int quad8_x, quad8_y; // for pointing to 8x8 blocks in a macroblock |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
299 int quad4_x, quad4_y; // for pointing to 4x4 blocks in an 8x8 block |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
300 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
301 unsigned char *y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
302 unsigned char *u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
303 unsigned char *v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
304 unsigned char *prev_y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
305 unsigned char *prev_u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
306 unsigned char *prev_v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
307 unsigned int y_stride = mpi->stride[0]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
308 unsigned int u_stride = mpi->stride[1]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
309 unsigned int v_stride = mpi->stride[2]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
310 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
311 roq_v4_codebook v4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
312 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
313 // make sure the encoded chunk is of minimal acceptable length |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
314 if (encoded_size < 8) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
315 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
316 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
317 "RoQ video: chunk isn't even 8 bytes long (minimum acceptable length)\n"); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
318 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
319 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
320 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
321 // make sure the resolution checks out |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
322 if ((mpi->width % 16 != 0) || (mpi->height % 16 != 0)) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
323 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
324 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
10717 | 325 "RoQ video resolution: %d x %d; expected dimensions divisible by 16\n", |
326 mpi->width, mpi->height); | |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
327 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
328 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
329 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
330 if (LE_16(&encoded[stream_ptr]) == RoQ_QUAD_CODEBOOK) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
331 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
332 stream_ptr += 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
333 chunk_length = LE_32(&encoded[stream_ptr]); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
334 stream_ptr += 4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
335 v4_count = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
336 v2_count = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
337 if (v2_count == 0) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
338 v2_count = 256; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
339 if ((v4_count == 0) && (v2_count * 6 < chunk_length)) |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
340 v4_count = 256; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
341 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
342 // make sure the lengths agree with each other |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
343 if (((v2_count * 6) + (v4_count * 4)) != chunk_length) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
344 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
345 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
346 "RoQ video: encountered quad codebook chunk with weird lengths (1)\n"); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
347 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
348 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
349 if ((v2_count * 6) > (encoded_size - stream_ptr)) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
350 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
351 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
352 "RoQ video: encountered quad codebook chunk with weird lengths (2)\n"); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
353 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
354 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
355 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
356 // load the 2x2 vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
357 for (i = 0; i < v2_count; i++) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
358 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
359 info->v2[i].y0 = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
360 info->v2[i].y1 = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
361 info->v2[i].y2 = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
362 info->v2[i].y3 = encoded[stream_ptr++]; |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
363 info->v2[i].u = encoded[stream_ptr++]; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
364 info->v2[i].v = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
365 prep_v2(&info->v2[i]); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
366 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
367 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
368 if ((v4_count * 4) > (encoded_size - stream_ptr)) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
369 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
370 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
371 "RoQ video: encountered quad codebook chunk with weird lengths (3)\n"); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
372 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
373 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
374 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
375 // load the 4x4 vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
376 for (i = 0; i < v4_count; i++) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
377 { |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
378 info->v4[i].v2_index[0] = encoded[stream_ptr++]; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
379 info->v4[i].v2_index[1] = encoded[stream_ptr++]; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
380 info->v4[i].v2_index[2] = encoded[stream_ptr++]; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
381 info->v4[i].v2_index[3] = encoded[stream_ptr++]; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
382 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
383 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
384 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
385 if (LE_16(&encoded[stream_ptr]) == RoQ_QUAD_VQ) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
386 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
387 stream_ptr += 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
388 chunk_length = LE_32(&encoded[stream_ptr]); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
389 stream_ptr += 4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
390 mean_motion_y = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
391 mean_motion_x = encoded[stream_ptr++]; |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
392 |
5684 | 393 //RoQ reuses its buffers so a transparent block keeps content |
394 //from 2 frames ago. The only exception is 2'd frame (#1) | |
395 if(info->numframe==1) | |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
396 { |
5684 | 397 CHECK_PREV_FRAME(); |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
398 memcpy(mpi->planes[0], info->prev_frame->planes[0], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
399 mpi->width * mpi->height); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
400 memcpy(mpi->planes[1], info->prev_frame->planes[1], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
401 (mpi->width * mpi->height) / 4); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
402 memcpy(mpi->planes[2], info->prev_frame->planes[2], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
403 (mpi->width * mpi->height) / 4); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
404 } |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
405 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
406 // iterate through the 16x16 macroblocks |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
407 for (mblock_y = 0; mblock_y < mpi->height; mblock_y += 16) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
408 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
409 for (mblock_x = 0; mblock_x < mpi->width; mblock_x += 16) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
410 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
411 // iterate through the 4 quadrants of the macroblock |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
412 for (i = 0; i < 4; i++) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
413 { |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
414 quad8_x = mblock_x; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
415 quad8_y = mblock_y; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
416 if (i & 0x01) quad8_x += 8; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
417 if (i & 0x02) quad8_y += 8; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
418 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
419 // set up the planes |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
420 y_plane = mpi->planes[0] + quad8_y * y_stride + quad8_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
421 u_plane = mpi->planes[1] + (quad8_y / 2) * u_stride + (quad8_x / 2); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
422 v_plane = mpi->planes[2] + (quad8_y / 2) * v_stride + (quad8_x / 2); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
423 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
424 // decide how to handle this 8x8 quad |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
425 FETCH_NEXT_CODE(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
426 switch(roq_code) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
427 { |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
428 // 8x8 block is the same as in the previous frame; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
429 // skip it |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
430 case 0: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
431 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
432 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
433 // 8x8 block is painted with an 8x8 block from the last frame |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
434 // (i.e., motion compensation) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
435 case 1: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
436 CHECK_PREV_FRAME(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
437 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
438 // prepare the pointers to the planes in the previous frame |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
439 FETCH_NEXT_ARGUMENT(); // argument contains motion vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
440 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
441 // figure out the motion vectors |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
442 mx = quad8_x + 8 - (argument >> 4) - mean_motion_x; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
443 my = quad8_y + 8 - (argument & 0x0F) - mean_motion_y; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
444 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
445 prev_y_plane = info->prev_frame->planes[0] + |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
446 my * y_stride + mx; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
447 prev_u_plane = info->prev_frame->planes[1] + |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
448 (my / 2) * u_stride + (mx + 1) / 2; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
449 prev_v_plane = info->prev_frame->planes[2] + |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
450 (my / 2) * v_stride + (mx + 1) / 2; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
451 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
452 // sanity check before rendering |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
453 copy_8x8_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
454 y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
455 u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
456 v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
457 prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
458 prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
459 prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
460 y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
461 u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
462 v_stride |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
463 ); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
464 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
465 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
466 // 8x8 block is painted with a doublesized 4x4 vector |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
467 case 2: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
468 FETCH_NEXT_ARGUMENT(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
469 v4 = info->v4[argument]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
470 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
471 // sanity check before rendering |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
472 // iterate through 4 4x4 blocks |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
473 for (j = 0; j < 4; j++) |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
474 { |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
475 quad4_x = quad8_x; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
476 quad4_y = quad8_y; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
477 if (j & 0x01) quad4_x += 4; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
478 if (j & 0x02) quad4_y += 4; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
479 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
480 // set up the planes |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
481 y_plane = mpi->planes[0] + quad4_y * y_stride + quad4_x; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
482 u_plane = mpi->planes[1] + |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
483 (quad4_y / 2) * u_stride + (quad4_x / 2); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
484 v_plane = mpi->planes[2] + |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
485 (quad4_y / 2) * v_stride + (quad4_x / 2); |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
486 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
487 paint_v2double_block( |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
488 y_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
489 u_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
490 v_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
491 &info->v2[v4.v2_index[j]], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
492 y_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
493 u_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
494 v_stride |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
495 ); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
496 } |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
497 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
498 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
499 // 8x8 block is broken down into 4 4x4 blocks and painted using |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
500 // 4 different codes. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
501 case 3: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
502 // iterate through 4 4x4 blocks |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
503 for (j = 0; j < 4; j++) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
504 { |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
505 quad4_x = quad8_x; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
506 quad4_y = quad8_y; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
507 if (j & 0x01) quad4_x += 4; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
508 if (j & 0x02) quad4_y += 4; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
509 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
510 // set up the planes |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
511 y_plane = mpi->planes[0] + quad4_y * y_stride + quad4_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
512 u_plane = mpi->planes[1] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
513 (quad4_y / 2) * u_stride + (quad4_x / 2); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
514 v_plane = mpi->planes[2] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
515 (quad4_y / 2) * v_stride + (quad4_x / 2); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
516 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
517 // decide how to handle this 4x4 quad |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
518 FETCH_NEXT_CODE(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
519 switch(roq_code) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
520 { |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
521 // 4x4 block is the same as in the previous frame; |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
522 // skip it |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
523 case 0: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
524 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
525 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
526 // 4x4 block is motion compensated from the previous frame |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
527 case 1: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
528 CHECK_PREV_FRAME(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
529 // prepare the pointers to the planes in the previous frame |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
530 FETCH_NEXT_ARGUMENT(); // argument contains motion vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
531 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
532 // figure out the motion vectors |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
533 mx = quad4_x + 8 - (argument >> 4) - mean_motion_x; |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
534 my = quad4_y + 8 - (argument & 0x0F) - mean_motion_y; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
535 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
536 prev_y_plane = info->prev_frame->planes[0] + |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
537 my * y_stride + mx; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
538 prev_u_plane = info->prev_frame->planes[1] + |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
539 (my / 2) * u_stride + (mx + 1) / 2; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
540 prev_v_plane = info->prev_frame->planes[2] + |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
541 (my / 2) * u_stride + (mx + 1) / 2; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
542 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
543 // sanity check before rendering |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
544 copy_4x4_block( |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
545 y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
546 u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
547 v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
548 prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
549 prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
550 prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
551 y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
552 u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
553 v_stride |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
554 ); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
555 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
556 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
557 // 4x4 block is copied directly from v4 vector table |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
558 case 2: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
559 FETCH_NEXT_ARGUMENT(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
560 v4 = info->v4[argument]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
561 |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
562 paint_v4_block( |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
563 y_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
564 u_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
565 v_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
566 y_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
567 u_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
568 v_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
569 &info->v2[v4.v2_index[0]], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
570 &info->v2[v4.v2_index[1]], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
571 &info->v2[v4.v2_index[2]], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
572 &info->v2[v4.v2_index[3]]); |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
573 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
574 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
575 // 4x4 block is built from 4 2x2 vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
576 case 3: |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
577 if (stream_ptr + 4 > encoded_size) |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
578 { |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
579 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
580 "RoQ video: stream pointer just went out of bounds (2)\n"); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
581 return; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
582 } |
5182
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
583 paint_v4_block( |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
584 y_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
585 u_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
586 v_plane, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
587 y_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
588 u_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
589 v_stride, |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
590 &info->v2[encoded[stream_ptr + 0]], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
591 &info->v2[encoded[stream_ptr + 1]], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
592 &info->v2[encoded[stream_ptr + 2]], |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
593 &info->v2[encoded[stream_ptr + 3]]); |
11f440fa5ee9
the RoQ video decoder is so very close to working, I can almost taste it
melanson
parents:
5079
diff
changeset
|
594 stream_ptr += 4; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
595 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
596 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
597 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
598 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
599 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
600 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
601 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
602 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
603 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
604 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
605 // one last sanity check on the way out |
5079
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
606 // (apparently, it's not unusual to have 2 bytes left over after decode) |
6cba3ca983b5
RoQ video decoder is much closer to being categorized as "working" (there
melanson
parents:
4936
diff
changeset
|
607 if (stream_ptr < encoded_size - 2) |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
608 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
609 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
610 "RoQ video: completed frame decode with bytes left over (%d < %d)\n", |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
611 stream_ptr, encoded_size); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
612 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
613 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
614 // save the current frame as the previous frame for the next iteration |
5684 | 615 info->numframe++; |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
616 info->prev_frame = mpi; |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
617 } |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
618 |
4486 | 619 // Initialize the RoQ audio decoder, which is to say, initialize the table |
620 // of squares. | |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
621 void *roq_decode_audio_init(void) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
622 { |
4486 | 623 short *square_array; |
624 short square; | |
625 int i; | |
626 | |
627 square_array = (short *)malloc(256 * sizeof(short)); | |
628 if (!square_array) | |
629 return NULL; | |
630 | |
631 for (i = 0; i < 128; i++) | |
632 { | |
633 square = i * i; | |
634 square_array[i] = square; | |
635 square_array[i + 128] = -square; | |
636 } | |
637 | |
638 return square_array; | |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
639 } |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
640 |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
641 int roq_decode_audio( |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
642 unsigned short *output, |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
643 unsigned char *input, |
4486 | 644 int encoded_size, |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
645 int channels, |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
646 void *context) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
647 { |
4486 | 648 short *square_array = (short *)context; |
649 int i; | |
650 int predictor[2]; | |
651 int channel_number = 0; | |
652 | |
653 // prepare the initial predictors | |
654 if (channels == 1) | |
655 predictor[0] = LE_16(&input[0]); | |
656 else | |
657 { | |
658 predictor[0] = input[1] << 8; | |
659 predictor[1] = input[0] << 8; | |
660 } | |
661 SE_16BIT(predictor[0]); | |
662 SE_16BIT(predictor[1]); | |
663 | |
664 // decode the samples | |
665 for (i = 2; i < encoded_size; i++) | |
666 { | |
667 predictor[channel_number] += square_array[input[i]]; | |
668 CLAMP_S16(predictor[channel_number]); | |
669 output[i - 2] = predictor[channel_number]; | |
670 | |
671 // toggle channel | |
672 channel_number ^= channels - 1; | |
673 } | |
674 | |
675 // return the number of samples decoded | |
676 return (encoded_size - 2); | |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
677 } |