comparison utils.c @ 9192:6faca73d75cc libavcodec

Change linesize alignment method to ensure that linesize[0] == 2*linesize[1] for YUV420P and YUV422P always. Fixes MPEG-2 4:2:2 encoding on PPC and ARM, and should fix mxf_d10 regression.
author reimar
date Thu, 19 Mar 2009 21:34:55 +0000
parents caee3bed2145
children 9fd579338f23
comparison
equal deleted inserted replaced
9191:fa58c81d8cde 9192:6faca73d75cc
240 buf->last_pic_num= *picture_number; 240 buf->last_pic_num= *picture_number;
241 }else{ 241 }else{
242 int h_chroma_shift, v_chroma_shift; 242 int h_chroma_shift, v_chroma_shift;
243 int size[4] = {0}; 243 int size[4] = {0};
244 int tmpsize; 244 int tmpsize;
245 int unaligned;
245 AVPicture picture; 246 AVPicture picture;
246 int stride_align[4]; 247 int stride_align[4];
247 248
248 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); 249 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
249 250
252 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ 253 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
253 w+= EDGE_WIDTH*2; 254 w+= EDGE_WIDTH*2;
254 h+= EDGE_WIDTH*2; 255 h+= EDGE_WIDTH*2;
255 } 256 }
256 257
258 do {
259 // NOTE: do not align linesizes individually, this breaks e.g. assumptions
260 // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
257 ff_fill_linesize(&picture, s->pix_fmt, w); 261 ff_fill_linesize(&picture, s->pix_fmt, w);
258 262 // increase alignment of w for next try (rhs gives the lowest bit set in w)
263 w += w & ~(w-1);
264
265 unaligned = 0;
259 for (i=0; i<4; i++){ 266 for (i=0; i<4; i++){
260 //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes 267 //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
261 //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the 268 //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
262 //picture size unneccessarily in some cases. The solution here is not 269 //picture size unneccessarily in some cases. The solution here is not
263 //pretty and better ideas are welcome! 270 //pretty and better ideas are welcome!
265 if(s->codec_id == CODEC_ID_SVQ1) 272 if(s->codec_id == CODEC_ID_SVQ1)
266 stride_align[i]= 16; 273 stride_align[i]= 16;
267 else 274 else
268 #endif 275 #endif
269 stride_align[i] = STRIDE_ALIGN; 276 stride_align[i] = STRIDE_ALIGN;
270 picture.linesize[i] = ALIGN(picture.linesize[i], stride_align[i]); 277 unaligned |= picture.linesize[i] % stride_align[i];
271 } 278 }
279 } while (unaligned);
272 280
273 tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h); 281 tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h);
274 if (tmpsize < 0) 282 if (tmpsize < 0)
275 return -1; 283 return -1;
276 284