[FFmpeg-devel] [PATCH 6/6] lavfi/mptestsrc: make use of AV_OPT_TYPE_VIDEO_RATE

Paul B Mahol onemda at gmail.com
Tue Mar 26 14:22:09 CET 2013


On 3/26/13, Clement Boesch <ubitux at gmail.com> wrote:
> On Tue, Mar 26, 2013 at 12:26:35PM +0000, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavfilter/vsrc_mptestsrc.c | 24 ++++++++----------------
>>  1 file changed, 8 insertions(+), 16 deletions(-)
>>
>> diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
>> index 05a1af6..6d59900 100644
>> --- a/libavfilter/vsrc_mptestsrc.c
>> +++ b/libavfilter/vsrc_mptestsrc.c
>> @@ -53,18 +53,18 @@ enum test_type {
>>  typedef struct MPTestContext {
>>      const AVClass *class;
>>      unsigned int frame_nb;
>> -    AVRational time_base;
>> +    AVRational frame_rate;
>>      int64_t pts, max_pts;
>>      int hsub, vsub;
>> -    char *size, *rate, *duration;
>> +    char *size, *duration;
>>      enum test_type test;
>>  } MPTestContext;
>>
>>  #define OFFSET(x) offsetof(MPTestContext, x)
>>  #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
>>  static const AVOption mptestsrc_options[]= {
>> -    { "rate",     "set video rate",     OFFSET(rate),
>> AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS },
>> -    { "r",        "set video rate",     OFFSET(rate),
>> AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS },
>> +    { "rate",     "set video rate",     OFFSET(frame_rate),
>> AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
>> +    { "r",        "set video rate",     OFFSET(frame_rate),
>> AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
>>      { "duration", "set video duration", OFFSET(duration),
>> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
>>      { "d",        "set video duration", OFFSET(duration),
>> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
>>
>> @@ -259,7 +259,6 @@ static void ring2_test(uint8_t *dst, int dst_linesize,
>> int off)
>>  static av_cold int init(AVFilterContext *ctx, const char *args)
>>  {
>>      MPTestContext *test = ctx->priv;
>> -    AVRational frame_rate_q;
>>      int64_t duration = -1;
>>      int ret;
>>
>> @@ -269,26 +268,19 @@ static av_cold int init(AVFilterContext *ctx, const
>> char *args)
>>      if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0)
>>          return ret;
>>
>> -    if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0) {
>> -        av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n",
>> test->rate);
>> -        return ret;
>> -    }
>> -
>>      if ((test->duration) && (ret = av_parse_time(&duration,
>> test->duration, 1)) < 0) {
>>          av_log(ctx, AV_LOG_ERROR, "Invalid duration: '%s'\n",
>> test->duration);
>>          return ret;
>>      }
>>
>> -    test->time_base.num = frame_rate_q.den;
>> -    test->time_base.den = frame_rate_q.num;
>>      test->max_pts = duration >= 0 ?
>> -        av_rescale_q(duration, AV_TIME_BASE_Q, test->time_base) : -1;
>> +        av_rescale_q(duration, AV_TIME_BASE_Q, test->frame_rate) : -1;
>
> frame_rate has not been swapped, this will likely not behave as expected.
>
>>      test->frame_nb = 0;
>>      test->pts = 0;
>>
>>      av_log(ctx, AV_LOG_VERBOSE, "rate:%d/%d duration:%f\n",
>> -           frame_rate_q.num, frame_rate_q.den,
>> -           duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base));
>> +           test->frame_rate.num, test->frame_rate.den,
>> +           duration < 0 ? -1 : test->max_pts *
>> av_q2d(test->frame_rate));
>>      init_idct();
>>
>>      return 0;
>> @@ -305,7 +297,7 @@ static int config_props(AVFilterLink *outlink)
>>
>>      outlink->w = WIDTH;
>>      outlink->h = HEIGHT;
>> -    outlink->time_base = test->time_base;
>> +    outlink->time_base = test->frame_rate;
>>
>
> ditto.

fixed all and applied.

>
>
> --
> Clement B.
>


More information about the ffmpeg-devel mailing list