Mercurial > libavcodec.hg
annotate roqvideo.c @ 3967:01e1a12aa380 libavcodec
remove bytestream_end checks, seems to work fine without them and the bitstream reader doesnt check for the end either
author | michael |
---|---|
date | Mon, 09 Oct 2006 12:25:24 +0000 |
parents | c8c591fe26f8 |
children | 365f2fed8461 |
rev | line source |
---|---|
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
1 /* |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
2 * Copyright (C) 2003 the ffmpeg project |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
3 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
4 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
10 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
14 * Lesser General Public License for more details. |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
15 * |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
19 * |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
20 */ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
21 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
22 /** |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
23 * @file roqvideo.c |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
24 * Id RoQ Video Decoder by Dr. Tim Ferguson |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
25 * For more information about the Id RoQ format, visit: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
26 * http://www.csse.monash.edu.au/~timf/ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
27 */ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
28 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
29 #include <stdio.h> |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
30 #include <stdlib.h> |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
31 #include <string.h> |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
32 #include <unistd.h> |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
33 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
34 #include "common.h" |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
35 #include "avcodec.h" |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
36 #include "dsputil.h" |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
37 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
38 typedef struct { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
39 unsigned char y0, y1, y2, y3, u, v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
40 } roq_cell; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
41 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
42 typedef struct { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
43 int idx[4]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
44 } roq_qcell; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
45 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
46 static int uiclip[1024], *uiclp; /* clipping table */ |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
47 #define avg2(a,b) uiclp[(((int)(a)+(int)(b)+1)>>1)] |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
48 #define avg4(a,b,c,d) uiclp[(((int)(a)+(int)(b)+(int)(c)+(int)(d)+2)>>2)] |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
49 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
50 typedef struct RoqContext { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
51 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
52 AVCodecContext *avctx; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
53 DSPContext dsp; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
54 AVFrame last_frame; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
55 AVFrame current_frame; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
56 int first_frame; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
57 int y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
58 int c_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
59 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
60 roq_cell cells[256]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
61 roq_qcell qcells[256]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
62 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
63 unsigned char *buf; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
64 int size; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
65 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
66 } RoqContext; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
67 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
68 #define RoQ_INFO 0x1001 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
69 #define RoQ_QUAD_CODEBOOK 0x1002 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
70 #define RoQ_QUAD_VQ 0x1011 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
71 #define RoQ_SOUND_MONO 0x1020 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
72 #define RoQ_SOUND_STEREO 0x1021 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
73 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
74 #define RoQ_ID_MOT 0x00 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
75 #define RoQ_ID_FCC 0x01 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
76 #define RoQ_ID_SLD 0x02 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
77 #define RoQ_ID_CCC 0x03 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
78 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
79 #define get_byte(in_buffer) *(in_buffer++) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
80 #define get_word(in_buffer) ((unsigned short)(in_buffer += 2, \ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
81 (in_buffer[-1] << 8 | in_buffer[-2]))) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
82 #define get_long(in_buffer) ((unsigned long)(in_buffer += 4, \ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
83 (in_buffer[-1] << 24 | in_buffer[-2] << 16 | in_buffer[-3] << 8 | in_buffer[-4]))) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
84 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
85 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
86 static void apply_vector_2x2(RoqContext *ri, int x, int y, roq_cell *cell) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
87 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
88 unsigned char *yptr; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
89 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
90 yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
91 *yptr++ = cell->y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
92 *yptr++ = cell->y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
93 yptr += (ri->y_stride - 2); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
94 *yptr++ = cell->y2; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
95 *yptr++ = cell->y3; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
96 ri->current_frame.data[1][(y/2) * (ri->c_stride) + x/2] = cell->u; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
97 ri->current_frame.data[2][(y/2) * (ri->c_stride) + x/2] = cell->v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
98 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
99 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
100 static void apply_vector_4x4(RoqContext *ri, int x, int y, roq_cell *cell) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
101 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
102 unsigned long row_inc, c_row_inc; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
103 register unsigned char y0, y1, u, v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
104 unsigned char *yptr, *uptr, *vptr; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
105 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
106 yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
107 uptr = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
108 vptr = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
109 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
110 row_inc = ri->y_stride - 4; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
111 c_row_inc = (ri->c_stride) - 2; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
112 *yptr++ = y0 = cell->y0; *uptr++ = u = cell->u; *vptr++ = v = cell->v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
113 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
114 *yptr++ = y1 = cell->y1; *uptr++ = u; *vptr++ = v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
115 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
116 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
117 yptr += row_inc; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
118 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
119 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
120 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
121 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
122 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
123 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
124 yptr += row_inc; uptr += c_row_inc; vptr += c_row_inc; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
125 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
126 *yptr++ = y0 = cell->y2; *uptr++ = u; *vptr++ = v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
127 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
128 *yptr++ = y1 = cell->y3; *uptr++ = u; *vptr++ = v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
129 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
130 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
131 yptr += row_inc; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
132 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
133 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
134 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
135 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
136 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
137 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
138 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
139 static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv, |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
140 signed char mean_x, signed char mean_y) |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
141 { |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
142 int i, hw, mx, my; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
143 unsigned char *pa, *pb; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
144 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
145 mx = x + 8 - (mv >> 4) - mean_x; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
146 my = y + 8 - (mv & 0xf) - mean_y; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
147 |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
148 /* check MV against frame boundaries */ |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
149 if ((mx < 0) || (mx > ri->avctx->width - 4) || |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
150 (my < 0) || (my > ri->avctx->height - 4)) { |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
151 av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n", |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
152 mx, my, ri->avctx->width, ri->avctx->height); |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
153 return; |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
154 } |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
155 |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
156 pa = ri->current_frame.data[0] + (y * ri->y_stride) + x; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
157 pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
158 for(i = 0; i < 4; i++) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
159 pa[0] = pb[0]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
160 pa[1] = pb[1]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
161 pa[2] = pb[2]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
162 pa[3] = pb[3]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
163 pa += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
164 pb += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
165 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
166 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
167 hw = ri->y_stride/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
168 pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
169 pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
170 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
171 for(i = 0; i < 2; i++) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
172 switch(((my & 0x01) << 1) | (mx & 0x01)) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
173 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
174 case 0: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
175 pa[0] = pb[0]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
176 pa[1] = pb[1]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
177 pa[hw] = pb[hw]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
178 pa[hw+1] = pb[hw+1]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
179 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
180 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
181 case 1: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
182 pa[0] = avg2(pb[0], pb[1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
183 pa[1] = avg2(pb[1], pb[2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
184 pa[hw] = avg2(pb[hw], pb[hw+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
185 pa[hw+1] = avg2(pb[hw+1], pb[hw+2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
186 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
187 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
188 case 2: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
189 pa[0] = avg2(pb[0], pb[hw]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
190 pa[1] = avg2(pb[1], pb[hw+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
191 pa[hw] = avg2(pb[hw], pb[hw*2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
192 pa[hw+1] = avg2(pb[hw+1], pb[(hw*2)+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
193 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
194 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
195 case 3: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
196 pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
197 pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
198 pa[hw] = avg4(pb[hw], pb[hw+1], pb[hw*2], pb[(hw*2)+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
199 pa[hw+1] = avg4(pb[hw+1], pb[hw+2], pb[(hw*2)+1], pb[(hw*2)+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
200 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
201 } |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
202 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
203 pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
204 pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
205 } |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
206 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
207 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
208 static void apply_motion_8x8(RoqContext *ri, int x, int y, |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
209 unsigned char mv, signed char mean_x, signed char mean_y) |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
210 { |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
211 int mx, my, i, j, hw; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
212 unsigned char *pa, *pb; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
213 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
214 mx = x + 8 - (mv >> 4) - mean_x; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
215 my = y + 8 - (mv & 0xf) - mean_y; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
216 |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
217 /* check MV against frame boundaries */ |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
218 if ((mx < 0) || (mx > ri->avctx->width - 8) || |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
219 (my < 0) || (my > ri->avctx->height - 8)) { |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
220 av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n", |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
221 mx, my, ri->avctx->width, ri->avctx->height); |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
222 return; |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
223 } |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
224 |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
225 pa = ri->current_frame.data[0] + (y * ri->y_stride) + x; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
226 pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
227 for(i = 0; i < 8; i++) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
228 pa[0] = pb[0]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
229 pa[1] = pb[1]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
230 pa[2] = pb[2]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
231 pa[3] = pb[3]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
232 pa[4] = pb[4]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
233 pa[5] = pb[5]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
234 pa[6] = pb[6]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
235 pa[7] = pb[7]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
236 pa += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
237 pb += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
238 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
239 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
240 hw = ri->c_stride; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
241 pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
242 pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
243 for(j = 0; j < 2; j++) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
244 for(i = 0; i < 4; i++) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
245 switch(((my & 0x01) << 1) | (mx & 0x01)) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
246 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
247 case 0: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
248 pa[0] = pb[0]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
249 pa[1] = pb[1]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
250 pa[2] = pb[2]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
251 pa[3] = pb[3]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
252 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
253 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
254 case 1: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
255 pa[0] = avg2(pb[0], pb[1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
256 pa[1] = avg2(pb[1], pb[2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
257 pa[2] = avg2(pb[2], pb[3]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
258 pa[3] = avg2(pb[3], pb[4]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
259 break; |
2967 | 260 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
261 case 2: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
262 pa[0] = avg2(pb[0], pb[hw]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
263 pa[1] = avg2(pb[1], pb[hw+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
264 pa[2] = avg2(pb[2], pb[hw+2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
265 pa[3] = avg2(pb[3], pb[hw+3]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
266 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
267 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
268 case 3: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
269 pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
270 pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
271 pa[2] = avg4(pb[2], pb[3], pb[hw+2], pb[hw+3]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
272 pa[3] = avg4(pb[3], pb[4], pb[hw+3], pb[hw+4]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
273 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
274 } |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
275 pa += ri->c_stride; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
276 pb += ri->c_stride; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
277 } |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
278 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
279 pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
280 pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
281 } |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
282 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
283 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
284 static void roqvideo_decode_frame(RoqContext *ri) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
285 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
286 unsigned int chunk_id = 0, chunk_arg = 0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
287 unsigned long chunk_size = 0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
288 int i, j, k, nv1, nv2, vqflg = 0, vqflg_pos = -1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
289 int vqid, bpos, xpos, ypos, xp, yp, x, y; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
290 int frame_stats[2][4] = {{0},{0}}; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
291 roq_qcell *qcell; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
292 unsigned char *buf = ri->buf; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
293 unsigned char *buf_end = ri->buf + ri->size; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
294 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
295 while (buf < buf_end) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
296 chunk_id = get_word(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
297 chunk_size = get_long(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
298 chunk_arg = get_word(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
299 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
300 if(chunk_id == RoQ_QUAD_VQ) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
301 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
302 if(chunk_id == RoQ_QUAD_CODEBOOK) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
303 if((nv1 = chunk_arg >> 8) == 0) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
304 nv1 = 256; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
305 if((nv2 = chunk_arg & 0xff) == 0 && nv1 * 6 < chunk_size) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
306 nv2 = 256; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
307 for(i = 0; i < nv1; i++) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
308 ri->cells[i].y0 = get_byte(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
309 ri->cells[i].y1 = get_byte(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
310 ri->cells[i].y2 = get_byte(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
311 ri->cells[i].y3 = get_byte(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
312 ri->cells[i].u = get_byte(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
313 ri->cells[i].v = get_byte(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
314 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
315 for(i = 0; i < nv2; i++) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
316 for(j = 0; j < 4; j++) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
317 ri->qcells[i].idx[j] = get_byte(buf); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
318 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
319 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
320 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
321 bpos = xpos = ypos = 0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
322 while(bpos < chunk_size) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
323 for (yp = ypos; yp < ypos + 16; yp += 8) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
324 for (xp = xpos; xp < xpos + 16; xp += 8) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
325 if (vqflg_pos < 0) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
326 vqflg = buf[bpos++]; vqflg |= (buf[bpos++] << 8); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
327 vqflg_pos = 7; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
328 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
329 vqid = (vqflg >> (vqflg_pos * 2)) & 0x3; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
330 frame_stats[0][vqid]++; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
331 vqflg_pos--; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
332 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
333 switch(vqid) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
334 case RoQ_ID_MOT: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
335 apply_motion_8x8(ri, xp, yp, 0, 8, 8); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
336 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
337 case RoQ_ID_FCC: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
338 apply_motion_8x8(ri, xp, yp, buf[bpos++], chunk_arg >> 8, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
339 chunk_arg & 0xff); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
340 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
341 case RoQ_ID_SLD: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
342 qcell = ri->qcells + buf[bpos++]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
343 apply_vector_4x4(ri, xp, yp, ri->cells + qcell->idx[0]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
344 apply_vector_4x4(ri, xp+4, yp, ri->cells + qcell->idx[1]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
345 apply_vector_4x4(ri, xp, yp+4, ri->cells + qcell->idx[2]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
346 apply_vector_4x4(ri, xp+4, yp+4, ri->cells + qcell->idx[3]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
347 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
348 case RoQ_ID_CCC: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
349 for (k = 0; k < 4; k++) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
350 x = xp; y = yp; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
351 if(k & 0x01) x += 4; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
352 if(k & 0x02) y += 4; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
353 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
354 if (vqflg_pos < 0) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
355 vqflg = buf[bpos++]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
356 vqflg |= (buf[bpos++] << 8); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
357 vqflg_pos = 7; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
358 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
359 vqid = (vqflg >> (vqflg_pos * 2)) & 0x3; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
360 frame_stats[1][vqid]++; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
361 vqflg_pos--; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
362 switch(vqid) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
363 case RoQ_ID_MOT: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
364 apply_motion_4x4(ri, x, y, 0, 8, 8); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
365 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
366 case RoQ_ID_FCC: |
2967 | 367 apply_motion_4x4(ri, x, y, buf[bpos++], |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
368 chunk_arg >> 8, chunk_arg & 0xff); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
369 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
370 case RoQ_ID_SLD: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
371 qcell = ri->qcells + buf[bpos++]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
372 apply_vector_2x2(ri, x, y, ri->cells + qcell->idx[0]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
373 apply_vector_2x2(ri, x+2, y, ri->cells + qcell->idx[1]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
374 apply_vector_2x2(ri, x, y+2, ri->cells + qcell->idx[2]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
375 apply_vector_2x2(ri, x+2, y+2, ri->cells + qcell->idx[3]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
376 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
377 case RoQ_ID_CCC: |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
378 apply_vector_2x2(ri, x, y, ri->cells + buf[bpos]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
379 apply_vector_2x2(ri, x+2, y, ri->cells + buf[bpos+1]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
380 apply_vector_2x2(ri, x, y+2, ri->cells + buf[bpos+2]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
381 apply_vector_2x2(ri, x+2, y+2, ri->cells + buf[bpos+3]); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
382 bpos += 4; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
383 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
384 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
385 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
386 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
387 default: |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1495
diff
changeset
|
388 av_log(ri->avctx, AV_LOG_ERROR, "Unknown vq code: %d\n", vqid); |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
389 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
390 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
391 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
392 xpos += 16; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
393 if (xpos >= ri->avctx->width) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
394 xpos -= ri->avctx->width; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
395 ypos += 16; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
396 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
397 if(ypos >= ri->avctx->height) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
398 break; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
399 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
400 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
401 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
402 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
403 static int roq_decode_init(AVCodecContext *avctx) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
404 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
405 RoqContext *s = avctx->priv_data; |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
406 int i; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
407 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
408 s->avctx = avctx; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
409 s->first_frame = 1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
410 avctx->pix_fmt = PIX_FMT_YUV420P; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
411 avctx->has_b_frames = 0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
412 dsputil_init(&s->dsp, avctx); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
413 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
414 uiclp = uiclip+512; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
415 for(i = -512; i < 512; i++) |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
416 uiclp[i] = (i < 0 ? 0 : (i > 255 ? 255 : i)); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
417 |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
418 return 0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
419 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
420 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
421 static int roq_decode_frame(AVCodecContext *avctx, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
422 void *data, int *data_size, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
423 uint8_t *buf, int buf_size) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
424 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
425 RoqContext *s = avctx->priv_data; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
426 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
427 if (avctx->get_buffer(avctx, &s->current_frame)) { |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1495
diff
changeset
|
428 av_log(avctx, AV_LOG_ERROR, " RoQ: get_buffer() failed\n"); |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
429 return -1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
430 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
431 s->y_stride = s->current_frame.linesize[0]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
432 s->c_stride = s->current_frame.linesize[1]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
433 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
434 s->buf = buf; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
435 s->size = buf_size; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
436 roqvideo_decode_frame(s); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
437 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
438 /* release the last frame if it is allocated */ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
439 if (s->first_frame) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
440 s->first_frame = 0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
441 else |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
442 avctx->release_buffer(avctx, &s->last_frame); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
443 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
444 /* shuffle frames */ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
445 s->last_frame = s->current_frame; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
446 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
447 *data_size = sizeof(AVFrame); |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
448 *(AVFrame*)data = s->current_frame; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
449 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
450 return buf_size; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
451 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
452 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
453 static int roq_decode_end(AVCodecContext *avctx) |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
454 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
455 RoqContext *s = avctx->priv_data; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
456 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
457 /* release the last frame */ |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
458 if (s->last_frame.data[0]) |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
459 avctx->release_buffer(avctx, &s->last_frame); |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
460 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
461 return 0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
462 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
463 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
464 AVCodec roq_decoder = { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
465 "roqvideo", |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
466 CODEC_TYPE_VIDEO, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
467 CODEC_ID_ROQ, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
468 sizeof(RoqContext), |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
469 roq_decode_init, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
470 NULL, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
471 roq_decode_end, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
472 roq_decode_frame, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
473 CODEC_CAP_DR1, |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
474 }; |