@@ -44,10 +44,9 @@ static int pass_alloc_output(SwsPass *pass)
44
44
pass -> num_slices * pass -> slice_h , pass -> format , 64 );
45
45
}
46
46
47
- /* slice_align should be a power of two, or 0 to disable slice threading */
48
- static SwsPass * pass_add (SwsGraph * graph , void * priv , enum AVPixelFormat fmt ,
49
- int w , int h , SwsPass * input , int slice_align ,
50
- sws_filter_run_t run )
47
+ SwsPass * ff_sws_graph_add_pass (SwsGraph * graph , enum AVPixelFormat fmt ,
48
+ int width , int height , SwsPass * input ,
49
+ int align , void * priv , sws_filter_run_t run )
51
50
{
52
51
int ret ;
53
52
SwsPass * pass = av_mallocz (sizeof (* pass ));
@@ -58,8 +57,8 @@ static SwsPass *pass_add(SwsGraph *graph, void *priv, enum AVPixelFormat fmt,
58
57
pass -> run = run ;
59
58
pass -> priv = priv ;
60
59
pass -> format = fmt ;
61
- pass -> width = w ;
62
- pass -> height = h ;
60
+ pass -> width = width ;
61
+ pass -> height = height ;
63
62
pass -> input = input ;
64
63
pass -> output .fmt = AV_PIX_FMT_NONE ;
65
64
@@ -69,12 +68,12 @@ static SwsPass *pass_add(SwsGraph *graph, void *priv, enum AVPixelFormat fmt,
69
68
return NULL ;
70
69
}
71
70
72
- if (!slice_align ) {
71
+ if (!align ) {
73
72
pass -> slice_h = pass -> height ;
74
73
pass -> num_slices = 1 ;
75
74
} else {
76
75
pass -> slice_h = (pass -> height + graph -> num_threads - 1 ) / graph -> num_threads ;
77
- pass -> slice_h = FFALIGN (pass -> slice_h , slice_align );
76
+ pass -> slice_h = FFALIGN (pass -> slice_h , align );
78
77
pass -> num_slices = (pass -> height + pass -> slice_h - 1 ) / pass -> slice_h ;
79
78
}
80
79
@@ -84,12 +83,11 @@ static SwsPass *pass_add(SwsGraph *graph, void *priv, enum AVPixelFormat fmt,
84
83
return pass ;
85
84
}
86
85
87
- /* Wrapper around pass_add that chains a pass "in-place" */
88
- static int pass_append (SwsGraph * graph , void * priv , enum AVPixelFormat fmt ,
89
- int w , int h , SwsPass * * pass , int slice_align ,
90
- sws_filter_run_t run )
86
+ /* Wrapper around ff_sws_graph_add_pass() that chains a pass "in-place" */
87
+ static int pass_append (SwsGraph * graph , enum AVPixelFormat fmt , int w , int h ,
88
+ SwsPass * * pass , int align , void * priv , sws_filter_run_t run )
91
89
{
92
- SwsPass * new = pass_add (graph , priv , fmt , w , h , * pass , slice_align , run );
90
+ SwsPass * new = ff_sws_graph_add_pass (graph , fmt , w , h , * pass , align , priv , run );
93
91
if (!new )
94
92
return AVERROR (ENOMEM );
95
93
* pass = new ;
@@ -325,19 +323,19 @@ static int init_legacy_subpass(SwsGraph *graph, SwsContext *sws,
325
323
align = 0 ; /* disable slice threading */
326
324
327
325
if (c -> src0Alpha && !c -> dst0Alpha && isALPHA (sws -> dst_format )) {
328
- ret = pass_append (graph , c , AV_PIX_FMT_RGBA , src_w , src_h , & input , 1 , run_rgb0 );
326
+ ret = pass_append (graph , AV_PIX_FMT_RGBA , src_w , src_h , & input , 1 , c , run_rgb0 );
329
327
if (ret < 0 )
330
328
return ret ;
331
329
}
332
330
333
331
if (c -> srcXYZ && !(c -> dstXYZ && unscaled )) {
334
- ret = pass_append (graph , c , AV_PIX_FMT_RGB48 , src_w , src_h , & input , 1 , run_xyz2rgb );
332
+ ret = pass_append (graph , AV_PIX_FMT_RGB48 , src_w , src_h , & input , 1 , c , run_xyz2rgb );
335
333
if (ret < 0 )
336
334
return ret ;
337
335
}
338
336
339
- pass = pass_add (graph , sws , sws -> dst_format , dst_w , dst_h , input , align ,
340
- c -> convert_unscaled ? run_legacy_unscaled : run_legacy_swscale );
337
+ pass = ff_sws_graph_add_pass (graph , sws -> dst_format , dst_w , dst_h , input , align , sws ,
338
+ c -> convert_unscaled ? run_legacy_unscaled : run_legacy_swscale );
341
339
if (!pass )
342
340
return AVERROR (ENOMEM );
343
341
pass -> setup = setup_legacy_swscale ;
@@ -387,7 +385,7 @@ static int init_legacy_subpass(SwsGraph *graph, SwsContext *sws,
387
385
}
388
386
389
387
if (c -> dstXYZ && !(c -> srcXYZ && unscaled )) {
390
- ret = pass_append (graph , c , AV_PIX_FMT_RGB48 , dst_w , dst_h , & pass , 1 , run_rgb2xyz );
388
+ ret = pass_append (graph , AV_PIX_FMT_RGB48 , dst_w , dst_h , & pass , 1 , c , run_rgb2xyz );
391
389
if (ret < 0 )
392
390
return ret ;
393
391
}
@@ -548,8 +546,8 @@ static int adapt_colors(SwsGraph *graph, SwsFormat src, SwsFormat dst,
548
546
return ret ;
549
547
}
550
548
551
- pass = pass_add (graph , lut , fmt_out , src .width , src .height ,
552
- input , 1 , run_lut3d );
549
+ pass = ff_sws_graph_add_pass (graph , fmt_out , src .width , src .height ,
550
+ input , 1 , lut , run_lut3d );
553
551
if (!pass ) {
554
552
ff_sws_lut3d_free (& lut );
555
553
return AVERROR (ENOMEM );
@@ -589,7 +587,8 @@ static int init_passes(SwsGraph *graph)
589
587
graph -> noop = 1 ;
590
588
591
589
/* Add threaded memcpy pass */
592
- pass = pass_add (graph , NULL , dst .format , dst .width , dst .height , pass , 1 , run_copy );
590
+ pass = ff_sws_graph_add_pass (graph , dst .format , dst .width , dst .height ,
591
+ pass , 1 , NULL , run_copy );
593
592
if (!pass )
594
593
return AVERROR (ENOMEM );
595
594
}
0 commit comments