aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-10-04 13:51:42 +0200
committerNiklas Haas <git@haasn.dev>2024-10-07 19:51:34 +0200
commit286bdc9cdc6deea081aeff70dfc0e0254be5e283 (patch)
tree9ed842d433fc10ed3b845ae2199e3ca6ff7c8a6c
parent61369484f62e21999116e9b806d0eb4a7cc6a7b4 (diff)
downloadffmpeg-286bdc9cdc6deea081aeff70dfc0e0254be5e283.tar.gz
swscale/internal: turn cascaded_tmp into an array
Slightly more convenient to access from the new wrapping code. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
-rw-r--r--libswscale/swscale.c20
-rw-r--r--libswscale/swscale_internal.h6
-rw-r--r--libswscale/utils.c16
3 files changed, 20 insertions, 22 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index ad0cde6ad8..8cb34570f3 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -837,26 +837,26 @@ static int scale_gamma(SwsContext *c,
{
int ret = scale_internal(c->cascaded_context[0],
srcSlice, srcStride, srcSliceY, srcSliceH,
- c->cascaded_tmp, c->cascaded_tmpStride, 0, c->srcH);
+ c->cascaded_tmp[0], c->cascaded_tmpStride[0], 0, c->srcH);
if (ret < 0)
return ret;
if (c->cascaded_context[2])
- ret = scale_internal(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp,
- c->cascaded_tmpStride, srcSliceY, srcSliceH,
- c->cascaded1_tmp, c->cascaded1_tmpStride, 0, c->dstH);
+ ret = scale_internal(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp[0],
+ c->cascaded_tmpStride[0], srcSliceY, srcSliceH,
+ c->cascaded_tmp[1], c->cascaded_tmpStride[1], 0, c->dstH);
else
- ret = scale_internal(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp,
- c->cascaded_tmpStride, srcSliceY, srcSliceH,
+ ret = scale_internal(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp[0],
+ c->cascaded_tmpStride[0], srcSliceY, srcSliceH,
dstSlice, dstStride, dstSliceY, dstSliceH);
if (ret < 0)
return ret;
if (c->cascaded_context[2]) {
- ret = scale_internal(c->cascaded_context[2], (const uint8_t * const *)c->cascaded1_tmp,
- c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret,
+ ret = scale_internal(c->cascaded_context[2], (const uint8_t * const *)c->cascaded_tmp[1],
+ c->cascaded_tmpStride[1], c->cascaded_context[1]->dstY - ret,
c->cascaded_context[1]->dstY,
dstSlice, dstStride, dstSliceY, dstSliceH);
}
@@ -871,12 +871,12 @@ static int scale_cascaded(SwsContext *c,
{
int ret = scale_internal(c->cascaded_context[0],
srcSlice, srcStride, srcSliceY, srcSliceH,
- c->cascaded_tmp, c->cascaded_tmpStride,
+ c->cascaded_tmp[0], c->cascaded_tmpStride[0],
0, c->cascaded_context[0]->dstH);
if (ret < 0)
return ret;
ret = scale_internal(c->cascaded_context[1],
- (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride,
+ (const uint8_t * const * )c->cascaded_tmp[0], c->cascaded_tmpStride[0],
0, c->cascaded_context[0]->dstH,
dstSlice, dstStride, dstSliceY, dstSliceH);
return ret;
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 66d0664721..b8d198a9f4 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -351,10 +351,8 @@ typedef struct SwsContext {
* downscaling factor that needs to be supported in one scaler.
*/
struct SwsContext *cascaded_context[3];
- int cascaded_tmpStride[4];
- uint8_t *cascaded_tmp[4];
- int cascaded1_tmpStride[4];
- uint8_t *cascaded1_tmp[4];
+ int cascaded_tmpStride[2][4];
+ uint8_t *cascaded_tmp[2][4];
int cascaded_mainindex;
double gamma_value;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c3154d82c1..642e34c46c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1133,7 +1133,7 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
tmp_height = srcH;
}
- ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
+ ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0],
tmp_width, tmp_height, tmp_format, 64);
if (ret < 0)
return ret;
@@ -1613,7 +1613,7 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
SwsContext *c2;
c->cascaded_context[0] = NULL;
- ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
+ ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0],
srcW, srcH, tmpFmt, 64);
if (ret < 0)
return ret;
@@ -1651,7 +1651,7 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
c->cascaded_context[2] = NULL;
if (dstFormat != tmpFmt) {
- ret = av_image_alloc(c->cascaded1_tmp, c->cascaded1_tmpStride,
+ ret = av_image_alloc(c->cascaded_tmp[1], c->cascaded_tmpStride[1],
dstW, dstH, tmpFmt, 64);
if (ret < 0)
return ret;
@@ -1671,7 +1671,7 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
dstFormat != AV_PIX_FMT_RGB48)) {
enum AVPixelFormat tmpFormat = isBayer16BPS(srcFormat) ? AV_PIX_FMT_RGB48 : AV_PIX_FMT_RGB24;
- ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
+ ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0],
srcW, srcH, tmpFormat, 64);
if (ret < 0)
return ret;
@@ -1714,7 +1714,7 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
c->srcRange != c->dstRange
) {
c->cascaded_mainindex = 1;
- ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
+ ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0],
srcW, srcH, tmpFormat, 64);
if (ret < 0)
return ret;
@@ -1996,7 +1996,7 @@ fail: // FIXME replace things by appropriate error codes
if (srcW*(int64_t)srcH <= 4LL*dstW*dstH)
return AVERROR(EINVAL);
- ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
+ ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0],
tmpW, tmpH, tmpFormat, 64);
if (ret < 0)
return ret;
@@ -2490,8 +2490,8 @@ void sws_freeContext(SwsContext *c)
sws_freeContext(c->cascaded_context[1]);
sws_freeContext(c->cascaded_context[2]);
memset(c->cascaded_context, 0, sizeof(c->cascaded_context));
- av_freep(&c->cascaded_tmp[0]);
- av_freep(&c->cascaded1_tmp[0]);
+ av_freep(&c->cascaded_tmp[0][0]);
+ av_freep(&c->cascaded_tmp[1][0]);
av_freep(&c->gamma);
av_freep(&c->inv_gamma);