Commit 6e90dff6 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

winegstreamer: Merge video_wmv into video field.

parent 654dc115
......@@ -651,14 +651,7 @@ bool wg_video_format_is_rgb(enum wg_video_format format)
case WG_VIDEO_FORMAT_RGB16:
return true;
case WG_VIDEO_FORMAT_AYUV:
case WG_VIDEO_FORMAT_I420:
case WG_VIDEO_FORMAT_NV12:
case WG_VIDEO_FORMAT_UYVY:
case WG_VIDEO_FORMAT_YUY2:
case WG_VIDEO_FORMAT_YV12:
case WG_VIDEO_FORMAT_YVYU:
case WG_VIDEO_FORMAT_UNKNOWN:
default:
break;
}
......
......@@ -370,8 +370,8 @@ static unsigned int wg_format_get_max_size_video_raw(enum wg_video_format format
return ALIGN(width, 4) * ALIGN(height, 2) /* Y plane */
+ ALIGN(width, 4) * ((height + 1) / 2); /* U/V plane */
case WG_VIDEO_FORMAT_UNKNOWN:
FIXME("Cannot guess maximum sample size for unknown video format.\n");
default:
FIXME("Cannot guess maximum sample size for video format %d.\n", format);
return 0;
}
......@@ -402,7 +402,7 @@ unsigned int wg_format_get_max_size(const struct wg_format *format)
case WG_MAJOR_TYPE_VIDEO_WMV:
return wg_format_get_max_size_video_raw(WG_VIDEO_FORMAT_YV12,
format->u.video_wmv.width, format->u.video_wmv.height);
format->u.video.width, format->u.video.height);
case WG_MAJOR_TYPE_AUDIO:
{
......@@ -488,6 +488,11 @@ 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_WMV1: return &MEDIASUBTYPE_WMV1;
case WG_VIDEO_FORMAT_WMV2: return &MEDIASUBTYPE_WMV2;
case WG_VIDEO_FORMAT_WMV3: return &MEDIASUBTYPE_WMV3;
case WG_VIDEO_FORMAT_WMVA: return &MEDIASUBTYPE_WMVA;
case WG_VIDEO_FORMAT_WVC1: return &MEDIASUBTYPE_WVC1;
}
assert(0);
......@@ -511,10 +516,10 @@ 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');
default:
ERR("Cannot get compression for video format %d.", format);
return 0;
}
assert(0);
return 0;
}
static WORD wg_video_format_get_depth(enum wg_video_format format)
......@@ -534,10 +539,10 @@ 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;
default:
ERR("Cannot get depth for video format %d.", format);
return 0;
}
assert(0);
return 0;
}
static bool amt_from_wg_format_video(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool wm)
......@@ -628,29 +633,29 @@ static bool amt_from_wg_format_video_wmv(AM_MEDIA_TYPE *mt, const struct wg_form
uint32_t frame_time;
const GUID *subtype;
switch (format->u.video_wmv.format)
switch (format->u.video.format)
{
case WG_WMV_VIDEO_FORMAT_WMV1:
case WG_VIDEO_FORMAT_WMV1:
subtype = &MEDIASUBTYPE_WMV1;
break;
case WG_WMV_VIDEO_FORMAT_WMV2:
case WG_VIDEO_FORMAT_WMV2:
subtype = &MEDIASUBTYPE_WMV2;
break;
case WG_WMV_VIDEO_FORMAT_WMV3:
case WG_VIDEO_FORMAT_WMV3:
subtype = &MEDIASUBTYPE_WMV3;
break;
case WG_WMV_VIDEO_FORMAT_WMVA:
case WG_VIDEO_FORMAT_WMVA:
subtype = &MEDIASUBTYPE_WMVA;
break;
case WG_WMV_VIDEO_FORMAT_WVC1:
case WG_VIDEO_FORMAT_WVC1:
subtype = &MEDIASUBTYPE_WVC1;
break;
default:
WARN("Invalid WMV format %u.\n", format->u.video_wmv.format);
WARN("Invalid WMV format %u.\n", format->u.video.format);
return false;
}
if (!(video_format = CoTaskMemAlloc(sizeof(*video_format) + format->u.video_wmv.codec_data_len)))
if (!(video_format = CoTaskMemAlloc(sizeof(*video_format) + format->u.video.codec_data_len)))
return false;
mt->majortype = MEDIATYPE_Video;
......@@ -659,22 +664,22 @@ static bool amt_from_wg_format_video_wmv(AM_MEDIA_TYPE *mt, const struct wg_form
mt->bTemporalCompression = TRUE;
mt->lSampleSize = 0;
mt->formattype = FORMAT_VideoInfo;
mt->cbFormat = sizeof(*video_format) + format->u.video_wmv.codec_data_len;
mt->cbFormat = sizeof(*video_format) + format->u.video.codec_data_len;
mt->pbFormat = (BYTE *)video_format;
memset(video_format, 0, sizeof(*video_format));
SetRect(&video_format->rcSource, 0, 0, format->u.video_wmv.width, format->u.video_wmv.height);
SetRect(&video_format->rcSource, 0, 0, format->u.video.width, format->u.video.height);
video_format->rcTarget = video_format->rcSource;
if ((frame_time = MulDiv(10000000, format->u.video_wmv.fps_d, format->u.video_wmv.fps_n)) != -1)
if ((frame_time = MulDiv(10000000, format->u.video.fps_d, format->u.video.fps_n)) != -1)
video_format->AvgTimePerFrame = frame_time;
video_format->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + format->u.video_wmv.codec_data_len;
video_format->bmiHeader.biWidth = format->u.video_wmv.width;
video_format->bmiHeader.biHeight = format->u.video_wmv.height;
video_format->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + format->u.video.codec_data_len;
video_format->bmiHeader.biWidth = format->u.video.width;
video_format->bmiHeader.biHeight = format->u.video.height;
video_format->bmiHeader.biPlanes = 1;
video_format->bmiHeader.biCompression = mt->subtype.Data1;
video_format->bmiHeader.biBitCount = 24;
video_format->dwBitRate = 0;
memcpy(video_format+1, format->u.video_wmv.codec_data, format->u.video_wmv.codec_data_len);
memcpy(video_format+1, format->u.video.codec_data, format->u.video.codec_data_len);
return true;
}
......@@ -985,31 +990,31 @@ static bool amt_to_wg_format_video_wmv(const AM_MEDIA_TYPE *mt, struct wg_format
}
format->major_type = WG_MAJOR_TYPE_VIDEO_WMV;
format->u.video_wmv.width = video_format->bmiHeader.biWidth;
format->u.video_wmv.height = video_format->bmiHeader.biHeight;
format->u.video_wmv.fps_n = 10000000;
format->u.video_wmv.fps_d = video_format->AvgTimePerFrame;
format->u.video.width = video_format->bmiHeader.biWidth;
format->u.video.height = video_format->bmiHeader.biHeight;
format->u.video.fps_n = 10000000;
format->u.video.fps_d = video_format->AvgTimePerFrame;
if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WMV1))
format->u.video_wmv.format = WG_WMV_VIDEO_FORMAT_WMV1;
format->u.video.format = WG_VIDEO_FORMAT_WMV1;
else if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WMV2))
format->u.video_wmv.format = WG_WMV_VIDEO_FORMAT_WMV2;
format->u.video.format = WG_VIDEO_FORMAT_WMV2;
else if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WMV3))
format->u.video_wmv.format = WG_WMV_VIDEO_FORMAT_WMV3;
format->u.video.format = WG_VIDEO_FORMAT_WMV3;
else if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WMVA))
format->u.video_wmv.format = WG_WMV_VIDEO_FORMAT_WMVA;
format->u.video.format = WG_VIDEO_FORMAT_WMVA;
else if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_WVC1))
format->u.video_wmv.format = WG_WMV_VIDEO_FORMAT_WVC1;
format->u.video.format = WG_VIDEO_FORMAT_WVC1;
else
format->u.video_wmv.format = WG_WMV_VIDEO_FORMAT_UNKNOWN;
format->u.video.format = WG_VIDEO_FORMAT_UNKNOWN;
format->u.video_wmv.codec_data_len = mt->cbFormat - sizeof(VIDEOINFOHEADER);
if (format->u.video_wmv.codec_data_len > sizeof(format->u.video_wmv.codec_data))
format->u.video.codec_data_len = mt->cbFormat - sizeof(VIDEOINFOHEADER);
if (format->u.video.codec_data_len > sizeof(format->u.video.codec_data))
{
ERR("Too big codec_data value (%u).\n", format->u.video_wmv.codec_data_len);
format->u.video_wmv.codec_data_len = 0;
ERR("Too big codec_data value (%u).\n", format->u.video.codec_data_len);
format->u.video.codec_data_len = 0;
}
memcpy(format->u.video_wmv.codec_data, video_format+1, format->u.video_wmv.codec_data_len);
memcpy(format->u.video.codec_data, video_format+1, format->u.video.codec_data_len);
return true;
}
......
......@@ -76,17 +76,12 @@ enum wg_video_format
WG_VIDEO_FORMAT_YUY2,
WG_VIDEO_FORMAT_YV12,
WG_VIDEO_FORMAT_YVYU,
};
typedef UINT32 wg_wmv_video_format;
enum wg_wmv_video_format
{
WG_WMV_VIDEO_FORMAT_UNKNOWN,
WG_WMV_VIDEO_FORMAT_WMV1,
WG_WMV_VIDEO_FORMAT_WMV2,
WG_WMV_VIDEO_FORMAT_WMV3,
WG_WMV_VIDEO_FORMAT_WMVA,
WG_WMV_VIDEO_FORMAT_WVC1,
WG_VIDEO_FORMAT_WMV1,
WG_VIDEO_FORMAT_WMV2,
WG_VIDEO_FORMAT_WMV3,
WG_VIDEO_FORMAT_WMVA,
WG_VIDEO_FORMAT_WVC1,
};
struct wg_format
......@@ -123,7 +118,8 @@ struct wg_format
*
* Uncompressed(RGB and YUV): width, height, fps_n, fps_d, padding.
* CINEPAK: width, height, fps_n, fps_d.
* H264: width, height, fps_n, fps_d, profile, level, codec_data_len, codec_data. */
* H264: width, height, fps_n, fps_d, profile, level, codec_data_len, codec_data.
* WMV: width, height, fps_n, fps_d, codec_data_len, codec_data. */
struct
{
wg_video_format format;
......@@ -140,14 +136,6 @@ struct wg_format
} video;
struct
{
wg_wmv_video_format format;
int32_t width, height;
uint32_t fps_n, fps_d;
uint32_t codec_data_len;
unsigned char codec_data[64];
} video_wmv;
struct
{
int32_t width, height;
uint32_t fps_n, fps_d;
uint32_t version;
......
......@@ -298,8 +298,8 @@ static void wg_format_from_caps_video_wmv(struct wg_format *format, const GstCap
const GstStructure *structure = gst_caps_get_structure(caps, 0);
gint width, height, fps_n, fps_d, wmv_version = 0;
gchar format_buffer[5] = {'W','M','V','0',0};
enum wg_wmv_video_format wmv_format;
const gchar *wmv_format_str = NULL;
enum wg_video_format video_format;
const GValue *codec_data_value;
GstBuffer *codec_data;
GstMapInfo map;
......@@ -323,17 +323,17 @@ static void wg_format_from_caps_video_wmv(struct wg_format *format, const GstCap
wmv_format_str = format_buffer;
}
if (!strcmp(wmv_format_str, "WMV1"))
wmv_format = WG_WMV_VIDEO_FORMAT_WMV1;
video_format = WG_VIDEO_FORMAT_WMV1;
else if (!strcmp(wmv_format_str, "WMV2"))
wmv_format = WG_WMV_VIDEO_FORMAT_WMV2;
video_format = WG_VIDEO_FORMAT_WMV2;
else if (!strcmp(wmv_format_str, "WMV3"))
wmv_format = WG_WMV_VIDEO_FORMAT_WMV3;
video_format = WG_VIDEO_FORMAT_WMV3;
else if (!strcmp(wmv_format_str, "WMVA"))
wmv_format = WG_WMV_VIDEO_FORMAT_WMVA;
video_format = WG_VIDEO_FORMAT_WMVA;
else if (!strcmp(wmv_format_str, "WVC1"))
wmv_format = WG_WMV_VIDEO_FORMAT_WVC1;
video_format = WG_VIDEO_FORMAT_WVC1;
else
wmv_format = WG_WMV_VIDEO_FORMAT_UNKNOWN;
video_format = WG_VIDEO_FORMAT_UNKNOWN;
if (!gst_structure_get_fraction(structure, "framerate", &fps_n, &fps_d))
{
......@@ -342,19 +342,19 @@ static void wg_format_from_caps_video_wmv(struct wg_format *format, const GstCap
}
format->major_type = WG_MAJOR_TYPE_VIDEO_WMV;
format->u.video_wmv.width = width;
format->u.video_wmv.height = height;
format->u.video_wmv.format = wmv_format;
format->u.video_wmv.fps_n = fps_n;
format->u.video_wmv.fps_d = fps_d;
format->u.video.width = width;
format->u.video.height = height;
format->u.video.format = video_format;
format->u.video.fps_n = fps_n;
format->u.video.fps_d = fps_d;
if ((codec_data_value = gst_structure_get_value(structure, "codec_data")) && (codec_data = gst_value_get_buffer(codec_data_value)))
{
gst_buffer_map(codec_data, &map, GST_MAP_READ);
if (map.size <= sizeof(format->u.video_wmv.codec_data))
if (map.size <= sizeof(format->u.video.codec_data))
{
format->u.video_wmv.codec_data_len = map.size;
memcpy(format->u.video_wmv.codec_data, map.data, map.size);
format->u.video.codec_data_len = map.size;
memcpy(format->u.video.codec_data, map.data, map.size);
}
else
GST_WARNING("Too big codec_data value (%u) in %" GST_PTR_FORMAT ".", (UINT)map.size, caps);
......@@ -757,32 +757,32 @@ static GstCaps *wg_format_to_caps_video_wmv(const struct wg_format *format)
if (!(caps = gst_caps_new_empty_simple("video/x-wmv")))
return NULL;
switch (format->u.video_wmv.format)
switch (format->u.video.format)
{
case WG_WMV_VIDEO_FORMAT_WMV1:
case WG_VIDEO_FORMAT_WMV1:
wmv_format = "WMV1";
wmv_version = 1;
break;
case WG_WMV_VIDEO_FORMAT_WMV2:
case WG_VIDEO_FORMAT_WMV2:
wmv_format = "WMV2";
wmv_version = 2;
break;
case WG_WMV_VIDEO_FORMAT_WMV3:
case WG_VIDEO_FORMAT_WMV3:
wmv_format = "WMV3";
wmv_version = 3;
break;
case WG_WMV_VIDEO_FORMAT_WMVA:
case WG_VIDEO_FORMAT_WMVA:
wmv_format = "WMVA";
wmv_version = 3;
break;
case WG_WMV_VIDEO_FORMAT_WVC1:
case WG_VIDEO_FORMAT_WVC1:
wmv_format = "WVC1";
wmv_version = 3;
break;
default:
GST_WARNING("Unknown WMV format %u.", format->u.video_wmv.format);
GST_WARNING("Unknown WMV format %u.", format->u.video.format);
/* fallthrough */
case WG_WMV_VIDEO_FORMAT_UNKNOWN:
case WG_VIDEO_FORMAT_UNKNOWN:
wmv_format = NULL;
wmv_version = 0;
break;
......@@ -792,22 +792,22 @@ static GstCaps *wg_format_to_caps_video_wmv(const struct wg_format *format)
gst_caps_set_simple(caps, "format", G_TYPE_STRING, wmv_format, NULL);
if (wmv_version)
gst_caps_set_simple(caps, "wmvversion", G_TYPE_INT, wmv_version, NULL);
if (format->u.video_wmv.width)
gst_caps_set_simple(caps, "width", G_TYPE_INT, format->u.video_wmv.width, NULL);
if (format->u.video_wmv.height)
gst_caps_set_simple(caps, "height", G_TYPE_INT, format->u.video_wmv.height, NULL);
if (format->u.video_wmv.fps_d || format->u.video_wmv.fps_n)
gst_caps_set_simple(caps, "framerate", GST_TYPE_FRACTION, format->u.video_wmv.fps_n, format->u.video_wmv.fps_d, NULL);
if (format->u.video.width)
gst_caps_set_simple(caps, "width", G_TYPE_INT, format->u.video.width, NULL);
if (format->u.video.height)
gst_caps_set_simple(caps, "height", G_TYPE_INT, format->u.video.height, NULL);
if (format->u.video.fps_d || format->u.video.fps_n)
gst_caps_set_simple(caps, "framerate", GST_TYPE_FRACTION, format->u.video.fps_n, format->u.video.fps_d, NULL);
if (format->u.video_wmv.codec_data_len)
if (format->u.video.codec_data_len)
{
if (!(buffer = gst_buffer_new_and_alloc(format->u.video_wmv.codec_data_len)))
if (!(buffer = gst_buffer_new_and_alloc(format->u.video.codec_data_len)))
{
gst_caps_unref(caps);
return NULL;
}
gst_buffer_fill(buffer, 0, format->u.video_wmv.codec_data, format->u.video_wmv.codec_data_len);
gst_buffer_fill(buffer, 0, format->u.video.codec_data, format->u.video.codec_data_len);
gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
gst_buffer_unref(buffer);
}
......@@ -921,9 +921,9 @@ bool wg_format_compare(const struct wg_format *a, const struct wg_format *b)
case WG_MAJOR_TYPE_VIDEO_WMV:
/* Do not compare FPS. */
return a->u.video_wmv.format == b->u.video_wmv.format
&& a->u.video_wmv.width == b->u.video_wmv.width
&& a->u.video_wmv.height == b->u.video_wmv.height;
return a->u.video.format == b->u.video.format
&& a->u.video.width == b->u.video.width
&& a->u.video.height == b->u.video.height;
}
assert(0);
......
......@@ -358,21 +358,21 @@ static GstCaps *transform_get_parsed_caps(struct wg_format *format, const char *
gst_caps_set_simple(parsed_caps, "parsed", G_TYPE_BOOLEAN, true, "mpegversion", G_TYPE_INT, 1, NULL);
break;
case WG_MAJOR_TYPE_VIDEO_WMV:
switch (format->u.video_wmv.format)
switch (format->u.video.format)
{
case WG_WMV_VIDEO_FORMAT_WMV1:
case WG_VIDEO_FORMAT_WMV1:
gst_caps_set_simple(parsed_caps, "wmvversion", G_TYPE_INT, 1, NULL);
break;
case WG_WMV_VIDEO_FORMAT_WMV2:
case WG_VIDEO_FORMAT_WMV2:
gst_caps_set_simple(parsed_caps, "wmvversion", G_TYPE_INT, 2, NULL);
break;
case WG_WMV_VIDEO_FORMAT_WMV3:
case WG_WMV_VIDEO_FORMAT_WMVA:
case WG_WMV_VIDEO_FORMAT_WVC1:
case WG_VIDEO_FORMAT_WMV3:
case WG_VIDEO_FORMAT_WMVA:
case WG_VIDEO_FORMAT_WVC1:
gst_caps_set_simple(parsed_caps, "wmvversion", G_TYPE_INT, 3, NULL);
break;
default:
GST_WARNING("Unknown WMV format %u.", format->u.video_wmv.format);
GST_WARNING("Unknown WMV format %u.", format->u.video.format);
break;
}
break;
......
......@@ -445,8 +445,8 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde
if (!wg_format_is_set(&decoder->input_format))
return DMO_E_TYPE_NOT_SET;
width = decoder->input_format.u.video_wmv.width;
height = abs(decoder->input_format.u.video_wmv.height);
width = decoder->input_format.u.video.width;
height = abs(decoder->input_format.u.video.height);
subtype = wmv_decoder_output_types[type_index].subtype;
if (FAILED(hr = MFCalculateImageSize(subtype, width, height, &image_size)))
{
......@@ -470,8 +470,8 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde
info->rcSource.bottom = height;
info->rcTarget.right = width;
info->rcTarget.bottom = height;
info->AvgTimePerFrame = MulDiv(10000000, decoder->input_format.u.video_wmv.fps_d,
decoder->input_format.u.video_wmv.fps_n);
info->AvgTimePerFrame = MulDiv(10000000, decoder->input_format.u.video.fps_d,
decoder->input_format.u.video.fps_n);
info->bmiHeader.biSize = sizeof(info->bmiHeader);
info->bmiHeader.biWidth = width;
info->bmiHeader.biHeight = height;
......@@ -881,7 +881,7 @@ HRESULT wmv_decoder_create(IUnknown *outer, IUnknown **out)
static const struct wg_format input_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO_WMV,
.u.video_wmv.format = WG_WMV_VIDEO_FORMAT_WMV3,
.u.video.format = WG_VIDEO_FORMAT_WMV3,
};
static const struct wg_format output_format =
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment