History

swscale/utils: add return code to fill_xyztables()

Needed for lazy allocation of XYZ tables.

Niklas Haas committed 1 year ago

Commit 60bfafc1 parent af6d52e1 file · +14 −7Browse files

Unified · Split

libswscale/utils.c+14−7
@@ -936,7 +936,7 @@ static void fill_rgb2yuv_table(SwsInternal *c, const int table[4], int dstRange) · 935 unmodified lines
936936 AV_WL16(p + 16*4 + 2*i, map[i] >= 0 ? c->input_rgb2yuv_table[map[i]] : 0);
937937 }
938938
939−static void fill_xyztables(SwsInternal *c)
939+static int fill_xyztables(SwsInternal *c)
940940 {
941941 int i;
942942 double xyzgamma = XYZ_GAMMA;
@@ -962,7 +962,7 @@ static void fill_xyztables(SwsInternal *c) · 19 unmodified lines
962962 c->rgbgammainv = rgbgammainv_tab;
963963
964964 if (xyzgamma_tab[4095])
965− return;
965+ return 0;
966966
967967 /* set input gamma vectors */
968968 for (i = 0; i < 4096; i++) {
@@ -975,6 +975,7 @@ static void fill_xyztables(SwsInternal *c) · 6 unmodified lines
975975 rgbgamma_tab[i] = lrint(pow(i / 65535.0, rgbgamma) * 4095.0);
976976 xyzgammainv_tab[i] = lrint(pow(i / 65535.0, xyzgammainv) * 4095.0);
977977 }
978+ return 0;
978979 }
979980
980981 static int handle_jpeg(enum AVPixelFormat *format)
@@ -1035,7 +1036,7 @@ static int handle_xyz(enum AVPixelFormat *format) · 54 unmodified lines
10351036 }
10361037 }
10371038
1038−static void handle_formats(SwsContext *sws)
1039+static int handle_formats(SwsContext *sws)
10391040 {
10401041 SwsInternal *c = sws_internal(sws);
10411042 c->src0Alpha |= handle_0alpha(&sws->src_format);
@@ -1043,7 +1044,9 @@ static void handle_formats(SwsContext *sws) · 1 unmodified line
10431044 c->srcXYZ |= handle_xyz(&sws->src_format);
10441045 c->dstXYZ |= handle_xyz(&sws->dst_format);
10451046 if (c->srcXYZ || c->dstXYZ)
1046− fill_xyztables(c);
1047+ return fill_xyztables(c);
1048+ else
1049+ return 0;
10471050 }
10481051
10491052 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
10581061 SwsInternal *c = sws_internal(sws);
10591062 const AVPixFmtDescriptor *desc_dst;
10601063 const AVPixFmtDescriptor *desc_src;
1061− int need_reinit = 0;
1064+ int ret, need_reinit = 0;
10621065
10631066 if (c->nb_slice_ctx) {
10641067 int parent_ret = 0;
@@ -1073,7 +1076,9 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 8 unmodified lines
10731076 return parent_ret;
10741077 }
10751078
1076− handle_formats(sws);
1079+ ret = handle_formats(sws);
1080+ if (ret < 0)
1081+ return ret;
10771082 desc_dst = av_pix_fmt_desc_get(sws->dst_format);
10781083 desc_src = av_pix_fmt_desc_get(sws->src_format);
10791084
@@ -1353,7 +1358,9 @@ av_cold int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter, · 273 unmodified lines
13531358 ff_yuv2rgb_coeffs[SWS_CS_DEFAULT],
13541359 sws->dst_range, 0, 1 << 16, 1 << 16);
13551360
1356− handle_formats(sws);
1361+ ret = handle_formats(sws);
1362+ if (ret < 0)
1363+ return ret;
13571364 srcFormat = sws->src_format;
13581365 dstFormat = sws->dst_format;
13591366 desc_src = av_pix_fmt_desc_get(srcFormat);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t