]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vsrc_testsrc.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavfilter / vsrc_testsrc.c
index 4ba0b5252561fac5946726e0c42c376b4a9824d9..5de7abf51fec57c8de8db290af2cbb7cf4dd53c4 100644 (file)
 #include "libavutil/intreadwrite.h"
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
+#include "formats.h"
+#include "video.h"
 
 typedef struct {
     const AVClass *class;
-    int h, w;
+    int w, h;
     unsigned int nb_frame;
     AVRational time_base;
     int64_t pts, max_pts;
-    char *size;                 ///< video frame size
     char *rate;                 ///< video frame rate
     char *duration;             ///< total duration of the generated video
     AVRational sar;             ///< sample aspect ratio
@@ -58,8 +59,8 @@ typedef struct {
 #define OFFSET(x) offsetof(TestSourceContext, x)
 
 static const AVOption testsrc_options[]= {
-    { "size",     "set video size",     OFFSET(size),     AV_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 },
-    { "s",        "set video size",     OFFSET(size),     AV_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 },
+    { "size",     "set video size",     OFFSET(w),        AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0 },
+    { "s",        "set video size",     OFFSET(w),        AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0 },
     { "rate",     "set video rate",     OFFSET(rate),     AV_OPT_TYPE_STRING, {.str = "25"},      0, 0 },
     { "r",        "set video rate",     OFFSET(rate),     AV_OPT_TYPE_STRING, {.str = "25"},      0, 0 },
     { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL},      0, 0 },
@@ -84,12 +85,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
         return ret;
     }
 
-    if ((ret = av_parse_video_size(&test->w, &test->h, test->size)) < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'\n", test->size);
-        return ret;
-    }
-    av_freep(&test->size);
-
     if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0 ||
         frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
         av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->rate);
@@ -153,9 +148,9 @@ static int request_frame(AVFilterLink *outlink)
     test->fill_picture_fn(outlink->src, picref);
     test->nb_frame++;
 
-    avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
-    avfilter_draw_slice(outlink, 0, picref->video->h, 1);
-    avfilter_end_frame(outlink);
+    ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
+    ff_draw_slice(outlink, 0, picref->video->h, 1);
+    ff_end_frame(outlink);
     avfilter_unref_buffer(picref);
 
     return 0;
@@ -163,14 +158,9 @@ static int request_frame(AVFilterLink *outlink)
 
 #if CONFIG_NULLSRC_FILTER
 
-static const char *nullsrc_get_name(void *ctx)
-{
-    return "nullsrc";
-}
-
 static const AVClass nullsrc_class = {
     .class_name = "NullSourceContext",
-    .item_name  = nullsrc_get_name,
+    .item_name  = av_default_item_name,
     .option     = testsrc_options,
 };
 
@@ -203,14 +193,9 @@ AVFilter avfilter_vsrc_nullsrc = {
 
 #if CONFIG_TESTSRC_FILTER
 
-static const char *testsrc_get_name(void *ctx)
-{
-    return "testsrc";
-}
-
 static const AVClass testsrc_class = {
     .class_name = "TestSourceContext",
-    .item_name  = testsrc_get_name,
+    .item_name  = av_default_item_name,
     .option     = testsrc_options,
 };
 
@@ -405,7 +390,7 @@ static int test_query_formats(AVFilterContext *ctx)
     static const enum PixelFormat pix_fmts[] = {
         PIX_FMT_RGB24, PIX_FMT_NONE
     };
-    avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
+    ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
     return 0;
 }
 
@@ -430,14 +415,9 @@ AVFilter avfilter_vsrc_testsrc = {
 
 #if CONFIG_RGBTESTSRC_FILTER
 
-static const char *rgbtestsrc_get_name(void *ctx)
-{
-    return "rgbtestsrc";
-}
-
 static const AVClass rgbtestsrc_class = {
     .class_name = "RGBTestSourceContext",
-    .item_name  = rgbtestsrc_get_name,
+    .item_name  = av_default_item_name,
     .option     = testsrc_options,
 };
 
@@ -516,7 +496,7 @@ static int rgbtest_query_formats(AVFilterContext *ctx)
         PIX_FMT_RGB555, PIX_FMT_BGR555,
         PIX_FMT_NONE
     };
-    avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
+    ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
     return 0;
 }