62 #define OFFSET(x) offsetof(TestSourceContext, x)
63 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
88 frame_rate_q.
den <= 0 || frame_rate_q.
num <= 0) {
100 test->
max_pts = duration >= 0 ?
106 test->
w, test->
h, frame_rate_q.
num, frame_rate_q.
den,
116 outlink->
w = test->
w;
117 outlink->
h = test->
h;
146 #if CONFIG_TESTSRC_FILTER
148 static const char *testsrc_get_name(
void *ctx)
153 static const AVClass testsrc_class = {
155 .item_name = testsrc_get_name,
171 static void draw_rectangle(
unsigned val,
uint8_t *dst,
int dst_linesize,
unsigned segment_width,
172 unsigned x,
unsigned y,
unsigned w,
unsigned h)
177 dst += segment_width * (step * x + y * dst_linesize);
178 w *= segment_width *
step;
180 for (i = 0; i < h; i++) {
186 static void draw_digit(
int digit,
uint8_t *dst,
unsigned dst_linesize,
187 unsigned segment_width)
192 #define LEFT_TOP_VBAR 8
193 #define LEFT_BOT_VBAR 16
194 #define RIGHT_TOP_VBAR 32
195 #define RIGHT_BOT_VBAR 64
207 static const unsigned char masks[10] = {
208 TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
209 RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
210 TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
211 TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
212 MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
213 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
214 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
215 TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
216 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
217 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
219 unsigned mask = masks[digit];
222 draw_rectangle(0, dst, dst_linesize, segment_width, 0, 0, 8, 13);
225 draw_rectangle(255, dst, dst_linesize, segment_width,
226 segments[i].x, segments[i].y, segments[i].w, segments[i].h);
229 #define GRADIENT_SIZE (6 * 256)
236 int color, color_rest;
240 int dquad_x, dquad_y;
241 int grad, dgrad, rgrad, drgrad;
250 radius = (width +
height) / 4;
251 quad0 = width * width / 4 + height * height / 4 - radius * radius;
254 for (y = 0; y <
height; y++) {
260 for (x = 0; x <
width; x++) {
266 *(p++) = icolor & 1 ? 255 : 0;
267 *(p++) = icolor & 2 ? 255 : 0;
268 *(p++) = icolor & 4 ? 255 : 0;
270 if (color_rest >= width) {
281 p = data + frame->
linesize[0] * height * 3/4;
285 dgrad = GRADIENT_SIZE /
width;
286 drgrad = GRADIENT_SIZE %
width;
287 for (x = 0; x <
width; x++) {
289 grad < 256 || grad >= 5 * 256 ? 255 :
290 grad >= 2 * 256 && grad < 4 * 256 ? 0 :
291 grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
293 grad >= 4 * 256 ? 0 :
294 grad >= 1 * 256 && grad < 3 * 256 ? 255 :
295 grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
298 grad >= 3 * 256 && grad < 5 * 256 ? 255 :
299 grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
302 if (rgrad >= GRADIENT_SIZE) {
304 rgrad -= GRADIENT_SIZE;
306 if (grad >= GRADIENT_SIZE)
307 grad -= GRADIENT_SIZE;
309 for (y = height / 8; y > 0; y--) {
310 memcpy(p, p - frame->
linesize[0], 3 * width);
315 seg_size = width / 80;
316 if (seg_size >= 1 && height >= 13 * seg_size) {
318 x = width - (width - seg_size * 64) / 2;
319 y = (height - seg_size * 13) / 2;
320 p = data + (x*3 + y * frame->
linesize[0]);
321 for (i = 0; i < 8; i++) {
322 p -= 3 * 8 * seg_size;
323 draw_digit(second % 10, p, frame->
linesize[0], seg_size);
348 static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
362 .priv_class = &testsrc_class,
369 .
outputs = avfilter_vsrc_testsrc_outputs,
374 #if CONFIG_RGBTESTSRC_FILTER
376 static const char *rgbtestsrc_get_name(
void *ctx)
381 static const AVClass rgbtestsrc_class = {
383 .item_name = rgbtestsrc_get_name,
392 static void rgbtest_put_pixel(
uint8_t *dst,
int dst_linesize,
400 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4);
break;
401 case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b >> 4) << 8) | ((g >> 4) << 4) | (r >> 4);
break;
402 case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<10) | ((g>>3)<<5) | (b>>3);
break;
403 case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<10) | ((g>>3)<<5) | (r>>3);
break;
404 case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((r>>3)<<11) | ((g>>2)<<5) | (b>>3);
break;
405 case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((b>>3)<<11) | ((g>>2)<<5) | (r>>3);
break;
408 v = (r << (rgba_map[
R]*8)) + (g << (rgba_map[
G]*8)) + (b << (rgba_map[
B]*8));
409 p = dst + 3*x + y*dst_linesize;
416 v = (r << (rgba_map[
R]*8)) + (g << (rgba_map[
G]*8)) + (b << (rgba_map[
B]*8));
417 p = dst + 4*x + y*dst_linesize;
428 for (y = 0; y < h; y++) {
429 for (x = 0; x < w; x++) {
431 int r = 0, g = 0, b = 0;
434 else if (3*y < 2*h) g = c;
437 rgbtest_put_pixel(frame->
data[0], frame->
linesize[0], x, y, r, g, b,
469 switch (outlink->
format) {
481 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
486 .config_props = rgbtest_config_props,
492 .
name =
"rgbtestsrc",
495 .priv_class = &rgbtestsrc_class,
496 .
init = rgbtest_init,
502 .
outputs = avfilter_vsrc_rgbtestsrc_outputs,
This structure describes decoded (raw) audio or video data.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
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.
static const AVFilterPad outputs[]
Main libavfilter public API header.
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.
int h
agreed upon image height
#define FF_ARRAY_ELEMS(a)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_PIX_FMT_RGB444
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...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static double av_q2d(AVRational a)
Convert rational to double.
static int request_frame(AVFilterLink *outlink)
static const AVOption testsrc_options[]
#define AVERROR_EOF
End of file.
int interlaced_frame
The content of the picture is interlaced.
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.
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static av_cold int init_common(AVFilterContext *ctx)
#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
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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
enum AVPictureType pict_type
Picture type of the frame.
static void test(const char *pattern, const char *host)
static int config_props(AVFilterLink *outlink)
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterContext * src
source filter
int format
agreed upon media format
char * rate
video frame rate
#define AV_PIX_FMT_BGR555
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Describe the class of an AVClass context structure.
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
#define AV_PIX_FMT_BGR565
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal and external API header
char * size
video frame size
#define AV_PIX_FMT_BGR444
#define AV_PIX_FMT_RGB555
static const uint8_t color[]
static av_cold int init(AVCodecParserContext *s)
int key_frame
1 -> keyframe, 0-> not
void(* fill_picture_fn)(AVFilterContext *ctx, AVFrame *frame)
#define AV_PIX_FMT_RGB565
AVPixelFormat
Pixel format.