I'm going to need to add a few more compressed formats, WMV which is straightforward, but also AAC (so MPEG v2/v4 audio), and I think wg_format could be cleaned up a bit like this beforehand.
Then, AAC could either be added as a separate `AUDIO_MPEG4` format, or, with an version field, to the (renamed) `AUDIO_MPEG` format, though it doesn't share any of the current `AUDIO_MPEG1` properties. FWIW GStreamer caps is `audio/mpeg` for both, with an `mpegversion` that can be 1, 2 or 4. Could be very well added as `AUDIO_AAC` too, I don't really mind.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/mfplat.c | 1 + dlls/winegstreamer/quartz_parser.c | 49 ++++++++++++++++++++++++------ dlls/winegstreamer/unixlib.h | 10 ++++-- dlls/winegstreamer/wg_format.c | 35 +++++++++++++++++---- dlls/winegstreamer/wg_parser.c | 1 - dlls/winegstreamer/wg_transform.c | 2 ++ dlls/winegstreamer/wm_reader.c | 4 +++ 7 files changed, 83 insertions(+), 19 deletions(-)
diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index d6620c0d08a..7c58ed93bfd 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -490,6 +490,7 @@ IMFMediaType *mf_media_type_from_wg_format(const struct wg_format *format) case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_MPEG1_AUDIO: + case WG_MAJOR_TYPE_VIDEO_CINEPAK: FIXME("Format %u not implemented!\n", format->major_type); /* fallthrough */ case WG_MAJOR_TYPE_UNKNOWN: diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 1ba24580cf6..12091d75398 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -300,12 +300,6 @@ unsigned int wg_format_get_max_size(const struct wg_format *format) return ALIGN(width, 4) * ALIGN(height, 2) /* Y plane */ + ALIGN(width, 4) * ((height + 1) / 2); /* U/V plane */
- case WG_VIDEO_FORMAT_CINEPAK: - /* Both ffmpeg's encoder and a Cinepak file seen in the wild report - * 24 bpp. ffmpeg sets biSizeImage as below; others may be smaller, - * but as long as every sample fits into our allocator, we're fine. */ - return width * height * 3; - case WG_VIDEO_FORMAT_UNKNOWN: FIXME("Cannot guess maximum sample size for unknown video format.\n"); return 0; @@ -313,6 +307,12 @@ unsigned int wg_format_get_max_size(const struct wg_format *format) break; }
+ case WG_MAJOR_TYPE_VIDEO_CINEPAK: + /* Both ffmpeg's encoder and a Cinepak file seen in the wild report + * 24 bpp. ffmpeg sets biSizeImage as below; others may be smaller, + * but as long as every sample fits into our allocator, we're fine. */ + return format->u.video_cinepak.width * format->u.video_cinepak.height * 3; + case WG_MAJOR_TYPE_AUDIO: { unsigned int rate = format->u.audio.rate, channels = format->u.audio.channels; @@ -390,7 +390,6 @@ static const GUID *wg_video_format_get_mediasubtype(enum wg_video_format format) case WG_VIDEO_FORMAT_YUY2: return &MEDIASUBTYPE_YUY2; case WG_VIDEO_FORMAT_YV12: return &MEDIASUBTYPE_YV12; case WG_VIDEO_FORMAT_YVYU: return &MEDIASUBTYPE_YVYU; - case WG_VIDEO_FORMAT_CINEPAK: return &MEDIASUBTYPE_CVID; }
assert(0); @@ -414,7 +413,6 @@ static DWORD wg_video_format_get_compression(enum wg_video_format format) case WG_VIDEO_FORMAT_YUY2: return mmioFOURCC('Y','U','Y','2'); case WG_VIDEO_FORMAT_YV12: return mmioFOURCC('Y','V','1','2'); case WG_VIDEO_FORMAT_YVYU: return mmioFOURCC('Y','V','Y','U'); - case WG_VIDEO_FORMAT_CINEPAK: return mmioFOURCC('C','V','I','D'); }
assert(0); @@ -438,7 +436,6 @@ static WORD wg_video_format_get_depth(enum wg_video_format format) case WG_VIDEO_FORMAT_YUY2: return 16; case WG_VIDEO_FORMAT_YV12: return 12; case WG_VIDEO_FORMAT_YVYU: return 16; - case WG_VIDEO_FORMAT_CINEPAK: return 24; }
assert(0); @@ -495,6 +492,36 @@ static bool amt_from_wg_format_video(AM_MEDIA_TYPE *mt, const struct wg_format * return true; }
+static bool amt_from_wg_format_video_cinepak(AM_MEDIA_TYPE *mt, const struct wg_format *format) +{ + VIDEOINFO *video_format; + uint32_t frame_time; + + if (!(video_format = CoTaskMemAlloc(sizeof(*video_format)))) + return false; + + mt->majortype = MEDIATYPE_Video; + mt->subtype = MEDIASUBTYPE_CVID; + mt->bTemporalCompression = TRUE; + mt->lSampleSize = 1; + mt->formattype = FORMAT_VideoInfo; + mt->cbFormat = sizeof(VIDEOINFOHEADER); + mt->pbFormat = (BYTE *)video_format; + + memset(video_format, 0, sizeof(*video_format)); + if ((frame_time = MulDiv(10000000, format->u.video_cinepak.fps_d, format->u.video_cinepak.fps_n)) != -1) + video_format->AvgTimePerFrame = frame_time; + video_format->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + video_format->bmiHeader.biWidth = format->u.video_cinepak.width; + video_format->bmiHeader.biHeight = format->u.video_cinepak.height; + video_format->bmiHeader.biPlanes = 1; + video_format->bmiHeader.biBitCount = 24; + video_format->bmiHeader.biCompression = mt->subtype.Data1; + video_format->bmiHeader.biSizeImage = wg_format_get_max_size(format); + + return true; +} + bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool wm) { memset(mt, 0, sizeof(*mt)); @@ -516,6 +543,9 @@ bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool
case WG_MAJOR_TYPE_VIDEO: return amt_from_wg_format_video(mt, format, wm); + + case WG_MAJOR_TYPE_VIDEO_CINEPAK: + return amt_from_wg_format_video_cinepak(mt, format); }
assert(0); @@ -656,7 +686,6 @@ static bool amt_to_wg_format_video(const AM_MEDIA_TYPE *mt, struct wg_format *fo {&MEDIASUBTYPE_YUY2, WG_VIDEO_FORMAT_YUY2}, {&MEDIASUBTYPE_YV12, WG_VIDEO_FORMAT_YV12}, {&MEDIASUBTYPE_YVYU, WG_VIDEO_FORMAT_YVYU}, - {&MEDIASUBTYPE_CVID, WG_VIDEO_FORMAT_CINEPAK}, };
const VIDEOINFOHEADER *video_format = (const VIDEOINFOHEADER *)mt->pbFormat; diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index e2eef2a4932..5692b0e6f11 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -36,6 +36,7 @@ struct wg_format { WG_MAJOR_TYPE_UNKNOWN, WG_MAJOR_TYPE_VIDEO, + WG_MAJOR_TYPE_VIDEO_CINEPAK, WG_MAJOR_TYPE_AUDIO, WG_MAJOR_TYPE_MPEG1_AUDIO, WG_MAJOR_TYPE_WMA, @@ -63,8 +64,6 @@ struct wg_format WG_VIDEO_FORMAT_YUY2, WG_VIDEO_FORMAT_YV12, WG_VIDEO_FORMAT_YVYU, - - WG_VIDEO_FORMAT_CINEPAK, } format; int32_t width, height; uint32_t fps_n, fps_d; @@ -106,6 +105,13 @@ struct wg_format unsigned char codec_data[64]; } wma; struct + { + uint32_t width; + uint32_t height; + uint32_t fps_n; + uint32_t fps_d; + } video_cinepak; + struct { int32_t width, height; uint32_t fps_n, fps_d; diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c index 3b568ea2fec..5f87163cb72 100644 --- a/dlls/winegstreamer/wg_format.c +++ b/dlls/winegstreamer/wg_format.c @@ -225,12 +225,11 @@ static void wg_format_from_caps_video_cinepak(struct wg_format *format, const Gs fps_d = 1; }
- format->major_type = WG_MAJOR_TYPE_VIDEO; - format->u.video.format = WG_VIDEO_FORMAT_CINEPAK; - format->u.video.width = width; - format->u.video.height = height; - format->u.video.fps_n = fps_n; - format->u.video.fps_d = fps_d; + format->major_type = WG_MAJOR_TYPE_VIDEO_CINEPAK; + format->u.video_cinepak.width = width; + format->u.video_cinepak.height = height; + format->u.video_cinepak.fps_n = fps_n; + format->u.video_cinepak.fps_d = fps_d; }
void wg_format_from_caps(struct wg_format *format, const GstCaps *caps) @@ -407,6 +406,23 @@ static GstCaps *wg_format_to_caps_video(const struct wg_format *format) return caps; }
+static GstCaps *wg_format_to_caps_video_cinepak(const struct wg_format *format) +{ + GstCaps *caps; + + if (!(caps = gst_caps_new_empty_simple("video/x-cinepak"))) + return NULL; + + if (format->u.video_cinepak.width) + gst_caps_set_simple(caps, "width", G_TYPE_INT, format->u.video_cinepak.width, NULL); + if (format->u.video_cinepak.height) + gst_caps_set_simple(caps, "height", G_TYPE_INT, format->u.video_cinepak.height, NULL); + if (format->u.video_cinepak.fps_d || format->u.video_cinepak.fps_n) + gst_caps_set_simple(caps, "framerate", GST_TYPE_FRACTION, format->u.video_cinepak.fps_n, format->u.video_cinepak.fps_d, NULL); + + return caps; +} + static GstCaps *wg_format_to_caps_wma(const struct wg_format *format) { GstBuffer *buffer; @@ -523,6 +539,8 @@ GstCaps *wg_format_to_caps(const struct wg_format *format) return wg_format_to_caps_audio(format); case WG_MAJOR_TYPE_VIDEO: return wg_format_to_caps_video(format); + case WG_MAJOR_TYPE_VIDEO_CINEPAK: + return wg_format_to_caps_video_cinepak(format); } assert(0); return NULL; @@ -554,6 +572,11 @@ bool wg_format_compare(const struct wg_format *a, const struct wg_format *b) && a->u.video.width == b->u.video.width && abs(a->u.video.height) == abs(b->u.video.height) && EqualRect( &a->u.video.padding, &b->u.video.padding ); + + case WG_MAJOR_TYPE_VIDEO_CINEPAK: + /* Do not compare FPS. */ + return a->u.video_cinepak.width == b->u.video_cinepak.width + && a->u.video_cinepak.height == b->u.video_cinepak.height; }
assert(0); diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index f0487fd1ffa..3e428cdebe8 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -236,7 +236,6 @@ static NTSTATUS wg_parser_stream_enable(void *args) case WG_VIDEO_FORMAT_YV12: case WG_VIDEO_FORMAT_YVYU: case WG_VIDEO_FORMAT_UNKNOWN: - case WG_VIDEO_FORMAT_CINEPAK: break; }
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index e703e93b07e..6fd3a097ed0 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -425,6 +425,7 @@ NTSTATUS wg_transform_create(void *args) /* fallthrough */ case WG_MAJOR_TYPE_MPEG1_AUDIO: case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_VIDEO_CINEPAK: if (!(element = transform_find_element(GST_ELEMENT_FACTORY_TYPE_DECODER, src_caps, raw_caps)) || !transform_append_element(transform, element, &first, &last)) { @@ -475,6 +476,7 @@ NTSTATUS wg_transform_create(void *args) case WG_MAJOR_TYPE_MPEG1_AUDIO: case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_VIDEO_CINEPAK: case WG_MAJOR_TYPE_UNKNOWN: GST_FIXME("Format %u not implemented!", output_format.major_type); goto out; diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 95d6d8e0180..610338554f1 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1511,6 +1511,8 @@ static const char *get_major_type_string(enum wg_major_type type) return "audio"; case WG_MAJOR_TYPE_VIDEO: return "video"; + case WG_MAJOR_TYPE_VIDEO_CINEPAK: + return "cinepak"; case WG_MAJOR_TYPE_UNKNOWN: return "unknown"; case WG_MAJOR_TYPE_MPEG1_AUDIO: @@ -1975,6 +1977,7 @@ static HRESULT WINAPI reader_GetOutputFormat(IWMSyncReader2 *iface, case WG_MAJOR_TYPE_MPEG1_AUDIO: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_H264: + case WG_MAJOR_TYPE_VIDEO_CINEPAK: FIXME("Format %u not implemented!\n", format.major_type); break; case WG_MAJOR_TYPE_UNKNOWN: @@ -2013,6 +2016,7 @@ static HRESULT WINAPI reader_GetOutputFormatCount(IWMSyncReader2 *iface, DWORD o case WG_MAJOR_TYPE_MPEG1_AUDIO: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_H264: + case WG_MAJOR_TYPE_VIDEO_CINEPAK: FIXME("Format %u not implemented!\n", format.major_type); /* fallthrough */ case WG_MAJOR_TYPE_AUDIO:
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/mfplat.c | 2 +- dlls/winegstreamer/quartz_parser.c | 40 +++++++++++++-------------- dlls/winegstreamer/quartz_transform.c | 4 +-- dlls/winegstreamer/unixlib.h | 4 +-- dlls/winegstreamer/wg_format.c | 22 +++++++-------- dlls/winegstreamer/wg_transform.c | 4 +-- dlls/winegstreamer/wm_reader.c | 8 +++--- 7 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 7c58ed93bfd..379f5dd77ee 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -487,9 +487,9 @@ IMFMediaType *mf_media_type_from_wg_format(const struct wg_format *format) { switch (format->major_type) { + case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_WMA: - case WG_MAJOR_TYPE_MPEG1_AUDIO: case WG_MAJOR_TYPE_VIDEO_CINEPAK: FIXME("Format %u not implemented!\n", format->major_type); /* fallthrough */ diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 12091d75398..322675a5e73 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -208,12 +208,12 @@ static bool amt_from_wg_format_audio(AM_MEDIA_TYPE *mt, const struct wg_format * return false; }
-static bool amt_from_wg_format_mpeg1_audio(AM_MEDIA_TYPE *mt, const struct wg_format *format) +static bool amt_from_wg_format_audio_mpeg1(AM_MEDIA_TYPE *mt, const struct wg_format *format) { mt->majortype = MEDIATYPE_Audio; mt->formattype = FORMAT_WaveFormatEx;
- switch (format->u.mpeg1_audio.layer) + switch (format->u.audio_mpeg1.layer) { case 1: case 2: @@ -228,10 +228,10 @@ static bool amt_from_wg_format_mpeg1_audio(AM_MEDIA_TYPE *mt, const struct wg_fo mt->cbFormat = sizeof(*wave_format); mt->pbFormat = (BYTE *)wave_format; wave_format->wfx.wFormatTag = WAVE_FORMAT_MPEG; - wave_format->wfx.nChannels = format->u.mpeg1_audio.channels; - wave_format->wfx.nSamplesPerSec = format->u.mpeg1_audio.rate; + wave_format->wfx.nChannels = format->u.audio_mpeg1.channels; + wave_format->wfx.nSamplesPerSec = format->u.audio_mpeg1.rate; wave_format->wfx.cbSize = sizeof(*wave_format) - sizeof(WAVEFORMATEX); - wave_format->fwHeadLayer = format->u.mpeg1_audio.layer; + wave_format->fwHeadLayer = format->u.audio_mpeg1.layer; return true; }
@@ -247,8 +247,8 @@ static bool amt_from_wg_format_mpeg1_audio(AM_MEDIA_TYPE *mt, const struct wg_fo mt->cbFormat = sizeof(*wave_format); mt->pbFormat = (BYTE *)wave_format; wave_format->wfx.wFormatTag = WAVE_FORMAT_MPEGLAYER3; - wave_format->wfx.nChannels = format->u.mpeg1_audio.channels; - wave_format->wfx.nSamplesPerSec = format->u.mpeg1_audio.rate; + wave_format->wfx.nChannels = format->u.audio_mpeg1.channels; + wave_format->wfx.nSamplesPerSec = format->u.audio_mpeg1.rate; wave_format->wfx.cbSize = sizeof(*wave_format) - sizeof(WAVEFORMATEX); /* FIXME: We can't get most of the MPEG data from the caps. We may have * to manually parse the header. */ @@ -345,8 +345,8 @@ unsigned int wg_format_get_max_size(const struct wg_format *format) break; }
- case WG_MAJOR_TYPE_MPEG1_AUDIO: - switch (format->u.mpeg1_audio.layer) + case WG_MAJOR_TYPE_AUDIO_MPEG1: + switch (format->u.audio_mpeg1.layer) { case 1: return 56000; @@ -535,12 +535,12 @@ bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool case WG_MAJOR_TYPE_UNKNOWN: return false;
- case WG_MAJOR_TYPE_MPEG1_AUDIO: - return amt_from_wg_format_mpeg1_audio(mt, format); - case WG_MAJOR_TYPE_AUDIO: return amt_from_wg_format_audio(mt, format);
+ case WG_MAJOR_TYPE_AUDIO_MPEG1: + return amt_from_wg_format_audio_mpeg1(mt, format); + case WG_MAJOR_TYPE_VIDEO: return amt_from_wg_format_video(mt, format, wm);
@@ -636,10 +636,10 @@ static bool amt_to_wg_format_audio_mpeg1(const AM_MEDIA_TYPE *mt, struct wg_form return false; }
- format->major_type = WG_MAJOR_TYPE_MPEG1_AUDIO; - format->u.mpeg1_audio.channels = audio_format->wfx.nChannels; - format->u.mpeg1_audio.rate = audio_format->wfx.nSamplesPerSec; - format->u.mpeg1_audio.layer = audio_format->fwHeadLayer; + format->major_type = WG_MAJOR_TYPE_AUDIO_MPEG1; + format->u.audio_mpeg1.channels = audio_format->wfx.nChannels; + format->u.audio_mpeg1.rate = audio_format->wfx.nSamplesPerSec; + format->u.audio_mpeg1.layer = audio_format->fwHeadLayer; return true; }
@@ -658,10 +658,10 @@ static bool amt_to_wg_format_audio_mpeg1_layer3(const AM_MEDIA_TYPE *mt, struct return false; }
- format->major_type = WG_MAJOR_TYPE_MPEG1_AUDIO; - format->u.mpeg1_audio.channels = audio_format->wfx.nChannels; - format->u.mpeg1_audio.rate = audio_format->wfx.nSamplesPerSec; - format->u.mpeg1_audio.layer = 3; + format->major_type = WG_MAJOR_TYPE_AUDIO_MPEG1; + format->u.audio_mpeg1.channels = audio_format->wfx.nChannels; + format->u.audio_mpeg1.rate = audio_format->wfx.nSamplesPerSec; + format->u.audio_mpeg1.layer = 3; return true; }
diff --git a/dlls/winegstreamer/quartz_transform.c b/dlls/winegstreamer/quartz_transform.c index b4640b497ec..9a713b120d2 100644 --- a/dlls/winegstreamer/quartz_transform.c +++ b/dlls/winegstreamer/quartz_transform.c @@ -700,8 +700,8 @@ HRESULT mpeg_audio_codec_create(IUnknown *outer, IUnknown **out) }; static const struct wg_format input_format = { - .major_type = WG_MAJOR_TYPE_MPEG1_AUDIO, - .u.mpeg1_audio = + .major_type = WG_MAJOR_TYPE_AUDIO_MPEG1, + .u.audio_mpeg1 = { .layer = 2, .channels = 1, diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index 5692b0e6f11..6c3843eb517 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -38,7 +38,7 @@ struct wg_format WG_MAJOR_TYPE_VIDEO, WG_MAJOR_TYPE_VIDEO_CINEPAK, WG_MAJOR_TYPE_AUDIO, - WG_MAJOR_TYPE_MPEG1_AUDIO, + WG_MAJOR_TYPE_AUDIO_MPEG1, WG_MAJOR_TYPE_WMA, WG_MAJOR_TYPE_H264, } major_type; @@ -92,7 +92,7 @@ struct wg_format uint32_t layer; uint32_t rate; uint32_t channels; - } mpeg1_audio; + } audio_mpeg1; struct { uint32_t version; diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c index 5f87163cb72..5ecb2f779d6 100644 --- a/dlls/winegstreamer/wg_format.c +++ b/dlls/winegstreamer/wg_format.c @@ -198,10 +198,10 @@ static void wg_format_from_caps_audio_mpeg1(struct wg_format *format, const GstC return; }
- format->major_type = WG_MAJOR_TYPE_MPEG1_AUDIO; - format->u.mpeg1_audio.layer = layer; - format->u.mpeg1_audio.channels = channels; - format->u.mpeg1_audio.rate = rate; + format->major_type = WG_MAJOR_TYPE_AUDIO_MPEG1; + format->u.audio_mpeg1.layer = layer; + format->u.audio_mpeg1.channels = channels; + format->u.audio_mpeg1.rate = rate; }
static void wg_format_from_caps_video_cinepak(struct wg_format *format, const GstCaps *caps) @@ -330,7 +330,7 @@ static void wg_channel_mask_to_gst(GstAudioChannelPosition *positions, uint32_t } }
-static GstCaps *wg_format_to_caps_mpeg1_audio(const struct wg_format *format) +static GstCaps *wg_format_to_caps_audio_mpeg1(const struct wg_format *format) { GstCaps *caps;
@@ -338,9 +338,9 @@ static GstCaps *wg_format_to_caps_mpeg1_audio(const struct wg_format *format) return NULL;
gst_caps_set_simple(caps, "mpegversion", G_TYPE_INT, 1, NULL); - gst_caps_set_simple(caps, "layer", G_TYPE_INT, format->u.mpeg1_audio.layer, NULL); - gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.mpeg1_audio.rate, NULL); - gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.mpeg1_audio.channels, NULL); + gst_caps_set_simple(caps, "layer", G_TYPE_INT, format->u.audio_mpeg1.layer, NULL); + gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.audio_mpeg1.rate, NULL); + gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.audio_mpeg1.channels, NULL); gst_caps_set_simple(caps, "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
return caps; @@ -529,14 +529,14 @@ GstCaps *wg_format_to_caps(const struct wg_format *format) { case WG_MAJOR_TYPE_UNKNOWN: return gst_caps_new_any(); - case WG_MAJOR_TYPE_MPEG1_AUDIO: - return wg_format_to_caps_mpeg1_audio(format); case WG_MAJOR_TYPE_WMA: return wg_format_to_caps_wma(format); case WG_MAJOR_TYPE_H264: return wg_format_to_caps_h264(format); case WG_MAJOR_TYPE_AUDIO: return wg_format_to_caps_audio(format); + case WG_MAJOR_TYPE_AUDIO_MPEG1: + return wg_format_to_caps_audio_mpeg1(format); case WG_MAJOR_TYPE_VIDEO: return wg_format_to_caps_video(format); case WG_MAJOR_TYPE_VIDEO_CINEPAK: @@ -553,7 +553,7 @@ bool wg_format_compare(const struct wg_format *a, const struct wg_format *b)
switch (a->major_type) { - case WG_MAJOR_TYPE_MPEG1_AUDIO: + case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_H264: GST_FIXME("Format %u not implemented!", a->major_type); diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index 6fd3a097ed0..6d07d884ada 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -423,7 +423,7 @@ NTSTATUS wg_transform_create(void *args) || !transform_append_element(transform, element, &first, &last)) goto out; /* fallthrough */ - case WG_MAJOR_TYPE_MPEG1_AUDIO: + case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_VIDEO_CINEPAK: if (!(element = transform_find_element(GST_ELEMENT_FACTORY_TYPE_DECODER, src_caps, raw_caps)) @@ -473,7 +473,7 @@ NTSTATUS wg_transform_create(void *args) gst_util_set_object_arg(G_OBJECT(element), "n-threads", "0"); break;
- case WG_MAJOR_TYPE_MPEG1_AUDIO: + case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_VIDEO_CINEPAK: diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 610338554f1..ad0f6037c72 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1509,14 +1509,14 @@ static const char *get_major_type_string(enum wg_major_type type) { case WG_MAJOR_TYPE_AUDIO: return "audio"; + case WG_MAJOR_TYPE_AUDIO_MPEG1: + return "mpeg1-audio"; case WG_MAJOR_TYPE_VIDEO: return "video"; case WG_MAJOR_TYPE_VIDEO_CINEPAK: return "cinepak"; case WG_MAJOR_TYPE_UNKNOWN: return "unknown"; - case WG_MAJOR_TYPE_MPEG1_AUDIO: - return "mpeg1-audio"; case WG_MAJOR_TYPE_WMA: return "wma"; case WG_MAJOR_TYPE_H264: @@ -1974,7 +1974,7 @@ static HRESULT WINAPI reader_GetOutputFormat(IWMSyncReader2 *iface, format.u.audio.format = WG_AUDIO_FORMAT_S16LE; break;
- case WG_MAJOR_TYPE_MPEG1_AUDIO: + case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK: @@ -2013,7 +2013,7 @@ static HRESULT WINAPI reader_GetOutputFormatCount(IWMSyncReader2 *iface, DWORD o *count = ARRAY_SIZE(video_formats); break;
- case WG_MAJOR_TYPE_MPEG1_AUDIO: + case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK:
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/mfplat.c | 24 ++++++++--------- dlls/winegstreamer/quartz_parser.c | 4 +-- dlls/winegstreamer/unixlib.h | 4 +-- dlls/winegstreamer/wg_format.c | 42 +++++++++++++++--------------- dlls/winegstreamer/wg_transform.c | 4 +-- dlls/winegstreamer/wm_reader.c | 8 +++--- dlls/winegstreamer/wma_decoder.c | 2 +- 7 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 379f5dd77ee..1c8b2ebfc6d 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -488,8 +488,8 @@ IMFMediaType *mf_media_type_from_wg_format(const struct wg_format *format) switch (format->major_type) { case WG_MAJOR_TYPE_AUDIO_MPEG1: + case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_H264: - case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_VIDEO_CINEPAK: FIXME("Format %u not implemented!\n", format->major_type); /* fallthrough */ @@ -601,7 +601,7 @@ static void mf_media_type_to_wg_format_video(IMFMediaType *type, const GUID *sub FIXME("Unrecognized video subtype %s.\n", debugstr_guid(subtype)); }
-static void mf_media_type_to_wg_format_wma(IMFMediaType *type, const GUID *subtype, struct wg_format *format) +static void mf_media_type_to_wg_format_audio_wma(IMFMediaType *type, const GUID *subtype, struct wg_format *format) { UINT32 rate, depth, channels, block_align, bytes_per_second, codec_data_len; BYTE codec_data[64]; @@ -652,15 +652,15 @@ static void mf_media_type_to_wg_format_wma(IMFMediaType *type, const GUID *subty return; }
- format->major_type = WG_MAJOR_TYPE_WMA; - format->u.wma.version = version; - format->u.wma.bitrate = bytes_per_second * 8; - format->u.wma.rate = rate; - format->u.wma.depth = depth; - format->u.wma.channels = channels; - format->u.wma.block_align = block_align; - format->u.wma.codec_data_len = codec_data_len; - memcpy(format->u.wma.codec_data, codec_data, codec_data_len); + format->major_type = WG_MAJOR_TYPE_AUDIO_WMA; + format->u.audio_wma.version = version; + format->u.audio_wma.bitrate = bytes_per_second * 8; + format->u.audio_wma.rate = rate; + format->u.audio_wma.depth = depth; + format->u.audio_wma.channels = channels; + format->u.audio_wma.block_align = block_align; + format->u.audio_wma.codec_data_len = codec_data_len; + memcpy(format->u.audio_wma.codec_data, codec_data, codec_data_len); }
static void mf_media_type_to_wg_format_h264(IMFMediaType *type, struct wg_format *format) @@ -718,7 +718,7 @@ void mf_media_type_to_wg_format(IMFMediaType *type, struct wg_format *format) IsEqualGUID(&subtype, &MFAudioFormat_WMAudioV8) || IsEqualGUID(&subtype, &MFAudioFormat_WMAudioV9) || IsEqualGUID(&subtype, &MFAudioFormat_WMAudio_Lossless)) - mf_media_type_to_wg_format_wma(type, &subtype, format); + mf_media_type_to_wg_format_audio_wma(type, &subtype, format); else mf_media_type_to_wg_format_audio(type, &subtype, format); } diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 322675a5e73..d9248f81d81 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -359,8 +359,8 @@ unsigned int wg_format_get_max_size(const struct wg_format *format) } break;
+ case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_H264: - case WG_MAJOR_TYPE_WMA: FIXME("Format %u not implemented!\n", format->major_type); return 0;
@@ -528,8 +528,8 @@ bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool
switch (format->major_type) { + case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_H264: - case WG_MAJOR_TYPE_WMA: FIXME("Format %u not implemented!\n", format->major_type); /* fallthrough */ case WG_MAJOR_TYPE_UNKNOWN: diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index 6c3843eb517..31e7d8359cd 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -39,7 +39,7 @@ struct wg_format WG_MAJOR_TYPE_VIDEO_CINEPAK, WG_MAJOR_TYPE_AUDIO, WG_MAJOR_TYPE_AUDIO_MPEG1, - WG_MAJOR_TYPE_WMA, + WG_MAJOR_TYPE_AUDIO_WMA, WG_MAJOR_TYPE_H264, } major_type;
@@ -103,7 +103,7 @@ struct wg_format uint32_t block_align; uint32_t codec_data_len; unsigned char codec_data[64]; - } wma; + } audio_wma; struct { uint32_t width; diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c index 5ecb2f779d6..261dc9a03e8 100644 --- a/dlls/winegstreamer/wg_format.c +++ b/dlls/winegstreamer/wg_format.c @@ -423,36 +423,36 @@ static GstCaps *wg_format_to_caps_video_cinepak(const struct wg_format *format) return caps; }
-static GstCaps *wg_format_to_caps_wma(const struct wg_format *format) +static GstCaps *wg_format_to_caps_audio_wma(const struct wg_format *format) { GstBuffer *buffer; GstCaps *caps;
if (!(caps = gst_caps_new_empty_simple("audio/x-wma"))) return NULL; - if (format->u.wma.version) - gst_caps_set_simple(caps, "wmaversion", G_TYPE_INT, format->u.wma.version, NULL); - - if (format->u.wma.bitrate) - gst_caps_set_simple(caps, "bitrate", G_TYPE_INT, format->u.wma.bitrate, NULL); - if (format->u.wma.rate) - gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.wma.rate, NULL); - if (format->u.wma.depth) - gst_caps_set_simple(caps, "depth", G_TYPE_INT, format->u.wma.depth, NULL); - if (format->u.wma.channels) - gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.wma.channels, NULL); - if (format->u.wma.block_align) - gst_caps_set_simple(caps, "block_align", G_TYPE_INT, format->u.wma.block_align, NULL); - - if (format->u.wma.codec_data_len) + if (format->u.audio_wma.version) + gst_caps_set_simple(caps, "wmaversion", G_TYPE_INT, format->u.audio_wma.version, NULL); + + if (format->u.audio_wma.bitrate) + gst_caps_set_simple(caps, "bitrate", G_TYPE_INT, format->u.audio_wma.bitrate, NULL); + if (format->u.audio_wma.rate) + gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.audio_wma.rate, NULL); + if (format->u.audio_wma.depth) + gst_caps_set_simple(caps, "depth", G_TYPE_INT, format->u.audio_wma.depth, NULL); + if (format->u.audio_wma.channels) + gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.audio_wma.channels, NULL); + if (format->u.audio_wma.block_align) + gst_caps_set_simple(caps, "block_align", G_TYPE_INT, format->u.audio_wma.block_align, NULL); + + if (format->u.audio_wma.codec_data_len) { - if (!(buffer = gst_buffer_new_and_alloc(format->u.wma.codec_data_len))) + if (!(buffer = gst_buffer_new_and_alloc(format->u.audio_wma.codec_data_len))) { gst_caps_unref(caps); return NULL; }
- gst_buffer_fill(buffer, 0, format->u.wma.codec_data, format->u.wma.codec_data_len); + gst_buffer_fill(buffer, 0, format->u.audio_wma.codec_data, format->u.audio_wma.codec_data_len); gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL); gst_buffer_unref(buffer); } @@ -529,14 +529,14 @@ GstCaps *wg_format_to_caps(const struct wg_format *format) { case WG_MAJOR_TYPE_UNKNOWN: return gst_caps_new_any(); - case WG_MAJOR_TYPE_WMA: - return wg_format_to_caps_wma(format); case WG_MAJOR_TYPE_H264: return wg_format_to_caps_h264(format); case WG_MAJOR_TYPE_AUDIO: return wg_format_to_caps_audio(format); case WG_MAJOR_TYPE_AUDIO_MPEG1: return wg_format_to_caps_audio_mpeg1(format); + case WG_MAJOR_TYPE_AUDIO_WMA: + return wg_format_to_caps_audio_wma(format); case WG_MAJOR_TYPE_VIDEO: return wg_format_to_caps_video(format); case WG_MAJOR_TYPE_VIDEO_CINEPAK: @@ -554,7 +554,7 @@ bool wg_format_compare(const struct wg_format *a, const struct wg_format *b) switch (a->major_type) { case WG_MAJOR_TYPE_AUDIO_MPEG1: - case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_H264: GST_FIXME("Format %u not implemented!", a->major_type); /* fallthrough */ diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index 6d07d884ada..8a590a042a0 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -424,7 +424,7 @@ NTSTATUS wg_transform_create(void *args) goto out; /* fallthrough */ case WG_MAJOR_TYPE_AUDIO_MPEG1: - case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_VIDEO_CINEPAK: if (!(element = transform_find_element(GST_ELEMENT_FACTORY_TYPE_DECODER, src_caps, raw_caps)) || !transform_append_element(transform, element, &first, &last)) @@ -474,8 +474,8 @@ NTSTATUS wg_transform_create(void *args) break;
case WG_MAJOR_TYPE_AUDIO_MPEG1: + case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_H264: - case WG_MAJOR_TYPE_WMA: case WG_MAJOR_TYPE_VIDEO_CINEPAK: case WG_MAJOR_TYPE_UNKNOWN: GST_FIXME("Format %u not implemented!", output_format.major_type); diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index ad0f6037c72..ba3bff79761 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1511,14 +1511,14 @@ static const char *get_major_type_string(enum wg_major_type type) return "audio"; case WG_MAJOR_TYPE_AUDIO_MPEG1: return "mpeg1-audio"; + case WG_MAJOR_TYPE_AUDIO_WMA: + return "wma"; case WG_MAJOR_TYPE_VIDEO: return "video"; case WG_MAJOR_TYPE_VIDEO_CINEPAK: return "cinepak"; case WG_MAJOR_TYPE_UNKNOWN: return "unknown"; - case WG_MAJOR_TYPE_WMA: - return "wma"; case WG_MAJOR_TYPE_H264: return "h264"; } @@ -1975,7 +1975,7 @@ static HRESULT WINAPI reader_GetOutputFormat(IWMSyncReader2 *iface, break;
case WG_MAJOR_TYPE_AUDIO_MPEG1: - case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK: FIXME("Format %u not implemented!\n", format.major_type); @@ -2014,7 +2014,7 @@ static HRESULT WINAPI reader_GetOutputFormatCount(IWMSyncReader2 *iface, DWORD o break;
case WG_MAJOR_TYPE_AUDIO_MPEG1: - case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_AUDIO_WMA: case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK: FIXME("Format %u not implemented!\n", format.major_type); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index 6d8917c9c07..1391a7b60e1 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -870,7 +870,7 @@ HRESULT wma_decoder_create(IUnknown *outer, IUnknown **out) .rate = 44100, }, }; - static const struct wg_format input_format = {.major_type = WG_MAJOR_TYPE_WMA}; + static const struct wg_format input_format = {.major_type = WG_MAJOR_TYPE_AUDIO_WMA}; struct wg_transform *transform; struct wma_decoder *decoder; HRESULT hr;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/h264_decoder.c | 2 +- dlls/winegstreamer/mfplat.c | 24 ++++++++++++------------ dlls/winegstreamer/quartz_parser.c | 4 ++-- dlls/winegstreamer/unixlib.h | 4 ++-- dlls/winegstreamer/wg_format.c | 28 ++++++++++++++-------------- dlls/winegstreamer/wg_transform.c | 4 ++-- dlls/winegstreamer/wm_reader.c | 8 ++++---- 7 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/dlls/winegstreamer/h264_decoder.c b/dlls/winegstreamer/h264_decoder.c index 44c6d992b55..7fbe46c22a4 100644 --- a/dlls/winegstreamer/h264_decoder.c +++ b/dlls/winegstreamer/h264_decoder.c @@ -698,7 +698,7 @@ HRESULT h264_decoder_create(REFIID riid, void **ret) .height = 1080, }, }; - static const struct wg_format input_format = {.major_type = WG_MAJOR_TYPE_H264}; + static const struct wg_format input_format = {.major_type = WG_MAJOR_TYPE_VIDEO_H264}; struct wg_transform *transform; struct h264_decoder *decoder; HRESULT hr; diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 1c8b2ebfc6d..7e83d570f06 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -489,8 +489,8 @@ IMFMediaType *mf_media_type_from_wg_format(const struct wg_format *format) { case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_AUDIO_WMA: - case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK: + case WG_MAJOR_TYPE_VIDEO_H264: FIXME("Format %u not implemented!\n", format->major_type); /* fallthrough */ case WG_MAJOR_TYPE_UNKNOWN: @@ -663,36 +663,36 @@ static void mf_media_type_to_wg_format_audio_wma(IMFMediaType *type, const GUID memcpy(format->u.audio_wma.codec_data, codec_data, codec_data_len); }
-static void mf_media_type_to_wg_format_h264(IMFMediaType *type, struct wg_format *format) +static void mf_media_type_to_wg_format_video_h264(IMFMediaType *type, struct wg_format *format) { UINT64 frame_rate, frame_size; UINT32 profile, level;
memset(format, 0, sizeof(*format)); - format->major_type = WG_MAJOR_TYPE_H264; + format->major_type = WG_MAJOR_TYPE_VIDEO_H264;
if (SUCCEEDED(IMFMediaType_GetUINT64(type, &MF_MT_FRAME_SIZE, &frame_size))) { - format->u.h264.width = frame_size >> 32; - format->u.h264.height = (UINT32)frame_size; + format->u.video_h264.width = frame_size >> 32; + format->u.video_h264.height = (UINT32)frame_size; }
if (SUCCEEDED(IMFMediaType_GetUINT64(type, &MF_MT_FRAME_RATE, &frame_rate)) && (UINT32)frame_rate) { - format->u.h264.fps_n = frame_rate >> 32; - format->u.h264.fps_d = (UINT32)frame_rate; + format->u.video_h264.fps_n = frame_rate >> 32; + format->u.video_h264.fps_d = (UINT32)frame_rate; } else { - format->u.h264.fps_n = 1; - format->u.h264.fps_d = 1; + format->u.video_h264.fps_n = 1; + format->u.video_h264.fps_d = 1; }
if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_MPEG2_PROFILE, &profile))) - format->u.h264.profile = profile; + format->u.video_h264.profile = profile;
if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_MPEG2_LEVEL, &level))) - format->u.h264.level = level; + format->u.video_h264.level = level; }
void mf_media_type_to_wg_format(IMFMediaType *type, struct wg_format *format) @@ -725,7 +725,7 @@ void mf_media_type_to_wg_format(IMFMediaType *type, struct wg_format *format) else if (IsEqualGUID(&major_type, &MFMediaType_Video)) { if (IsEqualGUID(&subtype, &MFVideoFormat_H264)) - mf_media_type_to_wg_format_h264(type, format); + mf_media_type_to_wg_format_video_h264(type, format); else mf_media_type_to_wg_format_video(type, &subtype, format); } diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index d9248f81d81..55e5988e880 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -360,7 +360,7 @@ unsigned int wg_format_get_max_size(const struct wg_format *format) break;
case WG_MAJOR_TYPE_AUDIO_WMA: - case WG_MAJOR_TYPE_H264: + case WG_MAJOR_TYPE_VIDEO_H264: FIXME("Format %u not implemented!\n", format->major_type); return 0;
@@ -529,7 +529,7 @@ bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool switch (format->major_type) { case WG_MAJOR_TYPE_AUDIO_WMA: - case WG_MAJOR_TYPE_H264: + case WG_MAJOR_TYPE_VIDEO_H264: FIXME("Format %u not implemented!\n", format->major_type); /* fallthrough */ case WG_MAJOR_TYPE_UNKNOWN: diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index 31e7d8359cd..9ec992368b9 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -37,10 +37,10 @@ struct wg_format WG_MAJOR_TYPE_UNKNOWN, WG_MAJOR_TYPE_VIDEO, WG_MAJOR_TYPE_VIDEO_CINEPAK, + WG_MAJOR_TYPE_VIDEO_H264, WG_MAJOR_TYPE_AUDIO, WG_MAJOR_TYPE_AUDIO_MPEG1, WG_MAJOR_TYPE_AUDIO_WMA, - WG_MAJOR_TYPE_H264, } major_type;
union @@ -117,7 +117,7 @@ struct wg_format uint32_t fps_n, fps_d; uint32_t profile; uint32_t level; - } h264; + } video_h264; } u; };
diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c index 261dc9a03e8..b67c820dd71 100644 --- a/dlls/winegstreamer/wg_format.c +++ b/dlls/winegstreamer/wg_format.c @@ -460,7 +460,7 @@ static GstCaps *wg_format_to_caps_audio_wma(const struct wg_format *format) return caps; }
-static GstCaps *wg_format_to_caps_h264(const struct wg_format *format) +static GstCaps *wg_format_to_caps_video_h264(const struct wg_format *format) { const char *profile, *level; GstCaps *caps; @@ -470,20 +470,20 @@ static GstCaps *wg_format_to_caps_h264(const struct wg_format *format) gst_caps_set_simple(caps, "stream-format", G_TYPE_STRING, "byte-stream", NULL); gst_caps_set_simple(caps, "alignment", G_TYPE_STRING, "au", NULL);
- if (format->u.h264.width) - gst_caps_set_simple(caps, "width", G_TYPE_INT, format->u.h264.width, NULL); - if (format->u.h264.height) - gst_caps_set_simple(caps, "height", G_TYPE_INT, format->u.h264.height, NULL); - if (format->u.h264.fps_n || format->u.h264.fps_d) - gst_caps_set_simple(caps, "framerate", GST_TYPE_FRACTION, format->u.h264.fps_n, format->u.h264.fps_d, NULL); + if (format->u.video_h264.width) + gst_caps_set_simple(caps, "width", G_TYPE_INT, format->u.video_h264.width, NULL); + if (format->u.video_h264.height) + gst_caps_set_simple(caps, "height", G_TYPE_INT, format->u.video_h264.height, NULL); + if (format->u.video_h264.fps_n || format->u.video_h264.fps_d) + gst_caps_set_simple(caps, "framerate", GST_TYPE_FRACTION, format->u.video_h264.fps_n, format->u.video_h264.fps_d, NULL);
- switch (format->u.h264.profile) + switch (format->u.video_h264.profile) { case eAVEncH264VProfile_Main: profile = "main"; break; case eAVEncH264VProfile_High: profile = "high"; break; case eAVEncH264VProfile_444: profile = "high-4:4:4"; break; default: - GST_FIXME("H264 profile attribute %u not implemented.", format->u.h264.profile); + GST_FIXME("H264 profile attribute %u not implemented.", format->u.video_h264.profile); /* fallthrough */ case eAVEncH264VProfile_unknown: profile = NULL; @@ -492,7 +492,7 @@ static GstCaps *wg_format_to_caps_h264(const struct wg_format *format) if (profile) gst_caps_set_simple(caps, "profile", G_TYPE_STRING, profile, NULL);
- switch (format->u.h264.level) + switch (format->u.video_h264.level) { case eAVEncH264VLevel1: level = "1"; break; case eAVEncH264VLevel1_1: level = "1.1"; break; @@ -511,7 +511,7 @@ static GstCaps *wg_format_to_caps_h264(const struct wg_format *format) case eAVEncH264VLevel5_1: level = "5.1"; break; case eAVEncH264VLevel5_2: level = "5.2"; break; default: - GST_FIXME("H264 level attribute %u not implemented.", format->u.h264.level); + GST_FIXME("H264 level attribute %u not implemented.", format->u.video_h264.level); /* fallthrough */ case 0: level = NULL; @@ -529,8 +529,6 @@ GstCaps *wg_format_to_caps(const struct wg_format *format) { case WG_MAJOR_TYPE_UNKNOWN: return gst_caps_new_any(); - case WG_MAJOR_TYPE_H264: - return wg_format_to_caps_h264(format); case WG_MAJOR_TYPE_AUDIO: return wg_format_to_caps_audio(format); case WG_MAJOR_TYPE_AUDIO_MPEG1: @@ -541,6 +539,8 @@ GstCaps *wg_format_to_caps(const struct wg_format *format) return wg_format_to_caps_video(format); case WG_MAJOR_TYPE_VIDEO_CINEPAK: return wg_format_to_caps_video_cinepak(format); + case WG_MAJOR_TYPE_VIDEO_H264: + return wg_format_to_caps_video_h264(format); } assert(0); return NULL; @@ -555,7 +555,7 @@ bool wg_format_compare(const struct wg_format *a, const struct wg_format *b) { case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_AUDIO_WMA: - case WG_MAJOR_TYPE_H264: + case WG_MAJOR_TYPE_VIDEO_H264: GST_FIXME("Format %u not implemented!", a->major_type); /* fallthrough */ case WG_MAJOR_TYPE_UNKNOWN: diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index 8a590a042a0..486562fdff6 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -411,7 +411,7 @@ NTSTATUS wg_transform_create(void *args)
switch (input_format.major_type) { - case WG_MAJOR_TYPE_H264: + case WG_MAJOR_TYPE_VIDEO_H264: /* Call of Duty: Black Ops 3 doesn't care about the ProcessInput/ProcessOutput * return values, it calls them in a specific order and expects the decoder * transform to be able to queue its input buffers. We need to use a buffer list @@ -475,8 +475,8 @@ NTSTATUS wg_transform_create(void *args)
case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_AUDIO_WMA: - case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK: + case WG_MAJOR_TYPE_VIDEO_H264: case WG_MAJOR_TYPE_UNKNOWN: GST_FIXME("Format %u not implemented!", output_format.major_type); goto out; diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index ba3bff79761..f4210379a30 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1517,10 +1517,10 @@ static const char *get_major_type_string(enum wg_major_type type) return "video"; case WG_MAJOR_TYPE_VIDEO_CINEPAK: return "cinepak"; + case WG_MAJOR_TYPE_VIDEO_H264: + return "h264"; case WG_MAJOR_TYPE_UNKNOWN: return "unknown"; - case WG_MAJOR_TYPE_H264: - return "h264"; } assert(0); return NULL; @@ -1976,8 +1976,8 @@ static HRESULT WINAPI reader_GetOutputFormat(IWMSyncReader2 *iface,
case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_AUDIO_WMA: - case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK: + case WG_MAJOR_TYPE_VIDEO_H264: FIXME("Format %u not implemented!\n", format.major_type); break; case WG_MAJOR_TYPE_UNKNOWN: @@ -2015,8 +2015,8 @@ static HRESULT WINAPI reader_GetOutputFormatCount(IWMSyncReader2 *iface, DWORD o
case WG_MAJOR_TYPE_AUDIO_MPEG1: case WG_MAJOR_TYPE_AUDIO_WMA: - case WG_MAJOR_TYPE_H264: case WG_MAJOR_TYPE_VIDEO_CINEPAK: + case WG_MAJOR_TYPE_VIDEO_H264: FIXME("Format %u not implemented!\n", format.major_type); /* fallthrough */ case WG_MAJOR_TYPE_AUDIO:
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/mfplat.c | 16 ++------ dlls/winegstreamer/quartz_parser.c | 65 ++++++++---------------------- dlls/winegstreamer/unixlib.h | 63 ++++++++++++++++++----------- dlls/winegstreamer/wg_format.c | 45 ++++----------------- 4 files changed, 66 insertions(+), 123 deletions(-)
diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 7e83d570f06..634d3721788 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -371,19 +371,9 @@ static const struct } video_formats[] = { - {&MFVideoFormat_ARGB32, WG_VIDEO_FORMAT_BGRA}, - {&MFVideoFormat_RGB32, WG_VIDEO_FORMAT_BGRx}, - {&MFVideoFormat_RGB24, WG_VIDEO_FORMAT_BGR}, - {&MFVideoFormat_RGB555, WG_VIDEO_FORMAT_RGB15}, - {&MFVideoFormat_RGB565, WG_VIDEO_FORMAT_RGB16}, - {&MFVideoFormat_AYUV, WG_VIDEO_FORMAT_AYUV}, - {&MFVideoFormat_I420, WG_VIDEO_FORMAT_I420}, - {&MFVideoFormat_IYUV, WG_VIDEO_FORMAT_I420}, - {&MFVideoFormat_NV12, WG_VIDEO_FORMAT_NV12}, - {&MFVideoFormat_UYVY, WG_VIDEO_FORMAT_UYVY}, - {&MFVideoFormat_YUY2, WG_VIDEO_FORMAT_YUY2}, - {&MFVideoFormat_YV12, WG_VIDEO_FORMAT_YV12}, - {&MFVideoFormat_YVYU, WG_VIDEO_FORMAT_YVYU}, +#define X(x, g, d, t) {&MFVideoFormat_ ## g, WG_VIDEO_FORMAT_ ## x}, + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X };
static const struct diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 55e5988e880..3816895387f 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -377,19 +377,10 @@ static const GUID *wg_video_format_get_mediasubtype(enum wg_video_format format) { switch (format) { +#define X(x, g, d, t) case WG_VIDEO_FORMAT_ ## x: return &MEDIASUBTYPE_ ## g; + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X case WG_VIDEO_FORMAT_UNKNOWN: return &GUID_NULL; - case WG_VIDEO_FORMAT_BGRA: return &MEDIASUBTYPE_ARGB32; - case WG_VIDEO_FORMAT_BGRx: return &MEDIASUBTYPE_RGB32; - case WG_VIDEO_FORMAT_BGR: return &MEDIASUBTYPE_RGB24; - case WG_VIDEO_FORMAT_RGB15: return &MEDIASUBTYPE_RGB555; - case WG_VIDEO_FORMAT_RGB16: return &MEDIASUBTYPE_RGB565; - case WG_VIDEO_FORMAT_AYUV: return &MEDIASUBTYPE_AYUV; - case WG_VIDEO_FORMAT_I420: return &MEDIASUBTYPE_I420; - case WG_VIDEO_FORMAT_NV12: return &MEDIASUBTYPE_NV12; - case WG_VIDEO_FORMAT_UYVY: return &MEDIASUBTYPE_UYVY; - case WG_VIDEO_FORMAT_YUY2: return &MEDIASUBTYPE_YUY2; - case WG_VIDEO_FORMAT_YV12: return &MEDIASUBTYPE_YV12; - case WG_VIDEO_FORMAT_YVYU: return &MEDIASUBTYPE_YVYU; }
assert(0); @@ -400,19 +391,14 @@ static DWORD wg_video_format_get_compression(enum wg_video_format format) { switch (format) { +#define X_RGB(g) BI_RGB +#define X_YUV(g) MEDIASUBTYPE_ ## g.Data1 +#define X(x, g, d, t) case WG_VIDEO_FORMAT_ ## x: return X_ ## t(g); + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X +#undef X_YUV +#undef X_RGB case WG_VIDEO_FORMAT_UNKNOWN: return 0; - case WG_VIDEO_FORMAT_BGRA: return BI_RGB; - case WG_VIDEO_FORMAT_BGRx: return BI_RGB; - case WG_VIDEO_FORMAT_BGR: return BI_RGB; - case WG_VIDEO_FORMAT_RGB15: return BI_RGB; - case WG_VIDEO_FORMAT_RGB16: return BI_BITFIELDS; - case WG_VIDEO_FORMAT_AYUV: return mmioFOURCC('A','Y','U','V'); - case WG_VIDEO_FORMAT_I420: return mmioFOURCC('I','4','2','0'); - case WG_VIDEO_FORMAT_NV12: return mmioFOURCC('N','V','1','2'); - case WG_VIDEO_FORMAT_UYVY: return mmioFOURCC('U','Y','V','Y'); - case WG_VIDEO_FORMAT_YUY2: return mmioFOURCC('Y','U','Y','2'); - case WG_VIDEO_FORMAT_YV12: return mmioFOURCC('Y','V','1','2'); - case WG_VIDEO_FORMAT_YVYU: return mmioFOURCC('Y','V','Y','U'); }
assert(0); @@ -423,19 +409,10 @@ static WORD wg_video_format_get_depth(enum wg_video_format format) { switch (format) { +#define X(x, g, d, t) case WG_VIDEO_FORMAT_ ## x: return d; + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X case WG_VIDEO_FORMAT_UNKNOWN: return 0; - case WG_VIDEO_FORMAT_BGRA: return 32; - case WG_VIDEO_FORMAT_BGRx: return 32; - case WG_VIDEO_FORMAT_BGR: return 24; - case WG_VIDEO_FORMAT_RGB15: return 16; - case WG_VIDEO_FORMAT_RGB16: return 16; - case WG_VIDEO_FORMAT_AYUV: return 32; - case WG_VIDEO_FORMAT_I420: return 12; - case WG_VIDEO_FORMAT_NV12: return 12; - case WG_VIDEO_FORMAT_UYVY: return 16; - case WG_VIDEO_FORMAT_YUY2: return 16; - case WG_VIDEO_FORMAT_YV12: return 12; - case WG_VIDEO_FORMAT_YVYU: return 16; }
assert(0); @@ -484,6 +461,7 @@ static bool amt_from_wg_format_video(AM_MEDIA_TYPE *mt, const struct wg_format * if (format->u.video.format == WG_VIDEO_FORMAT_RGB16) { mt->cbFormat = offsetof(VIDEOINFO, dwBitMasks[3]); + video_format->bmiHeader.biCompression = BI_BITFIELDS; video_format->dwBitMasks[iRED] = 0xf800; video_format->dwBitMasks[iGREEN] = 0x07e0; video_format->dwBitMasks[iBLUE] = 0x001f; @@ -674,18 +652,9 @@ static bool amt_to_wg_format_video(const AM_MEDIA_TYPE *mt, struct wg_format *fo } format_map[] = { - {&MEDIASUBTYPE_ARGB32, WG_VIDEO_FORMAT_BGRA}, - {&MEDIASUBTYPE_RGB32, WG_VIDEO_FORMAT_BGRx}, - {&MEDIASUBTYPE_RGB24, WG_VIDEO_FORMAT_BGR}, - {&MEDIASUBTYPE_RGB555, WG_VIDEO_FORMAT_RGB15}, - {&MEDIASUBTYPE_RGB565, WG_VIDEO_FORMAT_RGB16}, - {&MEDIASUBTYPE_AYUV, WG_VIDEO_FORMAT_AYUV}, - {&MEDIASUBTYPE_I420, WG_VIDEO_FORMAT_I420}, - {&MEDIASUBTYPE_NV12, WG_VIDEO_FORMAT_NV12}, - {&MEDIASUBTYPE_UYVY, WG_VIDEO_FORMAT_UYVY}, - {&MEDIASUBTYPE_YUY2, WG_VIDEO_FORMAT_YUY2}, - {&MEDIASUBTYPE_YV12, WG_VIDEO_FORMAT_YV12}, - {&MEDIASUBTYPE_YVYU, WG_VIDEO_FORMAT_YVYU}, +#define X(x, g, d, t) {&MEDIASUBTYPE_ ## g, WG_VIDEO_FORMAT_ ## x}, + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X };
const VIDEOINFOHEADER *video_format = (const VIDEOINFOHEADER *)mt->pbFormat; diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index 9ec992368b9..f91fb986322 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -30,6 +30,37 @@
#include "wine/unixlib.h"
+/* List all supported raw video formats, with their metadata. + * + * Each element should be X(wg, guid, depth, type), with: + * wg: suffix of the GStreamer constant, and enum wg_video_format value. + * guid: suffix of the corresponding MEDIASUBTYPE / MFVideoFormat guid. + * depth: the number of bits of each video sample. + * type: whether the video format is RGB or YUV. + * + */ +#define FOR_EACH_WG_VIDEO_FORMAT(F) \ + F(BGRA, ARGB32, 32, RGB) \ + F(BGRx, RGB32, 32, RGB) \ + F(BGR, RGB24, 24, RGB) \ + F(RGB15, RGB555, 16, RGB) \ + F(RGB16, RGB565, 16, RGB) \ + F(AYUV, AYUV, 32, YUV) \ + F(I420, I420, 12, YUV) \ + F(NV12, NV12, 12, YUV) \ + F(UYVY, UYVY, 16, YUV) \ + F(YUY2, YUY2, 16, YUV) \ + F(YV12, YV12, 12, YUV) \ + F(YVYU, YVYU, 16, YUV) \ + +enum wg_video_format +{ + WG_VIDEO_FORMAT_UNKNOWN = 0, +#define X(x, g, d, t) WG_VIDEO_FORMAT_ ## x, + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X +}; + struct wg_format { enum wg_major_type @@ -45,30 +76,6 @@ struct wg_format
union { - struct - { - enum wg_video_format - { - WG_VIDEO_FORMAT_UNKNOWN, - - WG_VIDEO_FORMAT_BGRA, - WG_VIDEO_FORMAT_BGRx, - WG_VIDEO_FORMAT_BGR, - WG_VIDEO_FORMAT_RGB15, - WG_VIDEO_FORMAT_RGB16, - - WG_VIDEO_FORMAT_AYUV, - WG_VIDEO_FORMAT_I420, - WG_VIDEO_FORMAT_NV12, - WG_VIDEO_FORMAT_UYVY, - WG_VIDEO_FORMAT_YUY2, - WG_VIDEO_FORMAT_YV12, - WG_VIDEO_FORMAT_YVYU, - } format; - int32_t width, height; - uint32_t fps_n, fps_d; - RECT padding; - } video; struct { enum wg_audio_format @@ -104,6 +111,14 @@ struct wg_format uint32_t codec_data_len; unsigned char codec_data[64]; } audio_wma; + + struct + { + enum wg_video_format format; + int32_t width, height; + uint32_t fps_n, fps_d; + RECT padding; + } video; struct { uint32_t width; diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c index b67c820dd71..50c5d1ba256 100644 --- a/dlls/winegstreamer/wg_format.c +++ b/dlls/winegstreamer/wg_format.c @@ -138,32 +138,10 @@ static enum wg_video_format wg_video_format_from_gst(GstVideoFormat format) { switch (format) { - case GST_VIDEO_FORMAT_BGRA: - return WG_VIDEO_FORMAT_BGRA; - case GST_VIDEO_FORMAT_BGRx: - return WG_VIDEO_FORMAT_BGRx; - case GST_VIDEO_FORMAT_BGR: - return WG_VIDEO_FORMAT_BGR; - case GST_VIDEO_FORMAT_RGB15: - return WG_VIDEO_FORMAT_RGB15; - case GST_VIDEO_FORMAT_RGB16: - return WG_VIDEO_FORMAT_RGB16; - case GST_VIDEO_FORMAT_AYUV: - return WG_VIDEO_FORMAT_AYUV; - case GST_VIDEO_FORMAT_I420: - return WG_VIDEO_FORMAT_I420; - case GST_VIDEO_FORMAT_NV12: - return WG_VIDEO_FORMAT_NV12; - case GST_VIDEO_FORMAT_UYVY: - return WG_VIDEO_FORMAT_UYVY; - case GST_VIDEO_FORMAT_YUY2: - return WG_VIDEO_FORMAT_YUY2; - case GST_VIDEO_FORMAT_YV12: - return WG_VIDEO_FORMAT_YV12; - case GST_VIDEO_FORMAT_YVYU: - return WG_VIDEO_FORMAT_YVYU; - default: - return WG_VIDEO_FORMAT_UNKNOWN; +#define X(x, g, d, t) case GST_VIDEO_FORMAT_ ## x: return WG_VIDEO_FORMAT_ ## x; + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X + default: return WG_VIDEO_FORMAT_UNKNOWN; } }
@@ -364,18 +342,9 @@ static GstVideoFormat wg_video_format_to_gst(enum wg_video_format format) { switch (format) { - case WG_VIDEO_FORMAT_BGRA: return GST_VIDEO_FORMAT_BGRA; - case WG_VIDEO_FORMAT_BGRx: return GST_VIDEO_FORMAT_BGRx; - case WG_VIDEO_FORMAT_BGR: return GST_VIDEO_FORMAT_BGR; - case WG_VIDEO_FORMAT_RGB15: return GST_VIDEO_FORMAT_RGB15; - case WG_VIDEO_FORMAT_RGB16: return GST_VIDEO_FORMAT_RGB16; - case WG_VIDEO_FORMAT_AYUV: return GST_VIDEO_FORMAT_AYUV; - case WG_VIDEO_FORMAT_I420: return GST_VIDEO_FORMAT_I420; - case WG_VIDEO_FORMAT_NV12: return GST_VIDEO_FORMAT_NV12; - case WG_VIDEO_FORMAT_UYVY: return GST_VIDEO_FORMAT_UYVY; - case WG_VIDEO_FORMAT_YUY2: return GST_VIDEO_FORMAT_YUY2; - case WG_VIDEO_FORMAT_YV12: return GST_VIDEO_FORMAT_YV12; - case WG_VIDEO_FORMAT_YVYU: return GST_VIDEO_FORMAT_YVYU; +#define X(x, g, d, t) case WG_VIDEO_FORMAT_ ## x: return GST_VIDEO_FORMAT_ ## x; + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X default: return GST_VIDEO_FORMAT_UNKNOWN; } }
On 9/27/22 03:32, Rémi Bernon wrote:
+/* List all supported raw video formats, with their metadata.
- Each element should be X(wg, guid, depth, type), with:
- wg: suffix of the GStreamer constant, and enum wg_video_format value.
- guid: suffix of the corresponding MEDIASUBTYPE / MFVideoFormat guid.
- depth: the number of bits of each video sample.
- type: whether the video format is RGB or YUV.
- */
+#define FOR_EACH_WG_VIDEO_FORMAT(F) \
- F(BGRA, ARGB32, 32, RGB) \
- F(BGRx, RGB32, 32, RGB) \
- F(BGR, RGB24, 24, RGB) \
- F(RGB15, RGB555, 16, RGB) \
- F(RGB16, RGB565, 16, RGB) \
- F(AYUV, AYUV, 32, YUV) \
- F(I420, I420, 12, YUV) \
- F(NV12, NV12, 12, YUV) \
- F(UYVY, UYVY, 16, YUV) \
- F(YUY2, YUY2, 16, YUV) \
- F(YV12, YV12, 12, YUV) \
- F(YVYU, YVYU, 16, YUV) \
+enum wg_video_format +{
- WG_VIDEO_FORMAT_UNKNOWN = 0,
+#define X(x, g, d, t) WG_VIDEO_FORMAT_ ## x,
- FOR_EACH_WG_VIDEO_FORMAT(X)
+#undef X +};
I don't hate this, but I'm also less than thrilled about it.
One of the nice things about spelling things out explicitly is that it's easy for someone unfamiliar with the code to grep for constants to see how they're converted.
This also puts some burden on the reader to mentally preprocess the code first. It's probably not a big deal, since it's not difficult to understand what it's doing, but I'm not really sure it's worthwhile in this case.
On 9/28/22 16:13, Zebediah Figura wrote:
On 9/27/22 03:32, Rémi Bernon wrote:
+/* List all supported raw video formats, with their metadata.
- Each element should be X(wg, guid, depth, type), with:
- * wg: suffix of the GStreamer constant, and enum wg_video_format
value.
- * guid: suffix of the corresponding MEDIASUBTYPE / MFVideoFormat
guid.
- * depth: the number of bits of each video sample.
- * type: whether the video format is RGB or YUV.
- */
+#define FOR_EACH_WG_VIDEO_FORMAT(F) \ + F(BGRA, ARGB32, 32, RGB) \ + F(BGRx, RGB32, 32, RGB) \ + F(BGR, RGB24, 24, RGB) \ + F(RGB15, RGB555, 16, RGB) \ + F(RGB16, RGB565, 16, RGB) \ + F(AYUV, AYUV, 32, YUV) \ + F(I420, I420, 12, YUV) \ + F(NV12, NV12, 12, YUV) \ + F(UYVY, UYVY, 16, YUV) \ + F(YUY2, YUY2, 16, YUV) \ + F(YV12, YV12, 12, YUV) \ + F(YVYU, YVYU, 16, YUV) \
+enum wg_video_format +{ + WG_VIDEO_FORMAT_UNKNOWN = 0, +#define X(x, g, d, t) WG_VIDEO_FORMAT_ ## x, + FOR_EACH_WG_VIDEO_FORMAT(X) +#undef X +};
I don't hate this, but I'm also less than thrilled about it.
One of the nice things about spelling things out explicitly is that it's easy for someone unfamiliar with the code to grep for constants to see how they're converted.
This also puts some burden on the reader to mentally preprocess the code first. It's probably not a big deal, since it's not difficult to understand what it's doing, but I'm not really sure it's worthwhile in this case.
FWIW, I think the other patches in this series are fine (namely 2, 3, 4, 7). I don't easily see patch 1/7 as being an improvement if not required for this patch, but the renames seem like an improvement.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/mfplat.c | 9 +++----- dlls/winegstreamer/quartz_parser.c | 35 ++++++++++++++-------------- dlls/winegstreamer/unixlib.h | 37 ++++++++++++++++++++---------- dlls/winegstreamer/wg_format.c | 27 ++++++---------------- 4 files changed, 52 insertions(+), 56 deletions(-)
diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 634d3721788..49674c4fce7 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -384,12 +384,9 @@ static const struct } audio_formats[] = { - {&MFAudioFormat_PCM, 8, WG_AUDIO_FORMAT_U8}, - {&MFAudioFormat_PCM, 16, WG_AUDIO_FORMAT_S16LE}, - {&MFAudioFormat_PCM, 24, WG_AUDIO_FORMAT_S24LE}, - {&MFAudioFormat_PCM, 32, WG_AUDIO_FORMAT_S32LE}, - {&MFAudioFormat_Float, 32, WG_AUDIO_FORMAT_F32LE}, - {&MFAudioFormat_Float, 64, WG_AUDIO_FORMAT_F64LE}, +#define X(x, g, d) {&MFAudioFormat_ ## g, d, WG_AUDIO_FORMAT_ ## x}, + FOR_EACH_WG_AUDIO_FORMAT(X) +#undef X };
static inline UINT64 make_uint64(UINT32 high, UINT32 low) diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 3816895387f..3cb08376dc2 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -106,12 +106,13 @@ static bool wg_audio_format_is_float(enum wg_audio_format format) switch (format) { case WG_AUDIO_FORMAT_UNKNOWN: return false; - case WG_AUDIO_FORMAT_U8: return false; - case WG_AUDIO_FORMAT_S16LE: return false; - case WG_AUDIO_FORMAT_S24LE: return false; - case WG_AUDIO_FORMAT_S32LE: return false; - case WG_AUDIO_FORMAT_F32LE: return true; - case WG_AUDIO_FORMAT_F64LE: return true; +#define X_PCM false +#define X_Float true +#define X(x, g, d) case WG_AUDIO_FORMAT_ ## x: return X_ ## g; + FOR_EACH_WG_AUDIO_FORMAT(X) +#undef X +#undef X_Float +#undef X_PCM }
assert(0); @@ -122,13 +123,10 @@ static WORD wg_audio_format_get_depth(enum wg_audio_format format) { switch (format) { +#define X(x, g, d) case WG_AUDIO_FORMAT_ ## x: return d; + FOR_EACH_WG_AUDIO_FORMAT(X) +#undef X case WG_AUDIO_FORMAT_UNKNOWN: return 0; - case WG_AUDIO_FORMAT_U8: return 8; - case WG_AUDIO_FORMAT_S16LE: return 16; - case WG_AUDIO_FORMAT_S24LE: return 24; - case WG_AUDIO_FORMAT_S32LE: return 32; - case WG_AUDIO_FORMAT_F32LE: return 32; - case WG_AUDIO_FORMAT_F64LE: return 64; }
assert(0); @@ -540,12 +538,13 @@ static bool amt_to_wg_format_audio(const AM_MEDIA_TYPE *mt, struct wg_format *fo } format_map[] = { - {&MEDIASUBTYPE_PCM, 8, WG_AUDIO_FORMAT_U8}, - {&MEDIASUBTYPE_PCM, 16, WG_AUDIO_FORMAT_S16LE}, - {&MEDIASUBTYPE_PCM, 24, WG_AUDIO_FORMAT_S24LE}, - {&MEDIASUBTYPE_PCM, 32, WG_AUDIO_FORMAT_S32LE}, - {&MEDIASUBTYPE_IEEE_FLOAT, 32, WG_AUDIO_FORMAT_F32LE}, - {&MEDIASUBTYPE_IEEE_FLOAT, 64, WG_AUDIO_FORMAT_F64LE}, +#define X_PCM MEDIASUBTYPE_PCM +#define X_Float MEDIASUBTYPE_IEEE_FLOAT +#define X(x, g, d) {&X_ ## g, d, WG_AUDIO_FORMAT_ ## x}, + FOR_EACH_WG_AUDIO_FORMAT(X) +#undef X +#undef X_Float +#undef X_PCM };
const WAVEFORMATEX *audio_format = (const WAVEFORMATEX *)mt->pbFormat; diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index f91fb986322..a8c94852fc7 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -30,6 +30,30 @@
#include "wine/unixlib.h"
+/* List all supported raw audio formats, with their metadata. + * + * Each element should be X(wg, guid, depth), with: + * wg: suffix of the GStreamer constant, and enum wg_video_format value. + * guid: suffix of the corresponding MEDIASUBTYPE / MFAudioFormat guid. + * depth: the number of bits of each audio sample. + * + */ +#define FOR_EACH_WG_AUDIO_FORMAT(F) \ + F(U8, PCM, 8) \ + F(S16LE, PCM, 16) \ + F(S24LE, PCM, 24) \ + F(S32LE, PCM, 32) \ + F(F32LE, Float, 32) \ + F(F64LE, Float, 64) \ + +enum wg_audio_format +{ + WG_AUDIO_FORMAT_UNKNOWN = 0, +#define X(x, g, d) WG_AUDIO_FORMAT_ ## x, + FOR_EACH_WG_AUDIO_FORMAT(X) +#undef X +}; + /* List all supported raw video formats, with their metadata. * * Each element should be X(wg, guid, depth, type), with: @@ -78,18 +102,7 @@ struct wg_format { struct { - enum wg_audio_format - { - WG_AUDIO_FORMAT_UNKNOWN, - - WG_AUDIO_FORMAT_U8, - WG_AUDIO_FORMAT_S16LE, - WG_AUDIO_FORMAT_S24LE, - WG_AUDIO_FORMAT_S32LE, - WG_AUDIO_FORMAT_F32LE, - WG_AUDIO_FORMAT_F64LE, - } format; - + enum wg_audio_format format; uint32_t channels; uint32_t channel_mask; /* In WinMM format. */ uint32_t rate; diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c index 50c5d1ba256..1b83f7b86a8 100644 --- a/dlls/winegstreamer/wg_format.c +++ b/dlls/winegstreamer/wg_format.c @@ -47,20 +47,10 @@ static enum wg_audio_format wg_audio_format_from_gst(GstAudioFormat format) { switch (format) { - case GST_AUDIO_FORMAT_U8: - return WG_AUDIO_FORMAT_U8; - case GST_AUDIO_FORMAT_S16LE: - return WG_AUDIO_FORMAT_S16LE; - case GST_AUDIO_FORMAT_S24LE: - return WG_AUDIO_FORMAT_S24LE; - case GST_AUDIO_FORMAT_S32LE: - return WG_AUDIO_FORMAT_S32LE; - case GST_AUDIO_FORMAT_F32LE: - return WG_AUDIO_FORMAT_F32LE; - case GST_AUDIO_FORMAT_F64LE: - return WG_AUDIO_FORMAT_F64LE; - default: - return WG_AUDIO_FORMAT_UNKNOWN; +#define X(x, g, d) case GST_AUDIO_FORMAT_ ## x: return WG_AUDIO_FORMAT_ ## x; + FOR_EACH_WG_AUDIO_FORMAT(X) +#undef X + default: return WG_AUDIO_FORMAT_UNKNOWN; } }
@@ -252,12 +242,9 @@ static GstAudioFormat wg_audio_format_to_gst(enum wg_audio_format format) { switch (format) { - case WG_AUDIO_FORMAT_U8: return GST_AUDIO_FORMAT_U8; - case WG_AUDIO_FORMAT_S16LE: return GST_AUDIO_FORMAT_S16LE; - case WG_AUDIO_FORMAT_S24LE: return GST_AUDIO_FORMAT_S24LE; - case WG_AUDIO_FORMAT_S32LE: return GST_AUDIO_FORMAT_S32LE; - case WG_AUDIO_FORMAT_F32LE: return GST_AUDIO_FORMAT_F32LE; - case WG_AUDIO_FORMAT_F64LE: return GST_AUDIO_FORMAT_F64LE; +#define X(x, g, d) case WG_AUDIO_FORMAT_ ## x: return GST_AUDIO_FORMAT_ ## x; + FOR_EACH_WG_AUDIO_FORMAT(X) +#undef X default: return GST_AUDIO_FORMAT_UNKNOWN; } }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/unixlib.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index a8c94852fc7..3283b3aa305 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -89,13 +89,13 @@ struct wg_format { enum wg_major_type { - WG_MAJOR_TYPE_UNKNOWN, - WG_MAJOR_TYPE_VIDEO, - WG_MAJOR_TYPE_VIDEO_CINEPAK, - WG_MAJOR_TYPE_VIDEO_H264, + WG_MAJOR_TYPE_UNKNOWN = 0, WG_MAJOR_TYPE_AUDIO, WG_MAJOR_TYPE_AUDIO_MPEG1, WG_MAJOR_TYPE_AUDIO_WMA, + WG_MAJOR_TYPE_VIDEO, + WG_MAJOR_TYPE_VIDEO_CINEPAK, + WG_MAJOR_TYPE_VIDEO_H264, } major_type;
union
On Wed Sep 28 21:13:10 2022 +0000, **** wrote:
Zebediah Figura replied on the mailing list:
On 9/27/22 03:32, Rémi Bernon wrote: > +/* List all supported raw video formats, with their metadata. > + * > + * Each element should be X(wg, guid, depth, type), with: > + * wg: suffix of the GStreamer constant, and enum wg_video_format value. > + * guid: suffix of the corresponding MEDIASUBTYPE / MFVideoFormat guid. > + * depth: the number of bits of each video sample. > + * type: whether the video format is RGB or YUV. > + * > + */ > +#define FOR_EACH_WG_VIDEO_FORMAT(F) \ > + F(BGRA, ARGB32, 32, RGB) \ > + F(BGRx, RGB32, 32, RGB) \ > + F(BGR, RGB24, 24, RGB) \ > + F(RGB15, RGB555, 16, RGB) \ > + F(RGB16, RGB565, 16, RGB) \ > + F(AYUV, AYUV, 32, YUV) \ > + F(I420, I420, 12, YUV) \ > + F(NV12, NV12, 12, YUV) \ > + F(UYVY, UYVY, 16, YUV) \ > + F(YUY2, YUY2, 16, YUV) \ > + F(YV12, YV12, 12, YUV) \ > + F(YVYU, YVYU, 16, YUV) \ > + > +enum wg_video_format > +{ > + WG_VIDEO_FORMAT_UNKNOWN = 0, > +#define X(x, g, d, t) WG_VIDEO_FORMAT_ ## x, > + FOR_EACH_WG_VIDEO_FORMAT(X) > +#undef X > +}; I don't hate this, but I'm also less than thrilled about it. One of the nice things about spelling things out explicitly is that it's easy for someone unfamiliar with the code to grep for constants to see how they're converted. This also puts some burden on the reader to mentally preprocess the code first. It's probably not a big deal, since it's not difficult to understand what it's doing, but I'm not really sure it's worthwhile in this case.
In my opinion the advantages of generating all these arrays from the same macro outweight the drawbacks, especially when the mappings are spread out like that in several files, converting the wg_format to multiple formats back and forth.
When there's a switch on the enum the compiler will catch missing values but with the arrays it's very easy to miss one, and hard to validate that all the values are handled, and in a consistent way with the other mappings elsewhere.
To allow grepping the names, instead of just keeping the prefix it could use the full wg name, and keep the gst suffix, guid, etc... Though imho it gets a bit too verbose and not very necessary (like I agree you can't grep for the enum values but it's always easy to get to the enum declaration and lookup how it generates the value, or grep for the macro usage).
On Wed Sep 28 21:32:17 2022 +0000, Rémi Bernon wrote:
In my opinion the advantages of generating all these arrays from the same macro outweight the drawbacks, especially when the mappings are spread out like that in several files, converting the wg_format to multiple formats back and forth. When there's a switch on the enum the compiler will catch missing values but with the arrays it's very easy to miss one, and hard to validate that all the values are handled, and in a consistent way with the other mappings elsewhere. To allow grepping the names, instead of just keeping the prefix it could use the full wg name, and keep the gst suffix, guid, etc... Though imho it gets a bit too verbose and not very necessary (like I agree you can't grep for the enum values but it's always easy to get to the enum declaration and lookup how it generates the value, or grep for the macro usage).
For instance, it could look like that instead.
```c /* List all supported raw audio formats, with their metadata. * * Each element should be X(wg, gst, guid, depth), with: * wg: the enum wg_video_format value. * gst: corresponding GStreamer constant. * guid: suffix of the corresponding MEDIASUBTYPE / MFAudioFormat guid. * depth: the number of bits of each audio sample. * */ #define FOR_EACH_WG_AUDIO_FORMAT(F) \ F(WG_AUDIO_FORMAT_U8, GST_AUDIO_FORMAT_U8, PCM, 8) \ F(WG_AUDIO_FORMAT_S16LE, GST_AUDIO_FORMAT_S16LE, PCM, 16) \ F(WG_AUDIO_FORMAT_S24LE, GST_AUDIO_FORMAT_S24LE, PCM, 24) \ F(WG_AUDIO_FORMAT_S32LE, GST_AUDIO_FORMAT_S32LE, PCM, 32) \ F(WG_AUDIO_FORMAT_F32LE, GST_AUDIO_FORMAT_F32LE, Float, 32) \ F(WG_AUDIO_FORMAT_F64LE, GST_AUDIO_FORMAT_F64LE, Float, 64) \
enum wg_audio_format { WG_AUDIO_FORMAT_UNKNOWN = 0, #define X(wg, gst, guid, depth) wg, FOR_EACH_WG_AUDIO_FORMAT(X) #undef X };
/* List all supported raw video formats, with their metadata. * * Each element should be X(wg, gst, guid, depth, type), with: * wg: the enum wg_video_format value. * gst: corresponding GStreamer constant. * guid: suffix of the corresponding MEDIASUBTYPE / MFVideoFormat guid. * depth: the number of bits of each video sample. * type: whether the video format is RGB or YUV. * */ #define FOR_EACH_WG_VIDEO_FORMAT(F) \ F(WG_VIDEO_FORMAT_BGRA, GST_VIDEO_FORMAT_BGRA, ARGB32, 32, RGB) \ F(WG_VIDEO_FORMAT_BGRx, GST_VIDEO_FORMAT_BGRx, RGB32, 32, RGB) \ F(WG_VIDEO_FORMAT_BGR, GST_VIDEO_FORMAT_BGR, RGB24, 24, RGB) \ F(WG_VIDEO_FORMAT_RGBA, GST_VIDEO_FORMAT_RGBA, ABGR32, 32, RGB) \ F(WG_VIDEO_FORMAT_RGB15, GST_VIDEO_FORMAT_RGB15, RGB555, 16, RGB) \ F(WG_VIDEO_FORMAT_RGB16, GST_VIDEO_FORMAT_RGB16, RGB565, 16, RGB) \ F(WG_VIDEO_FORMAT_AYUV, GST_VIDEO_FORMAT_AYUV, AYUV, 32, YUV) \ F(WG_VIDEO_FORMAT_I420, GST_VIDEO_FORMAT_I420, I420, 12, YUV) \ F(WG_VIDEO_FORMAT_NV12, GST_VIDEO_FORMAT_NV12, NV12, 12, YUV) \ F(WG_VIDEO_FORMAT_UYVY, GST_VIDEO_FORMAT_UYVY, UYVY, 16, YUV) \ F(WG_VIDEO_FORMAT_YUY2, GST_VIDEO_FORMAT_YUY2, YUY2, 16, YUV) \ F(WG_VIDEO_FORMAT_YV12, GST_VIDEO_FORMAT_YV12, YV12, 12, YUV) \ F(WG_VIDEO_FORMAT_YVYU, GST_VIDEO_FORMAT_YVYU, YVYU, 16, YUV) \
enum wg_video_format { WG_VIDEO_FORMAT_UNKNOWN = 0, #define X(wg, gst, guid, depth, type) wg, FOR_EACH_WG_VIDEO_FORMAT(X) #undef X }; ```