FAQ
Hello,

out of curiosity, why does "writeDQT()" emit the table as is, without
zig-zag reordering? I'm asking because the JPEG Spec says: "The
quantization elements shall be specified in zig-zag scan order."

Search Discussions

  • Nigel Tao at Sep 4, 2012 at 4:59 am

    On 3 September 2012 04:49, Tuom Larsen wrote:
    out of curiosity, why does "writeDQT()" emit the table as is, without
    zig-zag reordering? I'm asking because the JPEG Spec says: "The quantization
    elements shall be specified in zig-zag scan order."
    The e.quant table is already in zig-zag order. For example, in
    encoder.writeBlock, the "for k := 1; k < blockSize; k++" loop is
    iterating in zig-zag order, and the unzig[k] in the loop body converts
    to the natural coefficient order.
  • Tuom Larsen at Sep 4, 2012 at 8:51 am

    On Tue, Sep 4, 2012 at 6:59 AM, Nigel Tao wrote:
    The e.quant table is already in zig-zag order. For example, in
    encoder.writeBlock, the "for k := 1; k < blockSize; k++" loop is
    iterating in zig-zag order, and the unzig[k] in the loop body converts
    to the natural coefficient order.
    Thank you for the reply!

    This is what I thought as well but (and maybe I'm confused here) I
    don't think the quantization tables from the Spec are in zig-zag
    order. E.g., the luminance quantization table at the very top says
    "16, 11, 10, 16, ..." but if it was in zig-zag order it would read
    "16, 11, 12, 14, ...", no?

    I checked this with Independent JPEG Group (http://www.ijg.org/files/)
    and they use the same tables but on writing DQT they do:

    for (i = 0; i <= cinfo->lim_Se; i++) {
    /* The table entries must be emitted in zigzag order. */
    unsigned int qval = qtbl->quantval[cinfo->natural_order[i]];
    if (prec)
    emit_byte(cinfo, (int) (qval >> 8));
    emit_byte(cinfo, (int) (qval & 0xFF));
    }
  • Nigel Tao at Sep 5, 2012 at 1:54 am

    On 4 September 2012 18:50, Tuom Larsen wrote:
    This is what I thought as well but (and maybe I'm confused here) I
    don't think the quantization tables from the Spec are in zig-zag
    order.
    Ah, I double-checked this with my colleague, Raph Levien, and you are
    right and I am wrong. Thanks for the bug report. I'll send out a
    patch.
  • Tuom Larsen at Sep 5, 2012 at 7:29 am

    On Wed, Sep 5, 2012 at 2:45 AM, Nigel Tao wrote:
    Ah, I double-checked this with my colleague, Raph Levien, and you are
    right and I am wrong. Thanks for the bug report. I'll send out a
    patch.
    Thank you and Raph as well.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 2, '12 at 10:25p
activeSep 5, '12 at 7:29a
posts5
users2
websitegolang.org

2 users in discussion

Tuom Larsen: 3 posts Nigel Tao: 2 posts

People

Translate

site design / logo © 2021 Grokbase