History

swscale: eliminate redundant SwsInternal accesses

This is a purely cosmetic commit aimed at replacing accesses to SwsInternal.opts by direct access to SwsContext wherever convenient.

Niklas Haas committed 2 years ago

Commit 6a91a161 parent ed5dd677 files · +203 −208Browse files

Unified · Split

7 files
  1. libswscale/options.c +1 −1
  2. libswscale/swscale.c +45 −48
  3. libswscale/utils.c +114 −119
  4. tests/checkasm/sw_gbrp.c +8 −8
  5. tests/checkasm/sw_range_convert.c +8 −8
  6. tests/checkasm/sw_rgb.c +16 −13
  7. tests/checkasm/sw_scale.c +11 −11
libswscale/options.c+1−1
@@ -27,7 +27,7 @@ static const char *sws_context_to_name(void *ptr) · 26 unmodified lines
2727 return "swscaler";
2828 }
2929
30−#define OFFSET(x) offsetof(SwsInternal, opts.x)
30+#define OFFSET(x) offsetof(SwsContext, x)
3131 #define DEFAULT 0
3232 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
3333
libswscale/swscale.c+45−48
@@ -895,7 +895,7 @@ static int scale_cascaded(SwsInternal *c, · 894 unmodified lines
895895 uint8_t * const dstSlice[], const int dstStride[],
896896 int dstSliceY, int dstSliceH)
897897 {
898− const int dstH0 = sws_internal(c->cascaded_context[0])->opts.dst_h;
898+ const int dstH0 = c->cascaded_context[0]->dst_h;
899899 int ret = scale_internal(c->cascaded_context[0],
900900 srcSlice, srcStride, srcSliceY, srcSliceH,
901901 c->cascaded_tmp[0], c->cascaded_tmpStride[0],
@@ -915,13 +915,13 @@ static int scale_internal(SwsContext *sws, · 13 unmodified lines
915915 int dstSliceY, int dstSliceH)
916916 {
917917 SwsInternal *c = sws_internal(sws);
918− const int scale_dst = dstSliceY > 0 || dstSliceH < c->opts.dst_h;
918+ const int scale_dst = dstSliceY > 0 || dstSliceH < sws->dst_h;
919919 const int frame_start = scale_dst || !c->sliceDir;
920920 int i, ret;
921921 const uint8_t *src2[4];
922922 uint8_t *dst2[4];
923− int macro_height_src = isBayer(c->opts.src_format) ? 2 : (1 << c->chrSrcVSubSample);
924− int macro_height_dst = isBayer(c->opts.dst_format) ? 2 : (1 << c->chrDstVSubSample);
923+ int macro_height_src = isBayer(sws->src_format) ? 2 : (1 << c->chrSrcVSubSample);
924+ int macro_height_dst = isBayer(sws->dst_format) ? 2 : (1 << c->chrDstVSubSample);
925925 // copy strides, so they can safely be modified
926926 int srcStride2[4];
927927 int dstStride2[4];
@@ -933,25 +933,25 @@ static int scale_internal(SwsContext *sws, · 5 unmodified lines
933933 }
934934
935935 if ((srcSliceY & (macro_height_src - 1)) ||
936− ((srcSliceH & (macro_height_src - 1)) && srcSliceY + srcSliceH != c->opts.src_h) ||
937− srcSliceY + srcSliceH > c->opts.src_h ||
938− (isBayer(c->opts.src_format) && srcSliceH <= 1)) {
936+ ((srcSliceH & (macro_height_src - 1)) && srcSliceY + srcSliceH != sws->src_h) ||
937+ srcSliceY + srcSliceH > sws->src_h ||
938+ (isBayer(sws->src_format) && srcSliceH <= 1)) {
939939 av_log(c, AV_LOG_ERROR, "Slice parameters %d, %d are invalid\n", srcSliceY, srcSliceH);
940940 return AVERROR(EINVAL);
941941 }
942942
943943 if ((dstSliceY & (macro_height_dst - 1)) ||
944− ((dstSliceH & (macro_height_dst - 1)) && dstSliceY + dstSliceH != c->opts.dst_h) ||
945− dstSliceY + dstSliceH > c->opts.dst_h) {
944+ ((dstSliceH & (macro_height_dst - 1)) && dstSliceY + dstSliceH != sws->dst_h) ||
945+ dstSliceY + dstSliceH > sws->dst_h) {
946946 av_log(c, AV_LOG_ERROR, "Slice parameters %d, %d are invalid\n", dstSliceY, dstSliceH);
947947 return AVERROR(EINVAL);
948948 }
949949
950− if (!check_image_pointers(srcSlice, c->opts.src_format, srcStride)) {
950+ if (!check_image_pointers(srcSlice, sws->src_format, srcStride)) {
951951 av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
952952 return AVERROR(EINVAL);
953953 }
954− if (!check_image_pointers((const uint8_t* const*)dstSlice, c->opts.dst_format, dstStride)) {
954+ if (!check_image_pointers((const uint8_t* const*)dstSlice, sws->dst_format, dstStride)) {
955955 av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
956956 return AVERROR(EINVAL);
957957 }
@@ -960,22 +960,19 @@ static int scale_internal(SwsContext *sws, · 2 unmodified lines
960960 if (srcSliceH == 0)
961961 return 0;
962962
963− if (c->opts.gamma_flag && c->cascaded_context[0])
963+ if (sws->gamma_flag && c->cascaded_context[0])
964964 return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH,
965965 dstSlice, dstStride, dstSliceY, dstSliceH);
966966
967− if (c->cascaded_context[0] && srcSliceY == 0 &&
968− srcSliceH == sws_internal(c->cascaded_context[0])->opts.src_h)
969− {
967+ if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->src_h)
970968 return scale_cascaded(c, srcSlice, srcStride, srcSliceY, srcSliceH,
971969 dstSlice, dstStride, dstSliceY, dstSliceH);
972− }
973970
974− if (!srcSliceY && (c->opts.flags & SWS_BITEXACT) && c->opts.dither == SWS_DITHER_ED && c->dither_error[0])
971+ if (!srcSliceY && (sws->flags & SWS_BITEXACT) && sws->dither == SWS_DITHER_ED && c->dither_error[0])
975972 for (i = 0; i < 4; i++)
976− memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->opts.dst_w+2));
973+ memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (sws->dst_w+2));
977974
978− if (usePal(c->opts.src_format))
975+ if (usePal(sws->src_format))
979976 ff_update_palette(c, (const uint32_t *)srcSlice[1]);
980977
981978 memcpy(src2, srcSlice, sizeof(src2));
@@ -984,7 +981,7 @@ static int scale_internal(SwsContext *sws, · 2 unmodified lines
984981 memcpy(dstStride2, dstStride, sizeof(dstStride2));
985982
986983 if (frame_start && !scale_dst) {
987− if (srcSliceY != 0 && srcSliceY + srcSliceH != c->opts.src_h) {
984+ if (srcSliceY != 0 && srcSliceY + srcSliceH != sws->src_h) {
988985 av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
989986 return AVERROR(EINVAL);
990987 }
@@ -993,7 +990,7 @@ static int scale_internal(SwsContext *sws, · 2 unmodified lines
993990 } else if (scale_dst)
994991 c->sliceDir = 1;
995992
996− if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->opts.dst_format)) {
993+ if (c->src0Alpha && !c->dst0Alpha && isALPHA(sws->dst_format)) {
997994 uint8_t *base;
998995 int x,y;
999996
@@ -1005,15 +1002,15 @@ static int scale_internal(SwsContext *sws, · 5 unmodified lines
10051002 base = srcStride[0] < 0 ? c->rgb0_scratch - srcStride[0] * (srcSliceH-1) :
10061003 c->rgb0_scratch;
10071004 for (y=0; y<srcSliceH; y++){
1008− memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->opts.src_w);
1009− for (x=c->src0Alpha-1; x<4*c->opts.src_w; x+=4) {
1005+ memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*sws->src_w);
1006+ for (x=c->src0Alpha-1; x<4*sws->src_w; x+=4) {
10101007 base[ srcStride[0]*y + x] = 0xFF;
10111008 }
10121009 }
10131010 src2[0] = base;
10141011 }
10151012
1016− if (c->srcXYZ && !(c->dstXYZ && c->opts.src_w==c->opts.dst_w && c->opts.src_h==c->opts.dst_h)) {
1013+ if (c->srcXYZ && !(c->dstXYZ && sws->src_w==sws->dst_w && sws->src_h==sws->dst_h)) {
10171014 uint8_t *base;
10181015
10191016 av_fast_malloc(&c->xyz_scratch, &c->xyz_scratch_allocated,
@@ -1024,7 +1021,7 @@ static int scale_internal(SwsContext *sws, · 4 unmodified lines
10241021 base = srcStride[0] < 0 ? c->xyz_scratch - srcStride[0] * (srcSliceH-1) :
10251022 c->xyz_scratch;
10261023
1027− ff_xyz12Torgb48(c, base, srcStride[0], src2[0], srcStride[0], c->opts.src_w, srcSliceH);
1024+ ff_xyz12Torgb48(c, base, srcStride[0], src2[0], srcStride[0], sws->src_w, srcSliceH);
10281025 src2[0] = base;
10291026 }
10301027
@@ -1036,19 +1033,19 @@ static int scale_internal(SwsContext *sws, · 5 unmodified lines
10361033 }
10371034
10381035 src2[0] += (srcSliceH - 1) * srcStride[0];
1039− if (!usePal(c->opts.src_format))
1036+ if (!usePal(sws->src_format))
10401037 src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];
10411038 src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];
10421039 src2[3] += (srcSliceH - 1) * srcStride[3];
1043− dst2[0] += ( c->opts.dst_h - 1) * dstStride[0];
1044− dst2[1] += ((c->opts.dst_h >> c->chrDstVSubSample) - 1) * dstStride[1];
1045− dst2[2] += ((c->opts.dst_h >> c->chrDstVSubSample) - 1) * dstStride[2];
1046− dst2[3] += ( c->opts.dst_h - 1) * dstStride[3];
1040+ dst2[0] += ( sws->dst_h - 1) * dstStride[0];
1041+ dst2[1] += ((sws->dst_h >> c->chrDstVSubSample) - 1) * dstStride[1];
1042+ dst2[2] += ((sws->dst_h >> c->chrDstVSubSample) - 1) * dstStride[2];
1043+ dst2[3] += ( sws->dst_h - 1) * dstStride[3];
10471044
1048− srcSliceY_internal = c->opts.src_h-srcSliceY-srcSliceH;
1045+ srcSliceY_internal = sws->src_h-srcSliceY-srcSliceH;
10491046 }
1050− reset_ptr(src2, c->opts.src_format);
1051− reset_ptr((void*)dst2, c->opts.dst_format);
1047+ reset_ptr(src2, sws->src_format);
1048+ reset_ptr((void*)dst2, sws->dst_format);
10521049
10531050 if (c->convert_unscaled) {
10541051 int offset = srcSliceY_internal;
@@ -1058,13 +1055,13 @@ static int scale_internal(SwsContext *sws, · 3 unmodified lines
10581055 if (scale_dst) {
10591056 av_assert0(offset == 0);
10601057 for (i = 0; i < 4 && src2[i]; i++) {
1061− if (!src2[i] || (i > 0 && usePal(c->opts.src_format)))
1058+ if (!src2[i] || (i > 0 && usePal(sws->src_format)))
10621059 break;
10631060 src2[i] += (dstSliceY >> ((i == 1 || i == 2) ? c->chrSrcVSubSample : 0)) * srcStride2[i];
10641061 }
10651062
10661063 for (i = 0; i < 4 && dst2[i]; i++) {
1067− if (!dst2[i] || (i > 0 && usePal(c->opts.dst_format)))
1064+ if (!dst2[i] || (i > 0 && usePal(sws->dst_format)))
10681065 break;
10691066 dst2[i] -= (dstSliceY >> ((i == 1 || i == 2) ? c->chrDstVSubSample : 0)) * dstStride2[i];
10701067 }
@@ -1081,7 +1078,7 @@ static int scale_internal(SwsContext *sws, · 10 unmodified lines
10811078 dst2, dstStride2, dstSliceY, dstSliceH);
10821079 }
10831080
1084− if (c->dstXYZ && !(c->srcXYZ && c->opts.src_w==c->opts.dst_w && c->opts.src_h==c->opts.dst_h)) {
1081+ if (c->dstXYZ && !(c->srcXYZ && sws->src_w==sws->dst_w && sws->src_h==sws->dst_h)) {
10851082 uint8_t *dst;
10861083
10871084 if (scale_dst) {
@@ -1091,16 +1088,16 @@ static int scale_internal(SwsContext *sws, · 3 unmodified lines
10911088
10921089 av_assert0(dstY >= ret);
10931090 av_assert0(ret >= 0);
1094− av_assert0(c->opts.dst_h >= dstY);
1091+ av_assert0(sws->dst_h >= dstY);
10951092 dst = dst2[0] + (dstY - ret) * dstStride2[0];
10961093 }
10971094
10981095 /* replace on the same data */
1099− ff_rgb48Toxyz12(c, dst, dstStride2[0], dst, dstStride2[0], c->opts.dst_w, ret);
1096+ ff_rgb48Toxyz12(c, dst, dstStride2[0], dst, dstStride2[0], sws->dst_w, ret);
11001097 }
11011098
11021099 /* reset slice direction at end of frame */
1103− if ((srcSliceY_internal + srcSliceH == c->opts.src_h) || scale_dst)
1100+ if ((srcSliceY_internal + srcSliceH == sws->src_h) || scale_dst)
11041101 c->sliceDir = 0;
11051102
11061103 return ret;
@@ -1124,9 +1121,9 @@ int sws_frame_start(SwsContext *sws, AVFrame *dst, const AVFrame *src) · 17 unmodified lines
11241121 return ret;
11251122
11261123 if (!dst->buf[0]) {
1127− dst->width = c->opts.dst_w;
1128− dst->height = c->opts.dst_h;
1129− dst->format = c->opts.dst_format;
1124+ dst->width = sws->dst_w;
1125+ dst->height = sws->dst_h;
1126+ dst->format = sws->dst_format;
11301127
11311128 ret = av_frame_get_buffer(dst, 0);
11321129 if (ret < 0)
@@ -1177,10 +1174,10 @@ int sws_receive_slice(SwsContext *sws, unsigned int slice_start, · 44 unmodified lines
11771174 /* wait until complete input has been received */
11781175 if (!(c->src_ranges.nb_ranges == 1 &&
11791176 c->src_ranges.ranges[0].start == 0 &&
1180− c->src_ranges.ranges[0].len == c->opts.src_h))
1177+ c->src_ranges.ranges[0].len == sws->src_h))
11811178 return AVERROR(EAGAIN);
11821179
1183− if ((slice_start > 0 || slice_height < c->opts.dst_h) &&
1180+ if ((slice_start > 0 || slice_height < sws->dst_h) &&
11841181 (slice_start % align || slice_height % align)) {
11851182 av_log(c, AV_LOG_ERROR,
11861183 "Incorrectly aligned output: %u/%u not multiples of %u\n",
@@ -1192,7 +1189,7 @@ int sws_receive_slice(SwsContext *sws, unsigned int slice_start, · 5 unmodified lines
11921189 int nb_jobs = c->nb_slice_ctx;
11931190 int ret = 0;
11941191
1195− if (sws_internal(c->slice_ctx[0])->opts.dither == SWS_DITHER_ED)
1192+ if (c->slice_ctx[0]->dither == SWS_DITHER_ED)
11961193 nb_jobs = 1;
11971194
11981195 c->dst_slice_start = slice_start;
@@ -1218,7 +1215,7 @@ int sws_receive_slice(SwsContext *sws, unsigned int slice_start, · 19 unmodified lines
12181215 }
12191216
12201217 return scale_internal(sws, (const uint8_t * const *)c->frame_src->data,
1221− c->frame_src->linesize, 0, c->opts.src_h,
1218+ c->frame_src->linesize, 0, sws->src_h,
12221219 dst, c->frame_dst->linesize, slice_start, slice_height);
12231220 }
12241221
@@ -1256,7 +1253,7 @@ int attribute_align_arg sws_scale(SwsContext *sws, · 31 unmodified lines
12561253 }
12571254
12581255 return scale_internal(sws, srcSlice, srcStride, srcSliceY, srcSliceH,
1259− dst, dstStride, 0, c->opts.dst_h);
1256+ dst, dstStride, 0, sws->dst_h);
12601257 }
12611258
12621259 void ff_sws_slice_worker(void *priv, int jobnr, int threadnr,
@@ -1284,7 +1281,7 @@ void ff_sws_slice_worker(void *priv, int jobnr, int threadnr, · 21 unmodified lines
12841281 }
12851282
12861283 err = scale_internal(sws, (const uint8_t * const *)parent->frame_src->data,
1287− parent->frame_src->linesize, 0, c->opts.src_h,
1284+ parent->frame_src->linesize, 0, sws->src_h,
12881285 dst, parent->frame_dst->linesize,
12891286 parent->dst_slice_start + slice_start, slice_end - slice_start);
12901287 }
libswscale/utils.c+114−119
@@ -1026,12 +1026,13 @@ static int handle_xyz(enum AVPixelFormat *format) · 1025 unmodified lines
10261026 }
10271027 }
10281028
1029−static void handle_formats(SwsInternal *c)
1029+static void handle_formats(SwsContext *sws)
10301030 {
1031− c->src0Alpha |= handle_0alpha(&c->opts.src_format);
1032− c->dst0Alpha |= handle_0alpha(&c->opts.dst_format);
1033− c->srcXYZ |= handle_xyz(&c->opts.src_format);
1034− c->dstXYZ |= handle_xyz(&c->opts.dst_format);
1031+ SwsInternal *c = sws_internal(sws);
1032+ c->src0Alpha |= handle_0alpha(&sws->src_format);
1033+ c->dst0Alpha |= handle_0alpha(&sws->dst_format);
1034+ c->srcXYZ |= handle_xyz(&sws->src_format);
1035+ c->dstXYZ |= handle_xyz(&sws->dst_format);
10351036 if (c->srcXYZ || c->dstXYZ)
10361037 fill_xyztables(c);
10371038 }
@@ -1063,17 +1064,17 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 25 unmodified lines
10631064 return parent_ret;
10641065 }
10651066
1066− handle_formats(c);
1067− desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
1068− desc_src = av_pix_fmt_desc_get(c->opts.src_format);
1067+ handle_formats(sws);
1068+ desc_dst = av_pix_fmt_desc_get(sws->dst_format);
1069+ desc_src = av_pix_fmt_desc_get(sws->src_format);
10691070
1070− if(range_override_needed(c->opts.dst_format))
1071+ if(range_override_needed(sws->dst_format))
10711072 dstRange = 0;
1072− if(range_override_needed(c->opts.src_format))
1073+ if(range_override_needed(sws->src_format))
10731074 srcRange = 0;
10741075
1075− if (c->opts.src_range != srcRange ||
1076− c->opts.dst_range != dstRange ||
1076+ if (sws->src_range != srcRange ||
1077+ sws->dst_range != dstRange ||
10771078 c->brightness != brightness ||
10781079 c->contrast != contrast ||
10791080 c->saturation != saturation ||
@@ -1090,8 +1091,8 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 10 unmodified lines
10901091 c->brightness = brightness;
10911092 c->contrast = contrast;
10921093 c->saturation = saturation;
1093− c->opts.src_range = srcRange;
1094− c->opts.dst_range = dstRange;
1094+ sws->src_range = srcRange;
1095+ sws->dst_range = dstRange;
10951096
10961097 if (need_reinit)
10971098 ff_sws_init_range_convert(c);
@@ -1105,27 +1106,27 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 7 unmodified lines
11051106 if (!need_reinit)
11061107 return 0;
11071108
1108− if ((isYUV(c->opts.dst_format) || isGray(c->opts.dst_format)) && (isYUV(c->opts.src_format) || isGray(c->opts.src_format))) {
1109+ if ((isYUV(sws->dst_format) || isGray(sws->dst_format)) && (isYUV(sws->src_format) || isGray(sws->src_format))) {
11091110 if (!c->cascaded_context[0] &&
11101111 memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 4) &&
1111− c->opts.src_w && c->opts.src_h && c->opts.dst_w && c->opts.dst_h) {
1112+ sws->src_w && sws->src_h && sws->dst_w && sws->dst_h) {
11121113 enum AVPixelFormat tmp_format;
11131114 int tmp_width, tmp_height;
1114− int srcW = c->opts.src_w;
1115− int srcH = c->opts.src_h;
1116− int dstW = c->opts.dst_w;
1117− int dstH = c->opts.dst_h;
1115+ int srcW = sws->src_w;
1116+ int srcH = sws->src_h;
1117+ int dstW = sws->dst_w;
1118+ int dstH = sws->dst_h;
11181119 int ret;
11191120 av_log(c, AV_LOG_VERBOSE, "YUV color matrix differs for YUV->YUV, using intermediate RGB to convert\n");
11201121
1121− if (isNBPS(c->opts.dst_format) || is16BPS(c->opts.dst_format)) {
1122− if (isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) {
1122+ if (isNBPS(sws->dst_format) || is16BPS(sws->dst_format)) {
1123+ if (isALPHA(sws->src_format) && isALPHA(sws->dst_format)) {
11231124 tmp_format = AV_PIX_FMT_BGRA64;
11241125 } else {
11251126 tmp_format = AV_PIX_FMT_BGR48;
11261127 }
11271128 } else {
1128− if (isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) {
1129+ if (isALPHA(sws->src_format) && isALPHA(sws->dst_format)) {
11291130 tmp_format = AV_PIX_FMT_BGRA;
11301131 } else {
11311132 tmp_format = AV_PIX_FMT_BGR24;
@@ -1145,14 +1146,13 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 13 unmodified lines
11451146 if (ret < 0)
11461147 return ret;
11471148
1148− c->cascaded_context[0] = alloc_set_opts(srcW, srcH, c->opts.src_format,
1149+ c->cascaded_context[0] = alloc_set_opts(srcW, srcH, sws->src_format,
11491150 tmp_width, tmp_height, tmp_format,
1150− c->opts.flags,
1151− c->opts.scaler_params);
1151+ sws->flags, sws->scaler_params);
11521152 if (!c->cascaded_context[0])
11531153 return -1;
11541154
1155− sws_internal(c->cascaded_context[0])->opts.alpha_blend = c->opts.alpha_blend;
1155+ c->cascaded_context[0]->alpha_blend = sws->alpha_blend;
11561156 ret = sws_init_context(c->cascaded_context[0], NULL , NULL);
11571157 if (ret < 0)
11581158 return ret;
@@ -1162,13 +1162,12 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 3 unmodified lines
11621162 brightness, contrast, saturation);
11631163
11641164 c->cascaded_context[1] = alloc_set_opts(tmp_width, tmp_height, tmp_format,
1165− dstW, dstH, c->opts.dst_format,
1166− c->opts.flags,
1167− c->opts.scaler_params);
1165+ dstW, dstH, sws->dst_format,
1166+ sws->flags, sws->scaler_params);
11681167 if (!c->cascaded_context[1])
11691168 return -1;
1170− sws_internal(c->cascaded_context[1])->opts.src_range = srcRange;
1171− sws_internal(c->cascaded_context[1])->opts.dst_range = dstRange;
1169+ c->cascaded_context[1]->src_range = srcRange;
1170+ c->cascaded_context[1]->dst_range = dstRange;
11721171 ret = sws_init_context(c->cascaded_context[1], NULL , NULL);
11731172 if (ret < 0)
11741173 return ret;
@@ -1183,7 +1182,7 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 8 unmodified lines
11831182 return 0;
11841183 }
11851184
1186− if (!isYUV(c->opts.dst_format) && !isGray(c->opts.dst_format)) {
1185+ if (!isYUV(sws->dst_format) && !isGray(sws->dst_format)) {
11871186 ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
11881187 contrast, saturation);
11891188 // FIXME factorize
@@ -1215,8 +1214,8 @@ int sws_getColorspaceDetails(SwsContext *sws, int **inv_table, · 25 unmodified lines
12151214
12161215 *inv_table = c->srcColorspaceTable;
12171216 *table = c->dstColorspaceTable;
1218− *srcRange = range_override_needed(c->opts.src_format) ? 1 : c->opts.src_range;
1219− *dstRange = range_override_needed(c->opts.dst_format) ? 1 : c->opts.dst_range;
1217+ *srcRange = range_override_needed(sws->src_format) ? 1 : sws->src_range;
1218+ *dstRange = range_override_needed(sws->dst_format) ? 1 : sws->dst_range;
12201219 *brightness = c->brightness;
12211220 *contrast = c->contrast;
12221221 *saturation = c->saturation;
@@ -1321,10 +1320,10 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 98 unmodified lines
13211320 int unscaled;
13221321 SwsInternal *c = sws_internal(sws);
13231322 SwsFilter dummyFilter = { NULL, NULL, NULL, NULL };
1324− int srcW = c->opts.src_w;
1325− int srcH = c->opts.src_h;
1326− int dstW = c->opts.dst_w;
1327− int dstH = c->opts.dst_h;
1323+ int srcW = sws->src_w;
1324+ int srcH = sws->src_h;
1325+ int dstW = sws->dst_w;
1326+ int dstH = sws->dst_h;
13281327 int dst_stride = FFALIGN(dstW * sizeof(int16_t) + 66, 16);
13291328 int flags, cpu_flags;
13301329 enum AVPixelFormat srcFormat, dstFormat;
@@ -1335,25 +1334,25 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 4 unmodified lines
13351334 static const float float_mult = 1.0f / 255.0f;
13361335
13371336 cpu_flags = av_get_cpu_flags();
1338− flags = c->opts.flags;
1337+ flags = sws->flags;
13391338 emms_c();
13401339
13411340 unscaled = (srcW == dstW && srcH == dstH);
13421341
13431342 if (!c->contrast && !c->saturation && !c->dstFormatBpp)
1344− sws_setColorspaceDetails(sws, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->opts.src_range,
1343+ sws_setColorspaceDetails(sws, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], sws->src_range,
13451344 ff_yuv2rgb_coeffs[SWS_CS_DEFAULT],
1346− c->opts.dst_range, 0, 1 << 16, 1 << 16);
1345+ sws->dst_range, 0, 1 << 16, 1 << 16);
13471346
1348− handle_formats(c);
1349− srcFormat = c->opts.src_format;
1350− dstFormat = c->opts.dst_format;
1347+ handle_formats(sws);
1348+ srcFormat = sws->src_format;
1349+ dstFormat = sws->dst_format;
13511350 desc_src = av_pix_fmt_desc_get(srcFormat);
13521351 desc_dst = av_pix_fmt_desc_get(dstFormat);
13531352
13541353 // If the source has no alpha then disable alpha blendaway
13551354 if (c->src0Alpha)
1356− c->opts.alpha_blend = SWS_ALPHA_BLEND_NONE;
1355+ sws->alpha_blend = SWS_ALPHA_BLEND_NONE;
13571356
13581357 if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) &&
13591358 av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) {
@@ -1390,7 +1389,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 30 unmodified lines
13901389 flags |= SWS_BICUBIC;
13911390 else
13921391 flags |= SWS_BICUBIC;
1393− c->opts.flags = flags;
1392+ sws->flags = flags;
13941393 } else if (i & (i - 1)) {
13951394 av_log(c, AV_LOG_ERROR,
13961395 "Exactly one scaler algorithm must be chosen, got %X\n", i);
@@ -1407,7 +1406,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 10 unmodified lines
14071406 if (flags & SWS_FAST_BILINEAR) {
14081407 if (srcW < 8 || dstW < 8) {
14091408 flags ^= SWS_FAST_BILINEAR | SWS_BILINEAR;
1410− c->opts.flags = flags;
1409+ sws->flags = flags;
14111410 }
14121411 }
14131412
@@ -1440,46 +1439,46 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 26 unmodified lines
14401439 if (dstW&1) {
14411440 av_log(c, AV_LOG_DEBUG, "Forcing full internal H chroma due to odd output size\n");
14421441 flags |= SWS_FULL_CHR_H_INT;
1443− c->opts.flags = flags;
1442+ sws->flags = flags;
14441443 }
14451444
14461445 if ( c->chrSrcHSubSample == 0
14471446 && c->chrSrcVSubSample == 0
1448− && c->opts.dither != SWS_DITHER_BAYER //SWS_FULL_CHR_H_INT is currently not supported with SWS_DITHER_BAYER
1449− && !(c->opts.flags & SWS_FAST_BILINEAR)
1447+ && sws->dither != SWS_DITHER_BAYER //SWS_FULL_CHR_H_INT is currently not supported with SWS_DITHER_BAYER
1448+ && !(sws->flags & SWS_FAST_BILINEAR)
14501449 ) {
14511450 av_log(c, AV_LOG_DEBUG, "Forcing full internal H chroma due to input having non subsampled chroma\n");
14521451 flags |= SWS_FULL_CHR_H_INT;
1453− c->opts.flags = flags;
1452+ sws->flags = flags;
14541453 }
14551454 }
14561455
1457− if (c->opts.dither == SWS_DITHER_AUTO) {
1456+ if (sws->dither == SWS_DITHER_AUTO) {
14581457 if (flags & SWS_ERROR_DIFFUSION)
1459− c->opts.dither = SWS_DITHER_ED;
1458+ sws->dither = SWS_DITHER_ED;
14601459 }
14611460
14621461 if(dstFormat == AV_PIX_FMT_BGR4_BYTE ||
14631462 dstFormat == AV_PIX_FMT_RGB4_BYTE ||
14641463 dstFormat == AV_PIX_FMT_BGR8 ||
14651464 dstFormat == AV_PIX_FMT_RGB8) {
1466− if (c->opts.dither == SWS_DITHER_AUTO)
1467− c->opts.dither = (flags & SWS_FULL_CHR_H_INT) ? SWS_DITHER_ED : SWS_DITHER_BAYER;
1465+ if (sws->dither == SWS_DITHER_AUTO)
1466+ sws->dither = (flags & SWS_FULL_CHR_H_INT) ? SWS_DITHER_ED : SWS_DITHER_BAYER;
14681467 if (!(flags & SWS_FULL_CHR_H_INT)) {
1469− if (c->opts.dither == SWS_DITHER_ED || c->opts.dither == SWS_DITHER_A_DITHER || c->opts.dither == SWS_DITHER_X_DITHER || c->opts.dither == SWS_DITHER_NONE) {
1468+ if (sws->dither == SWS_DITHER_ED || sws->dither == SWS_DITHER_A_DITHER || sws->dither == SWS_DITHER_X_DITHER || sws->dither == SWS_DITHER_NONE) {
14701469 av_log(c, AV_LOG_DEBUG,
14711470 "Desired dithering only supported in full chroma interpolation for destination format '%s'\n",
14721471 av_get_pix_fmt_name(dstFormat));
14731472 flags |= SWS_FULL_CHR_H_INT;
1474− c->opts.flags = flags;
1473+ sws->flags = flags;
14751474 }
14761475 }
14771476 if (flags & SWS_FULL_CHR_H_INT) {
1478− if (c->opts.dither == SWS_DITHER_BAYER) {
1477+ if (sws->dither == SWS_DITHER_BAYER) {
14791478 av_log(c, AV_LOG_DEBUG,
14801479 "Ordered dither is not supported in full chroma interpolation for destination format '%s'\n",
14811480 av_get_pix_fmt_name(dstFormat));
1482− c->opts.dither = SWS_DITHER_ED;
1481+ sws->dither = SWS_DITHER_ED;
14831482 }
14841483 }
14851484 }
@@ -1489,7 +1488,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 3 unmodified lines
14891488 "%s output is not supported with half chroma resolution, switching to full\n",
14901489 av_get_pix_fmt_name(dstFormat));
14911490 flags |= SWS_FULL_CHR_H_INT;
1492− c->opts.flags = flags;
1491+ sws->flags = flags;
14931492 }
14941493 }
14951494
@@ -1523,7 +1522,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 27 unmodified lines
15231522 "full chroma interpolation for destination format '%s' not yet implemented\n",
15241523 av_get_pix_fmt_name(dstFormat));
15251524 flags &= ~SWS_FULL_CHR_H_INT;
1526− c->opts.flags = flags;
1525+ sws->flags = flags;
15271526 }
15281527 if (isAnyRGB(dstFormat) && !(flags & SWS_FULL_CHR_H_INT))
15291528 c->chrDstHSubSample = 1;
@@ -1585,7 +1584,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 55 unmodified lines
15851584 av_log(c, AV_LOG_INFO,
15861585 "output width is not a multiple of 32 -> no MMXEXT scaler\n");
15871586 }
1588− if (usesHFilter || isNBPS(c->opts.src_format) || is16BPS(c->opts.src_format) || isAnyRGB(c->opts.src_format))
1587+ if (usesHFilter || isNBPS(sws->src_format) || is16BPS(sws->src_format) || isAnyRGB(sws->src_format))
15891588 c->canMMXEXTBeUsed = 0;
15901589 } else
15911590 c->canMMXEXTBeUsed = 0;
@@ -1616,8 +1615,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 24 unmodified lines
16161615 c->gamma_value = 2.2;
16171616 tmpFmt = AV_PIX_FMT_RGBA64LE;
16181617
1619−
1620− if (!unscaled && c->opts.gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
1618+ if (!unscaled && sws->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
16211619 SwsInternal *c2;
16221620 c->cascaded_context[0] = NULL;
16231621
@@ -1629,7 +1627,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 5 unmodified lines
16291627 c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat,
16301628 srcW, srcH, tmpFmt,
16311629 flags, NULL, NULL,
1632− c->opts.scaler_params);
1630+ sws->scaler_params);
16331631 if (!c->cascaded_context[0]) {
16341632 return AVERROR(ENOMEM);
16351633 }
@@ -1637,7 +1635,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 1 unmodified line
16371635 c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt,
16381636 dstW, dstH, tmpFmt,
16391637 flags, srcFilter, dstFilter,
1640− c->opts.scaler_params);
1638+ sws->scaler_params);
16411639
16421640 if (!c->cascaded_context[1])
16431641 return AVERROR(ENOMEM);
@@ -1669,7 +1667,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 25 unmodified lines
16691667 c->cascaded_context[2] = sws_getContext(dstW, dstH, tmpFmt,
16701668 dstW, dstH, dstFormat,
16711669 flags, NULL, NULL,
1672− c->opts.scaler_params);
1670+ sws->scaler_params);
16731671 if (!c->cascaded_context[2])
16741672 return AVERROR(ENOMEM);
16751673 }
@@ -1690,14 +1688,14 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 14 unmodified lines
16901688 c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat,
16911689 srcW, srcH, tmpFormat,
16921690 flags, srcFilter, NULL,
1693− c->opts.scaler_params);
1691+ sws->scaler_params);
16941692 if (!c->cascaded_context[0])
16951693 return AVERROR(ENOMEM);
16961694
16971695 c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFormat,
16981696 dstW, dstH, dstFormat,
16991697 flags, NULL, dstFilter,
1700− c->opts.scaler_params);
1698+ sws->scaler_params);
17011699 if (!c->cascaded_context[1])
17021700 return AVERROR(ENOMEM);
17031701 return 0;
@@ -1720,11 +1718,11 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 16 unmodified lines
17201718 if (CONFIG_SWSCALE_ALPHA && isALPHA(srcFormat) && !isALPHA(dstFormat)) {
17211719 enum AVPixelFormat tmpFormat = alphaless_fmt(srcFormat);
17221720
1723− if (tmpFormat != AV_PIX_FMT_NONE && c->opts.alpha_blend != SWS_ALPHA_BLEND_NONE) {
1721+ if (tmpFormat != AV_PIX_FMT_NONE && sws->alpha_blend != SWS_ALPHA_BLEND_NONE) {
17241722 if (!unscaled ||
17251723 dstFormat != tmpFormat ||
17261724 usesHFilter || usesVFilter ||
1727− c->opts.src_range != c->opts.dst_range
1725+ sws->src_range != sws->dst_range
17281726 ) {
17291727 c->cascaded_mainindex = 1;
17301728 ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0],
@@ -1734,22 +1732,22 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 3 unmodified lines
17341732
17351733 c->cascaded_context[0] = alloc_set_opts(srcW, srcH, srcFormat,
17361734 srcW, srcH, tmpFormat,
1737− flags, c->opts.scaler_params);
1735+ flags, sws->scaler_params);
17381736 if (!c->cascaded_context[0])
17391737 return AVERROR(EINVAL);
1740− sws_internal(c->cascaded_context[0])->opts.alpha_blend = c->opts.alpha_blend;
1738+ c->cascaded_context[0]->alpha_blend = sws->alpha_blend;
17411739 ret = sws_init_context(c->cascaded_context[0], NULL , NULL);
17421740 if (ret < 0)
17431741 return ret;
17441742
17451743 c->cascaded_context[1] = alloc_set_opts(srcW, srcH, tmpFormat,
17461744 dstW, dstH, dstFormat,
1747− flags, c->opts.scaler_params);
1745+ flags, sws->scaler_params);
17481746 if (!c->cascaded_context[1])
17491747 return AVERROR(EINVAL);
17501748
1751− sws_internal(c->cascaded_context[1])->opts.src_range = c->opts.src_range;
1752− sws_internal(c->cascaded_context[1])->opts.dst_range = c->opts.dst_range;
1749+ c->cascaded_context[1]->src_range = sws->src_range;
1750+ c->cascaded_context[1]->dst_range = sws->dst_range;
17531751 ret = sws_init_context(c->cascaded_context[1], srcFilter , dstFilter);
17541752 if (ret < 0)
17551753 return ret;
@@ -1761,9 +1759,9 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 5 unmodified lines
17611759
17621760 /* alpha blend special case, note this has been split via cascaded contexts if its scaled */
17631761 if (unscaled && !usesHFilter && !usesVFilter &&
1764− c->opts.alpha_blend != SWS_ALPHA_BLEND_NONE &&
1762+ sws->alpha_blend != SWS_ALPHA_BLEND_NONE &&
17651763 isALPHA(srcFormat) &&
1766− (c->opts.src_range == c->opts.dst_range || isAnyRGB(dstFormat)) &&
1764+ (sws->src_range == sws->dst_range || isAnyRGB(dstFormat)) &&
17671765 alphaless_fmt(srcFormat) == dstFormat
17681766 ) {
17691767 c->convert_unscaled = ff_sws_alphablendaway;
@@ -1777,7 +1775,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 7 unmodified lines
17771775
17781776 /* unscaled special cases */
17791777 if (unscaled && !usesHFilter && !usesVFilter &&
1780− (c->opts.src_range == c->opts.dst_range || isAnyRGB(dstFormat) ||
1778+ (sws->src_range == sws->dst_range || isAnyRGB(dstFormat) ||
17811779 isFloat(srcFormat) || isFloat(dstFormat) || isBayer(srcFormat))){
17821780
17831781 ff_get_unscaled_swscale(c);
@@ -1873,7 +1871,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 89 unmodified lines
18731871 srcW, dstW, filterAlign, 1 << 14,
18741872 (flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags,
18751873 cpu_flags, srcFilter->lumH, dstFilter->lumH,
1876− c->opts.scaler_params,
1874+ sws->scaler_params,
18771875 get_local_pos(c, 0, 0, 0),
18781876 get_local_pos(c, 0, 0, 0))) < 0)
18791877 goto fail;
@@ -1884,9 +1882,9 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 4 unmodified lines
18841882 c->chrSrcW, c->chrDstW, filterAlign, 1 << 14,
18851883 (flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags,
18861884 cpu_flags, srcFilter->chrH, dstFilter->chrH,
1887− c->opts.scaler_params,
1888− get_local_pos(c, c->chrSrcHSubSample, c->opts.src_h_chr_pos, 0),
1889− get_local_pos(c, c->chrDstHSubSample, c->opts.dst_h_chr_pos, 0))) < 0)
1885+ sws->scaler_params,
1886+ get_local_pos(c, c->chrSrcHSubSample, sws->src_h_chr_pos, 0),
1887+ get_local_pos(c, c->chrDstHSubSample, sws->dst_h_chr_pos, 0))) < 0)
18901888 goto fail;
18911889 if (ff_shuffle_filter_coefficients(c, c->hChrFilterPos, c->hChrFilterSize, c->hChrFilter, c->chrDstW) < 0)
18921890 goto nomem;
@@ -1903,7 +1901,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 10 unmodified lines
19031901 c->lumYInc, srcH, dstH, filterAlign, (1 << 12),
19041902 (flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags,
19051903 cpu_flags, srcFilter->lumV, dstFilter->lumV,
1906− c->opts.scaler_params,
1904+ sws->scaler_params,
19071905 get_local_pos(c, 0, 0, 1),
19081906 get_local_pos(c, 0, 0, 1))) < 0)
19091907 goto fail;
@@ -1912,18 +1910,18 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 2 unmodified lines
19121910 filterAlign, (1 << 12),
19131911 (flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags,
19141912 cpu_flags, srcFilter->chrV, dstFilter->chrV,
1915− c->opts.scaler_params,
1916− get_local_pos(c, c->chrSrcVSubSample, c->opts.src_v_chr_pos, 1),
1917− get_local_pos(c, c->chrDstVSubSample, c->opts.dst_v_chr_pos, 1))) < 0)
1913+ sws->scaler_params,
1914+ get_local_pos(c, c->chrSrcVSubSample, sws->src_v_chr_pos, 1),
1915+ get_local_pos(c, c->chrDstVSubSample, sws->dst_v_chr_pos, 1))) < 0)
19181916
19191917 goto fail;
19201918
19211919 #if HAVE_ALTIVEC
1922− if (!FF_ALLOC_TYPED_ARRAY(c->vYCoeffsBank, c->vLumFilterSize * c->opts.dst_h) ||
1920+ if (!FF_ALLOC_TYPED_ARRAY(c->vYCoeffsBank, c->vLumFilterSize * sws->dst_h) ||
19231921 !FF_ALLOC_TYPED_ARRAY(c->vCCoeffsBank, c->vChrFilterSize * c->chrDstH))
19241922 goto nomem;
19251923
1926− for (i = 0; i < c->vLumFilterSize * c->opts.dst_h; i++) {
1924+ for (i = 0; i < c->vLumFilterSize * sws->dst_h; i++) {
19271925 int j;
19281926 short *p = (short *)&c->vYCoeffsBank[i];
19291927 for (j = 0; j < 8; j++)
@@ -1940,10 +1938,10 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 10 unmodified lines
19401938 }
19411939
19421940 for (i = 0; i < 4; i++)
1943− if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], c->opts.dst_w + 3))
1941+ if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], sws->dst_w + 3))
19441942 goto nomem;
19451943
1946− c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) ? 1 : 0;
1944+ c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(sws->src_format) && isALPHA(sws->dst_format)) ? 1 : 0;
19471945
19481946 // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate)
19491947 c->uv_off = (dst_stride>>1) + 64 / (c->dstBpc &~ 7);
@@ -1985,7 +1983,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 35 unmodified lines
19851983 av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
19861984 av_log(c, AV_LOG_DEBUG,
19871985 "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
1988− c->opts.src_w, c->opts.src_h, c->opts.dst_w, c->opts.dst_h, c->lumXInc, c->lumYInc);
1986+ sws->src_w, sws->src_h, sws->dst_w, sws->dst_h, c->lumXInc, c->lumYInc);
19891987 av_log(c, AV_LOG_DEBUG,
19901988 "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
19911989 c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH,
@@ -2017,14 +2015,14 @@ fail: // FIXME replace things by appropriate error codes · 25 unmodified lines
20172015 c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat,
20182016 tmpW, tmpH, tmpFormat,
20192017 flags, srcFilter, NULL,
2020− c->opts.scaler_params);
2018+ sws->scaler_params);
20212019 if (!c->cascaded_context[0])
20222020 return AVERROR(ENOMEM);
20232021
20242022 c->cascaded_context[1] = sws_getContext(tmpW, tmpH, tmpFormat,
20252023 dstW, dstH, dstFormat,
20262024 flags, NULL, dstFilter,
2027− c->opts.scaler_params);
2025+ sws->scaler_params);
20282026 if (!c->cascaded_context[1])
20292027 return AVERROR(ENOMEM);
20302028 return 0;
@@ -2039,41 +2037,38 @@ static int context_init_threaded(SwsContext *sws, · 8 unmodified lines
20392037 int ret;
20402038
20412039 ret = avpriv_slicethread_create(&c->slicethread, (void*) sws,
2042− ff_sws_slice_worker, NULL, c->opts.threads);
2040+ ff_sws_slice_worker, NULL, sws->threads);
20432041 if (ret == AVERROR(ENOSYS)) {
2044− c->opts.threads = 1;
2042+ sws->threads = 1;
20452043 return 0;
20462044 } else if (ret < 0)
20472045 return ret;
20482046
2049− c->opts.threads = ret;
2047+ sws->threads = ret;
20502048
2051− c->slice_ctx = av_calloc(c->opts.threads, sizeof(*c->slice_ctx));
2052− c->slice_err = av_calloc(c->opts.threads, sizeof(*c->slice_err));
2049+ c->slice_ctx = av_calloc(sws->threads, sizeof(*c->slice_ctx));
2050+ c->slice_err = av_calloc(sws->threads, sizeof(*c->slice_err));
20532051 if (!c->slice_ctx || !c->slice_err)
20542052 return AVERROR(ENOMEM);
20552053
2056− for (int i = 0; i < c->opts.threads; i++) {
2057− SwsInternal *c2;
2058− c->slice_ctx[i] = sws_alloc_context();
2059− if (!c->slice_ctx[i])
2054+ for (int i = 0; i < sws->threads; i++) {
2055+ SwsContext *slice;
2056+ slice = c->slice_ctx[i] = sws_alloc_context();
2057+ if (!slice)
20602058 return AVERROR(ENOMEM);
2061− c2 = sws_internal(c->slice_ctx[i]);
2062−
2059+ sws_internal(slice)->parent = sws;
20632060 c->nb_slice_ctx++;
2064− c2->parent = sws;
20652061
2066− ret = av_opt_copy((void*)c->slice_ctx[i], (void*)c);
2062+ ret = av_opt_copy(slice, sws);
20672063 if (ret < 0)
20682064 return ret;
2065+ slice->threads = 1;
20692066
2070− c2->opts.threads = 1;
2071−
2072− ret = sws_init_single_context(c->slice_ctx[i], src_filter, dst_filter);
2067+ ret = sws_init_single_context(slice, src_filter, dst_filter);
20732068 if (ret < 0)
20742069 return ret;
20752070
2076− if (c2->opts.dither == SWS_DITHER_ED) {
2071+ if (slice->dither == SWS_DITHER_ED) {
20772072 av_log(c, AV_LOG_VERBOSE,
20782073 "Error-diffusion dither is in use, scaling will be single-threaded.");
20792074 break;
@@ -2099,17 +2094,17 @@ av_cold int sws_init_context(SwsContext *sws, SwsFilter *srcFilter, · 19 unmodified lines
20992094 if (ff_thread_once(&rgb2rgb_once, ff_sws_rgb2rgb_init) != 0)
21002095 return AVERROR_UNKNOWN;
21012096
2102− src_format = c->opts.src_format;
2103− dst_format = c->opts.dst_format;
2104− c->opts.src_range |= handle_jpeg(&c->opts.src_format);
2105− c->opts.dst_range |= handle_jpeg(&c->opts.dst_format);
2097+ src_format = sws->src_format;
2098+ dst_format = sws->dst_format;
2099+ sws->src_range |= handle_jpeg(&sws->src_format);
2100+ sws->dst_range |= handle_jpeg(&sws->dst_format);
21062101
2107− if (src_format != c->opts.src_format || dst_format != c->opts.dst_format)
2102+ if (src_format != sws->src_format || dst_format != sws->dst_format)
21082103 av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n");
21092104
2110− if (c->opts.threads != 1) {
2105+ if (sws->threads != 1) {
21112106 ret = context_init_threaded(sws, srcFilter, dstFilter);
2112− if (ret < 0 || c->opts.threads > 1)
2107+ if (ret < 0 || sws->threads > 1)
21132108 return ret;
21142109 // threading disabled in this build, init as single-threaded
21152110 }
tests/checkasm/sw_gbrp.c+8−8
@@ -135,13 +135,13 @@ static void check_output_yuv2gbrp(void) · 134 unmodified lines
135135 fail();
136136
137137 c = sws_internal(sws);
138− c->opts.flags |= SWS_FULL_CHR_H_INT;
138+ sws->flags |= SWS_FULL_CHR_H_INT;
139139
140140 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
141141 for (fsi = 0; fsi < FILTER_SIZES; fsi++) {
142142 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) {
143143 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
144− c->opts.dst_format = planar_fmts[fmi];
144+ sws->dst_format = planar_fmts[fmi];
145145
146146 dstW = input_sizes[isi];
147147 luma_filter_size = filter_sizes[fsi];
@@ -229,8 +229,8 @@ static void check_input_planar_rgb_to_y(void) · 81 unmodified lines
229229 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
230230 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) {
231231 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
232− c->opts.src_format = planar_fmts[fmi];
233− c->opts.dst_format = AV_PIX_FMT_YUVA444P16;
232+ sws->src_format = planar_fmts[fmi];
233+ sws->dst_format = AV_PIX_FMT_YUVA444P16;
234234 byte_size = 2;
235235 dstW = input_sizes[isi];
236236
@@ -300,8 +300,8 @@ static void check_input_planar_rgb_to_uv(void) · 63 unmodified lines
300300 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
301301 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) {
302302 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
303− c->opts.src_format = planar_fmts[fmi];
304− c->opts.dst_format = AV_PIX_FMT_YUVA444P16;
303+ sws->src_format = planar_fmts[fmi];
304+ sws->dst_format = AV_PIX_FMT_YUVA444P16;
305305 byte_size = 2;
306306 dstW = input_sizes[isi];
307307
@@ -373,8 +373,8 @@ static void check_input_planar_rgb_to_a(void) · 65 unmodified lines
373373 if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA))
374374 continue;
375375
376− c->opts.src_format = planar_fmts[fmi];
377− c->opts.dst_format = AV_PIX_FMT_YUVA444P16;
376+ sws->src_format = planar_fmts[fmi];
377+ sws->dst_format = AV_PIX_FMT_YUVA444P16;
378378 byte_size = 2;
379379 dstW = input_sizes[isi];
380380
tests/checkasm/sw_range_convert.c+8−8
@@ -73,16 +73,16 @@ static void check_lumConvertRange(int from) · 72 unmodified lines
7373 fail();
7474
7575 c = sws_internal(sws);
76− c->opts.src_range = from;
77− c->opts.dst_range = !from;
76+ sws->src_range = from;
77+ sws->dst_range = !from;
7878
7979 for (int pfi = 0; pfi < FF_ARRAY_ELEMS(pixel_formats); pfi++) {
8080 enum AVPixelFormat pix_fmt = pixel_formats[pfi];
8181 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
8282 int bit_depth = desc->comp[0].depth;
8383 int sample_size = bit_depth == 16 ? sizeof(int32_t) : sizeof(int16_t);
84− c->opts.src_format = pix_fmt;
85− c->opts.dst_format = pix_fmt;
84+ sws->src_format = pix_fmt;
85+ sws->dst_format = pix_fmt;
8686 c->dstBpc = bit_depth;
8787 ff_sws_init_scale(c);
8888 for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
@@ -123,16 +123,16 @@ static void check_chrConvertRange(int from) · 34 unmodified lines
123123 fail();
124124
125125 c = sws_internal(sws);
126− c->opts.src_range = from;
127− c->opts.dst_range = !from;
126+ sws->src_range = from;
127+ sws->dst_range = !from;
128128
129129 for (int pfi = 0; pfi < FF_ARRAY_ELEMS(pixel_formats); pfi++) {
130130 enum AVPixelFormat pix_fmt = pixel_formats[pfi];
131131 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
132132 int bit_depth = desc->comp[0].depth;
133133 int sample_size = bit_depth == 16 ? sizeof(int32_t) : sizeof(int16_t);
134− c->opts.src_format = pix_fmt;
135− c->opts.dst_format = pix_fmt;
134+ sws->src_format = pix_fmt;
135+ sws->dst_format = pix_fmt;
136136 c->dstBpc = bit_depth;
137137 ff_sws_init_scale(c);
138138 for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
tests/checkasm/sw_rgb.c+16−13
@@ -127,9 +127,10 @@ static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int a · 126 unmodified lines
127127 return 0;
128128 }
129129
130−static void check_rgb24toyv12(SwsInternal *ctx)
130+static void check_rgb24toyv12(SwsContext *sws)
131131 {
132132 static const int input_sizes[] = {16, 128, 512, MAX_LINE_SIZE, -MAX_LINE_SIZE};
133+ SwsInternal *ctx = sws_internal(sws);
133134
134135 LOCAL_ALIGNED_32(uint8_t, src, [BUFSIZE * 3]);
135136 LOCAL_ALIGNED_32(uint8_t, buf_y_0, [BUFSIZE]);
@@ -353,8 +354,10 @@ static const enum AVPixelFormat rgb_formats[] = { · 217 unmodified lines
353354 AV_PIX_FMT_ARGB,
354355 };
355356
356−static void check_rgb_to_y(SwsInternal *ctx)
357+static void check_rgb_to_y(SwsContext *sws)
357358 {
359+ SwsInternal *ctx = sws_internal(sws);
360+
358361 LOCAL_ALIGNED_16(uint8_t, src24, [MAX_LINE_SIZE * 3]);
359362 LOCAL_ALIGNED_16(uint8_t, src32, [MAX_LINE_SIZE * 4]);
360363 LOCAL_ALIGNED_32(uint8_t, dst0_y, [MAX_LINE_SIZE * 2]);
@@ -370,7 +373,7 @@ static void check_rgb_to_y(SwsInternal *ctx) · 9 unmodified lines
370373 for (int i = 0; i < FF_ARRAY_ELEMS(rgb_formats); i++) {
371374 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(rgb_formats[i]);
372375
373− ctx->opts.src_format = rgb_formats[i];
376+ sws->src_format = rgb_formats[i];
374377 ff_sws_init_scale(ctx);
375378
376379 for (int j = 0; j < FF_ARRAY_ELEMS(input_sizes); j++) {
@@ -389,15 +392,17 @@ static void check_rgb_to_y(SwsInternal *ctx) · 12 unmodified lines
389392
390393 if (desc->nb_components == 3 ||
391394 // only bench native endian formats
392− (ctx->opts.src_format == AV_PIX_FMT_RGB32 || ctx->opts.src_format == AV_PIX_FMT_RGB32_1))
395+ (sws->src_format == AV_PIX_FMT_RGB32 || sws->src_format == AV_PIX_FMT_RGB32_1))
393396 bench_new(dst1_y, src, NULL, NULL, w, ctx->input_rgb2yuv_table, NULL);
394397 }
395398 }
396399 }
397400 }
398401
399−static void check_rgb_to_uv(SwsInternal *ctx)
402+static void check_rgb_to_uv(SwsContext *sws)
400403 {
404+ SwsInternal *ctx = sws_internal(sws);
405+
401406 LOCAL_ALIGNED_16(uint8_t, src24, [MAX_LINE_SIZE * 3]);
402407 LOCAL_ALIGNED_16(uint8_t, src32, [MAX_LINE_SIZE * 4]);
403408 LOCAL_ALIGNED_16(uint8_t, dst0_u, [MAX_LINE_SIZE * 2]);
@@ -417,8 +422,8 @@ static void check_rgb_to_uv(SwsInternal *ctx) · 13 unmodified lines
417422 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src_fmt);
418423
419424 ctx->chrSrcHSubSample = (i % 2) ? 0 : 1;
420− ctx->opts.src_format = src_fmt;
421− ctx->opts.dst_format = ctx->chrSrcHSubSample ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV444P;
425+ sws->src_format = src_fmt;
426+ sws->dst_format = ctx->chrSrcHSubSample ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV444P;
422427 ff_sws_init_scale(ctx);
423428
424429 for (int j = 0; j < FF_ARRAY_ELEMS(input_sizes); j++) {
@@ -441,7 +446,7 @@ static void check_rgb_to_uv(SwsInternal *ctx) · 16 unmodified lines
441446
442447 if (desc->nb_components == 3 ||
443448 // only bench native endian formats
444− (ctx->opts.src_format == AV_PIX_FMT_RGB32 || ctx->opts.src_format == AV_PIX_FMT_RGB32_1))
449+ (sws->src_format == AV_PIX_FMT_RGB32 || sws->src_format == AV_PIX_FMT_RGB32_1))
445450 bench_new(dst1_u, dst1_v, NULL, src, src, w, ctx->input_rgb2yuv_table, NULL);
446451 }
447452 }
@@ -451,7 +456,6 @@ static void check_rgb_to_uv(SwsInternal *ctx) · 3 unmodified lines
451456 void checkasm_check_sw_rgb(void)
452457 {
453458 SwsContext *sws;
454− SwsInternal *c;
455459
456460 ff_sws_rgb2rgb_init();
457461
@@ -485,14 +489,13 @@ void checkasm_check_sw_rgb(void) · 27 unmodified lines
485489 if (!sws)
486490 fail();
487491
488− c = sws_internal(sws);
489− check_rgb_to_y(c);
492+ check_rgb_to_y(sws);
490493 report("rgb_to_y");
491494
492− check_rgb_to_uv(c);
495+ check_rgb_to_uv(sws);
493496 report("rgb_to_uv");
494497
495− check_rgb24toyv12(c);
498+ check_rgb24toyv12(sws);
496499 report("rgb24toyv12");
497500
498501 sws_freeContext(sws);
tests/checkasm/sw_scale.c+11−11
@@ -123,12 +123,12 @@ static void check_yuv2yuv1(int accurate) · 122 unmodified lines
123123 randomize_buffers((uint8_t*)dither, 8);
124124 randomize_buffers((uint8_t*)src_pixels, LARGEST_INPUT_SIZE * sizeof(int16_t));
125125 sws = sws_alloc_context();
126− c = sws_internal(sws);
127126 if (accurate)
128− c->opts.flags |= SWS_ACCURATE_RND;
127+ sws->flags |= SWS_ACCURATE_RND;
129128 if (sws_init_context(sws, NULL, NULL) < 0)
130129 fail();
131130
131+ c = sws_internal(sws);
132132 ff_sws_init_scale(c);
133133 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi) {
134134 dstW = input_sizes[isi];
@@ -190,12 +190,12 @@ static void check_yuv2yuvX(int accurate) · 55 unmodified lines
190190 memset(dither, d_val, LARGEST_INPUT_SIZE);
191191 randomize_buffers((uint8_t*)src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t));
192192 sws = sws_alloc_context();
193− c = sws_internal(sws);
194193 if (accurate)
195− c->opts.flags |= SWS_ACCURATE_RND;
194+ sws->flags |= SWS_ACCURATE_RND;
196195 if (sws_init_context(sws, NULL, NULL) < 0)
197196 fail();
198197
198+ c = sws_internal(sws);
199199 ff_sws_init_scale(c);
200200 for(isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi){
201201 dstW = input_sizes[isi];
@@ -341,20 +341,20 @@ static void check_hscale(void) · 139 unmodified lines
341341
342342 filter[SRC_PIXELS * width + i] = rnd();
343343 }
344− c->opts.dst_w = c->chrDstW = input_sizes[dstWi];
344+ sws->dst_w = c->chrDstW = input_sizes[dstWi];
345345 ff_sws_init_scale(c);
346346 memcpy(filterAvx2, filter, sizeof(uint16_t) * (SRC_PIXELS * MAX_FILTER_WIDTH + MAX_FILTER_WIDTH));
347− ff_shuffle_filter_coefficients(c, filterPosAvx, width, filterAvx2, c->opts.dst_w);
347+ ff_shuffle_filter_coefficients(c, filterPosAvx, width, filterAvx2, sws->dst_w);
348348
349− if (check_func(c->hcScale, "hscale_%d_to_%d__fs_%d_dstW_%d", c->srcBpc, c->dstBpc + 1, width, c->opts.dst_w)) {
349+ if (check_func(c->hcScale, "hscale_%d_to_%d__fs_%d_dstW_%d", c->srcBpc, c->dstBpc + 1, width, sws->dst_w)) {
350350 memset(dst0, 0, SRC_PIXELS * sizeof(dst0[0]));
351351 memset(dst1, 0, SRC_PIXELS * sizeof(dst1[0]));
352352
353− call_ref(NULL, dst0, c->opts.dst_w, src, filter, filterPos, width);
354− call_new(NULL, dst1, c->opts.dst_w, src, filterAvx2, filterPosAvx, width);
355− if (memcmp(dst0, dst1, c->opts.dst_w * sizeof(dst0[0])))
353+ call_ref(NULL, dst0, sws->dst_w, src, filter, filterPos, width);
354+ call_new(NULL, dst1, sws->dst_w, src, filterAvx2, filterPosAvx, width);
355+ if (memcmp(dst0, dst1, sws->dst_w * sizeof(dst0[0])))
356356 fail();
357− bench_new(NULL, dst0, c->opts.dst_w, src, filter, filterPosAvx, width);
357+ bench_new(NULL, dst0, sws->dst_w, src, filter, filterPosAvx, width);
358358 }
359359 }
360360 }

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