/*
* H263/MPEG4 backend for ffmpeg encoder and decoder
* Copyright (c) 2000,2001 Fabrice Bellard.
* H263+ support.
* Copyright (c) 2001 Juan J. Sierralta P.
*
* This library 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 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ac prediction encoding, b-frame support, error resilience, optimizations,
* qpel decoding, gmc decoding, interlaced decoding,
* by Michael Niedermayer <michaelni@gmx.at>
*/
//#define DEBUG
#include "common.h"
#include "dsputil.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "h263data.h"
#include "mpeg4data.h"
//#undef NDEBUG
//#include <assert.h>
#if 1
#define PRINT_MB_TYPE(a) {}
#else
#define PRINT_MB_TYPE(a) printf(a)
#endif
#define INTRA_MCBPC_VLC_BITS 6
#define INTER_MCBPC_VLC_BITS 6
#define CBPY_VLC_BITS 6
#define MV_VLC_BITS 9
#define DC_VLC_BITS 9
#define SPRITE_TRAJ_VLC_BITS 6
#define MB_TYPE_B_VLC_BITS 4
#define TEX_VLC_BITS 9
#ifdef CONFIG_ENCODERS
static void h263_encode_block(MpegEncContext * s, DCTELEM * block,
int n);
static void h263_encode_motion(MpegEncContext * s, int val, int fcode);
static void h263p_encode_umotion(MpegEncContext * s, int val);
static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block,
int n, int dc, UINT8 *scan_table,
PutBitContext *dc_pb, PutBitContext *ac_pb);
#endif
static int h263_decode_motion(MpegEncContext * s, int pred, int fcode);
static int h263p_decode_umotion(MpegEncContext * s, int pred);
static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded);
static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, int intra);
static int h263_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr);
static void mpeg4_inv_pred_ac(MpegEncContext * s, INT16 *block, int n,
int dir);
static void mpeg4_decode_sprite_trajectory(MpegEncContext * s);
static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr, int *dir_ptr);
extern UINT32 inverse[256];
static UINT16 uni_DCtab_lum [512][2];
static UINT16 uni_DCtab_chrom[512][2];
#ifdef CONFIG_ENCODERS
static UINT16 (*mv_penalty)[MAX_MV*2+1]= NULL;
static UINT8 fcode_tab[MAX_MV*2+1];
static UINT8 umv_fcode_tab[MAX_MV*2+1];
static UINT32 uni_mpeg4_intra_rl_bits[64*64*2*2];
static UINT8 uni_mpeg4_intra_rl_len [64*64*2*2];
static UINT32 uni_mpeg4_inter_rl_bits[64*64*2*2];
static UINT8 uni_mpeg4_inter_rl_len [64*64*2*2];
#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128 + (run)*256 + (level))
//#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run) + (level)*64)
/* mpeg4
inter
max level: 24/6
max run: 53/63
intra
max level: 53/16
max run: 29/41
*/
#endif
int h263_get_picture_format(int width, int height)
{
int format;
if (width == 128 && height == 96)
format = 1;
else if (width == 176 && height == 144)
format = 2;
else if (width == 352 && height == 288)
format = 3;
else if (width == 704 && height == 576)
format = 4;
else if (width == 1408 && height == 1152)
format = 5;
else
format = 7;
return format;
}
static void init_aspect_info(MpegEncContext * s){
double aspect;
emms_c(); //paranoia ;)
if(s->avctx->aspect_ratio==0) aspect= 1.0;
aspect= s->avctx->aspect_ratio;
ff_float2fraction(&s->aspected_width, &s->aspected_height, aspect, 255);
if(s->aspected_width == 4 && s->aspected_height == 3)
s->aspect_ratio_info= FF_ASPECT_4_3_625;
else if(s->aspected_width == 16 && s->aspected_height == 9)
s->aspect_ratio_info= FF_ASPECT_16_9_625;
else if(s->aspected_width == 1 && s->aspected_height == 1)
s->aspect_ratio_info= FF_ASPECT_SQUARE;
else
s->aspect_ratio_info= FF_ASPECT_EXTENDED;
}
void h263_encode_picture_header(MpegEncContext * s, int picture_number)
{
int format;
align_put_bits(&s->pb);
/* Update the pointer to last GOB */
s->ptr_lastgob = pbBufPtr(&s->pb);
s->gob_number = 0;
put_bits(&s->pb, 22, 0x20); /* PSC */
put_bits(&s->pb, 8, (((INT64)s->picture_number * 30 * FRAME_RATE_BASE) /
s->frame_rate) & 0xff);
put_bits(&s->pb, 1, 1); /* marker */
put_bits(&s->pb, 1, 0); /* h263 id */
put_bits(&s->pb, 1, 0); /* split screen off */
put_bits(&s->pb, 1, 0); /* camera off */
put_bits(&s->pb, 1, 0); /* freeze picture release off */
format = h263_get_picture_format(s->width, s->height);
if (!s->h263_plus) {
/* H.263v1 */
put_bits(&s->pb, 3, format);
put_bits(&s->pb, 1, (s->pict_type == P_TYPE));
/* By now UMV IS DISABLED ON H.263v1, since the restrictions
of H.263v1 UMV implies to check the predicted MV after
calculation of the current MB to see if we're on the limits */
put_bits(&s->pb, 1, 0); /* unrestricted motion vector: off */
put_bits(&s->pb, 1, 0); /* SAC: off */
put_bits(&s->pb, 1, 0); /* advanced prediction mode: off */
put_bits(&s->pb, 1, 0); /* not PB frame */
put_bits(&s->pb, 5, s->qscale);
put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
} else {
/* H.263v2 */
/* H.263 Plus PTYPE */
put_bits(&s->pb, 3, 7);
put_bits(&s->pb,3,1); /* Update Full Extended PTYPE */
if (format == 7)
put_bits(&s->pb,3,6); /* Custom Source Format */
else
put_bits(&s->pb, 3, format);
put_bits(&s->pb,1,0); /* Custom PCF: off */
s->umvplus = (s->pict_type == P_TYPE) && s->unrestricted_mv;
put_bits(&s->pb, 1, s->umvplus); /* Unrestricted Motion Vector */
put_bits(&s->pb,1,0); /* SAC: off */
put_bits(&s->pb,1,0); /* Advanced Prediction Mode: off */
put_bits(&s->pb,1,s->h263_aic); /* Advanced Intra Coding */
put_bits(&s->pb,1,0); /* Deblocking Filter: off */
put_bits(&s->pb,1,0); /* Slice Structured: off */
put_bits(&s->pb,1,0); /* Reference Picture Selection: off */
put_bits(&s->pb,1,0); /* Independent Segment Decoding: off */
put_bits(&s->pb,1,0); /* Alternative Inter VLC: off */
put_bits(&s->pb,1,0); /* Modified Quantization: off */
put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
put_bits(&s->pb,3,0); /* Reserved */
put_bits(&s->pb, 3, s->pict_type == P_TYPE);
put_bits(&s->pb,1,0); /* Reference Picture Resampling: off */
put_bits(&s->pb,1,0); /* Reduced-Resolution Update: off */
if (s->pict_type == I_TYPE)
s->no_rounding = 0;
else
s->no_rounding ^= 1;
put_bits(&s->pb,1,s->no_rounding); /* Rounding Type */
put_bits(&s->pb,2,0); /* Reserved */
put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
/* This should be here if PLUSPTYPE */
put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
if (format == 7) {
/* Custom Picture Format (CPFMT) */
init_aspect_info(s);
put_bits(&s->pb,4,s->aspect_ratio_info);
没有合适的资源?快使用搜索试试~ 我知道了~
qtopia-free-1.7.0.tar.gz
5星 · 超过95%的资源 需积分: 17 164 下载量 78 浏览量
2009-03-19
19:31:34
上传
评论 2
收藏 10.53MB GZ 举报
温馨提示
共5507个文件
html:1834个
h:797个
png:635个
嵌入式QT平台搭建的必要文件之一,是LINUX平台优秀的人机界面编写工具,搭建这个平台需要六个文件,我会全部上传。
资源推荐
资源详情
资源评论
收起资源包目录
qtopia-free-1.7.0.tar.gz (5507个子文件)
gsm_option.3 5KB
gsm.3 3KB
Abidjan 73B
Accra 156B
Acre 226B
ACT 785B
Adak 840B
Makefile.add 138B
Addis_Ababa 74B
addressbook 38B
addressbook 23B
Adelaide 785B
Aden 73B
Alaska 839B
Aleutian 840B
Algiers 287B
Almaty 682B
Amman 692B
Amsterdam 1KB
Anadyr 716B
Anchorage 839B
Andorra 624B
Anguilla 73B
Antananarivo 104B
Antigua 90B
Apia 91B
Aqtau 780B
Aqtobe 738B
Araguaina 671B
Arizona 130B
Aruba 90B
Ashgabat 273B
Ashkhabad 273B
Asmera 74B
AST4 78B
AST4ADT 1KB
Asuncion 729B
at 416B
Athens 823B
Atka 840B
Atlantic 1KB
Auckland 870B
AUTHORS 155B
AUTHORS 63B
Azores 1KB
Baghdad 661B
Bahrain 90B
BajaNorte 844B
BajaSur 569B
Baku 758B
Bamako 95B
Bangkok 73B
Bangui 73B
Banjul 107B
Barbados 142B
Beirut 769B
Belem 226B
Belfast 1KB
Belgrade 696B
Belize 368B
Berlin 837B
Bermuda 725B
Bishkek 728B
Bissau 90B
Blantyre 73B
Boa_Vista 246B
Bogota 96B
Boise 866B
Bratislava 806B
Brazzaville 73B
Brisbane 160B
Broken_Hill 790B
Brunei 86B
Brussels 1KB
Bucharest 798B
Budapest 866B
Buenos_Aires 377B
Bujumbura 56B
h263.c 155KB
mpegvideo.c 115KB
mpegaudiodec.c 74KB
huffman.c 71KB
mpeg12.c 63KB
layer3.c 63KB
msmpeg4.c 59KB
dsputil.c 58KB
motion_est.c 56KB
svq1.c 52KB
simple_idct_mmx.c 52KB
mjpeg.c 47KB
mov.c 44KB
ac3enc.c 42KB
wmadec.c 42KB
asf.c 37KB
huffyuv.c 36KB
imgconvert.c 34KB
jrevdct.c 33KB
error_resilience.c 33KB
utils.c 33KB
rtsp.c 32KB
共 5507 条
- 1
- 2
- 3
- 4
- 5
- 6
- 56
黑鸟与幽灵
- 粉丝: 32
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页