xine-lib: xine-lib-1.2.13/src/video_dec/libvdpau/vdpau_mpeg12.c File Reference

xine-lib 1.2.13-20230125hg15249

Data Structures | Macros | Typedefs | Functions | Variables
vdpau_mpeg12.c File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/types.h>`
`#include <unistd.h>`
`#include <xine/xine_internal.h>`
`#include <xine/video_out.h>`
`#include <xine/buffer.h>`
`#include <xine/xineutils.h>`
`#include "accel_vdpau.h"`
`#include "bits_reader.h"`
`#include "group_vdpau.h"`
`#include <vdpau/vdpau.h>`

## Data Structures
struct | picture_t
struct | sequence_t
struct | vdpau_mpeg12_decoder_s

## Macros
#define | LOG_MODULE "vdpau_mpeg12"
#define | sequence_header_code 0xb3
#define | sequence_error_code 0xb4
#define | sequence_end_code 0xb7
#define | group_start_code 0xb8
#define | extension_start_code 0xb5
#define | user_data_start_code 0xb2
#define | picture_start_code 0x00
#define | begin_slice_start_code 0x01
#define | end_slice_start_code 0xaf
#define | sequence_ext_sc 1
#define | quant_matrix_ext_sc 3
#define | picture_coding_ext_sc 8
#define | sequence_display_ext_sc 2
#define | I_FRAME 1
#define | P_FRAME 2
#define | B_FRAME 3
#define | PICTURE_TOP 1
#define | PICTURE_BOTTOM 2
#define | PICTURE_FRAME 3

## Typedefs
typedef struct vdpau_mpeg12_decoder_s | vdpau_mpeg12_decoder_t

## Functions
static void | picture_ready (vdpau_mpeg12_decoder_t *vd, uint8_t end_of_sequence)
static void | reset_picture (picture_t *pic)
static void | init_picture (picture_t *pic)
static void | reset_sequence (sequence_t *sequence, int free_refs)
static void | free_sequence (sequence_t *sequence)
static void | sequence_header (vdpau_mpeg12_decoder_t *this_gen, uint8_t *buf, int len)
static void | process_sequence_mpeg12_dependent_data (vdpau_mpeg12_decoder_t *this_gen)
static void | picture_header (vdpau_mpeg12_decoder_t *this_gen, uint8_t *buf, int len)
static void | sequence_extension (sequence_t *sequence, uint8_t *buf, int len)
static void | picture_coding_extension (sequence_t *sequence, uint8_t *buf, int len)
static void | quant_matrix_extension (sequence_t *sequence, uint8_t *buf, int len)
static void | copy_slice (sequence_t *sequence, uint8_t *buf, int len)
static int | parse_code (vdpau_mpeg12_decoder_t *this_gen, uint8_t *buf, int len)
static void | decode_render (vdpau_mpeg12_decoder_t *vd, vdpau_accel_t *accel)
static void | decode_picture (vdpau_mpeg12_decoder_t *vd, uint8_t end_of_sequence)
static void | vdpau_mpeg12_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
static void | vdpau_mpeg12_flush (video_decoder_t *this_gen)
static void | vdpau_mpeg12_reset (video_decoder_t *this_gen)
static void | vdpau_mpeg12_discontinuity (video_decoder_t *this_gen)
static void | vdpau_mpeg12_dispose (video_decoder_t *this_gen)
static video_decoder_t * | open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream)
void * | mpeg12_init_plugin (xine_t *xine, const void *data)

## Variables
static const uint8_t | default_intra_quantizer_matrix [64]
uint8_t | mpeg2_scan_norm [64]

## Macro Definition Documentation

## ◆ B_FRAME

#define B_FRAME 3

Referenced by decode_picture(), decode_render(), and picture_header().

## ◆ begin_slice_start_code

#define begin_slice_start_code 0x01

Referenced by parse_code().

## ◆ end_slice_start_code

#define end_slice_start_code 0xaf

Referenced by parse_code().

## ◆ extension_start_code

#define extension_start_code 0xb5

Referenced by parse_code().

## ◆ group_start_code

#define group_start_code 0xb8

Referenced by parse_code().

## ◆ I_FRAME

#define I_FRAME 1

Referenced by decode_picture(), decode_render(), and picture_header().

## ◆ LOG_MODULE

#define LOG_MODULE "vdpau_mpeg12"

## ◆ P_FRAME

#define P_FRAME 2

Referenced by decode_picture(), and decode_render().

## ◆ PICTURE_BOTTOM

#define PICTURE_BOTTOM 2

## ◆ picture_coding_ext_sc

#define picture_coding_ext_sc 8

Referenced by parse_code().

## ◆ PICTURE_FRAME

#define PICTURE_FRAME 3

Referenced by decode_picture(), decode_render(), picture_coding_extension(), and picture_header().

## ◆ picture_start_code

#define picture_start_code 0x00

Referenced by parse_code().

## ◆ PICTURE_TOP

#define PICTURE_TOP 1

## ◆ quant_matrix_ext_sc

#define quant_matrix_ext_sc 3

Referenced by parse_code().

## ◆ sequence_display_ext_sc

#define sequence_display_ext_sc 2

Referenced by parse_code().

## ◆ sequence_end_code

#define sequence_end_code 0xb7

Referenced by parse_code(), and vdpau_mpeg12_decode_data().

## ◆ sequence_error_code

#define sequence_error_code 0xb4

Referenced by parse_code().

## ◆ sequence_ext_sc

#define sequence_ext_sc 1

Referenced by parse_code().

## ◆ sequence_header_code

#define sequence_header_code 0xb3

Referenced by parse_code().

## ◆ user_data_start_code

#define user_data_start_code 0xb2

Referenced by parse_code().

## Typedef Documentation

## ◆ vdpau_mpeg12_decoder_t

typedef struct vdpau_mpeg12_decoder_s vdpau_mpeg12_decoder_t

## Function Documentation

## ◆ copy_slice()

static void copy_slice | ( | sequence_t * | sequence,
|  | uint8_t * | buf,
|  | int | len )
| static

References sequence_t::picture, picture_t::slices, picture_t::slices_count, picture_t::slices_count2, picture_t::slices_pos, picture_t::slices_pos_top, picture_t::slices_size, and xine_fast_memcpy.

Referenced by parse_code().

## ◆ decode_picture()

static void decode_picture | ( | vdpau_mpeg12_decoder_t * | vd,
|  | uint8_t | end_of_sequence )
| static

References vo_frame_s::accel_data, sequence_t::accel_vdpau, B_FRAME, sequence_t::backward_ref, vo_frame_s::bad_frame, sequence_t::chroma, sequence_t::coded_height, sequence_t::coded_width, vdpau_accel_t::current_vdp_runtime_nr, decode_render(), vdpau_mpeg12_decoder_s::decoder, vo_frame_s::draw, vo_frame_s::drawn, vo_frame_s::duration, sequence_t::forward_ref, vo_frame_s::free, xine_video_port_s::get_frame, I_FRAME, lprintf, NULL, P_FRAME, sequence_t::picture, PICTURE_FRAME, sequence_t::profile, picture_t::progressive_frame, vo_frame_s::progressive_frame, sequence_t::progressive_sequence, vo_frame_s::pts, sequence_t::ratio, picture_t::repeat_first_field, vo_frame_s::repeat_first_field, sequence_t::reset, sequence_t::seq_pts, vdpau_mpeg12_decoder_s::sequence, picture_t::slices, picture_t::slices_pos, vdpau_mpeg12_decoder_s::stream, vdpau_accel_t::surface, sequence_t::top_field_first, vo_frame_s::top_field_first, picture_t::vdp_infos, sequence_t::vdp_runtime_nr, xine_stream_s::video_out, sequence_t::video_step, VO_BOTH_FIELDS, VO_SET_FLAGS_CM, VO_STILL_IMAGE, and XINE_IMGFMT_VDPAU.

Referenced by picture_ready(), and vdpau_mpeg12_decode_data().

## ◆ decode_render()

static void decode_render | ( | vdpau_mpeg12_decoder_t * | vd,
|  | vdpau_accel_t * | accel )
| static

References B_FRAME, CAST_VdpPictureInfo_PTR, sequence_t::coded_height, sequence_t::coded_width, sequence_t::cur_pts, vdpau_mpeg12_decoder_s::decoder, vdpau_mpeg12_decoder_s::decoder_height, vdpau_mpeg12_decoder_s::decoder_profile, vdpau_mpeg12_decoder_s::decoder_width, I_FRAME, vdpau_accel_t::lock, lprintf, P_FRAME, sequence_t::picture, PICTURE_FRAME, sequence_t::profile, vdpau_mpeg12_decoder_s::sequence, picture_t::slices, picture_t::slices_count, picture_t::slices_count2, picture_t::slices_pos, picture_t::slices_pos_top, vdpau_accel_t::surface, vdpau_accel_t::unlock, vdpau_accel_t::vdp_decoder_create, vdpau_accel_t::vdp_decoder_destroy, vdpau_accel_t::vdp_decoder_render, vdpau_accel_t::vdp_device, vdpau_accel_t::vdp_get_error_string, picture_t::vdp_infos, picture_t::vdp_infos2, sequence_t::vdp_runtime_nr, vdpau_accel_t::vdp_runtime_nr, and vdpau_accel_t::vo_frame.

Referenced by decode_picture().

## ◆ free_sequence()

static void free_sequence | ( | sequence_t * | sequence | ) |
| static

References sequence_t::chroma, sequence_t::have_header, lprintf, sequence_t::profile, reset_sequence(), and sequence_t::video_step.

Referenced by open_plugin(), and vdpau_mpeg12_dispose().

## ◆ init_picture()

static void init_picture | ( | picture_t * | pic | ) |
| static

References reset_picture(), picture_t::slices, and picture_t::slices_size.

Referenced by open_plugin().

## ◆ mpeg12_init_plugin()

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

References video_decoder_s::dispose, N_, NULL, open_plugin(), and video_decoder_class_s::open_plugin.

## ◆ open_plugin()

static video_decoder_t * open_plugin | ( | video_decoder_class_t * | class_gen,
|  | xine_stream_t * | stream )
| static

References vo_frame_s::accel_data, vo_frame_s::free, free_sequence(), xine_video_port_s::get_capabilities, xine_video_port_s::get_frame, init_picture(), vdpau_accel_t::lock, lprintf, NULL, xine_video_port_s::open, vdpau_accel_t::unlock, vdpau_accel_t::vdp_decoder_create, vdpau_accel_t::vdp_decoder_destroy, vdpau_accel_t::vdp_device, vdpau_accel_t::vdp_runtime_nr, vdpau_mpeg12_decode_data(), vdpau_mpeg12_discontinuity(), vdpau_mpeg12_dispose(), vdpau_mpeg12_flush(), vdpau_mpeg12_reset(), xine_stream_s::video_out, VO_BOTH_FIELDS, VO_CAP_VDPAU_MPEG12, vdpau_accel_t::vo_frame, VO_GET_FRAME_MAY_FAIL, VO_NEW_SEQUENCE_FLAG, and XINE_IMGFMT_VDPAU.

Referenced by mpeg12_init_plugin().

## ◆ parse_code()

static int parse_code | ( | vdpau_mpeg12_decoder_t * | this_gen,
|  | uint8_t * | buf,
|  | int | len )
| static

References begin_slice_start_code, copy_slice(), end_slice_start_code, extension_start_code, group_start_code, sequence_t::have_header, lprintf, picture_coding_ext_sc, picture_coding_extension(), picture_header(), picture_start_code, quant_matrix_ext_sc, quant_matrix_extension(), vdpau_mpeg12_decoder_s::sequence, sequence_display_ext_sc, sequence_end_code, sequence_error_code, sequence_ext_sc, sequence_extension(), sequence_header(), sequence_header_code, and user_data_start_code.

Referenced by vdpau_mpeg12_decode_data().

## ◆ picture_coding_extension()

static void picture_coding_extension | ( | sequence_t * | sequence,
|  | uint8_t * | buf,
|  | int | len )
| static

References bits_reader_set(), sequence_t::br, lprintf, sequence_t::picture, PICTURE_FRAME, picture_t::progressive_frame, read_bits(), picture_t::repeat_first_field, skip_bits(), picture_t::vdp_infos, and picture_t::vdp_infos2.

Referenced by parse_code().

## ◆ picture_header()

static void picture_header | ( | vdpau_mpeg12_decoder_t * | this_gen,
|  | uint8_t * | buf,
|  | int | len )
| static

References B_FRAME, bits_reader_set(), sequence_t::br, sequence_t::cur_pts, I_FRAME, lprintf, sequence_t::picture, PICTURE_FRAME, picture_ready(), process_sequence_mpeg12_dependent_data(), sequence_t::profile, read_bits(), reset_picture(), sequence_t::seq_pts, vdpau_mpeg12_decoder_s::sequence, skip_bits(), picture_t::slices_pos, picture_t::slices_pos_top, picture_t::vdp_infos, and picture_t::vdp_infos2.

Referenced by parse_code().

## ◆ picture_ready()

static void picture_ready | ( | vdpau_mpeg12_decoder_t * | vd,
|  | uint8_t | end_of_sequence )
| static

References decode_picture(), sequence_t::picture, vdpau_mpeg12_decoder_s::sequence, picture_t::slices_count, picture_t::slices_count2, and picture_t::vdp_infos2.

Referenced by picture_header().

## ◆ process_sequence_mpeg12_dependent_data()

static void process_sequence_mpeg12_dependent_data | ( | vdpau_mpeg12_decoder_t * | this_gen | ) |
| static

References _x_meta_info_set_utf8(), _x_stream_info_set(), xine_format_change_data_t::aspect, sequence_t::aspect_ratio_information, sequence_t::coded_height, sequence_t::coded_width, sequence_t::display_horizontal_size, sequence_t::display_vertical_size, sequence_t::frame_rate_code, sequence_t::frame_rate_extension_d, sequence_t::frame_rate_extension_n, sequence_t::have_display_extension, sequence_t::have_header, xine_format_change_data_t::height, sequence_t::horizontal_size_extension, sequence_t::horizontal_size_value, sequence_t::profile, sequence_t::ratio, sequence_t::reported_video_step, vdpau_mpeg12_decoder_s::sequence, vdpau_mpeg12_decoder_s::stream, sequence_t::vertical_size_extension, sequence_t::vertical_size_value, sequence_t::video_step, xine_format_change_data_t::width, XINE_EVENT_FRAME_FORMAT_CHANGE, xine_event_send(), XINE_META_INFO_VIDEOCODEC, XINE_STREAM_INFO_FRAME_DURATION, XINE_STREAM_INFO_VIDEO_HEIGHT, XINE_STREAM_INFO_VIDEO_RATIO, and XINE_STREAM_INFO_VIDEO_WIDTH.

Referenced by picture_header().

## ◆ quant_matrix_extension()

static void quant_matrix_extension | ( | sequence_t * | sequence,
|  | uint8_t * | buf,
|  | int | len )
| static

References bits_reader_set(), sequence_t::br, default_intra_quantizer_matrix, lprintf, mpeg2_scan_norm, sequence_t::picture, read_bits(), skip_bits(), picture_t::vdp_infos, and picture_t::vdp_infos2.

Referenced by parse_code().

## ◆ reset_picture()

static void reset_picture | ( | picture_t * | pic | ) |
| static

References lprintf, picture_t::progressive_frame, picture_t::repeat_first_field, picture_t::slices_count, picture_t::slices_count2, picture_t::slices_pos, picture_t::slices_pos_top, picture_t::vdp_infos, and picture_t::vdp_infos2.

Referenced by init_picture(), and picture_header().

## ◆ reset_sequence()

static void reset_sequence | ( | sequence_t * | sequence,
|  | int | free_refs )
| static

References sequence_t::backward_ref, sequence_t::bufpos, sequence_t::bufseek, sequence_t::cur_pts, sequence_t::forward_ref, vo_frame_s::free, NULL, vo_frame_s::pts, sequence_t::reset, sequence_t::seq_pts, sequence_t::start, sequence_t::top_field_first, and VO_NEW_SEQUENCE_FLAG.

Referenced by free_sequence(), vdpau_mpeg12_discontinuity(), and vdpau_mpeg12_reset().

## ◆ sequence_extension()

static void sequence_extension | ( | sequence_t * | sequence,
|  | uint8_t * | buf,
|  | int | len )
| static

References bits_reader_set(), sequence_t::br, sequence_t::chroma, sequence_t::frame_rate_extension_d, sequence_t::frame_rate_extension_n, lprintf, sequence_t::profile, sequence_t::progressive_sequence, read_bits(), skip_bits(), and VO_CHROMA_422.

Referenced by parse_code().

## ◆ sequence_header()

static void sequence_header | ( | vdpau_mpeg12_decoder_t * | this_gen,
|  | uint8_t * | buf,
|  | int | len )
| static

References sequence_t::aspect_ratio_information, bits_reader_set(), sequence_t::br, default_intra_quantizer_matrix, sequence_t::frame_rate_code, sequence_t::have_display_extension, sequence_t::have_header, sequence_t::horizontal_size_extension, sequence_t::horizontal_size_value, lprintf, mpeg2_scan_norm, sequence_t::picture, sequence_t::profile, read_bits(), vdpau_mpeg12_decoder_s::sequence, skip_bits(), picture_t::vdp_infos, picture_t::vdp_infos2, sequence_t::vertical_size_extension, and sequence_t::vertical_size_value.

Referenced by parse_code().

## ◆ vdpau_mpeg12_decode_data()

static void vdpau_mpeg12_decode_data | ( | video_decoder_t * | this_gen,
|  | buf_element_t * | buf )
| static

References sequence_t::buf, BUF_FLAG_PREVIEW, sequence_t::bufpos, sequence_t::bufseek, sequence_t::bufsize, buf_element_s::content, sequence_t::cur_pts, decode_picture(), buf_element_s::decoder_flags, parse_code(), buf_element_s::pts, sequence_end_code, buf_element_s::size, sequence_t::start, and xine_fast_memcpy.

Referenced by open_plugin().

## ◆ vdpau_mpeg12_discontinuity()

static void vdpau_mpeg12_discontinuity | ( | video_decoder_t * | this_gen | ) |
| static

References lprintf, and reset_sequence().

Referenced by open_plugin().

## ◆ vdpau_mpeg12_dispose()

static void vdpau_mpeg12_dispose | ( | video_decoder_t * | this_gen | ) |
| static

References free_sequence(), and lprintf.

Referenced by open_plugin().

## ◆ vdpau_mpeg12_flush()

static void vdpau_mpeg12_flush | ( | video_decoder_t * | this_gen | ) |
| static

References lprintf.

Referenced by open_plugin().

## ◆ vdpau_mpeg12_reset()

static void vdpau_mpeg12_reset | ( | video_decoder_t * | this_gen | ) |
| static

References lprintf, and reset_sequence().

Referenced by open_plugin().

## Variable Documentation

## ◆ default_intra_quantizer_matrix

const uint8_t default_intra_quantizer_matrix[64]
| static

Initial value:
= {
8,
16, 16,
19, 16, 19,
22, 22, 22, 22,
22, 22, 26, 24, 26,
27, 27, 27, 26, 26, 26,
26, 27, 27, 27, 29, 29, 29,
34, 34, 34, 29, 29, 29, 27, 27,
29, 29, 32, 32, 34, 34, 37,
38, 37, 35, 35, 34, 35,
38, 38, 40, 40, 40,
48, 48, 46, 46,
56, 56, 58,
69, 69,
83
}

Referenced by quant_matrix_extension(), and sequence_header().

## ◆ mpeg2_scan_norm

uint8_t mpeg2_scan_norm[64]

Initial value:
= {
0, 1, 8,16, 9, 2, 3,10,
17,24,32,25,18,11, 4, 5,
12,19,26,33,40,48,41,34,
27,20,13, 6, 7,14,21,28,
35,42,49,56,57,50,43,36,
29,22,15,23,30,37,44,51,
58,59,52,45,38,31,39,46,
53,60,61,54,47,55,62,63
}

Referenced by quant_matrix_extension(), and sequence_header().