Deflate Format: differences between type blocks











up vote
1
down vote

favorite












I am currently trying to write a compressor and decompressor with the same purpose as the RFC Deflate specification.



I'm not able to understand the difference between how blocks are composed in the compression with fixed tables and dynamic tables. The file is processed by LZ77 generating (distance, length) + literal.




  • How do I know the type of block?

  • Do I have to compress this data?

  • Given that I use a fixed compression and don't have to send the tables, how would the encoder know how to encode data?

  • Moreover, do I have to send data before the actual compression executes?


I am confused on the difference between fixed tables and the table we send in the dynamic mode, and how the two blocks use them to encode data.



I'm currently reading Data Compression: The Complete Reference. Any advice will be helpful.










share|improve this question




























    up vote
    1
    down vote

    favorite












    I am currently trying to write a compressor and decompressor with the same purpose as the RFC Deflate specification.



    I'm not able to understand the difference between how blocks are composed in the compression with fixed tables and dynamic tables. The file is processed by LZ77 generating (distance, length) + literal.




    • How do I know the type of block?

    • Do I have to compress this data?

    • Given that I use a fixed compression and don't have to send the tables, how would the encoder know how to encode data?

    • Moreover, do I have to send data before the actual compression executes?


    I am confused on the difference between fixed tables and the table we send in the dynamic mode, and how the two blocks use them to encode data.



    I'm currently reading Data Compression: The Complete Reference. Any advice will be helpful.










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am currently trying to write a compressor and decompressor with the same purpose as the RFC Deflate specification.



      I'm not able to understand the difference between how blocks are composed in the compression with fixed tables and dynamic tables. The file is processed by LZ77 generating (distance, length) + literal.




      • How do I know the type of block?

      • Do I have to compress this data?

      • Given that I use a fixed compression and don't have to send the tables, how would the encoder know how to encode data?

      • Moreover, do I have to send data before the actual compression executes?


      I am confused on the difference between fixed tables and the table we send in the dynamic mode, and how the two blocks use them to encode data.



      I'm currently reading Data Compression: The Complete Reference. Any advice will be helpful.










      share|improve this question















      I am currently trying to write a compressor and decompressor with the same purpose as the RFC Deflate specification.



      I'm not able to understand the difference between how blocks are composed in the compression with fixed tables and dynamic tables. The file is processed by LZ77 generating (distance, length) + literal.




      • How do I know the type of block?

      • Do I have to compress this data?

      • Given that I use a fixed compression and don't have to send the tables, how would the encoder know how to encode data?

      • Moreover, do I have to send data before the actual compression executes?


      I am confused on the difference between fixed tables and the table we send in the dynamic mode, and how the two blocks use them to encode data.



      I'm currently reading Data Compression: The Complete Reference. Any advice will be helpful.







      c deflate






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 23:45









      usr2564301

      17.1k73269




      17.1k73269










      asked Nov 10 at 21:08









      Franco Bosi

      62




      62
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Since you are trying to compress, you would pick the smaller of the two. zlib's deflate computes what the size of a fixed block and dynamic block would be, and emits the smaller of the two.



          If you are encoding a fixed block, you encode using the fixed code for literal/lengths and distances. This code is provided in the RFC.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243422%2fdeflate-format-differences-between-type-blocks%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            Since you are trying to compress, you would pick the smaller of the two. zlib's deflate computes what the size of a fixed block and dynamic block would be, and emits the smaller of the two.



            If you are encoding a fixed block, you encode using the fixed code for literal/lengths and distances. This code is provided in the RFC.






            share|improve this answer

























              up vote
              1
              down vote













              Since you are trying to compress, you would pick the smaller of the two. zlib's deflate computes what the size of a fixed block and dynamic block would be, and emits the smaller of the two.



              If you are encoding a fixed block, you encode using the fixed code for literal/lengths and distances. This code is provided in the RFC.






              share|improve this answer























                up vote
                1
                down vote










                up vote
                1
                down vote









                Since you are trying to compress, you would pick the smaller of the two. zlib's deflate computes what the size of a fixed block and dynamic block would be, and emits the smaller of the two.



                If you are encoding a fixed block, you encode using the fixed code for literal/lengths and distances. This code is provided in the RFC.






                share|improve this answer












                Since you are trying to compress, you would pick the smaller of the two. zlib's deflate computes what the size of a fixed block and dynamic block would be, and emits the smaller of the two.



                If you are encoding a fixed block, you encode using the fixed code for literal/lengths and distances. This code is provided in the RFC.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 at 1:52









                Mark Adler

                56.1k759106




                56.1k759106






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243422%2fdeflate-format-differences-between-type-blocks%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Danny Elfman

                    Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues