@ubuntu:/usr/src/jetson_multimedia_api/samples/06_jpeg_decode$ ./jpeg_decode num_files 1 ~/1545211199813.jpg ~/1.yuv
Improper call to JPEG library in state 205
It’s JP4.6.3
@ubuntu:/usr/src/jetson_multimedia_api/samples/06_jpeg_decode$ ./jpeg_decode num_files 1 ~/1545211199813.jpg ~/1.yuv
Improper call to JPEG library in state 205
It’s JP4.6.3
Hi,
Hardware decoder does not support this type of JPEG. By decoding it on Xavier/Jetpack 5.1.2, it shows the error:
ReadFrameInfo: 634: HW doesn't support progressive decode
[JPEG Decode] Unsupported JPEG file
Block Error Event recieved : 0x2
For Jetpack 4 releases, the error message may not be well printed.
How to know it can not decode the picture? decodeToFd always return >0
Hi,
A possible solution is to add check for inspecting the JPEG files. If it is progressive JPEGs, not to feed into hardware decoder. We will check this.
Some discussion about detecting progressive JPEGs is in
Detecting Progressive JPEG | TechSlides
Hi,
please apply this patch so the APP will exit correctly when fed with unsupported files:
diff --git a/multimedia_api/ll_samples/samples/06_jpeg_decode/jpeg_decode_main.cpp b/multimedia_api/ll_samples/samples/06_jpeg_decode/jpeg_decode_main.cpp
index a75f282..5089dd5 100644
--- a/multimedia_api/ll_samples/samples/06_jpeg_decode/jpeg_decode_main.cpp
+++ b/multimedia_api/ll_samples/samples/06_jpeg_decode/jpeg_decode_main.cpp
@@ -45,6 +45,47 @@
using namespace std;
+static bool
+is_supported_type(ifstream * stream)
+{
+
+ bool ret;
+ unsigned char bytes[2];
+ unsigned int size;
+
+ while (true)
+ {
+ stream->read(reinterpret_cast<char*>(bytes), 2);
+
+ if (bytes[0] != 0xff)
+ {
+ ret = false;
+ break;
+ }
+ else if (bytes[0] == 0xff && bytes[1] == 0xd8)
+ continue;
+ else if (bytes[0] == 0xff && bytes[1] == 0xc0)
+ {
+ ret = true;
+ break;
+ }
+ else if (bytes[0] == 0xff && bytes[1] == 0xc2)
+ {
+ ret = false;
+ break;
+ }
+ else
+ {
+ stream->read(reinterpret_cast<char*>(bytes), 2);
+ size = bytes[0] * 256 + bytes[1];
+ stream->seekg(size - 2, stream->cur);
+ }
+ }
+
+ stream->seekg(0, stream->beg);
+ return ret;
+}
+
static uint64_t
get_file_size(ifstream * stream)
{
@@ -100,6 +141,8 @@
ctx.in_file[i] = new ifstream(ctx.in_file_path[i]);
TEST_ERROR(!ctx.in_file[i]->is_open(), "Could not open input file", cleanup);
+ TEST_ERROR(!is_supported_type(ctx.in_file[i]), "Unsupported file type", cleanup);
+
ctx.out_file[i] = new ofstream(ctx.out_file_path[i]);
TEST_ERROR(!ctx.out_file[i]->is_open(), "Could not open output file", cleanup);
}
I see. Thank you anyway. I have used the opencv to decode jpeg. ^_^
I hope you do it like that in the library for the next verison, if the function can not decode JPEG to FD and return -1 the error and then I will decode it to the buffer.
The compatibility will be better.
Thanks!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.