[FFmpeg-devel] [PATCH] lavu: introduce av_parse_ratio() and use it in ffmpeg and lavfi/aspect

Michael Niedermayer michaelni at gmx.at
Sat Jan 28 00:15:32 CET 2012


On Fri, Jan 27, 2012 at 10:51:25PM +0100, Stefano Sabatini wrote:
> On date Friday 2012-01-27 19:58:16 +0100, Michael Niedermayer encoded:
> > On Fri, Jan 27, 2012 at 12:53:44PM +0100, Stefano Sabatini wrote:
> [...]
> > > -static double parse_frame_aspect_ratio(const char *arg)
> > > -{
> > > -    int x = 0, y = 0;
> > > -    double ar = 0;
> > > -    const char *p;
> > > -    char *end;
> > > -
> > > -    p = strchr(arg, ':');
> > > -    if (p) {
> > > -        x = strtol(arg, &end, 10);
> > > -        if (end == p)
> > > -            y = strtol(end + 1, &end, 10);
> > > -        if (x > 0 && y > 0)
> > > -            ar = (double)x / (double)y;
> > > -    } else
> > > -        ar = strtod(arg, NULL);
> > > -
> > > -    if (!ar) {
> > > -        av_log(NULL, AV_LOG_FATAL, "Incorrect aspect ratio specification.\n");
> > > -        exit_program(1);
> > > -    }
> > > -    return ar;
> > > -}
> > > -
> > >  static int opt_video_channel(const char *opt, const char *arg)
> > >  {
> > >      av_log(NULL, AV_LOG_WARNING, "This option is deprecated, use -channel.\n");
> > > @@ -3998,8 +3974,15 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
> > >          }
> > >  
> > >          MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st);
> > > -        if (frame_aspect_ratio)
> > > -            ost->frame_aspect_ratio = parse_frame_aspect_ratio(frame_aspect_ratio);
> > > +        if (frame_aspect_ratio) {
> > > +            AVRational q;
> > > +            if (av_parse_ratio(&q, frame_aspect_ratio, 255, 0, NULL) < 0 ||
> > > +                q.num <= 0 || q.den <= 0) {
> > > +                av_log(NULL, AV_LOG_FATAL, "Invalid aspect ratio: %s\n", frame_aspect_ratio);
> > > +                exit_program(1);
> > > +            }
> > > +            ost->frame_aspect_ratio = av_q2d(q);
> > > +        }
> > 
> > how can a undefined aspect be specified ?
> > (use case would be a few files with wrong but unknown aspect as input)
> 
> Currently you can't (num > 0 && den > 0 or fail), and I don't want to
> change the behavior with this patch.

agree

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120128/9c8f1ed1/attachment.asc>


More information about the ffmpeg-devel mailing list