Hi,
I was rather blind -- dvbcut does have a full mpeg audio
parser in streamdata::audio_addpts() which I overlooked.
[argh, why isn't it just using the one from ffmpeg,
or at least called parse_audio_frames :-) ?]
But audio_addpts has a bug which regularly hits with my
"strange" stream.
The test for an MPEG audio header just isn't sharp enough -- with my
test stream I regularly get false hits and therefore wrong timestamps
are generated.
The patch below fixes this, please consider my earlier patch
withdrawn.
Regards,
Wolfram.
--- dvbcut/src/streamdata.cpp 2006-10-29 21:03:53.000000000 +0100
+++ dvbcut-wg/src/streamdata.cpp 2006-12-01 22:40:23.000000000 +0100
@@ -29,10 +29,25 @@
{0,32,64,96,128,160,192,224,256,288,320,352,384,416,448} // layer 1
};
+static inline int is_mpa(const unsigned char *header)
+{
+ /* header */
+ if (header[0] != 0xff || (header[1] & 0xe0) != 0xe0 ||
+ /* layer check */
+ (header[1] & (3<<1)) == 0 ||
+ /* bit rate */
+ (header[2] & (0xf<<4)) == 0xf<<4 ||
+ /* frequency */
+ (header[2] & (3<<2)) == 3<<2)
+ return 0;
+ else
+ return 1;
+}
+
static int mpaframe(const void *data, int &pos, int len)
{
const unsigned char *d=(const unsigned char *)data;
- while ((pos+2)<len && (d[pos]!=0xff || (d[pos+1]&0xf0!=0xf0)))
+ while ((pos+2)<len && !is_mpa(&d[pos]))
++pos;
if (pos+2>=len)
return 0;
@@ -48,7 +63,7 @@
else
pos+=3;
- while ((pos+2)<len && (d[pos]!=0xff || (d[pos+1]&0xf0!=0xf0)))
+ while ((pos+2)<len && !is_mpa(&d[pos]))
++pos;
return samples*90000/samplingrate; // Duration of MPEG audio frame in
90000Hz units
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
DVBCUT-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dvbcut-user