2001-02-24 20:28:24 +00:00
|
|
|
/*
|
|
|
|
* mpeg2_internal.h
|
2001-03-04 21:01:54 +00:00
|
|
|
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
|
2001-02-24 20:28:24 +00:00
|
|
|
*
|
|
|
|
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
|
|
|
|
*
|
|
|
|
* mpeg2dec is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* mpeg2dec is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* macroblock modes */
|
2001-02-24 20:28:24 +00:00
|
|
|
#define MACROBLOCK_INTRA 1
|
|
|
|
#define MACROBLOCK_PATTERN 2
|
|
|
|
#define MACROBLOCK_MOTION_BACKWARD 4
|
|
|
|
#define MACROBLOCK_MOTION_FORWARD 8
|
|
|
|
#define MACROBLOCK_QUANT 16
|
|
|
|
#define DCT_TYPE_INTERLACED 32
|
2001-03-04 21:01:54 +00:00
|
|
|
/* motion_type */
|
2001-02-24 20:28:24 +00:00
|
|
|
#define MOTION_TYPE_MASK (3*64)
|
|
|
|
#define MOTION_TYPE_BASE 64
|
|
|
|
#define MC_FIELD (1*64)
|
|
|
|
#define MC_FRAME (2*64)
|
|
|
|
#define MC_16X8 (2*64)
|
|
|
|
#define MC_DMV (3*64)
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* picture structure */
|
2001-02-24 20:28:24 +00:00
|
|
|
#define TOP_FIELD 1
|
|
|
|
#define BOTTOM_FIELD 2
|
|
|
|
#define FRAME_PICTURE 3
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* picture coding type */
|
2001-02-24 20:28:24 +00:00
|
|
|
#define I_TYPE 1
|
|
|
|
#define P_TYPE 2
|
|
|
|
#define B_TYPE 3
|
|
|
|
#define D_TYPE 4
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
typedef struct motion_s {
|
|
|
|
uint8_t * ref[2][3];
|
|
|
|
int pmv[2][2];
|
|
|
|
int f_code[2];
|
|
|
|
} motion_t;
|
|
|
|
|
|
|
|
typedef struct vo_frame_s {
|
|
|
|
uint8_t * base[3]; /* pointer to 3 planes */
|
|
|
|
void (* copy) (struct vo_frame_s * frame, uint8_t ** src);
|
|
|
|
void* vo;
|
2001-03-11 01:28:31 +00:00
|
|
|
// int slice;
|
2001-03-04 21:01:54 +00:00
|
|
|
// void (* field) (struct vo_frame_s * frame, int flags);
|
|
|
|
// void (* draw) (struct vo_frame_s * frame);
|
|
|
|
// vo_instance_t * instance;
|
|
|
|
} vo_frame_t;
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
typedef struct picture_s {
|
2001-03-04 21:01:54 +00:00
|
|
|
/* first, state that carries information from one macroblock to the */
|
|
|
|
/* next inside a slice, and is never used outside of slice_process() */
|
|
|
|
|
|
|
|
/* DCT coefficients - should be kept aligned ! */
|
|
|
|
int16_t DCTblock[64];
|
|
|
|
|
|
|
|
/* bit parsing stuff */
|
|
|
|
uint32_t bitstream_buf; /* current 32 bit working set of buffer */
|
|
|
|
int bitstream_bits; /* used bits in working set */
|
|
|
|
uint8_t * bitstream_ptr; /* buffer with stream data */
|
|
|
|
|
|
|
|
/* Motion vectors */
|
|
|
|
/* The f_ and b_ correspond to the forward and backward motion */
|
|
|
|
/* predictors */
|
|
|
|
motion_t b_motion;
|
|
|
|
motion_t f_motion;
|
|
|
|
|
|
|
|
/* predictor for DC coefficients in intra blocks */
|
|
|
|
int16_t dc_dct_pred[3];
|
|
|
|
|
|
|
|
int quantizer_scale; /* remove */
|
|
|
|
int current_field; /* remove */
|
2001-03-07 01:15:02 +00:00
|
|
|
int v_offset; /* remove */
|
2001-03-04 21:01:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* now non-slice-specific information */
|
|
|
|
|
|
|
|
/* sequence header stuff */
|
2001-02-24 20:28:24 +00:00
|
|
|
uint8_t intra_quantizer_matrix [64];
|
|
|
|
uint8_t non_intra_quantizer_matrix [64];
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* The width and height of the picture snapped to macroblock units */
|
2001-02-24 20:28:24 +00:00
|
|
|
int coded_picture_width;
|
|
|
|
int coded_picture_height;
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* picture header stuff */
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* what type of picture this is (I, P, B, D) */
|
2001-02-24 20:28:24 +00:00
|
|
|
int picture_coding_type;
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* picture coding extension stuff */
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* quantization factor for intra dc coefficients */
|
2001-02-24 20:28:24 +00:00
|
|
|
int intra_dc_precision;
|
2001-03-04 21:01:54 +00:00
|
|
|
/* top/bottom/both fields */
|
2001-02-24 20:28:24 +00:00
|
|
|
int picture_structure;
|
2001-03-04 21:01:54 +00:00
|
|
|
/* bool to indicate all predictions are frame based */
|
2001-02-24 20:28:24 +00:00
|
|
|
int frame_pred_frame_dct;
|
2001-03-04 21:01:54 +00:00
|
|
|
/* bool to indicate whether intra blocks have motion vectors */
|
|
|
|
/* (for concealment) */
|
2001-02-24 20:28:24 +00:00
|
|
|
int concealment_motion_vectors;
|
2001-03-04 21:01:54 +00:00
|
|
|
/* bit to indicate which quantization table to use */
|
2001-02-24 20:28:24 +00:00
|
|
|
int q_scale_type;
|
2001-03-04 21:01:54 +00:00
|
|
|
/* bool to use different vlc tables */
|
2001-02-24 20:28:24 +00:00
|
|
|
int intra_vlc_format;
|
2001-03-04 21:01:54 +00:00
|
|
|
/* used for DMV MC */
|
|
|
|
int top_field_first;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* stuff derived from bitstream */
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* pointer to the zigzag scan we're supposed to be using */
|
2001-02-24 20:28:24 +00:00
|
|
|
uint8_t * scan;
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
struct vo_frame_s * current_frame;
|
|
|
|
struct vo_frame_s * forward_reference_frame;
|
|
|
|
struct vo_frame_s * backward_reference_frame;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
int second_field;
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
int mpeg1;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* these things are not needed by the decoder */
|
|
|
|
/* this is a temporary interface, we will build a better one later. */
|
2001-02-24 20:28:24 +00:00
|
|
|
int aspect_ratio_information;
|
|
|
|
int frame_rate_code;
|
|
|
|
int progressive_sequence;
|
|
|
|
int repeat_first_field;
|
|
|
|
int progressive_frame;
|
|
|
|
int bitrate;
|
2001-03-04 21:01:54 +00:00
|
|
|
|
|
|
|
// added by A'rpi/ESP-team
|
2001-02-24 20:28:24 +00:00
|
|
|
int display_picture_width;
|
|
|
|
int display_picture_height;
|
2001-03-04 21:01:54 +00:00
|
|
|
int pp_options;
|
|
|
|
int repeat_count;
|
2001-03-11 01:28:31 +00:00
|
|
|
|
|
|
|
struct vo_frame_s * display_frame;
|
|
|
|
int slice;
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
} picture_t;
|
|
|
|
|
|
|
|
typedef struct mpeg2_config_s {
|
2001-03-04 21:01:54 +00:00
|
|
|
/* Bit flags that enable various things */
|
2001-02-24 20:28:24 +00:00
|
|
|
uint32_t flags;
|
|
|
|
} mpeg2_config_t;
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* The only global variable, */
|
|
|
|
/* the config struct */
|
2001-02-24 20:28:24 +00:00
|
|
|
extern mpeg2_config_t config;
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* slice.c */
|
2001-02-24 20:28:24 +00:00
|
|
|
void header_state_init (picture_t * picture);
|
|
|
|
int header_process_picture_header (picture_t * picture, uint8_t * buffer);
|
|
|
|
int header_process_sequence_header (picture_t * picture, uint8_t * buffer);
|
|
|
|
int header_process_extension (picture_t * picture, uint8_t * buffer);
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* idct.c */
|
2001-02-24 20:28:24 +00:00
|
|
|
void idct_init (void);
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* idct_mlib.c */
|
2001-02-24 20:28:24 +00:00
|
|
|
void idct_block_copy_mlib (int16_t * block, uint8_t * dest, int stride);
|
|
|
|
void idct_block_add_mlib (int16_t * block, uint8_t * dest, int stride);
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* idct_mmx.c */
|
2001-02-24 20:28:24 +00:00
|
|
|
void idct_block_copy_mmxext (int16_t *block, uint8_t * dest, int stride);
|
|
|
|
void idct_block_add_mmxext (int16_t *block, uint8_t * dest, int stride);
|
|
|
|
void idct_block_copy_mmx (int16_t *block, uint8_t * dest, int stride);
|
|
|
|
void idct_block_add_mmx (int16_t *block, uint8_t * dest, int stride);
|
|
|
|
void idct_mmx_init (void);
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* motion_comp.c */
|
2001-02-24 20:28:24 +00:00
|
|
|
void motion_comp_init (void);
|
|
|
|
|
|
|
|
typedef struct mc_functions_s
|
|
|
|
{
|
|
|
|
void (* put [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t);
|
|
|
|
void (* avg [8]) (uint8_t *dst, uint8_t *, int32_t, int32_t);
|
|
|
|
} mc_functions_t;
|
|
|
|
|
|
|
|
#define MOTION_COMP_EXTERN(x) mc_functions_t mc_functions_##x = \
|
|
|
|
{ \
|
|
|
|
{MC_put_16_##x, MC_put_x16_##x, MC_put_y16_##x, MC_put_xy16_##x, \
|
|
|
|
MC_put_8_##x, MC_put_x8_##x, MC_put_y8_##x, MC_put_xy8_##x}, \
|
|
|
|
{MC_avg_16_##x, MC_avg_x16_##x, MC_avg_y16_##x, MC_avg_xy16_##x, \
|
|
|
|
MC_avg_8_##x, MC_avg_x8_##x, MC_avg_y8_##x, MC_avg_xy8_##x} \
|
|
|
|
};
|
|
|
|
|
|
|
|
extern mc_functions_t mc_functions_c;
|
|
|
|
extern mc_functions_t mc_functions_mmx;
|
|
|
|
extern mc_functions_t mc_functions_mmxext;
|
|
|
|
extern mc_functions_t mc_functions_3dnow;
|
|
|
|
extern mc_functions_t mc_functions_mlib;
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* slice.c */
|
2001-02-24 20:28:24 +00:00
|
|
|
int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
|
|
|
|
|
2001-03-04 21:01:54 +00:00
|
|
|
/* stats.c */
|
2001-02-24 20:28:24 +00:00
|
|
|
void stats_header (uint8_t code, uint8_t * buffer);
|
2001-03-05 23:02:30 +00:00
|
|
|
|
2001-07-08 00:21:20 +00:00
|
|
|
void mpeg2_allocate_image_buffers(picture_t * picture);
|
|
|
|
|
|
|
|
|
2001-03-05 23:02:30 +00:00
|
|
|
#ifdef MPEG12_POSTPROC
|
2001-05-17 22:18:45 +00:00
|
|
|
#define MBC 48
|
2001-03-05 23:02:30 +00:00
|
|
|
#define MBR 36
|
|
|
|
extern int quant_store[MBR+1][MBC+1]; // [Review]
|
|
|
|
#endif
|