@@ -269,6 +269,34 @@ static const FormatEntry format_entries[] = {
269
269
[AV_PIX_FMT_XV36LE ] = { 1 , 1 },
270
270
};
271
271
272
+ /**
273
+ * Allocate and return an SwsContext without performing initialization.
274
+ */
275
+ static SwsContext * alloc_set_opts (int srcW , int srcH , enum AVPixelFormat srcFormat ,
276
+ int dstW , int dstH , enum AVPixelFormat dstFormat ,
277
+ int flags , const double * param )
278
+ {
279
+ SwsContext * c = sws_alloc_context ();
280
+
281
+ if (!c )
282
+ return NULL ;
283
+
284
+ c -> flags = flags ;
285
+ c -> srcW = srcW ;
286
+ c -> srcH = srcH ;
287
+ c -> dstW = dstW ;
288
+ c -> dstH = dstH ;
289
+ c -> srcFormat = srcFormat ;
290
+ c -> dstFormat = dstFormat ;
291
+
292
+ if (param ) {
293
+ c -> param [0 ] = param [0 ];
294
+ c -> param [1 ] = param [1 ];
295
+ }
296
+
297
+ return c ;
298
+ }
299
+
272
300
int ff_shuffle_filter_coefficients (SwsContext * c , int * filterPos ,
273
301
int filterSize , int16_t * filter ,
274
302
int dstW )
@@ -1101,9 +1129,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
1101
1129
if (ret < 0 )
1102
1130
return ret ;
1103
1131
1104
- c -> cascaded_context [0 ] = sws_alloc_set_opts (srcW , srcH , c -> srcFormat ,
1105
- tmp_width , tmp_height , tmp_format ,
1106
- c -> flags , c -> param );
1132
+ c -> cascaded_context [0 ] = alloc_set_opts (srcW , srcH , c -> srcFormat ,
1133
+ tmp_width , tmp_height , tmp_format ,
1134
+ c -> flags , c -> param );
1107
1135
if (!c -> cascaded_context [0 ])
1108
1136
return -1 ;
1109
1137
@@ -1116,9 +1144,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
1116
1144
srcRange , table , dstRange ,
1117
1145
brightness , contrast , saturation );
1118
1146
1119
- c -> cascaded_context [1 ] = sws_alloc_set_opts (tmp_width , tmp_height , tmp_format ,
1120
- dstW , dstH , c -> dstFormat ,
1121
- c -> flags , c -> param );
1147
+ c -> cascaded_context [1 ] = alloc_set_opts (tmp_width , tmp_height , tmp_format ,
1148
+ dstW , dstH , c -> dstFormat ,
1149
+ c -> flags , c -> param );
1122
1150
if (!c -> cascaded_context [1 ])
1123
1151
return -1 ;
1124
1152
c -> cascaded_context [1 ]-> srcRange = srcRange ;
@@ -1682,19 +1710,19 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
1682
1710
if (ret < 0 )
1683
1711
return ret ;
1684
1712
1685
- c -> cascaded_context [0 ] = sws_alloc_set_opts (srcW , srcH , srcFormat ,
1686
- srcW , srcH , tmpFormat ,
1687
- flags , c -> param );
1713
+ c -> cascaded_context [0 ] = alloc_set_opts (srcW , srcH , srcFormat ,
1714
+ srcW , srcH , tmpFormat ,
1715
+ flags , c -> param );
1688
1716
if (!c -> cascaded_context [0 ])
1689
1717
return AVERROR (EINVAL );
1690
1718
c -> cascaded_context [0 ]-> alphablend = c -> alphablend ;
1691
1719
ret = sws_init_context (c -> cascaded_context [0 ], NULL , NULL );
1692
1720
if (ret < 0 )
1693
1721
return ret ;
1694
1722
1695
- c -> cascaded_context [1 ] = sws_alloc_set_opts (srcW , srcH , tmpFormat ,
1696
- dstW , dstH , dstFormat ,
1697
- flags , c -> param );
1723
+ c -> cascaded_context [1 ] = alloc_set_opts (srcW , srcH , tmpFormat ,
1724
+ dstW , dstH , dstFormat ,
1725
+ flags , c -> param );
1698
1726
if (!c -> cascaded_context [1 ])
1699
1727
return AVERROR (EINVAL );
1700
1728
@@ -2066,41 +2094,16 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
2066
2094
return sws_init_single_context (c , srcFilter , dstFilter );
2067
2095
}
2068
2096
2069
- SwsContext * sws_alloc_set_opts (int srcW , int srcH , enum AVPixelFormat srcFormat ,
2070
- int dstW , int dstH , enum AVPixelFormat dstFormat ,
2071
- int flags , const double * param )
2072
- {
2073
- SwsContext * c ;
2074
-
2075
- if (!(c = sws_alloc_context ()))
2076
- return NULL ;
2077
-
2078
- c -> flags = flags ;
2079
- c -> srcW = srcW ;
2080
- c -> srcH = srcH ;
2081
- c -> dstW = dstW ;
2082
- c -> dstH = dstH ;
2083
- c -> srcFormat = srcFormat ;
2084
- c -> dstFormat = dstFormat ;
2085
-
2086
- if (param ) {
2087
- c -> param [0 ] = param [0 ];
2088
- c -> param [1 ] = param [1 ];
2089
- }
2090
-
2091
- return c ;
2092
- }
2093
-
2094
2097
SwsContext * sws_getContext (int srcW , int srcH , enum AVPixelFormat srcFormat ,
2095
2098
int dstW , int dstH , enum AVPixelFormat dstFormat ,
2096
2099
int flags , SwsFilter * srcFilter ,
2097
2100
SwsFilter * dstFilter , const double * param )
2098
2101
{
2099
2102
SwsContext * c ;
2100
2103
2101
- c = sws_alloc_set_opts (srcW , srcH , srcFormat ,
2102
- dstW , dstH , dstFormat ,
2103
- flags , param );
2104
+ c = alloc_set_opts (srcW , srcH , srcFormat ,
2105
+ dstW , dstH , dstFormat ,
2106
+ flags , param );
2104
2107
if (!c )
2105
2108
return NULL ;
2106
2109
0 commit comments