mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
directshow: Fix for division by zero
The AvgTimePerFrame value may be unknown. Use arbitrary value (30 fps) instead of crashing. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1828>
This commit is contained in:
parent
9f798776e5
commit
df6624bf1c
2 changed files with 19 additions and 4 deletions
|
@ -101,7 +101,11 @@ gst_dshow_new_pin_mediatype_from_enum_mediatypes (IPin * pin, IEnumMediaTypes *e
|
|||
|
||||
pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth;
|
||||
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;
|
||||
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
|
||||
if (video_info->AvgTimePerFrame > 0) {
|
||||
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
|
||||
} else {
|
||||
pin_mediatype->defaultFPS = 30;
|
||||
}
|
||||
pin_mediatype->granularityWidth = 1;
|
||||
pin_mediatype->granularityHeight = 1;
|
||||
|
||||
|
@ -125,7 +129,11 @@ gst_dshow_new_pin_mediatype_from_streamcaps (IPin * pin, gint id, IAMStreamConfi
|
|||
|
||||
pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth;
|
||||
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;
|
||||
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
|
||||
if (video_info->AvgTimePerFrame > 0) {
|
||||
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
|
||||
} else {
|
||||
pin_mediatype->defaultFPS = 30;
|
||||
}
|
||||
pin_mediatype->granularityWidth = pin_mediatype->vscc.OutputGranularityX;
|
||||
pin_mediatype->granularityHeight = pin_mediatype->vscc.OutputGranularityY;
|
||||
|
||||
|
|
|
@ -999,16 +999,23 @@ gst_dshowvideodec_src_getcaps (GstPad * pad)
|
|||
if (IsEqualGUID (mediatype->subtype, MEDIASUBTYPE_RGB24) &&
|
||||
IsEqualGUID (mediatype->formattype, FORMAT_VideoInfo))
|
||||
{
|
||||
gint fps_n;
|
||||
|
||||
video_info = (VIDEOINFOHEADER *) mediatype->pbFormat;
|
||||
|
||||
if (video_info->AvgTimePerFrame > 0) {
|
||||
fps_n = 10000000 / video_info->AvgTimePerFrame;
|
||||
} else {
|
||||
fps_n = 30;
|
||||
}
|
||||
|
||||
/* ffmpegcolorspace handles RGB24 in BIG_ENDIAN */
|
||||
mediacaps = gst_caps_new_simple ("video/x-raw-rgb",
|
||||
"bpp", G_TYPE_INT, 24,
|
||||
"depth", G_TYPE_INT, 24,
|
||||
"width", G_TYPE_INT, video_info->bmiHeader.biWidth,
|
||||
"height", G_TYPE_INT, video_info->bmiHeader.biHeight,
|
||||
"framerate", GST_TYPE_FRACTION,
|
||||
(int) (10000000 / video_info->AvgTimePerFrame), 1, "endianness",
|
||||
"framerate", GST_TYPE_FRACTION, fps_n, 1, "endianness",
|
||||
G_TYPE_INT, G_BIG_ENDIAN, "red_mask", G_TYPE_INT, 255,
|
||||
"green_mask", G_TYPE_INT, 65280, "blue_mask", G_TYPE_INT,
|
||||
16711680, NULL);
|
||||
|
|
Loading…
Reference in a new issue