Rockbox Technical Forums

Support and General Use => Plugins/Viewers => Topic started by: James_Horgan on January 19, 2017, 11:26:51 PM

Title: Can't open .jpg's
Post by: James_Horgan on January 19, 2017, 11:26:51 PM
Hello,
I just got Rockbox on my iPod video (5th gen), and promptly loaded some music and image file onto it. All was fine until I tried to open some of the images. The pictures would not load, and I got the error "unsupported -4". Naturally, I assumed that the problem was with the image, so I loaded up some more. Still no luck. Maybe all of the picture were messed up? They all loaded just fine on my computer. Does anybody know why this isn't working? Am I missing something obvious?
Any help is appreciated,
James
Title: Re: Can't open .jpg's
Post by: saratoga on January 20, 2017, 12:39:09 AM
Some of the more uncommon jpeg variants are not supported.
Title: Re: Can't open .jpg's
Post by: gevaerts on January 20, 2017, 06:06:43 AM
Some of the more uncommon jpeg variants are not supported.

In particular, one of the more common unsupported variants is progressive jpeg
Title: Re: Can't open .jpg's
Post by: Jason Arthur Taylor on January 24, 2017, 09:37:25 PM
Mr. Horgan, it is a little annoying that rockbox, given it's alleged dynamic nature, doesn't display some modern mp3, jpg, and mpeg files properly.  But, as a workaround, for the mp3 files you can run this .bat file

Code: [Select]
for /f "usebackq delims=" %%m in ( ` dir /s /b *.mp3 ` ) do (
 echo Processing %%m...
 call fixmp3single.bat "%%m"
 rename "%%~fm" "%%~nm-original-pleasedeleteme%%~xm"
 rem Below I am using mv, but you might need to use move instead if you don't have this
 rem on your system.
 mv -v tmp.mp3 "%%~fm"
 del tmp-np.jpg
 del tmp.jpg
)
echo After testing, you can type "del /s *pleasedeleteme*" to remove the original mp3 files.

which relies upon this batch file

Code: [Select]
echo This batch file fixes album art from whatever format to something older mp3 players can probably display.
echo It requires that you install ffmpeg and irfanview.  Here I assume your path includes whereever they were installed.  If now, edit below to include it.
echo You may need to edit an irfanview default option file for saving jpg files to be non-progressive, but this worked for me without this, so I don't know for sure.
echo To do multiple files or entire drives use the fixmp3.bat file.
echo This was written by Jason Arthur Taylor ( jasontaylor.us ) but plenty of code was borrowed from others who posted on the internet.
echo usage: The argument is the single mp3 file that you need fixed.
ffmpeg -i %1 tmp.jpg
i_view32.exe tmp.jpg /convert=tmp-np.jpg
ffmpeg -i %1 -i tmp-np.jpg -map 0:0 -map 1:0 -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" tmp.mp3
,

and ffmpeg https://ffmpeg.org/download.html and irfanview http://www.irfanview.com/ , but to make it easier I have added these two above batch files as attachments as well.  So just right click and download.  Due to restrictions here, I was forced to rename the files.  Remove the .txt extensions.  They should do a whole drive at time.

For the image files, you can use the above line with i_view32.exe and the concepts in the above batch files, but because there are a ton of batch image manipulation programs and I'm lazy, I won't write the equivalent of those batch files here.

I hope that helps some.
Title: Re: Can't open .jpg's
Post by: saratoga on January 25, 2017, 12:09:07 AM
Mr. Horgan, it is a little annoying that rockbox, given it's alleged dynamic nature, doesn't display some modern mp3, jpg, and mpeg files properly.

I think you'll struggle to find many valid mp3 files that don't play at this point, but the problem with JPG and MPEG is that you can't reasonably decode all variants of those formats given the available memory and CPU on a lot of targets.  Fortunately, the more memory intensive jpeg variants are almost never used in practice. 
Title: Re: Can't open .jpg's
Post by: Jason Arthur Taylor on January 28, 2017, 11:03:01 PM
Saratoga, you implied I wrote that mp3 files won't play, but I said "play properly." Only the latter probably encompasses displaying the album art, which is included to be displayable to the viewer.

You also wrote,

"Fortunately, the more memory intensive jpeg variants are almost never used in practice."

I disagree.  Progressive is the default in some image software programs.  And, I mean, I didn't write those scripts to waste time, and the op isn't the only one who has posted about this.  It is a common thread around here. 

Regarding ram usage of progressive jpgs, I, of course, disagree with you all, as usual.  See, e.g., https://www.linkedin.com/pulse/low-memory-progressive-jpeg-decoding-giles-payne , which states, in part,

"I was sure that there must be another way to decode these images without using hundreds of megabytes of RAM and so I came up with my low memory progressive-mode JPEG decode implementation.

How the implementation works

Two passes are used to decode progressive mode JPEGs. The first determines the locations of each of the scans; the second does the actual decoding.

Pass Number One - reads through the file to determine the location of all the "start of scan" markers. Initializes a "scan context" for each scan.
Pass Number Two - restores the scan context of the first scan, reads one row of MCUs, saves the updated scan context for the first scan. Repeats for the second scan and all subsequent scans until a complete row of MCUs is decoded. Outputs the completed row of MCUs and repeats for the second row of MCUs etc. The implementation relies on the data source being "seekable" where as the original libjpeg does not. A "check_seekable" method has been added in the jpeg_source_mgr to check for working implementations of the standard C library seek/tell functions." 

He then specific gives examples in which ram required to process progressive jpgs went down by factors as high as ~400.  (It probably scales with image size, so smaller images probably wouldn't get that kind of benefit.)  The code is already in c, so it shouldn't be too much work to swap out the prior code.  On the other hand, that would be a little work, and I'd guess it probably won't happen, especially since, according to Paul's recent email to me, nobody here is capable of getting any of the paypal donation money, the amount of which is unknown anyway.
Title: Re: Can't open .jpg's
Post by: __builtin on January 29, 2017, 03:50:42 PM
The code is already in c, so it shouldn't be too much work to swap out the prior code.  On the other hand, that would be a little work, and I'd guess it probably won't happen, especially since, according to Paul's recent email to me, nobody here is capable of getting any of the paypal donation money, the amount of which is unknown anyway.

None of us are paid to work on Rockbox. If you want to see a feature added, you'll have to either to do it yourself or find an interested dev, which is unlikely.
Title: Re: Can't open .jpg's
Post by: saratoga on January 29, 2017, 06:56:02 PM
If you think you can get progressive jpeg decoding working, go for it. I think it will be very hard given the constraints, but maybe you can find something that other people have overlooked.