1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * MPEG-1/2 muxer and demuxer common defines
3cabdff1aSopenharmony_ci * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * This file is part of FFmpeg.
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11cabdff1aSopenharmony_ci *
12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cabdff1aSopenharmony_ci * Lesser General Public License for more details.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20cabdff1aSopenharmony_ci */
21cabdff1aSopenharmony_ci
22cabdff1aSopenharmony_ci#ifndef AVFORMAT_MPEG_H
23cabdff1aSopenharmony_ci#define AVFORMAT_MPEG_H
24cabdff1aSopenharmony_ci
25cabdff1aSopenharmony_ci#include <stdint.h>
26cabdff1aSopenharmony_ci#include "libavutil/intreadwrite.h"
27cabdff1aSopenharmony_ci
28cabdff1aSopenharmony_ci#define PACK_START_CODE             ((unsigned int)0x000001ba)
29cabdff1aSopenharmony_ci#define SYSTEM_HEADER_START_CODE    ((unsigned int)0x000001bb)
30cabdff1aSopenharmony_ci#define SEQUENCE_END_CODE           ((unsigned int)0x000001b7)
31cabdff1aSopenharmony_ci#define PACKET_START_CODE_MASK      ((unsigned int)0xffffff00)
32cabdff1aSopenharmony_ci#define PACKET_START_CODE_PREFIX    ((unsigned int)0x00000100)
33cabdff1aSopenharmony_ci#define ISO_11172_END_CODE          ((unsigned int)0x000001b9)
34cabdff1aSopenharmony_ci
35cabdff1aSopenharmony_ci/* mpeg2 */
36cabdff1aSopenharmony_ci#define PROGRAM_STREAM_MAP 0x1bc
37cabdff1aSopenharmony_ci#define PRIVATE_STREAM_1   0x1bd
38cabdff1aSopenharmony_ci#define PADDING_STREAM     0x1be
39cabdff1aSopenharmony_ci#define PRIVATE_STREAM_2   0x1bf
40cabdff1aSopenharmony_ci
41cabdff1aSopenharmony_ci#define AUDIO_ID 0xc0
42cabdff1aSopenharmony_ci#define VIDEO_ID 0xe0
43cabdff1aSopenharmony_ci#define H264_ID  0xe2
44cabdff1aSopenharmony_ci#define AC3_ID   0x80
45cabdff1aSopenharmony_ci#define DTS_ID   0x88
46cabdff1aSopenharmony_ci#define LPCM_ID  0xa0
47cabdff1aSopenharmony_ci#define SUB_ID   0x20
48cabdff1aSopenharmony_ci
49cabdff1aSopenharmony_ci#define STREAM_TYPE_VIDEO_MPEG1     0x01
50cabdff1aSopenharmony_ci#define STREAM_TYPE_VIDEO_MPEG2     0x02
51cabdff1aSopenharmony_ci#define STREAM_TYPE_AUDIO_MPEG1     0x03
52cabdff1aSopenharmony_ci#define STREAM_TYPE_AUDIO_MPEG2     0x04
53cabdff1aSopenharmony_ci#define STREAM_TYPE_PRIVATE_SECTION 0x05
54cabdff1aSopenharmony_ci#define STREAM_TYPE_PRIVATE_DATA    0x06
55cabdff1aSopenharmony_ci#define STREAM_TYPE_AUDIO_AAC       0x0f
56cabdff1aSopenharmony_ci#define STREAM_TYPE_VIDEO_MPEG4     0x10
57cabdff1aSopenharmony_ci#define STREAM_TYPE_VIDEO_H264      0x1b
58cabdff1aSopenharmony_ci#define STREAM_TYPE_VIDEO_HEVC      0x24
59cabdff1aSopenharmony_ci#define STREAM_TYPE_VIDEO_CAVS      0x42
60cabdff1aSopenharmony_ci
61cabdff1aSopenharmony_ci#define STREAM_TYPE_AUDIO_AC3       0x81
62cabdff1aSopenharmony_ci
63cabdff1aSopenharmony_cistatic const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
64cabdff1aSopenharmony_ci
65cabdff1aSopenharmony_ci/**
66cabdff1aSopenharmony_ci * Parse MPEG-PES five-byte timestamp
67cabdff1aSopenharmony_ci */
68cabdff1aSopenharmony_cistatic inline int64_t ff_parse_pes_pts(const uint8_t *buf) {
69cabdff1aSopenharmony_ci    return (int64_t)(*buf & 0x0e) << 29 |
70cabdff1aSopenharmony_ci            (AV_RB16(buf+1) >> 1) << 15 |
71cabdff1aSopenharmony_ci             AV_RB16(buf+3) >> 1;
72cabdff1aSopenharmony_ci}
73cabdff1aSopenharmony_ci
74cabdff1aSopenharmony_ci#endif /* AVFORMAT_MPEG_H */
75