Browse code

vsrc_testsrc: allow to set the sample aspect ratio

Add the sar option. Useful for debugging/testing purposes.

Stefano Sabatini authored on 2011/08/21 22:12:40
Showing 3 changed files
... ...
@@ -2340,6 +2340,9 @@ generated per second. It has to be a string in the format
2340 2340
 number or a valid video frame rate abbreviation. The default value is
2341 2341
 "25".
2342 2342
 
2343
+@item sar
2344
+Set the sample aspect ratio of the sourced video.
2345
+
2343 2346
 @item duration
2344 2347
 Set the video duration of the sourced video. The accepted syntax is:
2345 2348
 @example
... ...
@@ -30,7 +30,7 @@
30 30
 
31 31
 #define LIBAVFILTER_VERSION_MAJOR  2
32 32
 #define LIBAVFILTER_VERSION_MINOR 34
33
-#define LIBAVFILTER_VERSION_MICRO  0
33
+#define LIBAVFILTER_VERSION_MICRO  1
34 34
 
35 35
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 36
                                                LIBAVFILTER_VERSION_MINOR, \
... ...
@@ -46,6 +46,8 @@ typedef struct {
46 46
     char *size;                 ///< video frame size
47 47
     char *rate;                 ///< video frame rate
48 48
     char *duration;             ///< total duration of the generated video
49
+    AVRational sar;             ///< sample aspect ratio
50
+
49 51
     void (* fill_picture_fn)(AVFilterContext *ctx, AVFilterBufferRef *picref);
50 52
 
51 53
     /* only used by rgbtest */
... ...
@@ -60,6 +62,7 @@ static const AVOption testsrc_options[]= {
60 60
     { "rate",     "set video rate",     OFFSET(rate),     FF_OPT_TYPE_STRING, {.str = "25"},      0, 0 },
61 61
     { "r",        "set video rate",     OFFSET(rate),     FF_OPT_TYPE_STRING, {.str = "25"},      0, 0 },
62 62
     { "duration", "set video duration", OFFSET(duration), FF_OPT_TYPE_STRING, {.str = NULL},      0, 0 },
63
+    { "sar",      "set video sample aspect ratio", OFFSET(sar), FF_OPT_TYPE_RATIONAL, {.dbl= 1},  0, INT_MAX },
63 64
     { NULL },
64 65
 };
65 66
 
... ...
@@ -100,9 +103,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
100 100
     test->nb_frame = 0;
101 101
     test->pts = 0;
102 102
 
103
-    av_log(ctx, AV_LOG_INFO, "size:%dx%d rate:%d/%d duration:%f\n",
103
+    av_log(ctx, AV_LOG_INFO, "size:%dx%d rate:%d/%d duration:%f sar:%d/%d\n",
104 104
            test->w, test->h, frame_rate_q.num, frame_rate_q.den,
105
-           duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base));
105
+           duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base),
106
+           test->sar.num, test->sar.den);
106 107
     return 0;
107 108
 }
108 109
 
... ...
@@ -112,6 +116,7 @@ static int config_props(AVFilterLink *outlink)
112 112
 
113 113
     outlink->w = test->w;
114 114
     outlink->h = test->h;
115
+    outlink->sample_aspect_ratio = test->sar;
115 116
     outlink->time_base = test->time_base;
116 117
 
117 118
     return 0;
... ...
@@ -127,6 +132,7 @@ static int request_frame(AVFilterLink *outlink)
127 127
     picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
128 128
                                        test->w, test->h);
129 129
     picref->pts = test->pts++;
130
+    picref->video->sample_aspect_ratio = test->sar;
130 131
     test->nb_frame++;
131 132
     test->fill_picture_fn(outlink->src, picref);
132 133