⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slice.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
/* $Id$ * slice.c * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> * Copyright (C) 2003      Peter Gubanov <peter@elecard.net.ru> * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. * See http://libmpeg2.sourceforge.net/ for updates. * * 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 */#include "xxmc-config.h"#include <inttypes.h>#include "mpeg2.h"#include "attributes.h"#include "mpeg2_internal.h"extern mpeg2_mc_t mpeg2_mc;extern void (* mpeg2_cpu_state_save) (cpu_state_t * state);extern void (* mpeg2_cpu_state_restore) (cpu_state_t * state);#include "vlc.h"static inline int get_motion_delta( mpeg2_decoder_t * const decoder,				    const int f_code ){#define bit_buf (decoder->bitstream_buf)#define bits (decoder->bitstream_bits)#define bit_ptr (decoder->bitstream_ptr)    int delta;    int sign;    const MVtab * tab;    if( bit_buf & 0x80000000 )    {        DUMPBITS (bit_buf, bits, 1);        return 0;    }    else if (bit_buf >= 0x0c000000)    {        tab = MV_4 + UBITS (bit_buf, 4);        delta = (tab->delta << f_code) + 1;        bits += tab->len + f_code + 1;        bit_buf <<= tab->len;        sign = SBITS (bit_buf, 1);        bit_buf <<= 1;        if (f_code)            delta += UBITS (bit_buf, f_code);        bit_buf <<= f_code;        return (delta ^ sign) - sign;    }    else    {        tab = MV_10 + UBITS (bit_buf, 10);        delta = (tab->delta << f_code) + 1;        bits += tab->len + 1;        bit_buf <<= tab->len;        sign = SBITS (bit_buf, 1);        bit_buf <<= 1;        if (f_code)        {            NEEDBITS (bit_buf, bits, bit_ptr);            delta += UBITS (bit_buf, f_code);            DUMPBITS (bit_buf, bits, f_code);        }        return (delta ^ sign) - sign;    }#undef bit_buf#undef bits#undef bit_ptr}static inline int bound_motion_vector (const int vector, const int f_code){    return ((int32_t)vector << (27 - f_code)) >> (27 - f_code);}static inline int get_dmv (mpeg2_decoder_t * const decoder){#define bit_buf (decoder->bitstream_buf)#define bits (decoder->bitstream_bits)#define bit_ptr (decoder->bitstream_ptr)    const DMVtab * tab;    tab = DMV_2 + UBITS (bit_buf, 2);    DUMPBITS (bit_buf, bits, tab->len);    return tab->dmv;#undef bit_buf#undef bits#undef bit_ptr}#define MOTION_420(table,ref,motion_x,motion_y,size,y)			      \    pos_x = 2 * decoder->offset + motion_x;				      \    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;			      \    if (unlikely (pos_x > decoder->limit_x)) {				      \	pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;		      \	motion_x = pos_x - 2 * decoder->offset;				      \    }									      \    if (unlikely (pos_y > decoder->limit_y_ ## size)) {			      \	pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;	      \	motion_y = pos_y - 2 * decoder->v_offset - 2 * y;		      \    }									      \    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);				      \    table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \		    ref[0] + (pos_x >> 1) + (pos_y >> 1) * decoder->stride,   \		    decoder->stride, size);				      \    motion_x /= 2;	motion_y /= 2;					      \    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);			      \    offset = (((decoder->offset + motion_x) >> 1) +			      \	      ((((decoder->v_offset + motion_y) >> 1) + y/2) *		      \	       decoder->uv_stride));					      \    table[4+xy_half] (decoder->dest[1] + y/2 * decoder->uv_stride +	      \		      (decoder->offset >> 1), ref[1] + offset,		      \		      decoder->uv_stride, size/2);			      \    table[4+xy_half] (decoder->dest[2] + y/2 * decoder->uv_stride +	      \		      (decoder->offset >> 1), ref[2] + offset,		      \		      decoder->uv_stride, size/2)#define MOTION_FIELD_420(table,ref,motion_x,motion_y,dest_field,op,src_field) \    pos_x = 2 * decoder->offset + motion_x;				      \    pos_y = decoder->v_offset + motion_y;				      \    if (unlikely (pos_x > decoder->limit_x)) {				      \	pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;		      \	motion_x = pos_x - 2 * decoder->offset;				      \    }									      \    if (unlikely (pos_y > decoder->limit_y)) {				      \	pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;		      \	motion_y = pos_y - decoder->v_offset;				      \    }									      \    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);				      \    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +	      \		    decoder->offset,					      \		    (ref[0] + (pos_x >> 1) +				      \		     ((pos_y op) + src_field) * decoder->stride),	      \		    2 * decoder->stride, 8);				      \    motion_x /= 2;	motion_y /= 2;					      \    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);			      \    offset = (((decoder->offset + motion_x) >> 1) +			      \	      (((decoder->v_offset >> 1) + (motion_y op) + src_field) *	      \	       decoder->uv_stride));					      \    table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride +    \		      (decoder->offset >> 1), ref[1] + offset,		      \		      2 * decoder->uv_stride, 4);			      \    table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride +    \		      (decoder->offset >> 1), ref[2] + offset,		      \		      2 * decoder->uv_stride, 4)#define MOTION_DMV_420(table,ref,motion_x,motion_y)			      \    pos_x = 2 * decoder->offset + motion_x;				      \    pos_y = decoder->v_offset + motion_y;				      \    if (unlikely (pos_x > decoder->limit_x)) {				      \	pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;		      \	motion_x = pos_x - 2 * decoder->offset;				      \    }									      \    if (unlikely (pos_y > decoder->limit_y)) {				      \	pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;		      \	motion_y = pos_y - decoder->v_offset;				      \    }									      \    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);				      \    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;		      \    table[xy_half] (decoder->dest[0] + decoder->offset,			      \		    ref[0] + offset, 2 * decoder->stride, 8);		      \    table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset,     \		    ref[0] + decoder->stride + offset,			      \		    2 * decoder->stride, 8);				      \    motion_x /= 2;	motion_y /= 2;					      \    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);			      \    offset = (((decoder->offset + motion_x) >> 1) +			      \	      (((decoder->v_offset >> 1) + (motion_y & ~1)) *		      \	       decoder->uv_stride));					      \    table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1),	      \		      ref[1] + offset, 2 * decoder->uv_stride, 4);	      \    table[4+xy_half] (decoder->dest[1] + decoder->uv_stride +		      \		      (decoder->offset >> 1),				      \		      ref[1] + decoder->uv_stride + offset,		      \		      2 * decoder->uv_stride, 4);			      \    table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1),	      \		      ref[2] + offset, 2 * decoder->uv_stride, 4);	      \    table[4+xy_half] (decoder->dest[2] + decoder->uv_stride +		      \		      (decoder->offset >> 1),				      \		      ref[2] + decoder->uv_stride + offset,		      \		      2 * decoder->uv_stride, 4)#define MOTION_ZERO_420(table,ref)					      \    table[0] (decoder->dest[0] + decoder->offset,			      \	      (ref[0] + decoder->offset +				      \	       decoder->v_offset * decoder->stride), decoder->stride, 16);    \    offset = ((decoder->offset >> 1) +					      \	      (decoder->v_offset >> 1) * decoder->uv_stride);		      \    table[4] (decoder->dest[1] + (decoder->offset >> 1),		      \	      ref[1] + offset, decoder->uv_stride, 8);			      \    table[4] (decoder->dest[2] + (decoder->offset >> 1),		      \	      ref[2] + offset, decoder->uv_stride, 8)#define MOTION_422(table,ref,motion_x,motion_y,size,y)			      \    pos_x = 2 * decoder->offset + motion_x;				      \    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;			      \    if (unlikely (pos_x > decoder->limit_x)) {				      \	pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;		      \	motion_x = pos_x - 2 * decoder->offset;				      \    }									      \    if (unlikely (pos_y > decoder->limit_y_ ## size)) {			      \	pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;	      \	motion_y = pos_y - 2 * decoder->v_offset - 2 * y;		      \    }									      \    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);				      \    offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride;		      \    table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \		    ref[0] + offset, decoder->stride, size);		      \    offset = (offset + (motion_x & (motion_x < 0))) >> 1;		      \    motion_x /= 2;							      \    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);			      \    table[4+xy_half] (decoder->dest[1] + y * decoder->uv_stride +	      \		      (decoder->offset >> 1), ref[1] + offset,		      \		      decoder->uv_stride, size);			      \    table[4+xy_half] (decoder->dest[2] + y * decoder->uv_stride +	      \		      (decoder->offset >> 1), ref[2] + offset,		      \		      decoder->uv_stride, size)#define MOTION_FIELD_422(table,ref,motion_x,motion_y,dest_field,op,src_field) \    pos_x = 2 * decoder->offset + motion_x;				      \    pos_y = decoder->v_offset + motion_y;				      \    if (unlikely (pos_x > decoder->limit_x)) {				      \	pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;		      \	motion_x = pos_x - 2 * decoder->offset;				      \    }									      \    if (unlikely (pos_y > decoder->limit_y)) {				      \	pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;		      \	motion_y = pos_y - decoder->v_offset;				      \    }									      \    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);				      \    offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride;	      \    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +	      \		    decoder->offset, ref[0] + offset,			      \		    2 * decoder->stride, 8);				      \    offset = (offset + (motion_x & (motion_x < 0))) >> 1;		      \    motion_x /= 2;							      \    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);			      \    table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride +    \		      (decoder->offset >> 1), ref[1] + offset,		      \		      2 * decoder->uv_stride, 8);			      \    table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride +    \		      (decoder->offset >> 1), ref[2] + offset,		      \		      2 * decoder->uv_stride, 8)#define MOTION_DMV_422(table,ref,motion_x,motion_y)			      \    pos_x = 2 * decoder->offset + motion_x;				      \    pos_y = decoder->v_offset + motion_y;				      \    if (unlikely (pos_x > decoder->limit_x)) {				      \	pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;		      \	motion_x = pos_x - 2 * decoder->offset;				      \    }									      \    if (unlikely (pos_y > decoder->limit_y)) {				      \	pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;		      \	motion_y = pos_y - decoder->v_offset;				      \    }									      \    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);				      \    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;		      \    table[xy_half] (decoder->dest[0] + decoder->offset,			      \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -