libmpeg2-0.2.0 merge

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi_esp 2001-03-04 21:01:54 +00:00
parent c25474941c
commit 156ec7764e
19 changed files with 833 additions and 875 deletions

View File

@ -12,7 +12,10 @@ Note: If you've sent patches not applied in pre22, please send them again!
*** 0.11 release is coming SOON!!! ***
v0.11-CVS: yeah, we moved to SourceForge CVS!
v0.11-pre26-CVS:
- updated libmpeg2 source to libmpeg2-0.2.0 version
v0.11-pre25: yeah, we moved to SourceForge CVS!
- DOCS updated (email address changed from arpi@* -> maillist)
- LIRC fix, mplayer_lirc changed back to mplayer [Andreas Ackermann]
- stream.c: unsigned int fixes, required for some strange .asf files

View File

@ -91,6 +91,12 @@ void send_cmd(int fd,int cmd){
// fflush(control_fifo);
}
static const int frameratecode2framerate[16] = {
0, 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001,
60*10000, 0,0,0,0,0,0,0
};
void mpeg_codec_controller(vo_functions_t *video_out){
//================== CODEC Controller: ==========================
signal(SIGTERM,codec_ctrl_sighandler); // set our SIGTERM handler
@ -145,8 +151,9 @@ void mpeg_codec_controller(vo_functions_t *video_out){
mpeg2_decode_data(video_out, videobuffer, videobuffer+len);
t+=GetTimer();
send_cmd(control_fifo2,0); // FRAME_COMPLETED command
send_cmd(control_fifo2,picture->frame_rate); // fps
send_cmd(control_fifo2,frameratecode2framerate[picture->frame_rate_code]); // fps
send_cmd(control_fifo2,100+picture->repeat_count);picture->repeat_count=0;
// send_cmd(control_fifo2,100); // FIXME!
send_cmd(control_fifo2,t);t=0;
}
video_out->uninit();

View File

@ -3,8 +3,8 @@ LIBNAME = libmpeg2.a
include ../config.mak
SRCS = decode.c header.c idct.c idct_mmx.c motion_comp.c motion_comp_mmx.c slice.c stats.c
OBJS = decode.o header.o idct.o idct_mmx.o motion_comp.o motion_comp_mmx.o slice.o stats.o
SRCS = header.c idct.c idct_mmx.c motion_comp.c motion_comp_mmx.c slice.c stats.c decode.c
OBJS = header.o idct.o idct_mmx.o motion_comp.o motion_comp_mmx.o slice.o stats.o decode.o
INCLUDE = -I. -I../libvo -I..
CFLAGS = $(OPTFLAGS) $(INCLUDE) -DMPG12PLAY

View File

@ -1,6 +1,6 @@
/*
* attributes.h
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -19,11 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//use gcc attribs to align critical data structures
/* maximum supported data alignment */
#define ATTRIBUTE_ALIGNED_MAX 64
/* use gcc attribs to align critical data structures */
#ifdef ATTRIBUTE_ALIGNED_MAX
#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
#else

View File

@ -3,8 +3,7 @@
/* mpeg2dec version: */
#define PACKAGE "mpeg2dec"
//#define VERSION "0.1.7-cvs"
#define VERSION "0.1.8-cvs"
#define VERSION "0.2.0-release"
#include <stdio.h>
#include <stdlib.h>
@ -14,7 +13,8 @@
#include "config.h"
//#include "video_out.h"
#include "video_out.h"
#include <inttypes.h>
#include "mpeg2.h"
#include "mpeg2_internal.h"
@ -32,6 +32,9 @@
#include "mmx.h"
#endif
#include "mm_accel.h"
//this is where we keep the state of the decoder
//picture_t picture_data;
//picture_t *picture=&picture_data;
@ -48,7 +51,9 @@ mpeg2_config_t config;
static int drop_flag = 0;
static int drop_frame = 0;
#ifdef POSTPROC
int quant_store[MBR+1][MBC+1]; // [Review]
#endif
void mpeg2_init (void)
{
@ -73,7 +78,7 @@ void mpeg2_init (void)
picture=shmem_alloc(sizeof(picture_t)); // !!! NEW HACK :) !!!
header_state_init (picture);
picture->repeat_count=0;
// picture->repeat_count=0;
picture->pp_options=0;
@ -81,10 +86,13 @@ void mpeg2_init (void)
motion_comp_init ();
}
static vo_frame_t frames[3];
void mpeg2_allocate_image_buffers (picture_t * picture)
{
int frame_size,buff_size;
unsigned char *base=NULL;
int i;
// height+1 requires for yuv2rgb_mmx code (it reads next line after last)
frame_size = picture->coded_picture_width * (1+picture->coded_picture_height);
@ -92,56 +100,44 @@ void mpeg2_allocate_image_buffers (picture_t * picture)
buff_size = frame_size + (frame_size/4)*2; // 4Y + 1U + 1V
// allocate images in YV12 format
base = shmem_alloc(buff_size);
picture->throwaway_frame[0] = base;
picture->throwaway_frame[1] = base + frame_size * 5 / 4;
picture->throwaway_frame[2] = base + frame_size;
base = shmem_alloc(buff_size);
picture->backward_reference_frame[0] = base;
picture->backward_reference_frame[1] = base + frame_size * 5 / 4;
picture->backward_reference_frame[2] = base + frame_size;
base = shmem_alloc(buff_size);
picture->forward_reference_frame[0] = base;
picture->forward_reference_frame[1] = base + frame_size * 5 / 4;
picture->forward_reference_frame[2] = base + frame_size;
for(i=0;i<3;i++){
base = shmem_alloc(buff_size);
frames[i].base[0] = base;
frames[i].base[1] = base + frame_size * 5 / 4;
frames[i].base[2] = base + frame_size;
frames[i].copy = NULL;
frames[i].vo = NULL;
frames[i].slice=0;
}
picture->forward_reference_frame=&frames[0];
picture->backward_reference_frame=&frames[1];
picture->current_frame=&frames[2];
#ifdef POSTPROC
base = shmem_alloc(buff_size);
picture->pp_frame[0] = base;
picture->pp_frame[1] = base + frame_size * 5 / 4;
picture->pp_frame[2] = base + frame_size;
#endif
}
static void decode_reorder_frames (void)
{
if (picture->picture_coding_type != B_TYPE) {
static void copy_slice (vo_frame_t * frame, uint8_t ** src){
vo_functions_t * output = frame->vo;
int stride[3];
int y=frame->slice*16;
//reuse the soon to be outdated forward reference frame
picture->current_frame[0] = picture->forward_reference_frame[0];
picture->current_frame[1] = picture->forward_reference_frame[1];
picture->current_frame[2] = picture->forward_reference_frame[2];
stride[0]=picture->coded_picture_width;
stride[1]=stride[2]=stride[0]/2;
//make the backward reference frame the new forward reference frame
picture->forward_reference_frame[0] =
picture->backward_reference_frame[0];
picture->forward_reference_frame[1] =
picture->backward_reference_frame[1];
picture->forward_reference_frame[2] =
picture->backward_reference_frame[2];
output->draw_slice (src, stride,
picture->display_picture_width,
(y+16<=picture->display_picture_height) ? 16 :
picture->display_picture_height-y,
0, y);
picture->backward_reference_frame[0] = picture->current_frame[0];
picture->backward_reference_frame[1] = picture->current_frame[1];
picture->backward_reference_frame[2] = picture->current_frame[2];
} else {
picture->current_frame[0] = picture->throwaway_frame[0];
picture->current_frame[1] = picture->throwaway_frame[1];
picture->current_frame[2] = picture->throwaway_frame[2];
}
++frame->slice;
}
static int in_slice_flag=0;
@ -156,43 +152,27 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer)
if (is_frame_done) {
in_slice_flag = 0;
if(picture->picture_structure != FRAME_PICTURE) printf("Field! %d \n",picture->second_field);
// if(picture->picture_structure != FRAME_PICTURE) printf("Field! %d \n",picture->second_field);
if ( ((HACK_MODE == 2) || (picture->mpeg1))
&& ((picture->picture_structure == FRAME_PICTURE) ||
if (((picture->picture_structure == FRAME_PICTURE) ||
(picture->second_field))
) {
uint8_t ** bar;
int stride[3];
if (picture->picture_coding_type == B_TYPE)
bar = picture->throwaway_frame;
else
bar = picture->forward_reference_frame;
stride[0]=picture->coded_picture_width;
stride[1]=stride[2]=stride[0]/2;
if(picture->pp_options){
// apply OpenDivX postprocess filter
postprocess(bar, stride[0],
picture->pp_frame, stride[0],
picture->coded_picture_width, picture->coded_picture_height,
&quant_store[1][1], (MBC+1), picture->pp_options);
output->draw_slice (picture->pp_frame, stride,
picture->display_picture_width,
picture->display_picture_height, 0, 0);
} else {
output->draw_slice (bar, stride,
) {
#if 1
if (picture->picture_coding_type != B_TYPE) {
int stride[3];
stride[0]=picture->coded_picture_width;
stride[1]=stride[2]=stride[0]/2;
output->draw_slice (picture->forward_reference_frame->base,
stride,
picture->display_picture_width,
picture->display_picture_height, 0, 0);
}
}
#ifdef ARCH_X86
if (config.flags & MM_ACCEL_X86_MMX) emms ();
#endif
output->flip_page ();
}
#ifdef ARCH_X86
if (config.flags & MM_ACCEL_X86_MMX) emms();
#endif
output->flip_page();
}
switch (code) {
@ -227,40 +207,32 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer)
if (!(in_slice_flag)) {
in_slice_flag = 1;
if(!(picture->second_field)) decode_reorder_frames ();
// if(!(picture->second_field)) decode_reorder_frames ();
// set current_frame pointer:
if (picture->second_field){
// vo_field (picture->current_frame, picture->picture_structure);
} else {
if (picture->picture_coding_type == B_TYPE){
picture->current_frame = &frames[2];
picture->current_frame->copy=copy_slice;
} else {
picture->current_frame = picture->forward_reference_frame;
picture->forward_reference_frame = picture->backward_reference_frame;
picture->backward_reference_frame = picture->current_frame;
picture->current_frame->copy=NULL;
}
}
picture->current_frame->vo=output;
picture->current_frame->slice=0;
}
if (!drop_frame) {
uint8_t ** bar;
slice_process (picture, code, buffer);
if ((HACK_MODE < 2) && (!(picture->mpeg1))) {
uint8_t * foo[3];
uint8_t ** bar;
//frame_t * bar;
int stride[3];
int offset;
if (picture->picture_coding_type == B_TYPE)
bar = picture->throwaway_frame;
else
bar = picture->forward_reference_frame;
offset = (code-1) * 4 * picture->coded_picture_width;
if ((! HACK_MODE) && (picture->picture_coding_type == B_TYPE))
offset = 0;
foo[0] = bar[0] + 4 * offset;
foo[1] = bar[1] + offset;
foo[2] = bar[2] + offset;
stride[0]=picture->coded_picture_width;
stride[1]=stride[2]=stride[0]/2;
output->draw_slice (foo, stride,
picture->display_picture_width, 16, 0, (code-1)*16);
}
#ifdef ARCH_X86
if (config.flags & MM_ACCEL_X86_MMX) emms ();
#endif

View File

@ -1,6 +1,6 @@
/*
* slice.c
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -26,7 +26,7 @@
#include "mpeg2_internal.h"
#include "attributes.h"
// default intra quant matrix, in zig-zag order
/* default intra quant matrix, in zig-zag order */
static uint8_t default_intra_quantizer_matrix[64] ATTR_ALIGN(16) = {
8,
16, 16,
@ -47,7 +47,7 @@ static uint8_t default_intra_quantizer_matrix[64] ATTR_ALIGN(16) = {
uint8_t scan_norm[64] ATTR_ALIGN(16) =
{
// Zig-Zag scan pattern
/* Zig-Zag scan pattern */
0, 1, 8,16, 9, 2, 3,10,
17,24,32,25,18,11, 4, 5,
12,19,26,33,40,48,41,34,
@ -60,7 +60,7 @@ uint8_t scan_norm[64] ATTR_ALIGN(16) =
uint8_t scan_alt[64] ATTR_ALIGN(16) =
{
// Alternate scan pattern
/* Alternate scan pattern */
0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49,
41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43,
51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45,
@ -69,47 +69,34 @@ uint8_t scan_alt[64] ATTR_ALIGN(16) =
void header_state_init (picture_t * picture)
{
//FIXME we should set pointers to the real scan matrices here (mmx vs
//normal) instead of the ifdefs in header_process_picture_coding_extension
picture->scan = scan_norm;
}
static const int frameratecode2framerate[16] = {
0, 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001,
60*10000, 0,0,0,0,0,0,0
};
int header_process_sequence_header (picture_t * picture, uint8_t * buffer)
{
unsigned int h_size;
unsigned int v_size;
int width, height;
int i;
if ((buffer[6] & 0x20) != 0x20)
return 1; // missing marker_bit
return 1; /* missing marker_bit */
v_size = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
height = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
picture->display_picture_width = (v_size >> 12);
picture->display_picture_height = (v_size & 0xfff);
picture->display_picture_width = (height >> 12);
picture->display_picture_height = (height & 0xfff);
h_size = ((v_size >> 12) + 15) & ~15;
v_size = ((v_size & 0xfff) + 15) & ~15;
width = ((height >> 12) + 15) & ~15;
height = ((height & 0xfff) + 15) & ~15;
if ((h_size > 768) || (v_size > 576))
return 1; // size restrictions for MP@ML or MPEG1
if ((width > 768) || (height > 576))
return 1; /* size restrictions for MP@ML or MPEG1 */
//XXX this needs field fixups
picture->coded_picture_width = h_size;
picture->coded_picture_height = v_size;
picture->last_mba = ((h_size * v_size) >> 8) - 1;
picture->coded_picture_width = width;
picture->coded_picture_height = height;
// this is not used by the decoder
/* this is not used by the decoder */
picture->aspect_ratio_information = buffer[3] >> 4;
picture->frame_rate_code = buffer[3] & 15;
picture->frame_rate = frameratecode2framerate[picture->frame_rate_code];
picture->bitrate = (buffer[4]<<10)|(buffer[5]<<2)|(buffer[6]>>6);
if (buffer[7] & 2) {
@ -132,15 +119,15 @@ int header_process_sequence_header (picture_t * picture, uint8_t * buffer)
picture->non_intra_quantizer_matrix[i] = 16;
}
// MPEG1 - for testing only
/* MPEG1 - for testing only */
picture->mpeg1 = 1;
picture->intra_dc_precision = 0;
picture->frame_pred_frame_dct = 1;
picture->q_scale_type = 0;
picture->concealment_motion_vectors = 0;
//picture->alternate_scan = 0;
/* picture->alternate_scan = 0; */
picture->picture_structure = FRAME_PICTURE;
//picture->second_field = 0;
/* picture->second_field = 0; */
return 0;
}
@ -148,28 +135,20 @@ int header_process_sequence_header (picture_t * picture, uint8_t * buffer)
static int header_process_sequence_extension (picture_t * picture,
uint8_t * buffer)
{
// MPEG1 - for testing only
picture->mpeg1 = 0;
/* check chroma format, size extensions, marker bit */
if (((buffer[1] & 0x07) != 0x02) || (buffer[2] & 0xe0) ||
((buffer[3] & 0x01) != 0x01))
return 1;
// check chroma format, size extensions, marker bit
if(((buffer[1]>>1)&3)!=1){
printf("This CHROMA format not yet supported :(\n");
return 1;
}
if ((buffer[1] & 1) || (buffer[2] & 0xe0)){
printf("Big resolution video not yet supported :(\n");
return 1;
}
if((buffer[3] & 0x01) != 0x01) return 1; // marker bit
// this is not used by the decoder
/* this is not used by the decoder */
picture->progressive_sequence = (buffer[1] >> 3) & 1;
if (picture->progressive_sequence)
picture->coded_picture_height =
(picture->coded_picture_height + 31) & ~31;
picture->bitrate>>=1; // hack
/* MPEG1 - for testing only */
picture->mpeg1 = 0;
return 0;
}
@ -197,7 +176,7 @@ static int header_process_quant_matrix_extension (picture_t * picture,
static int header_process_picture_coding_extension (picture_t * picture, uint8_t * buffer)
{
//pre subtract 1 for use later in compute_motion_vector
/* pre subtract 1 for use later in compute_motion_vector */
picture->f_code[0][0] = (buffer[0] & 15) - 1;
picture->f_code[0][1] = (buffer[1] >> 4) - 1;
picture->f_code[1][0] = (buffer[1] & 15) - 1;
@ -210,12 +189,12 @@ static int header_process_picture_coding_extension (picture_t * picture, uint8_t
picture->q_scale_type = (buffer[3] >> 4) & 1;
picture->intra_vlc_format = (buffer[3] >> 3) & 1;
if (buffer[3] & 4) // alternate_scan
if (buffer[3] & 4) /* alternate_scan */
picture->scan = scan_alt;
else
picture->scan = scan_norm;
// these are not used by the decoder
/* these are not used by the decoder */
picture->top_field_first = buffer[3] >> 7;
picture->repeat_first_field = (buffer[3] >> 1) & 1;
picture->progressive_frame = buffer[4] >> 7;
@ -240,13 +219,13 @@ static int header_process_picture_coding_extension (picture_t * picture, uint8_t
int header_process_extension (picture_t * picture, uint8_t * buffer)
{
switch (buffer[0] & 0xf0) {
case 0x10: // sequence extension
case 0x10: /* sequence extension */
return header_process_sequence_extension (picture, buffer);
case 0x30: // quant matrix extension
case 0x30: /* quant matrix extension */
return header_process_quant_matrix_extension (picture, buffer);
case 0x80: // picture coding extension
case 0x80: /* picture coding extension */
return header_process_picture_coding_extension (picture, buffer);
}
@ -257,14 +236,14 @@ int header_process_picture_header (picture_t *picture, uint8_t * buffer)
{
picture->picture_coding_type = (buffer [1] >> 3) & 7;
// forward_f_code and backward_f_code - used in mpeg1 only
/* forward_f_code and backward_f_code - used in mpeg1 only */
picture->f_code[0][1] = (buffer[3] >> 2) & 1;
picture->f_code[0][0] =
(((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
picture->f_code[1][1] = (buffer[4] >> 6) & 1;
picture->f_code[1][0] = ((buffer[4] >> 3) & 7) - 1;
// move in header_process_picture_header
/* move in header_process_picture_header */
picture->second_field =
(picture->picture_structure != FRAME_PICTURE) &&
!(picture->second_field);

View File

@ -1,6 +1,6 @@
/*
* idct.c
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* Portions of this code are from the MPEG software simulation group
* idct implementation. This code will be replaced with a new
@ -52,8 +52,7 @@
#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */
// idct main entry point
/* idct main entry point */
void (*idct_block_copy) (int16_t * block, uint8_t * dest, int stride);
void (*idct_block_add) (int16_t * block, uint8_t * dest, int stride);

View File

@ -1,6 +1,6 @@
/*
* idct_mlib.c
* Copyright (C) 1999 Håkan Hjort <d95hjort@dtek.chalmers.se>
* Copyright (C) 1999-2001 Håkan Hjort <d95hjort@dtek.chalmers.se>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -38,8 +38,8 @@ 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)
{
// Should we use mlib_VideoIDCT_IEEE_S16_S16 here ??
// it's ~30% slower.
/* Should we use mlib_VideoIDCT_IEEE_S16_S16 here ?? */
/* it's ~30% slower. */
mlib_VideoIDCT8x8_S16_S16 (block, block);
mlib_VideoAddBlock_U8_S16 (dest, block, stride);
}

View File

@ -1,6 +1,6 @@
/*
* idct_mmx.c
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -37,7 +37,7 @@
#if 0
// C row IDCT - its just here to document the MMXEXT and MMX versions
/* C row IDCT - its just here to document the MMXEXT and MMX versions */
static inline void idct_row (int16_t * row, int offset,
int16_t * table, int32_t * rounder)
{
@ -76,7 +76,7 @@ static inline void idct_row (int16_t * row, int offset,
#endif
// MMXEXT row IDCT
/* MMXEXT row IDCT */
#define mmxext_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, -c4, -c2, \
c4, c6, c4, c6, \
@ -155,7 +155,7 @@ static inline void mmxext_row_tail (int16_t * row, int store)
movq_r2m (mm1, *(row+store)); // save y3 y2 y1 y0
pshufw_r2r (mm4, mm4, 0xb1); // mm4 = y7 y6 y5 y4
// slot
/* slot */
movq_r2m (mm4, *(row+store+4)); // save y7 y6 y5 y4
}
@ -188,7 +188,7 @@ static inline void mmxext_row_mid (int16_t * row, int store,
}
// MMX row IDCT
/* MMX row IDCT */
#define mmx_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, c4, c6, \
c4, c6, -c4, -c2, \
@ -276,7 +276,7 @@ static inline void mmx_row_tail (int16_t * row, int store)
por_r2r (mm4, mm7); // mm7 = y7 y6 y5 y4
// slot
/* slot */
movq_r2m (mm7, *(row+store+4)); // save y7 y6 y5 y4
}
@ -320,10 +320,10 @@ static inline void mmx_row_mid (int16_t * row, int store,
// C column IDCT - its just here to document the MMXEXT and MMX versions
static inline void idct_col (int16_t * col, int offset)
{
// multiplication - as implemented on mmx
/* multiplication - as implemented on mmx */
#define F(c,x) (((c) * (x)) >> 16)
// saturation - it helps us handle torture test cases
/* saturation - it helps us handle torture test cases */
#define S(x) (((x)>32767) ? 32767 : ((x)<-32768) ? -32768 : (x))
int16_t x0, x1, x2, x3, x4, x5, x6, x7;
@ -344,25 +344,25 @@ static inline void idct_col (int16_t * col, int offset)
u04 = S (x0 + x4);
v04 = S (x0 - x4);
u26 = S (F (T2, x6) + x2); // -0.5
v26 = S (F (T2, x2) - x6); // -0.5
u26 = S (F (T2, x6) + x2);
v26 = S (F (T2, x2) - x6);
a0 = S (u04 + u26);
a1 = S (v04 + v26);
a2 = S (v04 - v26);
a3 = S (u04 - u26);
u17 = S (F (T1, x7) + x1); // -0.5
v17 = S (F (T1, x1) - x7); // -0.5
u35 = S (F (T3, x5) + x3); // -0.5
v35 = S (F (T3, x3) - x5); // -0.5
u17 = S (F (T1, x7) + x1);
v17 = S (F (T1, x1) - x7);
u35 = S (F (T3, x5) + x3);
v35 = S (F (T3, x3) - x5);
b0 = S (u17 + u35);
b3 = S (v17 - v35);
u12 = S (u17 - u35);
v12 = S (v17 + v35);
u12 = S (2 * F (C4, u12)); // -0.5
v12 = S (2 * F (C4, v12)); // -0.5
u12 = S (2 * F (C4, u12));
v12 = S (2 * F (C4, v12));
b1 = S (u12 + v12);
b2 = S (u12 - v12);
@ -400,7 +400,6 @@ static inline void idct_col (int16_t * col, int offset)
static short _T2[] ATTR_ALIGN(8) = {T2,T2,T2,T2};
static short _T3[] ATTR_ALIGN(8) = {T3,T3,T3,T3};
static short _C4[] ATTR_ALIGN(8) = {C4,C4,C4,C4};
static mmx_t scratch0, scratch1;
/* column code adapted from peter gubanov */
/* http://www.elecard.com/peter/idct.shtml */
@ -428,7 +427,7 @@ static inline void idct_col (int16_t * col, int offset)
paddsw_r2r (mm2, mm1); // mm1 = u17
pmulhw_r2r (mm6, mm7); // mm7 = (T3-1)*x5
// slot
/* slot */
movq_r2r (mm4, mm2); // mm2 = T2
paddsw_r2r (mm3, mm5); // mm5 = T3*x3
@ -448,7 +447,7 @@ static inline void idct_col (int16_t * col, int offset)
psubsw_r2r (mm3, mm4); // mm4 = v26
paddsw_r2r (mm6, mm5); // mm5 = v12
movq_r2m (mm0, scratch0); // save b3
movq_r2m (mm0, *(col+offset+3*8)); // save b3 in scratch0
movq_r2r (mm1, mm6); // mm6 = u17
paddsw_m2r (*(col+offset+2*8), mm2);// mm2 = u26
@ -463,7 +462,7 @@ static inline void idct_col (int16_t * col, int offset)
movq_m2r (*_C4, mm0); // mm0 = C4/2
psubsw_r2r (mm5, mm7); // mm7 = u12-v12
movq_r2m (mm6, scratch1); // save b0
movq_r2m (mm6, *(col+offset+5*8)); // save b0 in scratch1
pmulhw_r2r (mm0, mm1); // mm1 = b1/2
movq_r2r (mm4, mm6); // mm6 = v26
@ -496,7 +495,7 @@ static inline void idct_col (int16_t * col, int offset)
psraw_i2r (COL_SHIFT, mm4); // mm4 = y1
psubsw_r2r (mm1, mm6); // mm6 = a1-b1
movq_m2r (scratch1, mm1); // mm1 = b0
movq_m2r (*(col+offset+5*8), mm1); // mm1 = b0
psubsw_r2r (mm7, mm2); // mm2 = a2-b2
psraw_i2r (COL_SHIFT, mm6); // mm6 = y6
@ -508,7 +507,7 @@ static inline void idct_col (int16_t * col, int offset)
movq_r2m (mm3, *(col+offset+2*8)); // save y2
paddsw_r2r (mm1, mm5); // mm5 = a0+b0
movq_m2r (scratch0, mm4); // mm4 = b3
movq_m2r (*(col+offset+3*8), mm4); // mm4 = b3
psubsw_r2r (mm1, mm7); // mm7 = a0-b0
psraw_i2r (COL_SHIFT, mm5); // mm5 = y0
@ -538,17 +537,17 @@ static int32_t rounder0[] ATTR_ALIGN(8) =
rounder ((1 << (COL_SHIFT - 1)) - 0.5);
static int32_t rounder4[] ATTR_ALIGN(8) = rounder (0);
static int32_t rounder1[] ATTR_ALIGN(8) =
rounder (1.25683487303); // C1*(C1/C4+C1+C7)/2
rounder (1.25683487303); /* C1*(C1/C4+C1+C7)/2 */
static int32_t rounder7[] ATTR_ALIGN(8) =
rounder (-0.25); // C1*(C7/C4+C7-C1)/2
rounder (-0.25); /* C1*(C7/C4+C7-C1)/2 */
static int32_t rounder2[] ATTR_ALIGN(8) =
rounder (0.60355339059); // C2 * (C6+C2)/2
rounder (0.60355339059); /* C2 * (C6+C2)/2 */
static int32_t rounder6[] ATTR_ALIGN(8) =
rounder (-0.25); // C2 * (C6-C2)/2
rounder (-0.25); /* C2 * (C6-C2)/2 */
static int32_t rounder3[] ATTR_ALIGN(8) =
rounder (0.087788325588); // C3*(-C3/C4+C3+C5)/2
rounder (0.087788325588); /* C3*(-C3/C4+C3+C5)/2 */
static int32_t rounder5[] ATTR_ALIGN(8) =
rounder (-0.441341716183); // C3*(-C5/C4+C5-C3)/2
rounder (-0.441341716183); /* C3*(-C5/C4+C5-C3)/2 */
#define declare_idct(idct,table,idct_row_head,idct_row,idct_row_tail,idct_row_mid) \
@ -693,7 +692,7 @@ void idct_mmx_init (void)
extern uint8_t scan_alt[64];
int i, j;
// the mmx/mmxext idct uses a reordered input, so we patch scan tables
/* the mmx/mmxext idct uses a reordered input, so we patch scan tables */
for (i = 0; i < 64; i++) {
j = scan_norm[i];

View File

@ -1,6 +1,6 @@
/*
* mmx.h
* Copyright (C) 1997-1999 H. Dietz and R. Fisher
* Copyright (C) 1997-2001 H. Dietz and R. Fisher
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -41,16 +41,16 @@ typedef union {
#define mmx_i2r(op,imm,reg) \
__asm__ __volatile__ (#op " %0, %%" #reg \
: /* nothing */ \
: "X" (imm) )
: "i" (imm) )
#define mmx_m2r(op,mem,reg) \
__asm__ __volatile__ (#op " %0, %%" #reg \
: /* nothing */ \
: "X" (mem))
: "m" (mem))
#define mmx_r2m(op,reg,mem) \
__asm__ __volatile__ (#op " %%" #reg ", %0" \
: "=X" (mem) \
: "=m" (mem) \
: /* nothing */ )
#define mmx_r2r(op,regs,regd) \

View File

@ -1,6 +1,6 @@
/*
* motion_comp.c
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -67,7 +67,7 @@ void motion_comp_init (void)
#define put(predictor,i) dest[i] = predictor (i)
#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
// mc function template
/* mc function template */
#define MC_FUNC(op,xy) \
static void MC_##op##_##xy##16_c (uint8_t * dest, uint8_t * ref,\
@ -111,7 +111,7 @@ static void MC_##op##_##xy##8_c (uint8_t * dest, uint8_t * ref, \
} while (--height); \
}
// definitions of the actual mc functions
/* definitions of the actual mc functions */
MC_FUNC (put,)
MC_FUNC (avg,)

View File

@ -1,6 +1,6 @@
/*
* MC_mlib.c
* Copyright (C) 2000 Håkan Hjort <d95hjort@dtek.chalmers.se>
* motion_comp_mlib.c
* Copyright (C) 2000-2001 Håkan Hjort <d95hjort@dtek.chalmers.se>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*

View File

@ -1,6 +1,6 @@
/*
* motion_comp_mmx.c
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -33,7 +33,7 @@
#define CPU_3DNOW 1
//MMX code - needs a rewrite
/* MMX code - needs a rewrite */
@ -41,7 +41,7 @@
// some rounding constants
/* some rounding constants */
mmx_t round1 = {0x0001000100010001LL};
mmx_t round4 = {0x0002000200020002LL};
@ -55,16 +55,14 @@ mmx_t round4 = {0x0002000200020002LL};
static inline void mmx_zero_reg ()
{
// load 0 into mm0
/* load 0 into mm0 */
pxor_r2r (mm0, mm0);
}
static inline void mmx_average_2_U8 (uint8_t * dest,
uint8_t * src1, uint8_t * src2)
{
//
// *dest = (*src1 + *src2 + 1)/ 2;
//
/* *dest = (*src1 + *src2 + 1)/ 2; */
movq_m2r (*src1, mm1); // load 8 src1 bytes
movq_r2r (mm1, mm2); // copy 8 src1 bytes
@ -93,9 +91,7 @@ static inline void mmx_average_2_U8 (uint8_t * dest,
static inline void mmx_interp_average_2_U8 (uint8_t * dest,
uint8_t * src1, uint8_t * src2)
{
//
// *dest = (*dest + (*src1 + *src2 + 1)/ 2 + 1)/ 2;
//
/* *dest = (*dest + (*src1 + *src2 + 1)/ 2 + 1)/ 2; */
movq_m2r (*dest, mm1); // load 8 dest bytes
movq_r2r (mm1, mm2); // copy 8 dest bytes
@ -139,9 +135,7 @@ static inline void mmx_average_4_U8 (uint8_t * dest,
uint8_t * src1, uint8_t * src2,
uint8_t * src3, uint8_t * src4)
{
//
// *dest = (*src1 + *src2 + *src3 + *src4 + 2)/ 4;
//
/* *dest = (*src1 + *src2 + *src3 + *src4 + 2)/ 4; */
movq_m2r (*src1, mm1); // load 8 src1 bytes
movq_r2r (mm1, mm2); // copy 8 src1 bytes
@ -158,7 +152,7 @@ static inline void mmx_average_4_U8 (uint8_t * dest,
paddw_r2r (mm3, mm1); // add lows
paddw_r2r (mm4, mm2); // add highs
// now have partials in mm1 and mm2
/* now have partials in mm1 and mm2 */
movq_m2r (*src3, mm3); // load 8 src3 bytes
movq_r2r (mm3, mm4); // copy 8 src3 bytes
@ -178,7 +172,7 @@ static inline void mmx_average_4_U8 (uint8_t * dest,
paddw_r2r (mm5, mm1); // add lows
paddw_r2r (mm6, mm2); // add highs
// now have subtotal in mm1 and mm2
/* now have subtotal in mm1 and mm2 */
paddw_m2r (round4, mm1);
psraw_i2r (2, mm1); // /4
@ -193,9 +187,7 @@ static inline void mmx_interp_average_4_U8 (uint8_t * dest,
uint8_t * src1, uint8_t * src2,
uint8_t * src3, uint8_t * src4)
{
//
// *dest = (*dest + (*src1 + *src2 + *src3 + *src4 + 2)/ 4 + 1)/ 2;
//
/* *dest = (*dest + (*src1 + *src2 + *src3 + *src4 + 2)/ 4 + 1)/ 2; */
movq_m2r (*src1, mm1); // load 8 src1 bytes
movq_r2r (mm1, mm2); // copy 8 src1 bytes
@ -212,7 +204,7 @@ static inline void mmx_interp_average_4_U8 (uint8_t * dest,
paddw_r2r (mm3, mm1); // add lows
paddw_r2r (mm4, mm2); // add highs
// now have partials in mm1 and mm2
/* now have partials in mm1 and mm2 */
movq_m2r (*src3, mm3); // load 8 src3 bytes
movq_r2r (mm3, mm4); // copy 8 src3 bytes
@ -237,7 +229,7 @@ static inline void mmx_interp_average_4_U8 (uint8_t * dest,
paddw_m2r (round4, mm2);
psraw_i2r (2, mm2); // /4
// now have subtotal/4 in mm1 and mm2
/* now have subtotal/4 in mm1 and mm2 */
movq_m2r (*dest, mm3); // load 8 dest bytes
movq_r2r (mm3, mm4); // copy 8 dest bytes
@ -253,13 +245,13 @@ static inline void mmx_interp_average_4_U8 (uint8_t * dest,
paddw_m2r (round1, mm2);
psraw_i2r (1, mm2); // /2
// now have end value in mm1 and mm2
/* now have end value in mm1 and mm2 */
packuswb_r2r (mm2, mm1); // pack (w/ saturation)
movq_r2m (mm1,*dest); // store result in dest
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
static inline void MC_avg_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
@ -289,7 +281,7 @@ static void MC_avg_8_mmx (uint8_t * dest, uint8_t * ref,
MC_avg_mmx (8, height, dest, ref, stride);
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
static inline void MC_put_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
@ -323,9 +315,9 @@ static void MC_put_8_mmx (uint8_t * dest, uint8_t * ref,
MC_put_mmx (8, height, dest, ref, stride);
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
// Half pixel interpolation in the x direction
/* Half pixel interpolation in the x direction */
static inline void MC_avg_x_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
{
@ -354,7 +346,7 @@ static void MC_avg_x8_mmx (uint8_t * dest, uint8_t * ref,
MC_avg_x_mmx (8, height, dest, ref, stride);
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
static inline void MC_put_x_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
@ -384,7 +376,7 @@ static void MC_put_x8_mmx (uint8_t * dest, uint8_t * ref,
MC_put_x_mmx (8, height, dest, ref, stride);
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
static inline void MC_avg_xy_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
@ -418,7 +410,7 @@ static void MC_avg_xy8_mmx (uint8_t * dest, uint8_t * ref,
MC_avg_xy_mmx (8, height, dest, ref, stride);
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
static inline void MC_put_xy_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
@ -451,7 +443,7 @@ static void MC_put_xy8_mmx (uint8_t * dest, uint8_t * ref,
MC_put_xy_mmx (8, height, dest, ref, stride);
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
static inline void MC_avg_y_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
@ -484,7 +476,7 @@ static void MC_avg_y8_mmx (uint8_t * dest, uint8_t * ref,
MC_avg_y_mmx (8, height, dest, ref, stride);
}
//-----------------------------------------------------------------------
/*-----------------------------------------------------------------------*/
static inline void MC_put_y_mmx (int width, int height,
uint8_t * dest, uint8_t * ref, int stride)
@ -526,7 +518,7 @@ MOTION_COMP_EXTERN (mmx)
//CPU_MMXEXT/CPU_3DNOW adaptation layer
/* CPU_MMXEXT/CPU_3DNOW adaptation layer */
#define pavg_r2r(src,dest) \
do { \
@ -545,7 +537,7 @@ do { \
} while (0)
//CPU_MMXEXT code
/* CPU_MMXEXT code */
static inline void MC_put1_8 (int height, uint8_t * dest, uint8_t * ref,

View File

@ -1,57 +1,71 @@
/*
* mpeg2.h
*
* Copyright (C) Aaron Holtzman <aholtzma@ess.engr.uvic.ca> - Mar 2000
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* 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, or (at your option)
* any later version.
*
* 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
* 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 GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation,
*
* 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
*/
#ifdef __OMS__
#include <oms/plugin/output_video.h>
#ifndef vo_functions_t
#define vo_functions_t plugin_output_video_t
#endif
#else
//FIXME normally I wouldn't nest includes, but we'll leave this here until I get
//another chance to move things around
#include "video_out.h"
#endif
/* Structure for the mpeg2dec decoder */
#include <inttypes.h>
#ifdef __OMS__
#include <oms/accel.h>
#else
#include "mm_accel.h"
#endif
typedef struct mpeg2dec_s {
// vo_instance_t * output;
//config flags
#define MPEG2_MLIB_ENABLE MM_ACCEL_MLIB
#define MPEG2_MMX_ENABLE MM_ACCEL_X86_MMX
#define MPEG2_3DNOW_ENABLE MM_ACCEL_X86_3DNOW
#define MPEG2_SSE_ENABLE MM_ACCEL_X86_MMXEXT
/* this is where we keep the state of the decoder */
struct picture_s * picture;
uint32_t shift;
int is_display_initialized;
int is_sequence_needed;
int drop_flag;
int drop_frame;
int in_slice;
/* the maximum chunk size is determined by vbv_buffer_size */
/* which is 224K for MP@ML streams. */
/* (we make no pretenses of decoding anything more than that) */
/* allocated in init - gcc has problems allocating such big structures */
uint8_t * chunk_buffer;
/* pointer to current position in chunk_buffer */
uint8_t * chunk_ptr;
/* last start code ? */
uint8_t code;
/* ONLY for 0.2.0 release - will not stay there later */
int frame_rate_code;
} mpeg2dec_t ;
//typedef struct mpeg2_config_s {
// //Bit flags that enable various things
// uint32_t flags;
//} mpeg2_config_t;
void mpeg2_init (void);
//void mpeg2_allocate_image_buffers (picture_t * picture);
int mpeg2_decode_data (vo_functions_t *, uint8_t * data_start, uint8_t * data_end);
//void mpeg2_close (vo_functions_t *);
void mpeg2_drop (int flag);
/* initialize mpegdec with a opaque user pointer */
//void mpeg2_init (mpeg2dec_t * mpeg2dec, uint32_t mm_accel
// ,vo_instance_t * output
// );
/* destroy everything which was allocated, shutdown the output */
//void mpeg2_close (mpeg2dec_t * mpeg2dec);
//int mpeg2_decode_data (mpeg2dec_t * mpeg2dec,
// uint8_t * data_start, uint8_t * data_end);
//void mpeg2_drop (mpeg2dec_t * mpeg2dec, int flag);

View File

@ -1,7 +1,6 @@
#include <inttypes.h>
/*
* mpeg2_internal.h
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -20,20 +19,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// hack mode - temporary
// 0 = decode B pictures in a small slice buffer, display slice per slice
// 1 = decode in a frame buffer, display slice per slice
// 2 = decode in a frame buffer, display whole frames
#define HACK_MODE 0
// macroblock modes
/* macroblock modes */
#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
// motion_type
/* motion_type */
#define MOTION_TYPE_MASK (3*64)
#define MOTION_TYPE_BASE 64
#define MC_FIELD (1*64)
@ -41,151 +34,154 @@
#define MC_16X8 (2*64)
#define MC_DMV (3*64)
//picture structure
/* picture structure */
#define TOP_FIELD 1
#define BOTTOM_FIELD 2
#define FRAME_PICTURE 3
//picture coding type
/* picture coding type */
#define I_TYPE 1
#define P_TYPE 2
#define B_TYPE 3
#define D_TYPE 4
//The picture struct contains all of the top level state
//information (ie everything except slice and macroblock
//state)
typedef struct picture_s {
//-- sequence header stuff --
uint8_t intra_quantizer_matrix [64];
uint8_t non_intra_quantizer_matrix [64];
//The width and height of the picture snapped to macroblock units
int coded_picture_width;
int coded_picture_height;
//-- picture header stuff --
//what type of picture this is (I,P,or B) D from MPEG-1 isn't supported
int picture_coding_type;
//-- picture coding extension stuff --
//quantization factor for motion vectors
int f_code[2][2];
//quantization factor for intra dc coefficients
int intra_dc_precision;
//top/bottom/both fields
int picture_structure;
//bool to indicate all predictions are frame based
int frame_pred_frame_dct;
//bool to indicate whether intra blocks have motion vectors
// (for concealment)
int concealment_motion_vectors;
//bit to indicate which quantization table to use
int q_scale_type;
//bool to use different vlc tables
int intra_vlc_format;
//last macroblock in the picture
int last_mba;
//width of picture in macroblocks
int mb_width;
//stuff derived from bitstream
//pointer to the zigzag scan we're supposed to be using
uint8_t * scan;
//Pointer to the current planar frame buffer (Y,Cr,CB)
uint8_t * current_frame[3];
//storage for reference frames plus a b-frame
uint8_t * forward_reference_frame[3];
uint8_t * backward_reference_frame[3];
uint8_t * throwaway_frame[3];
uint8_t * pp_frame[3]; // postprocess
//uint8_t * throwaway_frame;
int pp_options; // postprocess
int second_field;
// MPEG1 - testing
uint8_t mpeg1;
//these things are not needed by the decoder
//NOTICE : this is a temporary interface, we will build a better one later.
int aspect_ratio_information;
int frame_rate_code;
int progressive_sequence;
int top_field_first; // this one is actually used for DMV MC
int repeat_first_field;
int progressive_frame;
// added by A'rpi/ESP-team:
int repeat_count;
int bitrate;
int frame_rate;
int display_picture_width;
int display_picture_height;
} picture_t;
typedef struct motion_s {
uint8_t * ref[2][3];
int pmv[2][2];
int f_code[2];
} motion_t;
// state that is carried from one macroblock to the next inside of a same slice
typedef struct slice_s {
// 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
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;
int slice;
// void (* field) (struct vo_frame_s * frame, int flags);
// void (* draw) (struct vo_frame_s * frame);
// vo_instance_t * instance;
} vo_frame_t;
//Motion vectors
//The f_ and b_ correspond to the forward and backward motion
//predictors
typedef struct picture_s {
/* 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
/* predictor for DC coefficients in intra blocks */
int16_t dc_dct_pred[3];
uint16_t quantizer_scale; // remove
} slice_t;
int quantizer_scale; /* remove */
int current_field; /* remove */
/* now non-slice-specific information */
/* sequence header stuff */
uint8_t intra_quantizer_matrix [64];
uint8_t non_intra_quantizer_matrix [64];
/* The width and height of the picture snapped to macroblock units */
int coded_picture_width;
int coded_picture_height;
/* picture header stuff */
/* what type of picture this is (I, P, B, D) */
int picture_coding_type;
/* picture coding extension stuff */
/* quantization factor for motion vectors */
int f_code[2][2];
/* quantization factor for intra dc coefficients */
int intra_dc_precision;
/* top/bottom/both fields */
int picture_structure;
/* bool to indicate all predictions are frame based */
int frame_pred_frame_dct;
/* bool to indicate whether intra blocks have motion vectors */
/* (for concealment) */
int concealment_motion_vectors;
/* bit to indicate which quantization table to use */
int q_scale_type;
/* bool to use different vlc tables */
int intra_vlc_format;
/* used for DMV MC */
int top_field_first;
/* stuff derived from bitstream */
/* pointer to the zigzag scan we're supposed to be using */
uint8_t * scan;
struct vo_frame_s * current_frame;
struct vo_frame_s * forward_reference_frame;
struct vo_frame_s * backward_reference_frame;
int second_field;
int mpeg1;
/* these things are not needed by the decoder */
/* this is a temporary interface, we will build a better one later. */
int aspect_ratio_information;
int frame_rate_code;
int progressive_sequence;
int repeat_first_field;
int progressive_frame;
int bitrate;
// added by A'rpi/ESP-team
int display_picture_width;
int display_picture_height;
int pp_options;
int repeat_count;
} picture_t;
typedef struct mpeg2_config_s {
//Bit flags that enable various things
/* Bit flags that enable various things */
uint32_t flags;
} mpeg2_config_t;
//The only global variable,
//the config struct
/* The only global variable, */
/* the config struct */
extern mpeg2_config_t config;
// slice.c
/* slice.c */
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);
// idct.c
/* idct.c */
void idct_init (void);
// idct_mlib.c
/* idct_mlib.c */
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);
// idct_mmx.c
/* idct_mmx.c */
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);
// motion_comp.c
/* motion_comp.c */
void motion_comp_init (void);
typedef struct mc_functions_s
@ -208,13 +204,8 @@ extern mc_functions_t mc_functions_mmxext;
extern mc_functions_t mc_functions_3dnow;
extern mc_functions_t mc_functions_mlib;
// slice.c
/* slice.c */
int slice_process (picture_t *picture, uint8_t code, uint8_t * buffer);
// stats.c
/* stats.c */
void stats_header (uint8_t code, uint8_t * buffer);
#define MBC 45
#define MBR 36
extern int quant_store[MBR+1][MBC+1]; // [Review]

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/*
* stats.c
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -29,8 +29,8 @@
static int debug_level = -1;
// Determine is debug output is required.
// We could potentially have multiple levels of debug info
/* Determine is debug output is required. */
/* We could potentially have multiple levels of debug info */
static int debug_is_on (void)
{
char * env_var;
@ -152,7 +152,7 @@ static void stats_group (uint8_t * buffer)
static void stats_slice (uint8_t code, uint8_t * buffer)
{
//fprintf (stderr, " (slice %d)\n", code);
/* fprintf (stderr, " (slice %d)\n", code); */
}
static void stats_sequence_extension (uint8_t * buffer)
@ -274,7 +274,6 @@ void stats_header (uint8_t code, uint8_t * buffer)
stats_sequence_error (buffer);
break;
case 0xb5:
//stats_extension (buffer);
switch (buffer[0] >> 4) {
case 1:
stats_sequence_extension (buffer);

View File

@ -1,6 +1,6 @@
/*
* vlc.h
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
@ -25,14 +25,14 @@ do { \
bit_ptr += 2; \
} while (0)
static inline void bitstream_init (slice_t * slice, uint8_t * start)
static inline void bitstream_init (picture_t * picture, uint8_t * start)
{
slice->bitstream_buf = 0; GETWORD (slice->bitstream_buf, 16, start);
slice->bitstream_ptr = start;
slice->bitstream_bits = 0;
picture->bitstream_buf = 0; GETWORD (picture->bitstream_buf, 16, start);
picture->bitstream_ptr = start;
picture->bitstream_bits = 0;
}
// make sure that there are at least 16 valid bits in bit_buf
/* make sure that there are at least 16 valid bits in bit_buf */
#define NEEDBITS(bit_buf,bits,bit_ptr) \
do { \
if (bits > 0) { \
@ -41,17 +41,17 @@ do { \
} \
} while (0)
// remove num valid bits from bit_buf
/* remove num valid bits from bit_buf */
#define DUMPBITS(bit_buf,bits,num) \
do { \
bit_buf <<= (num); \
bits += (num); \
} while (0)
// take num bits from the high part of bit_buf and zero extend them
/* take num bits from the high part of bit_buf and zero extend them */
#define UBITS(bit_buf,num) (((uint32_t)(bit_buf)) >> (32 - (num)))
// take num bits from the high part of bit_buf and sign extend them
/* take num bits from the high part of bit_buf and sign extend them */
#define SBITS(bit_buf,num) (((int32_t)(bit_buf)) >> (32 - (num)))
typedef struct {

View File

@ -29,6 +29,8 @@
#include "version.h"
#include "config.h"
#include "libvo/video_out.h"
// CODECS:
#include "mp3lib/mp3.h"
#include "libac3/ac3.h"
@ -37,7 +39,6 @@
#include "loader.h"
#include "wine/avifmt.h"
//#include "libvo/x11_common.h" // included from mpeg2.h
#include "opendivx/decore.h"
@ -861,7 +862,7 @@ switch(has_video){
printf ("bad sequence header extension!\n"); return 1;
}
}
default_fps=picture->frame_rate*0.0001f;
default_fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;
if(verbose) printf("mpeg bitrate: %d (%X)\n",picture->bitrate,picture->bitrate);
printf("VIDEO: %s %dx%d (aspect %d) %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n",
picture->mpeg1?"MPEG1":"MPEG2",
@ -989,6 +990,7 @@ float num_frames=0; // number of frames played
double video_time_usage=0;
double vout_time_usage=0;
double audio_time_usage=0;
int grab_frames=0;
#ifdef HAVE_LIRC
lirc_mp_setup();
@ -1495,11 +1497,17 @@ switch(has_video){
if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode
else if(!i){ eof=1; break;} // EOF
}
if(grab_frames==2 && (i==0x1B3 || i==0x1B8)) grab_frames=1;
if(!read_video_packet(d_video)){ eof=1; break;} // EOF
//printf("read packet 0x%X, len=%d\n",i,videobuf_len);
}
if(videobuf_len>max_framesize) max_framesize=videobuf_len; // debug
//printf("--- SEND %d bytes\n",videobuf_len);
if(grab_frames==1){
FILE *f=fopen("grab.mpg","ab");
fwrite(videobuffer,videobuf_len-4,1,f);
fclose(f);
}
++dbg_es_sent;
//if(videobuf_len>4)
my_write(data_fifo,(char*) &videobuf_len,4);
@ -1671,6 +1679,7 @@ switch(has_video){
case KEY_ESC: // ESC
case KEY_ENTER: // ESC
case 'q': exit_player("Quit");
case 'g': grab_frames=2;break;
// restart codec
case 'k': kill(codec_pid,SIGKILL);break;
// case 'k': kill(child_pid,SIGKILL);break;