GithubHelp home page GithubHelp logo

Comments (4)

jmvalin avatar jmvalin commented on July 23, 2024

We're aware of the opus_compare.c issue and it's a WONTFIX. That file is part of the standard for testing Opus compliance so we're not changing it at all unless something really bad gets discovered. When it comes to opus_demo, it would be good to have a less repetitive patch (maybe using goto?) to merge.

from opus.

ddkilzer avatar ddkilzer commented on July 23, 2024

Seems odd to leave known issues unfixed in test code, but okay.

I’m not allowed to post patches to other projects without internal review, so this bug report documents the issue. You’re free to take the existing patch and use it, modify it or fix it a different way. I’m not a huge fan of goto statements, anyway. :)

from opus.

jmvalin avatar jmvalin commented on July 23, 2024

About opus_compare.c, let's just say that it's as much of a contract and political statement as it is software, so any change to it makes some people nervous. As for opus_demo.c, can you have a look at this goto-based patch I made and give it a try?
https://jmvalin.ca/misc_stuff/fix_opus_demo_leaks.patch
As much as I also hate gotos in general, I think this is the one use case, where it's cleaner than alternatives. I believe it also addresses a case that your patch missed (exiting on opus_decoder_create() would fail to destroy the encoder)

from opus.

ddkilzer avatar ddkilzer commented on July 23, 2024

Okay, will try to do a code review here.

-static void check_encoder_option(int decode_only, const char *opt)
-{
-   if (decode_only)
-   {
-      fprintf(stderr, "option %s is only for encoding\n", opt);
-      exit(EXIT_FAILURE);
-   }
-}
+#define check_encoder_option(decode_only, opt) do {if (decode_only) {fprintf(stderr, "option %s is only for encoding\n", opt); goto failure;}} while(0)

I would find the macro much easier to read if it were formatted like regular code with line continuation backslashes at the end of each line:

+#define check_encoder_option(decode_only, opt) \
+do { \
+    if (decode_only) { \
+        fprintf(stderr, "option %s is only for encoding\n", opt); \
+        goto failure; \
+    } \
+} while(0)

Also learned that calling free(NULL) is okay. (Didn't realize that!)

Patch looks good to me other than the readability of check_encoder_option() macro.

from opus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.