Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 12 Jun 2012 18:44:57 +0000 (20:44 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 12 Jun 2012 18:44:57 +0000 (20:44 +0200)
* qatar/master:
  avfilter: Log an error if avfilter fails to configure a link.
  avconv: support only native pthreads.
  rtmp: Fix a possible access to invalid memory location when the playpath is too short.

Conflicts:
ffmpeg.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
ffmpeg.c
libavfilter/avfilter.c
libavformat/rtmpproto.c

diff --cc ffmpeg.c
+++ b/ffmpeg.c
  #include <sys/select.h>
  #endif
  
- #if HAVE_THREADS
 +#if HAVE_TERMIOS_H
 +#include <fcntl.h>
 +#include <sys/ioctl.h>
 +#include <sys/time.h>
 +#include <termios.h>
 +#elif HAVE_KBHIT
 +#include <conio.h>
 +#endif
 +
  #if HAVE_PTHREADS
  #include <pthread.h>
- #else
- //#include "libavcodec/w32pthreads.h"
- #undef HAVE_THREADS
- #define HAVE_THREADS 0
- #endif
  #endif
  
  #include <time.h>
@@@ -175,13 -141,10 +169,13 @@@ static int nb_frames_drop = 0
  static int input_sync;
  
  static float dts_delta_threshold = 10;
 +static float dts_error_threshold = 3600*30;
  
  static int print_stats = 1;
 +static int debug_ts = 0;
 +static int current_time;
  
- #if HAVE_THREADS
+ #if HAVE_PTHREADS
  /* signal to input threads that they should exit; set by the main thread */
  static int transcoding_finished;
  #endif
@@@ -3241,100 -2783,7 +3235,100 @@@ static int select_input_file(uint8_t *n
      return file_index;
  }
  
- #if HAVE_THREADS
 +static int check_keyboard_interaction(int64_t cur_time)
 +{
 +    int i, ret, key;
 +    static int64_t last_time;
 +    if (received_nb_signals)
 +        return AVERROR_EXIT;
 +    /* read_key() returns 0 on EOF */
 +    if(cur_time - last_time >= 100000 && !run_as_daemon){
 +        key =  read_key();
 +        last_time = cur_time;
 +    }else
 +        key = -1;
 +    if (key == 'q')
 +        return AVERROR_EXIT;
 +    if (key == '+') av_log_set_level(av_log_get_level()+10);
 +    if (key == '-') av_log_set_level(av_log_get_level()-10);
 +    if (key == 's') qp_hist     ^= 1;
 +    if (key == 'h'){
 +        if (do_hex_dump){
 +            do_hex_dump = do_pkt_dump = 0;
 +        } else if(do_pkt_dump){
 +            do_hex_dump = 1;
 +        } else
 +            do_pkt_dump = 1;
 +        av_log_set_level(AV_LOG_DEBUG);
 +    }
 +    if (key == 'c' || key == 'C'){
 +        char buf[4096], target[64], command[256], arg[256] = {0};
 +        double time;
 +        int k, n = 0;
 +        fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
 +        i = 0;
 +        while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
 +            if (k > 0)
 +                buf[i++] = k;
 +        buf[i] = 0;
 +        if (k > 0 &&
 +            (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
 +            av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
 +                   target, time, command, arg);
 +            for (i = 0; i < nb_filtergraphs; i++) {
 +                FilterGraph *fg = filtergraphs[i];
 +                if (fg->graph) {
 +                    if (time < 0) {
 +                        ret = avfilter_graph_send_command(fg->graph, target, command, arg, buf, sizeof(buf),
 +                                                          key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
 +                        fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf);
 +                    } else {
 +                        ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time);
 +                    }
 +                }
 +            }
 +        } else {
 +            av_log(NULL, AV_LOG_ERROR,
 +                   "Parse error, at least 3 arguments were expected, "
 +                   "only %d given in string '%s'\n", n, buf);
 +        }
 +    }
 +    if (key == 'd' || key == 'D'){
 +        int debug=0;
 +        if(key == 'D') {
 +            debug = input_streams[0]->st->codec->debug<<1;
 +            if(!debug) debug = 1;
 +            while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash
 +                debug += debug;
 +        }else
 +            if(scanf("%d", &debug)!=1)
 +                fprintf(stderr,"error parsing debug value\n");
 +        for(i=0;i<nb_input_streams;i++) {
 +            input_streams[i]->st->codec->debug = debug;
 +        }
 +        for(i=0;i<nb_output_streams;i++) {
 +            OutputStream *ost = output_streams[i];
 +            ost->st->codec->debug = debug;
 +        }
 +        if(debug) av_log_set_level(AV_LOG_DEBUG);
 +        fprintf(stderr,"debug=%d\n", debug);
 +    }
 +    if (key == '?'){
 +        fprintf(stderr, "key    function\n"
 +                        "?      show this help\n"
 +                        "+      increase verbosity\n"
 +                        "-      decrease verbosity\n"
 +                        "c      Send command to filtergraph\n"
 +                        "D      cycle through available debug modes\n"
 +                        "h      dump packets/hex press to cycle through the 3 states\n"
 +                        "q      quit\n"
 +                        "s      Show QP histogram\n"
 +        );
 +    }
 +    return 0;
 +}
 +
+ #if HAVE_PTHREADS
  static void *input_thread(void *arg)
  {
      InputFile *f = arg;
@@@ -3627,9 -3038,9 +3621,9 @@@ static int transcode(void
          av_free_packet(&pkt);
  
          /* dump report by using the output first video and audio streams */
 -        print_report(0, timer_start);
 +        print_report(0, timer_start, cur_time);
      }
- #if HAVE_THREADS
+ #if HAVE_PTHREADS
      free_input_threads();
  #endif
  
@@@ -231,26 -163,27 +231,30 @@@ int avfilter_config_links(AVFilterConte
                                                      "callbacks on all outputs\n");
                      return AVERROR(EINVAL);
                  }
-             } else if ((ret = config_link(link)) < 0)
+             } else if ((ret = config_link(link)) < 0) {
+                 av_log(link->src, AV_LOG_ERROR,
+                        "Failed to configure output pad on %s\n",
+                        link->src->name);
                  return ret;
+             }
  
 -            if (link->time_base.num == 0 && link->time_base.den == 0)
 -                link->time_base = link->src && link->src->input_count ?
 -                    link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
 +            switch (link->type) {
 +            case AVMEDIA_TYPE_VIDEO:
 +                if (!link->time_base.num && !link->time_base.den)
 +                    link->time_base = inlink ? inlink->time_base : AV_TIME_BASE_Q;
  
 -            if (link->type == AVMEDIA_TYPE_VIDEO) {
                  if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den)
 -                    link->sample_aspect_ratio = link->src->input_count ?
 -                        link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1};
 +                    link->sample_aspect_ratio = inlink ?
 +                        inlink->sample_aspect_ratio : (AVRational){1,1};
 +
 +                if (inlink && !link->frame_rate.num && !link->frame_rate.den)
 +                    link->frame_rate = inlink->frame_rate;
  
 -                if (link->src->input_count) {
 +                if (inlink) {
                      if (!link->w)
 -                        link->w = link->src->inputs[0]->w;
 +                        link->w = inlink->w;
                      if (!link->h)
 -                        link->h = link->src->inputs[0]->h;
 +                        link->h = inlink->h;
                  } else if (!link->w || !link->h) {
                      av_log(link->src, AV_LOG_ERROR,
                             "Video source filters must set their output link's "
Simple merge