Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 23 May 2012 19:41:13 +0000 (21:41 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 23 May 2012 19:48:31 +0000 (21:48 +0200)
* qatar/master:
  os_support: Define SHUT_RD, SHUT_WR and SHUT_RDWR on OS/2
  http: Add support for reading http POST reply headers
  http: Add http_shutdown() for ending writing of posts
  tcp: Allow signalling end of reading/writing
  avio: Add a function for signalling end of reading/writing
  lavfi: fix comment, audio is supported now.
  lavfi: fix incorrect comment.
  lavfi: remove avfilter_null_* from public API on next bump.
  lavfi: remove avfilter_default_* from public API on next bump.
  lavfi: deprecate default config_props() callback and refactor avfilter_config_links()
  avfiltergraph: smarter sample format selection.
  avconv: rename transcode_audio/video to decode_audio/video.
  asyncts: reset delta to 0 when it's not used.
  x86: lavc: use %if HAVE_AVX guards around AVX functions in yasm code.
  dwt: return errors from ff_slice_buffer_init()

Conflicts:
ffmpeg.c
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/formats.c
libavfilter/version.h
libavfilter/vf_blackframe.c
libavfilter/vf_drawtext.c
libavfilter/vf_fade.c
libavfilter/vf_format.c
libavfilter/vf_showinfo.c
libavfilter/video.c
libavfilter/video.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
39 files changed:
1  2 
ffmpeg.c
libavcodec/dwt.c
libavcodec/dwt.h
libavcodec/snowdec.c
libavcodec/x86/dsputil_yasm.asm
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/avfiltergraph.c
libavfilter/formats.c
libavfilter/formats.h
libavfilter/split.c
libavfilter/version.h
libavfilter/vf_aspect.c
libavfilter/vf_blackframe.c
libavfilter/vf_copy.c
libavfilter/vf_crop.c
libavfilter/vf_cropdetect.c
libavfilter/vf_delogo.c
libavfilter/vf_drawbox.c
libavfilter/vf_drawtext.c
libavfilter/vf_fade.c
libavfilter/vf_fifo.c
libavfilter/vf_format.c
libavfilter/vf_null.c
libavfilter/vf_select.c
libavfilter/vf_setpts.c
libavfilter/vf_settb.c
libavfilter/vf_showinfo.c
libavfilter/vf_slicify.c
libavfilter/vf_vflip.c
libavfilter/vf_yadif.c
libavfilter/video.c
libavfilter/video.h
libavformat/avio.c
libavformat/http.c
libavformat/os_support.h
libavformat/tcp.c
libavformat/url.h
tools/lavfi-showfiltfmts.c

diff --cc ffmpeg.c
+++ b/ffmpeg.c
@@@ -2824,27 -2410,21 +2824,27 @@@ static int output_packet(InputStream *i
  
          switch (ist->st->codec->codec_type) {
          case AVMEDIA_TYPE_AUDIO:
-             ret = transcode_audio    (ist, &avpkt, &got_output);
+             ret = decode_audio    (ist, &avpkt, &got_output);
              break;
          case AVMEDIA_TYPE_VIDEO:
-             ret = transcode_video    (ist, &avpkt, &got_output);
+             ret = decode_video    (ist, &avpkt, &got_output);
 -            if (avpkt.duration)
 -                ist->next_dts += av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q);
 -            else if (ist->st->r_frame_rate.num)
 -                ist->next_dts += av_rescale_q(1, (AVRational){ist->st->r_frame_rate.den,
 -                                                              ist->st->r_frame_rate.num},
 -                                              AV_TIME_BASE_Q);
 -            else if (ist->st->codec->time_base.num != 0) {
 -                int ticks      = ist->st->parser ? ist->st->parser->repeat_pict + 1 :
 -                                                   ist->st->codec->ticks_per_frame;
 -                ist->next_dts += av_rescale_q(ticks, ist->st->codec->time_base, AV_TIME_BASE_Q);
 -            }
 +            if (avpkt.duration) {
 +                duration = av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q);
 +            } else if(ist->st->codec->time_base.num != 0 && ist->st->codec->time_base.den != 0) {
 +                int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
 +                duration = ((int64_t)AV_TIME_BASE *
 +                                ist->st->codec->time_base.num * ticks) /
 +                                ist->st->codec->time_base.den;
 +            } else
 +                duration = 0;
 +
 +            if(ist->dts != AV_NOPTS_VALUE && duration) {
 +                ist->next_dts += duration;
 +            }else
 +                ist->next_dts = AV_NOPTS_VALUE;
 +
 +            if (got_output)
 +                ist->next_pts += duration; //FIXME the duration is not correct in some cases
              break;
          case AVMEDIA_TYPE_SUBTITLE:
              ret = transcode_subtitles(ist, &avpkt, &got_output);
  #include "libavutil/attributes.h"
  #include "dsputil.h"
  #include "dwt.h"
 +#include "libavcodec/x86/dwt.h"
  
void ff_slice_buffer_init(slice_buffer *buf, int line_count,
-                           int max_allocated_lines, int line_width,
-                           IDWTELEM *base_buffer)
int ff_slice_buffer_init(slice_buffer *buf, int line_count,
+                          int max_allocated_lines, int line_width,
+                          IDWTELEM *base_buffer)
  {
      int i;
  
Simple merge
Simple merge
Simple merge
@@@ -193,47 -166,28 +193,45 @@@ int avfilter_config_links(AVFilterConte
              } else if ((ret = config_link(link)) < 0)
                  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 1
 -                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 "
                             "width and height\n");
                      return AVERROR(EINVAL);
                  }
 +                break;
 +
 +            case AVMEDIA_TYPE_AUDIO:
 +                if (inlink) {
 +                    if (!link->sample_rate)
 +                        link->sample_rate = inlink->sample_rate;
 +                    if (!link->time_base.num && !link->time_base.den)
 +                        link->time_base = inlink->time_base;
 +                } else if (!link->sample_rate) {
 +                    av_log(link->src, AV_LOG_ERROR,
 +                           "Audio source filters must set their output link's "
 +                           "sample_rate\n");
 +                    return AVERROR(EINVAL);
 +                }
 +
 +                if (!link->time_base.num && !link->time_base.den)
 +                    link->time_base = (AVRational) {1, link->sample_rate};
              }
  
- #endif
              if ((config_link = link->dstpad->config_props))
                  if ((ret = config_link(link)) < 0)
                      return ret;
@@@ -473,10 -428,8 +473,10 @@@ struct AVFilterPad 
       * Frame request callback. A call to this should result in at least one
       * frame being output over the given link. This should return zero on
       * success, and another value on error.
 +     * See avfilter_request_frame() for the error codes with a specific
 +     * meaning.
       *
-      * Output video pads only.
+      * Output pads only.
       */
      int (*request_frame)(AVFilterLink *link);
  
@@@ -507,30 -460,35 +510,35 @@@ attribute_deprecate
  void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
  
  /** default handler for end_frame() for video inputs */
+ attribute_deprecated
  void avfilter_default_end_frame(AVFilterLink *link);
  
 -#if FF_API_DEFAULT_CONFIG_OUTPUT_LINK
 -/** default handler for config_props() for audio/video outputs */
 -attribute_deprecated
 -int avfilter_default_config_output_link(AVFilterLink *link);
 -#endif
 -
  /** default handler for get_video_buffer() for video inputs */
+ attribute_deprecated
  AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
                                                       int perms, int w, int h);
  
+ /** Default handler for query_formats() */
+ attribute_deprecated
+ int avfilter_default_query_formats(AVFilterContext *ctx);
+ #endif
  
  /**
 - * A helper for query_formats() which sets all links to the same list of
 - * formats. If there are no links hooked to this filter, the list of formats is
 - * freed.
 + * Helpers for query_formats() which set all links to the same list of
 + * formats/layouts. If there are no links hooked to this filter, the list
 + * of formats is freed.
   */
  void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
 +void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
 +void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
 +void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
 +#if FF_API_PACKING
 +void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
 +#endif
  
- /** Default handler for query_formats() */
- int avfilter_default_query_formats(AVFilterContext *ctx);
+ #if FF_API_FILTERS_PUBLIC
  /** start_frame() handler for filters which simply pass video along */
+ attribute_deprecated
  void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
  
  /** draw_slice() handler for filters which simply pass video along */
Simple merge
@@@ -464,92 -379,9 +464,97 @@@ int ff_default_query_formats(AVFilterCo
      return 0;
  }
  
 +/* internal functions for parsing audio format arguments */
 +
 +int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx)
 +{
 +    char *tail;
 +    int pix_fmt = av_get_pix_fmt(arg);
 +    if (pix_fmt == PIX_FMT_NONE) {
 +        pix_fmt = strtol(arg, &tail, 0);
 +        if (*tail || (unsigned)pix_fmt >= PIX_FMT_NB) {
 +            av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg);
 +            return AVERROR(EINVAL);
 +        }
 +    }
 +    *ret = pix_fmt;
 +    return 0;
 +}
 +
 +int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx)
 +{
 +    char *tail;
 +    int sfmt = av_get_sample_fmt(arg);
 +    if (sfmt == AV_SAMPLE_FMT_NONE) {
 +        sfmt = strtol(arg, &tail, 0);
 +        if (*tail || (unsigned)sfmt >= AV_SAMPLE_FMT_NB) {
 +            av_log(log_ctx, AV_LOG_ERROR, "Invalid sample format '%s'\n", arg);
 +            return AVERROR(EINVAL);
 +        }
 +    }
 +    *ret = sfmt;
 +    return 0;
 +}
 +
 +int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx)
 +{
 +    AVRational r;
 +    if(av_parse_ratio(&r, arg, INT_MAX, 0, log_ctx) < 0 ||r.num<=0  ||r.den<=0) {
 +        av_log(log_ctx, AV_LOG_ERROR, "Invalid time base '%s'\n", arg);
 +        return AVERROR(EINVAL);
 +    }
 +    *ret = r;
 +    return 0;
 +}
 +
 +int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
 +{
 +    char *tail;
 +    double srate = av_strtod(arg, &tail);
 +    if (*tail || srate < 1 || (int)srate != srate || srate > INT_MAX) {
 +        av_log(log_ctx, AV_LOG_ERROR, "Invalid sample rate '%s'\n", arg);
 +        return AVERROR(EINVAL);
 +    }
 +    *ret = srate;
 +    return 0;
 +}
 +
 +int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx)
 +{
 +    char *tail;
 +    int64_t chlayout = av_get_channel_layout(arg);
 +    if (chlayout == 0) {
 +        chlayout = strtol(arg, &tail, 10);
 +        if (*tail || chlayout == 0) {
 +            av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg);
 +            return AVERROR(EINVAL);
 +        }
 +    }
 +    *ret = chlayout;
 +    return 0;
 +}
 +
+ #if FF_API_FILTERS_PUBLIC
+ int avfilter_default_query_formats(AVFilterContext *ctx)
+ {
+     return ff_default_query_formats(ctx);
+ }
+ #endif
 +#ifdef TEST
 +
 +#undef printf
 +
 +int main(void)
 +{
 +    const int64_t *cl;
 +    char buf[512];
 +
 +    for (cl = avfilter_all_channel_layouts; *cl != -1; cl++) {
 +        av_get_channel_layout_string(buf, sizeof(buf), -1, *cl);
 +        printf("%s\n", buf);
 +    }
 +
 +    return 0;
 +}
 +
 +#endif
Simple merge
@@@ -98,9 -99,9 +99,9 @@@ AVFilter avfilter_vf_split = 
      .init   = split_init,
      .uninit = split_uninit,
  
 -    .inputs    = (AVFilterPad[]) {{ .name            = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer= avfilter_null_get_video_buffer,
+                                     .get_video_buffer= ff_null_get_video_buffer,
                                      .start_frame     = start_frame,
                                      .draw_slice      = draw_slice,
                                      .end_frame       = end_frame, },
  #ifndef FF_API_VSRC_BUFFER_ADD_FRAME
  #define FF_API_VSRC_BUFFER_ADD_FRAME        (LIBAVFILTER_VERSION_MAJOR < 3)
  #endif
 +#ifndef FF_API_PACKING
 +#define FF_API_PACKING                  (LIBAVFILTER_VERSION_MAJOR < 3)
 +#endif
+ #ifndef FF_API_DEFAULT_CONFIG_OUTPUT_LINK
+ #define FF_API_DEFAULT_CONFIG_OUTPUT_LINK   (LIBAVFILTER_VERSION_MAJOR < 3)
+ #endif
+ #ifndef FF_API_FILTERS_PUBLIC
+ #define FF_API_FILTERS_PUBLIC               (LIBAVFILTER_VERSION_MAJOR < 3)
+ #endif
  
  #endif // AVFILTER_VERSION_H
   */
  
  #include "libavutil/mathematics.h"
 +#include "libavutil/parseutils.h"
  #include "avfilter.h"
+ #include "video.h"
  
  typedef struct {
 -    AVRational aspect;
 +    AVRational ratio;
  } AspectContext;
  
  static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
@@@ -83,15 -98,15 +84,15 @@@ AVFilter avfilter_vf_setdar = 
  
      .priv_size = sizeof(AspectContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
                                      .config_props     = setdar_config_props,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .start_frame      = start_frame,
-                                     .end_frame        = avfilter_null_end_frame },
+                                     .end_frame        = ff_null_end_frame },
                                    { .name = NULL}},
  
 -    .outputs   = (AVFilterPad[]) {{ .name             = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO, },
                                    { .name = NULL}},
  };
@@@ -115,15 -131,15 +116,15 @@@ AVFilter avfilter_vf_setsar = 
  
      .priv_size = sizeof(AspectContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
                                      .config_props     = setsar_config_props,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .start_frame      = start_frame,
-                                     .end_frame        = avfilter_null_end_frame },
+                                     .end_frame        = ff_null_end_frame },
                                    { .name = NULL}},
  
 -    .outputs   = (AVFilterPad[]) {{ .name             = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO, },
                                    { .name = NULL}},
  };
@@@ -28,7 -28,7 +28,8 @@@
   */
  
  #include "avfilter.h"
 +#include "internal.h"
+ #include "video.h"
  
  typedef struct {
      unsigned int bamount; ///< black amount
@@@ -124,11 -116,11 +125,11 @@@ AVFilter avfilter_vf_blackframe = 
  
      .query_formats = query_formats,
  
 -    .inputs    = (AVFilterPad[]) {{ .name = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
                                      .draw_slice       = draw_slice,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
 -                                    .start_frame      = ff_null_start_frame,
 +                                    .start_frame      = ff_null_start_frame_keep_ref,
                                      .end_frame        = end_frame, },
                                    { .name = NULL}},
  
@@@ -27,14 -28,14 +28,14 @@@ AVFilter avfilter_vf_copy = 
      .name      = "copy",
      .description = NULL_IF_CONFIG_SMALL("Copy the input video unchanged to the output."),
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
-                                     .start_frame      = avfilter_null_start_frame,
-                                     .end_frame        = avfilter_null_end_frame,
+                                     .get_video_buffer = ff_null_get_video_buffer,
+                                     .start_frame      = ff_null_start_frame,
+                                     .end_frame        = ff_null_end_frame,
                                      .rej_perms        = ~0 },
                                    { .name = NULL}},
 -    .outputs   = (AVFilterPad[]) {{ .name             = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO, },
                                    { .name = NULL}},
  };
@@@ -352,10 -334,10 +353,10 @@@ AVFilter avfilter_vf_crop = 
                                      .start_frame      = start_frame,
                                      .draw_slice       = draw_slice,
                                      .end_frame        = end_frame,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .config_props     = config_input, },
                                    { .name = NULL}},
 -    .outputs   = (AVFilterPad[]) {{ .name             = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
                                      .config_props     = config_output, },
                                    { .name = NULL}},
@@@ -200,11 -201,11 +201,11 @@@ AVFilter avfilter_vf_cropdetect = 
  
      .query_formats = query_formats,
  
 -    .inputs    = (AVFilterPad[]) {{ .name = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
                                      .config_props     = config_input,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
-                                     .start_frame      = avfilter_null_start_frame,
+                                     .get_video_buffer = ff_null_get_video_buffer,
+                                     .start_frame      = ff_null_start_frame,
                                      .end_frame        = end_frame, },
                                    { .name = NULL}},
  
@@@ -273,9 -270,9 +274,9 @@@ AVFilter avfilter_vf_delogo = 
      .init          = init,
      .query_formats = query_formats,
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .start_frame      = start_frame,
                                      .draw_slice       = null_draw_slice,
                                      .end_frame        = end_frame,
@@@ -127,13 -128,13 +128,13 @@@ AVFilter avfilter_vf_drawbox = 
      .init      = init,
  
      .query_formats   = query_formats,
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
                                      .config_props     = config_input,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
-                                     .start_frame      = avfilter_null_start_frame,
+                                     .get_video_buffer = ff_null_get_video_buffer,
+                                     .start_frame      = ff_null_start_frame,
                                      .draw_slice       = draw_slice,
-                                     .end_frame        = avfilter_null_end_frame,
+                                     .end_frame        = ff_null_end_frame,
                                      .min_perms        = AV_PERM_WRITE | AV_PERM_READ,
                                      .rej_perms        = AV_PERM_PRESERVE },
                                    { .name = NULL}},
@@@ -828,10 -874,10 +829,10 @@@ AVFilter avfilter_vf_drawtext = 
      .uninit        = uninit,
      .query_formats = query_formats,
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
-                                     .start_frame      = avfilter_null_start_frame,
+                                     .get_video_buffer = ff_null_get_video_buffer,
 -                                    .start_frame      = start_frame,
++                                    .start_frame      = ff_null_start_frame,
                                      .draw_slice       = null_draw_slice,
                                      .end_frame        = end_frame,
                                      .config_props     = config_input,
   * based heavily on vf_negate.c by Bobby Bingham
   */
  
 +#include "libavutil/avstring.h"
 +#include "libavutil/eval.h"
 +#include "libavutil/opt.h"
  #include "libavutil/pixdesc.h"
  #include "avfilter.h"
 +#include "drawutils.h"
 +#include "internal.h"
+ #include "video.h"
  
 +#define R 0
 +#define G 1
 +#define B 2
 +#define A 3
 +
 +#define Y 0
 +#define U 1
 +#define V 2
 +
  typedef struct {
 +    const AVClass *class;
      int factor, fade_per_frame;
 -    unsigned int frame_index, start_frame, stop_frame;
 +    unsigned int frame_index, start_frame, stop_frame, nb_frames;
      int hsub, vsub, bpp;
 +    unsigned int black_level, black_level_scaled;
 +    uint8_t is_packed_rgb;
 +    uint8_t rgba_map[4];
 +    int alpha;
 +
 +    char *type;
  } FadeContext;
  
 +#define OFFSET(x) offsetof(FadeContext, x)
 +
 +static const AVOption fade_options[] = {
 +    { "type",        "set the fade direction",                     OFFSET(type),        AV_OPT_TYPE_STRING, {.str = "in" }, CHAR_MIN, CHAR_MAX },
 +    { "t",           "set the fade direction",                     OFFSET(type),        AV_OPT_TYPE_STRING, {.str = "in" }, CHAR_MIN, CHAR_MAX },
 +    { "start_frame", "set expression of frame to start fading",    OFFSET(start_frame), AV_OPT_TYPE_INT, {.dbl = 0    }, 0, INT_MAX },
 +    { "s",           "set expression of frame to start fading",    OFFSET(start_frame), AV_OPT_TYPE_INT, {.dbl = 0    }, 0, INT_MAX },
 +    { "nb_frames",   "set expression for fade duration in frames", OFFSET(nb_frames),   AV_OPT_TYPE_INT, {.dbl = 25   }, 0, INT_MAX },
 +    { "n",           "set expression for fade duration in frames", OFFSET(nb_frames),   AV_OPT_TYPE_INT, {.dbl = 25   }, 0, INT_MAX },
 +    { "alpha",       "fade alpha if it is available on the input", OFFSET(alpha),       AV_OPT_TYPE_INT, {.dbl = 0    }, 0,       1 },
 +    {NULL},
 +};
 +
 +static const char *fade_get_name(void *ctx)
 +{
 +    return "fade";
 +}
 +
 +static const AVClass fade_class = {
 +    "FadeContext",
 +    fade_get_name,
 +    fade_options
 +};
 +
  static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
  {
      FadeContext *fade = ctx->priv;
@@@ -285,11 -155,11 +286,11 @@@ AVFilter avfilter_vf_fade = 
      .priv_size     = sizeof(FadeContext),
      .query_formats = query_formats,
  
 -    .inputs    = (AVFilterPad[]) {{ .name            = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO,
                                      .config_props    = config_props,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
-                                     .start_frame      = avfilter_null_start_frame,
+                                     .get_video_buffer = ff_null_get_video_buffer,
+                                     .start_frame      = ff_null_start_frame,
                                      .draw_slice      = draw_slice,
                                      .end_frame       = end_frame,
                                      .min_perms       = AV_PERM_READ | AV_PERM_WRITE,
@@@ -104,9 -105,9 +105,9 @@@ AVFilter avfilter_vf_fifo = 
  
      .priv_size = sizeof(FifoContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name            = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer= avfilter_null_get_video_buffer,
+                                     .get_video_buffer= ff_null_get_video_buffer,
                                      .start_frame     = start_frame,
                                      .draw_slice      = draw_slice,
                                      .end_frame       = end_frame,
@@@ -25,7 -25,7 +25,8 @@@
  
  #include "libavutil/pixdesc.h"
  #include "avfilter.h"
 +#include "internal.h"
+ #include "video.h"
  
  typedef struct {
      /**
@@@ -100,14 -103,14 +101,14 @@@ AVFilter avfilter_vf_format = 
  
      .priv_size = sizeof(FormatContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name            = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer= avfilter_null_get_video_buffer,
-                                     .start_frame     = avfilter_null_start_frame,
-                                     .draw_slice      = avfilter_null_draw_slice,
-                                     .end_frame       = avfilter_null_end_frame, },
+                                     .get_video_buffer= ff_null_get_video_buffer,
+                                     .start_frame     = ff_null_start_frame,
+                                     .draw_slice      = ff_null_draw_slice,
+                                     .end_frame       = ff_null_end_frame, },
                                    { .name = NULL}},
 -    .outputs   = (AVFilterPad[]) {{ .name            = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO },
                                    { .name = NULL}},
  };
@@@ -130,14 -133,14 +131,14 @@@ AVFilter avfilter_vf_noformat = 
  
      .priv_size = sizeof(FormatContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name            = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer= avfilter_null_get_video_buffer,
-                                     .start_frame     = avfilter_null_start_frame,
-                                     .draw_slice      = avfilter_null_draw_slice,
-                                     .end_frame       = avfilter_null_end_frame, },
+                                     .get_video_buffer= ff_null_get_video_buffer,
+                                     .start_frame     = ff_null_start_frame,
+                                     .draw_slice      = ff_null_draw_slice,
+                                     .end_frame       = ff_null_end_frame, },
                                    { .name = NULL}},
 -    .outputs   = (AVFilterPad[]) {{ .name            = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO },
                                    { .name = NULL}},
  };
@@@ -29,14 -30,14 +30,14 @@@ AVFilter avfilter_vf_null = 
  
      .priv_size = 0,
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
-                                     .start_frame      = avfilter_null_start_frame,
-                                     .end_frame        = avfilter_null_end_frame },
+                                     .get_video_buffer = ff_null_get_video_buffer,
+                                     .start_frame      = ff_null_start_frame,
+                                     .end_frame        = ff_null_end_frame },
                                    { .name = NULL}},
  
 -    .outputs   = (AVFilterPad[]) {{ .name             = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO, },
                                    { .name = NULL}},
  };
  
  #include "libavutil/eval.h"
  #include "libavutil/fifo.h"
 -#include "libavutil/mathematics.h"
  #include "avfilter.h"
+ #include "video.h"
  
  static const char *const var_names[] = {
 -    "E",                 ///< Euler number
 -    "PHI",               ///< golden ratio
 -    "PI",                ///< greek pi
 -
      "TB",                ///< timebase
  
      "pts",               ///< original pts in the file of the frame
@@@ -324,9 -338,9 +325,9 @@@ AVFilter avfilter_vf_select = 
  
      .priv_size = sizeof(SelectContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .config_props     = config_input,
                                      .start_frame      = start_frame,
                                      .draw_slice       = draw_slice,
  #include "libavutil/eval.h"
  #include "libavutil/mathematics.h"
  #include "avfilter.h"
+ #include "video.h"
  
  static const char *const var_names[] = {
 -    "E",           ///< Euler number
      "INTERLACED",  ///< tell if the current frame is interlaced
      "N",           ///< frame number (starting at zero)
 -    "PHI",         ///< golden ratio
 -    "PI",          ///< greek pi
      "POS",         ///< original position in the file of the frame
      "PREV_INPTS",  ///< previous  input PTS
      "PREV_OUTPTS", ///< previous output PTS
@@@ -137,9 -147,9 +138,9 @@@ AVFilter avfilter_vf_setpts = 
  
      .priv_size = sizeof(SetPTSContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .config_props     = config_input,
                                      .start_frame      = start_frame, },
                                    { .name = NULL }},
  #include "libavutil/rational.h"
  #include "avfilter.h"
  #include "internal.h"
+ #include "video.h"
  
  static const char *const var_names[] = {
 -    "E",
 -    "PHI",
 -    "PI",
      "AVTB",   /* default timebase 1/AV_TIME_BASE */
      "intb",   /* input timebase */
      NULL
@@@ -119,14 -129,14 +120,14 @@@ AVFilter avfilter_vf_settb = 
  
      .priv_size = sizeof(SetTBContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .start_frame      = start_frame,
-                                     .end_frame        = avfilter_null_end_frame },
+                                     .end_frame        = ff_null_end_frame },
                                    { .name = NULL }},
  
 -    .outputs   = (AVFilterPad[]) {{ .name            = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO,
                                      .config_props    = config_output_props, },
                                    { .name = NULL}},
  #include "libavutil/adler32.h"
  #include "libavutil/imgutils.h"
  #include "libavutil/pixdesc.h"
 +#include "libavutil/timestamp.h"
  #include "avfilter.h"
 +#include "internal.h"
+ #include "video.h"
  
  typedef struct {
      unsigned int frame;
@@@ -91,10 -85,10 +92,10 @@@ AVFilter avfilter_vf_showinfo = 
      .priv_size = sizeof(ShowInfoContext),
      .init      = init,
  
 -    .inputs    = (AVFilterPad[]) {{ .name = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
 -                                    .start_frame      = ff_null_start_frame,
 +                                    .start_frame      = ff_null_start_frame_keep_ref,
                                      .end_frame        = end_frame,
                                      .min_perms        = AV_PERM_READ, },
                                    { .name = NULL}},
@@@ -103,15 -104,15 +104,15 @@@ AVFilter avfilter_vf_slicify = 
  
      .priv_size = sizeof(SliceContext),
  
 -    .inputs    = (AVFilterPad[]) {{ .name             = "default",
 +    .inputs    = (const AVFilterPad[]) {{ .name       = "default",
                                      .type             = AVMEDIA_TYPE_VIDEO,
-                                     .get_video_buffer = avfilter_null_get_video_buffer,
+                                     .get_video_buffer = ff_null_get_video_buffer,
                                      .start_frame      = start_frame,
                                      .draw_slice       = draw_slice,
                                      .config_props     = config_props,
-                                     .end_frame        = avfilter_null_end_frame, },
+                                     .end_frame        = ff_null_end_frame, },
                                    { .name = NULL}},
 -    .outputs   = (AVFilterPad[]) {{ .name            = "default",
 +    .outputs   = (const AVFilterPad[]) {{ .name      = "default",
                                      .type            = AVMEDIA_TYPE_VIDEO, },
                                    { .name = NULL}},
  };
Simple merge
Simple merge
@@@ -20,7 -20,9 +20,8 @@@
  
  #include "avfilter.h"
  #include "internal.h"
+ #include "video.h"
  
 -#ifdef DEBUG
  static char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms)
  {
      snprintf(buf, buf_size, "%s%s%s%s%s%s",
@@@ -66,7 -70,10 +67,7 @@@ AVFilterBufferRef *ff_null_get_video_bu
      return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
  }
  
- AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
 -/* TODO: set the buffer's priv member to a context structure for the whole
 - * filter chain.  This will allow for a buffer pool instead of the constant
 - * alloc & free cycle currently implemented. */
+ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
  {
      int linesize[4];
      uint8_t *data[4];
@@@ -233,20 -208,10 +234,20 @@@ void avfilter_start_frame(AVFilterLink 
      else
          link->cur_buf = picref;
  
 +    while(cmd && cmd->time <= picref->pts * av_q2d(link->time_base)){
 +        av_log(link->dst, AV_LOG_DEBUG,
 +               "Processing command time:%f command:%s arg:%s\n",
 +               cmd->time, cmd->command, cmd->arg);
 +        avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags);
 +        ff_command_queue_pop(link->dst);
 +        cmd= link->dst->command_queue;
 +    }
 +
      start_frame(link, link->cur_buf);
 +    ff_update_link_current_pts(link, link->cur_buf->pts);
  }
  
- void avfilter_null_end_frame(AVFilterLink *link)
+ void ff_null_end_frame(AVFilterLink *link)
  {
      avfilter_end_frame(link->dst->outputs[0]);
  }
index 0000000,f20f30b..d4c31a0
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,30 +1,34 @@@
 - * This file is part of Libav.
+ /*
 - * Libav is free software; you can redistribute it and/or
++ * Copyright (c) 2007 Bobby Bingham
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
++
+ #ifndef AVFILTER_VIDEO_H
+ #define AVFILTER_VIDEO_H
+ AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link,
+                                                int perms, int w, int h);
+ AVFilterBufferRef *ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h);
++
+ void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
+ void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
+ void ff_null_end_frame(AVFilterLink *link);
+ #endif /* AVFILTER_VIDEO_H */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  
  #include "libavformat/avformat.h"
  #include "libavutil/pixdesc.h"
 +#include "libavutil/samplefmt.h"
  #include "libavfilter/avfilter.h"
+ #include "libavfilter/formats.h"
  
 +static void print_formats(AVFilterContext *filter_ctx)
 +{
 +    int i, j;
 +
 +#define PRINT_FMTS(inout, outin, INOUT)                                 \
 +    for (i = 0; i < filter_ctx->inout##put_count; i++) {                     \
 +        if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) {   \
 +            AVFilterFormats *fmts =                                     \
 +                filter_ctx->inout##puts[i]->outin##_formats;            \
 +            for (j = 0; j < fmts->format_count; j++)                    \
 +                if(av_get_pix_fmt_name(fmts->formats[j]))               \
 +                printf(#INOUT "PUT[%d] %s: fmt:%s\n",                   \
 +                       i, filter_ctx->filter->inout##puts[i].name,      \
 +                       av_get_pix_fmt_name(fmts->formats[j]));          \
 +        } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \
 +            AVFilterFormats *fmts;                                      \
 +                                                                        \
 +            fmts = filter_ctx->inout##puts[i]->outin##_formats;         \
 +            for (j = 0; j < fmts->format_count; j++)                    \
 +                printf(#INOUT "PUT[%d] %s: fmt:%s\n",                   \
 +                       i, filter_ctx->filter->inout##puts[i].name,      \
 +                       av_get_sample_fmt_name(fmts->formats[j]));       \
 +                                                                        \
 +            fmts = filter_ctx->inout##puts[i]->outin##_channel_layouts; \
 +            for (j = 0; j < fmts->format_count; j++) {                  \
 +                char buf[256];                                          \
 +                av_get_channel_layout_string(buf, sizeof(buf), -1,      \
 +                                             fmts->formats[j]);         \
 +                printf(#INOUT "PUT[%d] %s: chlayout:%s\n",              \
 +                       i, filter_ctx->filter->inout##puts[i].name, buf); \
 +            }                                                           \
 +        }                                                               \
 +    }                                                                   \
 +
 +    PRINT_FMTS(in,  out, IN);
 +    PRINT_FMTS(out, in,  OUT);
 +}
 +
  int main(int argc, char **argv)
  {
      AVFilter *filter;
      if (filter->query_formats)
          filter->query_formats(filter_ctx);
      else
-         avfilter_default_query_formats(filter_ctx);
+         ff_default_query_formats(filter_ctx);
  
 -    /* print the supported formats in input */
 -    for (i = 0; i < filter_ctx->input_count; i++) {
 -        AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
 -        for (j = 0; j < fmts->format_count; j++)
 -            printf("INPUT[%d] %s: %s\n",
 -                   i, filter_ctx->filter->inputs[i].name,
 -                   av_pix_fmt_descriptors[fmts->formats[j]].name);
 -    }
 -
 -    /* print the supported formats in output */
 -    for (i = 0; i < filter_ctx->output_count; i++) {
 -        AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
 -        for (j = 0; j < fmts->format_count; j++)
 -            printf("OUTPUT[%d] %s: %s\n",
 -                   i, filter_ctx->filter->outputs[i].name,
 -                   av_pix_fmt_descriptors[fmts->formats[j]].name);
 -    }
 +    print_formats(filter_ctx);
  
      avfilter_free(filter_ctx);
      fflush(stdout);