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

📄 store.c

📁 h263解码程序.。。。。。。。。。。。
💻 C
字号:
/************************************************************************
 *
 *  store.c, picture output routines 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: Michael Gallant <mikeg@ee.ubc.ca>
 *               Guy Cote <guyc@ee.ubc.ca>
 *               Berna Erol <bernae@ee.ubc.ca>
 *
 *  Contacts:
 *  Michael 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.
 * 
 */



/* 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 <fcntl.h>
#ifdef WIN32
#include <io.h>
#endif

#include "config.h"
#include "tmndec.h"
#include "global.h"

/* private prototypes */

#define OBFRSIZE 4096
//static unsigned char obfr[OBFRSIZE];
static unsigned char *optr;
static int outfile;
#ifdef SINGLE_TEST
extern unsigned char *vo_buf;
extern int init_fb;
#endif
/* store a picture as either one frame or two fields */
void storeframe (unsigned char *src[], int frame)
{
  char outname[32];

  sprintf (outname, outputname, frame, 'f');
  store_one (outname, src, 0, coded_picture_width, vertical_size,frame);
}

#ifdef WIN32
void store_one (char *outname, unsigned char *src[], int offset, int incr, int height,int frame)
{
  int i, j;
  unsigned char *py, *pu, *pv,*py_tmp,*pu_tmp,*pv_tmp;
  int incr_tmp;
  static unsigned char vpsfilehead[8] = {0x56,0x50,0x53,0x5f,0x14,0,0,0};
  static unsigned char vpsframehead[4] = {0x56,0x46,0x52,0x48};  
  static unsigned char vpsreserve[4] = {0xcc,0xcc,0xcc,0xcc};
  int height_s=0;
  int height_e=height;
  int width_s=0;
  int width_e=incr;
/*
  if(height_e>240)
		height_e=240;	
	if(width_e>320)
		width_e=320;
*/
  printf("frame No.%d\n",frame);
  strcat(outname,".vps");
    
#ifdef RUN_ON_BOARD
#else
  if ((outfile = open(outname,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666))==-1)
  {
   printf("Couldn't create output file \n");
  }
#endif
  optr = vo_buf; 	

  for(i=0;i<8;i++)
  *optr++ = vpsfilehead[i];
  *optr++ = 1;//vps_ColorType;
  *optr++ = 1/*vps_ColorType*/>>8;
  *optr++ = 1;//vps_ColorRate;
  *optr++ = 1/*vps_ColorRate*/>>8;
  *optr++ = width_e-width_s; 
  *optr++ = (width_e-width_s)>>8;
  *optr++ = height_e-height_s; //height;
  *optr++ = (height_e-height_s)>>8;//height
  for(i=0;i<4;i++)
  *optr++ = vpsreserve[i];

   for(i=0;i<4;i++)
	 *optr++ = vpsframehead[i];
  *((int *)optr) = frame; optr+=4;
  *((int *)optr) = 0; optr+=4;
  *((int *)optr) = 0; optr+=4;
  *((int *)optr) = 0; optr+=4;
  *((int *)optr) = 0; optr+=4;
  *((int *)optr) = 2*(height_e-height_s)*(width_e-width_s); optr+=4;

  for(i=0;i<4;i++)
	  *optr++ = vpsreserve[i]; 

  py_tmp=src[0]+offset;
  pu_tmp=src[1]+(offset>>1);
  pv_tmp=src[2]+(offset>>1);
  incr_tmp=incr>>1;


for (i=height_e-1; i>=height_s; i--)
  	{
         py = py_tmp + incr*i+width_s;
			pu = pu_tmp + incr_tmp*(i>>1)+width_s/2;//Cb
			pv = pv_tmp + incr_tmp*(i>>1)+width_s/2;
	for (j=width_s; j<width_e; j+=8)//挪一行
  		{
  			WORD_CPY(optr,py);
  			WORD_CPY(optr+4,pu);
  			WORD_CPY(optr+8,py+4);
  			WORD_CPY(optr+12,pv);
  			optr+=16;
  			py+=8;
  			pu+=4;
  			pv+=4;
		}		
	}  	


  if (optr!=vo_buf)
 write(outfile,vo_buf,optr-vo_buf);
  close(outfile);
}
#else
void store_one (char *outname, unsigned char *src[], int offset, int incr, int height,int frame)
{
  int i, j,temp_width;
  unsigned char *py, *pu, *pv,*py_tmp,*pu_tmp,*pv_tmp;
  int incr_tmp;
  static unsigned char *u422, *v422;
int height_s=0;
int height_e=height;
int width_s=0;
int width_e=incr;

	if(height_e>240)
		height_e=240;	
	if(width_e>320)
		width_e=320;
  optr = vo_buf;

  *((int *)optr) = 0; //vo_frame_t:time_stamp
  optr+=4;
  *((int *)optr) = width_e-width_s; 
  optr+=4;
  *((int *)optr) = height_e-height_s; 
  optr+=4;
  *((int *)optr) = 0x1;//FMT_YUV; 
  optr+=4;

  py_tmp=src[0]+offset;
  pu_tmp=src[1]+(offset>>1);
  pv_tmp=src[2]+(offset>>1);
  incr_tmp=incr>>1;

#ifdef SINGLE_TEST
	optr = vo_buf;//送去frame buffer的地址需从纯数据开始
#endif

 	for (i=height_s; i<height_e; i++)
  	{
         py = py_tmp + incr*i+width_s;
			pu = pu_tmp + incr_tmp*(i>>1)+width_s/2;//Cb
			pv = pv_tmp + incr_tmp*(i>>1)+width_s/2;

  	for (j=width_s; j<width_e; j+=8)//挪一行
  		{
  			WORD_CPY(optr,py);
  			WORD_CPY(optr+4,pu);
  			WORD_CPY(optr+8,py+4);
  			WORD_CPY(optr+12,pv);

  			optr+=16;
  			py+=8;
  			pu+=4;
  			pv+=4;
		}		
	} 
#ifdef SINGLE_TEST
		if(init_fb==1)	{
			init_fb=0;	
			initDisplay((width_e-width_s),(height_e-height_s));
		}
				unsigned int get_clock_time();
				displayImage();	
				if(frame == 200)
				{
					printf("decode    %d    frames with ellapse time   %d   microseconds\n", frame,get_clock_time());		
					exit(0);
				}
#endif

}
#endif//WIN32

⌨️ 快捷键说明

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