diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/gst_transform_resize.py b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/gst_transform_resize.py index f89624b296..7f662e2a58 100755 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/gst_transform_resize.py +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/gst_transform_resize.py @@ -132,6 +132,16 @@ def project_factory(args: argparse.Namespace) -> Any: height_to=args.height_to, framerate=args.framerate, ) + elif "carmel" in args.platform: + return CarmelProject( + platform=args.platform, + codec=args.encoder_plugin, + width_from=args.width_from, + height_from=args.height_from, + width_to=args.width_to, + height_to=args.height_to, + framerate=args.framerate, + ) else: raise SystemExit( "Error: Cannot get the implementation for '{}'".format( @@ -227,6 +237,97 @@ def build_pipeline(self) -> str: return pipeline +class CarmelProject(PipelineInterface): + """ + carmel project pipeline handle + """ + + def __init__( + self, + platform: str, + codec: str, + width_from: int, + height_from: int, + width_to: int, + height_to: int, + framerate: int, + ): + self._platform = platform + self._codec = codec + self._width_from = width_from + self._height_from = height_from + self._width_to = width_to + self._height_to = height_to + self._framerate = framerate + self._codec_parser_map = { + GStreamerEncodePlugins.V4L2H264ENC.value: "h264parse" + } + # This sample video file will be consumed by any gstreamer piple as + # input video. + golden_sample_file = "{}p_{}fps_h264.mp4".format( + self._height_from, + self._framerate, + ) + self._golden_sample = os.path.join( + VIDEO_CODEC_TESTING_DATA, "video", golden_sample_file + ) + self._artifact_file = "" + + @property + def artifact_file(self) -> str: + if not self._artifact_file: + self._artifact_file = generate_artifact_name(extension="mp4") + return self._artifact_file + + @property + def psnr_reference_file(self) -> str: + """ + A golden reference which has been transformed in advance. It's used to + be the compared reference file for PSNR. + """ + golden_reference = "{}p_30fps_h264.mp4".format( + self._height_to, + ) + + full_path = os.path.join( + VIDEO_CODEC_TESTING_DATA, "video", golden_reference + ) + if not os.path.exists(full_path): + raise SystemExit( + "Error: Golden PSNR reference '{}' doesn't exist".format( + full_path + ) + ) + + return full_path + + def build_pipeline(self) -> str: + """ + Build the GStreamer commands based on the platform and codec. + + Returns: + str: A GStreamer command based on the platform and + codec. + """ + pipeline = ( + "{} -e filesrc location={} ! qtdemux ! queue ! " + "h264parse ! v4l2h264dec capture-io-mode=5 output-io-mode=5 ! " + "qtivtransform ! video/x-raw\\(memory:GBM\\),format=NV12," + "width={},height={},framerate=30/1 ! " + "v4l2h264enc capture-io-mode=5 output-io-mode=5 ! " + "queue ! h264parse ! mp4mux ! queue ! " + "filesink location={}" + ).format( + GST_LAUNCH_BIN, + self._golden_sample, + self._width_to, + self._height_to, + self.artifact_file, + ) + + return pipeline + + def main() -> None: args = register_arguments() p = project_factory(args) diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/data/video-codec-test-confs/carmel.json b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/data/video-codec-test-confs/carmel.json index 50e6c4fc4c..05631c12ef 100644 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/data/video-codec-test-confs/carmel.json +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/data/video-codec-test-confs/carmel.json @@ -50,5 +50,54 @@ } ] } + ], + "gst_transform_resize": [ + { + "encoder_plugin": "v4l2h264enc", + "resolutions": [ + { + "width_from": 3840, + "height_from": 2160, + "fps": 30, + "width_to": 1920, + "height_to": 1080 + }, + { + "width_from": 1920, + "height_from": 1080, + "fps": 30, + "width_to": 1280, + "height_to": 720 + }, + { + "width_from": 1920, + "height_from": 1080, + "fps": 30, + "width_to": 640, + "height_to": 480 + }, + { + "width_from": 1920, + "height_from": 1080, + "fps": 30, + "width_to": 3840, + "height_to": 2160 + }, + { + "width_from": 1280, + "height_from": 720, + "fps": 30, + "width_to": 1920, + "height_to": 1080 + }, + { + "width_from": 1280, + "height_from": 720, + "fps": 30, + "width_to": 3840, + "height_to": 2160 + } + ] + } ] } \ No newline at end of file diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/jobs.pxu b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/jobs.pxu index cb0259a432..058a18e675 100644 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/jobs.pxu +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/jobs.pxu @@ -156,4 +156,26 @@ category_id: video-codec estimated_duration: 60s environ: GST_LAUNCH_BIN, PLAINBOX_SESSION_SHARE, VIDEO_CODEC_TESTING_DATA command: - gst_encoder_psnr.py -p "{{ platform }}" -ep "{{ encoder_plugin }}" -wi {{ width }} -hi {{ height }} -f "{{ framerate }}" \ No newline at end of file + gst_encoder_psnr.py -p "{{ platform }}" -ep "{{ encoder_plugin }}" -wi {{ width }} -hi {{ height }} -f "{{ framerate }}" + +unit: template +template-engine: jinja2 +template-resource: video_codec_resource +template-filter: + video_codec_resource.scenario == "gst_transform_resize" + video_codec_resource.platform == "carmel" +template-unit: job +template-id: ce-oem-video-codec/carmel-gst_transform_resize +_template-summary: Check if the resize (scale up or down) are functional +id: ce-oem-video-codec/{{ scenario }}-{{ encoder_plugin }}_from_{{ width_from }}x{{ height_from }}_to_{{ width_to }}x{{ height_to }} +_summary: Perform resize - from {{ width_from }}x{{ height_from }} to {{ width_to }}x{{ height_to }} file +plugin: shell +user: root +category_id: video-codec +estimated_duration: 60s +imports: from com.canonical.plainbox import manifest +requires: manifest.has_video_codec == 'True' +environ: GST_LAUNCH_BIN, PLAINBOX_SESSION_SHARE, VIDEO_CODEC_TESTING_DATA +command: + export XDG_RUNTIME_DIR=/run/user/1000 + gst_transform_resize.py -p "{{ platform }}" -ep "{{ encoder_plugin }}" -wf "{{ width_from }}" -hf "{{ height_from }}" -wt "{{ width_to }}" -ht "{{ height_to }}" -f "{{ framerate }}" diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/test-plan.pxu b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/test-plan.pxu index d5d65a8cd1..20b763ac18 100644 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/test-plan.pxu +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/test-plan.pxu @@ -29,3 +29,4 @@ include: ce-oem-video-codec/gst_transform_rotate_and_flip ce-oem-video-codec/genio-gst_transform_resize ce-oem-video-codec/carmel-gst_encoder_psnr + ce-oem-video-codec/carmel-gst_transform_resize \ No newline at end of file