annotate xvmcvideo.c @ 4517:75701d9842cc libavcodec

consistency renaming: yuv422 --> yuyv422
author diego
date Mon, 12 Feb 2007 23:23:05 +0000
parents ed375c76b5e0
children cf6608b00186
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3589
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3589
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3589
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
8 * 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
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: 3589
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3589
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
13 * 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
14 * 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
15 * 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
16 *
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
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: 3589
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: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
20 */
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
21
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
22 #include <limits.h>
f07e17427140 initial XvMC support
iive
parents:
diff changeset
23
f07e17427140 initial XvMC support
iive
parents:
diff changeset
24 //avcodec include
f07e17427140 initial XvMC support
iive
parents:
diff changeset
25 #include "avcodec.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
26 #include "dsputil.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
27 #include "mpegvideo.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
28
f07e17427140 initial XvMC support
iive
parents:
diff changeset
29 #undef NDEBUG
f07e17427140 initial XvMC support
iive
parents:
diff changeset
30 #include <assert.h>
f07e17427140 initial XvMC support
iive
parents:
diff changeset
31
f07e17427140 initial XvMC support
iive
parents:
diff changeset
32 #ifdef USE_FASTMEMCPY
3589
19c437d6aba5 Explicitly include fastmemcpy.h from libvo/.
diego
parents: 3036
diff changeset
33 #include "libvo/fastmemcpy.h"
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
34 #endif
f07e17427140 initial XvMC support
iive
parents:
diff changeset
35
f07e17427140 initial XvMC support
iive
parents:
diff changeset
36 #ifdef HAVE_XVMC
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
37
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
38 //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
39 //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
40 //XvMC emulation could be performed
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
41
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
42 #include "xvmc_render.h"
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
43
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
44 //#include "xvmc_debug.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
45
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
46 //set s->block
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
47 inline void XVMC_init_block(MpegEncContext *s){
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
48 xvmc_render_state_t * render;
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
49 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
50 assert(render != NULL);
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
51 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
52 assert(0);
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
53 return;//make sure that this is render packet
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 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
56 }
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
57
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
58 void XVMC_pack_pblocks(MpegEncContext *s, int cbp){
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
59 int i,j;
2076
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
60 const int mb_block_count = 4+(1<<s->chroma_format);
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
61
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
62 j=0;
2076
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
63 cbp<<= 12-mb_block_count;
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
64 for(i=0; i<mb_block_count; i++){
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
65 if(cbp & (1<<11)) {
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
66 s->pblocks[i] = (short *)(&s->block[(j++)]);
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
67 }else{
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
68 s->pblocks[i] = NULL;
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
69 }
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
70 cbp+=cbp;
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
71 // 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
72 }
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
73 }
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
74
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
75 //these functions should be called on every new field or/and frame
f07e17427140 initial XvMC support
iive
parents:
diff changeset
76 //They should be safe if they are called few times for same field!
f07e17427140 initial XvMC support
iive
parents:
diff changeset
77 int XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
78 xvmc_render_state_t * render,* last, * next;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
79
f07e17427140 initial XvMC support
iive
parents:
diff changeset
80 assert(avctx != NULL);
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
81
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
82 render = (xvmc_render_state_t*)s->current_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
83 assert(render != NULL);
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
84 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
85 return -1;//make sure that this is render packet
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
86
f07e17427140 initial XvMC support
iive
parents:
diff changeset
87 render->picture_structure = s->picture_structure;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
88 render->flags = (s->first_field)? 0: XVMC_SECOND_FIELD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
89
f07e17427140 initial XvMC support
iive
parents:
diff changeset
90 //make sure that all data is drawn by XVMC_end_frame
f07e17427140 initial XvMC support
iive
parents:
diff changeset
91 assert(render->filled_mv_blocks_num==0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
92
f07e17427140 initial XvMC support
iive
parents:
diff changeset
93 render->p_future_surface = NULL;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
94 render->p_past_surface = NULL;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
95
f07e17427140 initial XvMC support
iive
parents:
diff changeset
96 switch(s->pict_type){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
97 case I_TYPE:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
98 return 0;// no prediction from other frames
f07e17427140 initial XvMC support
iive
parents:
diff changeset
99 case B_TYPE:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
100 next = (xvmc_render_state_t*)s->next_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
101 assert(next!=NULL);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
102 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
103 if(next == NULL) return -1;
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
104 if(next->magic != MP_XVMC_RENDER_MAGIC) return -1;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
105 render->p_future_surface = next->p_surface;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
106 //no return here, going to set forward prediction
f07e17427140 initial XvMC support
iive
parents:
diff changeset
107 case P_TYPE:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
108 last = (xvmc_render_state_t*)s->last_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
109 if(last == NULL)// && !s->first_field)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
110 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
111 if(last->magic != MP_XVMC_RENDER_MAGIC) return -1;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
112 assert(last->state & MP_XVMC_STATE_PREDICTION);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
113 render->p_past_surface = last->p_surface;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
114 return 0;
1848
c72589baee53 initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents: 1830
diff changeset
115 }
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
116
f07e17427140 initial XvMC support
iive
parents:
diff changeset
117 return -1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
118 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
119
f07e17427140 initial XvMC support
iive
parents:
diff changeset
120 void XVMC_field_end(MpegEncContext *s){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
121 xvmc_render_state_t * render;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
122 render = (xvmc_render_state_t*)s->current_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
123 assert(render != NULL);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
124
f07e17427140 initial XvMC support
iive
parents:
diff changeset
125 if(render->filled_mv_blocks_num > 0){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
126 // printf("xvmcvideo.c: rendering %d left blocks after last slice!!!\n",render->filled_mv_blocks_num );
f07e17427140 initial XvMC support
iive
parents:
diff changeset
127 ff_draw_horiz_band(s,0,0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
128 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
129 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
130
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
131 void XVMC_decode_mb(MpegEncContext *s){
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
132 XvMCMacroBlock * mv_block;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
133 xvmc_render_state_t * render;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
134 int i,cbp,blocks_per_mb;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
135
f07e17427140 initial XvMC support
iive
parents:
diff changeset
136 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
137
f07e17427140 initial XvMC support
iive
parents:
diff changeset
138
f07e17427140 initial XvMC support
iive
parents:
diff changeset
139 if(s->encoding){
1830
024752284c25 av_log() patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents: 1580
diff changeset
140 av_log(s->avctx, AV_LOG_ERROR, "XVMC doesn't support encoding!!!\n");
4010
rathann
parents: 3947
diff changeset
141 return;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
142 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
143
f07e17427140 initial XvMC support
iive
parents:
diff changeset
144 //from MPV_decode_mb(),
f07e17427140 initial XvMC support
iive
parents:
diff changeset
145 /* update DC predictors for P macroblocks */
f07e17427140 initial XvMC support
iive
parents:
diff changeset
146 if (!s->mb_intra) {
f07e17427140 initial XvMC support
iive
parents:
diff changeset
147 s->last_dc[0] =
f07e17427140 initial XvMC support
iive
parents:
diff changeset
148 s->last_dc[1] =
f07e17427140 initial XvMC support
iive
parents:
diff changeset
149 s->last_dc[2] = 128 << s->intra_dc_precision;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
150 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
151
f07e17427140 initial XvMC support
iive
parents:
diff changeset
152 //MC doesn't skip blocks
2628
511e3afc43e1 Ministry of English Composition, reporting for duty (and the word is "skipped", not "skiped"; "skiped" would rhyme with "hyped")
melanson
parents: 2281
diff changeset
153 s->mb_skipped = 0;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
154
f07e17427140 initial XvMC support
iive
parents:
diff changeset
155
f07e17427140 initial XvMC support
iive
parents:
diff changeset
156 // do I need to export quant when I could not perform postprocessing?
f07e17427140 initial XvMC support
iive
parents:
diff changeset
157 // anyway, it doesn't hurrt
f07e17427140 initial XvMC support
iive
parents:
diff changeset
158 s->current_picture.qscale_table[mb_xy] = s->qscale;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
159
f07e17427140 initial XvMC support
iive
parents:
diff changeset
160 //START OF XVMC specific code
f07e17427140 initial XvMC support
iive
parents:
diff changeset
161 render = (xvmc_render_state_t*)s->current_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
162 assert(render!=NULL);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
163 assert(render->magic==MP_XVMC_RENDER_MAGIC);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
164 assert(render->mv_blocks);
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
165
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
166 //take the next free macroblock
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
167 mv_block = &render->mv_blocks[render->start_mv_blocks_num +
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
168 render->filled_mv_blocks_num ];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
169
f07e17427140 initial XvMC support
iive
parents:
diff changeset
170 // memset(mv_block,0,sizeof(XvMCMacroBlock));
f07e17427140 initial XvMC support
iive
parents:
diff changeset
171
f07e17427140 initial XvMC support
iive
parents:
diff changeset
172 mv_block->x = s->mb_x;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
173 mv_block->y = s->mb_y;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
174 mv_block->dct_type = s->interlaced_dct;//XVMC_DCT_TYPE_FRAME/FIELD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
175 // mv_block->motion_type = 0; //zero to silense warnings
f07e17427140 initial XvMC support
iive
parents:
diff changeset
176 if(s->mb_intra){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
177 mv_block->macroblock_type = XVMC_MB_TYPE_INTRA;//no MC, all done
f07e17427140 initial XvMC support
iive
parents:
diff changeset
178 }else{
f07e17427140 initial XvMC support
iive
parents:
diff changeset
179 mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
180
f07e17427140 initial XvMC support
iive
parents:
diff changeset
181 if(s->mv_dir & MV_DIR_FORWARD){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
182 mv_block->macroblock_type|= XVMC_MB_TYPE_MOTION_FORWARD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
183 //pmv[n][dir][xy]=mv[dir][n][xy]
f07e17427140 initial XvMC support
iive
parents:
diff changeset
184 mv_block->PMV[0][0][0] = s->mv[0][0][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
185 mv_block->PMV[0][0][1] = s->mv[0][0][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
186 mv_block->PMV[1][0][0] = s->mv[0][1][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
187 mv_block->PMV[1][0][1] = s->mv[0][1][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
188 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
189 if(s->mv_dir & MV_DIR_BACKWARD){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
190 mv_block->macroblock_type|=XVMC_MB_TYPE_MOTION_BACKWARD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
191 mv_block->PMV[0][1][0] = s->mv[1][0][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
192 mv_block->PMV[0][1][1] = s->mv[1][0][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
193 mv_block->PMV[1][1][0] = s->mv[1][1][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
194 mv_block->PMV[1][1][1] = s->mv[1][1][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
195 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
196
f07e17427140 initial XvMC support
iive
parents:
diff changeset
197 switch(s->mv_type){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
198 case MV_TYPE_16X16:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
199 mv_block->motion_type = XVMC_PREDICTION_FRAME;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
200 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
201 case MV_TYPE_16X8:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
202 mv_block->motion_type = XVMC_PREDICTION_16x8;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
203 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
204 case MV_TYPE_FIELD:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
205 mv_block->motion_type = XVMC_PREDICTION_FIELD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
206 if(s->picture_structure == PICT_FRAME){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
207 mv_block->PMV[0][0][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
208 mv_block->PMV[1][0][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
209 mv_block->PMV[0][1][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
210 mv_block->PMV[1][1][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
211 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
212 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
213 case MV_TYPE_DMV:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
214 mv_block->motion_type = XVMC_PREDICTION_DUAL_PRIME;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
215 if(s->picture_structure == PICT_FRAME){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
216
f07e17427140 initial XvMC support
iive
parents:
diff changeset
217 mv_block->PMV[0][0][0] = s->mv[0][0][0];//top from top
f07e17427140 initial XvMC support
iive
parents:
diff changeset
218 mv_block->PMV[0][0][1] = s->mv[0][0][1]<<1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
219
f07e17427140 initial XvMC support
iive
parents:
diff changeset
220 mv_block->PMV[0][1][0] = s->mv[0][0][0];//bottom from bottom
f07e17427140 initial XvMC support
iive
parents:
diff changeset
221 mv_block->PMV[0][1][1] = s->mv[0][0][1]<<1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
222
f07e17427140 initial XvMC support
iive
parents:
diff changeset
223 mv_block->PMV[1][0][0] = s->mv[0][2][0];//dmv00, top from bottom
f07e17427140 initial XvMC support
iive
parents:
diff changeset
224 mv_block->PMV[1][0][1] = s->mv[0][2][1]<<1;//dmv01
f07e17427140 initial XvMC support
iive
parents:
diff changeset
225
f07e17427140 initial XvMC support
iive
parents:
diff changeset
226 mv_block->PMV[1][1][0] = s->mv[0][3][0];//dmv10, bottom from top
f07e17427140 initial XvMC support
iive
parents:
diff changeset
227 mv_block->PMV[1][1][1] = s->mv[0][3][1]<<1;//dmv11
f07e17427140 initial XvMC support
iive
parents:
diff changeset
228
f07e17427140 initial XvMC support
iive
parents:
diff changeset
229 }else{
f07e17427140 initial XvMC support
iive
parents:
diff changeset
230 mv_block->PMV[0][1][0] = s->mv[0][2][0];//dmv00
f07e17427140 initial XvMC support
iive
parents:
diff changeset
231 mv_block->PMV[0][1][1] = s->mv[0][2][1];//dmv01
f07e17427140 initial XvMC support
iive
parents:
diff changeset
232 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
233 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
234 default:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
235 assert(0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
236 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
237
f07e17427140 initial XvMC support
iive
parents:
diff changeset
238 mv_block->motion_vertical_field_select = 0;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
239
f07e17427140 initial XvMC support
iive
parents:
diff changeset
240 //set correct field referenses
f07e17427140 initial XvMC support
iive
parents:
diff changeset
241 if(s->mv_type == MV_TYPE_FIELD || s->mv_type == MV_TYPE_16X8){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
242 if( s->field_select[0][0] ) mv_block->motion_vertical_field_select|=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
243 if( s->field_select[1][0] ) mv_block->motion_vertical_field_select|=2;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
244 if( s->field_select[0][1] ) mv_block->motion_vertical_field_select|=4;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
245 if( s->field_select[1][1] ) mv_block->motion_vertical_field_select|=8;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
246 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
247 }//!intra
f07e17427140 initial XvMC support
iive
parents:
diff changeset
248 //time to handle data blocks;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
249 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
250
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
251 blocks_per_mb = 6;
1848
c72589baee53 initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents: 1830
diff changeset
252 if( s->chroma_format >= 2){
1849
63eafb5b1c38 fix typo
iive
parents: 1848
diff changeset
253 blocks_per_mb = 4 + (1 << (s->chroma_format));
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
254 }
1848
c72589baee53 initial chroma_format changes,xvmc tweaks and codec_cap
iive
parents: 1830
diff changeset
255
2076
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
256 // calculate cbp
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
257 cbp = 0;
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
258 for(i=0; i<blocks_per_mb; i++) {
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
259 cbp+= cbp;
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
260 if(s->block_last_index[i] >= 0)
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
261 cbp++;
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
262 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
263
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
264 if(s->flags & CODEC_FLAG_GRAY){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
265 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
266 for(i=4; i<blocks_per_mb; i++){
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
267 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
268 if(!render->unsigned_intra)
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
269 s->pblocks[i][0] = 1<<10;
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
270 }
2076
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
271 }else{
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
272 cbp&= 0xf << (blocks_per_mb - 4);
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
273 blocks_per_mb = 4;//Luminance blocks only
2076
23280e1b8dbf better cbp handling and small speedup in mpeg12
iive
parents: 1849
diff changeset
274 }
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
275 }
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
276 mv_block->coded_block_pattern = cbp;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
277 if(cbp == 0)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
278 mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
279
f07e17427140 initial XvMC support
iive
parents:
diff changeset
280 for(i=0; i<blocks_per_mb; i++){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
281 if(s->block_last_index[i] >= 0){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
282 // i do not have unsigned_intra MOCO to test, hope it is OK
f07e17427140 initial XvMC support
iive
parents:
diff changeset
283 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
284 s->pblocks[i][0]-=1<<10;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
285 if(!render->idct){
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
286 s->dsp.idct(s->pblocks[i]);
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
287 //!!TODO!clip!!!
f07e17427140 initial XvMC support
iive
parents:
diff changeset
288 }
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
289 //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
290 if(s->avctx->xvmc_acceleration == 1){
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
291 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
292 s->pblocks[i],sizeof(short)*8*8);
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
293 }else{
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
294 /* if(s->pblocks[i] != &render->data_blocks[
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
295 (render->next_free_data_block_num)*64]){
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
296 printf("ERROR mb(%d,%d) s->pblocks[i]=%p data_block[]=%p\n",
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2628
diff changeset
297 s->mb_x,s->mb_y, s->pblocks[i],
1580
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
298 &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
299 }*/
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
300 }
628bf341e099 XvMC speedup by removing one memcpy and doing MB packing
iive
parents: 1517
diff changeset
301 render->next_free_data_block_num++;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
302 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
303 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
304 render->filled_mv_blocks_num++;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
305
f07e17427140 initial XvMC support
iive
parents:
diff changeset
306 assert(render->filled_mv_blocks_num <= render->total_number_of_mv_blocks);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
307 assert(render->next_free_data_block_num <= render->total_number_of_data_blocks);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
308
f07e17427140 initial XvMC support
iive
parents:
diff changeset
309
f07e17427140 initial XvMC support
iive
parents:
diff changeset
310 if(render->filled_mv_blocks_num >= render->total_number_of_mv_blocks)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
311 ff_draw_horiz_band(s,0,0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
312
f07e17427140 initial XvMC support
iive
parents:
diff changeset
313 // DumpRenderInfo(render);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
314 // DumpMBlockInfo(mv_block);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
315
f07e17427140 initial XvMC support
iive
parents:
diff changeset
316 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
317
f07e17427140 initial XvMC support
iive
parents:
diff changeset
318 #endif