Mercurial > mplayer.hg
comparison libswscale/swscale.c @ 26133:94cc4bac8cd0
Turn ancient V offset numerical constants into named ones.
Add a check that checks that the width is within the chosen constant.
This might have been exploitable.
author | michael |
---|---|
date | Wed, 05 Mar 2008 03:00:25 +0000 |
parents | afd429e00184 |
children | 1b59dfbe0308 |
comparison
equal
deleted
inserted
replaced
26132:b6280829f7f8 | 26133:94cc4bac8cd0 |
---|---|
395 int v=1<<18; | 395 int v=1<<18; |
396 int j; | 396 int j; |
397 for (j=0; j<chrFilterSize; j++) | 397 for (j=0; j<chrFilterSize; j++) |
398 { | 398 { |
399 u += chrSrc[j][i] * chrFilter[j]; | 399 u += chrSrc[j][i] * chrFilter[j]; |
400 v += chrSrc[j][i + 2048] * chrFilter[j]; | 400 v += chrSrc[j][i + VOFW] * chrFilter[j]; |
401 } | 401 } |
402 | 402 |
403 uDest[i]= av_clip_uint8(u>>19); | 403 uDest[i]= av_clip_uint8(u>>19); |
404 vDest[i]= av_clip_uint8(v>>19); | 404 vDest[i]= av_clip_uint8(v>>19); |
405 } | 405 } |
431 int v=1<<18; | 431 int v=1<<18; |
432 int j; | 432 int j; |
433 for (j=0; j<chrFilterSize; j++) | 433 for (j=0; j<chrFilterSize; j++) |
434 { | 434 { |
435 u += chrSrc[j][i] * chrFilter[j]; | 435 u += chrSrc[j][i] * chrFilter[j]; |
436 v += chrSrc[j][i + 2048] * chrFilter[j]; | 436 v += chrSrc[j][i + VOFW] * chrFilter[j]; |
437 } | 437 } |
438 | 438 |
439 uDest[2*i]= av_clip_uint8(u>>19); | 439 uDest[2*i]= av_clip_uint8(u>>19); |
440 uDest[2*i+1]= av_clip_uint8(v>>19); | 440 uDest[2*i+1]= av_clip_uint8(v>>19); |
441 } | 441 } |
446 int v=1<<18; | 446 int v=1<<18; |
447 int j; | 447 int j; |
448 for (j=0; j<chrFilterSize; j++) | 448 for (j=0; j<chrFilterSize; j++) |
449 { | 449 { |
450 u += chrSrc[j][i] * chrFilter[j]; | 450 u += chrSrc[j][i] * chrFilter[j]; |
451 v += chrSrc[j][i + 2048] * chrFilter[j]; | 451 v += chrSrc[j][i + VOFW] * chrFilter[j]; |
452 } | 452 } |
453 | 453 |
454 uDest[2*i]= av_clip_uint8(v>>19); | 454 uDest[2*i]= av_clip_uint8(v>>19); |
455 uDest[2*i+1]= av_clip_uint8(u>>19); | 455 uDest[2*i+1]= av_clip_uint8(u>>19); |
456 } | 456 } |
472 Y2 += lumSrc[j][i2+1] * lumFilter[j];\ | 472 Y2 += lumSrc[j][i2+1] * lumFilter[j];\ |
473 }\ | 473 }\ |
474 for (j=0; j<chrFilterSize; j++)\ | 474 for (j=0; j<chrFilterSize; j++)\ |
475 {\ | 475 {\ |
476 U += chrSrc[j][i] * chrFilter[j];\ | 476 U += chrSrc[j][i] * chrFilter[j];\ |
477 V += chrSrc[j][i+2048] * chrFilter[j];\ | 477 V += chrSrc[j][i+VOFW] * chrFilter[j];\ |
478 }\ | 478 }\ |
479 Y1>>=19;\ | 479 Y1>>=19;\ |
480 Y2>>=19;\ | 480 Y2>>=19;\ |
481 U >>=19;\ | 481 U >>=19;\ |
482 V >>=19;\ | 482 V >>=19;\ |
502 for (i=0; i<(dstW>>1); i++){ \ | 502 for (i=0; i<(dstW>>1); i++){ \ |
503 const int i2= 2*i; \ | 503 const int i2= 2*i; \ |
504 int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>19; \ | 504 int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>19; \ |
505 int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>19; \ | 505 int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>19; \ |
506 int U= (uvbuf0[i ]*uvalpha1+uvbuf1[i ]*uvalpha)>>19; \ | 506 int U= (uvbuf0[i ]*uvalpha1+uvbuf1[i ]*uvalpha)>>19; \ |
507 int V= (uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19; \ | 507 int V= (uvbuf0[i+VOFW]*uvalpha1+uvbuf1[i+VOFW]*uvalpha)>>19; \ |
508 | 508 |
509 #define YSCALE_YUV_2_RGB2_C(type) \ | 509 #define YSCALE_YUV_2_RGB2_C(type) \ |
510 YSCALE_YUV_2_PACKED2_C\ | 510 YSCALE_YUV_2_PACKED2_C\ |
511 type *r, *b, *g;\ | 511 type *r, *b, *g;\ |
512 r = (type *)c->table_rV[V];\ | 512 r = (type *)c->table_rV[V];\ |
517 for (i=0; i<(dstW>>1); i++){\ | 517 for (i=0; i<(dstW>>1); i++){\ |
518 const int i2= 2*i;\ | 518 const int i2= 2*i;\ |
519 int Y1= buf0[i2 ]>>7;\ | 519 int Y1= buf0[i2 ]>>7;\ |
520 int Y2= buf0[i2+1]>>7;\ | 520 int Y2= buf0[i2+1]>>7;\ |
521 int U= (uvbuf1[i ])>>7;\ | 521 int U= (uvbuf1[i ])>>7;\ |
522 int V= (uvbuf1[i+2048])>>7;\ | 522 int V= (uvbuf1[i+VOFW])>>7;\ |
523 | 523 |
524 #define YSCALE_YUV_2_RGB1_C(type) \ | 524 #define YSCALE_YUV_2_RGB1_C(type) \ |
525 YSCALE_YUV_2_PACKED1_C\ | 525 YSCALE_YUV_2_PACKED1_C\ |
526 type *r, *b, *g;\ | 526 type *r, *b, *g;\ |
527 r = (type *)c->table_rV[V];\ | 527 r = (type *)c->table_rV[V];\ |
532 for (i=0; i<(dstW>>1); i++){\ | 532 for (i=0; i<(dstW>>1); i++){\ |
533 const int i2= 2*i;\ | 533 const int i2= 2*i;\ |
534 int Y1= buf0[i2 ]>>7;\ | 534 int Y1= buf0[i2 ]>>7;\ |
535 int Y2= buf0[i2+1]>>7;\ | 535 int Y2= buf0[i2+1]>>7;\ |
536 int U= (uvbuf0[i ] + uvbuf1[i ])>>8;\ | 536 int U= (uvbuf0[i ] + uvbuf1[i ])>>8;\ |
537 int V= (uvbuf0[i+2048] + uvbuf1[i+2048])>>8;\ | 537 int V= (uvbuf0[i+VOFW] + uvbuf1[i+VOFW])>>8;\ |
538 | 538 |
539 #define YSCALE_YUV_2_RGB1B_C(type) \ | 539 #define YSCALE_YUV_2_RGB1B_C(type) \ |
540 YSCALE_YUV_2_PACKED1B_C\ | 540 YSCALE_YUV_2_PACKED1B_C\ |
541 type *r, *b, *g;\ | 541 type *r, *b, *g;\ |
542 r = (type *)c->table_rV[V];\ | 542 r = (type *)c->table_rV[V];\ |
2076 { | 2076 { |
2077 av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n", | 2077 av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n", |
2078 srcW, srcH, dstW, dstH); | 2078 srcW, srcH, dstW, dstH); |
2079 return NULL; | 2079 return NULL; |
2080 } | 2080 } |
2081 if(srcW > VOFW || dstW > VOFW){ | |
2082 av_log(NULL, AV_LOG_ERROR, "swScaler: Compile time max width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n"); | |
2083 return NULL; | |
2084 } | |
2081 | 2085 |
2082 if (!dstFilter) dstFilter= &dummyFilter; | 2086 if (!dstFilter) dstFilter= &dummyFilter; |
2083 if (!srcFilter) srcFilter= &dummyFilter; | 2087 if (!srcFilter) srcFilter= &dummyFilter; |
2084 | 2088 |
2085 c= av_mallocz(sizeof(SwsContext)); | 2089 c= av_mallocz(sizeof(SwsContext)); |
2382 c->lumPixBuf= av_malloc(c->vLumBufSize*2*sizeof(int16_t*)); | 2386 c->lumPixBuf= av_malloc(c->vLumBufSize*2*sizeof(int16_t*)); |
2383 c->chrPixBuf= av_malloc(c->vChrBufSize*2*sizeof(int16_t*)); | 2387 c->chrPixBuf= av_malloc(c->vChrBufSize*2*sizeof(int16_t*)); |
2384 //Note we need at least one pixel more at the end because of the mmx code (just in case someone wanna replace the 4000/8000) | 2388 //Note we need at least one pixel more at the end because of the mmx code (just in case someone wanna replace the 4000/8000) |
2385 /* align at 16 bytes for AltiVec */ | 2389 /* align at 16 bytes for AltiVec */ |
2386 for (i=0; i<c->vLumBufSize; i++) | 2390 for (i=0; i<c->vLumBufSize; i++) |
2387 c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= av_mallocz(4000); | 2391 c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= av_mallocz(VOF+1); |
2388 for (i=0; i<c->vChrBufSize; i++) | 2392 for (i=0; i<c->vChrBufSize; i++) |
2389 c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= av_malloc(8000); | 2393 c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= av_malloc((VOF+1)*2); |
2390 | 2394 |
2391 //try to avoid drawing green stuff between the right end and the stride end | 2395 //try to avoid drawing green stuff between the right end and the stride end |
2392 for (i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, 8000); | 2396 for (i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, (VOF+1)*2); |
2397 | |
2398 assert(2*VOF == VOFW); | |
2393 | 2399 |
2394 ASSERT(c->chrDstH <= dstH) | 2400 ASSERT(c->chrDstH <= dstH) |
2395 | 2401 |
2396 if (flags&SWS_PRINT_INFO) | 2402 if (flags&SWS_PRINT_INFO) |
2397 { | 2403 { |