62 #define OFFSET(x) offsetof(TestSourceContext, x)
94 frame_rate_q.
den <= 0 || frame_rate_q.
num <= 0) {
106 test->
max_pts = duration >= 0 ?
112 test->
w, test->
h, frame_rate_q.
num, frame_rate_q.
den,
122 outlink->
w = test->
w;
123 outlink->
h = test->
h;
141 picref->
pts = test->
pts++;
153 #if CONFIG_TESTSRC_FILTER
155 static const char *testsrc_get_name(
void *ctx)
160 static const AVClass testsrc_class = {
162 .item_name = testsrc_get_name,
178 static void draw_rectangle(
unsigned val,
uint8_t *dst,
int dst_linesize,
unsigned segment_width,
179 unsigned x,
unsigned y,
unsigned w,
unsigned h)
184 dst += segment_width * (step * x + y * dst_linesize);
185 w *= segment_width *
step;
187 for (i = 0; i < h; i++) {
193 static void draw_digit(
int digit,
uint8_t *dst,
unsigned dst_linesize,
194 unsigned segment_width)
199 #define LEFT_TOP_VBAR 8
200 #define LEFT_BOT_VBAR 16
201 #define RIGHT_TOP_VBAR 32
202 #define RIGHT_BOT_VBAR 64
214 static const unsigned char masks[10] = {
215 TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
216 RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
217 TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
218 TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
219 MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
220 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
221 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
222 TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
223 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
224 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
226 unsigned mask = masks[digit];
229 draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13);
232 draw_rectangle(255, dst, dst_linesize, segment_width,
233 segments[i].x, segments[i].y, segments[i].w, segments[i].h);
236 #define GRADIENT_SIZE (6 * 256)
243 int color, color_rest;
247 int dquad_x, dquad_y;
248 int grad, dgrad, rgrad, drgrad;
257 radius = (width +
height) / 4;
258 quad0 = width * width / 4 + height * height / 4 - radius * radius;
261 for (y = 0; y <
height; y++) {
267 for (x = 0; x <
width; x++) {
273 *(p++) = icolor & 1 ? 255 : 0;
274 *(p++) = icolor & 2 ? 255 : 0;
275 *(p++) = icolor & 4 ? 255 : 0;
277 if (color_rest >= width) {
288 p = data + picref->
linesize[0] * height * 3/4;
292 dgrad = GRADIENT_SIZE /
width;
293 drgrad = GRADIENT_SIZE %
width;
294 for (x = 0; x <
width; x++) {
296 grad < 256 || grad >= 5 * 256 ? 255 :
297 grad >= 2 * 256 && grad < 4 * 256 ? 0 :
298 grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
300 grad >= 4 * 256 ? 0 :
301 grad >= 1 * 256 && grad < 3 * 256 ? 255 :
302 grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
305 grad >= 3 * 256 && grad < 5 * 256 ? 255 :
306 grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
309 if (rgrad >= GRADIENT_SIZE) {
311 rgrad -= GRADIENT_SIZE;
313 if (grad >= GRADIENT_SIZE)
314 grad -= GRADIENT_SIZE;
316 for (y = height / 8; y > 0; y--) {
317 memcpy(p, p - picref->
linesize[0], 3 * width);
322 seg_size = width / 80;
323 if (seg_size >= 1 && height >= 13 * seg_size) {
325 x = width - (width - seg_size * 64) / 2;
326 y = (height - seg_size * 13) / 2;
327 p = data + (x*3 + y * picref->
linesize[0]);
328 for (i = 0; i < 8; i++) {
329 p -= 3 * 8 * seg_size;
330 draw_digit(second % 10, p, picref->
linesize[0], seg_size);
342 test->
class = &testsrc_class;
356 static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
376 .
outputs = avfilter_vsrc_testsrc_outputs,
381 #if CONFIG_RGBTESTSRC_FILTER
383 static const char *rgbtestsrc_get_name(
void *ctx)
388 static const AVClass rgbtestsrc_class = {
390 .item_name = rgbtestsrc_get_name,
399 static void rgbtest_put_pixel(
uint8_t *dst,
int dst_linesize,
407 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4);
break;
408 case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4);
break;
409 case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3);
break;
410 case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3);
break;
411 case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3);
break;
412 case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3);
break;
415 v = (r << (rgba_map[
R]*8)) + (g << (rgba_map[
G]*8)) + (b << (rgba_map[
B]*8));
416 p = dst + 3*x + y*dst_linesize;
423 v = (r << (rgba_map[
R]*8)) + (g << (rgba_map[
G]*8)) + (b << (rgba_map[
B]*8));
424 p = dst + 4*x + y*dst_linesize;
435 for (y = 0; y < h; y++) {
436 for (x = 0; x < picref->
video->
w; x++) {
438 int r = 0, g = 0, b = 0;
441 else if (3*y < 2*h) g = c;
444 rgbtest_put_pixel(picref->
data[0], picref->
linesize[0], x, y, r, g, b,
454 test->
class = &rgbtestsrc_class;
477 switch (outlink->
format) {
489 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
494 .config_props = rgbtest_config_props,
499 AVFilter avfilter_vsrc_rgbtestsrc = {
500 .
name =
"rgbtestsrc",
503 .
init = rgbtest_init,
509 .
outputs = avfilter_vsrc_rgbtestsrc_outputs,
#define AV_PIX_FMT_BGR565
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
AVFilterBufferRefVideoProps * video
video buffer specific properties
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
#define AV_PIX_FMT_RGB444
int linesize[8]
number of bytes per line
static const AVFilterPad outputs[]
packed RGB 8:8:8, 24bpp, RGBRGB...
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
#define AV_PIX_FMT_BGR444
int h
agreed upon image height
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
#define AV_PIX_FMT_BGR555
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
void(* fill_picture_fn)(AVFilterContext *ctx, AVFilterBufferRef *picref)
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_PIX_FMT_RGB555
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static double av_q2d(AVRational a)
Convert rational to double.
int key_frame
1 -> keyframe, 0-> not
static int request_frame(AVFilterLink *outlink)
static const AVOption testsrc_options[]
AVRational pixel_aspect
pixel aspect ratio
#define AV_PIX_FMT_RGB565
static int init(AVCodecParserContext *s)
int64_t pts
presentation timestamp.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
static const uint16_t mask[17]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void * priv
private data for use by the filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
void av_log(void *avcl, int level, const char *fmt,...)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int w
agreed upon image width
AVRational sar
sample aspect ratio
static int config_props(AVFilterLink *outlink)
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterContext * src
source filter
static av_cold int init_common(AVFilterContext *ctx, const char *args)
int format
agreed upon media format
char * rate
video frame rate
A reference to an AVFilterBuffer.
static void test(const char *base, const char *rel)
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
enum AVPictureType pict_type
picture type of the frame
Describe the class of an AVClass context structure.
#define FF_ARRAY_ELEMS(a)
static const AVFilterPad inputs[]
rational number numerator/denominator
const char * name
filter name
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
char * duration
total duration of the generated video
AVFilterLink ** outputs
array of pointers to output links
int interlaced
is frame interlaced
common internal and external API header
char * size
video frame size
static const uint8_t color[]
#define AV_PERM_WRITE
can write to the buffer
int64_t pos
byte position in stream, -1 if unknown
uint8_t * data[8]
picture/audio data for each plane
AVPixelFormat
Pixel format.