This allows to convert between formats of arbitrary width,
regardless of the value of VOF/VOFW.
| ... | ... |
@@ -122,7 +122,7 @@ typedef struct SwsContext {
|
| 122 | 122 |
int chrBufIndex; ///< Index in ring buffer of the last scaled horizontal chroma line from source. |
| 123 | 123 |
//@} |
| 124 | 124 |
|
| 125 |
- uint8_t formatConvBuffer[VOF]; //FIXME dynamic allocation, but we have to change a lot of code for this to be useful |
|
| 125 |
+ uint8_t *formatConvBuffer; |
|
| 126 | 126 |
|
| 127 | 127 |
/** |
| 128 | 128 |
* @name Horizontal and vertical filters. |
| ... | ... |
@@ -459,9 +459,10 @@ inline static void hcscale_c(SwsContext *c, uint16_t *dst, long dstWidth, |
| 459 | 459 |
src2 += c->chrSrcOffset; |
| 460 | 460 |
|
| 461 | 461 |
if (c->chrToYV12) {
|
| 462 |
- c->chrToYV12(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal); |
|
| 462 |
+ uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW, 16); |
|
| 463 |
+ c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); |
|
| 463 | 464 |
src1= formatConvBuffer; |
| 464 |
- src2= formatConvBuffer+VOFW; |
|
| 465 |
+ src2= buf2; |
|
| 465 | 466 |
} |
| 466 | 467 |
|
| 467 | 468 |
if (!c->hcscale_fast) {
|
| ... | ... |
@@ -790,10 +790,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) |
| 790 | 790 |
srcW, srcH, dstW, dstH); |
| 791 | 791 |
return AVERROR(EINVAL); |
| 792 | 792 |
} |
| 793 |
- if(srcW > VOFW || dstW > VOFW) {
|
|
| 794 |
- av_log(NULL, AV_LOG_ERROR, "swScaler: Compile-time maximum width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n"); |
|
| 795 |
- return AVERROR(EINVAL); |
|
| 796 |
- } |
|
| 793 |
+ FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW, 16) * 2, fail); |
|
| 797 | 794 |
|
| 798 | 795 |
if (!dstFilter) dstFilter= &dummyFilter; |
| 799 | 796 |
if (!srcFilter) srcFilter= &dummyFilter; |
| ... | ... |
@@ -1507,6 +1504,7 @@ void sws_freeContext(SwsContext *c) |
| 1507 | 1507 |
#endif /* HAVE_MMX */ |
| 1508 | 1508 |
|
| 1509 | 1509 |
av_freep(&c->yuvTable); |
| 1510 |
+ av_free(c->formatConvBuffer); |
|
| 1510 | 1511 |
|
| 1511 | 1512 |
av_free(c); |
| 1512 | 1513 |
} |