From fbcb71c562b893650f58730f774f17db5d082dd3 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Sat, 17 Mar 2018 18:50:17 +0100
Subject: [PATCH] fate/hapqa_extract : add test for hapqa_extract bsf

test extract color and alpha
with the three main kind of hap frame :
- no snappy compression
- snappy compression and one chunk
- snappy compression and several chunks (16 here)

like the bsf filter need to be used with vtag and encoder edition
also test the information of the target mov for color and alpha
---
 tests/fate/hap.mak                                 | 43 +++++++++++++
 .../hapqa-extract-nosnappy-to-hapalphaonly-mov     | 73 ++++++++++++++++++++++
 tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov  | 73 ++++++++++++++++++++++
 .../ref/fate/hapqa-extract-snappy1-to-hapalphaonly | 10 +++
 tests/ref/fate/hapqa-extract-snappy1-to-hapq       | 10 +++
 .../fate/hapqa-extract-snappy16-to-hapalphaonly    | 10 +++
 tests/ref/fate/hapqa-extract-snappy16-to-hapq      | 10 +++
 7 files changed, 229 insertions(+)
 create mode 100644 tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov
 create mode 100644 tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov
 create mode 100644 tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly
 create mode 100644 tests/ref/fate/hapqa-extract-snappy1-to-hapq
 create mode 100644 tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly
 create mode 100644 tests/ref/fate/hapqa-extract-snappy16-to-hapq

diff --git a/tests/fate/hap.mak b/tests/fate/hap.mak
index 51673366f2..cd2838c7ce 100644
--- a/tests/fate/hap.mak
+++ b/tests/fate/hap.mak
@@ -29,6 +29,49 @@ FATE_SAMPLES_AVCONV-$(call DEMDEC, MOV, HAP) += $(FATE_HAP)
 fate-hap: $(FATE_HAP)
 
 
+#Test bsf conversion
+FATE_HAPQA_EXTRACT_BSF += fate-hapqa-extract-snappy1-to-hapq
+fate-hapqa-extract-snappy1-to-hapq: CMD = framemd5 -i $(TARGET_SAMPLES)/hap/HAPQA_Snappy_1chunk_127x1.mov -c copy -bsf:v hapqa_extract=texture=color -tag:v HapY -metadata:s:v:0 encoder="HAPQ"
+
+FATE_HAPQA_EXTRACT_BSF += fate-hapqa-extract-snappy16-to-hapq
+fate-hapqa-extract-snappy16-to-hapq: CMD = framemd5 -i $(TARGET_SAMPLES)/hap/HAPQA_Snappy_16chunk_127x1.mov -c copy -bsf:v hapqa_extract=texture=color -tag:v HapY -metadata:s:v:0 encoder="HAPQ"
+
+FATE_HAPQA_EXTRACT_BSF += fate-hapqa-extract-snappy1-to-hapalphaonly
+fate-hapqa-extract-snappy1-to-hapalphaonly: CMD = framemd5 -i $(TARGET_SAMPLES)/hap/HAPQA_Snappy_1chunk_127x1.mov -c copy -bsf:v hapqa_extract=texture=alpha -tag:v HapA -metadata:s:v:0 encoder="HAPAlphaOnly"
+
+FATE_HAPQA_EXTRACT_BSF += fate-hapqa-extract-snappy16-to-hapalphaonly
+fate-hapqa-extract-snappy16-to-hapalphaonly: CMD = framemd5 -i $(TARGET_SAMPLES)/hap/HAPQA_Snappy_16chunk_127x1.mov -c copy -bsf:v hapqa_extract=texture=alpha -tag:v HapA -metadata:s:v:0 encoder="HAPAlphaOnly"
+
+
+#Test bsf conversion and mov
+tests/data/hapq_nosnappy.mov: TAG = GEN
+tests/data/hapq_nosnappy.mov: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
+	$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
+	-i $(TARGET_SAMPLES)/hap/HAPQA_NoSnappy_127x1.mov -c copy -bsf:v hapqa_extract=texture=color \
+        -tag:v HapY -metadata:s:v:0 encoder="HAPQ" $(TARGET_PATH)/$@ -y 2>/dev/null
+
+tests/data/hapalphaonly_nosnappy.mov: TAG = GEN
+tests/data/hapalphaonly_nosnappy.mov: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
+	$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
+	-i $(TARGET_SAMPLES)/hap/HAPQA_NoSnappy_127x1.mov -c copy -bsf:v hapqa_extract=texture=alpha \
+        -tag:v HapA -metadata:s:v:0 encoder="HAPAlpha Only" $(TARGET_PATH)/$@ -y 2>/dev/null
+
+
+FATE_HAPQA_EXTRACT_BSF_FFPROBE += fate-hapqa-extract-nosnappy-to-hapq-mov
+fate-hapqa-extract-nosnappy-to-hapq-mov: tests/data/hapq_nosnappy.mov
+fate-hapqa-extract-nosnappy-to-hapq-mov: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -show_data_hash md5 -show_streams -select_streams v -v 0 $(TARGET_PATH)/tests/data/hapq_nosnappy.mov
+
+FATE_HAPQA_EXTRACT_BSF_FFPROBE += fate-hapqa-extract-nosnappy-to-hapalphaonly-mov
+fate-hapqa-extract-nosnappy-to-hapalphaonly-mov: tests/data/hapalphaonly_nosnappy.mov
+fate-hapqa-extract-nosnappy-to-hapalphaonly-mov: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -show_data_hash md5 -show_streams -select_streams v -v 0 $(TARGET_PATH)/tests/data/hapalphaonly_nosnappy.mov
+
+
+FATE_SAMPLES_AVCONV-$(call ALLYES, MOV_DEMUXER HAPQA_EXTRACT_BSF MOV_MUXER) += $(FATE_HAPQA_EXTRACT_BSF)
+FATE_SAMPLES_FFPROBE += $(FATE_HAPQA_EXTRACT_BSF_FFPROBE)
+
+fate-hapqa-extract-bsf: $(FATE_HAPQA_EXTRACT_BSF) $(FATE_HAPQA_EXTRACT_BSF_FFPROBE)
+
+
 fate-hapenc%: CMD = framemd5 -f image2 -c:v pgmyuv -i $(TARGET_PATH)/tests/vsynth1/%02d.pgm -sws_flags +accurate_rnd+bitexact -vframes 5 -c:v hap ${OPTS}
 
 FATE_HAPENC += fate-hapenc-hap-none
diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov
new file mode 100644
index 0000000000..c017868602
--- /dev/null
+++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov
@@ -0,0 +1,73 @@
+[PACKET]
+codec_type=video
+stream_index=0
+pts=0
+pts_time=0.000000
+dts=0
+dts_time=0.000000
+duration=512
+duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
+size=4612
+pos=36
+flags=K_
+data_hash=MD5:d57955a8cbec43d1113c2d9c525715a2
+[/PACKET]
+[STREAM]
+index=0
+codec_name=hap
+codec_long_name=Vidvox Hap
+profile=unknown
+codec_type=video
+codec_time_base=1/25
+codec_tag_string=HapA
+codec_tag=0x41706148
+width=127
+height=71
+coded_width=128
+coded_height=72
+has_b_frames=0
+sample_aspect_ratio=1:1
+display_aspect_ratio=127:71
+pix_fmt=gray
+level=-99
+color_range=unknown
+color_space=unknown
+color_transfer=unknown
+color_primaries=unknown
+chroma_location=unspecified
+field_order=unknown
+timecode=N/A
+refs=1
+id=N/A
+r_frame_rate=25/1
+avg_frame_rate=25/1
+time_base=1/12800
+start_pts=0
+start_time=0.000000
+duration_ts=512
+duration=0.040000
+bit_rate=922400
+max_bit_rate=N/A
+bits_per_raw_sample=N/A
+nb_frames=1
+nb_read_frames=N/A
+nb_read_packets=1
+extradata_hash=MD5:d41d8cd98f00b204e9800998ecf8427e
+DISPOSITION:default=1
+DISPOSITION:dub=0
+DISPOSITION:original=0
+DISPOSITION:comment=0
+DISPOSITION:lyrics=0
+DISPOSITION:karaoke=0
+DISPOSITION:forced=0
+DISPOSITION:hearing_impaired=0
+DISPOSITION:visual_impaired=0
+DISPOSITION:clean_effects=0
+DISPOSITION:attached_pic=0
+DISPOSITION:timed_thumbnails=0
+TAG:language=eng
+TAG:handler_name=DataHandler
+TAG:encoder=HAPAlpha Only
+[/STREAM]
diff --git a/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov
new file mode 100644
index 0000000000..79d83ed540
--- /dev/null
+++ b/tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov
@@ -0,0 +1,73 @@
+[PACKET]
+codec_type=video
+stream_index=0
+pts=0
+pts_time=0.000000
+dts=0
+dts_time=0.000000
+duration=512
+duration_time=0.040000
+convergence_duration=N/A
+convergence_duration_time=N/A
+size=9220
+pos=36
+flags=K_
+data_hash=MD5:0551b4b86c0c0e47ed1b80b4ae855d34
+[/PACKET]
+[STREAM]
+index=0
+codec_name=hap
+codec_long_name=Vidvox Hap
+profile=unknown
+codec_type=video
+codec_time_base=1/25
+codec_tag_string=HapY
+codec_tag=0x59706148
+width=127
+height=71
+coded_width=128
+coded_height=72
+has_b_frames=0
+sample_aspect_ratio=1:1
+display_aspect_ratio=127:71
+pix_fmt=rgb0
+level=-99
+color_range=unknown
+color_space=unknown
+color_transfer=unknown
+color_primaries=unknown
+chroma_location=unspecified
+field_order=unknown
+timecode=N/A
+refs=1
+id=N/A
+r_frame_rate=25/1
+avg_frame_rate=25/1
+time_base=1/12800
+start_pts=0
+start_time=0.000000
+duration_ts=512
+duration=0.040000
+bit_rate=1844000
+max_bit_rate=N/A
+bits_per_raw_sample=N/A
+nb_frames=1
+nb_read_frames=N/A
+nb_read_packets=1
+extradata_hash=MD5:d41d8cd98f00b204e9800998ecf8427e
+DISPOSITION:default=1
+DISPOSITION:dub=0
+DISPOSITION:original=0
+DISPOSITION:comment=0
+DISPOSITION:lyrics=0
+DISPOSITION:karaoke=0
+DISPOSITION:forced=0
+DISPOSITION:hearing_impaired=0
+DISPOSITION:visual_impaired=0
+DISPOSITION:clean_effects=0
+DISPOSITION:attached_pic=0
+DISPOSITION:timed_thumbnails=0
+TAG:language=eng
+TAG:handler_name=DataHandler
+TAG:encoder=HAPQ
+[/STREAM]
diff --git a/tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly b/tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly
new file mode 100644
index 0000000000..7a59d4fac7
--- /dev/null
+++ b/tests/ref/fate/hapqa-extract-snappy1-to-hapalphaonly
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: hap
+#dimensions 0: 127x71
+#sar 0: 1/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,     3044, 0b7886b80fb4eb897ac6ad5c1519908a
diff --git a/tests/ref/fate/hapqa-extract-snappy1-to-hapq b/tests/ref/fate/hapqa-extract-snappy1-to-hapq
new file mode 100644
index 0000000000..a008b3669a
--- /dev/null
+++ b/tests/ref/fate/hapqa-extract-snappy1-to-hapq
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: hap
+#dimensions 0: 127x71
+#sar 0: 1/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,     8217, e4cd2d1298ee95e45d30964eadffa65c
diff --git a/tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly b/tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly
new file mode 100644
index 0000000000..f922a1348c
--- /dev/null
+++ b/tests/ref/fate/hapqa-extract-snappy16-to-hapalphaonly
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: hap
+#dimensions 0: 127x71
+#sar 0: 1/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,     3513, 94f4ae543939c63a82be8f3a076faa60
diff --git a/tests/ref/fate/hapqa-extract-snappy16-to-hapq b/tests/ref/fate/hapqa-extract-snappy16-to-hapq
new file mode 100644
index 0000000000..261254876d
--- /dev/null
+++ b/tests/ref/fate/hapqa-extract-snappy16-to-hapq
@@ -0,0 +1,10 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: hap
+#dimensions 0: 127x71
+#sar 0: 1/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,     8726, 2a14fcb413db8b29d9d1ed1ce90922fa
-- 
2.14.3 (Apple Git-98)

