62 #define OFFSET(x) offsetof(TestSourceContext, x) 63 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM 113 outlink->
w = test->
w;
114 outlink->
h = test->
h;
144 #if CONFIG_TESTSRC_FILTER 146 static const char *testsrc_get_name(
void *
ctx)
151 static const AVClass testsrc_class = {
153 .item_name = testsrc_get_name,
170 unsigned x,
unsigned y,
unsigned w,
unsigned h)
175 dst += segment_width * (step * x + y * dst_linesize);
176 w *= segment_width *
step;
178 for (i = 0; i <
h; i++) {
184 static void draw_digit(
int digit,
uint8_t *dst,
unsigned dst_linesize,
185 unsigned segment_width)
190 #define LEFT_TOP_VBAR 8 191 #define LEFT_BOT_VBAR 16 192 #define RIGHT_TOP_VBAR 32 193 #define RIGHT_BOT_VBAR 64 205 static const unsigned char masks[10] = {
206 TOP_HBAR |BOT_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
207 RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
208 TOP_HBAR|MID_HBAR|BOT_HBAR|LEFT_BOT_VBAR |RIGHT_TOP_VBAR,
209 TOP_HBAR|MID_HBAR|BOT_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
210 MID_HBAR |LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
211 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_BOT_VBAR,
212 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR |RIGHT_BOT_VBAR,
213 TOP_HBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
214 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR|LEFT_BOT_VBAR|RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
215 TOP_HBAR|BOT_HBAR|MID_HBAR|LEFT_TOP_VBAR |RIGHT_TOP_VBAR|RIGHT_BOT_VBAR,
217 unsigned mask = masks[digit];
224 segments[i].x, segments[i].y, segments[i].
w, segments[i].
h);
227 #define GRADIENT_SIZE (6 * 256) 234 int color, color_rest;
238 int dquad_x, dquad_y;
239 int grad, dgrad, rgrad, drgrad;
248 radius = (width +
height) / 4;
249 quad0 = width * width / 4 + height * height / 4 - radius * radius;
252 for (y = 0; y <
height; y++) {
258 for (x = 0; x <
width; x++) {
264 *(p++) = icolor & 1 ? 255 : 0;
265 *(p++) = icolor & 2 ? 255 : 0;
266 *(p++) = icolor & 4 ? 255 : 0;
268 if (color_rest >= width) {
279 p = data + frame->
linesize[0] * height * 3/4;
283 dgrad = GRADIENT_SIZE /
width;
284 drgrad = GRADIENT_SIZE %
width;
285 for (x = 0; x <
width; x++) {
287 grad < 256 || grad >= 5 * 256 ? 255 :
288 grad >= 2 * 256 && grad < 4 * 256 ? 0 :
289 grad < 2 * 256 ? 2 * 256 - 1 - grad : grad - 4 * 256;
291 grad >= 4 * 256 ? 0 :
292 grad >= 1 * 256 && grad < 3 * 256 ? 255 :
293 grad < 1 * 256 ? grad : 4 * 256 - 1 - grad;
296 grad >= 3 * 256 && grad < 5 * 256 ? 255 :
297 grad < 3 * 256 ? grad - 2 * 256 : 6 * 256 - 1 - grad;
300 if (rgrad >= GRADIENT_SIZE) {
302 rgrad -= GRADIENT_SIZE;
304 if (grad >= GRADIENT_SIZE)
305 grad -= GRADIENT_SIZE;
307 for (y = height / 8; y > 0; y--) {
308 memcpy(p, p - frame->
linesize[0], 3 * width);
313 seg_size = width / 80;
314 if (seg_size >= 1 && height >= 13 * seg_size) {
316 x = width - (width - seg_size * 64) / 2;
317 y = (height - seg_size * 13) / 2;
318 p = data + (x*3 + y * frame->
linesize[0]);
319 for (i = 0; i < 8; i++) {
320 p -= 3 * 8 * seg_size;
321 draw_digit(second % 10, p, frame->
linesize[0], seg_size);
346 static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
360 .priv_class = &testsrc_class,
367 .
outputs = avfilter_vsrc_testsrc_outputs,
372 #if CONFIG_RGBTESTSRC_FILTER 374 static const char *rgbtestsrc_get_name(
void *ctx)
379 static const AVClass rgbtestsrc_class = {
381 .item_name = rgbtestsrc_get_name,
390 static void rgbtest_put_pixel(
uint8_t *dst,
int dst_linesize,
398 case AV_PIX_FMT_BGR444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r >> 4) << 8) | ((
g >> 4) << 4) | (
b >> 4);
break;
399 case AV_PIX_FMT_RGB444: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b >> 4) << 8) | ((
g >> 4) << 4) | (
r >> 4);
break;
400 case AV_PIX_FMT_BGR555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r>>3)<<10) | ((
g>>3)<<5) | (
b>>3);
break;
401 case AV_PIX_FMT_RGB555: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b>>3)<<10) | ((
g>>3)<<5) | (
r>>3);
break;
402 case AV_PIX_FMT_BGR565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
r>>3)<<11) | ((
g>>2)<<5) | (
b>>3);
break;
403 case AV_PIX_FMT_RGB565: ((uint16_t*)(dst + y*dst_linesize))[x] = ((
b>>3)<<11) | ((
g>>2)<<5) | (
r>>3);
break;
406 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8));
407 p = dst + 3*x + y*dst_linesize;
414 v = (
r << (rgba_map[
R]*8)) + (
g << (rgba_map[
G]*8)) + (
b << (rgba_map[
B]*8));
415 p = dst + 4*x + y*dst_linesize;
426 for (y = 0; y <
h; y++) {
427 for (x = 0; x <
w; x++) {
429 int r = 0,
g = 0,
b = 0;
432 else if (3*y < 2*h)
g = c;
435 rgbtest_put_pixel(frame->
data[0], frame->
linesize[0], x, y, r,
g,
b,
467 switch (outlink->
format) {
479 static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
484 .config_props = rgbtest_config_props,
490 .
name =
"rgbtestsrc",
493 .priv_class = &rgbtestsrc_class,
494 .
init = rgbtest_init,
500 .
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
static void draw_rectangle(AVFormatContext *s)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
#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.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
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...
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 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
void(* fill_picture_fn)(AVFilterContext *ctx, AVFrame *frame)
#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 test(const char *pattern, const char *host)
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[]
static const uint8_t color[NB_LEVELS]
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
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_BGR565
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
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 av_cold int init(AVCodecParserContext *s)
int key_frame
1 -> keyframe, 0-> not
#define AV_PIX_FMT_RGB565
AVPixelFormat
Pixel format.