summaryrefslogtreecommitdiffstats
path: root/libhb/demuxmpeg.c
diff options
context:
space:
mode:
authorvan <[email protected]>2008-03-15 08:02:08 +0000
committervan <[email protected]>2008-03-15 08:02:08 +0000
commitdced078041d66034f53d72cc282055a50a2d0687 (patch)
tree02bea4c568d1efec6890ed12c96a1e8c0ddd2753 /libhb/demuxmpeg.c
parentcf31c8ed79b120aa0c6e4c7280374dcbfb3b7320 (diff)
- Add mpeg2 "Standard Target Decoder" clock recovery to the low level mpeg stream reader so we don't have to guess about the clock in sync.
- Since sync now has a fairly reliable clock, make it just trim excess audio or video and fill holes so that we maintain cross media sync. - Redo the TS-to-PS transmuxing code to work on smaller units so that we can reliably convert the TS clock (PCR) to a PS clock (SCR). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1341 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/demuxmpeg.c')
-rw-r--r--libhb/demuxmpeg.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libhb/demuxmpeg.c b/libhb/demuxmpeg.c
index 93b3709c3..40264fd2e 100644
--- a/libhb/demuxmpeg.c
+++ b/libhb/demuxmpeg.c
@@ -11,9 +11,8 @@
int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es )
{
hb_buffer_t * buf_es;
- int pos;
-
- pos = 0;
+ int pos = 0;
+ int64_t scr;
#define d (buf_ps->data)
@@ -26,6 +25,14 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es )
return 0;
}
pos += 4; /* pack_start_code */
+ /* extract the system clock reference (scr) */
+ scr = ((uint64_t)(d[pos] & 0x38) << 27) |
+ ((uint64_t)(d[pos] & 0x03) << 28) |
+ ((uint64_t)(d[pos+1]) << 20) |
+ ((uint64_t)(d[pos+2] >> 3) << 15) |
+ ((uint64_t)(d[pos+2] & 3) << 13) |
+ ((uint64_t)(d[pos+3]) << 5) |
+ (d[pos+4] >> 3);
pos += 9; /* pack_header */
pos += 1 + ( d[pos] & 0x7 ); /* stuffing bytes */
@@ -112,6 +119,7 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es )
buf_es->id = id;
buf_es->start = pts;
+ buf_es->stop = scr;
if (id == 0xE0) {
// Consume a chapter break, and apply it to the ES.
buf_es->new_chap = buf_ps->new_chap;