]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'fa2a34cd40d124161c748bb0f430dc63c94dd0da'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 12 Apr 2013 13:01:41 +0000 (15:01 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 12 Apr 2013 13:08:40 +0000 (15:08 +0200)
* commit 'fa2a34cd40d124161c748bb0f430dc63c94dd0da':
  lavfi: change the filter registering system to match the other libraries

Conflicts:
cmdutils.c
ffplay.c
libavfilter/avfilter.c
libavfilter/avfilter.h

This removes the ability to put AVFilters in read only memory and having
them shareable.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
cmdutils.c
doc/APIchanges
ffmpeg.c
ffplay.c
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/version.h

diff --cc cmdutils.c
index 4634ae20ff2696b1b58c7d4121adf63945dce773,7084faed413adcaef3ca0d14ebe75a4ff0952cdb..bdcbebd4c21951eb99b13a9d707dcc09294f30ce
@@@ -1448,32 -1130,12 +1448,32 @@@ int show_protocols(void *optctx, const 
  
  int show_filters(void *optctx, const char *opt, const char *arg)
  {
-     AVFilter av_unused(**filter) = NULL;
+     const AVFilter av_unused(*filter) = NULL;
 +    char descr[64], *descr_cur;
 +    int i, j;
 +    const AVFilterPad *pad;
  
      printf("Filters:\n");
  #if CONFIG_AVFILTER
-     while ((filter = av_filter_next(filter)) && *filter) {
 -    while ((filter = avfilter_next(filter)))
 -        printf("%-16s %s\n", filter->name, filter->description);
++    while ((filter = avfilter_next(filter))) {
 +        descr_cur = descr;
 +        for (i = 0; i < 2; i++) {
 +            if (i) {
 +                *(descr_cur++) = '-';
 +                *(descr_cur++) = '>';
 +            }
-             pad = i ? (*filter)->outputs : (*filter)->inputs;
++            pad = i ? filter->outputs : filter->inputs;
 +            for (j = 0; pad && pad[j].name; j++) {
 +                if (descr_cur >= descr + sizeof(descr) - 4)
 +                    break;
 +                *(descr_cur++) = get_media_type_char(pad[j].type);
 +            }
 +            if (!j)
 +                *(descr_cur++) = '|';
 +        }
 +        *descr_cur = 0;
-         printf("%-16s %-10s %s\n", (*filter)->name, descr, (*filter)->description);
++        printf("%-16s %-10s %s\n", filter->name, descr, filter->description);
 +    }
  #endif
      return 0;
  }
diff --cc doc/APIchanges
Simple merge
diff --cc ffmpeg.c
Simple merge
diff --cc ffplay.c
index 759f46f3b5f9f0b4eeb77127c99d89ea0715cc83,018f63dedb188cddb902301e6646913d000bdbc1..a9fef72622544c7a3ff00375a7d5b716c481299b
+++ b/ffplay.c
@@@ -989,61 -869,7 +989,60 @@@ static void video_audio_display(VideoSt
      }
  }
  
 -static int video_open(VideoState *is)
 +static void stream_close(VideoState *is)
 +{
 +    VideoPicture *vp;
 +    int i;
 +    /* XXX: use a special url_shutdown call to abort parse cleanly */
 +    is->abort_request = 1;
 +    SDL_WaitThread(is->read_tid, NULL);
 +    packet_queue_destroy(&is->videoq);
 +    packet_queue_destroy(&is->audioq);
 +    packet_queue_destroy(&is->subtitleq);
 +
 +    /* free all pictures */
 +    for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) {
 +        vp = &is->pictq[i];
 +        if (vp->bmp) {
 +            SDL_FreeYUVOverlay(vp->bmp);
 +            vp->bmp = NULL;
 +        }
 +    }
 +    SDL_DestroyMutex(is->pictq_mutex);
 +    SDL_DestroyCond(is->pictq_cond);
 +    SDL_DestroyMutex(is->subpq_mutex);
 +    SDL_DestroyCond(is->subpq_cond);
 +    SDL_DestroyCond(is->continue_read_thread);
 +#if !CONFIG_AVFILTER
 +    sws_freeContext(is->img_convert_ctx);
 +#endif
 +    av_free(is);
 +}
 +
 +static void do_exit(VideoState *is)
 +{
 +    if (is) {
 +        stream_close(is);
 +    }
 +    av_lockmgr_register(NULL);
 +    uninit_opts();
 +#if CONFIG_AVFILTER
-     avfilter_uninit();
 +    av_freep(&vfilters);
 +#endif
 +    avformat_network_deinit();
 +    if (show_status)
 +        printf("\n");
 +    SDL_Quit();
 +    av_log(NULL, AV_LOG_QUIET, "%s", "");
 +    exit(0);
 +}
 +
 +static void sigterm_handler(int sig)
 +{
 +    exit(123);
 +}
 +
 +static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp)
  {
      int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
      int w,h;
index e03b6f2f61fd8405dd6b3fe299d9ab248785f329,199d8f97fc47788270c83b73a7b17bb4cf62e76a..484eda1c7f8f0019e0de9f600e3459fd485e7ccc
@@@ -365,32 -267,7 +365,28 @@@ int ff_poll_frame(AVFilterLink *link
      return min;
  }
  
- #define MAX_REGISTERED_AVFILTERS_NB 256
- static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1];
- static int next_registered_avfilter_idx = 0;
 +void ff_update_link_current_pts(AVFilterLink *link, int64_t pts)
 +{
 +    if (pts == AV_NOPTS_VALUE)
 +        return;
 +    link->current_pts = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q);
 +    /* TODO use duration */
 +    if (link->graph && link->age_index >= 0)
 +        ff_avfilter_graph_update_heap(link->graph, link);
 +}
 +
 +int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags)
 +{
 +    if(!strcmp(cmd, "ping")){
 +        av_strlcatf(res, res_len, "pong from:%s %s\n", filter->filter->name, filter->name);
 +        return 0;
 +    }else if(filter->filter->process_command) {
 +        return filter->filter->process_command(filter, cmd, arg, res, res_len, flags);
 +    }
 +    return AVERROR(ENOSYS);
 +}
 +
+ static AVFilter *first_filter;
  
  AVFilter *avfilter_get_by_name(const char *name)
  {
  
  int avfilter_register(AVFilter *filter)
  {
-     if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB) {
-         av_log(NULL, AV_LOG_ERROR,
-                "Maximum number of registered filters %d reached, "
-                "impossible to register filter with name '%s'\n",
-                MAX_REGISTERED_AVFILTERS_NB, filter->name);
-         return AVERROR(ENOMEM);
-     }
+     AVFilter **f = &first_filter;
 +    int i;
 +
-     registered_avfilters[next_registered_avfilter_idx++] = filter;
 +    for(i=0; filter->inputs && filter->inputs[i].name; i++) {
 +        const AVFilterPad *input = &filter->inputs[i];
 +        av_assert0(     !input->filter_frame
 +                    || (!input->start_frame && !input->end_frame));
 +    }
 +
+     while (*f)
+         f = &(*f)->next;
+     *f = filter;
+     filter->next = NULL;
++
      return 0;
  }
  
@@@ -463,21 -333,16 +461,22 @@@ static void *filter_child_next(void *ob
  
  static const AVClass *filter_child_class_next(const AVClass *prev)
  {
-     AVFilter **f = NULL;
+     AVFilter *f = NULL;
  
-     while (prev && *(f = av_filter_next(f)))
-         if ((*f)->priv_class == prev)
 +    /* find the filter that corresponds to prev */
+     while (prev && (f = avfilter_next(f)))
+         if (f->priv_class == prev)
              break;
  
-     if (prev && !(*f))
 +    /* could not find filter corresponding to prev */
-     while (*(f = av_filter_next(f)))
-         if ((*f)->priv_class)
-             return (*f)->priv_class;
++    if (prev && !f)
 +        return NULL;
 +
 +    /* find next filter with specific options */
+     while ((f = avfilter_next(f)))
+         if (f->priv_class)
+             return f->priv_class;
      return NULL;
  }
  
index 4bc97554fee648aac61f25dedb4e17032aeb9612,51d0fb5148bf7d438cb0f280f72ae4d68cd23cfa..44143b010a538bf066cb9f75dec2114e92653364
@@@ -496,35 -458,7 +496,37 @@@ typedef struct AVFilter 
  
      int priv_size;      ///< size of private data to allocate for the filter
  
+     struct AVFilter *next;
++
 +    /**
 +     * Make the filter instance process a command.
 +     *
 +     * @param cmd    the command to process, for handling simplicity all commands must be alphanumeric only
 +     * @param arg    the argument for the command
 +     * @param res    a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported.
 +     * @param flags  if AVFILTER_CMD_FLAG_FAST is set and the command would be
 +     *               time consuming then a filter should treat it like an unsupported command
 +     *
 +     * @returns >=0 on success otherwise an error code.
 +     *          AVERROR(ENOSYS) on unsupported commands
 +     */
 +    int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
 +
 +    /**
 +     * Filter initialization function, alternative to the init()
 +     * callback. Args contains the user-supplied parameters, opaque is
 +     * used for providing binary data.
 +     */
 +    int (*init_opaque)(AVFilterContext *ctx, void *opaque);
 +
 +    /**
 +     * Shorthand syntax for init arguments.
 +     * If this field is set (even to an empty list), just before init the
 +     * private class will be set and the arguments string will be parsed
 +     * using av_opt_set_from_string() with "=" and ":" delimiters, and
 +     * av_opt_free() will be called just after uninit.
 +     */
 +    const char *const *shorthand;
  } AVFilter;
  
  /** An instance of a filter */
Simple merge