Needed for lazy allocation of XYZ tables.
Unified · Split
| @@ -936,7 +936,7 @@ static void fill_rgb2yuv_table(SwsInternal *c, const int table[4], int dstRange) · 935 unmodified lines | |||
| 936 | AV_WL16(p + 16*4 + 2*i, map[i] >= 0 ? c->input_rgb2yuv_table[map[i]] : 0); | 936 | AV_WL16(p + 16*4 + 2*i, map[i] >= 0 ? c->input_rgb2yuv_table[map[i]] : 0); |
| 937 | } | 937 | } |
| 938 | 938 | ||
| 939 | static void fill_xyztables(SwsInternal *c) | 939 | static int fill_xyztables(SwsInternal *c) |
| 940 | { | 940 | { |
| 941 | int i; | 941 | int i; |
| 942 | double xyzgamma = XYZ_GAMMA; | 942 | double xyzgamma = XYZ_GAMMA; |
| @@ -962,7 +962,7 @@ static void fill_xyztables(SwsInternal *c) · 19 unmodified lines | |||
| 962 | c->rgbgammainv = rgbgammainv_tab; | 962 | c->rgbgammainv = rgbgammainv_tab; |
| 963 | 963 | ||
| 964 | if (xyzgamma_tab[4095]) | 964 | if (xyzgamma_tab[4095]) |
| 965 | return; | 965 | return 0; |
| 966 | 966 | ||
| 967 | /* set input gamma vectors */ | 967 | /* set input gamma vectors */ |
| 968 | for (i = 0; i < 4096; i++) { | 968 | for (i = 0; i < 4096; i++) { |
| @@ -975,6 +975,7 @@ static void fill_xyztables(SwsInternal *c) · 6 unmodified lines | |||
| 975 | rgbgamma_tab[i] = lrint(pow(i / 65535.0, rgbgamma) * 4095.0); | 975 | rgbgamma_tab[i] = lrint(pow(i / 65535.0, rgbgamma) * 4095.0); |
| 976 | xyzgammainv_tab[i] = lrint(pow(i / 65535.0, xyzgammainv) * 4095.0); | 976 | xyzgammainv_tab[i] = lrint(pow(i / 65535.0, xyzgammainv) * 4095.0); |
| 977 | } | 977 | } |
| 978 | return 0; | ||
| 978 | } | 979 | } |
| 979 | 980 | ||
| 980 | static int handle_jpeg(enum AVPixelFormat *format) | 981 | static int handle_jpeg(enum AVPixelFormat *format) |
| @@ -1035,7 +1036,7 @@ static int handle_xyz(enum AVPixelFormat *format) · 54 unmodified lines | |||
| 1035 | } | 1036 | } |
| 1036 | } | 1037 | } |
| 1037 | 1038 | ||
| 1038 | static void handle_formats(SwsContext *sws) | 1039 | static int handle_formats(SwsContext *sws) |
| 1039 | { | 1040 | { |
| 1040 | SwsInternal *c = sws_internal(sws); | 1041 | SwsInternal *c = sws_internal(sws); |
| 1041 | c->src0Alpha |= handle_0alpha(&sws->src_format); | 1042 | c->src0Alpha |= handle_0alpha(&sws->src_format); |
| @@ -1043,7 +1044,9 @@ static void handle_formats(SwsContext *sws) · 1 unmodified line | |||
| 1043 | c->srcXYZ |= handle_xyz(&sws->src_format); | 1044 | c->srcXYZ |= handle_xyz(&sws->src_format); |
| 1044 | c->dstXYZ |= handle_xyz(&sws->dst_format); | 1045 | c->dstXYZ |= handle_xyz(&sws->dst_format); |
| 1045 | if (c->srcXYZ || c->dstXYZ) | 1046 | if (c->srcXYZ || c->dstXYZ) |
| 1046 | fill_xyztables(c); | 1047 | return fill_xyztables(c); |
| 1048 | else | ||
| 1049 | return 0; | ||
| 1047 | } | 1050 | } |
| 1048 | 1051 | ||
| 1049 | static int range_override_needed(enum AVPixelFormat format) | 1052 | static int range_override_needed(enum AVPixelFormat format) |
| @@ -1058,7 +1061,7 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 8 unmodified lines | |||
| 1058 | SwsInternal *c = sws_internal(sws); | 1061 | SwsInternal *c = sws_internal(sws); |
| 1059 | const AVPixFmtDescriptor *desc_dst; | 1062 | const AVPixFmtDescriptor *desc_dst; |
| 1060 | const AVPixFmtDescriptor *desc_src; | 1063 | const AVPixFmtDescriptor *desc_src; |
| 1061 | int need_reinit = 0; | 1064 | int ret, need_reinit = 0; |
| 1062 | 1065 | ||
| 1063 | if (c->nb_slice_ctx) { | 1066 | if (c->nb_slice_ctx) { |
| 1064 | int parent_ret = 0; | 1067 | int parent_ret = 0; |
| @@ -1073,7 +1076,9 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 8 unmodified lines | |||
| 1073 | return parent_ret; | 1076 | return parent_ret; |
| 1074 | } | 1077 | } |
| 1075 | 1078 | ||
| 1076 | handle_formats(sws); | 1079 | ret = handle_formats(sws); |
| 1080 | if (ret < 0) | ||
| 1081 | return ret; | ||
| 1077 | desc_dst = av_pix_fmt_desc_get(sws->dst_format); | 1082 | desc_dst = av_pix_fmt_desc_get(sws->dst_format); |
| 1078 | desc_src = av_pix_fmt_desc_get(sws->src_format); | 1083 | desc_src = av_pix_fmt_desc_get(sws->src_format); |
| 1079 | 1084 | ||
| @@ -1353,7 +1358,9 @@ av_cold int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter, · 273 unmodified lines | |||
| 1353 | ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], | 1358 | ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], |
| 1354 | sws->dst_range, 0, 1 << 16, 1 << 16); | 1359 | sws->dst_range, 0, 1 << 16, 1 << 16); |
| 1355 | 1360 | ||
| 1356 | handle_formats(sws); | 1361 | ret = handle_formats(sws); |
| 1362 | if (ret < 0) | ||
| 1363 | return ret; | ||
| 1357 | srcFormat = sws->src_format; | 1364 | srcFormat = sws->src_format; |
| 1358 | dstFormat = sws->dst_format; | 1365 | dstFormat = sws->dst_format; |
| 1359 | desc_src = av_pix_fmt_desc_get(srcFormat); | 1366 | desc_src = av_pix_fmt_desc_get(srcFormat); |