validate: launcher: Keep variable framerate from input when possible

But disable it if forcing a framerate for some reason

Fixing our support for variable framerate in the encoding profile
serialization format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3122>
This commit is contained in:
Thibault Saunier 2022-10-04 19:16:44 -03:00 committed by GStreamer Marge Bot
parent fbddaffc62
commit 1577911d75
2 changed files with 34 additions and 8 deletions

View file

@ -17,6 +17,7 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
import argparse
from fractions import Fraction
import os
import copy
import sys
@ -34,7 +35,7 @@ from launcher.loggable import Loggable, error
from launcher.baseclasses import GstValidateTest, Test, \
ScenarioManager, NamedDic, GstValidateTestsGenerator, \
GstValidateMediaDescriptor, GstValidateEncodingTestInterface, \
GstValidateBaseTestManager, MediaDescriptor, MediaFormatCombination
GstValidateBaseTestManager, MediaDescriptor, MediaFormatCombination, VariableFramerateMode
from launcher.utils import path2url, url2path, DEFAULT_TIMEOUT, which, \
GST_SECOND, Result, Protocols, mkdir, printc, Colors, get_data_file, \
@ -819,7 +820,18 @@ class GstValidateTranscodingTest(GstValidateTest, GstValidateEncodingTestInterfa
if urllib.parse.urlparse(self.dest_file).scheme == "":
self.dest_file = path2url(self.dest_file)
profile = self.get_profile()
variable_framerate = VariableFramerateMode.DISABLED
if self.media_descriptor.get_num_tracks("video") == 1:
caps, = [c for (t, c) in self.media_descriptor.get_tracks_caps() if t == 'video']
framerate = None
for struct, _ in GstCaps.new_from_str(caps):
framerate = struct.get("framerate", None)
if framerate is not None and \
framerate.numerator == 0 and framerate.denominator == 1:
variable_framerate = VariableFramerateMode.AUTO
break
profile = self.get_profile(variable_framerate=variable_framerate)
self.add_arguments("-o", profile)
def build_arguments(self):

View file

@ -19,6 +19,7 @@
""" Class representing tests and test managers. """
from enum import Enum
import importlib.util
import json
import os
@ -43,7 +44,7 @@ import uuid
from itertools import cycle
from fractions import Fraction
from .utils import which
from .utils import GstCaps, which
from . import reporters
from . import loggable
from .loggable import Loggable
@ -1218,6 +1219,12 @@ class GstValidateTest(Test):
return result
class VariableFramerateMode(Enum):
DISABLED = 1
ENABLED = 2
AUTO = 3
class GstValidateEncodingTestInterface(object):
DURATION_TOLERANCE = GST_SECOND / 4
@ -1243,7 +1250,9 @@ class GstValidateEncodingTestInterface(object):
def _get_profile_full(self, muxer, venc, aenc, video_restriction=None,
audio_restriction=None, audio_presence=0,
video_presence=0, variable_framerate=False):
video_presence=0,
variable_framerate=VariableFramerateMode.DISABLED):
ret = ""
if muxer:
ret += muxer
@ -1254,9 +1263,14 @@ class GstValidateEncodingTestInterface(object):
ret += venc
props = ""
if video_presence:
props += 'presence=%s,' % str(video_presence)
if variable_framerate:
props += 'variable-framerate=true,'
props += 'presence=%s|' % str(video_presence)
if variable_framerate == VariableFramerateMode.AUTO:
if video_restriction and "framerate" in video_restriction:
variable_framerate = VariableFramerateMode.DISABLED
else:
variable_framerate = VariableFramerateMode.ENABLED
if variable_framerate == VariableFramerateMode.ENABLED:
props += 'variable-framerate=true|'
if props:
ret = ret + '|' + props[:-1]
if aenc:
@ -1270,7 +1284,7 @@ class GstValidateEncodingTestInterface(object):
return ret.replace("::", ":")
def get_profile(self, video_restriction=None, audio_restriction=None,
variable_framerate=False):
variable_framerate=VariableFramerateMode.DISABLED):
vcaps = self.combination.get_video_caps()
acaps = self.combination.get_audio_caps()
if video_restriction is None: