Mercurial > mplayer.hg
annotate roqav.c @ 5011:d53725339d5d
postprocess.h requires for GET_PP_QUALITY_MAX - patch by Fredrik Kuivinen
author | arpi |
---|---|
date | Sun, 10 Mar 2002 01:38:21 +0000 |
parents | 026329111b09 |
children | 6cba3ca983b5 |
rev | line source |
---|---|
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
1 /* |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
2 RoQ A/V decoder for the MPlayer program |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
3 by Mike Melanson |
4486 | 4 based on Dr. Tim Ferguson's RoQ document and accompanying source |
5 code found at: | |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
6 http://www.csse.monash.edu.au/~timf/videocodec.html |
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> |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
11 #include "config.h" |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
12 #include "bswap.h" |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
13 #include "mp_msg.h" |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
14 #include "mp_image.h" |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
15 |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
16 #define LE_16(x) (le2me_16(*(unsigned short *)(x))) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
17 #define LE_32(x) (le2me_32(*(unsigned int *)(x))) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
18 |
4486 | 19 #define CLAMP_S16(x) if (x < -32768) x = -32768; \ |
20 else if (x > 32767) x = 32767; | |
21 #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
|
22 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
23 // RoQ chunk types |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
24 #define RoQ_INFO 0x1001 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
25 #define RoQ_QUAD_CODEBOOK 0x1002 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
26 #define RoQ_QUAD_VQ 0x1011 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
27 #define RoQ_SOUND_MONO 0x1020 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
28 #define RoQ_SOUND_STEREO 0x1021 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
29 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
30 #define MAX_ROQ_CODEBOOK_SIZE 256 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
31 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
32 // codebook entry for 2x2 vector |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
33 typedef struct |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
34 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
35 // 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
|
36 unsigned short v2_y_u; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
37 unsigned short v2_y_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
38 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
39 // chrominance components |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
40 unsigned char u, v; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
41 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
42 // 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
|
43 unsigned char y0, y1, y2, y3; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
44 } roq_v2_codebook; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
45 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
46 // codebook entry for 4x4 vector |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
47 typedef struct |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
48 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
49 // these variables are for rendering a 4x4 block built from 4 2x2 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
50 // vectors [va vb vc vd]; e.g.: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
51 // v4_y_row1 = [va.y0 va.y1 vb.y0 vb.y1] |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
52 // v4_y_row4 = [vc.y2 vc.y3 vd.y2 vd.y3] |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
53 unsigned long v4_y_row1; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
54 unsigned long v4_y_row2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
55 unsigned long v4_y_row3; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
56 unsigned long v4_y_row4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
57 // ex: v4_u_row1 = [va.u vb.u] |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
58 // v4_u_row2 = [vc.u vd.u] |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
59 unsigned short v4_u_row1; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
60 unsigned short v4_u_row2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
61 unsigned short v4_v_row1; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
62 unsigned short v4_v_row2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
63 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
64 // these variables are for rendering a 4x4 block doublesized to an |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
65 // 8x8 block |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
66 // ex: v4d_y_rows_12_l contains the 4 luminance values used to paint |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
67 // the left half (4 pixels) of rows 1 and 2 of the 8x8 block, which |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
68 // will be comprised from the original 2x2 vectors as |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
69 // [va.y0 va.y0 va.y1 va.y1] |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
70 unsigned long v4d_y_rows_12_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
71 unsigned long v4d_y_rows_12_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
72 unsigned long v4d_y_rows_34_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
73 unsigned long v4d_y_rows_34_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
74 unsigned long v4d_y_rows_56_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
75 unsigned long v4d_y_rows_56_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
76 unsigned long v4d_y_rows_78_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
77 unsigned long v4d_y_rows_78_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
78 // doublesized chrominance values |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
79 // ex: v4d_u_rows_12 = [va.u va.u vb.u vb.u] |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
80 unsigned long v4d_u_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
81 unsigned long v4d_u_rows_34; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
82 unsigned long v4d_v_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
83 unsigned long v4d_v_rows_34; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
84 } roq_v4_codebook; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
85 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
86 typedef struct |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
87 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
88 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
|
89 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
|
90 mp_image_t *prev_frame; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
91 } roqvideo_info; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
92 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
93 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
94 // 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
|
95 // 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
|
96 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
|
97 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
98 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
|
99 v2->v2_y_l = be2me_16((v2->y2 << 8) | v2->y3); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
100 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
101 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
102 // This function fills in the missing information for a v4 vector based |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
103 // on 4 v2 indices. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
104 void prep_v4(roq_v4_codebook *v4, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
105 roq_v2_codebook *v2_a, roq_v2_codebook *v2_b, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
106 roq_v2_codebook *v2_c, roq_v2_codebook *v2_d) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
107 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
108 // fill in the v4 variables |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
109 v4->v4_y_row1 = be2me_32((v2_a->v2_y_u << 16) | v2_b->v2_y_u); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
110 v4->v4_y_row2 = be2me_32((v2_a->v2_y_l << 16) | v2_b->v2_y_l); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
111 v4->v4_y_row3 = be2me_32((v2_c->v2_y_u << 16) | v2_d->v2_y_u); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
112 v4->v4_y_row4 = be2me_32((v2_c->v2_y_l << 16) | v2_d->v2_y_l); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
113 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
114 v4->v4_u_row1 = be2me_16((v2_a->u << 8) | v2_b->u); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
115 v4->v4_u_row2 = be2me_16((v2_c->u << 8) | v2_d->u); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
116 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
117 v4->v4_v_row1 = be2me_16((v2_a->v << 8) | v2_b->v); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
118 v4->v4_v_row2 = be2me_16((v2_c->v << 8) | v2_d->v); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
119 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
120 // fill in the doublesized v4 variables |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
121 v4->v4d_y_rows_12_l = be2me_32((v2_a->y0 << 24) | (v2_a->y0 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
122 (v2_a->y1 << 8) | v2_a->y1); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
123 v4->v4d_y_rows_12_r = be2me_32((v2_b->y0 << 24) | (v2_b->y0 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
124 (v2_b->y1 << 8) | v2_b->y1); |
4486 | 125 |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
126 v4->v4d_y_rows_34_l = be2me_32((v2_a->y2 << 24) | (v2_a->y2 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
127 (v2_a->y3 << 8) | v2_a->y3); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
128 v4->v4d_y_rows_34_r = be2me_32((v2_b->y2 << 24) | (v2_b->y2 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
129 (v2_b->y3 << 8) | v2_b->y3); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
130 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
131 v4->v4d_y_rows_56_l = be2me_32((v2_c->y0 << 24) | (v2_c->y0 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
132 (v2_c->y1 << 8) | v2_c->y1); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
133 v4->v4d_y_rows_56_r = be2me_32((v2_d->y0 << 24) | (v2_d->y0 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
134 (v2_d->y1 << 8) | v2_d->y1); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
135 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
136 v4->v4d_y_rows_78_l = be2me_32((v2_c->y2 << 24) | (v2_c->y2 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
137 (v2_d->y3 << 8) | v2_d->y3); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
138 v4->v4d_y_rows_78_r = be2me_32((v2_c->y2 << 24) | (v2_c->y2 << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
139 (v2_d->y3 << 8) | v2_d->y3); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
140 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
141 v4->v4d_u_rows_12 = be2me_32((v2_a->u << 24) | (v2_a->u << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
142 (v2_b->u << 8) | v2_b->u); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
143 v4->v4d_u_rows_34 = be2me_32((v2_c->u << 24) | (v2_c->u << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
144 (v2_d->u << 8) | v2_d->u); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
145 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
146 v4->v4d_v_rows_12 = be2me_32((v2_a->v << 24) | (v2_a->v << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
147 (v2_b->v << 8) | v2_b->v); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
148 v4->v4d_v_rows_34 = be2me_32((v2_c->v << 24) | (v2_c->v << 16) | |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
149 (v2_d->v << 8) | v2_d->v); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
150 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
151 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
152 // 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
|
153 // current *_planes. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
154 inline void copy_4x4_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
155 unsigned char *y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
156 unsigned char *u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
157 unsigned char *v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
158 unsigned char *prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
159 unsigned char *prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
160 unsigned char *prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
161 unsigned int y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
162 unsigned int u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
163 unsigned int v_stride) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
164 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
165 // copy over the luminance components |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
166 *(unsigned int *)y_plane = *(unsigned int *)prev_y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
167 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
168 prev_y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
169 *(unsigned int *)y_plane = *(unsigned int *)prev_y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
170 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
171 prev_y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
172 *(unsigned int *)y_plane = *(unsigned int *)prev_y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
173 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
174 prev_y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
175 *(unsigned int *)y_plane = *(unsigned int *)prev_y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
176 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
177 // copy the chrominance values |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
178 *(unsigned short*)u_plane = *(unsigned short*)prev_u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
179 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
180 *(unsigned short*)u_plane = *(unsigned short*)prev_u_plane; |
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 *(unsigned short*)v_plane = *(unsigned short*)prev_v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
183 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
184 *(unsigned short*)v_plane = *(unsigned short*)prev_v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
185 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
186 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
187 // 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
|
188 // current *_planes. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
189 inline void copy_8x8_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
190 unsigned char *y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
191 unsigned char *u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
192 unsigned char *v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
193 unsigned char *prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
194 unsigned char *prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
195 unsigned char *prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
196 unsigned int y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
197 unsigned int u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
198 unsigned int v_stride) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
199 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
200 // copy over the luminance components |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
201 ((unsigned int *)y_plane)[0] = ((unsigned int *)prev_y_plane)[0]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
202 ((unsigned int *)y_plane)[1] = ((unsigned int *)prev_y_plane)[1]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
203 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
204 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
205 prev_y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
206 ((unsigned int *)y_plane)[0] = ((unsigned int *)prev_y_plane)[0]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
207 ((unsigned int *)y_plane)[1] = ((unsigned int *)prev_y_plane)[1]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
208 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
209 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
210 prev_y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
211 ((unsigned int *)y_plane)[0] = ((unsigned int *)prev_y_plane)[0]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
212 ((unsigned int *)y_plane)[1] = ((unsigned int *)prev_y_plane)[1]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
213 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
214 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
215 prev_y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
216 ((unsigned int *)y_plane)[0] = ((unsigned int *)prev_y_plane)[0]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
217 ((unsigned int *)y_plane)[1] = ((unsigned int *)prev_y_plane)[1]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
218 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
219 // copy the chrominance values |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
220 *(unsigned int*)u_plane = *(unsigned int*)prev_u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
221 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
222 *(unsigned int*)u_plane = *(unsigned int*)prev_u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
223 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
224 *(unsigned int*)u_plane = *(unsigned int*)prev_u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
225 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
226 *(unsigned int*)u_plane = *(unsigned int*)prev_u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
227 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
228 *(unsigned int*)v_plane = *(unsigned int*)prev_v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
229 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
230 *(unsigned int*)v_plane = *(unsigned int*)prev_v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
231 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
232 *(unsigned int*)v_plane = *(unsigned int*)prev_v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
233 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
234 *(unsigned int*)v_plane = *(unsigned int*)prev_v_plane; |
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 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
237 // 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
|
238 void *roq_decode_video_init(void) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
239 { |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
240 roqvideo_info *info = |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
241 (roqvideo_info *)malloc(sizeof(roqvideo_info)); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
242 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
243 info->prev_frame = NULL; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
244 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
245 return info; |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
246 } |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
247 |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
248 #define FETCH_NEXT_CODE() \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
249 if (current_roq_codeword == 0xFFFF0000) \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
250 { \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
251 if (stream_ptr + 2 > encoded_size) \ |
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 mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
254 "RoQ video: stream pointer just went out of bounds\n"); \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
255 return; \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
256 } \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
257 current_roq_codeword = (0x0000FFFF) | \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
258 (encoded[stream_ptr++] << 16) | \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
259 (encoded[stream_ptr++] << 24); \ |
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 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
|
262 current_roq_codeword <<= 2; |
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 //printf (" %d\n", roq_code); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
265 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
266 #define FETCH_NEXT_ARGUMENT() \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
267 if (stream_ptr + 1 > encoded_size) \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
268 { \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
269 mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
270 "RoQ video: stream pointer just went out of bounds\n"); \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
271 return; \ |
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 argument = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
274 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
275 #define CHECK_PREV_FRAME() \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
276 if (!info->prev_frame) \ |
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 mp_msg(MSGT_DECVIDEO, MSGL_WARN, \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
279 "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
|
280 return; \ |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
281 } |
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 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
284 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
|
285 int encoded_size, mp_image_t *mpi) |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
286 { |
4936
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
287 roqvideo_info *info = (roqvideo_info *)context; |
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 stream_ptr = 0; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
290 int i, j, k; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
291 int chunk_length; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
292 int v2_count; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
293 int v4_count; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
294 int v2_ia, v2_ib, v2_ic, v2_id; |
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 roq_code; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
297 unsigned int current_roq_codeword = 0xFFFF0000; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
298 unsigned char argument = 0; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
299 int mean_motion_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
300 int mean_motion_y; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
301 int dx_y, dy_y; // for calculating the motion vector |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
302 int dx_c, dy_c; // motion vector for chrominance components |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
303 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
304 int mblock_x = 0; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
305 int mblock_y = 0; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
306 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
|
307 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
|
308 int quad2_x, quad2_y; // for pointing to 2x2 blocks in a 4x4 block |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
309 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
310 unsigned char *y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
311 unsigned char *u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
312 unsigned char *v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
313 unsigned char *prev_y_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
314 unsigned char *prev_u_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
315 unsigned char *prev_v_plane; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
320 roq_v4_codebook v4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
321 roq_v2_codebook v2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
322 |
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 static int counter = 0; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
325 //printf ("frame %d\n", counter++); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
326 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
327 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
328 // 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
|
329 if (encoded_size < 8) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
330 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
331 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
332 "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
|
333 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
334 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
335 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
336 // make sure the resolution checks out |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
337 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
|
338 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
339 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
340 "RoQ video resolution: %d x %d; expected dimensions divisible by 16\n"); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
341 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
342 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
343 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
344 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
|
345 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
346 printf ("parsing codebook\n"); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
347 stream_ptr += 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
348 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
|
349 stream_ptr += 4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
350 v4_count = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
351 if (v4_count == 0) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
352 v4_count = 256; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
353 v2_count = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
354 if (v2_count == 0) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
355 v2_count = 256; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
356 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
357 // 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
|
358 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
|
359 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
360 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
361 "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
|
362 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
363 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
364 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
|
365 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
366 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
367 "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
|
368 return; |
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 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
371 // load the 2x2 vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
372 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
|
373 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
374 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
|
375 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
|
376 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
|
377 info->v2[i].y3 = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
378 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
|
379 info->v2[i].u = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
380 prep_v2(&info->v2[i]); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
381 } |
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 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
|
384 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
385 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
386 "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
|
387 return; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
388 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
389 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
390 // load the 4x4 vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
391 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
|
392 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
393 v2_ia = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
394 v2_ib = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
395 v2_ic = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
396 v2_id = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
397 prep_v4(&info->v4[i], &info->v2[v2_ia], &info->v2[v2_ib], |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
398 &info->v2[v2_ic], &info->v2[v2_id]); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
399 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
400 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
401 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
402 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
|
403 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
404 printf ("parsing quad vq\n"); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
405 stream_ptr += 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
406 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
|
407 stream_ptr += 4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
408 mean_motion_y = encoded[stream_ptr++]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
409 mean_motion_x = encoded[stream_ptr++]; |
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 16x16 macroblocks |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
412 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
|
413 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
414 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
|
415 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
416 quad8_x = mblock_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
417 quad8_y = mblock_y; |
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 // 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
|
420 for (i = 0; i < 4; i++) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
421 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
422 if (quad8_x & 8) |
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 quad8_x -= 8; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
425 quad8_y += 8; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
426 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
427 else |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
428 quad8_x += 8; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
429 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
430 // set up the planes |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
431 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
|
432 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
|
433 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
|
434 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
435 // 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
|
436 FETCH_NEXT_CODE(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
437 switch(roq_code) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
438 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
439 // 8x8 block is painted with the same block as the last frame |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
440 case 0: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
441 CHECK_PREV_FRAME(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
442 // 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
|
443 prev_y_plane = info->prev_frame->planes[0] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
444 quad8_y * y_stride + quad8_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
445 prev_u_plane = info->prev_frame->planes[1] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
446 (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
|
447 prev_v_plane = info->prev_frame->planes[2] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
448 (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
|
449 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
450 // sanity check before rendering |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
451 copy_8x8_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
452 y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
453 u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
454 v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
455 prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
456 prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
457 prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
458 y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
459 u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
460 v_stride |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
461 ); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
462 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
463 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
464 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
465 // 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
|
466 // (i.e., motion compensation) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
467 case 1: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
468 CHECK_PREV_FRAME(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
469 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
470 // 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
|
471 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
|
472 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
473 // figure out the motion vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
474 dx_y = quad8_x + 8 - (argument >> 4) - mean_motion_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
475 dy_y = quad8_y + 8 - (argument & 0x0F) - mean_motion_y; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
476 dx_c = (quad8_x + 8) / 2 - (argument >> 4) - mean_motion_x / 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
477 dy_c = (quad8_y + 8) / 2 - (argument & 0x0F) - mean_motion_y / 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
478 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
479 prev_y_plane = info->prev_frame->planes[0] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
480 dy_y * y_stride + dx_y; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
481 prev_u_plane = info->prev_frame->planes[1] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
482 dy_c * u_stride + dx_c; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
483 prev_v_plane = info->prev_frame->planes[2] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
484 dy_c * v_stride + dx_c; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
485 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
486 // sanity check before rendering |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
487 copy_8x8_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
488 y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
489 u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
490 v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
491 prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
492 prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
493 prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
494 y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
495 u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
496 v_stride |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
497 ); |
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 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
500 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
501 // 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
|
502 case 2: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
503 FETCH_NEXT_ARGUMENT(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
504 v4 = info->v4[argument]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
505 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
506 // sanity check before rendering |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
507 // take care of the 8 luminance rows |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
508 ((unsigned int*)y_plane)[0] = v4.v4d_y_rows_12_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
509 ((unsigned int*)y_plane)[1] = v4.v4d_y_rows_12_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
510 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
511 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
512 ((unsigned int*)y_plane)[0] = v4.v4d_y_rows_34_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
513 ((unsigned int*)y_plane)[1] = v4.v4d_y_rows_34_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
514 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
515 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
516 ((unsigned int*)y_plane)[0] = v4.v4d_y_rows_56_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
517 ((unsigned int*)y_plane)[1] = v4.v4d_y_rows_56_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
518 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
519 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
520 ((unsigned int*)y_plane)[0] = v4.v4d_y_rows_78_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
521 ((unsigned int*)y_plane)[1] = v4.v4d_y_rows_78_r; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
522 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
523 // then the 4 U & V chrominance rows |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
524 *(unsigned int*)u_plane = v4.v4d_u_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
525 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
526 *(unsigned int*)u_plane = v4.v4d_u_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
527 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
528 *(unsigned int*)u_plane = v4.v4d_u_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
529 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
530 *(unsigned int*)u_plane = v4.v4d_u_rows_12; |
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 *(unsigned int*)v_plane = v4.v4d_v_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
533 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
534 *(unsigned int*)v_plane = v4.v4d_v_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
535 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
536 *(unsigned int*)v_plane = v4.v4d_v_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
537 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
538 *(unsigned int*)v_plane = v4.v4d_v_rows_12; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
539 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
540 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
541 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
542 // 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
|
543 // 4 different codes. |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
544 case 3: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
545 quad4_x = quad8_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
546 quad4_y = quad8_y; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
547 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
548 // iterate through 4 4x4 blocks |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
549 for (j = 0; j < 4; j++) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
550 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
551 if (quad4_x & 4) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
552 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
553 quad4_x -= 4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
554 quad4_y += 4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
555 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
556 else |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
557 quad4_x += 4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
558 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
559 // set up the planes |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
560 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
|
561 u_plane = mpi->planes[1] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
562 (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
|
563 v_plane = mpi->planes[2] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
564 (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
|
565 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
566 // 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
|
567 FETCH_NEXT_CODE(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
568 switch(roq_code) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
569 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
570 // 4x4 block is the same as in the previous frame |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
571 case 0: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
572 CHECK_PREV_FRAME(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
573 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
574 // 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
|
575 prev_y_plane = info->prev_frame->planes[0] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
576 quad4_y * y_stride + quad4_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
577 prev_u_plane = info->prev_frame->planes[1] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
578 (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
|
579 prev_v_plane = info->prev_frame->planes[2] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
580 (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
|
581 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
582 // sanity check before rendering |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
583 copy_4x4_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
584 y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
585 u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
586 v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
587 prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
588 prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
589 prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
590 y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
591 u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
592 v_stride |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
593 ); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
594 |
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 // 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
|
598 case 1: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
599 CHECK_PREV_FRAME(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
600 // 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
|
601 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
|
602 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
603 // figure out the motion vectors |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
604 dx_y = quad4_x + 4 - (argument >> 4) - mean_motion_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
605 dy_y = quad4_y + 4 - (argument & 0x0F) - mean_motion_y; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
606 dx_c = (quad4_x + 4) / 2 - (argument >> 4) - |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
607 mean_motion_x / 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
608 dy_c = (quad4_y + 4) / 2 - (argument & 0x0F) - |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
609 mean_motion_y / 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
610 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
611 prev_y_plane = info->prev_frame->planes[0] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
612 dy_y * y_stride + dx_y; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
613 prev_u_plane = info->prev_frame->planes[1] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
614 dy_c * u_stride + dx_c; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
615 prev_v_plane = info->prev_frame->planes[2] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
616 dy_c * v_stride + dx_c; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
617 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
618 // sanity check before rendering |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
619 copy_8x8_block( |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
620 y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
621 u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
622 v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
623 prev_y_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
624 prev_u_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
625 prev_v_plane, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
626 y_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
627 u_stride, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
628 v_stride |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
629 ); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
630 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
631 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
632 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
633 // 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
|
634 case 2: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
635 FETCH_NEXT_ARGUMENT(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
636 v4 = info->v4[argument]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
637 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
638 // copy the 4 luminance rows |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
639 *(unsigned int*)y_plane = v4.v4_y_row1; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
640 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
641 *(unsigned int*)y_plane = v4.v4_y_row2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
642 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
643 *(unsigned int*)y_plane = v4.v4_y_row3; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
644 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
645 *(unsigned int*)y_plane = v4.v4_y_row4; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
646 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
647 // copy the U & V chrominance rows |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
648 *(unsigned short*)u_plane = v4.v4_u_row1; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
649 u_plane += u_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
650 *(unsigned short*)u_plane = v4.v4_u_row2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
651 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
652 *(unsigned short*)v_plane = v4.v4_v_row1; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
653 v_plane += v_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
654 *(unsigned short*)v_plane = v4.v4_v_row2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
655 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
656 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
657 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
658 // 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
|
659 case 3: |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
660 quad2_x = quad4_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
661 quad2_y = quad4_y; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
662 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
663 // iterate through 4 2x2 blocks |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
664 for (k = 0; k < 4; k++) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
665 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
666 if (quad2_x & 2) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
667 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
668 quad2_x -= 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
669 quad2_y += 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
670 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
671 else |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
672 quad2_x += 2; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
673 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
674 // set up the planes |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
675 y_plane = mpi->planes[0] + quad2_y * y_stride + quad2_x; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
676 u_plane = mpi->planes[1] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
677 (quad2_y / 2) * u_stride + (quad2_x / 2); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
678 v_plane = mpi->planes[2] + |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
679 (quad2_y / 2) * v_stride + (quad2_x / 2); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
680 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
681 // fetch the next index into the v2 vector table |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
682 FETCH_NEXT_ARGUMENT(); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
683 v2 = info->v2[argument]; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
684 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
685 // copy the luminance components |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
686 *(unsigned short*)y_plane = v2.v2_y_u; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
687 y_plane += y_stride; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
688 *(unsigned short*)y_plane = v2.v2_y_l; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
689 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
690 // copy the U and V bytes |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
691 u_plane[0] = v2.u; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
692 v_plane[0] = v2.v; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
693 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
694 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
695 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
696 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
697 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
698 break; |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
699 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
700 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
701 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
702 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
703 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
704 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
705 // one last sanity check on the way out |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
706 if (stream_ptr < encoded_size) |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
707 { |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
708 mp_msg(MSGT_DECVIDEO, MSGL_WARN, |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
709 "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
|
710 stream_ptr, encoded_size); |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
711 } |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
712 |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
713 // save the current frame as the previous frame for the next iteration |
026329111b09
first pass at RoQ video decoder...not exactly qualified as 'working' at
melanson
parents:
4486
diff
changeset
|
714 info->prev_frame = mpi; |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
715 } |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
716 |
4486 | 717 // Initialize the RoQ audio decoder, which is to say, initialize the table |
718 // of squares. | |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
719 void *roq_decode_audio_init(void) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
720 { |
4486 | 721 short *square_array; |
722 short square; | |
723 int i; | |
724 | |
725 square_array = (short *)malloc(256 * sizeof(short)); | |
726 if (!square_array) | |
727 return NULL; | |
728 | |
729 for (i = 0; i < 128; i++) | |
730 { | |
731 square = i * i; | |
732 square_array[i] = square; | |
733 square_array[i + 128] = -square; | |
734 } | |
735 | |
736 return square_array; | |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
737 } |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
738 |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
739 int roq_decode_audio( |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
740 unsigned short *output, |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
741 unsigned char *input, |
4486 | 742 int encoded_size, |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
743 int channels, |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
744 void *context) |
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
745 { |
4486 | 746 short *square_array = (short *)context; |
747 int i; | |
748 int predictor[2]; | |
749 int channel_number = 0; | |
750 | |
751 // prepare the initial predictors | |
752 if (channels == 1) | |
753 predictor[0] = LE_16(&input[0]); | |
754 else | |
755 { | |
756 predictor[0] = input[1] << 8; | |
757 predictor[1] = input[0] << 8; | |
758 } | |
759 SE_16BIT(predictor[0]); | |
760 SE_16BIT(predictor[1]); | |
761 | |
762 // decode the samples | |
763 for (i = 2; i < encoded_size; i++) | |
764 { | |
765 predictor[channel_number] += square_array[input[i]]; | |
766 CLAMP_S16(predictor[channel_number]); | |
767 output[i - 2] = predictor[channel_number]; | |
768 | |
769 // toggle channel | |
770 channel_number ^= channels - 1; | |
771 } | |
772 | |
773 // return the number of samples decoded | |
774 return (encoded_size - 2); | |
4450
3da8c5706371
added skeleton decoders for RoQ audio and video format decoders
melanson
parents:
diff
changeset
|
775 } |