Mercurial > libavcodec.hg
annotate xvmcvideo.c @ 1905:2761950695cc libavcodec
* some significant clean-up of the dv_decode_ac (it looks real
simple now, take a look for yourself).
* additional optimizations of the decoder. It runs at 55fps now
on my desktop and it used to be ~45fps.
author | romansh |
---|---|
date | Thu, 25 Mar 2004 01:46:40 +0000 |
parents | 63eafb5b1c38 |
children | 23280e1b8dbf |
rev | line source |
---|---|
1392
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
1 /* |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
2 * XVideo Motion Compensation |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
3 * Copyright (c) 2003 Ivan Kalvachev |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
4 * |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
9 * |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
13 * Lesser General Public License for more details. |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
14 * |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
18 */ |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
19 |
1381 | 20 #include <limits.h> |
21 | |
22 //avcodec include | |
23 #include "avcodec.h" | |
24 #include "dsputil.h" | |
25 #include "mpegvideo.h" | |
26 | |
27 #undef NDEBUG | |
28 #include <assert.h> | |
29 | |
30 #ifdef USE_FASTMEMCPY | |
31 #include "fastmemcpy.h" | |
32 #endif | |
33 | |
34 #ifdef HAVE_XVMC | |
1392
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
35 |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
36 //X11 includes are in the xvmc_render.h |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
37 //by replacing it with none-X one |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
38 //XvMC emulation could be performed |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
39 |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
40 #include "xvmc_render.h" |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
41 |
1381 | 42 //#include "xvmc_debug.h" |
43 | |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
44 //set s->block |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
45 inline void XVMC_init_block(MpegEncContext *s){ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
46 xvmc_render_state_t * render; |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
47 render = (xvmc_render_state_t*)s->current_picture.data[2]; |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
48 assert(render != NULL); |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
49 if( (render == NULL) || (render->magic != MP_XVMC_RENDER_MAGIC) ){ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
50 assert(0); |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
51 return;//make sure that this is render packet |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
52 } |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
53 s->block =(DCTELEM *)(render->data_blocks+(render->next_free_data_block_num)*64); |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
54 } |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
55 |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
56 void XVMC_pack_pblocks(MpegEncContext *s, int cbp){ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
57 int i,j; |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
58 |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
59 j=0; |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
60 for(i=0;i<6;i++){ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
61 if(cbp & (1<<(5-i)) ){ |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
62 s->pblocks[i] = (short *)(&s->block[(j++)]); |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
63 }else{ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
64 s->pblocks[i] = NULL; |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
65 } |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
66 // printf("s->pblocks[%d]=%p ,s->block=%p cbp=%d\n",i,s->pblocks[i],s->block,cbp); |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
67 } |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
68 if (s->chroma_format >= 2){ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
69 if (s->chroma_format == 2){//CHROMA_422 |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
70 for(i=6;i<8;i++){ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
71 if(cbp & (1<<(6+7-i)) ){ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
72 s->pblocks[i] = (short *)(&s->block[(j++)]); |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
73 }else{ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
74 s->pblocks[i] = NULL; |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
75 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
76 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
77 }else{//CHROMA_444 |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
78 for(i=6; i<12; i++){ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
79 if(cbp & (1<<(6+11-i)) ){ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
80 s->pblocks[i] = (short *)(&s->block[(j++)]); |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
81 }else{ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
82 s->pblocks[i] = NULL; |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
83 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
84 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
85 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
86 } |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
87 } |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
88 |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
89 static int calc_cbp(MpegEncContext *s){ |
1381 | 90 /* compute cbp */ |
91 int i,cbp = 0; | |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
92 for(i=0; i<4; i++) { |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
93 if(s->block_last_index[i] >= 0) |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
94 cbp |= 1 << (5 - i); |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
95 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
96 if(s->flags & CODEC_FLAG_GRAY) |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
97 return cbp; //4 block for grayscale one done |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
98 |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
99 |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
100 for(i=4; i<6; i++) { |
1381 | 101 if(s->block_last_index[i] >= 0) |
102 cbp |= 1 << (5 - i); | |
103 } | |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
104 if(s->chroma_format < 2) return cbp; |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
105 |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
106 |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
107 if(s->chroma_format == 2){/*CHROMA_422*/ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
108 for(i=6; i<8; i++) { |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
109 if(s->block_last_index[i] >= 0) |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
110 cbp |= 1 << (6+7 - i); |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
111 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
112 }else{/*CHROMA_444*/ |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
113 for(i=6; i<12; i++) { |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
114 if(s->block_last_index[i] >= 0) |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
115 cbp |= 1 << (6+11 - i); |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
116 } |
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
117 } |
1381 | 118 return cbp; |
119 } | |
120 | |
121 | |
122 | |
123 //these functions should be called on every new field or/and frame | |
124 //They should be safe if they are called few times for same field! | |
125 int XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx){ | |
126 xvmc_render_state_t * render,* last, * next; | |
127 | |
128 assert(avctx != NULL); | |
1392
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
129 |
1381 | 130 render = (xvmc_render_state_t*)s->current_picture.data[2]; |
131 assert(render != NULL); | |
1392
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
132 if( (render == NULL) || (render->magic != MP_XVMC_RENDER_MAGIC) ) |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
133 return -1;//make sure that this is render packet |
1381 | 134 |
135 render->picture_structure = s->picture_structure; | |
136 render->flags = (s->first_field)? 0: XVMC_SECOND_FIELD; | |
137 | |
138 //make sure that all data is drawn by XVMC_end_frame | |
139 assert(render->filled_mv_blocks_num==0); | |
140 | |
141 render->p_future_surface = NULL; | |
142 render->p_past_surface = NULL; | |
143 | |
144 switch(s->pict_type){ | |
145 case I_TYPE: | |
146 return 0;// no prediction from other frames | |
147 case B_TYPE: | |
148 next = (xvmc_render_state_t*)s->next_picture.data[2]; | |
149 assert(next!=NULL); | |
150 assert(next->state & MP_XVMC_STATE_PREDICTION); | |
1392
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
151 if(next == NULL) return -1; |
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
152 if(next->magic != MP_XVMC_RENDER_MAGIC) return -1; |
1381 | 153 render->p_future_surface = next->p_surface; |
154 //no return here, going to set forward prediction | |
155 case P_TYPE: | |
156 last = (xvmc_render_state_t*)s->last_picture.data[2]; | |
157 if(last == NULL)// && !s->first_field) | |
158 last = render;//predict second field from the first | |
1392
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
159 if(last->magic != MP_XVMC_RENDER_MAGIC) return -1; |
1381 | 160 assert(last->state & MP_XVMC_STATE_PREDICTION); |
161 render->p_past_surface = last->p_surface; | |
162 return 0; | |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
163 } |
1381 | 164 |
165 return -1; | |
166 } | |
167 | |
168 void XVMC_field_end(MpegEncContext *s){ | |
169 xvmc_render_state_t * render; | |
170 render = (xvmc_render_state_t*)s->current_picture.data[2]; | |
171 assert(render != NULL); | |
172 | |
173 if(render->filled_mv_blocks_num > 0){ | |
174 // printf("xvmcvideo.c: rendering %d left blocks after last slice!!!\n",render->filled_mv_blocks_num ); | |
175 ff_draw_horiz_band(s,0,0); | |
176 } | |
177 } | |
178 | |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
179 void XVMC_decode_mb(MpegEncContext *s){ |
1381 | 180 XvMCMacroBlock * mv_block; |
181 xvmc_render_state_t * render; | |
182 int i,cbp,blocks_per_mb; | |
183 | |
184 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; | |
185 | |
186 | |
187 if(s->encoding){ | |
1830
024752284c25
av_log() patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents:
1580
diff
changeset
|
188 av_log(s->avctx, AV_LOG_ERROR, "XVMC doesn't support encoding!!!\n"); |
1517 | 189 av_abort(); |
1381 | 190 } |
191 | |
192 //from MPV_decode_mb(), | |
193 /* update DC predictors for P macroblocks */ | |
194 if (!s->mb_intra) { | |
195 s->last_dc[0] = | |
196 s->last_dc[1] = | |
197 s->last_dc[2] = 128 << s->intra_dc_precision; | |
198 } | |
199 | |
200 //MC doesn't skip blocks | |
201 s->mb_skiped = 0; | |
202 | |
203 | |
204 // do I need to export quant when I could not perform postprocessing? | |
205 // anyway, it doesn't hurrt | |
206 s->current_picture.qscale_table[mb_xy] = s->qscale; | |
207 | |
208 //START OF XVMC specific code | |
209 render = (xvmc_render_state_t*)s->current_picture.data[2]; | |
210 assert(render!=NULL); | |
211 assert(render->magic==MP_XVMC_RENDER_MAGIC); | |
212 assert(render->mv_blocks); | |
1392
13a02518ffb6
Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents:
1381
diff
changeset
|
213 |
1381 | 214 //take the next free macroblock |
215 mv_block = &render->mv_blocks[render->start_mv_blocks_num + | |
216 render->filled_mv_blocks_num ]; | |
217 | |
218 // memset(mv_block,0,sizeof(XvMCMacroBlock)); | |
219 | |
220 mv_block->x = s->mb_x; | |
221 mv_block->y = s->mb_y; | |
222 mv_block->dct_type = s->interlaced_dct;//XVMC_DCT_TYPE_FRAME/FIELD; | |
223 // mv_block->motion_type = 0; //zero to silense warnings | |
224 if(s->mb_intra){ | |
225 mv_block->macroblock_type = XVMC_MB_TYPE_INTRA;//no MC, all done | |
226 }else{ | |
227 mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN; | |
228 | |
229 if(s->mv_dir & MV_DIR_FORWARD){ | |
230 mv_block->macroblock_type|= XVMC_MB_TYPE_MOTION_FORWARD; | |
231 //pmv[n][dir][xy]=mv[dir][n][xy] | |
232 mv_block->PMV[0][0][0] = s->mv[0][0][0]; | |
233 mv_block->PMV[0][0][1] = s->mv[0][0][1]; | |
234 mv_block->PMV[1][0][0] = s->mv[0][1][0]; | |
235 mv_block->PMV[1][0][1] = s->mv[0][1][1]; | |
236 } | |
237 if(s->mv_dir & MV_DIR_BACKWARD){ | |
238 mv_block->macroblock_type|=XVMC_MB_TYPE_MOTION_BACKWARD; | |
239 mv_block->PMV[0][1][0] = s->mv[1][0][0]; | |
240 mv_block->PMV[0][1][1] = s->mv[1][0][1]; | |
241 mv_block->PMV[1][1][0] = s->mv[1][1][0]; | |
242 mv_block->PMV[1][1][1] = s->mv[1][1][1]; | |
243 } | |
244 | |
245 switch(s->mv_type){ | |
246 case MV_TYPE_16X16: | |
247 mv_block->motion_type = XVMC_PREDICTION_FRAME; | |
248 break; | |
249 case MV_TYPE_16X8: | |
250 mv_block->motion_type = XVMC_PREDICTION_16x8; | |
251 break; | |
252 case MV_TYPE_FIELD: | |
253 mv_block->motion_type = XVMC_PREDICTION_FIELD; | |
254 if(s->picture_structure == PICT_FRAME){ | |
255 mv_block->PMV[0][0][1]<<=1; | |
256 mv_block->PMV[1][0][1]<<=1; | |
257 mv_block->PMV[0][1][1]<<=1; | |
258 mv_block->PMV[1][1][1]<<=1; | |
259 } | |
260 break; | |
261 case MV_TYPE_DMV: | |
262 mv_block->motion_type = XVMC_PREDICTION_DUAL_PRIME; | |
263 if(s->picture_structure == PICT_FRAME){ | |
264 | |
265 mv_block->PMV[0][0][0] = s->mv[0][0][0];//top from top | |
266 mv_block->PMV[0][0][1] = s->mv[0][0][1]<<1; | |
267 | |
268 mv_block->PMV[0][1][0] = s->mv[0][0][0];//bottom from bottom | |
269 mv_block->PMV[0][1][1] = s->mv[0][0][1]<<1; | |
270 | |
271 mv_block->PMV[1][0][0] = s->mv[0][2][0];//dmv00, top from bottom | |
272 mv_block->PMV[1][0][1] = s->mv[0][2][1]<<1;//dmv01 | |
273 | |
274 mv_block->PMV[1][1][0] = s->mv[0][3][0];//dmv10, bottom from top | |
275 mv_block->PMV[1][1][1] = s->mv[0][3][1]<<1;//dmv11 | |
276 | |
277 }else{ | |
278 mv_block->PMV[0][1][0] = s->mv[0][2][0];//dmv00 | |
279 mv_block->PMV[0][1][1] = s->mv[0][2][1];//dmv01 | |
280 } | |
281 break; | |
282 default: | |
283 assert(0); | |
284 } | |
285 | |
286 mv_block->motion_vertical_field_select = 0; | |
287 | |
288 //set correct field referenses | |
289 if(s->mv_type == MV_TYPE_FIELD || s->mv_type == MV_TYPE_16X8){ | |
290 if( s->field_select[0][0] ) mv_block->motion_vertical_field_select|=1; | |
291 if( s->field_select[1][0] ) mv_block->motion_vertical_field_select|=2; | |
292 if( s->field_select[0][1] ) mv_block->motion_vertical_field_select|=4; | |
293 if( s->field_select[1][1] ) mv_block->motion_vertical_field_select|=8; | |
294 } | |
295 }//!intra | |
296 //time to handle data blocks; | |
297 mv_block->index = render->next_free_data_block_num; | |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
298 |
1381 | 299 blocks_per_mb = 6; |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
300 if( s->chroma_format >= 2){ |
1849 | 301 blocks_per_mb = 4 + (1 << (s->chroma_format)); |
1381 | 302 } |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
303 |
1381 | 304 if(s->flags & CODEC_FLAG_GRAY){ |
305 if(s->mb_intra){//intra frames are alwasy full chroma block | |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
306 for(i=4; i<blocks_per_mb; i++){ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
307 memset(s->pblocks[i],0,sizeof(short)*8*8);//so we need to clear them |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
308 if(!render->unsigned_intra) |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
309 s->pblocks[i][0] = 1<<10; |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
310 } |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
311 }else |
1381 | 312 blocks_per_mb = 4;//Luminance blocks only |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
313 } |
1848
c72589baee53
initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents:
1830
diff
changeset
|
314 cbp = calc_cbp(s); |
1381 | 315 mv_block->coded_block_pattern = cbp; |
316 if(cbp == 0) | |
317 mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN; | |
318 | |
319 for(i=0; i<blocks_per_mb; i++){ | |
320 if(s->block_last_index[i] >= 0){ | |
321 // i do not have unsigned_intra MOCO to test, hope it is OK | |
322 if( (s->mb_intra) && ( render->idct || (!render->idct && !render->unsigned_intra)) ) | |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
323 s->pblocks[i][0]-=1<<10; |
1381 | 324 if(!render->idct){ |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
325 s->dsp.idct(s->pblocks[i]); |
1381 | 326 //!!TODO!clip!!! |
327 } | |
1580
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
328 //copy blocks only if the codec doesn't support pblocks reordering |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
329 if(s->avctx->xvmc_acceleration == 1){ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
330 memcpy(&render->data_blocks[(render->next_free_data_block_num)*64], |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
331 s->pblocks[i],sizeof(short)*8*8); |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
332 }else{ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
333 /* if(s->pblocks[i] != &render->data_blocks[ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
334 (render->next_free_data_block_num)*64]){ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
335 printf("ERROR mb(%d,%d) s->pblocks[i]=%p data_block[]=%p\n", |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
336 s->mb_x,s->mb_y, s->pblocks[i], |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
337 &render->data_blocks[(render->next_free_data_block_num)*64]); |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
338 }*/ |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
339 } |
628bf341e099
XvMC speedup by removing one memcpy and doing MB packing
iive
parents:
1517
diff
changeset
|
340 render->next_free_data_block_num++; |
1381 | 341 } |
342 } | |
343 render->filled_mv_blocks_num++; | |
344 | |
345 assert(render->filled_mv_blocks_num <= render->total_number_of_mv_blocks); | |
346 assert(render->next_free_data_block_num <= render->total_number_of_data_blocks); | |
347 | |
348 | |
349 if(render->filled_mv_blocks_num >= render->total_number_of_mv_blocks) | |
350 ff_draw_horiz_band(s,0,0); | |
351 | |
352 // DumpRenderInfo(render); | |
353 // DumpMBlockInfo(mv_block); | |
354 | |
355 } | |
356 | |
357 #endif |