/*
* Copyright (C) 2000-2002 the xine project
*
* This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* foovideo.c: This is a reference video decoder for the xine multimedia
* player. It really works too! It will output frames of packed YUY2 data
* where each byte in the map is the same value, which is 3 larger than the
* value from the last frame. This creates a slowly rotating solid color
* frame when the frames are played in succession.
*
* $Id: libmain.c,v 1.1.1.1 2004/07/19 10:17:15 yangyongqiang Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "xine/xine_internal.h"
#include "xine/video_out.h"
#include "xine/buffer.h"
#include "xine/xineutils.h"
#include "bswap.h"
#include "h264dec.h"
#define VIDEOBUFSIZE 128*1024
//#define LOG
typedef struct {
video_decoder_class_t decoder_class;
} dtv1video_class_t;
typedef struct dtv1video_decoder_s {
video_decoder_t video_decoder; /* parent video decoder structure */
dtv1video_class_t *class;
xine_stream_t *stream;
/* these are traditional variables in a video decoder object */
uint64_t video_step; /* frame duration in pts units */
int decoder_ok; /* current decoder status */
int skipframes;
unsigned char *buf; /* the accumulated buffer data */
int bufsize; /* the maximum size of buf */
int size; /* the current size of buf */
int width; /* the width of a video frame */
int height; /* the height of a video frame */
/* these are variables exclusive to the dtv1 video decoder */
struct img_par *dec_env;
unsigned char current_yuv_byte;
} dtv1video_decoder_t;
/**************************************************************************
* dtv1video specific decode functions
*************************************************************************/
void yuy_yv12(unsigned char *puc_y, int stride_y,
int stride_uv,
unsigned char *puc_out_y,unsigned char *puc_out_u,
unsigned char *puc_out_v, int width_y, int height_y,
unsigned int stride_out, int flip);
/**************************************************************************
* xine video plugin functions
*************************************************************************/
/*
* This function receives a buffer of data from the demuxer layer and
* figures out how to handle it based on its header flags.
*/
static void dtv1video_decode_data (video_decoder_t *this_gen,
buf_element_t *buf) {
dtv1video_decoder_t *this = (dtv1video_decoder_t *) this_gen;
xine_bmiheader *bih;
int ret,width,height;
unsigned char *output;//decoder output
vo_frame_t *img; /* video out frame */
/* a video decoder does not care about this flag (?) */
if (buf->decoder_flags & BUF_FLAG_PREVIEW)
return;
if (buf->decoder_flags & BUF_FLAG_HEADER) { /* need to initialize */
#ifdef LOG
printf("libdtv1dec.so dtv1video_decode_data() with BUF_FLAG_HEADER\n");
#endif
this->stream->video_out->open (this->stream->video_out, this->stream);
if(this->buf)
free(this->buf);
bih = (xine_bmiheader *) buf->content;
this->width = bih->biWidth;
this->height = bih->biHeight;
this->video_step = buf->decoder_info[1];
if (this->buf)
free (this->buf);
this->bufsize = VIDEOBUFSIZE;
this->buf = malloc(this->bufsize);
this->size = 0;
/* take this opportunity to load the stream/meta info */
this->stream->meta_info[XINE_META_INFO_VIDEOCODEC] = strdup("dtv1video");
/* do anything else relating to initializing this decoder */
this->current_yuv_byte = 0;
this->decoder_ok = 1;
this->dec_env = NULL;
return;
} else if (this->decoder_ok) {
if (this->size + buf->size > this->bufsize) {
this->bufsize = this->size + 2 * buf->size;
this->buf = realloc (this->buf, this->bufsize);
}
xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
this->size += buf->size;
if (buf->decoder_flags & BUF_FLAG_FRAMERATE)
this->video_step = buf->decoder_info[0];
if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
if(!this->dec_env) //init decode lib
{
ret = H264DecInit(&width, &height,this->buf, (void **)&(this->dec_env));
if(ret != 1) //init error
{
#ifdef LOG
printf("H264DecInit return error#%d\n",ret);
#endif
this->dec_env = NULL;
return;
}
#ifdef LOG
printf("H264DecInit return OK!size= %dx%d\n",width,height);
#endif
}
ret = H264Decode(this->buf,&output, this->dec_env);
#ifdef LOG
printf("H264Decode return = %d\n", ret);
#endif
if(ret == 0){
#ifdef LOG
printf("H264DecInit return error#%d,bufsize=%d\n",ret,this->size);
#endif
return;
}
img = this->stream->video_out->get_frame (this->stream->video_out,
this->width, this->height,
XINE_VO_ASPECT_DONT_TOUCH,
XINE_IMGFMT_YV12, VO_BOTH_FIELDS);
img->duration = this->video_step;
img->pts = buf->pts;
img->bad_frame = 0;
yuy_yv12(output, this->width,this->width>>1,
img->base[0],img->base[1],img->base[2],
this->width, this->height,
(((this->width*12+7)>>3)+3) & 0xfffffffc, 0);
//xine_fast_memcpy (img->base[0],output,this->width * this->height);
// memset(img->base[0], 0x00,this->width*this->height);
//this->current_yuv_byte += 3;
img->draw(img, this->stream);
img->free(img);
this->size = 0;
}
}
}
/*
* This function is called when xine needs to flush the system.
*/
static void dtv1video_flush (video_decoder_t *this_gen) {
return;
this_gen++; //to shut up gcc warning
}
/*
* This function resets the video decoder.
*/
static void dtv1video_reset (video_decoder_t *this_gen) {
dtv1video_decoder_t *this = (dtv1video_decoder_t *) this_gen;
this->size = 0;
}
/*
* The decoder should forget any stored pts values here.
*/
static void dtv1video_discontinuity (video_decoder_t *this_gen) {
dtv1video_decoder_t *this = (dtv1video_decoder_t *) this_gen;
return;
this++; //to shut up gcc warning //yyq
}
/*
* This function frees the video decoder instance allocated to the decoder.
*/
static void dtv1video_dispose (video_decoder_t *this_gen) {
dtv1video_decoder_t *this = (dtv1video_decoder_t *) this_gen;
if (this->buf) {
free (this->buf);
this->buf = NULL;
}
if (this->decoder_ok) {
this->decoder_ok = 0;
this->stream->video_out->close(this->stream->video_out, this->stream);
}
if(this->dec_env){
#ifdef LOG
printf("H264DeInit()\n");
#endif
H264DeInit(this->dec_env);
this->dec_env = NULL;
}
free (this_gen);
}
/*
* This function allocates, initializes, and returns a private video
* decoder structure.
*/
static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_str
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
h264dec-for-mobile.rar (32个子文件)
h264dec
bswap.h 4KB
block.o 5KB
h264dec.h 222B
loopFilter.cpp 13KB
image.o 3KB
ctx_tables.h 10KB
Makefile.x86 2KB
CVS
Entries 1KB
Entries.Extra 596B
Repository 21B
Root.bak 43B
Entries.Old 1KB
Entries.Extra.Old 596B
Root 43B
libdtv1dec.so 64KB
cabac.o 6KB
macroblock.h 10KB
yuv.h 2KB
macroblock.o 27KB
vlc.h 873B
ldecod.o 3KB
libmain.o 3KB
libmain.c 13KB
defines.h 3KB
global.h 9KB
biaridecod.h 3KB
vlc.o 3KB
loopFilter.o 7KB
Makefile 3KB
biaridecod.o 2KB
context_ini.o 5KB
www.pudn.com.txt 218B
共 32 条
- 1
nivana999
- 粉丝: 44
- 资源: 48
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0