Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-01-14 17:11:48 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-15 14:30:41 +0300
commitcdac68fbab6923a71431709c2109bd60d0f90bbd (patch)
tree0ae16324bb097838c35dcb9979d66191401f03f7 /libswscale/utils.c
parent1fd955606216e0b05bdf2f345d9e5c9b5455118c (diff)
swscale/utils: Detect and skip unneeded sws_setColorspaceDetails() calls
This avoids running various table inits unnecessarily Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit cc538e9dbd14b61d1ac8c9fa687d83289673fe90) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r--libswscale/utils.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c
index a108d99b8f..37820f68aa 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -830,8 +830,6 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
const AVPixFmtDescriptor *desc_dst;
const AVPixFmtDescriptor *desc_src;
int need_reinit = 0;
- memmove(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
- memmove(c->dstColorspaceTable, table, sizeof(int) * 4);
handle_formats(c);
desc_dst = av_pix_fmt_desc_get(c->dstFormat);
@@ -842,11 +840,24 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
srcRange = 0;
+ if (c->srcRange != srcRange ||
+ c->dstRange != dstRange ||
+ c->brightness != brightness ||
+ c->contrast != contrast ||
+ c->saturation != saturation ||
+ memcmp(c->srcColorspaceTable, inv_table, sizeof(int) * 4) ||
+ memcmp(c->dstColorspaceTable, table, sizeof(int) * 4)
+ )
+ need_reinit = 1;
+
+ memmove(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
+ memmove(c->dstColorspaceTable, table, sizeof(int) * 4);
+
+
+
c->brightness = brightness;
c->contrast = contrast;
c->saturation = saturation;
- if (c->srcRange != srcRange || c->dstRange != dstRange)
- need_reinit = 1;
c->srcRange = srcRange;
c->dstRange = dstRange;
@@ -861,6 +872,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
if (c->cascaded_context[0])
return sws_setColorspaceDetails(c->cascaded_context[0],inv_table, srcRange,table, dstRange, brightness, contrast, saturation);
+ if (!need_reinit)
+ return 0;
+
if ((isYUV(c->dstFormat) || isGray(c->dstFormat)) && (isYUV(c->srcFormat) || isGray(c->srcFormat))) {
if (!c->cascaded_context[0] &&
memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 4) &&