mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 05:28:48 +00:00
libav: avoid dividing by zero on insane fps/par
While there, fix mixup in num/den with par (copied from fps, apparently, and fps inverts fps to time base). Coverity 1139696
This commit is contained in:
parent
3529de1784
commit
4f1fd2687d
1 changed files with 30 additions and 13 deletions
|
@ -2379,26 +2379,43 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
|
||||||
fps = gst_structure_get_value (structure, "framerate");
|
fps = gst_structure_get_value (structure, "framerate");
|
||||||
if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
|
if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
|
||||||
|
|
||||||
/* somehow these seem mixed up.. */
|
int num = gst_value_get_fraction_numerator (fps);
|
||||||
context->time_base.den = gst_value_get_fraction_numerator (fps);
|
int den = gst_value_get_fraction_denominator (fps);
|
||||||
context->time_base.num = gst_value_get_fraction_denominator (fps);
|
|
||||||
context->ticks_per_frame = 1;
|
|
||||||
|
|
||||||
GST_DEBUG ("setting framerate %d/%d = %lf",
|
if (num > 0 && den > 0) {
|
||||||
context->time_base.den, context->time_base.num,
|
/* somehow these seem mixed up.. */
|
||||||
1. * context->time_base.den / context->time_base.num);
|
/* they're fine, this is because it does period=1/frequency */
|
||||||
|
context->time_base.den = gst_value_get_fraction_numerator (fps);
|
||||||
|
context->time_base.num = gst_value_get_fraction_denominator (fps);
|
||||||
|
context->ticks_per_frame = 1;
|
||||||
|
|
||||||
|
GST_DEBUG ("setting framerate %d/%d = %lf",
|
||||||
|
context->time_base.den, context->time_base.num,
|
||||||
|
1. * context->time_base.den / context->time_base.num);
|
||||||
|
} else {
|
||||||
|
GST_WARNING ("ignoring insane framerate %d/%d",
|
||||||
|
context->time_base.den, context->time_base.num);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
par = gst_structure_get_value (structure, "pixel-aspect-ratio");
|
par = gst_structure_get_value (structure, "pixel-aspect-ratio");
|
||||||
if (par && GST_VALUE_HOLDS_FRACTION (par)) {
|
if (par && GST_VALUE_HOLDS_FRACTION (par)) {
|
||||||
|
|
||||||
context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
|
int num = gst_value_get_fraction_numerator (par);
|
||||||
context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
|
int den = gst_value_get_fraction_denominator (par);
|
||||||
|
|
||||||
GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
|
if (num > 0 && den > 0) {
|
||||||
context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
|
context->sample_aspect_ratio.num = num;
|
||||||
1. * context->sample_aspect_ratio.den /
|
context->sample_aspect_ratio.den = den;
|
||||||
context->sample_aspect_ratio.num);
|
|
||||||
|
GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
|
||||||
|
context->sample_aspect_ratio.num, context->sample_aspect_ratio.den,
|
||||||
|
1. * context->sample_aspect_ratio.num /
|
||||||
|
context->sample_aspect_ratio.den);
|
||||||
|
} else {
|
||||||
|
GST_WARNING ("ignoring insane pixel-aspect-ratio %d/%d",
|
||||||
|
context->sample_aspect_ratio.num, context->sample_aspect_ratio.den);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!raw)
|
if (!raw)
|
||||||
|
|
Loading…
Reference in a new issue