Skip to content

Commit

Permalink
winegstreamer: Pass H264 codec data as "streamheader" when it's not p…
Browse files Browse the repository at this point in the history
…arsed yet.

CW-Bug-Id: #20833
  • Loading branch information
rbernon committed Sep 18, 2024
1 parent 25d9470 commit a799ca6
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions dlls/winegstreamer/wg_media_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,23 @@ DEFINE_MEDIATYPE_GUID(MFVideoFormat_IV50,MAKEFOURCC('I','V','5','0'));
DEFINE_MEDIATYPE_GUID(MFVideoFormat_VC1S,MAKEFOURCC('V','C','1','S'));
DEFINE_MEDIATYPE_GUID(MFVideoFormat_ABGR32,D3DFMT_A8B8G8R8);

static void init_caps_codec_data(GstCaps *caps, const void *codec_data, int codec_data_size)
static void init_caps_codec_data_name(GstCaps *caps, const void *codec_data, int codec_data_size, const char *name)
{
GstBuffer *buffer;

if (codec_data_size > 0 && (buffer = gst_buffer_new_and_alloc(codec_data_size)))
{
gst_buffer_fill(buffer, 0, codec_data, codec_data_size);
gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
gst_caps_set_simple(caps, name, GST_TYPE_BUFFER, buffer, NULL);
gst_buffer_unref(buffer);
}
}

static void init_caps_codec_data(GstCaps *caps, const void *codec_data, int codec_data_size)
{
init_caps_codec_data_name(caps, codec_data, codec_data_size, "codec_data");
}

static void init_caps_from_wave_format_mpeg1(GstCaps *caps, const MPEG1WAVEFORMAT *format, UINT32 format_size)
{
init_caps_codec_data(caps, &format->wfx + 1, format->wfx.cbSize);
Expand Down Expand Up @@ -298,11 +303,18 @@ static void init_caps_from_video_cinepak(GstCaps *caps, const MFVIDEOFORMAT *for

static void init_caps_from_video_h264(GstCaps *caps, const MFVIDEOFORMAT *format, UINT format_size)
{
init_caps_codec_data(caps, format + 1, format_size - sizeof(*format));

gst_structure_remove_field(gst_caps_get_structure(caps, 0), "format");
gst_structure_set_name(gst_caps_get_structure(caps, 0), "video/x-h264");
gst_caps_set_simple(caps, "stream-format", G_TYPE_STRING, format_size - sizeof(*format) ? "avc" : "byte-stream", NULL);
if (format_size - sizeof(*format) >= sizeof(UINT32) && *(UINT32 *)(format + 1) == 0x01000000)
{
init_caps_codec_data_name(caps, format + 1, format_size - sizeof(*format), "streamheader");
gst_caps_set_simple(caps, "stream-format", G_TYPE_STRING, "byte-stream", NULL);
}
else
{
init_caps_codec_data_name(caps, format + 1, format_size - sizeof(*format), "codec_data");
gst_caps_set_simple(caps, "stream-format", G_TYPE_STRING, format_size - sizeof(*format) ? "avc" : "byte-stream", NULL);
}
}

static void init_caps_from_video_wmv(GstCaps *caps, const MFVIDEOFORMAT *format, UINT format_size,
Expand Down

0 comments on commit a799ca6

Please sign in to comment.