Merge commit '277103e07fbe22fc8e4361bacd5c6b48133f3ba5' into release/0.10
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 9 Aug 2014 17:13:54 +0000 (19:13 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 9 Aug 2014 17:13:54 +0000 (19:13 +0200)
* commit '277103e07fbe22fc8e4361bacd5c6b48133f3ba5':
  video4linux2: Avoid a floating point exception

Conflicts:
avconv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
ffmpeg.c

diff --cc ffmpeg.c
+++ b/ffmpeg.c
@@@ -4690,35 -4009,44 +4690,36 @@@ static int opt_target(OptionsContext *o
          norm = FILM;
          arg += 5;
      } else {
 -        int fr;
 -        /* Calculate FR via float to avoid int overflow */
 -        fr = (int)(frame_rate.num * 1000.0 / frame_rate.den);
 -        if(fr == 25000) {
 -            norm = PAL;
 -        } else if((fr == 29970) || (fr == 23976)) {
 -            norm = NTSC;
 -        } else {
 -            /* Try to determine PAL/NTSC by peeking in the input files */
 -            if(nb_input_files) {
 -                int i, j;
 -                for (j = 0; j < nb_input_files; j++) {
 -                    for (i = 0; i < input_files[j].ctx->nb_streams; i++) {
 -                        AVCodecContext *c = input_files[j].ctx->streams[i]->codec;
 -                        if(c->codec_type != AVMEDIA_TYPE_VIDEO)
 -                            continue;
 -                        fr = c->time_base.den * 1000 / c->time_base.num;
 -                        if(fr == 25000) {
 -                            norm = PAL;
 -                            break;
 -                        } else if((fr == 29970) || (fr == 23976)) {
 -                            norm = NTSC;
 -                            break;
 -                        }
 -                    }
 -                    if(norm != UNKNOWN)
 +        /* Try to determine PAL/NTSC by peeking in the input files */
 +        if (nb_input_files) {
 +            int i, j, fr;
 +            for (j = 0; j < nb_input_files; j++) {
 +                for (i = 0; i < input_files[j].nb_streams; i++) {
 +                    AVCodecContext *c = input_files[j].ctx->streams[i]->codec;
-                     if (c->codec_type != AVMEDIA_TYPE_VIDEO)
++                    if (c->codec_type != AVMEDIA_TYPE_VIDEO ||
++                        !c->time_base.num)
 +                        continue;
 +                    fr = c->time_base.den * 1000 / c->time_base.num;
 +                    if (fr == 25000) {
 +                        norm = PAL;
 +                        break;
 +                    } else if ((fr == 29970) || (fr == 23976)) {
 +                        norm = NTSC;
                          break;
 +                    }
                  }
 +                if (norm != UNKNOWN)
 +                    break;
              }
          }
 -        if(verbose > 0 && norm != UNKNOWN)
 -            fprintf(stderr, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
 +        if (norm != UNKNOWN)
 +            av_log(NULL, AV_LOG_INFO, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC");
      }
  
 -    if(norm == UNKNOWN) {
 -        fprintf(stderr, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
 -        fprintf(stderr, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
 -        fprintf(stderr, "or set a framerate with \"-r xxx\".\n");
 +    if (norm == UNKNOWN) {
 +        av_log(NULL, AV_LOG_FATAL, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
 +        av_log(NULL, AV_LOG_FATAL, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
 +        av_log(NULL, AV_LOG_FATAL, "or set a framerate with \"-r xxx\".\n");
          exit_program(1);
      }