[FFmpeg-devel] [PATCH] Implement optimal huffman encoding for (M)JPEG.

Michael Niedermayer michael at niedermayer.cc
Fri Feb 10 00:34:36 EET 2017


On Thu, Feb 09, 2017 at 01:20:09PM +0100, Michael Niedermayer wrote:
[...]
> > int ff_mjpeg_encode_stuffing(MpegEncContext *s)
> > {
> >     int i;
> >     PutBitContext *pbc = &s->pb;
> >     int mb_y = s->mb_y - !s->mb_x;
> >+    int ret;
> >+    MJpegContext *m;
> >+
> >+    m = s->mjpeg_ctx;
> >+
> >+    if (m->error)
> >+        return m->error;
> >+
> >+    if (s->huffman == HUFFMAN_TABLE_OPTIMAL) {
> >+        ff_mjpeg_build_optimal_huffman(m);
> >+
> >+        // Replace the VLCs with the optimal ones.
> 
> >+        // The default ones may be used for trellis during quantization.
> >+        ff_init_uni_ac_vlc(m->huff_size_ac_luminance,   m->uni_ac_vlc_len);
> >+        ff_init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
> 
> This is wrong and will break trellis with non default tables, trellis
> needs to use the same VLCs as are used for encoding. which if non
> default ones are used should be these non default ones
> 
> the code generating the default tables wrote them in shared
> tables (uni*ac_vlc_len), now after the patch the default code is
> shared, called from 2 places and the tables moved into the context
> yet it still generates only the defau lt tables.

I did misread this part

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170209/8dfb5345/attachment.sig>


More information about the ffmpeg-devel mailing list