From 88cd527ad0051981183a82bba7faf296fddd4729 Mon Sep 17 00:00:00 2001 From: voroshil Date: Sat, 17 Nov 2007 19:51:46 +0000 Subject: Service routine for constructing AM_MEDIA_TYPE structure from given fourcc with help of lookup table. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25081 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/tvi_dshow.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'stream') diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c index 0ab788210c..88a91ecebc 100644 --- a/stream/tvi_dshow.c +++ b/stream/tvi_dshow.c @@ -1618,6 +1618,53 @@ static int get_control(priv_t * priv, int control, int *pvalue) return TVI_CONTROL_TRUE; } +/** + * \brief create AM_MEDIA_TYPE structure, corresponding to given FourCC code and width/height/fps + * \param fcc FourCC code for video format + * \param width picture width + * \param height pciture height + * \param fps frames per second (required for bitrate calculation) + * + * \return pointer to AM_MEDIA_TYPE structure if success, NULL - otherwise + */ +static AM_MEDIA_TYPE* create_video_format(int fcc, int width, int height, int fps) +{ + int i; + AM_MEDIA_TYPE mt; + VIDEOINFOHEADER vHdr; + + /* Check given fcc in lookup table*/ + for(i=0; img_fmt_list[i].fmt && img_fmt_list[i].fmt!=fcc; i++) /* NOTHING */; + if(!img_fmt_list[i].fmt) + return NULL; + + memset(&mt, 0, sizeof(AM_MEDIA_TYPE)); + memset(&vHdr, 0, sizeof(VIDEOINFOHEADER)); + + vHdr.bmiHeader.biSize = sizeof(vHdr.bmiHeader); + vHdr.bmiHeader.biWidth = width; + vHdr.bmiHeader.biHeight = height; + //FIXME: is biPlanes required too? + //vHdr.bmiHeader.biPlanes = img_fmt_list[i].nPlanes; + vHdr.bmiHeader.biBitCount = img_fmt_list[i].nBits; + vHdr.bmiHeader.biCompression = img_fmt_list[i].nCompression; + vHdr.bmiHeader.biSizeImage = width * height * img_fmt_list[i].nBits / 8; + vHdr.dwBitRate = vHdr.bmiHeader.biSizeImage * 8 * fps; + + mt.pbFormat = (char*)&vHdr; + mt.cbFormat = sizeof(vHdr); + + mt.majortype = MEDIATYPE_Video; + mt.subtype = *img_fmt_list[i].subtype; + mt.formattype = FORMAT_VideoInfo; + + mt.bFixedSizeSamples = 1; + mt.bTemporalCompression = 0; + mt.lSampleSize = vHdr.bmiHeader.biSizeImage; + + return CreateMediaType(&mt); +} + /** * \brief extracts fcc,width,height from AM_MEDIA_TYPE * -- cgit v1.2.3