annotate xvmcvideo.c @ 1550:fca47124001d libavcodec

mpeg2 aspect ratio encoding fixed
author michael
date Mon, 20 Oct 2003 23:24:39 +0000
parents d107c545d745
children 628bf341e099
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 *
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
f07e17427140 initial XvMC support
iive
parents:
diff changeset
20 #include <limits.h>
f07e17427140 initial XvMC support
iive
parents:
diff changeset
21
f07e17427140 initial XvMC support
iive
parents:
diff changeset
22 //avcodec include
f07e17427140 initial XvMC support
iive
parents:
diff changeset
23 #include "avcodec.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
24 #include "dsputil.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
25 #include "mpegvideo.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
26
f07e17427140 initial XvMC support
iive
parents:
diff changeset
27 #undef NDEBUG
f07e17427140 initial XvMC support
iive
parents:
diff changeset
28 #include <assert.h>
f07e17427140 initial XvMC support
iive
parents:
diff changeset
29
f07e17427140 initial XvMC support
iive
parents:
diff changeset
30 #ifdef USE_FASTMEMCPY
f07e17427140 initial XvMC support
iive
parents:
diff changeset
31 #include "fastmemcpy.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
32 #endif
f07e17427140 initial XvMC support
iive
parents:
diff changeset
33
f07e17427140 initial XvMC support
iive
parents:
diff changeset
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
f07e17427140 initial XvMC support
iive
parents:
diff changeset
42 //#include "xvmc_debug.h"
f07e17427140 initial XvMC support
iive
parents:
diff changeset
43
f07e17427140 initial XvMC support
iive
parents:
diff changeset
44 static int calc_cbp(MpegEncContext *s, int blocknum){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
45 /* compute cbp */
f07e17427140 initial XvMC support
iive
parents:
diff changeset
46 // for I420 bit_offset=5
f07e17427140 initial XvMC support
iive
parents:
diff changeset
47 int i,cbp = 0;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
48 for(i=0; i<blocknum; i++) {
f07e17427140 initial XvMC support
iive
parents:
diff changeset
49 if(s->block_last_index[i] >= 0)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
50 cbp |= 1 << (5 - i);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
51 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
52 return cbp;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
53 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
54
f07e17427140 initial XvMC support
iive
parents:
diff changeset
55
f07e17427140 initial XvMC support
iive
parents:
diff changeset
56
f07e17427140 initial XvMC support
iive
parents:
diff changeset
57 //these functions should be called on every new field or/and frame
f07e17427140 initial XvMC support
iive
parents:
diff changeset
58 //They should be safe if they are called few times for same field!
f07e17427140 initial XvMC support
iive
parents:
diff changeset
59 int XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
60 xvmc_render_state_t * render,* last, * next;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
61
f07e17427140 initial XvMC support
iive
parents:
diff changeset
62 assert(avctx != NULL);
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
63
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
64 render = (xvmc_render_state_t*)s->current_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
65 assert(render != NULL);
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
66 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
67 return -1;//make sure that this is render packet
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
68
f07e17427140 initial XvMC support
iive
parents:
diff changeset
69 render->picture_structure = s->picture_structure;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
70 render->flags = (s->first_field)? 0: XVMC_SECOND_FIELD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
71
f07e17427140 initial XvMC support
iive
parents:
diff changeset
72 //make sure that all data is drawn by XVMC_end_frame
f07e17427140 initial XvMC support
iive
parents:
diff changeset
73 assert(render->filled_mv_blocks_num==0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
74
f07e17427140 initial XvMC support
iive
parents:
diff changeset
75 render->p_future_surface = NULL;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
76 render->p_past_surface = NULL;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
77
f07e17427140 initial XvMC support
iive
parents:
diff changeset
78 switch(s->pict_type){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
79 case I_TYPE:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
80 return 0;// no prediction from other frames
f07e17427140 initial XvMC support
iive
parents:
diff changeset
81 case B_TYPE:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
82 next = (xvmc_render_state_t*)s->next_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
83 assert(next!=NULL);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
84 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
85 if(next == NULL) return -1;
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
86 if(next->magic != MP_XVMC_RENDER_MAGIC) return -1;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
87 render->p_future_surface = next->p_surface;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
88 //no return here, going to set forward prediction
f07e17427140 initial XvMC support
iive
parents:
diff changeset
89 case P_TYPE:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
90 last = (xvmc_render_state_t*)s->last_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
91 if(last == NULL)// && !s->first_field)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
92 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
93 if(last->magic != MP_XVMC_RENDER_MAGIC) return -1;
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
94 assert(last->state & MP_XVMC_STATE_PREDICTION);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
95 render->p_past_surface = last->p_surface;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
96 return 0;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
97 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
98
f07e17427140 initial XvMC support
iive
parents:
diff changeset
99 return -1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
100 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
101
f07e17427140 initial XvMC support
iive
parents:
diff changeset
102 void XVMC_field_end(MpegEncContext *s){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
103 xvmc_render_state_t * render;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
104 render = (xvmc_render_state_t*)s->current_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
105 assert(render != NULL);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
106
f07e17427140 initial XvMC support
iive
parents:
diff changeset
107 if(render->filled_mv_blocks_num > 0){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
108 // printf("xvmcvideo.c: rendering %d left blocks after last slice!!!\n",render->filled_mv_blocks_num );
f07e17427140 initial XvMC support
iive
parents:
diff changeset
109 ff_draw_horiz_band(s,0,0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
110 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
111 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
112
f07e17427140 initial XvMC support
iive
parents:
diff changeset
113 void XVMC_decode_mb(MpegEncContext *s, DCTELEM block[6][64]){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
114 XvMCMacroBlock * mv_block;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
115 xvmc_render_state_t * render;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
116 int i,cbp,blocks_per_mb;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
117
f07e17427140 initial XvMC support
iive
parents:
diff changeset
118 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
119
f07e17427140 initial XvMC support
iive
parents:
diff changeset
120
f07e17427140 initial XvMC support
iive
parents:
diff changeset
121 if(s->encoding){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
122 fprintf(stderr,"XVMC doesn't support encoding!!!\n");
1517
d107c545d745 using av_abort
alex
parents: 1444
diff changeset
123 av_abort();
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
124 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
125
f07e17427140 initial XvMC support
iive
parents:
diff changeset
126 //from MPV_decode_mb(),
f07e17427140 initial XvMC support
iive
parents:
diff changeset
127 /* update DC predictors for P macroblocks */
f07e17427140 initial XvMC support
iive
parents:
diff changeset
128 if (!s->mb_intra) {
f07e17427140 initial XvMC support
iive
parents:
diff changeset
129 s->last_dc[0] =
f07e17427140 initial XvMC support
iive
parents:
diff changeset
130 s->last_dc[1] =
f07e17427140 initial XvMC support
iive
parents:
diff changeset
131 s->last_dc[2] = 128 << s->intra_dc_precision;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
132 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
133
f07e17427140 initial XvMC support
iive
parents:
diff changeset
134 //MC doesn't skip blocks
f07e17427140 initial XvMC support
iive
parents:
diff changeset
135 s->mb_skiped = 0;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
136
f07e17427140 initial XvMC support
iive
parents:
diff changeset
137
f07e17427140 initial XvMC support
iive
parents:
diff changeset
138 // do I need to export quant when I could not perform postprocessing?
f07e17427140 initial XvMC support
iive
parents:
diff changeset
139 // anyway, it doesn't hurrt
f07e17427140 initial XvMC support
iive
parents:
diff changeset
140 s->current_picture.qscale_table[mb_xy] = s->qscale;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
141
f07e17427140 initial XvMC support
iive
parents:
diff changeset
142 //START OF XVMC specific code
f07e17427140 initial XvMC support
iive
parents:
diff changeset
143 render = (xvmc_render_state_t*)s->current_picture.data[2];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
144 assert(render!=NULL);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
145 assert(render->magic==MP_XVMC_RENDER_MAGIC);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
146 assert(render->mv_blocks);
1392
13a02518ffb6 Add GNU header, remove X includes, add more check for xvmc render packet
iive
parents: 1381
diff changeset
147
1381
f07e17427140 initial XvMC support
iive
parents:
diff changeset
148 //take the next free macroblock
f07e17427140 initial XvMC support
iive
parents:
diff changeset
149 mv_block = &render->mv_blocks[render->start_mv_blocks_num +
f07e17427140 initial XvMC support
iive
parents:
diff changeset
150 render->filled_mv_blocks_num ];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
151
f07e17427140 initial XvMC support
iive
parents:
diff changeset
152 // memset(mv_block,0,sizeof(XvMCMacroBlock));
f07e17427140 initial XvMC support
iive
parents:
diff changeset
153
f07e17427140 initial XvMC support
iive
parents:
diff changeset
154 mv_block->x = s->mb_x;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
155 mv_block->y = s->mb_y;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
156 mv_block->dct_type = s->interlaced_dct;//XVMC_DCT_TYPE_FRAME/FIELD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
157 // mv_block->motion_type = 0; //zero to silense warnings
f07e17427140 initial XvMC support
iive
parents:
diff changeset
158 if(s->mb_intra){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
159 mv_block->macroblock_type = XVMC_MB_TYPE_INTRA;//no MC, all done
f07e17427140 initial XvMC support
iive
parents:
diff changeset
160 }else{
f07e17427140 initial XvMC support
iive
parents:
diff changeset
161 mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
162
f07e17427140 initial XvMC support
iive
parents:
diff changeset
163 if(s->mv_dir & MV_DIR_FORWARD){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
164 mv_block->macroblock_type|= XVMC_MB_TYPE_MOTION_FORWARD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
165 //pmv[n][dir][xy]=mv[dir][n][xy]
f07e17427140 initial XvMC support
iive
parents:
diff changeset
166 mv_block->PMV[0][0][0] = s->mv[0][0][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
167 mv_block->PMV[0][0][1] = s->mv[0][0][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
168 mv_block->PMV[1][0][0] = s->mv[0][1][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
169 mv_block->PMV[1][0][1] = s->mv[0][1][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
170 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
171 if(s->mv_dir & MV_DIR_BACKWARD){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
172 mv_block->macroblock_type|=XVMC_MB_TYPE_MOTION_BACKWARD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
173 mv_block->PMV[0][1][0] = s->mv[1][0][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
174 mv_block->PMV[0][1][1] = s->mv[1][0][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
175 mv_block->PMV[1][1][0] = s->mv[1][1][0];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
176 mv_block->PMV[1][1][1] = s->mv[1][1][1];
f07e17427140 initial XvMC support
iive
parents:
diff changeset
177 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
178
f07e17427140 initial XvMC support
iive
parents:
diff changeset
179 switch(s->mv_type){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
180 case MV_TYPE_16X16:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
181 mv_block->motion_type = XVMC_PREDICTION_FRAME;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
182 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
183 case MV_TYPE_16X8:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
184 mv_block->motion_type = XVMC_PREDICTION_16x8;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
185 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
186 case MV_TYPE_FIELD:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
187 mv_block->motion_type = XVMC_PREDICTION_FIELD;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
188 if(s->picture_structure == PICT_FRAME){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
189 mv_block->PMV[0][0][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
190 mv_block->PMV[1][0][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
191 mv_block->PMV[0][1][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
192 mv_block->PMV[1][1][1]<<=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
193 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
194 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
195 case MV_TYPE_DMV:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
196 mv_block->motion_type = XVMC_PREDICTION_DUAL_PRIME;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
197 if(s->picture_structure == PICT_FRAME){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
198
f07e17427140 initial XvMC support
iive
parents:
diff changeset
199 mv_block->PMV[0][0][0] = s->mv[0][0][0];//top from top
f07e17427140 initial XvMC support
iive
parents:
diff changeset
200 mv_block->PMV[0][0][1] = s->mv[0][0][1]<<1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
201
f07e17427140 initial XvMC support
iive
parents:
diff changeset
202 mv_block->PMV[0][1][0] = s->mv[0][0][0];//bottom from bottom
f07e17427140 initial XvMC support
iive
parents:
diff changeset
203 mv_block->PMV[0][1][1] = s->mv[0][0][1]<<1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
204
f07e17427140 initial XvMC support
iive
parents:
diff changeset
205 mv_block->PMV[1][0][0] = s->mv[0][2][0];//dmv00, top from bottom
f07e17427140 initial XvMC support
iive
parents:
diff changeset
206 mv_block->PMV[1][0][1] = s->mv[0][2][1]<<1;//dmv01
f07e17427140 initial XvMC support
iive
parents:
diff changeset
207
f07e17427140 initial XvMC support
iive
parents:
diff changeset
208 mv_block->PMV[1][1][0] = s->mv[0][3][0];//dmv10, bottom from top
f07e17427140 initial XvMC support
iive
parents:
diff changeset
209 mv_block->PMV[1][1][1] = s->mv[0][3][1]<<1;//dmv11
f07e17427140 initial XvMC support
iive
parents:
diff changeset
210
f07e17427140 initial XvMC support
iive
parents:
diff changeset
211 }else{
f07e17427140 initial XvMC support
iive
parents:
diff changeset
212 mv_block->PMV[0][1][0] = s->mv[0][2][0];//dmv00
f07e17427140 initial XvMC support
iive
parents:
diff changeset
213 mv_block->PMV[0][1][1] = s->mv[0][2][1];//dmv01
f07e17427140 initial XvMC support
iive
parents:
diff changeset
214 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
215 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
216 default:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
217 assert(0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
218 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
219
f07e17427140 initial XvMC support
iive
parents:
diff changeset
220 mv_block->motion_vertical_field_select = 0;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
221
f07e17427140 initial XvMC support
iive
parents:
diff changeset
222 //set correct field referenses
f07e17427140 initial XvMC support
iive
parents:
diff changeset
223 if(s->mv_type == MV_TYPE_FIELD || s->mv_type == MV_TYPE_16X8){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
224 if( s->field_select[0][0] ) mv_block->motion_vertical_field_select|=1;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
225 if( s->field_select[1][0] ) mv_block->motion_vertical_field_select|=2;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
226 if( s->field_select[0][1] ) mv_block->motion_vertical_field_select|=4;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
227 if( s->field_select[1][1] ) mv_block->motion_vertical_field_select|=8;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
228 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
229 }//!intra
f07e17427140 initial XvMC support
iive
parents:
diff changeset
230 //time to handle data blocks;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
231 mv_block->index = render->next_free_data_block_num;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
232 blocks_per_mb = 6;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
233 /*
f07e17427140 initial XvMC support
iive
parents:
diff changeset
234 switch( s->chroma_format){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
235 case CHROMA_422:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
236 blocks_per_mb = 8;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
237 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
238 case CHROMA_444:
f07e17427140 initial XvMC support
iive
parents:
diff changeset
239 blocks_per_mb = 12;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
240 break;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
241 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
242 */
f07e17427140 initial XvMC support
iive
parents:
diff changeset
243 if(s->flags & CODEC_FLAG_GRAY){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
244 if(s->mb_intra){//intra frames are alwasy full chroma block
f07e17427140 initial XvMC support
iive
parents:
diff changeset
245 memset(block[4],0,sizeof(short)*8*8);//so we need to clear them
f07e17427140 initial XvMC support
iive
parents:
diff changeset
246 memset(block[5],0,sizeof(short)*8*8);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
247 if(!render->unsigned_intra)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
248 block[4][0] = block[5][0] = 1<<10;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
249 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
250 else
f07e17427140 initial XvMC support
iive
parents:
diff changeset
251 blocks_per_mb = 4;//Luminance blocks only
f07e17427140 initial XvMC support
iive
parents:
diff changeset
252 };
f07e17427140 initial XvMC support
iive
parents:
diff changeset
253 cbp = calc_cbp(s,blocks_per_mb);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
254 mv_block->coded_block_pattern = cbp;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
255 if(cbp == 0)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
256 mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
257
f07e17427140 initial XvMC support
iive
parents:
diff changeset
258 for(i=0; i<blocks_per_mb; i++){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
259 if(s->block_last_index[i] >= 0){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
260 // i do not have unsigned_intra MOCO to test, hope it is OK
f07e17427140 initial XvMC support
iive
parents:
diff changeset
261 if( (s->mb_intra) && ( render->idct || (!render->idct && !render->unsigned_intra)) )
f07e17427140 initial XvMC support
iive
parents:
diff changeset
262 block[i][0]-=1<<10;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
263 if(!render->idct){
f07e17427140 initial XvMC support
iive
parents:
diff changeset
264 s->dsp.idct(block[i]);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
265 //!!TODO!clip!!!
f07e17427140 initial XvMC support
iive
parents:
diff changeset
266 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
267 //TODO:avoid block copy by modifying s->block pointer
f07e17427140 initial XvMC support
iive
parents:
diff changeset
268 memcpy(&render->data_blocks[(render->next_free_data_block_num++)*64],
f07e17427140 initial XvMC support
iive
parents:
diff changeset
269 block[i],sizeof(short)*8*8);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
270 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
271 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
272 render->filled_mv_blocks_num++;
f07e17427140 initial XvMC support
iive
parents:
diff changeset
273
f07e17427140 initial XvMC support
iive
parents:
diff changeset
274 assert(render->filled_mv_blocks_num <= render->total_number_of_mv_blocks);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
275 assert(render->next_free_data_block_num <= render->total_number_of_data_blocks);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
276
f07e17427140 initial XvMC support
iive
parents:
diff changeset
277
f07e17427140 initial XvMC support
iive
parents:
diff changeset
278 if(render->filled_mv_blocks_num >= render->total_number_of_mv_blocks)
f07e17427140 initial XvMC support
iive
parents:
diff changeset
279 ff_draw_horiz_band(s,0,0);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
280
f07e17427140 initial XvMC support
iive
parents:
diff changeset
281 // DumpRenderInfo(render);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
282 // DumpMBlockInfo(mv_block);
f07e17427140 initial XvMC support
iive
parents:
diff changeset
283
f07e17427140 initial XvMC support
iive
parents:
diff changeset
284 }
f07e17427140 initial XvMC support
iive
parents:
diff changeset
285
f07e17427140 initial XvMC support
iive
parents:
diff changeset
286 #endif