ref: 9bb7bc2104c11c070caffa835fc4fb3287a3b6b9
parent: c372a2eb4bc59a0c7240b1055fe063ec781d5261
author: Timothy B. Terriberry <[email protected]>
date: Tue Oct 23 06:04:22 EDT 2012
Fix an assertion failure. This is no longer guaranteed after the change in e7661191, so test for it explicitly. Thanks to Greg Maxwell for the test case.
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -2093,11 +2093,12 @@
if(op_count>0){
ogg_int64_t gp;
gp=_of->op[op_count-1].granulepos;
- OP_ASSERT(gp!=-1);
/*Make sure the timestamp is valid.
+ The granule position might be -1 if we collected the packets from a
+ page without a granule position after reporting a hole.
The comparison with pcm_end must be strictly greater than, otherwise
we might include the last page (where _of->offset>end).*/
- if(OP_LIKELY(op_granpos_cmp(pcm_start,gp)<=0)
+ if(OP_LIKELY(gp!=-1)&&OP_LIKELY(op_granpos_cmp(pcm_start,gp)<=0)
&&OP_LIKELY(op_granpos_cmp(pcm_end,gp)>0)){
OP_ASSERT(_of->offset<=end);
ret=op_granpos_diff(&diff,gp,_target_gp);