ReactOS 0.4.17-dev-966-gf06eace
mediatype.c
Go to the documentation of this file.
1/*
2 * Implementation of MedaType utility functions
3 *
4 * Copyright 2003 Robert Shearman
5 * Copyright 2010 Aric Stewart, CodeWeavers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include "strmbase_private.h"
23#include "dvdmedia.h"
24#include "dxva.h"
25
27
28static const struct
29{
30 const GUID *guid;
31 const char *name;
32}
34{
35#define X(g) {&(g), #g}
36 X(GUID_NULL),
37
38#undef OUR_GUID_ENTRY
39#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) X(name),
40#include "uuids.h"
41
42#undef X
43};
44
45static const char *strmbase_debugstr_guid(const GUID *guid)
46{
47 unsigned int i;
48
49 for (i = 0; i < ARRAY_SIZE(strmbase_guids); ++i)
50 {
53 }
54
55 return debugstr_guid(guid);
56}
57
59{
60 if (!TRACE_ON(quartz) || !mt) return;
61
62 TRACE("Dumping media type %p: major type %s, subtype %s",
63 mt, strmbase_debugstr_guid(&mt->majortype), strmbase_debugstr_guid(&mt->subtype));
64 if (mt->bFixedSizeSamples) TRACE(", fixed size samples");
65 if (mt->bTemporalCompression) TRACE(", temporal compression");
66 if (mt->lSampleSize) TRACE(", sample size %ld", mt->lSampleSize);
67 if (mt->pUnk) TRACE(", pUnk %p", mt->pUnk);
68 TRACE(", format type %s.\n", strmbase_debugstr_guid(&mt->formattype));
69
70 if (!mt->pbFormat) return;
71
72 TRACE("Dumping format %p: ", mt->pbFormat);
73
74 if (IsEqualGUID(&mt->formattype, &FORMAT_WaveFormatEx) && mt->cbFormat >= sizeof(WAVEFORMATEX))
75 {
76 WAVEFORMATEX *wfx = (WAVEFORMATEX *)mt->pbFormat;
77
78 TRACE("tag %#x, %u channels, sample rate %lu, %lu bytes/sec, alignment %u, %u bits/sample.\n",
79 wfx->wFormatTag, wfx->nChannels, wfx->nSamplesPerSec,
81
82 if (wfx->cbSize)
83 {
84 const unsigned char *extra = (const unsigned char *)(wfx + 1);
85 unsigned int i;
86
87 TRACE(" Extra bytes:");
88 for (i = 0; i < wfx->cbSize; ++i)
89 {
90 if (!(i % 16)) TRACE("\n ");
91 TRACE(" %02x", extra[i]);
92 }
93 TRACE("\n");
94 }
95 }
96 else if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) && mt->cbFormat >= sizeof(VIDEOINFOHEADER))
97 {
98 VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)mt->pbFormat;
99
100 if (!IsRectEmpty(&vih->rcSource)) TRACE("source %s, ", wine_dbgstr_rect(&vih->rcSource));
101 if (!IsRectEmpty(&vih->rcTarget)) TRACE("target %s, ", wine_dbgstr_rect(&vih->rcTarget));
102 if (vih->dwBitRate) TRACE("bitrate %lu, ", vih->dwBitRate);
103 if (vih->dwBitErrorRate) TRACE("error rate %lu, ", vih->dwBitErrorRate);
104 TRACE("%s sec/frame, ", debugstr_time(vih->AvgTimePerFrame));
105 TRACE("size %ldx%ld, %u planes, %u bpp, compression %s, image size %lu",
110 TRACE(", resolution %ldx%ld", vih->bmiHeader.biXPelsPerMeter, vih->bmiHeader.biYPelsPerMeter);
111 if (vih->bmiHeader.biClrUsed) TRACE(", %lu colours", vih->bmiHeader.biClrUsed);
112 if (vih->bmiHeader.biClrImportant) TRACE(", %lu important colours", vih->bmiHeader.biClrImportant);
113 TRACE(".\n");
114 }
115 else if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo2) && mt->cbFormat >= sizeof(VIDEOINFOHEADER2))
116 {
117 VIDEOINFOHEADER2 *vih = (VIDEOINFOHEADER2 *)mt->pbFormat;
118
119 if (!IsRectEmpty(&vih->rcSource)) TRACE("source %s, ", wine_dbgstr_rect(&vih->rcSource));
120 if (!IsRectEmpty(&vih->rcTarget)) TRACE("target %s, ", wine_dbgstr_rect(&vih->rcTarget));
121 if (vih->dwBitRate) TRACE("bitrate %lu, ", vih->dwBitRate);
122 if (vih->dwBitErrorRate) TRACE("error rate %lu, ", vih->dwBitErrorRate);
123 TRACE("%s sec/frame, ", debugstr_time(vih->AvgTimePerFrame));
124 if (vih->dwInterlaceFlags) TRACE("interlace flags %#lx, ", vih->dwInterlaceFlags);
125 if (vih->dwCopyProtectFlags) TRACE("copy-protection flags %#lx, ", vih->dwCopyProtectFlags);
126 TRACE("aspect ratio %lu/%lu, ", vih->dwPictAspectRatioX, vih->dwPictAspectRatioY);
127 if (vih->dwControlFlags) TRACE("control flags %#lx, ", vih->dwControlFlags);
129 {
130 const DXVA_ExtendedFormat *colorimetry = (const DXVA_ExtendedFormat *)&vih->dwControlFlags;
131
132 TRACE("chroma site %#x, range %#x, matrix %#x, lighting %#x, primaries %#x, transfer function %#x, ",
133 colorimetry->VideoChromaSubsampling, colorimetry->NominalRange, colorimetry->VideoTransferMatrix,
134 colorimetry->VideoLighting, colorimetry->VideoPrimaries, colorimetry->VideoTransferFunction);
135 }
136 TRACE("size %ldx%ld, %u planes, %u bpp, compression %s, image size %lu",
141 TRACE(", resolution %ldx%ld", vih->bmiHeader.biXPelsPerMeter, vih->bmiHeader.biYPelsPerMeter);
142 if (vih->bmiHeader.biClrUsed) TRACE(", %lu colours", vih->bmiHeader.biClrUsed);
143 if (vih->bmiHeader.biClrImportant) TRACE(", %lu important colours", vih->bmiHeader.biClrImportant);
144 TRACE(".\n");
145 }
146 else
147 TRACE("not implemented for this format type.\n");
148}
149
151{
152 *dest = *src;
153 if (src->pbFormat)
154 {
155 dest->pbFormat = CoTaskMemAlloc(src->cbFormat);
156 if (!dest->pbFormat)
157 return E_OUTOFMEMORY;
158 memcpy(dest->pbFormat, src->pbFormat, src->cbFormat);
159 }
160 if (dest->pUnk)
161 IUnknown_AddRef(dest->pUnk);
162 return S_OK;
163}
164
166{
167 CoTaskMemFree(pMediaType->pbFormat);
168 pMediaType->pbFormat = NULL;
169 if (pMediaType->pUnk)
170 {
171 IUnknown_Release(pMediaType->pUnk);
172 pMediaType->pUnk = NULL;
173 }
174}
175
177{
178 AM_MEDIA_TYPE * pDest;
179
180 pDest = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
181 if (!pDest)
182 return NULL;
183
184 if (FAILED(CopyMediaType(pDest, pSrc)))
185 {
186 CoTaskMemFree(pDest);
187 return NULL;
188 }
189
190 return pDest;
191}
192
194{
195 FreeMediaType(pMediaType);
196 CoTaskMemFree(pMediaType);
197}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
#define TRACE_ON(x)
Definition: compat.h:75
#define AMCONTROL_COLORINFO_PRESENT
Definition: dvdmedia.h:25
GLenum src
Definition: glext.h:6340
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ extra
Definition: id3.c:95
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
#define GUID_NULL
Definition: ks.h:106
if(dx< 0)
Definition: linetemp.h:194
static const char * strmbase_debugstr_guid(const GUID *guid)
Definition: mediatype.c:45
void WINAPI FreeMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: mediatype.c:165
static const struct @5231 strmbase_guids[]
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *dest, const AM_MEDIA_TYPE *src)
Definition: mediatype.c:150
void strmbase_dump_media_type(const AM_MEDIA_TYPE *mt)
Definition: mediatype.c:58
AM_MEDIA_TYPE *WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc)
Definition: mediatype.c:176
const char * name
Definition: mediatype.c:31
const GUID * guid
Definition: mediatype.c:30
#define X(g)
void WINAPI DeleteMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: mediatype.c:193
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char * dest
Definition: rtl.c:149
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
static __inline const char * debugstr_fourcc(unsigned int cc)
Definition: debug.h:397
#define TRACE(s)
Definition: solgame.cpp:4
static const char * debugstr_time(REFERENCE_TIME time)
Definition: strmbase.h:32
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD biCompression
Definition: amvideo.idl:35
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
DWORD biSizeImage
Definition: amvideo.idl:36
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
WORD wBitsPerSample
Definition: audioclient.idl:45
DWORD nSamplesPerSec
Definition: audioclient.idl:42
DXVA_VideoTransferFunction VideoTransferFunction
Definition: dxva.h:1022
DXVA_NominalRange NominalRange
Definition: dxva.h:1018
DXVA_VideoLighting VideoLighting
Definition: dxva.h:1020
UINT VideoChromaSubsampling
Definition: dxva.h:1017
DXVA_VideoTransferMatrix VideoTransferMatrix
Definition: dxva.h:1019
DXVA_VideoPrimaries VideoPrimaries
Definition: dxva.h:1021
Definition: name.c:39
DWORD dwCopyProtectFlags
Definition: dvdmedia.h:34
DWORD dwPictAspectRatioX
Definition: dvdmedia.h:35
DWORD dwInterlaceFlags
Definition: dvdmedia.h:33
DWORD dwBitErrorRate
Definition: dvdmedia.h:31
DWORD dwPictAspectRatioY
Definition: dvdmedia.h:36
REFERENCE_TIME AvgTimePerFrame
Definition: dvdmedia.h:32
DWORD dwControlFlags
Definition: dvdmedia.h:38
BITMAPINFOHEADER bmiHeader
Definition: dvdmedia.h:42
BITMAPINFOHEADER bmiHeader
Definition: amvideo.idl:189
REFERENCE_TIME AvgTimePerFrame
Definition: amvideo.idl:187
#define WINAPI
Definition: msvc.h:6