intel / libyami

Yet Another Media Infrastructure. it is core part of media codec with hardware acceleration, it is yummy to your video experience on Linux like platform.
Apache License 2.0
146 stars 106 forks source link

duplicate EOI error when decoding MJPEG from certain usb camera #832

Closed LindaYu17 closed 6 years ago

LindaYu17 commented 6 years ago

We got “duplicate EOI” error when decoding MJPEG from certain kind of usb camera, not every frame, maybe about 10% frames. Is is reasonable to ignore the second EOI? By the way, simply ignore this error as below will cause decode current frame twice, because onMarker() M_EOI will be invoke twice.

diff --git a/codecparsers/jpegParser.cpp b/codecparsers/jpegParser.cpp index e5cd4db..4a6029a 100644 --- a/codecparsers/jpegParser.cpp +++ b/codecparsers/jpegParser.cpp @@ -643,8 +643,8 @@ bool Parser::parseSOS() bool Parser::parseEOI() { if (m_sawEOI) {

LindaYu17 commented 6 years ago

This is the failed frame.

fail-frame

uartie commented 6 years ago

I don't think it's a good idea for libyami jpeg parser/decoder to ignore the second EOI... it is technically a corrupt image at this level of parsing/decoding. Ideally, your application should be responsible for properly splitting the input stream into separate jpeg image buffers to follow spec. Unfortunately, yamidecode test/example application in libyami-utils will not detect the jpeg frame boundaries properly in this case. For special cases like this, you'll need to create your own app to deal with this type of non-standard data (i.e. throw out the invalid data before passing it on to libyami to decode).