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>
... | ... |
@@ -830,8 +830,6 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], |
830 | 830 |
const AVPixFmtDescriptor *desc_dst; |
831 | 831 |
const AVPixFmtDescriptor *desc_src; |
832 | 832 |
int need_reinit = 0; |
833 |
- memmove(c->srcColorspaceTable, inv_table, sizeof(int) * 4); |
|
834 |
- memmove(c->dstColorspaceTable, table, sizeof(int) * 4); |
|
835 | 833 |
|
836 | 834 |
handle_formats(c); |
837 | 835 |
desc_dst = av_pix_fmt_desc_get(c->dstFormat); |
... | ... |
@@ -842,11 +840,24 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], |
842 | 842 |
if(!isYUV(c->srcFormat) && !isGray(c->srcFormat)) |
843 | 843 |
srcRange = 0; |
844 | 844 |
|
845 |
+ if (c->srcRange != srcRange || |
|
846 |
+ c->dstRange != dstRange || |
|
847 |
+ c->brightness != brightness || |
|
848 |
+ c->contrast != contrast || |
|
849 |
+ c->saturation != saturation || |
|
850 |
+ memcmp(c->srcColorspaceTable, inv_table, sizeof(int) * 4) || |
|
851 |
+ memcmp(c->dstColorspaceTable, table, sizeof(int) * 4) |
|
852 |
+ ) |
|
853 |
+ need_reinit = 1; |
|
854 |
+ |
|
855 |
+ memmove(c->srcColorspaceTable, inv_table, sizeof(int) * 4); |
|
856 |
+ memmove(c->dstColorspaceTable, table, sizeof(int) * 4); |
|
857 |
+ |
|
858 |
+ |
|
859 |
+ |
|
845 | 860 |
c->brightness = brightness; |
846 | 861 |
c->contrast = contrast; |
847 | 862 |
c->saturation = saturation; |
848 |
- if (c->srcRange != srcRange || c->dstRange != dstRange) |
|
849 |
- need_reinit = 1; |
|
850 | 863 |
c->srcRange = srcRange; |
851 | 864 |
c->dstRange = dstRange; |
852 | 865 |
|
... | ... |
@@ -861,6 +872,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], |
861 | 861 |
if (c->cascaded_context[0]) |
862 | 862 |
return sws_setColorspaceDetails(c->cascaded_context[0],inv_table, srcRange,table, dstRange, brightness, contrast, saturation); |
863 | 863 |
|
864 |
+ if (!need_reinit) |
|
865 |
+ return 0; |
|
866 |
+ |
|
864 | 867 |
if ((isYUV(c->dstFormat) || isGray(c->dstFormat)) && (isYUV(c->srcFormat) || isGray(c->srcFormat))) { |
865 | 868 |
if (!c->cascaded_context[0] && |
866 | 869 |
memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 4) && |