Fewer than 4 huffman tables in a JPEG file? - jpeg

So I've been attempting to write my own JPEG decoder (In Lua for the ROBLOX platform if that's of any use) and in every guide I find online, it always uses an example where the image has 4 distinct Huffman tables. 1 for DC Luminance, 1 for AC Luminance, 1 for DC Chrominance, and 1 for AC Chrominance. When this is the case, my decoder works fine and everything is happy and nice. However when trying to decode some random jpeg images off the internet, I find that a lot of them have fewer than 4 Huffman tables, and in these cases my decoder fails miserably. I've tried researching for if there are some standard Huffman tables I should use as defaults for when the other tables aren't present, or if I should instead use a duplicate of one of the tables as a replacement for the missing ones, but I have come up empty handed. Any help on the subject would be greatly appreciated, thank you!

Okay so thank you to DaBler in explaining this to me in the comments on my original question, it was extremely helpful.
Apparently you can have multiple Huffman Tables under one DHT marker, which I did not know. I'll see if I can get it working and thank you for the help!

Related

find an altered image from the original image data set

Here is my problem:
I must match two images. One image from the project folder and this folder have over 20.000 images. The other one is from a camera.
What I have done?
I can compare images with basic OpenCV example codes that I found in the documentation. OpenCV Doc I can also compare and find an image by using the hash of my image data set. It is so fast and it is only suitable for 2 exact images. One for query the other one is the target. But they are the same exact image.
So, I need something as reliable as feature matching and as fast as hash methods. But I can't use machine learning or anything on that level. It should be basic. Plus, I'm new to these stuff. So, my term project is on risk.
Example scenario:
If I ever take a picture of an image in my image data set from my computer's screen. This would change many features of the original image. In the case of defining what's in that image, a human won't struggle much but a comparison algorithm will struggle. Such a case leaves lot's of basic comparison algorithm out of the game. But, a machine-learning algorithm could solve the problem but it's forbidden to use in my project.
Needs:
It must be fast.
It must be accurate.
It must be easy to understand.
Any help is okay. A piece of code, maybe an article or a tutorial. Even an advice or a topic title might be really helpful to me.
Once saw this camera model identification challenge on kaggle. This notebook discusses about noise pattern changes with changing devices. May be you should look in to this and other notebooks in that challenge. Thanks!

Reading and understanding a raw audio file(specifically MP3)

I am trying to understand what the raw data from an audio file looks like and how to get that data. I want to take the data and analyze it and see if I am able to make a program that can recognize patterns in a song such as in a hip hop song, finding the same beat in a chorus. In my head I think this could be a doable task if the data is in an integer form.
I've looked up many tutorials for this but all the tutorials use other libraries or don't explain it in a way I understand(more than likely the source of my issue).
I am wondering if there is someone out there that can help me understand a few things.
1). In an MP3 file, what is actually being stored in the file. Is it an integer that tells the radio/amp/audioPlayer a frequency, another integer for amplitude, etc...(over simplified because I don't know what other data is stored in an audio file).
2). If it is stored in an integer format, is there a way to read the integers and analyze it. If it is not stored in an integer format, how is it stored, and is there a way to convert it to an integer format?
3). In visual representations of an audio files like this one, it seems more clear what is what. It seems like the frequency is where on the circle the audio is represented, and the amplitude is how high it jumps. Is this right? Or does it just appear that way and I am understanding it incorrectly.
4). Is this task harder than I think it is? Considering I haven't found any good explanations or tutorials on how to do so, I am skeptical on how easy this would be.
(Sorry if this was poorly phrased, first question on stack and I am just illiterate :^)

Extract encoded message in WAV file

I've got a .wav file with a perfect square wave (PCM data with only "FF" or "00" bytes) and I'm positive there is some kind of encoded message in it.
I've tried everything I could think of to extract the encoded message in the file. From steganography to several different encoding schemes like NRZ, Manchester, Differential Manchester and got nothing.
I'm three days into analysis of the file and driving mad by now.
Can any of you think of some way (or software) that can perform any kind of analysis on uncompressed pcm data?
P.S.: The decoding of the file is part of a quiz with various steps and that is the reason I would rather not post the file or ask for a direct answer.
I want to get there myself, just needing someone pointing me in a new direction or fresh thoughts about the problem! :D
In te meanwhile I got some invaluable help and figured out it was a tape from a zx spectrum in form of a .wav file.
So all it took was downloading some emulator and loading the tape (.wav file)!
But thank you so much for helping Mike! :D

Reading jpeg image using c/c++

How to read the pixel values of jpeg image using c/c++, without using any library.
I read about how compression takes place in jpeg in my course,i want header information.
For the syntax of the file you can check wikipedia.
Each segment has its own marker. The variable length segments have a two byte field for their length. So far is not really a problem, as you are able to extract all segments using this information (or at least it seems so on a first glance).
The more problematic part is to actually do something useful with the data inside the segments. The wikipedia page provides information on this topic, but it will require quite some mathematic knowledge to actually decode and grab the pixels.
Finally found some really helpful links..
link 1
link 2
Thanks for help and support.

Progressive huffman table

Do anyone of you know of a defacto standard huffman table for progressive jpeg encoding? There's examples of tables for baseline encoding in the standard that a lot of implementations use that seem to be adequate for most uses in regards of symbol frequency and so on but I can't seem to find one for progressive encoding that includes the symbols EOB1 through EOB14.
I am not aware of such a table. The approach is to do two passes over the data and find the best table for the scan in questions.

Resources