00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "dshow.h"
00023
00024 long ff_copy_dshow_media_type(AM_MEDIA_TYPE *dst, const AM_MEDIA_TYPE *src)
00025 {
00026 uint8_t *pbFormat = NULL;
00027
00028 if (src->cbFormat) {
00029 pbFormat = CoTaskMemAlloc(src->cbFormat);
00030 if (!pbFormat)
00031 return E_OUTOFMEMORY;
00032 memcpy(pbFormat, src->pbFormat, src->cbFormat);
00033 }
00034
00035 *dst = *src;
00036 dst->pUnk = NULL;
00037 dst->pbFormat = pbFormat;
00038
00039 return S_OK;
00040 }
00041
00042 void ff_printGUID(const GUID *g)
00043 {
00044 #if DSHOWDEBUG
00045 const uint32_t *d = (const uint32_t *) &g->Data1;
00046 const uint16_t *w = (const uint16_t *) &g->Data2;
00047 const uint8_t *c = (const uint8_t *) &g->Data4;
00048
00049 dshowdebug("0x%08x 0x%04x 0x%04x %02x%02x%02x%02x%02x%02x%02x%02x",
00050 d[0], w[0], w[1],
00051 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
00052 #endif
00053 }
00054
00055 static const char *dshow_context_to_name(void *ptr)
00056 {
00057 return "dshow";
00058 }
00059 static const AVClass ff_dshow_context_class = { "DirectShow", dshow_context_to_name };
00060 const AVClass *ff_dshow_context_class_ptr = &ff_dshow_context_class;
00061
00062 #define dstruct(pctx, sname, var, type) \
00063 dshowdebug(" "#var":\t%"type"\n", sname->var)
00064
00065 #if DSHOWDEBUG
00066 static void dump_bih(void *s, BITMAPINFOHEADER *bih)
00067 {
00068 dshowdebug(" BITMAPINFOHEADER\n");
00069 dstruct(s, bih, biSize, "lu");
00070 dstruct(s, bih, biWidth, "ld");
00071 dstruct(s, bih, biHeight, "ld");
00072 dstruct(s, bih, biPlanes, "d");
00073 dstruct(s, bih, biBitCount, "d");
00074 dstruct(s, bih, biCompression, "lu");
00075 dshowdebug(" biCompression:\t\"%.4s\"\n",
00076 (char*) &bih->biCompression);
00077 dstruct(s, bih, biSizeImage, "lu");
00078 dstruct(s, bih, biXPelsPerMeter, "lu");
00079 dstruct(s, bih, biYPelsPerMeter, "lu");
00080 dstruct(s, bih, biClrUsed, "lu");
00081 dstruct(s, bih, biClrImportant, "lu");
00082 }
00083 #endif
00084
00085 void ff_print_AM_MEDIA_TYPE(const AM_MEDIA_TYPE *type)
00086 {
00087 #if DSHOWDEBUG
00088 dshowdebug(" majortype\t");
00089 ff_printGUID(&type->majortype);
00090 dshowdebug("\n");
00091 dshowdebug(" subtype\t");
00092 ff_printGUID(&type->subtype);
00093 dshowdebug("\n");
00094 dshowdebug(" bFixedSizeSamples\t%d\n", type->bFixedSizeSamples);
00095 dshowdebug(" bTemporalCompression\t%d\n", type->bTemporalCompression);
00096 dshowdebug(" lSampleSize\t%lu\n", type->lSampleSize);
00097 dshowdebug(" formattype\t");
00098 ff_printGUID(&type->formattype);
00099 dshowdebug("\n");
00100 dshowdebug(" pUnk\t%p\n", type->pUnk);
00101 dshowdebug(" cbFormat\t%lu\n", type->cbFormat);
00102 dshowdebug(" pbFormat\t%p\n", type->pbFormat);
00103
00104 if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo)) {
00105 VIDEOINFOHEADER *v = (void *) type->pbFormat;
00106 dshowdebug(" rcSource: left %ld top %ld right %ld bottom %ld\n",
00107 v->rcSource.left, v->rcSource.top, v->rcSource.right, v->rcSource.bottom);
00108 dshowdebug(" rcTarget: left %ld top %ld right %ld bottom %ld\n",
00109 v->rcTarget.left, v->rcTarget.top, v->rcTarget.right, v->rcTarget.bottom);
00110 dshowdebug(" dwBitRate: %lu\n", v->dwBitRate);
00111 dshowdebug(" dwBitErrorRate: %lu\n", v->dwBitErrorRate);
00112 dshowdebug(" AvgTimePerFrame: %"PRId64"\n", v->AvgTimePerFrame);
00113 dump_bih(NULL, &v->bmiHeader);
00114 } else if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo2)) {
00115 VIDEOINFOHEADER2 *v = (void *) type->pbFormat;
00116 dshowdebug(" rcSource: left %ld top %ld right %ld bottom %ld\n",
00117 v->rcSource.left, v->rcSource.top, v->rcSource.right, v->rcSource.bottom);
00118 dshowdebug(" rcTarget: left %ld top %ld right %ld bottom %ld\n",
00119 v->rcTarget.left, v->rcTarget.top, v->rcTarget.right, v->rcTarget.bottom);
00120 dshowdebug(" dwBitRate: %lu\n", v->dwBitRate);
00121 dshowdebug(" dwBitErrorRate: %lu\n", v->dwBitErrorRate);
00122 dshowdebug(" AvgTimePerFrame: %"PRId64"\n", v->AvgTimePerFrame);
00123 dshowdebug(" dwInterlaceFlags: %lu\n", v->dwInterlaceFlags);
00124 dshowdebug(" dwCopyProtectFlags: %lu\n", v->dwCopyProtectFlags);
00125 dshowdebug(" dwPictAspectRatioX: %lu\n", v->dwPictAspectRatioX);
00126 dshowdebug(" dwPictAspectRatioY: %lu\n", v->dwPictAspectRatioY);
00127
00128 dshowdebug(" dwReserved2: %lu\n", v->dwReserved2);
00129 dump_bih(NULL, &v->bmiHeader);
00130 } else if (IsEqualGUID(&type->formattype, &FORMAT_WaveFormatEx)) {
00131 WAVEFORMATEX *fx = (void *) type->pbFormat;
00132 dshowdebug(" wFormatTag: %u\n", fx->wFormatTag);
00133 dshowdebug(" nChannels: %u\n", fx->nChannels);
00134 dshowdebug(" nSamplesPerSec: %lu\n", fx->nSamplesPerSec);
00135 dshowdebug(" nAvgBytesPerSec: %lu\n", fx->nAvgBytesPerSec);
00136 dshowdebug(" nBlockAlign: %u\n", fx->nBlockAlign);
00137 dshowdebug(" wBitsPerSample: %u\n", fx->wBitsPerSample);
00138 dshowdebug(" cbSize: %u\n", fx->cbSize);
00139 }
00140 #endif
00141 }