/************************************************************************
*
* getpic.c, picture decoding for tmndecode (H.263 decoder)
* Copyright (C) 1995, 1996 Telenor R&D, Norway
*
* Contacts:
* Robert Danielsen <Robert.Danielsen@nta.no>
*
* Telenor Research and Development http://www.nta.no/brukere/DVC/
* P.O.Box 83 tel.: +47 63 84 84 00
* N-2007 Kjeller, Norway fax.: +47 63 81 00 76
*
* Copyright (C) 1997 University of BC, Canada
* Modified by: Mike Gallant <mikeg@ee.ubc.ca>
* Guy Cote <guyc@ee.ubc.ca>
* Berna Erol <bernae@ee.ubc.ca>
*
* Contacts:
* Micheal Gallant <mikeg@ee.ubc.ca>
*
* UBC Image Processing Laboratory http://www.ee.ubc.ca/image
* 2356 Main Mall tel.: +1 604 822 4051
* Vancouver BC Canada V6T1Z4 fax.: +1 604 822 5949
*
************************************************************************/
/* Disclaimer of Warranty
*
* These software programs are available to the user without any license fee
* or royalty on an "as is" basis. The University of British Columbia
* disclaims any and all warranties, whether express, implied, or
* statuary, including any implied warranties or merchantability or of
* fitness for a particular purpose. In no event shall the
* copyright-holder be liable for any incidental, punitive, or
* consequential damages of any kind whatsoever arising from the use of
* these programs.
*
* This disclaimer of warranty extends to the user of these programs and
* user's customers, employees, agents, transferees, successors, and
* assigns.
*
* The University of British Columbia does not represent or warrant that the
* programs furnished hereunder are free of infringement of any
* third-party patents.
*
* Commercial implementations of H.263, including shareware, are subject to
* royalty fees to patent holders. Many of these patents are general
* enough such that they are unavoidable regardless of implementation
* design.
*
*/
/* modified to support annex O true B frames, mikeg@ee.ubc.ca
*
* modified by Wayne Ellis BT Labs to run Annex E Arithmetic Decoding
* <ellis_w_wayne@bt-web.bt.co.uk>
*
* based on mpeg2decode, (C) 1994, MPEG Software Simulation Group and
* mpeg2play, (C) 1994 Stefan Eckart <stefan@lis.e-technik.tu-muenchen.de> */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "tmndec.h"
#include "global.h"
#include "indices.h"
#include "sactbls.h"
static int coded_map[MBR + 1][MBC + 1];
static int quant_map[MBR + 1][MBC + 1];
static int STRENGTH[] = {1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12};
static int STRENGTH1[] = {1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4};
static int STRENGTH2[] = {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
/* private prototypes */
static void get_I_P_MBs _ANSI_ARGS_ ((int framenum, int gob));
static void get_B_MBs _ANSI_ARGS_ ((int framenum));
static void get_EI_EP_MBs _ANSI_ARGS_ ((int framenum));
static void clearblock _ANSI_ARGS_ ((int comp));
static int motion_decode _ANSI_ARGS_ ((int vec, int pmv));
static int find_pmv _ANSI_ARGS_ ((int x, int y, int block, int comp));
static void addblock _ANSI_ARGS_ ((int comp, int bx, int by, int addflag));
static void reconblock_b _ANSI_ARGS_ ((int comp, int bx, int by, int mode, int bdx, int bdy));
static void find_bidir_limits _ANSI_ARGS_ ((int vec, int *start, int *stop, int nhv));
static void find_bidir_chroma_limits _ANSI_ARGS_ ((int vec, int *start, int *stop));
static void make_edge_image _ANSI_ARGS_ ((unsigned char *src, unsigned char *dst, int width, int height, int edge));
static void init_enhancement_layer _ANSI_ARGS_((int layer));
void edge_filter _ANSI_ARGS_ ((unsigned char *lum, unsigned char *Cb, unsigned char *Cr, int width, int height));
void horiz_edge_filter _ANSI_ARGS_ ((unsigned char *rec, int width, int height, int chr));
void vert_edge_filter _ANSI_ARGS_ ((unsigned char *rec, int width, int height, int chr));
void vert_post_filter (unsigned char *rec, int width, int height, int chr);
void horiz_post_filter (unsigned char *rec, int width, int height, int chr);
void PostFilter (unsigned char *lum, unsigned char *Cb, unsigned char *Cr, int width, int height);
/* reference picture selection */
int get_reference_picture(void);
void store_picture(int);
/* error concealment */
void conceal_missing_gobs(int start_mb_row_missing, int number_of_mb_rows_missing);
/**********************************************************************
*
* Name: getpicture
* Description: decode and display one picture
* Input: frame number
* Returns:
* Side effects:
*
* Date: 971102 Author: mikeg@ee.ubc.ca
*
*
***********************************************************************/
void getpicture (int *framenum, int gob)
{
unsigned char *tmp;
int i, store_pb, quality=0;
static int absolute_temp_ref = 0;
static int prev_temp_ref = 0;
FILE *fout;
switch (pict_type)
{
case PCT_INTRA:
case PCT_INTER:
case PCT_PB:
case PCT_IPB:
enhance_pict = NO;
if (0 == UFEP && plus_type)
{
mv_outside_frame = prev_mv_outside_frame;
deblocking_filter_mode = prev_df;
adv_pred_mode = prev_adv_pred;
overlapping_MC = prev_obmc;
use_4mv = prev_4mv;
long_vectors = prev_long_vectors;
syntax_arith_coding = prev_sac;
advanced_intra_coding = prev_aic;
slice_structured_mode = prev_slice_struct;
reference_picture_selection_mode = prev_rps;
independently_segmented_decoding_mode = prev_isd;
alternative_inter_VLC_mode = prev_aivlc;
modified_quantization_mode = prev_mq;
}
for (i = 0; i < 3; i++)
{
tmp = prev_frame[i];
prev_I_P_frame[i] = prev_frame[i] = next_I_P_frame[i];
next_I_P_frame[i] = current_frame[i] = tmp;
}
/* if the picture header is missing, assume temp_ref increments */
/* not done yet*/
/* Annex N: get the correct reference picture for prediction */
if (reference_picture_selection_mode)
{
if (-1 == (quality = get_reference_picture()))
break;
if (quality > 256)
{
fprintf(stderr,"completely out of sync -- waiting for I-frame\n");
stop_decoder = 1;
break;
}
}
#ifdef DEBUG
if (temp_ref < prev_temp_ref) prev_temp_ref -= 256;
absolute_temp_ref += temp_ref - prev_temp_ref;
prev_temp_ref = temp_ref;
fprintf(stdout, "%d\n", absolute_temp_ref);
#endif
if ((mv_outside_frame) && (*framenum > 0))
{
make_edge_image (prev_I_P_frame[0], edgeframe[0], coded_picture_width,
coded_picture_height, 32);
make_edge_image (prev_I_P_frame[1], edgeframe[1], chrom_width, chrom_height, 16);
make_edge_image (prev_I_P_frame[2], edgeframe[2], chrom_width, chrom_height, 16);
}
get_I_P_MBs (*framenum, gob);
store_pb = pb_frame;
pb_frame = 0;
if (deblocking_filter_mode)
{
edge_filter (current_frame[0], current_frame[1], current_frame[2],
coded_picture_width, coded_picture_height);
printf("do deblocking\n");
}
#if 1
fout = fopen("origen2.yuv", "wb");
if (fout == NULL)
{
printf("open output file fail\n");
exit(-1);
}
for(i=0;i<288;i++)
{
if (fwrite((current_frame[0]+coded_picture_width*i), 352, 1, fout) < 0)
{
printf("error/n");
break;
}
}
for(i=0;i<144;i++)
{
if(fwrite((current_frame[1]+(coded_picture_width>>1)*i),
没有合适的资源?快使用搜索试试~ 我知道了~
H263编解码器,使用纯C语言实现
共131个文件
obj:37个
c:37个
h:15个
5星 · 超过95%的资源 需积分: 13 129 下载量 199 浏览量
2009-03-15
21:10:12
上传
评论 3
收藏 1.45MB RAR 举报
温馨提示
H263的编解码器,纯C语言实现。带有VC6.0的工程文件,有命令行转换的实现
资源推荐
资源详情
资源评论
收起资源包目录
H263编解码器,使用纯C语言实现 (131个子文件)
getpic.c 115KB
countbit.c 81KB
P_picture.c 69KB
main.c 60KB
recon.c 41KB
B_picture.c 38KB
mot_est.c 33KB
gethdr.c 27KB
block_functions.c 23KB
EP_picture.c 22KB
dct.c 22KB
picture_functions.c 21KB
getblk.c 18KB
intra_pred.c 17KB
yuv2rgb.c 17KB
tmndec.c 16KB
ratectrl.c 16KB
display.c 15KB
store.c 14KB
getvlc.c 13KB
EI_picture.c 13KB
win.c 10KB
putvlc.c 9KB
I_picture.c 7KB
quant.c 7KB
filter.c 7KB
idct.c 7KB
dither.c 7KB
sac.c 7KB
sac.c 6KB
ring_buf.c 6KB
yuvrgb24.c 6KB
snr.c 5KB
ring_buf.c 4KB
getbits.c 4KB
putbits.c 4KB
idctref.c 4KB
CHANGES 14KB
CHANGES 14KB
COPYING 0B
UBC.COPYRIGHT 523B
UBC.COPYRIGHT 523B
DISCLAIM 1KB
DISCLAIM 1KB
tmn_coder.dsp 6KB
h263tmndec.dsp 6KB
tmn_coder.dsp 4KB
h263tmndec.dsw 545B
tmn_coder.dsw 543B
tmn_coder.dsw 543B
tmn_coder.exe 552KB
h263tmndec.exe 404KB
sim.h 30KB
getvlc.h 16KB
global.h 16KB
sactbls.h 15KB
sactbls.h 14KB
vlc.h 13KB
config.h 8KB
indices.h 7KB
tmndec.h 6KB
indices.h 5KB
win.h 3KB
main.h 3KB
macros.h 2KB
config.h 2KB
putvlc.h 2KB
vc60.idb 65KB
vc60.idb 57KB
tmn_coder.ilk 384KB
h263tmndec.ilk 310KB
tmndec.mak 10KB
Makefile 2KB
tmn_coder.ncb 153KB
h263tmndec.ncb 97KB
tmn_coder.ncb 41KB
getpic.obj 112KB
countbit.obj 102KB
main.obj 94KB
P_picture.obj 62KB
recon.obj 46KB
gethdr.obj 44KB
B_picture.obj 35KB
getvlc.obj 35KB
getblk.obj 33KB
block_functions.obj 31KB
tmndec.obj 31KB
EP_picture.obj 25KB
picture_functions.obj 24KB
putvlc.obj 24KB
ratectrl.obj 23KB
mot_est.obj 23KB
store.obj 21KB
dct.obj 20KB
intra_pred.obj 20KB
EI_picture.obj 16KB
filter.obj 13KB
I_picture.obj 13KB
sac.obj 11KB
quant.obj 10KB
共 131 条
- 1
- 2
baronban
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页