Mercurial > libavcodec.hg
annotate roqvideo.c @ 12518:67e7e49058c2 libavcodec
Split and then simplify address generation macro.
Allows nasm to work for this code.
author | reimar |
---|---|
date | Sun, 26 Sep 2010 09:08:11 +0000 |
parents | 7dd2a45249a9 |
children |
rev | line source |
---|---|
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
1 /* |
5189 | 2 * Copyright (C) 2003 Mike Melanson |
3 * Copyright (C) 2003 Dr. Tim Ferguson | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * Lesser General Public License for more details. |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
16 * |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
17 * 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
|
18 * 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
|
19 * 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
|
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 /** |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
8718
diff
changeset
|
23 * @file |
6812
0d01bae8d207
cosmetics: s/Id/id/ in libavcodec where Id refers to id Software.
diego
parents:
5205
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 |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
30 static inline void block_copy(unsigned char *out, unsigned char *in, |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
31 int outstride, int instride, int sz) |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
32 { |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
33 int rows = sz; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
34 while(rows--) { |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
35 memcpy(out, in, sz); |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
36 out += outstride; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
37 in += instride; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
38 } |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
39 } |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
40 |
5078 | 41 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
|
42 { |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
43 unsigned char *bptr; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
44 int boffs,stride; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
45 |
5199 | 46 stride = ri->current_frame->linesize[0]; |
5202 | 47 boffs = y*stride + x; |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
48 |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
49 bptr = ri->current_frame->data[0] + boffs; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
50 bptr[0 ] = cell->y[0]; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
51 bptr[1 ] = cell->y[1]; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
52 bptr[stride ] = cell->y[2]; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
53 bptr[stride+1] = cell->y[3]; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
54 |
5199 | 55 stride = ri->current_frame->linesize[1]; |
56 boffs = y*stride + x; | |
57 | |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
58 bptr = ri->current_frame->data[1] + boffs; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
59 bptr[0 ] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
60 bptr[1 ] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
61 bptr[stride ] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
62 bptr[stride+1] = cell->u; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
63 |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
64 bptr = ri->current_frame->data[2] + boffs; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
65 bptr[0 ] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
66 bptr[1 ] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
67 bptr[stride ] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
68 bptr[stride+1] = cell->v; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
69 } |
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
70 |
5078 | 71 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
|
72 { |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
73 unsigned char *bptr; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
74 int boffs,stride; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
75 |
5199 | 76 stride = ri->current_frame->linesize[0]; |
5202 | 77 boffs = y*stride + x; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
78 |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
79 bptr = ri->current_frame->data[0] + boffs; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
80 bptr[ 0] = bptr[ 1] = bptr[stride ] = bptr[stride +1] = cell->y[0]; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
81 bptr[ 2] = bptr[ 3] = bptr[stride +2] = bptr[stride +3] = cell->y[1]; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
82 bptr[stride*2 ] = bptr[stride*2+1] = bptr[stride*3 ] = bptr[stride*3+1] = cell->y[2]; |
5183 | 83 bptr[stride*2+2] = bptr[stride*2+3] = bptr[stride*3+2] = bptr[stride*3+3] = cell->y[3]; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
84 |
5199 | 85 stride = ri->current_frame->linesize[1]; |
86 boffs = y*stride + x; | |
87 | |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
88 bptr = ri->current_frame->data[1] + boffs; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
89 bptr[ 0] = bptr[ 1] = bptr[stride ] = bptr[stride +1] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
90 bptr[ 2] = bptr[ 3] = bptr[stride +2] = bptr[stride +3] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
91 bptr[stride*2 ] = bptr[stride*2+1] = bptr[stride*3 ] = bptr[stride*3+1] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
92 bptr[stride*2+2] = bptr[stride*2+3] = bptr[stride*3+2] = bptr[stride*3+3] = cell->u; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
93 |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
94 bptr = ri->current_frame->data[2] + boffs; |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
95 bptr[ 0] = bptr[ 1] = bptr[stride ] = bptr[stride +1] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
96 bptr[ 2] = bptr[ 3] = bptr[stride +2] = bptr[stride +3] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
97 bptr[stride*2 ] = bptr[stride*2+1] = bptr[stride*3 ] = bptr[stride*3+1] = |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
98 bptr[stride*2+2] = bptr[stride*2+3] = bptr[stride*3+2] = bptr[stride*3+3] = cell->v; |
1439
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 |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
101 |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
102 static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax, |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
103 int deltay, int sz) |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
104 { |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
105 int mx, my, cp; |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
106 |
5078 | 107 mx = x + deltax; |
108 my = y + deltay; | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
109 |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
110 /* check MV against frame boundaries */ |
5188 | 111 if ((mx < 0) || (mx > ri->width - sz) || |
112 (my < 0) || (my > ri->height - sz)) { | |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
113 av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n", |
5188 | 114 mx, my, ri->width, ri->height); |
2828
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
115 return; |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
116 } |
2aae25679885
tinfoil patch: validate motion vectors and do not free frame on exit if
melanson
parents:
2028
diff
changeset
|
117 |
5192 | 118 for(cp = 0; cp < 3; cp++) { |
5199 | 119 int outstride = ri->current_frame->linesize[cp]; |
120 int instride = ri->last_frame ->linesize[cp]; | |
5205 | 121 block_copy(ri->current_frame->data[cp] + y*outstride + x, |
122 ri->last_frame->data[cp] + my*instride + mx, | |
5199 | 123 outstride, instride, sz); |
5192 | 124 } |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
125 } |
1495
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
126 |
07029b2cd44f
experimental half-pel motion compensation for C planes, courtesy of Dr.
tmmm
parents:
1439
diff
changeset
|
127 |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
128 void ff_apply_motion_4x4(RoqContext *ri, int x, int y, |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
129 int deltax, int deltay) |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
130 { |
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
131 apply_motion_generic(ri, x, y, deltax, deltay, 4); |
1439
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 |
5078 | 134 void ff_apply_motion_8x8(RoqContext *ri, int x, int y, |
135 int deltax, int deltay) | |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
136 { |
5099
133329117637
Convert RoQ decoder to use YUV 4:4:4 unpacked macroblocks
benoit
parents:
5080
diff
changeset
|
137 apply_motion_generic(ri, x, y, deltax, deltay, 8); |
1439
a4d00b1f0271
initial commit for Id RoQ and Interplay MVE multimedia subsystems
tmmm
parents:
diff
changeset
|
138 } |