xine-lib: xine-lib-1.2.13/src/demuxers/demux_mpeg.c File Reference

xine-lib 1.2.13-20230125hg15249

Data Structures | Macros | Typedefs | Functions
demux_mpeg.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include "group_video.h"`
`#include <xine/xine_internal.h>`
`#include <xine/demux.h>`
`#include <xine/xineutils.h>`
`#include "bswap.h"`

## Data Structures
struct | demux_mpeg_s

## Macros
#define | LOG_MODULE "demux_mpeg"
#define | LOG_VERBOSE
#define | NUM_PREVIEW_BUFFERS 150
#define | SCRATCH_SIZE 256
#define | WRAP_THRESHOLD 120000
#define | PTS_AUDIO 0
#define | PTS_VIDEO 1
#define | QT_ATOM BE_FOURCC
#define | FREE_ATOM QT_ATOM('f', 'r', 'e', 'e')
#define | JUNK_ATOM QT_ATOM('j', 'u', 'n', 'k')
#define | MDAT_ATOM QT_ATOM('m', 'd', 'a', 't')
#define | MOOV_ATOM QT_ATOM('m', 'o', 'o', 'v')
#define | PNOT_ATOM QT_ATOM('p', 'n', 'o', 't')
#define | SKIP_ATOM QT_ATOM('s', 'k', 'i', 'p')
#define | WIDE_ATOM QT_ATOM('w', 'i', 'd', 'e')
#define | ATOM_PREAMBLE_SIZE 8
#define | FOURCC_TAG BE_FOURCC
#define | RIFF_TAG FOURCC_TAG('R', 'I', 'F', 'F')
#define | WAVE_TAG FOURCC_TAG('W', 'A', 'V', 'E')
#define | AVI_TAG FOURCC_TAG('A', 'V', 'I', ' ')
#define | FOURXM_TAG FOURCC_TAG('4', 'X', 'M', 'V')
#define | RIFF_CHECK_KILOBYTES 1024
#define | MPEG_MARKER FOURCC_TAG( 0x00, 0x00, 0x01, 0xBA )
#define | abs(x) ( ((x)<0) ? -(x) : (x) )

## Typedefs
typedef struct demux_mpeg_s | demux_mpeg_t

## Functions
static void | find_mdat_atom (input_plugin_t *input, off_t *mdat_offset, int64_t *mdat_size)
static void | reset_track_map (fifo_buffer_t *fifo)
static uint32_t | read_bytes (demux_mpeg_t *this, uint32_t n)
static void | check_newpts (demux_mpeg_t *this, int64_t pts, int video)
static int | mpeg1_read_pts (demux_mpeg_t *this, int64_t *pts, uint32_t leadbyte)
static int | mpeg2_read_pts (demux_mpeg_t *this, int64_t *pts)
static int64_t | mpeg_get_pts (const uint8_t *p)
static void | parse_mpeg2_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
static void | parse_mpeg1_packet (demux_mpeg_t *this, int stream_id, int64_t scr)
static uint32_t | parse_pack (demux_mpeg_t *this)
static uint32_t | parse_pack_preview (demux_mpeg_t *this, int *num_buffers)
static void | demux_mpeg_resync (demux_mpeg_t *this, uint32_t buf)
static int | demux_mpeg_send_chunk (demux_plugin_t *this_gen)
static int | demux_mpeg_get_status (demux_plugin_t *this_gen)
static void | demux_mpeg_send_headers (demux_plugin_t *this_gen)
static int | demux_mpeg_seek (demux_plugin_t *this_gen, off_t start_pos, int start_time, int playing)
static int | demux_mpeg_get_stream_length (demux_plugin_t *this_gen)
static uint32_t | demux_mpeg_get_capabilities (demux_plugin_t *this_gen)
static int | demux_mpeg_get_optional_data (demux_plugin_t *this_gen, void *data, int data_type)
static demux_plugin_t * | open_plugin (demux_class_t *class_gen, xine_stream_t *stream, input_plugin_t *input)
void * | demux_mpeg_init_class (xine_t *xine, const void *data)

## Macro Definition Documentation

## ◆ abs

#define abs | ( |  | x | ) | ( ((x)<0) ? -(x) : (x) )

Referenced by check_newpts().

## ◆ ATOM_PREAMBLE_SIZE

#define ATOM_PREAMBLE_SIZE 8

Referenced by find_mdat_atom().

## ◆ AVI_TAG

#define AVI_TAG FOURCC_TAG('A', 'V', 'I', ' ')

Referenced by open_plugin().

## ◆ FOURCC_TAG

#define FOURCC_TAG BE_FOURCC

## ◆ FOURXM_TAG

#define FOURXM_TAG FOURCC_TAG('4', 'X', 'M', 'V')

Referenced by open_plugin().

## ◆ FREE_ATOM

#define FREE_ATOM QT_ATOM('f', 'r', 'e', 'e')

Referenced by find_mdat_atom().

## ◆ JUNK_ATOM

#define JUNK_ATOM QT_ATOM('j', 'u', 'n', 'k')

Referenced by find_mdat_atom().

## ◆ LOG_MODULE

#define LOG_MODULE "demux_mpeg"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ MDAT_ATOM

#define MDAT_ATOM QT_ATOM('m', 'd', 'a', 't')

Referenced by find_mdat_atom().

## ◆ MOOV_ATOM

#define MOOV_ATOM QT_ATOM('m', 'o', 'o', 'v')

Referenced by find_mdat_atom().

## ◆ MPEG_MARKER

#define MPEG_MARKER FOURCC_TAG( 0x00, 0x00, 0x01, 0xBA )

Referenced by open_plugin().

## ◆ NUM_PREVIEW_BUFFERS

#define NUM_PREVIEW_BUFFERS 150

Referenced by demux_mpeg_send_headers().

## ◆ PNOT_ATOM

#define PNOT_ATOM QT_ATOM('p', 'n', 'o', 't')

Referenced by find_mdat_atom().

## ◆ PTS_AUDIO

#define PTS_AUDIO 0

Referenced by parse_mpeg1_packet(), and parse_mpeg2_packet().

## ◆ PTS_VIDEO

#define PTS_VIDEO 1

Referenced by parse_mpeg1_packet(), and parse_mpeg2_packet().

## ◆ QT_ATOM

#define QT_ATOM BE_FOURCC

## ◆ RIFF_CHECK_KILOBYTES

#define RIFF_CHECK_KILOBYTES 1024

Referenced by open_plugin().

## ◆ RIFF_TAG

#define RIFF_TAG FOURCC_TAG('R', 'I', 'F', 'F')

Referenced by open_plugin().

## ◆ SCRATCH_SIZE

#define SCRATCH_SIZE 256

Referenced by open_plugin().

## ◆ SKIP_ATOM

#define SKIP_ATOM QT_ATOM('s', 'k', 'i', 'p')

Referenced by find_mdat_atom().

## ◆ WAVE_TAG

#define WAVE_TAG FOURCC_TAG('W', 'A', 'V', 'E')

Referenced by open_plugin().

## ◆ WIDE_ATOM

#define WIDE_ATOM QT_ATOM('w', 'i', 'd', 'e')

Referenced by find_mdat_atom().

## ◆ WRAP_THRESHOLD

#define WRAP_THRESHOLD 120000

Referenced by check_newpts().

## Typedef Documentation

## ◆ demux_mpeg_t

typedef struct demux_mpeg_s demux_mpeg_t

## Function Documentation

## ◆ check_newpts()

static void check_newpts | ( | demux_mpeg_t * | this,
|  | int64_t | pts,
|  | int | video )
| static

References _x_demux_control_newpts(), abs, BUF_FLAG_SEEK, and WRAP_THRESHOLD.

Referenced by parse_mpeg1_packet(), and parse_mpeg2_packet().

## ◆ demux_mpeg_get_capabilities()

static uint32_t demux_mpeg_get_capabilities | ( | demux_plugin_t * | this_gen | ) |
| static

References DEMUX_CAP_AUDIOLANG, and DEMUX_CAP_SPULANG.

Referenced by open_plugin().

## ◆ demux_mpeg_get_optional_data()

static int demux_mpeg_get_optional_data | ( | demux_plugin_t * | this_gen,
|  | void * | data,
|  | int | data_type )
| static

References DEMUX_OPTIONAL_DATA_AUDIOLANG, DEMUX_OPTIONAL_DATA_SPULANG, DEMUX_OPTIONAL_SUCCESS, DEMUX_OPTIONAL_UNSUPPORTED, and NULL.

Referenced by open_plugin().

## ◆ demux_mpeg_get_status()

static int demux_mpeg_get_status | ( | demux_plugin_t * | this_gen | ) |
| static

Referenced by open_plugin().

## ◆ demux_mpeg_get_stream_length()

static int demux_mpeg_get_stream_length | ( | demux_plugin_t * | this_gen | ) |
| static

References input().

Referenced by open_plugin().

## ◆ demux_mpeg_init_class()

void * demux_mpeg_init_class | ( | xine_t * | xine,
|  | const void * | data )

References demux_plugin_s::dispose, N_, NULL, demux_class_s::open_plugin, and open_plugin().

## ◆ demux_mpeg_resync()

static void demux_mpeg_resync | ( | demux_mpeg_t * | this,
|  | uint32_t | buf )
| static

References DEMUX_FINISHED, DEMUX_OK, input(), INPUT_IS_SEEKABLE, and read_bytes().

Referenced by demux_mpeg_seek(), demux_mpeg_send_chunk(), and demux_mpeg_send_headers().

## ◆ demux_mpeg_seek()

static int demux_mpeg_seek | ( | demux_plugin_t * | this_gen,
|  | off_t | start_pos,
|  | int | start_time,
|  | int | playing )
| static

References _x_demux_flush_engine(), demux_mpeg_resync(), DEMUX_OK, input(), INPUT_IS_SEEKABLE, read_bytes(), and demux_plugin_s::seek.

Referenced by open_plugin().

## ◆ demux_mpeg_send_chunk()

static int demux_mpeg_send_chunk | ( | demux_plugin_t * | this_gen | ) |
| static

References demux_mpeg_resync(), and parse_pack().

Referenced by open_plugin().

## ◆ demux_mpeg_send_headers()

static void demux_mpeg_send_headers | ( | demux_plugin_t * | this_gen | ) |
| static

References _x_demux_control_start(), _x_stream_info_set(), demux_mpeg_resync(), DEMUX_OK, input(), NUM_PREVIEW_BUFFERS, parse_pack_preview(), XINE_STREAM_INFO_BITRATE, XINE_STREAM_INFO_HAS_AUDIO, and XINE_STREAM_INFO_HAS_VIDEO.

Referenced by open_plugin().

## ◆ find_mdat_atom()

static void find_mdat_atom | ( | input_plugin_t * | input,
|  | off_t * | mdat_offset,
|  | int64_t * | mdat_size )
| static

References _X_BE_32, ATOM_PREAMBLE_SIZE, FREE_ATOM, input(), JUNK_ATOM, MDAT_ATOM, MOOV_ATOM, PNOT_ATOM, SKIP_ATOM, and WIDE_ATOM.

Referenced by open_plugin().

## ◆ mpeg1_read_pts()

static int mpeg1_read_pts | ( | demux_mpeg_t * | this,
|  | int64_t * | pts,
|  | uint32_t | leadbyte )
| static

References DEMUX_FINISHED, input(), and v.

Referenced by parse_mpeg1_packet().

## ◆ mpeg2_read_pts()

static int mpeg2_read_pts | ( | demux_mpeg_t * | this,
|  | int64_t * | pts )
| static

References DEMUX_FINISHED, input(), and v.

Referenced by parse_mpeg1_packet().

## ◆ mpeg_get_pts()

static int64_t mpeg_get_pts | ( | const uint8_t * | p | ) |
| static

References _X_BE_32, and v.

Referenced by parse_mpeg2_packet().

## ◆ open_plugin()

static demux_plugin_t * open_plugin | ( | demux_class_t * | class_gen,
|  | xine_stream_t * | stream,
|  | input_plugin_t * | input )
| static

References _X_BE_32, _x_demux_read_header(), AVI_TAG, xine_stream_s::content_detection_method, default_demux_plugin_dispose, DEMUX_FINISHED, demux_mpeg_get_capabilities(), demux_mpeg_get_optional_data(), demux_mpeg_get_status(), demux_mpeg_get_stream_length(), demux_mpeg_seek(), demux_mpeg_send_chunk(), demux_mpeg_send_headers(), find_mdat_atom(), FOURXM_TAG, input(), INPUT_CAP_BLOCK, INPUT_IS_SEEKABLE, lprintf, METHOD_BY_CONTENT, METHOD_BY_MRL, METHOD_EXPLICIT, MPEG_MARKER, NULL, RIFF_CHECK_KILOBYTES, RIFF_TAG, SCRATCH_SIZE, input_plugin_s::seek, and WAVE_TAG.

Referenced by demux_mpeg_init_class().

## ◆ parse_mpeg1_packet()

static void parse_mpeg1_packet | ( | demux_mpeg_t * | this,
|  | int | stream_id,
|  | int64_t | scr )
| static

References BUF_AUDIO_MPEG, BUF_FLAG_FRAME_END, BUF_FLAG_PREVIEW, BUF_VIDEO_MPEG, check_newpts(), buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, DEMUX_FINISHED, DEMUX_OK, buf_element_s::extra_info, buf_element_s::free_buffer, input(), extra_info_s::input_normpos, extra_info_s::input_time, lprintf, buf_element_s::max_size, mpeg1_read_pts(), mpeg2_read_pts(), buf_element_s::pts, PTS_AUDIO, PTS_VIDEO, read_bytes(), reset_track_map(), buf_element_s::size, and buf_element_s::type.

Referenced by parse_pack(), and parse_pack_preview().

## ◆ parse_mpeg2_packet()

static void parse_mpeg2_packet | ( | demux_mpeg_t * | this,
|  | int | stream_id,
|  | int64_t | scr )
| static

References _X_BE_16, BUF_AUDIO_A52, BUF_AUDIO_DTS, BUF_AUDIO_LPCM_BE, BUF_AUDIO_MPEG, BUF_FLAG_FRAME_END, BUF_FLAG_PREVIEW, BUF_FLAG_SPECIAL, BUF_SPECIAL_LPCM_CONFIG, BUF_SPECIAL_SPU_DVD_SUBTYPE, BUF_SPU_CVD, BUF_SPU_DVD, BUF_SPU_SVCD, BUF_VIDEO_MPEG, BUF_VIDEO_VC1, check_newpts(), buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, DEMUX_FINISHED, buf_element_s::extra_info, buf_element_s::free_buffer, input(), extra_info_s::input_normpos, extra_info_s::input_time, lprintf, buf_element_s::max_size, mpeg_get_pts(), buf_element_s::pts, PTS_AUDIO, PTS_VIDEO, reset_track_map(), buf_element_s::size, SPU_DVD_SUBTYPE_PACKAGE, buf_element_s::type, and type.

Referenced by parse_pack(), and parse_pack_preview().

## ◆ parse_pack()

static uint32_t parse_pack | ( | demux_mpeg_t * | this | ) |
| static

References _X_BE_32, DEMUX_FINISHED, DEMUX_OK, input(), lprintf, parse_mpeg1_packet(), parse_mpeg2_packet(), and read_bytes().

Referenced by demux_mpeg_send_chunk().

## ◆ parse_pack_preview()

static uint32_t parse_pack_preview | ( | demux_mpeg_t * | this,
|  | int * | num_buffers )
| static

References _X_BE_32, DEMUX_FINISHED, DEMUX_OK, input(), lprintf, parse_mpeg1_packet(), parse_mpeg2_packet(), and read_bytes().

Referenced by demux_mpeg_send_headers().

## ◆ read_bytes()

static uint32_t read_bytes | ( | demux_mpeg_t * | this,
|  | uint32_t | n )
| static

References _x_assert, DEMUX_FINISHED, and input().

Referenced by demux_mpeg_resync(), demux_mpeg_seek(), http_plugin_read_int(), parse_mpeg1_packet(), parse_pack(), and parse_pack_preview().

## ◆ reset_track_map()

static void reset_track_map | ( | fifo_buffer_t * | fifo | ) |
| static

References BUF_CONTROL_RESET_TRACK_MAP, fifo_buffer_s::buffer_pool_alloc, buf_element_s::decoder_info, fifo_buffer_s::put, and buf_element_s::type.

Referenced by parse_mpeg1_packet(), and parse_mpeg2_packet().