/*
* 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>
*/
/**
* @file h263.c
* h263/mpeg4 codec.
*/
//#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>
#define INTRA_MCBPC_VLC_BITS 6
#define INTER_MCBPC_VLC_BITS 7
#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_t *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, int rvlc);
static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr);
#ifdef CONFIG_ENCODERS
static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
int dir);
static void mpeg4_encode_visual_object_header(MpegEncContext * s);
static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number);
#endif //CONFIG_ENCODERS
static void mpeg4_decode_sprite_trajectory(MpegEncContext * s);
static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr);
#ifdef CONFIG_ENCODERS
static uint8_t uni_DCtab_lum_len[512];
static uint8_t uni_DCtab_chrom_len[512];
static uint16_t uni_DCtab_lum_bits[512];
static uint16_t uni_DCtab_chrom_bits[512];
static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
static uint8_t fcode_tab[MAX_MV*2+1];
static uint8_t umv_fcode_tab[MAX_MV*2+1];
static uint32_t uni_mpeg4_intra_rl_bits[64*64*2*2];
static uint8_t uni_mpeg4_intra_rl_len [64*64*2*2];
static uint32_t uni_mpeg4_inter_rl_bits[64*64*2*2];
static uint8_t 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)
#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
/* mpeg4
inter
max level: 24/6
max run: 53/63
intra
max level: 53/16
max run: 29/41
*/
#endif
#if 0 //3IV1 is quite rare and tis slows things down a tiny bit
#define IS_3IV1 s->avctx->codec_tag == ff_get_fourcc("3IV1")
#else
#define IS_3IV1 0
#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;
}
#ifdef CONFIG_ENCODERS
static void float_aspect_to_info(MpegEncContext * s, float aspect){
int i;
aspect*= s->height/(double)s->width;
//printf("%f\n", aspect);
if(aspect==0) aspect= 1.0;
ff_float2fraction(&s->aspected_width, &s->aspected_height, aspect, 255);
//printf("%d %d\n", s->aspected_width, s->aspected_height);
for(i=1; i<6; i++){
if(s->aspected_width == pixel_aspect[i][0] && s->aspected_height== pixel_aspect[i][1]){
s->aspect_ratio_info=i;
return;
}
}
s->aspect_ratio_info= FF_ASPECT_EXTENDED;
}
void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number)
{
int format;
align_put_bits(&s->pb);
put_bits(&s->pb, 17, 1);
put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */
put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->frame_rate_base) /
s->avctx->frame_rate) & 0xff); /* TemporalReference */
if (s->width == 352 && s->height == 288)
format = 2;
else if (s->width == 176 && s->height == 144)
format = 3;
else if (s->width == 128 && s->height == 96)
format = 4;
else if (s->width == 320 && s->height == 240)
format = 5;
else if (s->width == 160 && s->height == 120)
format = 6;
else if (s->width <= 255 && s->height <= 255)
format = 0; /* use 1 byte width & height */
else
format = 1; /* use 2 bytes width & height */
put_bits(&s->pb, 3, format); /* PictureSize */
if (format == 0) {
put_bits(&s->pb, 8, s->width);
put_bits(&s->pb, 8, s->height);
} else if (format == 1) {
put_bits(&s->pb, 16, s->width);
put_bits(&s->pb, 16, s->height);
}
put_bits(&s->pb, 2, s->pict_type == P_TYPE); /* PictureType */
put_bits(&s->pb, 1, 1); /* DeblockingFlag: on */
put_bits(&s->pb, 5, s->qscale); /* Quantizer */
put_bits(&s->pb, 1, 0); /* ExtraInformation */
if(s->h263_aic){
s->y_dc_scale_table=
s->c_dc_scale_table= h263_aic_dc_scale_table;
}else{
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
}
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_t)s->picture_number * 30 * s->avctx->frame_rate_base) /
s->avctx->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 predic
没有合适的资源?快使用搜索试试~ 我知道了~
ffmpeg-0.4.8_src_20070726.rar_GM8180_ffmpeg_ffmpeg-0.11_ffmpeg-4
共546个文件
c:230个
h:120个
entries:32个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 161 浏览量
2022-09-21
05:43:43
上传
评论
收藏 2.3MB RAR 举报
温馨提示
GM8120/GM8180 ffmepg-0.48 完整原代码
资源推荐
资源详情
资源评论
收起资源包目录
ffmpeg-0.4.8_src_20070726.rar_GM8180_ffmpeg_ffmpeg-0.11_ffmpeg-4 (546个子文件)
ffmpeg.1 20KB
ffplay.1 6KB
ffserver.1 5KB
night.264 88KB
libSDL.a 306KB
libSDL.a 306KB
h263.c 175KB
mpegvideo.c 164KB
ffserver.c 156KB
h264.c 150KB
ffmpeg.c 147KB
dsputil.c 114KB
postprocess_template.c 96KB
vp3.c 92KB
mpeg12.c 87KB
mpegaudiodec.c 77KB
dsputil_mmx.c 68KB
qpel.c 67KB
ffplay.c 66KB
mjpeg.c 63KB
msmpeg4.c 60KB
imgconvert.c 58KB
firmware_7113.c 57KB
motion_est.c 56KB
fcap.c 55KB
mov.c 54KB
simple_idct_mmx.c 52KB
utils.c 47KB
dsputil_altivec.c 45KB
ac3enc.c 43KB
wmadec.c 41KB
motion_est_template.c 38KB
asf.c 38KB
fmjpeg_avcodec.c 38KB
error_resilience.c 38KB
indeo3.c 37KB
huffyuv.c 37KB
rtsp.c 34KB
jrevdct.c 33KB
grab.c 31KB
adpcm.c 30KB
rtp.c 30KB
svq3.c 29KB
mpegts.c 28KB
interplayvideo.c 28KB
fmpeg4_avcodec.c 28KB
ratecontrol.c 28KB
ffv1.c 27KB
postprocess.c 27KB
png.c 27KB
rm.c 26KB
dvcore.c 25KB
h263dec.c 25KB
wmv2.c 25KB
mpegvideo_altivec.c 24KB
ratecontrol.c 24KB
dv.c 24KB
movenc.c 24KB
avidec.c 24KB
avienc.c 23KB
svq1.c 23KB
parse.c 23KB
mpegaudio.c 23KB
4xm.c 23KB
ratecontrol.c 22KB
imgresample.c 22KB
xan.c 22KB
fcap_ctrl.c 22KB
mace.c 22KB
asv1.c 20KB
favc_avcodec.c 20KB
ipmovie.c 20KB
mpeg.c 20KB
ffm.c 19KB
mpegtsenc.c 19KB
idct_mmx.c 18KB
utils.c 17KB
downmix.c 17KB
rv10.c 16KB
jpeg_main.c 16KB
aviobuf.c 16KB
mpegvideo_mmx.c 16KB
gifdec.c 16KB
simple_idct.c 16KB
mpegvideo_mmx_template.c 16KB
gif.c 15KB
resample_mmx.c 15KB
jpeg_main.c 15KB
ffocus.c 15KB
dsputil_alpha.c 14KB
fcap_misc.c 14KB
swf.c 14KB
dct-test.c 14KB
nut.c 14KB
output_example.c 14KB
img.c 14KB
apiexample.c 13KB
wc3movie.c 13KB
i2c.c 13KB
motion_est_mmx.c 13KB
共 546 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
weixin_42653672
- 粉丝: 93
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功