32 #define KNOWN(l) (!FF_LAYOUT2COUNT(l))  
   37 #define MERGE_REF(ret, a, fmts, type, fail)                                \ 
   42     if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount,   \ 
   47     for (i = 0; i < a->refcount; i ++) {                                   \ 
   48         ret->refs[ret->refcount] = a->refs[i];                             \ 
   49         *ret->refs[ret->refcount++] = ret;                                 \ 
   61 #define MERGE_FORMATS(ret, a, b, fmts, nb, type, fail)                          \ 
   63     int i, j, k = 0, count = FFMIN(a->nb, b->nb);                               \ 
   65     if (!(ret = av_mallocz(sizeof(*ret))))                                      \ 
   69         if (!(ret->fmts = av_malloc_array(count, sizeof(*ret->fmts))))          \ 
   71         for (i = 0; i < a->nb; i++)                                             \ 
   72             for (j = 0; j < b->nb; j++)                                         \ 
   73                 if (a->fmts[i] == b->fmts[j]) {                                 \ 
   74                     if(k >= FFMIN(a->nb, b->nb)){                               \ 
   75                         av_log(NULL, AV_LOG_ERROR, "Duplicate formats in avfilter_merge_formats() detected\n"); \ 
   80                     ret->fmts[k++] = a->fmts[i];                                \ 
   88     MERGE_REF(ret, a, fmts, type, fail);                                        \ 
   89     MERGE_REF(ret, b, fmts, type, fail);                                        \ 
   97     int alpha1=0, alpha2=0;
 
   98     int chroma1=0, chroma2=0;
 
  124     if (alpha2 > alpha1 || chroma2 > chroma1)
 
  144     if (a == b) 
return a;
 
  172     int ret_max, ret_nb = 0, i, j, 
round;
 
  174     if (a == b) 
return a;
 
  179         FFSWAP(
unsigned, a_all, b_all);
 
  182         if (a_all == 1 && !b_all) {
 
  216     for (round = 0; round < 2; round++) {
 
  219             if (!fmt || !
KNOWN(fmt))
 
  258     for (p = fmts; *p != -1; p++) {
 
  265 #define COPY_INT_LIST(list_copy, list, type) {                          \ 
  268         for (count = 0; list[count] != -1; count++)                     \ 
  270     list_copy = av_calloc(count+1, sizeof(type));                       \ 
  272         memcpy(list_copy, list, sizeof(type) * count);                  \ 
  273         list_copy[count] = -1;                                          \ 
  277 #define MAKE_FORMAT_LIST(type, field, count_field)                      \ 
  281         for (count = 0; fmts[count] != -1; count++)                     \ 
  283     formats = av_mallocz(sizeof(*formats));                             \ 
  284     if (!formats) return NULL;                                          \ 
  285     formats->count_field = count;                                       \ 
  287         formats->field = av_malloc_array(count, sizeof(*formats->field));      \ 
  288         if (!formats->field) {                                          \ 
  306                      channel_layouts, nb_channel_layouts);
 
  308         memcpy(
formats->channel_layouts, fmts,
 
  314 #define ADD_FORMAT(f, fmt, type, list, nb)                  \ 
  319     if (!(*f) && !(*f = av_mallocz(sizeof(**f))))           \ 
  320         return AVERROR(ENOMEM);                             \ 
  322     fmts = av_realloc((*f)->list,                           \ 
  323                       sizeof(*(*f)->list) * ((*f)->nb + 1));\ 
  327         return AVERROR(ENOMEM);                             \ 
  331     (*f)->list[(*f)->nb++] = fmt;                           \ 
  343     ADD_FORMAT(l, channel_layout, uint64_t, channel_layouts, nb_channel_layouts);
 
  414 #define FORMATS_REF(f, ref)                                          \ 
  417     f->refs = av_realloc(f->refs, sizeof(*f->refs) * ++f->refcount); \ 
  418     f->refs[f->refcount-1] = ref;                                    \ 
  431 #define FIND_REF_INDEX(ref, idx)            \ 
  434     for (i = 0; i < (*ref)->refcount; i ++) \ 
  435         if((*ref)->refs[i] == ref) {        \ 
  441 #define FORMATS_UNREF(ref, list)                                   \ 
  448     FIND_REF_INDEX(ref, idx);                                      \ 
  451         memmove((*ref)->refs + idx, (*ref)->refs + idx + 1,        \ 
  452             sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \ 
  454     if(!--(*ref)->refcount) {                                      \ 
  455         av_free((*ref)->list);                                     \ 
  456         av_free((*ref)->refs);                                     \ 
  472 #define FORMATS_CHANGEREF(oldref, newref)       \ 
  476     FIND_REF_INDEX(oldref, idx);                \ 
  479         (*oldref)->refs[idx] = newref;          \ 
  496 #define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \ 
  500     for (i = 0; i < ctx->nb_inputs; i++) {                          \ 
  501         if (ctx->inputs[i] && !ctx->inputs[i]->out_fmts) {          \ 
  502             ref(fmts, &ctx->inputs[i]->out_fmts);                   \ 
  506     for (i = 0; i < ctx->nb_outputs; i++) {                         \ 
  507         if (ctx->outputs[i] && !ctx->outputs[i]->in_fmts) {         \ 
  508             ref(fmts, &ctx->outputs[i]->in_fmts);                   \ 
  514         av_freep(&fmts->list);                                      \ 
  515         av_freep(&fmts->refs);                                      \ 
  578         pix_fmt = strtol(arg, &tail, 0);
 
  593         sfmt = strtol(arg, &tail, 0);
 
  618     if (*tail || srate < 1 || (
int)srate != srate || srate > INT_MAX) {
 
  630     int64_t chlayout, 
count;
 
  633         count = strtol(arg, &tail, 10);
 
  634         if (*tail == 
'c' && !tail[1] && count > 0 && count < 63) {
 
  642         chlayout = strtol(arg, &tail, 10);
 
  643         if (*tail || chlayout == 0) {