GNOME Bugzilla – Bug 320765
[ffmpegcolorspace] make win32+msvc compliant, don't use __VA_ARGS__ macros
Last modified: 2006-03-15 11:41:23 UTC
Distribution/Version: VC6.0 ffmpegcolorspace can't build on visual studio c compiler. There are macro with variable numbers of parameters in gstffmpegcodecmap.c Attached a patch in the same code without macros.
Created attachment 54355 [details] [review] a patch to replace macros with variables params.
I don't particularly like this; can we do this in another way?
I agree with Ronald. Perhaps we could bust it out to an inline function that creates a new caps and then uses gst_caps_set_simple_valist?
ok, so #define GST_FF_VID_CAPS_NEW(mimetype, ...) \ (context != NULL) ? \ gst_caps_new_simple (mimetype, \ "width", G_TYPE_INT, context->width, \ "height", G_TYPE_INT, context->height, \ "framerate", GST_TYPE_FRACTION, \ (gint) context->frame_rate, (gint) context->frame_rate_base, \ __VA_ARGS__, NULL) \ : \ gst_caps_new_simple (mimetype, \ "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, \ "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, \ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,\ __VA_ARGS__, NULL) becomes something like void gst_ff_vid_caps_new(AVCodecContext * context, const char *mimetype, ...) { GstCaps *caps = NULL; va_list var_args; if(context != NULL) { caps = gst_caps_new_simple (mimetype, "width", G_TYPE_INT, context->width, "height", G_TYPE_INT, context->height, "framerate", GST_TYPE_FRACTION, (gint) context->frame_rate, (gint) context->frame_rate_base, NULL); } else { caps = gst_caps_new_simple (mimetype, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT, "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL); } va_start (var_args, mimetype); gst_caps_set_simple_valist (caps, ????, var_args); va_end (var_args); return caps; } What should be first field name ? can we extract it from var_args or use NULL then it should take the first one?
Ok you can forget my previous solution which i haven't tested. it can't work. I'm attaching a pacth with a solution i've just test and which works for me. Please check, test and let me know ... Thanks, Seb
Created attachment 58514 [details] [review] alternative to __VA_ARG__
looks fine to me, everybody happy with this?
Committed (without the stray \ in gst_ff_aud_caps_new()): 2006-03-15 Tim-Philipp Müller <tim at centricular dot net> Patch by: Sebastien Moutte <sebastien moutte net> * gst/ffmpegcolorspace/gstffmpegcodecmap.c: (gst_ff_vid_caps_new), (gst_ff_aud_caps_new), (gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_smpfmt_to_caps): Replace __VA_ARGS__ caps creation macros with varargs functions. Makes things compile on MSVC (#320765), looks nicer, and we can tell the compiler to check for the NULL terminator.