2121import shlex
2222import subprocess
2323from functools import lru_cache
24- from typing import List , Optional
24+ from typing import Any , Dict , List , Optional
2525
2626from fluster .codec import Codec , OutputFormat
2727from fluster .decoder import Decoder , register_decoder
@@ -109,14 +109,21 @@ def gen_pipeline(
109109 input_filepath : str ,
110110 output_filepath : Optional [str ],
111111 output_format : OutputFormat ,
112+ optional_params : Optional [Dict [str , Any ]] = None ,
112113 ) -> str :
113114 """Generate the GStreamer pipeline used to decode the test vector"""
114115 output = f"location={ output_filepath } " if output_filepath else ""
116+
117+ decoder_params = ""
118+ if optional_params :
119+ for key , value in optional_params .items ():
120+ decoder_params += f" { key } ={ value } "
121+
115122 return PIPELINE_TPL .format (
116123 self .cmd ,
117124 input_filepath ,
118125 self .parser if self .parser else "parsebin" ,
119- self .decoder_bin ,
126+ self .decoder_bin + decoder_params ,
120127 self .caps ,
121128 self .sink ,
122129 output ,
@@ -149,6 +156,7 @@ def decode(
149156 timeout : int ,
150157 verbose : bool ,
151158 keep_files : bool ,
159+ optional_params : Optional [Dict [str , Any ]] = None ,
152160 ) -> str :
153161 """Decode the test vector and do the checksum"""
154162 # When using videocodectestsink we can avoid writing files to disk
@@ -162,7 +170,7 @@ def decode(
162170 data = run_command_with_output (command , timeout = timeout , verbose = verbose ).splitlines ()
163171 return self .parse_videocodectestsink_md5sum (data )
164172
165- pipeline = self .gen_pipeline (input_filepath , output_filepath , output_format )
173+ pipeline = self .gen_pipeline (input_filepath , output_filepath , output_format , optional_params )
166174 run_command (shlex .split (pipeline ), timeout = timeout , verbose = verbose )
167175 return file_checksum (output_filepath )
168176
@@ -193,6 +201,7 @@ def gen_pipeline(
193201 input_filepath : str ,
194202 output_filepath : Optional [str ],
195203 output_format : OutputFormat ,
204+ optional_params : Optional [Dict [str , Any ]] = None ,
196205 ) -> str :
197206 raw_caps = "video/x-raw"
198207 try :
@@ -785,6 +794,7 @@ def gen_pipeline(
785794 input_filepath : str ,
786795 output_filepath : Optional [str ],
787796 output_format : OutputFormat ,
797+ optional_params : Optional [Dict [str , Any ]] = None ,
788798 ) -> str :
789799 caps = f"{ self .caps } ! videoconvert dither=none ! video/x-raw,format={ output_format_to_gst (output_format )} "
790800 output = f"location={ output_filepath } " if output_filepath else ""
0 commit comments