comparison mpegvideo.c @ 6445:2b553c57ec51 libavcodec

move ff_emulated_edge_mc() to dsputil
author aurel
date Tue, 04 Mar 2008 23:10:47 +0000
parents e1dd408a7864
children 588d15844c80
comparison
equal deleted inserted replaced
6444:3572cc5bc8ff 6445:2b553c57ec51
1340 } 1340 }
1341 } 1341 }
1342 } 1342 }
1343 } 1343 }
1344 1344
1345 /**
1346 * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples.
1347 * @param buf destination buffer
1348 * @param src source buffer
1349 * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
1350 * @param block_w width of block
1351 * @param block_h height of block
1352 * @param src_x x coordinate of the top left sample of the block in the source buffer
1353 * @param src_y y coordinate of the top left sample of the block in the source buffer
1354 * @param w width of the source buffer
1355 * @param h height of the source buffer
1356 */
1357 void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h,
1358 int src_x, int src_y, int w, int h){
1359 int x, y;
1360 int start_y, start_x, end_y, end_x;
1361
1362 if(src_y>= h){
1363 src+= (h-1-src_y)*linesize;
1364 src_y=h-1;
1365 }else if(src_y<=-block_h){
1366 src+= (1-block_h-src_y)*linesize;
1367 src_y=1-block_h;
1368 }
1369 if(src_x>= w){
1370 src+= (w-1-src_x);
1371 src_x=w-1;
1372 }else if(src_x<=-block_w){
1373 src+= (1-block_w-src_x);
1374 src_x=1-block_w;
1375 }
1376
1377 start_y= FFMAX(0, -src_y);
1378 start_x= FFMAX(0, -src_x);
1379 end_y= FFMIN(block_h, h-src_y);
1380 end_x= FFMIN(block_w, w-src_x);
1381
1382 // copy existing part
1383 for(y=start_y; y<end_y; y++){
1384 for(x=start_x; x<end_x; x++){
1385 buf[x + y*linesize]= src[x + y*linesize];
1386 }
1387 }
1388
1389 //top
1390 for(y=0; y<start_y; y++){
1391 for(x=start_x; x<end_x; x++){
1392 buf[x + y*linesize]= buf[x + start_y*linesize];
1393 }
1394 }
1395
1396 //bottom
1397 for(y=end_y; y<block_h; y++){
1398 for(x=start_x; x<end_x; x++){
1399 buf[x + y*linesize]= buf[x + (end_y-1)*linesize];
1400 }
1401 }
1402
1403 for(y=0; y<block_h; y++){
1404 //left
1405 for(x=0; x<start_x; x++){
1406 buf[x + y*linesize]= buf[start_x + y*linesize];
1407 }
1408
1409 //right
1410 for(x=end_x; x<block_w; x++){
1411 buf[x + y*linesize]= buf[end_x - 1 + y*linesize];
1412 }
1413 }
1414 }
1415
1416 static inline int hpel_motion_lowres(MpegEncContext *s, 1345 static inline int hpel_motion_lowres(MpegEncContext *s,
1417 uint8_t *dest, uint8_t *src, 1346 uint8_t *dest, uint8_t *src,
1418 int field_based, int field_select, 1347 int field_based, int field_select,
1419 int src_x, int src_y, 1348 int src_x, int src_y,
1420 int width, int height, int stride, 1349 int width, int height, int stride,