summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer/mpeg_stream.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_stream.h')
-rw-r--r--apps/plugins/mpegplayer/mpeg_stream.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_stream.h b/apps/plugins/mpegplayer/mpeg_stream.h
new file mode 100644
index 0000000000..0c850f072d
--- /dev/null
+++ b/apps/plugins/mpegplayer/mpeg_stream.h
@@ -0,0 +1,120 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Stream definitions for MPEG
11 *
12 * Copyright (c) 2007 Michael Sevakis
13 *
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef MPEG_STREAM_H
22#define MPEG_STREAM_H
23
24/* Codes for various header byte sequences - MSB represents lowest memory
25 address */
26#define PACKET_START_CODE_PREFIX 0x00000100ul
27#define END_CODE 0x000001b9ul
28#define PACK_START_CODE 0x000001baul
29#define SYSTEM_HEADER_START_CODE 0x000001bbul
30
31/* p = base pointer, b0 - b4 = byte offsets from p */
32/* We only care about the MS 32 bits of the 33 and so the ticks are 45kHz */
33#define TS_FROM_HEADER(p, b0) \
34 ((uint32_t)((((p)[(b0)+0] & 0x0e) << 28) | \
35 (((p)[(b0)+1] ) << 21) | \
36 (((p)[(b0)+2] & 0xfe) << 13) | \
37 (((p)[(b0)+3] ) << 6) | \
38 (((p)[(b0)+4] ) >> 2)))
39
40#define TS_CHECK_MARKERS(p, b0) \
41 (((((p)[(b0)+0] & 0x01) << 2) | \
42 (((p)[(b0)+2] & 0x01) << 1) | \
43 (((p)[(b0)+4] & 0x01) )) == 0x07)
44
45/* Get the SCR in our 45kHz ticks. Ignore the 9-bit extension */
46#define MPEG2_PACK_HEADER_SCR(p, b0) \
47 ((uint32_t)((((p)[(b0)+0] & 0x38) << 26) | \
48 (((p)[(b0)+0] & 0x03) << 27) | \
49 (((p)[(b0)+1] ) << 19) | \
50 (((p)[(b0)+2] & 0xf8) << 11) | \
51 (((p)[(b0)+2] & 0x03) << 12) | \
52 (((p)[(b0)+3] ) << 4) | \
53 (((p)[(b0)+4] ) >> 4)))
54
55#define MPEG2_CHECK_PACK_SCR_MARKERS(ph, b0) \
56 (((((ph)[(b0)+0] & 0x04) ) | \
57 (((ph)[(b0)+2] & 0x04) >> 1) | \
58 (((ph)[(b0)+4] & 0x04) >> 2)) == 0x07)
59
60#define INVALID_TIMESTAMP (~(uint32_t)0)
61#define MAX_TIMESTAMP (INVALID_TIMESTAMP-1)
62#define TS_SECOND (45000) /* Timestamp ticks per second */
63#define TC_SECOND (27000000) /* MPEG timecode ticks per second */
64
65/* These values immediately follow the start code prefix '00 00 01' */
66
67/* Video start codes */
68#define MPEG_START_PICTURE 0x00
69#define MPEG_START_SLICE_FIRST 0x01
70#define MPEG_START_SLICE_LAST 0xaf
71#define MPEG_START_RESERVED_1 0xb0
72#define MPEG_START_RESERVED_2 0xb1
73#define MPEG_START_USER_DATA 0xb2
74#define MPEG_START_SEQUENCE_HEADER 0xb3
75#define MPEG_START_SEQUENCE_ERROR 0xb4
76#define MPEG_START_EXTENSION 0xb5
77#define MPEG_START_RESERVED_3 0xb6
78#define MPEG_START_SEQUENCE_END 0xb7
79#define MPEG_START_GOP 0xb8
80
81/* Stream IDs */
82#define MPEG_STREAM_PROGRAM_END 0xb9
83#define MPEG_STREAM_PACK_HEADER 0xba
84#define MPEG_STREAM_SYSTEM_HEADER 0xbb
85#define MPEG_STREAM_PROGRAM_STREAM_MAP 0xbc
86#define MPEG_STREAM_PRIVATE_1 0xbd
87#define MPEG_STREAM_PADDING 0xbe
88#define MPEG_STREAM_PRIVATE_2 0xbf
89#define MPEG_STREAM_AUDIO_FIRST 0xc0
90#define MPEG_STREAM_AUDIO_LAST 0xcf
91#define MPEG_STREAM_VIDEO_FIRST 0xe0
92#define MPEG_STREAM_VIDEO_LAST 0xef
93#define MPEG_STREAM_ECM 0xf0
94#define MPEG_STREAM_EMM 0xf1
95/* ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or
96 * ISO/IEC 13818-6_DSMCC_stream */
97#define MPEG_STREAM_MISC_1 0xf2
98/* ISO/IEC_13522_stream */
99#define MPEG_STREAM_MISC_2 0xf3
100/* ITU-T Rec. H.222.1 type A - E */
101#define MPEG_STREAM_MISC_3 0xf4
102#define MPEG_STREAM_MISC_4 0xf5
103#define MPEG_STREAM_MISC_5 0xf6
104#define MPEG_STREAM_MISC_6 0xf7
105#define MPEG_STREAM_MISC_7 0xf8
106#define MPEG_STREAM_ANCILLARY 0xf9
107#define MPEG_STREAM_RESERVED_FIRST 0xfa
108#define MPEG_STREAM_RESERVED_LAST 0xfe
109/* Program stream directory */
110#define MPEG_STREAM_PROGRAM_DIRECTORY 0xff
111
112#define STREAM_IS_AUDIO(s) (((s) & 0xf0) == 0xc0)
113#define STREAM_IS_VIDEO(s) (((s) & 0xf0) == 0xe0)
114
115#define MPEG_MAX_PACKET_SIZE (64*1024+16)
116
117/* Largest MPEG audio frame - MPEG1, Layer II, 384kbps, 32kHz, pad */
118#define MPA_MAX_FRAME_SIZE 1729
119
120#endif /* MPEG_STREAM_H */