Mercurial > libavcodec.hg
annotate roqvideo.c @ 5090:20914da7d71b libavcodec
Remove get_byte wrapper
author | ramiro |
---|---|
date | Sat, 02 Jun 2007 01:42:47 +0000 |
parents | e72265f4e518 |
children | 133329117637 |
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 |
5080
e72265f4e518
Split RoQ decoder to accommodate future encoder patch
benoit
parents:
5078
diff
changeset
|
24 * Id RoQ Video common functions based on work by Dr. Tim Ferguson |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
25 */ |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
26 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
27 #include "avcodec.h" |
5080
e72265f4e518
Split RoQ decoder to accommodate future encoder patch
benoit
parents:
5078
diff
changeset
|
28 #include "roqvideo.h" |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
29 |
5078 | 30 #define avg2(a,b) av_clip_uint8(((int)(a)+(int)(b)+1)>>1) |
31 #define avg4(a,b,c,d) av_clip_uint8(((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
|
32 |
5078 | 33 void ff_apply_vector_2x2(RoqContext *ri, int x, int y, roq_cell *cell) |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
34 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
35 unsigned char *yptr; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
36 |
4586 | 37 yptr = ri->current_frame->data[0] + (y * ri->y_stride) + x; |
5078 | 38 *yptr++ = cell->y[0]; |
39 *yptr++ = cell->y[1]; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
40 yptr += (ri->y_stride - 2); |
5078 | 41 *yptr++ = cell->y[2]; |
42 *yptr++ = cell->y[3]; | |
4586 | 43 ri->current_frame->data[1][(y/2) * (ri->c_stride) + x/2] = cell->u; |
44 ri->current_frame->data[2][(y/2) * (ri->c_stride) + x/2] = cell->v; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
45 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
46 |
5078 | 47 void ff_apply_vector_4x4(RoqContext *ri, int x, int y, roq_cell *cell) |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
48 { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
49 unsigned long row_inc, c_row_inc; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
50 register unsigned char y0, y1, u, v; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
51 unsigned char *yptr, *uptr, *vptr; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
52 |
4586 | 53 yptr = ri->current_frame->data[0] + (y * ri->y_stride) + x; |
54 uptr = ri->current_frame->data[1] + (y/2) * (ri->c_stride) + x/2; | |
55 vptr = ri->current_frame->data[2] + (y/2) * (ri->c_stride) + x/2; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
56 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
57 row_inc = ri->y_stride - 4; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
58 c_row_inc = (ri->c_stride) - 2; |
5078 | 59 *yptr++ = y0 = cell->y[0]; *uptr++ = u = cell->u; *vptr++ = v = cell->v; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
60 *yptr++ = y0; |
5078 | 61 *yptr++ = y1 = cell->y[1]; *uptr++ = u; *vptr++ = v; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
62 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
63 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
64 yptr += row_inc; |
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 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
67 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
68 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
69 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
70 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
71 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
|
72 |
5078 | 73 *yptr++ = y0 = cell->y[2]; *uptr++ = u; *vptr++ = v; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
74 *yptr++ = y0; |
5078 | 75 *yptr++ = y1 = cell->y[3]; *uptr++ = u; *vptr++ = v; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
76 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
77 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
78 yptr += row_inc; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
79 |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
80 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
81 *yptr++ = y0; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
82 *yptr++ = y1; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
83 *yptr++ = y1; |
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 |
5078 | 86 void ff_apply_motion_4x4(RoqContext *ri, int x, int y, |
87 int deltax, int deltay) | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
88 { |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
89 int i, hw, mx, my; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
90 unsigned char *pa, *pb; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
91 |
5078 | 92 mx = x + deltax; |
93 my = y + deltay; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
94 |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
95 /* check MV against frame boundaries */ |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
96 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
|
97 (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
|
98 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
|
99 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
|
100 return; |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
101 } |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
102 |
4586 | 103 pa = ri->current_frame->data[0] + (y * ri->y_stride) + x; |
104 pb = ri->last_frame->data[0] + (my * ri->y_stride) + mx; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
105 for(i = 0; i < 4; i++) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
106 pa[0] = pb[0]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
107 pa[1] = pb[1]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
108 pa[2] = pb[2]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
109 pa[3] = pb[3]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
110 pa += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
111 pb += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
112 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
113 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
114 hw = ri->y_stride/2; |
4586 | 115 pa = ri->current_frame->data[1] + (y * ri->y_stride)/4 + x/2; |
116 pb = ri->last_frame->data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; | |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
117 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
118 for(i = 0; i < 2; i++) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
119 switch(((my & 0x01) << 1) | (mx & 0x01)) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
120 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
121 case 0: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
122 pa[0] = pb[0]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
123 pa[1] = pb[1]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
124 pa[hw] = pb[hw]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
125 pa[hw+1] = pb[hw+1]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
126 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
127 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
128 case 1: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
129 pa[0] = avg2(pb[0], pb[1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
130 pa[1] = avg2(pb[1], pb[2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
131 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
|
132 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
|
133 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
134 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
135 case 2: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
136 pa[0] = avg2(pb[0], pb[hw]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
137 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
|
138 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
|
139 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
|
140 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
141 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
142 case 3: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
143 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
|
144 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
|
145 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
|
146 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
|
147 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
148 } |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
149 |
4586 | 150 pa = ri->current_frame->data[2] + (y * ri->y_stride)/4 + x/2; |
151 pb = ri->last_frame->data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; | |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
152 } |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
153 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
154 |
5078 | 155 void ff_apply_motion_8x8(RoqContext *ri, int x, int y, |
156 int deltax, int deltay) | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
157 { |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
158 int mx, my, i, j, hw; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
159 unsigned char *pa, *pb; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
160 |
5078 | 161 mx = x + deltax; |
162 my = y + deltay; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
163 |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
164 /* check MV against frame boundaries */ |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
165 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
|
166 (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
|
167 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
|
168 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
|
169 return; |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
170 } |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
171 |
4586 | 172 pa = ri->current_frame->data[0] + (y * ri->y_stride) + x; |
173 pb = ri->last_frame->data[0] + (my * ri->y_stride) + mx; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
174 for(i = 0; i < 8; i++) { |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
175 pa[0] = pb[0]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
176 pa[1] = pb[1]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
177 pa[2] = pb[2]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
178 pa[3] = pb[3]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
179 pa[4] = pb[4]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
180 pa[5] = pb[5]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
181 pa[6] = pb[6]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
182 pa[7] = pb[7]; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
183 pa += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
184 pb += ri->y_stride; |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
185 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
186 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
187 hw = ri->c_stride; |
4586 | 188 pa = ri->current_frame->data[1] + (y * ri->y_stride)/4 + x/2; |
189 pb = ri->last_frame->data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; | |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
190 for(j = 0; j < 2; j++) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
191 for(i = 0; i < 4; i++) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
192 switch(((my & 0x01) << 1) | (mx & 0x01)) { |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
193 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
194 case 0: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
195 pa[0] = pb[0]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
196 pa[1] = pb[1]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
197 pa[2] = pb[2]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
198 pa[3] = pb[3]; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
199 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
200 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
201 case 1: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
202 pa[0] = avg2(pb[0], pb[1]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
203 pa[1] = avg2(pb[1], pb[2]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
204 pa[2] = avg2(pb[2], pb[3]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
205 pa[3] = avg2(pb[3], pb[4]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
206 break; |
2967 | 207 |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
208 case 2: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
209 pa[0] = avg2(pb[0], pb[hw]); |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
210 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
|
211 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
|
212 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
|
213 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
214 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
215 case 3: |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 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
|
220 break; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
221 } |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
222 pa += ri->c_stride; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
223 pb += ri->c_stride; |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
224 } |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
225 |
4586 | 226 pa = ri->current_frame->data[2] + (y * ri->y_stride)/4 + x/2; |
227 pb = ri->last_frame->data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2; | |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
228 } |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
229 } |