mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
swscale/utils: Detect and skip unneeded sws_setColorspaceDetails() calls
This avoids running various table inits unnecessarily Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
8f3a9a8c27
commit
cc538e9dbd
@ -832,8 +832,6 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
|
|||||||
const AVPixFmtDescriptor *desc_dst;
|
const AVPixFmtDescriptor *desc_dst;
|
||||||
const AVPixFmtDescriptor *desc_src;
|
const AVPixFmtDescriptor *desc_src;
|
||||||
int need_reinit = 0;
|
int need_reinit = 0;
|
||||||
memmove(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
|
|
||||||
memmove(c->dstColorspaceTable, table, sizeof(int) * 4);
|
|
||||||
|
|
||||||
handle_formats(c);
|
handle_formats(c);
|
||||||
desc_dst = av_pix_fmt_desc_get(c->dstFormat);
|
desc_dst = av_pix_fmt_desc_get(c->dstFormat);
|
||||||
@ -844,11 +842,24 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
|
|||||||
if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
|
if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
|
||||||
srcRange = 0;
|
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->brightness = brightness;
|
||||||
c->contrast = contrast;
|
c->contrast = contrast;
|
||||||
c->saturation = saturation;
|
c->saturation = saturation;
|
||||||
if (c->srcRange != srcRange || c->dstRange != dstRange)
|
|
||||||
need_reinit = 1;
|
|
||||||
c->srcRange = srcRange;
|
c->srcRange = srcRange;
|
||||||
c->dstRange = dstRange;
|
c->dstRange = dstRange;
|
||||||
|
|
||||||
@ -863,6 +874,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
|
|||||||
if (c->cascaded_context[c->cascaded_mainindex])
|
if (c->cascaded_context[c->cascaded_mainindex])
|
||||||
return sws_setColorspaceDetails(c->cascaded_context[c->cascaded_mainindex],inv_table, srcRange,table, dstRange, brightness, contrast, saturation);
|
return sws_setColorspaceDetails(c->cascaded_context[c->cascaded_mainindex],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 ((isYUV(c->dstFormat) || isGray(c->dstFormat)) && (isYUV(c->srcFormat) || isGray(c->srcFormat))) {
|
||||||
if (!c->cascaded_context[0] &&
|
if (!c->cascaded_context[0] &&
|
||||||
memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 4) &&
|
memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 4) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user