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

Function ff_sws_init_single_context

libswscale/utils.c:1122–1847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1120}
1121
1122av_cold int ff_sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter,
1123 SwsFilter *dstFilter)
1124{
1125 int i;
1126 int usesVFilter, usesHFilter;
1127 int unscaled;
1128 SwsInternal *c = sws_internal(sws);
1129 SwsFilter dummyFilter = { NULL, NULL, NULL, NULL };
1130 int srcW = sws->src_w;
1131 int srcH = sws->src_h;
1132 int dstW = sws->dst_w;
1133 int dstH = sws->dst_h;
1134 int dst_stride = FFALIGN(dstW * sizeof(int16_t) + 66, 16);
1135 int flags, cpu_flags;
1136 enum AVPixelFormat srcFormat, dstFormat;
1137 const AVPixFmtDescriptor *desc_src;
1138 const AVPixFmtDescriptor *desc_dst;
1139 int ret = 0;
1140 enum AVPixelFormat tmpFmt;
1141 static const float float_mult = 1.0f / 255.0f;
1142
1143 cpu_flags = av_get_cpu_flags();
1144 flags = sws->flags;
1145 emms_c();
1146
1147 unscaled = (srcW == dstW && srcH == dstH);
1148
1149 if (!c->contrast && !c->saturation && !c->dstFormatBpp)
1150 sws_setColorspaceDetails(sws, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], sws->src_range,
1151 ff_yuv2rgb_coeffs[SWS_CS_DEFAULT],
1152 sws->dst_range, 0, 1 << 16, 1 << 16);
1153
1154 ret = handle_formats(sws);
1155 if (ret < 0)
1156 return ret;
1157 srcFormat = sws->src_format;
1158 dstFormat = sws->dst_format;
1159 desc_src = av_pix_fmt_desc_get(srcFormat);
1160 desc_dst = av_pix_fmt_desc_get(dstFormat);
1161
1162 // If the source has no alpha then disable alpha blendaway
1163 if (c->src0Alpha)
1164 sws->alpha_blend = SWS_ALPHA_BLEND_NONE;
1165
1166 if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) &&
1167 av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) {
1168 if (!sws_isSupportedInput(srcFormat)) {
1169 av_log(c, AV_LOG_ERROR, "%s is not supported as input pixel format\n",
1170 av_get_pix_fmt_name(srcFormat));
1171 return AVERROR(EINVAL);
1172 }
1173 if (!sws_isSupportedOutput(dstFormat)) {
1174 av_log(c, AV_LOG_ERROR, "%s is not supported as output pixel format\n",
1175 av_get_pix_fmt_name(dstFormat));
1176 return AVERROR(EINVAL);
1177 }
1178 }
1179 av_assert2(desc_src && desc_dst);

Callers 3

context_init_threadedFunction · 0.85
sws_init_contextFunction · 0.85
init_legacy_subpassFunction · 0.85

Calls 15

sws_internalFunction · 0.85
av_get_cpu_flagsFunction · 0.85
emms_cFunction · 0.85
sws_setColorspaceDetailsFunction · 0.85
handle_formatsFunction · 0.85
av_pix_fmt_desc_getFunction · 0.85
sws_isSupportedInputFunction · 0.85
av_logFunction · 0.85
av_get_pix_fmt_nameFunction · 0.85
sws_isSupportedOutputFunction · 0.85

Tested by

no test coverage detected