3 # Test to check that jpegdec handles different chroma sub-samplings right.
7 command -v djpeg &> /dev/null || { echo "djpeg needed, should be in libjpeg-turbo-progs." 1>&2; exit 1; }
8 command -v cjpeg &> /dev/null || { echo "cjpeg needed, should be in libjpeg-turbo-progs." 1>&2; exit 1; }
14 gst-launch-1.0 videotestsrc num-buffers=1 ! "video/x-raw,width=${WIDTH},height=${HEIGHT}" ! jpegenc ! filesink location=videotest.jpg
15 INPUT_FILE="videotest.jpg"
21 # 4:1:0 is ambiguous, see https://blog.awm.jp/2016/02/10/yuv/
22 SAMPLINGS["NORMAL_410"]="4x2,1x1,1x1"
23 SAMPLINGS["NORMAL_411"]="4x1,1x1,1x1"
24 SAMPLINGS["NORMAL_420"]="2x2,1x1,1x1"
25 SAMPLINGS["NORMAL_422"]="2x1,1x1,1x1"
26 SAMPLINGS["NORMAL_440"]="1x2,1x1,1x1"
27 SAMPLINGS["NORMAL_444"]="1x1,1x1,1x1"
28 SAMPLINGS["WEIRD_422"]="2x2,1x2,1x2"
29 SAMPLINGS["WEIRD_440"]="2x2,2x1,2x1"
31 for sampling in "${!SAMPLINGS[@]}";
33 BASE_NAME="${INPUT_FILE##/*}"
34 RESAMPLED_BASE_NAME="${BASE_NAME%.*}_${sampling}"
36 RESAMPLED_FILE="${RESAMPLED_BASE_NAME}.jpg"
37 djpeg "$INPUT_FILE" | cjpeg -sample "${SAMPLINGS[$sampling]}" > "$RESAMPLED_FILE"
39 DECODED_RESAMPLED_FILE="decoded_${RESAMPLED_BASE_NAME}_jpegdec.png"
40 gst-launch-1.0 filesrc location="$RESAMPLED_FILE" ! jpegparse ! jpegdec ! videoconvert ! pngenc ! filesink location="$DECODED_RESAMPLED_FILE" || :
42 DECODED_RESAMPLED_FILE="decoded_${RESAMPLED_BASE_NAME}_avdec_mjpeg.png"
43 gst-launch-1.0 filesrc location="$RESAMPLED_FILE" ! jpegparse ! avdec_mjpeg ! videoconvert ! pngenc ! filesink location="$DECODED_RESAMPLED_FILE" || :
45 DECODED_RESAMPLED_FILE="decoded_${RESAMPLED_BASE_NAME}_djpeg.bmp"
46 djpeg -bmp "$RESAMPLED_FILE" > "$DECODED_RESAMPLED_FILE"