Ticket #1655: aligndim.diff
| File aligndim.diff, 3.9 KB (added by , 17 years ago) |
|---|
-
libavcodec/utils.c
117 117 118 118 #define INTERNAL_BUFFER_SIZE 32 119 119 120 void avcodec_align_dimensions (AVCodecContext *s, int *width, int *height){120 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int *linesize_align){ 121 121 int w_align= 1; 122 122 int h_align= 1; 123 123 … … 180 180 *height= FFALIGN(*height, h_align); 181 181 if(s->codec_id == CODEC_ID_H264) 182 182 *height+=2; // some of the optimized chroma MC reads one line too much 183 184 *linesize_align = STRIDE_ALIGN; 185 //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes 186 //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the 187 //picture size unneccessarily in some cases. The solution here is not 188 //pretty and better ideas are welcome! 189 #if HAVE_MMX 190 if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 || 191 s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F || 192 s->codec_id == CODEC_ID_VP6A) 193 *linesize_align = 16; 194 #endif 183 195 } 184 196 197 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ 198 int linesize_align; 199 avcodec_align_dimensions2(s, width, height, &linesize_align); 200 *width=FFALIGN(*width, 2*linesize_align); 201 } 202 185 203 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){ 186 204 if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) 187 205 return 0; … … 260 278 261 279 unaligned = 0; 262 280 for (i=0; i<4; i++){ 263 //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes264 //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the265 //picture size unneccessarily in some cases. The solution here is not266 //pretty and better ideas are welcome!267 #if HAVE_MMX268 if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||269 s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||270 s->codec_id == CODEC_ID_VP6A)271 stride_align[i]= 16;272 else273 #endif274 281 stride_align[i] = STRIDE_ALIGN; 275 282 unaligned |= picture.linesize[i] % stride_align[i]; 276 283 } -
libavcodec/avcodec.h
1367 1367 /** 1368 1368 * Called at the beginning of each frame to get a buffer for it. 1369 1369 * If pic.reference is set then the frame will be read later by libavcodec. 1370 * avcodec_align_dimensions () should be used to find the required width and1370 * avcodec_align_dimensions2() should be used to find the required width and 1371 1371 * height, as they normally need to be rounded up to the next multiple of 16. 1372 1372 * if CODEC_CAP_DR1 is not set then get_buffer() must call 1373 1373 * avcodec_default_get_buffer() instead of providing buffers allocated by … … 3226 3226 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); 3227 3227 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); 3228 3228 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); 3229 /** 3230 * Modifies width and height values so that they will result in a memory 3231 * buffer that is acceptable for the codec if you do not use any horizontal 3232 * padding. 3233 */ 3229 3234 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); 3235 /** 3236 * Modifies width and height values so that they will result in a memory 3237 * buffer that is acceptable for the codec if you also ensure that all 3238 * line sizes are a multiple of linesize_align. 3239 */ 3240 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, 3241 int *linesize_align); 3230 3242 3231 3243 /** 3232 3244 * Checks if the given dimension of a picture is valid, meaning that all
