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; }
12 gst-launch-1.0 videotestsrc num-buffers=1 ! video/x-raw,width=996,height=784 ! jpegenc ! filesink location=videotest.jpg
13 INPUT_FILE="videotest.jpg"
19 SAMPLINGS["NORMAL_420"]="2x2,1x1,1x1"
20 SAMPLINGS["NORMAL_422"]="2x1,1x1,1x1"
21 SAMPLINGS["NORMAL_444"]="1x1,1x1,1x1"
22 SAMPLINGS["WEIRD_422"]="2x2,1x2,1x2"
23 SAMPLINGS["WEIRDER_422"]="2x2,2x1,2x1"
25 for sampling in "${!SAMPLINGS[@]}";
27 BASE_NAME="${INPUT_FILE##/*}"
28 RESAMPLED_BASE_NAME="${BASE_NAME%.*}_${sampling}"
30 RESAMPLED_FILE="${RESAMPLED_BASE_NAME}.jpg"
31 djpeg "$INPUT_FILE" | cjpeg -sample "${SAMPLINGS[$sampling]}" > "$RESAMPLED_FILE"
33 DECODED_RESAMPLED_FILE="decoded_${RESAMPLED_BASE_NAME}_jpegdec.png"
34 gst-launch-1.0 filesrc location="$RESAMPLED_FILE" ! jpegparse ! jpegdec ! videoconvert ! pngenc ! filesink location="$DECODED_RESAMPLED_FILE" || :
36 DECODED_RESAMPLED_FILE="decoded_${RESAMPLED_BASE_NAME}_avdec_mjpeg.png"
37 gst-launch-1.0 filesrc location="$RESAMPLED_FILE" ! jpegparse ! avdec_mjpeg ! videoconvert ! pngenc ! filesink location="$DECODED_RESAMPLED_FILE" || :
39 DECODED_RESAMPLED_FILE="decoded_${RESAMPLED_BASE_NAME}_djpeg.bmp"
40 djpeg -bmp "$RESAMPLED_FILE" > "$DECODED_RESAMPLED_FILE"