Mercurial > libavcodec.hg
annotate roqvideo.c @ 5530:cd266411b11a libavcodec
use shorter types vec_"type" instead of the too long vector "type"
part 1 of h264 luma interpolation 8x8 for altivec contributed by
Mauricio Alvarez % lokifo A gmail P com %
Original thread:
Date: Jun 26, 2007 8:15 PM
Subject: Re: [FFmpeg-devel] [PATCH] h264 luma interpolation 8x8 for altivec
author | gpoirier |
---|---|
date | Sun, 12 Aug 2007 13:50:06 +0000 |
parents | 922bb0564bd3 |
children | 0d01bae8d207 |
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 /** |
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 |
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 } |