comparison utils.c @ 2324:ba91c976c7aa libavcodec

stride align cleanup
author michael
date Tue, 26 Oct 2004 12:47:56 +0000
parents 550ae8914fd3
children 7a6ff8cc7c95
comparison
equal deleted inserted replaced
2323:1c39d9786efd 2324:ba91c976c7aa
217 if(buf->base[0]){ 217 if(buf->base[0]){
218 pic->age= *picture_number - buf->last_pic_num; 218 pic->age= *picture_number - buf->last_pic_num;
219 buf->last_pic_num= *picture_number; 219 buf->last_pic_num= *picture_number;
220 }else{ 220 }else{
221 int h_chroma_shift, v_chroma_shift; 221 int h_chroma_shift, v_chroma_shift;
222 int s_align, pixel_size; 222 int pixel_size;
223 223
224 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); 224 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
225 225
226 switch(s->pix_fmt){ 226 switch(s->pix_fmt){
227 case PIX_FMT_RGB555: 227 case PIX_FMT_RGB555:
240 default: 240 default:
241 pixel_size=1; 241 pixel_size=1;
242 } 242 }
243 243
244 avcodec_align_dimensions(s, &w, &h); 244 avcodec_align_dimensions(s, &w, &h);
245 #if defined(ARCH_POWERPC) || defined(HAVE_MMI) //FIXME some cleaner check
246 s_align= 16;
247 #else
248 s_align= 8;
249 #endif
250 245
251 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ 246 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
252 w+= EDGE_WIDTH*2; 247 w+= EDGE_WIDTH*2;
253 h+= EDGE_WIDTH*2; 248 h+= EDGE_WIDTH*2;
254 } 249 }
258 for(i=0; i<3; i++){ 253 for(i=0; i<3; i++){
259 const int h_shift= i==0 ? 0 : h_chroma_shift; 254 const int h_shift= i==0 ? 0 : h_chroma_shift;
260 const int v_shift= i==0 ? 0 : v_chroma_shift; 255 const int v_shift= i==0 ? 0 : v_chroma_shift;
261 256
262 //FIXME next ensures that linesize= 2^x uvlinesize, thats needed because some MC code assumes it 257 //FIXME next ensures that linesize= 2^x uvlinesize, thats needed because some MC code assumes it
263 buf->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align<<(h_chroma_shift-h_shift)); 258 buf->linesize[i]= ALIGN(pixel_size*w>>h_shift, STRIDE_ALIGN<<(h_chroma_shift-h_shift));
264 259
265 buf->base[i]= av_mallocz((buf->linesize[i]*h>>v_shift)+16); //FIXME 16 260 buf->base[i]= av_mallocz((buf->linesize[i]*h>>v_shift)+16); //FIXME 16
266 if(buf->base[i]==NULL) return -1; 261 if(buf->base[i]==NULL) return -1;
267 memset(buf->base[i], 128, buf->linesize[i]*h>>v_shift); 262 memset(buf->base[i], 128, buf->linesize[i]*h>>v_shift);
268 263
269 if(s->flags&CODEC_FLAG_EMU_EDGE) 264 if(s->flags&CODEC_FLAG_EMU_EDGE)
270 buf->data[i] = buf->base[i]; 265 buf->data[i] = buf->base[i];
271 else 266 else
272 buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align); 267 buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN);
273 } 268 }
274 pic->age= 256*256*256*64; 269 pic->age= 256*256*256*64;
275 } 270 }
276 pic->type= FF_BUFFER_TYPE_INTERNAL; 271 pic->type= FF_BUFFER_TYPE_INTERNAL;
277 272