shithub: opusfile

Download patch

ref: e0ab29d482cc10d880d1fac7e6c5c2a0c12ca056
parent: 1b114a82b93eb18f8cc87331236660a5f4bf3992
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Wed Aug 28 19:47:54 EDT 2013

Minor decode control flow updates.

This makes op_fetch_and_process_page() always try to fetch another
 page, like it used to (and like its name implies).
There was only one place where we needed the early return for
 unprocessed packets, and getting rid of that actually simplifies
 the logic there (replacing a conditional continue with an
 unconditional one in a slightly different location).

--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -1828,11 +1828,8 @@
   int           seekable;
   int           cur_link;
   int           ret;
-  if(OP_LIKELY(_of->ready_state>=OP_INITSET)
-   &&OP_LIKELY(_of->op_pos<_of->op_count)){
-    /*We're ready to decode and have at least one packet available already.*/
-    return 1;
-  }
+  /*We shouldn't get here if we have unprocessed packets.*/
+  OP_ASSERT(_of->ready_state<OP_INITSET||_of->op_pos>=_of->op_count);
   if(!_readp)return 0;
   seekable=_of->seekable;
   links=_of->links;
@@ -2700,8 +2697,6 @@
              what was decoded.*/
           _of->bytes_tracked+=pop->bytes;
           _of->samples_tracked+=trimmed_duration-od_buffer_pos;
-          /*Don't grab another page yet.*/
-          if(OP_LIKELY(od_buffer_pos<trimmed_duration))continue;
         }
         else{
           /*Otherwise decode directly into the user's buffer.*/
@@ -2728,6 +2723,9 @@
             }
           }
         }
+        /*Don't grab another page yet.
+          This one might have more packets, or might have buffered data now.*/
+        continue;
       }
     }
     /*Suck in another page.*/