| @@ -71,6 +71,9 @@ typedef struct TestSourceContext { · 70 unmodified lines |
| 71 | /* only used by testsrc2 */ | 71 | /* only used by testsrc2 */ |
| 72 | int alpha; | 72 | int alpha; |
| 73 | | 73 | |
| | 74 | /* only used by yuvtest */ |
| | 75 | uint8_t ayuv_map[4]; |
| | 76 | |
| 74 | /* only used by colorspectrum */ | 77 | /* only used by colorspectrum */ |
| 75 | int type; | 78 | int type; |
| 76 | | 79 | |
| @@ -1141,118 +1144,56 @@ const AVFilter ff_vsrc_rgbtestsrc = { · 1064 unmodified lines |
| 1141 | | 1144 | |
| 1142 | #if CONFIG_YUVTESTSRC_FILTER | 1145 | #if CONFIG_YUVTESTSRC_FILTER |
| 1143 | | 1146 | |
| 1144 | static void yuvtest_fill_picture8(AVFilterContext *ctx, AVFrame *frame) | 1147 | #define Y 0 |
| 1145 | { | 1148 | #define U 1 |
| 1146 | int x, y, w = frame->width, h = frame->height / 3; | 1149 | #define V 2 |
| 1147 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); | | |
| 1148 | const int factor = 1 << desc->comp[0].depth; | | |
| 1149 | const int mid = 1 << (desc->comp[0].depth - 1); | | |
| 1150 | uint8_t *ydst = frame->data[0]; | | |
| 1151 | uint8_t *udst = frame->data[1]; | | |
| 1152 | uint8_t *vdst = frame->data[2]; | | |
| 1153 | ptrdiff_t ylinesize = frame->linesize[0]; | | |
| 1154 | ptrdiff_t ulinesize = frame->linesize[1]; | | |
| 1155 | ptrdiff_t vlinesize = frame->linesize[2]; | | |
| 1156 | | | |
| 1157 | for (y = 0; y < h; y++) { | | |
| 1158 | for (x = 0; x < w; x++) { | | |
| 1159 | int c = factor * x / w; | | |
| 1160 | | | |
| 1161 | ydst[x] = c; | | |
| 1162 | udst[x] = mid; | | |
| 1163 | vdst[x] = mid; | | |
| 1164 | } | | |
| 1165 | | | |
| 1166 | ydst += ylinesize; | | |
| 1167 | udst += ulinesize; | | |
| 1168 | vdst += vlinesize; | | |
| 1169 | } | | |
| 1170 | | | |
| 1171 | h += h; | | |
| 1172 | for (; y < h; y++) { | | |
| 1173 | for (x = 0; x < w; x++) { | | |
| 1174 | int c = factor * x / w; | | |
| 1175 | | | |
| 1176 | ydst[x] = mid; | | |
| 1177 | udst[x] = c; | | |
| 1178 | vdst[x] = mid; | | |
| 1179 | } | | |
| 1180 | | | |
| 1181 | ydst += ylinesize; | | |
| 1182 | udst += ulinesize; | | |
| 1183 | vdst += vlinesize; | | |
| 1184 | } | | |
| 1185 | | | |
| 1186 | for (; y < frame->height; y++) { | | |
| 1187 | for (x = 0; x < w; x++) { | | |
| 1188 | int c = factor * x / w; | | |
| 1189 | | 1150 | |
| 1190 | ydst[x] = mid; | 1151 | static void yuvtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4], |
| 1191 | udst[x] = mid; | 1152 | int i, int j, unsigned y, unsigned u, unsigned v, enum AVPixelFormat fmt, |
| 1192 | vdst[x] = c; | 1153 | uint8_t ayuv_map[4]) |
| 1193 | } | 1154 | { |
| | 1155 | uint32_t n; |
| 1194 | | 1156 | |
| 1195 | ydst += ylinesize; | 1157 | switch (fmt) { |
| 1196 | udst += ulinesize; | 1158 | case AV_PIX_FMT_YUV444P: |
| 1197 | vdst += vlinesize; | 1159 | case AV_PIX_FMT_YUVJ444P: |
| | 1160 | dstp[0][i + j*dst_linesizep[0]] = y; |
| | 1161 | dstp[1][i + j*dst_linesizep[1]] = u; |
| | 1162 | dstp[2][i + j*dst_linesizep[2]] = v; |
| | 1163 | break; |
| | 1164 | case AV_PIX_FMT_YUV444P9: |
| | 1165 | case AV_PIX_FMT_YUV444P10: |
| | 1166 | case AV_PIX_FMT_YUV444P12: |
| | 1167 | case AV_PIX_FMT_YUV444P14: |
| | 1168 | case AV_PIX_FMT_YUV444P16: |
| | 1169 | AV_WN16(&dstp[0][i*2 + j*dst_linesizep[0]], y); |
| | 1170 | AV_WN16(&dstp[1][i*2 + j*dst_linesizep[1]], u); |
| | 1171 | AV_WN16(&dstp[2][i*2 + j*dst_linesizep[2]], v); |
| | 1172 | break; |
| 1198 | } | 1173 | } |
| 1199 | } | 1174 | } |
| 1200 | | 1175 | |
| 1201 | static void yuvtest_fill_picture16(AVFilterContext *ctx, AVFrame *frame) | 1176 | static void yuvtest_fill_picture(AVFilterContext *ctx, AVFrame *frame) |
| 1202 | { | 1177 | { |
| 1203 | int x, y, w = frame->width, h = frame->height / 3; | 1178 | TestSourceContext *test = ctx->priv; |
| | 1179 | int i, j, w = frame->width, h = frame->height; |
| 1204 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); | 1180 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); |
| 1205 | const int factor = 1 << desc->comp[0].depth; | 1181 | const int factor = 1 << desc->comp[0].depth; |
| 1206 | const int mid = 1 << (desc->comp[0].depth - 1); | 1182 | const int mid = 1 << (desc->comp[0].depth - 1); |
| 1207 | uint16_t *ydst = (uint16_t *)frame->data[0]; | | |
| 1208 | uint16_t *udst = (uint16_t *)frame->data[1]; | | |
| 1209 | uint16_t *vdst = (uint16_t *)frame->data[2]; | | |
| 1210 | ptrdiff_t ylinesize = frame->linesize[0] / 2; | | |
| 1211 | ptrdiff_t ulinesize = frame->linesize[1] / 2; | | |
| 1212 | ptrdiff_t vlinesize = frame->linesize[2] / 2; | | |
| 1213 | | | |
| 1214 | for (y = 0; y < h; y++) { | | |
| 1215 | for (x = 0; x < w; x++) { | | |
| 1216 | int c = factor * x / w; | | |
| 1217 | | 1183 | |
| 1218 | ydst[x] = c; | 1184 | for (j = 0; j < h; j++) { |
| 1219 | udst[x] = mid; | 1185 | for (i = 0; i < w; i++) { |
| 1220 | vdst[x] = mid; | 1186 | int c = factor * i / w; |
| 1221 | } | 1187 | int y = mid, u = mid, v = mid; |
| 1222 | | | |
| 1223 | ydst += ylinesize; | | |
| 1224 | udst += ulinesize; | | |
| 1225 | vdst += vlinesize; | | |
| 1226 | } | | |
| 1227 | | 1188 | |
| 1228 | h += h; | 1189 | if (3*j < h ) y = c; |
| 1229 | for (; y < h; y++) { | 1190 | else if (3*j < 2*h) u = c; |
| 1230 | for (x = 0; x < w; x++) { | 1191 | else v = c; |
| 1231 | int c = factor * x / w; | | |
| 1232 | | | |
| 1233 | ydst[x] = mid; | | |
| 1234 | udst[x] = c; | | |
| 1235 | vdst[x] = mid; | | |
| 1236 | } | | |
| 1237 | | 1192 | |
| 1238 | ydst += ylinesize; | 1193 | yuvtest_put_pixel(frame->data, frame->linesize, i, j, y, u, v, |
| 1239 | udst += ulinesize; | 1194 | ctx->outputs[0]->format, test->ayuv_map); |
| 1240 | vdst += vlinesize; | 1195 | } |
| 1241 | } | 1196 | } |
| 1242 | | | |
| 1243 | for (; y < frame->height; y++) { | | |
| 1244 | for (x = 0; x < w; x++) { | | |
| 1245 | int c = factor * x / w; | | |
| 1246 | | | |
| 1247 | ydst[x] = mid; | | |
| 1248 | udst[x] = mid; | | |
| 1249 | vdst[x] = c; | | |
| 1250 | } | | |
| 1251 | | | |
| 1252 | ydst += ylinesize; | | |
| 1253 | udst += ulinesize; | | |
| 1254 | vdst += vlinesize; | | |
| 1255 | } | | |
| 1256 | } | 1197 | } |
| 1257 | | 1198 | |
| 1258 | static av_cold int yuvtest_init(AVFilterContext *ctx) | 1199 | static av_cold int yuvtest_init(AVFilterContext *ctx) |
| @@ -1260,6 +1201,7 @@ static av_cold int yuvtest_init(AVFilterContext *ctx) · 1 unmodified line |
| 1260 | TestSourceContext *test = ctx->priv; | 1201 | TestSourceContext *test = ctx->priv; |
| 1261 | | 1202 | |
| 1262 | test->draw_once = 1; | 1203 | test->draw_once = 1; |
| | 1204 | test->fill_picture_fn = yuvtest_fill_picture; |
| 1263 | return init(ctx); | 1205 | return init(ctx); |
| 1264 | } | 1206 | } |
| 1265 | | 1207 | |
| @@ -1274,9 +1216,8 @@ static const enum AVPixelFormat yuvtest_pix_fmts[] = { · 8 unmodified lines |
| 1274 | static int yuvtest_config_props(AVFilterLink *outlink) | 1216 | static int yuvtest_config_props(AVFilterLink *outlink) |
| 1275 | { | 1217 | { |
| 1276 | TestSourceContext *test = outlink->src->priv; | 1218 | TestSourceContext *test = outlink->src->priv; |
| 1277 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); | | |
| 1278 | | 1219 | |
| 1279 | test->fill_picture_fn = desc->comp[0].depth > 8 ? yuvtest_fill_picture16 : yuvtest_fill_picture8; | 1220 | ff_fill_ayuv_map(test->ayuv_map, outlink->format); |
| 1280 | return config_props(outlink); | 1221 | return config_props(outlink); |
| 1281 | } | 1222 | } |
| 1282 | | 1223 | |