/*
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file libavcodec/h264.c
* H.264 / AVC / MPEG4 part10 codec.
* @author Michael Niedermayer <michaelni@gmx.at>
*/
#include "internal.h"
#include "dsputil.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "h264.h"
#include "h264data.h"
#include "h264_parser.h"
#include "golomb.h"
#include "mathops.h"
#include "rectangle.h"
#include "vdpau_internal.h"
#include "cabac.h"
#if ARCH_X86
#include "x86/h264_i386.h"
#endif
//#undef NDEBUG
#include <assert.h>
/**
* Value of Picture.reference when Picture is not a reference picture, but
* is held for delayed output.
*/
#define DELAYED_PIC_REF 4
static VLC coeff_token_vlc[4];
static VLC_TYPE coeff_token_vlc_tables[520+332+280+256][2];
static const int coeff_token_vlc_tables_size[4]={520,332,280,256};
static VLC chroma_dc_coeff_token_vlc;
static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2];
static const int chroma_dc_coeff_token_vlc_table_size = 256;
static VLC total_zeros_vlc[15];
static VLC_TYPE total_zeros_vlc_tables[15][512][2];
static const int total_zeros_vlc_tables_size = 512;
static VLC chroma_dc_total_zeros_vlc[3];
static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2];
static const int chroma_dc_total_zeros_vlc_tables_size = 8;
static VLC run_vlc[6];
static VLC_TYPE run_vlc_tables[6][8][2];
static const int run_vlc_tables_size = 8;
static VLC run7_vlc;
static VLC_TYPE run7_vlc_table[96][2];
static const int run7_vlc_table_size = 96;
static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp);
static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
static Picture * remove_long(H264Context *h, int i, int ref_mask);
static av_always_inline uint32_t pack16to32(int a, int b){
#ifdef WORDS_BIGENDIAN
return (b&0xFFFF) + (a<<16);
#else
return (a&0xFFFF) + (b<<16);
#endif
}
static const uint8_t rem6[52]={
0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
};
static const uint8_t div6[52]={
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
};
static const uint8_t left_block_options[4][8]={
{0,1,2,3,7,10,8,11},
{2,2,3,3,8,11,8,11},
{0,0,1,1,7,10,7,10},
{0,2,0,2,7,10,7,10}
};
#define LEVEL_TAB_BITS 8
static int8_t cavlc_level_tab[7][1<<LEVEL_TAB_BITS][2];
static void fill_caches(H264Context *h, int mb_type, int for_deblock){
MpegEncContext * const s = &h->s;
const int mb_xy= h->mb_xy;
int topleft_xy, top_xy, topright_xy, left_xy[2];
int topleft_type, top_type, topright_type, left_type[2];
const uint8_t * left_block;
int topleft_partition= -1;
int i;
top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE);
//FIXME deblocking could skip the intra and nnz parts.
if(for_deblock && (h->slice_num == 1 || h->slice_table[mb_xy] == h->slice_table[top_xy]) && !FRAME_MBAFF)
return;
/* Wow, what a mess, why didn't they simplify the interlacing & intra
* stuff, I can't imagine that these complex rules are worth it. */
topleft_xy = top_xy - 1;
topright_xy= top_xy + 1;
left_xy[1] = left_xy[0] = mb_xy-1;
left_block = left_block_options[0];
if(FRAME_MBAFF){
const int pair_xy = s->mb_x + (s->mb_y & ~1)*s->mb_stride;
const int top_pair_xy = pair_xy - s->mb_stride;
const int topleft_pair_xy = top_pair_xy - 1;
const int topright_pair_xy = top_pair_xy + 1;
const int topleft_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[topleft_pair_xy]);
const int top_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[top_pair_xy]);
const int topright_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[topright_pair_xy]);
const int left_mb_field_flag = IS_INTERLACED(s->current_picture.mb_type[pair_xy-1]);
const int curr_mb_field_flag = IS_INTERLACED(mb_type);
const int bottom = (s->mb_y & 1);
tprintf(s->avctx, "fill_caches: curr_mb_field_flag:%d, left_mb_field_flag:%d, topleft_mb_field_flag:%d, top_mb_field_flag:%d, topright_mb_field_flag:%d\n", curr_mb_field_flag, left_mb_field_flag, topleft_mb_field_flag, top_mb_field_flag, topright_mb_field_flag);
if (curr_mb_field_flag && (bottom || top_mb_field_flag)){
top_xy -= s->mb_stride;
}
if (curr_mb_field_flag && (bottom || topleft_mb_field_flag)){
topleft_xy -= s->mb_stride;
} else if(bottom && !curr_mb_field_flag && left_mb_field_flag) {
topleft_xy += s->mb_stride;
// take top left mv from the middle of the mb, as opposed to all other modes which use the bottom right partition
topleft_partition = 0;
}
if (curr_mb_field_flag && (bottom || topright_mb_field_flag)){
topright_xy -= s->mb_stride;
}
if (left_mb_field_flag != curr_mb_field_flag) {
left_xy[1] = left_xy[0] = pair_xy - 1;
if (curr_mb_field_flag) {
left_xy[1] += s->mb_stride;
left_block = left_block_options[3];
} else {
left_block= left_block_options[2 - bottom];
}
}
}
h->top_mb_xy = top_xy;
h->left_mb_xy[0] = left_xy[0];
h->left_mb_xy[1] = left_xy[1];
if(for_deblock){
topleft_type = 0;
topright_type = 0;
top_type = h->slice_table[top_xy ] < 0xFFFF ? s->current_picture.mb_type[top_xy] : 0;
left_type[0] = h->slice_table[left_xy[0] ] < 0xFFFF ? s->current_picture.mb_type[left_xy[0]] : 0;
left_type[1] = h->slice_table[left_xy[1] ] < 0xFFFF ? s->current_picture.mb_type[left_xy[1]] : 0;
if(MB_MBAFF && !IS_INTRA(mb_type)){
int list;
for(list=0; list<h->list_count; list++){
//These values where changed for ease of performing MC, we need to change them back
//FIXME maybe we can make MC and loop filter use the same values or prevent
//the MC code from changing ref_cache and rather use a temporary array.
if(USES_LIST(mb_type,list)){
int8_t *ref = &s->current_picture.ref_index[list][h->mb2b8_xy[mb_xy]];
*(uint32_t*)&h->ref_cache[list][scan8[ 0]] =
*(uint32_t*)&h->ref_cache[list][scan8[ 2]] = (pack16to32(ref[0],ref[1])&0x00FF00FF)*0x0101;
ref += h->b8_stride;
*(uint32_t*)&h->ref_cache[list][scan8[ 8]] =
*(uint32_t*)&h->ref_cache[list][scan8[10]] = (pack16to32(ref[0],ref[1])&0x00FF00FF)*0x0101;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
linux下 Mplayer 执行程序 (3277个子文件)
mplayer.1 349KB
mplayer.1 346KB
mplayer.1 345KB
mplayer.1 343KB
mplayer.1 325KB
mplayer.1 313KB
mplayer.1 302KB
mplayer.1 302KB
mplayer.1 255KB
mplayer.1 224KB
Makefile.am 982B
Makefile.am 756B
Makefile.am 350B
h264_deblock_sse2.asm 19KB
x86inc.asm 14KB
fft_mmx.asm 11KB
x86util.asm 5KB
dsputil_yasm.asm 4KB
h264_idct_sse2.asm 2KB
hacking.ati 9KB
README.Ati 4KB
AUTHORS 32KB
pci_db2c.awk 10KB
h264.c 315KB
h263.c 215KB
snow.c 180KB
dsputil.c 167KB
postprocess_template.c 161KB
vc1.c 155KB
win32.c 140KB
mpegvideo_enc.c 139KB
vorbis_data.c 129KB
swscale_template.c 128KB
dsputil_mmx.c 124KB
dsputil_vis.c 119KB
radeon_vid.c 114KB
mplayer.c 114KB
tvi_dshow.c 110KB
swscale.c 107KB
utils.c 101KB
rgb2rgb_template.c 98KB
demux_mkv.c 97KB
command.c 93KB
h264dsp_mmx.c 92KB
mpegvideo.c 87KB
mpeg12.c 87KB
sbr_hfadj.c 83KB
msmpeg4data.c 83KB
vp3.c 81KB
demux_ts.c 80KB
demux_mov.c 80KB
sbr_dct.c 80KB
imgconvert.c 80KB
syntax.c 78KB
mpegaudiodec.c 78KB
ass_render.c 75KB
mov.c 74KB
tvi_v4l2.c 72KB
x11_common.c 71KB
simple_idct_mmx.c 71KB
motion_est.c 71KB
opts.c 71KB
mxfenc.c 71KB
muxer_mpeg.c 70KB
ps_dec.c 69KB
slice.c 69KB
demux_real.c 67KB
tvi_v4l.c 66KB
qdm2.c 66KB
subreader.c 66KB
matroskadec.c 65KB
ifo_read.c 65KB
aac.c 64KB
vf_fspp.c 63KB
movenc.c 63KB
adpcm.c 61KB
qpel.c 61KB
msmpeg4.c 60KB
vorbis_dec.c 59KB
ac3dec_data.c 59KB
ioctl.c 58KB
css.c 58KB
tvi_vbi.c 58KB
gl_common.c 57KB
dsputil_altivec.c 57KB
vm.c 56KB
vo_directx.c 56KB
mga_vid.c 55KB
input.c 54KB
mencoder.c 54KB
postprocess_altivec_template.c 53KB
gui.c 53KB
vo_sdl.c 52KB
rtsp.c 52KB
parser.c 52KB
rv34.c 52KB
h264_altivec.c 51KB
mjpegdec.c 51KB
demuxer.c 50KB
ve_xvid4.c 50KB
共 3277 条
- 1
- 2
- 3
- 4
- 5
- 6
- 33
资源评论
- zgrobben2022-01-14假的 , 不是可执行的,需要编译的。气愤
- I'mAlex2013-05-12经过测试,该资源为源码,并不是可执行程序。需要自己编译
- 本初君2014-05-12呵呵,谢谢分享,终于找到源码了
lijinxue22
- 粉丝: 2
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 手机电脑互传文件LocalSend(一款免费、开源、跨平台的局域网文件互传软件)
- 小波分析是一种基于时频分析的数学工具,它的核心概念是小波变换和小波系数 小波变换通过将信号与小波函数进行卷积运算,得到一系列的小
- 五一数学建模联赛的论文通常包含了对特定问题的数学建模、算法设计、编程实现以及结果分析等部分 由于具体的题目和解决方案会因每年的比
- 2024年五一数学建模竞赛是一项重要的数学建模赛事,旨在通过模拟面对实际问题寻求解决方案的活动,训练学生的想象力、洞察力和创造力
- Unity3D游戏源码PLUS教程(2018)3D传送门
- 管理系统源码是一套用于支持和优化组织内部运营的软件程序资源,涵盖了从项目规划、执行到监控的全方位管理功能 以下是关于管理系统源码
- Unity3D游戏源码PLUS教程火炬之光demo第四代
- Python爬虫是一种使用Python编程语言来自动化获取网页数据的技术 这项技术主要涉及到向目标服务器发送请求,获取HTML页
- Unity3D游戏源码PLUS教程大型ARPG手游(降临)客户端服务端全套源码
- 毕业设计是大学生涯中一项重要且富有挑战性的任务,它不仅是对学生专业知识掌握程度的检验,更是对学生创新能力、实践能力和团队协作能力
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功