[FFmpeg-devel] [PATCH] [1/??] [3/3] Colorspace negotiation

Michael Niedermayer michaelni
Sat Feb 9 23:41:19 CET 2008


On Sat, Feb 09, 2008 at 11:07:14PM +0100, Vitor Sessak wrote:
> Hi and thanks for the review,
> 
> Michael Niedermayer wrote:
> > On Sat, Feb 09, 2008 at 07:33:04PM +0100, Vitor Sessak wrote:
> > 
> >> /*
> >>  * Filter layer - format negotiation
> > [...]
> >>     /* merge list of formats */
> >>     ret->formats = av_malloc(sizeof(int) * FFMIN(a->format_count,
> >>                                                  b->format_count));
> > 
> > sizeof(*ret->formats)
> > 
> > 
> > [...]
> >>     /* merge and update all the references */
> >>     ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));
> >>     for(i = 0; i < a->refcount; i ++) {
> >>         ret->refs[ret->refcount] = a->refs[i];
> >>         *ret->refs[ret->refcount++] = ret;
> >>     }
> >>     for(i = 0; i < b->refcount; i ++) {
> >>         ret->refs[ret->refcount] = b->refs[i];
> >>         *ret->refs[ret->refcount++] = ret;
> >>     }
> >>
> >>     av_free(a->refs);
> >>     av_free(a->formats);
> >>     av_free(a);
> >>
> >>     av_free(b->refs);
> >>     av_free(b->formats);
> >>     av_free(b);
> > 
> > that could be factored into a merge_ref or so function and
> > merge_ref(ret, a);
> > merge_ref(ret, b);
> > 
> > 
> > [...]
> >>     ret->formats = av_malloc(sizeof(int) * len);
> > 
> > sizeof(*ret->formats)
> > 
> > 
> > [...]
> >> AVFilterFormats *avfilter_all_colorspaces(void)
> >> {
> >>     return avfilter_make_format_list(35,
> >>                 PIX_FMT_YUV444P,  PIX_FMT_YUV422P,  PIX_FMT_YUV420P,
> >>                 PIX_FMT_YUV411P,  PIX_FMT_YUV410P,
> >>                 PIX_FMT_YUYV422,  PIX_FMT_UYVY422,  PIX_FMT_UYYVYY411,
> >>                 PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
> >>                 PIX_FMT_YUV440P,  PIX_FMT_YUVJ440P,
> >>                 PIX_FMT_RGB32,    PIX_FMT_BGR32,
> >>                 PIX_FMT_RGB32_1,  PIX_FMT_BGR32_1,
> >>                 PIX_FMT_RGB24,    PIX_FMT_BGR24,
> >>                 PIX_FMT_RGB565,   PIX_FMT_BGR565,
> >>                 PIX_FMT_RGB555,   PIX_FMT_BGR555,
> >>                 PIX_FMT_RGB8,     PIX_FMT_BGR8,
> >>                 PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
> >>                 PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
> >>                 PIX_FMT_GRAY8,    PIX_FMT_PAL8,
> >>                 PIX_FMT_MONOWHITE,PIX_FMT_MONOBLACK,
> >>                 PIX_FMT_NV12,     PIX_FMT_NV21);
> > 
> > I dont like this, something based on PIX_FMT_NB should work better
> 
> Agree with all of the above. Modified code in 
> http://svn.mplayerhq.hu/soc/libavfilter/formats.c?content-type=text%2Fplain&view=co 

>    av_free(a->refs);
>    av_free(a->formats);
>    av_free(a);
>
>    av_free(b->refs);
>    av_free(b->formats);
>    av_free(b);

these can also be moved into merge_ref()


[...]

>    int idx;
>
>    if((idx = find_ref_index(ref)) >= 0)

int idx= find_ref_index(ref);

if(idx >= 0)

and there are more of these


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080209/5980e7b8/attachment.pgp>



More information about the ffmpeg-devel mailing list