shithub: opus-tools

Download patch

ref: 2b249750bc49554358916d83392a4d2e006f5b3a
parent: c27db573523ba968921a845af1ece5076013d4cc
author: Gregory Maxwell <greg@xiph.org>
date: Sat May 26 20:50:37 EDT 2012

Ogginfo test additions from Tim's review.

--- a/src/info_opus.c
+++ b/src/info_opus.c
@@ -96,6 +96,7 @@
     ogg_stream_pagein(&stream->os, page);
     if(inf->doneheaders < 2)
         header = 1;
+    inf->last_eos = ogg_page_eos(page);
 
     while(1) {
         int32_t spp;
@@ -201,6 +202,7 @@
         inf->total_samples += spp;
         page_samples += spp;
         inf->total_packets++;
+        inf->last_packet_duration = spp;
         if(inf->max_packet_duration<spp)inf->max_packet_duration=spp;
         if(inf->min_packet_duration>spp)inf->min_packet_duration=spp;
         if(inf->max_packet_bytes<packet.bytes)inf->max_packet_bytes=packet.bytes;
@@ -224,12 +226,15 @@
                   else inf->firstgranule=0;
                 }
             }
-            if(inf->total_samples<gp-inf->firstgranule)oi_warn(_("WARNING: Sample count behind granule (%lld<%lld) in stream %d\n"),
+            if(inf->total_samples<gp-inf->firstgranule)oi_warn(_("WARNING: Sample count behind granule (%" I64FORMAT ">%" I64FORMAT ") in stream %d\n"),
                 (long long)inf->total_samples,(long long)(gp-inf->firstgranule),stream->num);
             if(!ogg_page_eos(page) && (inf->total_samples>gp-inf->firstgranule))
-                oi_warn(_("WARNING: Sample count ahead of granule (%lld>%lld) in stream %d\n"),
+                oi_warn(_("WARNING: Sample count ahead of granule (%" I64FORMAT ">%" I64FORMAT ") in stream %d\n"),
                 (long long)inf->total_samples,(long long)(gp-inf->firstgranule),stream->num);
+            inf->lastlastgranulepos = inf->lastgranulepos;
             inf->lastgranulepos = gp;
+            if(!packets)
+                oi_warn(_("WARNING: Page with positive granpos (%" I64FORMAT ") on a page with no completed packets in stream %d\n"),gp,stream->num);
         }
         else if(packets) {
             /* Only do this if we saw at least one packet ending on this page.
@@ -264,9 +269,11 @@
         seconds = (long)(time - minutes*60);
         milliseconds = (long)((time - minutes*60 - seconds)*1000);
         if(inf->lastgranulepos-inf->firstgranule<inf->oh.preskip)
-           oi_warn(_("\tERROR: stream %d has a negative duration\n"),stream->num);
+           oi_error(_("\tERROR: stream %d has a negative duration\n"),stream->num);
         if((inf->total_samples-inf->last_page_duration)>(inf->lastgranulepos-inf->firstgranule))
-           oi_warn(_("\tWARNING: stream %d has holes or excessive end trimming\n"),stream->num);
+           oi_error(_("\tERROR: stream %d has interior holes or more than one page of end trimming\n"),stream->num);
+        if(inf->last_eos &&( (inf->last_page_duration-inf->last_packet_duration)>(inf->lastgranulepos-inf->lastlastgranulepos)))
+           oi_warn(_("\tWARNING: stream %d has more than one packet of end trimming\n"),stream->num);
         if(inf->max_page_duration>=240000)
            oi_warn(_("\tWARNING: stream %d has high muxing delay\n"),stream->num);
         oi_info(_("\tPre-skip: %d\n"),inf->oh.preskip);
--- a/src/info_opus.h
+++ b/src/info_opus.h
@@ -29,11 +29,13 @@
     OpusHeader  oh;
     ogg_int64_t bytes;
     ogg_int64_t overhead_bytes;
+    ogg_int64_t lastlastgranulepos;
     ogg_int64_t lastgranulepos;
     ogg_int64_t firstgranule;
     ogg_int64_t total_samples;
     ogg_int64_t total_packets;
     ogg_int64_t total_pages;
+    ogg_int32_t last_packet_duration;
     ogg_int32_t last_page_duration;
     ogg_int32_t max_page_duration;
     ogg_int32_t min_page_duration;
@@ -41,6 +43,7 @@
     ogg_int32_t min_packet_duration;
     ogg_int32_t max_packet_bytes;
     ogg_int32_t min_packet_bytes;
+    int last_eos;
 
     int doneheaders;
 } misc_opus_info;
--- a/src/opusinfo.c
+++ b/src/opusinfo.c
@@ -271,7 +271,7 @@
     int i;
     for(i=0; i < set->used; i++) {
         if(!set->streams[i].end) {
-            oi_warn(_("WARNING: EOS not set on stream %d\n"),
+            oi_warn(_("WARNING: EOS not set on stream %d (normal for live streams)\n"),
                     set->streams[i].num);
             if(set->streams[i].process_end)
                 set->streams[i].process_end(&set->streams[i]);
@@ -530,8 +530,8 @@
         if(p->seqno++ != ogg_page_pageno(&page)) {
             if(!p->lostseq)
                 oi_warn(_("WARNING: sequence number gap in stream %d. Got page "
-                       "%ld when expecting page %ld. Indicates missing data.\n"
-                       ), p->num, ogg_page_pageno(&page), p->seqno - 1);
+                       "%ld when expecting page %ld. Indicates missing data.%s\n"
+                       ), p->num, ogg_page_pageno(&page), p->seqno - 1, p->seqno-1==2?_(" (normal for live streams)"):"");
             p->seqno = ogg_page_pageno(&page);
             p->lostseq = 1;
         }