Move parsing of MPEG-PES timestamp to mpeg.h (as an inline function) so it

can easily be reused by other demuxers for formats that encapsulate MPEG-PES.

Originally committed as revision 11451 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Ivo van Poorten 2008-01-07 23:32:57 +00:00
parent ca5323af4b
commit 66e9e30239
2 changed files with 14 additions and 10 deletions

View File

@ -120,17 +120,12 @@ static int mpegps_read_header(AVFormatContext *s,
static int64_t get_pts(ByteIOContext *pb, int c) static int64_t get_pts(ByteIOContext *pb, int c)
{ {
int64_t pts; uint8_t buf[5];
int val;
if (c < 0) buf[0] = c<0 ? get_byte(pb) : c;
c = get_byte(pb); get_buffer(pb, buf+1, 4);
pts = (int64_t)(c & 0x0e) << 29;
val = get_be16(pb); return ff_parse_pes_pts(buf);
pts |= (int64_t)(val >> 1) << 15;
val = get_be16(pb);
pts |= (int64_t)(val >> 1);
return pts;
} }
static int find_next_start_code(ByteIOContext *pb, int *size_ptr, static int find_next_start_code(ByteIOContext *pb, int *size_ptr,

View File

@ -57,4 +57,13 @@
static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 }; static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
/**
* Parse MPEG-PES five-byte timestamp
*/
static inline int64_t ff_parse_pes_pts(uint8_t *buf) {
return (int64_t)(*buf & 0x0e) << 29 |
(AV_RB16(buf+1) >> 1) << 15 |
AV_RB16(buf+3) >> 1;
}
#endif /* FFMPEG_MPEG_H */ #endif /* FFMPEG_MPEG_H */