MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / context_init_threaded

Function context_init_threaded

libswscale/utils.c:1849–1895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1847}
1848
1849static int context_init_threaded(SwsContext *sws,
1850 SwsFilter *src_filter, SwsFilter *dst_filter)
1851{
1852 SwsInternal *c = sws_internal(sws);
1853 int ret;
1854
1855 ret = avpriv_slicethread_create(&c->slicethread, (void*) sws,
1856 ff_sws_slice_worker, NULL, sws->threads);
1857 if (ret == AVERROR(ENOSYS)) {
1858 sws->threads = 1;
1859 return 0;
1860 } else if (ret < 0)
1861 return ret;
1862
1863 sws->threads = ret;
1864
1865 c->slice_ctx = av_calloc(sws->threads, sizeof(*c->slice_ctx));
1866 c->slice_err = av_calloc(sws->threads, sizeof(*c->slice_err));
1867 if (!c->slice_ctx || !c->slice_err)
1868 return AVERROR(ENOMEM);
1869
1870 for (int i = 0; i < sws->threads; i++) {
1871 SwsContext *slice;
1872 slice = c->slice_ctx[i] = sws_alloc_context();
1873 if (!slice)
1874 return AVERROR(ENOMEM);
1875 sws_internal(slice)->parent = sws;
1876 c->nb_slice_ctx++;
1877
1878 ret = av_opt_copy(slice, sws);
1879 if (ret < 0)
1880 return ret;
1881 slice->threads = 1;
1882
1883 ret = ff_sws_init_single_context(slice, src_filter, dst_filter);
1884 if (ret < 0)
1885 return ret;
1886
1887 if (slice->dither == SWS_DITHER_ED) {
1888 av_log(c, AV_LOG_VERBOSE,
1889 "Error-diffusion dither is in use, scaling will be single-threaded.");
1890 break;
1891 }
1892 }
1893
1894 return 0;
1895}
1896
1897av_cold int sws_init_context(SwsContext *sws, SwsFilter *srcFilter,
1898 SwsFilter *dstFilter)

Callers 1

sws_init_contextFunction · 0.85

Calls 7

sws_internalFunction · 0.85
av_callocFunction · 0.85
sws_alloc_contextFunction · 0.85
av_opt_copyFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected