Skip to content

Commit 612e9c2

Browse files
committed
implement gstreamer transform resize test for carmel
1 parent 10e8b35 commit 612e9c2

File tree

4 files changed

+174
-0
lines changed

4 files changed

+174
-0
lines changed

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/gst_transform_resize.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ def project_factory(args: argparse.Namespace) -> Any:
132132
height_to=args.height_to,
133133
framerate=args.framerate,
134134
)
135+
elif "carmel" in args.platform:
136+
return CarmelProject(
137+
platform=args.platform,
138+
codec=args.encoder_plugin,
139+
width_from=args.width_from,
140+
height_from=args.height_from,
141+
width_to=args.width_to,
142+
height_to=args.height_to,
143+
framerate=args.framerate,
144+
)
135145
else:
136146
raise SystemExit(
137147
"Error: Cannot get the implementation for '{}'".format(
@@ -227,6 +237,96 @@ def build_pipeline(self) -> str:
227237
return pipeline
228238

229239

240+
class CarmelProject(PipelineInterface):
241+
"""
242+
carmel project pipeline handle
243+
"""
244+
245+
def __init__(
246+
self,
247+
platform: str,
248+
codec: str,
249+
width_from: int,
250+
height_from: int,
251+
width_to: int,
252+
height_to: int,
253+
framerate: int,
254+
):
255+
self._platform = platform
256+
self._codec = codec
257+
self._width_from = width_from
258+
self._height_from = height_from
259+
self._width_to = width_to
260+
self._height_to = height_to
261+
self._framerate = framerate
262+
self._codec_parser_map = {
263+
GStreamerEncodePlugins.V4L2H264ENC.value: "h264parse"
264+
}
265+
# This sample video file will be consumed by any gstreamer piple as
266+
# input video.
267+
golden_sample_file = "{}p_{}fps_h264.mp4".format(
268+
self._height_from,
269+
self._framerate,
270+
)
271+
self._golden_sample = os.path.join(
272+
VIDEO_CODEC_TESTING_DATA, "video", golden_sample_file)
273+
self._artifact_file = ""
274+
275+
@property
276+
def artifact_file(self) -> str:
277+
if not self._artifact_file:
278+
self._artifact_file = generate_artifact_name(extension="mp4")
279+
return self._artifact_file
280+
281+
@property
282+
def psnr_reference_file(self) -> str:
283+
"""
284+
A golden reference which has been transformed in advance. It's used to
285+
be the compared reference file for PSNR.
286+
"""
287+
golden_reference = "{}p_30fps_h264.mp4".format(
288+
self._height_to,
289+
)
290+
291+
full_path = os.path.join(
292+
VIDEO_CODEC_TESTING_DATA, "video", golden_reference
293+
)
294+
if not os.path.exists(full_path):
295+
raise SystemExit(
296+
"Error: Golden PSNR reference '{}' doesn't exist".format(
297+
full_path
298+
)
299+
)
300+
301+
return full_path
302+
303+
def build_pipeline(self) -> str:
304+
"""
305+
Build the GStreamer commands based on the platform and codec.
306+
307+
Returns:
308+
str: A GStreamer command based on the platform and
309+
codec.
310+
"""
311+
pipeline = (
312+
"{} -e filesrc location={} ! qtdemux ! queue ! "
313+
"h264parse ! v4l2h264dec capture-io-mode=5 output-io-mode=5 ! "
314+
"qtivtransform ! video/x-raw\(memory:GBM\),format=NV12,"
315+
"width={},height={},framerate=30/1 ! "
316+
"v4l2h264enc capture-io-mode=5 output-io-mode=5 ! "
317+
"queue ! h264parse ! mp4mux ! queue ! "
318+
"filesink location={}"
319+
).format(
320+
GST_LAUNCH_BIN,
321+
self._golden_sample,
322+
self._width_to,
323+
self._height_to,
324+
self.artifact_file,
325+
)
326+
327+
return pipeline
328+
329+
230330
def main() -> None:
231331
args = register_arguments()
232332
p = project_factory(args)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"gst_transform_resize": [
3+
{
4+
"encoder_plugin": "v4l2h264enc",
5+
"resolutions": [
6+
{
7+
"width_from": 3840,
8+
"height_from": 2160,
9+
"fps": 30,
10+
"width_to": 1920,
11+
"height_to": 1080
12+
},
13+
{
14+
"width_from": 1920,
15+
"height_from": 1080,
16+
"fps": 30,
17+
"width_to": 1280,
18+
"height_to": 720
19+
},
20+
{
21+
"width_from": 1920,
22+
"height_from": 1080,
23+
"fps": 30,
24+
"width_to": 640,
25+
"height_to": 480
26+
},
27+
{
28+
"width_from": 1920,
29+
"height_from": 1080,
30+
"fps": 30,
31+
"width_to": 3840,
32+
"height_to": 2160
33+
},
34+
{
35+
"width_from": 1280,
36+
"height_from": 720,
37+
"fps": 30,
38+
"width_to": 1920,
39+
"height_to": 1080
40+
},
41+
{
42+
"width_from": 1280,
43+
"height_from": 720,
44+
"fps": 30,
45+
"width_to":3840,
46+
"height_to": 2160
47+
}
48+
]
49+
}
50+
]
51+
}

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/jobs.pxu

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,25 @@ flags: also-after-suspend
137137
environ: GST_LAUNCH_BIN, PLAINBOX_SESSION_SHARE, VIDEO_CODEC_TESTING_DATA
138138
command:
139139
gst_transform_resize.py -p "{{ platform }}" -ep "{{ encoder_plugin }}" -wf "{{ width_from }}" -hf "{{ height_from }}" -wt "{{ width_to }}" -ht "{{ height_to }}" -f "{{ framerate }}"
140+
141+
unit: template
142+
template-engine: jinja2
143+
template-resource: video_codec_resource
144+
template-filter:
145+
video_codec_resource.scenario == "gst_transform_resize"
146+
video_codec_resource.platform == "carmel"
147+
template-unit: job
148+
template-id: ce-oem-video-codec/carmel-gst_transform_resize
149+
_template-summary: Check if the resize (scale up or down) are functional
150+
id: ce-oem-video-codec/{{ scenario }}-{{ encoder_plugin }}_from_{{ width_from }}x{{ height_from }}_{{ framerate }}fps_to_{{ width_to }}x{{ height_to }}
151+
_summary: Perform resize - from {{ width_from }}x{{ height_from }} to {{ width_to }}x{{ height_to }} file
152+
plugin: shell
153+
user: root
154+
category_id: video-codec
155+
estimated_duration: 60s
156+
imports: from com.canonical.plainbox import manifest
157+
requires: manifest.has_video_codec == 'True'
158+
environ: GST_LAUNCH_BIN, PLAINBOX_SESSION_SHARE, VIDEO_CODEC_TESTING_DATA
159+
command:
160+
export XDG_RUNTIME_DIR=/run/user/1000
161+
gst_transform_resize.py -p "{{ platform }}" -ep "{{ encoder_plugin }}" -wf "{{ width_from }}" -hf "{{ height_from }}" -wt "{{ width_to }}" -ht "{{ height_to }}" -f "{{ framerate }}"

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/video-codec/test-plan.pxu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ include:
2828
ce-oem-video-codec/genio-gst_encoder_psnr
2929
ce-oem-video-codec/gst_transform_rotate_and_flip
3030
ce-oem-video-codec/genio-gst_transform_resize
31+
ce-oem-video-codec/carmel-gst_transform_resize

0 commit comments

Comments
 (0)