mpeg.h 2.4 KB

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