GNOME Bugzilla – Bug 763745
Can not decode jpeg without huffman tables.
Last modified: 2018-05-07 15:45:57 UTC
I use rpi and uvc camera that streams jpeg without huffman tables. So, if I use jpegdec all looks good, because jpegdec adds standard huffman tables to jpeglib decoder, if I use omxjpegdec, I receives message "No valid frames decoded before end of stream". Version of gstreamer is 1.6.3 and gst-omx is at master commit with hash 705d7722fbe05da17f2bedfdc34476382687c95f. Log of gstreamer decoding pipe: rpi grabber # GST_DEBUG=omxmjpegdec:5 gst-launch-1.0 -e v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg,width=640,height=480,framerate=30/1 ! videorate ! omxmjpegdec ! fakesink Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock ^Chandling interrupt. Interrupt: Stopping pipeline ... EOS on shutdown enabled -- Forcing EOS on the pipeline Waiting for EOS... ERROR: from element /GstPipeline:pipeline0/GstOMXMJPEGDec-omxmjpegdec:omxmjpegdec-omxmjpegdec0: No valid frames decoded before end of stream Additional debug info: /var/tmp/portage/media-libs/gst-plugins-base-1.6.3/work/gst-plugins-base-1.6.3/gst-libs/gst/video/gstvideodecoder.c(1256): gst_video_decoder_sink_event_default (): /GstPipeline:pipeline0/GstOMXMJPEGDec-omxmjpegdec:omxmjpegdec-omxmjpegdec0: no valid frames found An error happened while waiting for EOS Execution ended after 0:00:08.259984000 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... Log of gstreamer grabbing pipe and hexdump of first jpeg file: rpi grabber # rm -rf video-* rpi grabber # gst-launch-1.0 -e v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg,width=640,height=480,framerate=30/1 ! videorate ! multifilesink location=video-%d.jpeg Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock ^Chandling interrupt. Interrupt: Stopping pipeline ... EOS on shutdown enabled -- Forcing EOS on the pipeline Waiting for EOS... Got EOS from element "pipeline0". EOS received - stopping pipeline... Execution ended after 0:00:06.504037000 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... rpi grabber # hexdump -C -n 1024 video-0.jpeg 00000000 ff d8 ff e0 00 21 41 56 49 31 00 01 01 01 00 78 |.....!AVI1.....x| 00000010 00 78 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |.x..............| 00000020 00 00 00 00 00 ff db 00 43 00 04 02 03 03 03 02 |........C.......| 00000030 04 03 03 03 04 04 04 04 06 0a 06 06 05 05 06 0c |................| 00000040 08 09 07 0a 0e 0c 0f 0f 0e 0c 0e 0f 10 12 17 13 |................| 00000050 10 11 15 11 0d 0e 14 1a 14 15 17 18 19 1a 19 0f |................| 00000060 13 1c 1e 1c 19 1e 17 19 19 18 ff db 00 43 01 04 |.............C..| 00000070 04 04 06 05 06 0b 06 06 0b 18 10 0e 10 18 18 18 |................| 00000080 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 |................| * 000000a0 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 ff |................| 000000b0 dd 00 04 00 0a ff e0 00 04 00 00 ff c0 00 11 08 |................| 000000c0 01 e0 02 80 03 01 21 00 02 11 01 03 11 01 ff da |......!.........| 000000d0 00 0c 03 01 00 02 11 03 11 00 3f 00 f8 a9 63 6c |..........?...cl| 000000e0 72 6a 75 dc 70 49 38 03 00 56 28 d1 0f 55 cd 28 |rju.pI8..V(..U.(| 000000f0 52 c0 73 f8 d3 60 9d 81 93 1d 4f 14 cc 71 c7 7a |R.s..`....O..q.z| 00000100 34 02 07 4f 9f 8c f1 4d 75 eb c6 28 1a 19 2a 7f |4..O...Mu..(..*.| 00000110 91 50 91 81 c8 a1 05 c8 c8 a8 9c 7a 53 24 61 f5 |.P.........zS$a.| 00000120 a6 1a 61 d4 69 1c 52 1e 05 20 10 fd 28 a0 4e e2 |..a.i.R.. ..(.N.| 00000130 51 8a 69 d8 96 cf ff d0 f8 32 83 40 09 45 00 14 |Q.i......2.@.E..| 00000140 50 01 45 00 14 50 01 45 00 02 8a 00 28 a0 02 8a |P.E..P.E....(...| 00000150 00 28 a0 0f ff d1 f8 2e 8a 00 05 14 00 51 40 05 |.(...........Q@.| 00000160 14 00 51 40 05 14 00 51 40 05 14 00 51 40 05 15 |..Q@...Q@...Q@..| 00000170 0d dc 0f ff d2 f8 2e 8a 49 80 51 4c 02 8a 00 28 |........I.QL...(| 00000180 a0 02 81 40 08 29 68 00 a2 80 0e d4 50 01 45 00 |...@.)h.....P.E.| 00000190 14 52 b8 1f ff d3 f8 c4 47 c0 e6 a4 55 39 03 15 |.R......G...U9..| 000001a0 91 ad 87 85 20 f0 78 a7 05 e2 84 16 5b 83 28 2b |.... .x.....[.(+| 000001b0 92 69 8c bc 0a 5b 0a c3 19 0e 39 14 c7 8c e2 8b |.i...[....9.....| 000001c0 8d 24 36 68 f2 a0 0e d5 52 45 e0 fa 8a 10 99 13 |.$6h....RE......| 000001d0 2f 15 13 2d 52 02 32 2a 32 28 10 84 66 9a 46 0d |/..-R.2*2(..f.F.| 000001e0 01 70 34 dc 50 02 52 d0 41 ff d4 f8 32 83 50 9d |.p4.P.R.A...2.P.| 000001f0 80 0e 29 2a c0 28 a0 02 8a 00 28 a0 02 8a 00 28 |..)*.(....(....(| 00000200 a0 02 8a 00 28 a0 02 81 40 1f ff d5 f8 33 14 94 |....(...@....3..| 00000210 00 a3 a5 18 e6 80 03 d2 92 80 0a 28 00 fc 28 a0 |...........(..(.| 00000220 02 8a 00 28 a0 02 8a 00 0f 4a 2a 1b 00 a2 90 1f |...(.....J*.....| 00000230 ff d6 f8 2e 8a cc 02 8a b4 c0 28 a6 01 45 00 14 |..........(..E..| 00000240 50 01 45 00 14 50 01 45 00 14 52 6c 02 8a 80 3f |P.E..P.E..Rl...?| 00000250 ff d7 f8 d4 2d 4a 8a 71 9c e3 eb 59 5e c6 96 1e |....-J.q...Y^...| 00000260 b1 e7 ad 38 2f 18 a4 16 18 50 90 72 31 48 aa 70 |...8/....P.r1H.p| 00000270 78 e9 46 e3 68 51 19 3c 91 8f 6a 46 4e d4 6c 2b |x.F.hQ.<..jFN.l+| 00000280 11 3a 63 ad 53 b8 8f 93 8e 45 17 0b 15 dd 70 3a |.:c.S....E....p:| 00000290 d4 4c 30 29 a6 04 4e 2a 32 29 88 69 1c 03 41 e4 |.L0)..N*2).i..A.| 000002a0 50 16 1a 45 34 8a 00 43 45 04 f2 9f ff d0 f8 30 |P..E4..CE......0| 000002b0 d1 59 80 73 40 a6 9d 80 0d 25 58 0a 05 25 00 14 |.Y.s@....%X..%..| 000002c0 50 01 45 00 14 50 01 45 00 14 50 01 45 00 7f ff |P.E..P.E..P.E...| 000002d0 d1 f8 2e 97 14 00 80 50 68 01 48 38 06 8e f4 93 |.......Ph.H8....| 000002e0 00 3d 68 e2 98 00 cd 25 00 14 50 01 45 00 14 54 |.=h....%..P.E..T| 000002f0 36 01 45 20 03 45 00 7f ff d2 f8 2e 8a cc 02 8a |6.E .E..........| 00000300 00 28 ab 4c 02 8a 60 14 50 00 28 a0 02 8a 00 3b |.(.L..`.P.(....;| 00000310 51 49 b0 0a 2a 00 28 a0 0f ff d3 f8 e4 2e 46 47 |QI..*.(.......FG| 00000320 19 a9 23 07 af 51 58 a3 42 41 d7 9a 70 a3 71 a1 |..#..QX.BA..p.q.| 00000330 a7 ae 3b 52 6d c9 eb 43 56 06 c7 85 04 73 48 cb |..;Rm..CV....sH.| 00000340 8e 4f 5a 57 11 0c ab c6 45 56 91 46 08 c0 cf 5a |.OZW....EV.F...Z| 00000350 77 19 4e 64 2a 7a 54 0e 3d 68 42 4e c4 4c b5 1b |w.Nd*zT.=hBN.L..| 00000360 03 9a a0 18 47 34 83 3d a9 88 42 29 a4 73 40 0d |....G4.=..B).s@.| 00000370 20 e2 92 90 1f ff d4 f8 37 8a 4a cc 03 14 1a 00 | .......7.J.....| 00000380 4a 29 a6 01 45 58 05 14 00 51 40 05 14 00 51 40 |J)..EX...Q@...Q@| 00000390 05 14 00 51 40 1f ff d5 f8 2c d2 f6 a0 03 8c 52 |...Q@....,.....R| 000003a0 54 36 02 e4 50 29 00 51 8e 2a d3 00 a3 de 98 09 |T6..P).Q.*......| 000003b0 45 00 14 76 a8 6c 02 8a 40 14 50 01 45 00 7f ff |E..v.l..@.P.E...| 000003c0 d6 f8 2e 8a cc 02 8a 00 28 a0 02 8a b4 c0 28 a6 |........(.....(.| 000003d0 01 45 00 14 0a 4d 80 0a 2a 00 28 a0 02 8a 00 ff |.E...M..*.(.....| 000003e0 00 ff d7 f8 ed 47 18 cf 02 a4 43 db b5 63 63 42 |.....G....C..ccB| 000003f0 45 03 b1 a7 20 f5 34 87 a8 8c 3e 6c 0a 40 0e ed |E... .4...>l.@..| 00000400
Created attachment 324089 [details] First jpeg file.
So omxjpegdec should get the same code that jpegdec has for the huffman tables.
Please, look at add_huff_table, std_huff_tables and guarantee_huff_tables functions in gstjpegdec.c file.
I am trying to write some code to fix the problem. Example looks like: diff --git a/omx/gstomxmjpegdec.c b/omx/gstomxmjpegdec.c index 8e704ae..5eaa904 100644 --- a/omx/gstomxmjpegdec.c +++ b/omx/gstomxmjpegdec.c @@ -83,6 +83,54 @@ gst_omx_mjpeg_dec_is_format_change (GstOMXVideoDec * dec, return FALSE; } +static void guarantee_huff_tables(GstOMXVideoDec * dec) +{ + GstOMXMJPEGDec *self = GST_OMX_MJPEG_DEC (dec); + OMX_ERRORTYPE err; + OMX_IMAGE_PARAM_HUFFMANTTABLETYPE param_huffman_table; + + static const guint8 bit_ac_luminance[] = + { 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + static const guint8 val_ac_luminance[] = + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa + }; + + GST_OMX_INIT_STRUCT (¶m_huffman_table); + param_huffman_table.nPortIndex = GST_OMX_VIDEO_DEC (self)->dec_in_port->index; + param_huffman_table.eHuffmanTable = OMX_IMAGE_HuffmanTableACLuma; + memcpy(param_huffman_table.nNumberOfHuffmanCodeOfLength, bit_ac_luminance, sizeof(bit_ac_luminance)); + memcpy(param_huffman_table.nHuffmanTable, val_ac_luminance, sizeof(val_ac_luminance)); + + GST_DEBUG_OBJECT (self, "Port %d", param_huffman_table.nPortIndex); + + err = gst_omx_component_set_parameter (GST_OMX_VIDEO_DEC (self)->dec, OMX_IndexParamHuffmanTable, ¶m_huffman_table); + if (err != OMX_ErrorNone) { + GST_DEBUG_OBJECT (self, "Error %s (0x%08x)", gst_omx_error_to_string (err), err); + } else { + GST_DEBUG_OBJECT (self, "Ok"); + } +} + static gboolean gst_omx_mjpeg_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, GstVideoCodecState * state) @@ -94,5 +142,7 @@ gst_omx_mjpeg_dec_set_format (GstOMXVideoDec * dec, GstOMXPort * port, port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingMJPEG; ret = gst_omx_port_update_port_definition (port, &port_def) == OMX_ErrorNone; + guarantee_huff_tables (dec); + return ret; } If I try to set the table using gst_omx_component_set_parameter function it returns "Error Unsupported index (0x8000101a)". If I try to get the table using gst_omx_component_get_parameter it returns "Error Hardware (0x80001009)". Is this future supported by openmax or should I add huffman table to jpeg before decoding? Probably I have a mistake in my example?
Apparently your OpenMAX IL does not support this configuration. So you'll have to try putting it into the data before the remaining image data instead.
Do you plan to fix this error in the near future?
Can you try on a more recent rpi ?
Closing this bug report as no further information has been provided. Please feel free to reopen this bug report if you can provide the information that was asked for in a previous comment. Thanks!