From aca1ce2a22b41ab278f47bcc53107e114f9dc735 Mon Sep 17 00:00:00 2001 From: Vladimir Voroshilov Date: Sat, 4 May 2013 12:25:15 +0700 Subject: [PATCH 2/3] implement separated check_width/check_height --- stream/tvi_dshow.c | 69 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/stream/tvi_dshow.c b/stream/tvi_dshow.c index b16a4fc..ba00862 100644 --- a/stream/tvi_dshow.c +++ b/stream/tvi_dshow.c @@ -1847,6 +1847,50 @@ static int check_video_format(AM_MEDIA_TYPE * pmt, int fcc) } /** + * \brief checks if VIDEO_STREAM_CONFIG_CAPS compatible with given width + * + * \param pmt pointer to VIDEO_STREAM_CONFIG_CAPS for check + * \param width width of picture + * + * \return 1 if VIDEO_STREAM_CONFIG_CAPS compatible + & \return 0 if not + * + */ +static int check_picture_width(VIDEO_STREAM_CONFIG_CAPS * pCaps, int width) +{ + if (!pCaps) + return 0; + if (width < pCaps->MinOutputSize.cx + || width > pCaps->MaxOutputSize.cx) + return 0; + if (width % pCaps->OutputGranularityX) + return 0; + return 1; +} + +/** + * \brief checks if VIDEO_STREAM_CONFIG_CAPS compatible with given height + * + * \param pmt pointer to VIDEO_STREAM_CONFIG_CAPS for check + * \param height height of picture + * + * \return 1 if VIDEO_STREAM_CONFIG_CAPS compatible + & \return 0 if not + * + */ +static int check_picture_height(VIDEO_STREAM_CONFIG_CAPS * pCaps, int height) +{ + if (!pCaps) + return 0; + if (height < pCaps->MinOutputSize.cy + || height > pCaps->MaxOutputSize.cy) + return 0; + if (height % pCaps->OutputGranularityY) + return 0; + return 1; +} + +/** * \brief converts DirectShow subtype to MPlayer's IMGFMT * * \param subtype DirectShow subtype for video format @@ -3249,18 +3293,10 @@ static int control(priv_t * priv, int cmd, void *arg) } case TVI_CONTROL_VID_CHK_WIDTH: { - VIDEO_STREAM_CONFIG_CAPS *pCaps; int width = *(int *) arg; - pCaps = priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed]; - if (!pCaps) - return TVI_CONTROL_FALSE; - if (width < pCaps->MinOutputSize.cx - || width > pCaps->MaxOutputSize.cx) - return TVI_CONTROL_FALSE; - if (width % pCaps->OutputGranularityX) - return TVI_CONTROL_FALSE; - return TVI_CONTROL_TRUE; + return check_picture_width + (priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed], width); } case TVI_CONTROL_VID_SET_HEIGHT: { @@ -3305,19 +3341,10 @@ static int control(priv_t * priv, int cmd, void *arg) } case TVI_CONTROL_VID_CHK_HEIGHT: { - VIDEO_STREAM_CONFIG_CAPS *pCaps; int height = *(int *) arg; - pCaps = priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed]; - if (!pCaps) - return TVI_CONTROL_FALSE; - if (height < pCaps->MinOutputSize.cy - || height > pCaps->MaxOutputSize.cy) - return TVI_CONTROL_FALSE; - if (height % pCaps->OutputGranularityY) - return TVI_CONTROL_FALSE; - - return TVI_CONTROL_TRUE; + return check_picture_height + (priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed], height); } case TVI_CONTROL_IS_AUDIO: if (!priv->chains[1]->pmt) -- 1.8.0.msysgit.0