[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[323] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-10 14:22:25
|
Revision: 323 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=323&view=rev Author: nickols_k Date: 2012-11-10 14:22:16 +0000 (Sat, 10 Nov 2012) Log Message: ----------- first step towards packet-based demuxer Modified Paths: -------------- mplayerxp/libmpcodecs/dec_video.c mplayerxp/libmpcodecs/dec_video.h mplayerxp/libmpcodecs/vd.h mplayerxp/libmpcodecs/vd_divx4.c mplayerxp/libmpcodecs/vd_dmo.c mplayerxp/libmpcodecs/vd_dshow.c mplayerxp/libmpcodecs/vd_ffmpeg.c mplayerxp/libmpcodecs/vd_huffyuv.c mplayerxp/libmpcodecs/vd_internal.h mplayerxp/libmpcodecs/vd_libdv.c mplayerxp/libmpcodecs/vd_libmpeg2.c mplayerxp/libmpcodecs/vd_mpegpes.c mplayerxp/libmpcodecs/vd_null.c mplayerxp/libmpcodecs/vd_nuv.c mplayerxp/libmpcodecs/vd_qtvideo.c mplayerxp/libmpcodecs/vd_raw.c mplayerxp/libmpcodecs/vd_real.c mplayerxp/libmpcodecs/vd_theora.c mplayerxp/libmpcodecs/vd_vfw.c mplayerxp/libmpcodecs/vd_xanim.c mplayerxp/libmpcodecs/vd_xvid.c mplayerxp/libmpdemux/demuxer_r.c mplayerxp/libmpdemux/demuxer_r.h mplayerxp/xmpcore/xmp_vdecoder.c Modified: mplayerxp/libmpcodecs/dec_video.c =================================================================== --- mplayerxp/libmpcodecs/dec_video.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/dec_video.c 2012-11-10 14:22:16 UTC (rev 323) @@ -59,6 +59,7 @@ MPXP_Rc mpcv_set_quality(sh_video_t *sh_video,int quality){ if(mpvdec) return mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (any_t*)(&quality)); + return MPXP_False; } MPXP_Rc mpcv_set_colors(sh_video_t *sh_video,char *item,int value) @@ -224,7 +225,7 @@ extern vo_data_t* vo_data; static void update_subtitle(sh_video_t *sh_video,float v_pts,unsigned idx); -int mpcv_decode(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame, float pts){ +int mpcv_decode(sh_video_t *sh_video,const enc_frame_t* frame,int drop_frame){ vf_instance_t* vf; mp_image_t *mpi=NULL; unsigned int t; @@ -237,7 +238,7 @@ vf->control(vf,VFCTRL_START_FRAME,NULL); sh_video->active_slices=0; - mpi=mpvdec->decode(sh_video, start, in_size, drop_frame); + mpi=mpvdec->decode(sh_video, frame, drop_frame); MSG_DBG2("decvideo: decoding video %u bytes\n",in_size); while(sh_video->active_slices!=0) usleep(0); /* ------------------------ frame decoded. -------------------- */ @@ -255,7 +256,7 @@ } if(drop_frame) return 0; - update_subtitle(sh_video,pts,mpi->xp_idx); + update_subtitle(sh_video,frame->pts,mpi->xp_idx); vo_flush_page(vo_data,dae_curr_vdecoded(xp_core)); t2=GetTimer()-t2; Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/dec_video.h 2012-11-10 14:22:16 UTC (rev 323) @@ -7,7 +7,7 @@ extern void __FASTCALL__ mpcv_uninit(sh_video_t *sh_video); extern MPXP_Rc __FASTCALL__ mpcv_ffmpeg_init(sh_video_t*,any_t* libinput); -extern int __FASTCALL__ mpcv_decode(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame,float pts); +extern int __FASTCALL__ mpcv_decode(sh_video_t *sh_video,const enc_frame_t* frame,int drop_frame); extern MPXP_Rc __FASTCALL__ mpcv_get_quality_max(sh_video_t *sh_video,unsigned *qual); extern MPXP_Rc __FASTCALL__ mpcv_set_quality(sh_video_t *sh_video,int quality); Modified: mplayerxp/libmpcodecs/vd.h =================================================================== --- mplayerxp/libmpcodecs/vd.h 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd.h 2012-11-10 14:22:16 UTC (rev 323) @@ -20,7 +20,7 @@ MPXP_Rc (*__FASTCALL__ init)(sh_video_t *sh,any_t* libinput); void (*__FASTCALL__ uninit)(sh_video_t *sh); MPXP_Rc (* control)(sh_video_t *sh,int cmd,any_t* arg, ...); - mp_image_t* (*__FASTCALL__ decode)(sh_video_t *sh,any_t* data,int len,int flags); + mp_image_t* (*__FASTCALL__ decode)(sh_video_t *sh,const enc_frame_t* frame,int flags); } vd_functions_t; // NULL terminated array of all drivers Modified: mplayerxp/libmpcodecs/vd_divx4.c =================================================================== --- mplayerxp/libmpcodecs/vd_divx4.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_divx4.c 2012-11-10 14:22:16 UTC (rev 323) @@ -204,8 +204,8 @@ if(!(p=mp_mallocz(sizeof(priv_t)))) { MSG_ERR("Out of memory\n"); return MPXP_False; } sh->context=p; if(!(p->decoder=getDecore_ptr(sh->fourcc))) { - char *p=(char *)&(sh->fourcc); - MSG_ERR("Can't find decoder for %c%c%c%c fourcc\n",p[0],p[1],p[2],p[3]); + char *fcc=(char *)&(sh->fourcc); + MSG_ERR("Can't find decoder for %c%c%c%c fourcc\n",fcc[0],fcc[1],fcc[2],fcc[3]); return MPXP_False; } dinit.formatOut.fourCC=sh->codec->outfmt[sh->outfmtidx]; @@ -218,8 +218,8 @@ dinit.formatIn.fourCC=sh->fourcc; dinit.formatIn.framePeriod=sh->fps; if(p->decoder(NULL, DEC_OPT_INIT, (any_t*) &p->pHandle, &dinit)!=DEC_OK) { - char *p=(char *)&(dinit.formatOut); - MSG_ERR("Can't find decoder for %c%c%c%c fourcc\n",p[0],p[1],p[2],p[3]); + char *fcc=(char *)&(dinit.formatOut); + MSG_ERR("Can't find decoder for %c%c%c%c fourcc\n",fcc[0],fcc[1],fcc[2],fcc[3]); } MSG_V("INFO: DivX4Linux (libdivx.so) video codec init OK!\n"); fflush(stdout); @@ -235,20 +235,20 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ priv_t*p=sh->context; mp_image_t* mpi; DecFrame decFrame; memset(&decFrame,0,sizeof(DecFrame)); - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_PRESERVE | MP_IMGFLAG_ACCEPT_WIDTH, sh->src_w, sh->src_h); if(mpi->flags&MP_IMGFLAG_DIRECT) mpi->flags|=MP_IMGFLAG_RENDERED; - decFrame.bitstream.pBuff = data; - decFrame.bitstream.iLength = len; + decFrame.bitstream.pBuff = frame->data; + decFrame.bitstream.iLength = frame->len; decFrame.shallowDecode = (flags&3)?1:0; decFrame.pBmp=mpi->planes[0]; decFrame.bmpStride=(mpi->flags&(MP_IMGFLAG_YUV|MP_IMGFLAG_DIRECT))==(MP_IMGFLAG_YUV|MP_IMGFLAG_DIRECT)? Modified: mplayerxp/libmpcodecs/vd_dmo.c =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_dmo.c 2012-11-10 14:22:16 UTC (rev 323) @@ -79,13 +79,13 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ mp_image_t* mpi; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame if(flags&3){ // framedrop: - DMO_VideoDecoder_DecodeInternal(sh->context, data, len, sh->ds->flags&1, 0); + DMO_VideoDecoder_DecodeInternal(sh->context, frame->data, frame->len, sh->ds->flags&1, 0); return NULL; } @@ -98,7 +98,7 @@ return NULL; } - DMO_VideoDecoder_DecodeInternal(sh->context, data, len, sh->ds->flags&1, mpi->planes[0]); + DMO_VideoDecoder_DecodeInternal(sh->context, frame->data, frame->len, sh->ds->flags&1, mpi->planes[0]); return mpi; } Modified: mplayerxp/libmpcodecs/vd_dshow.c =================================================================== --- mplayerxp/libmpcodecs/vd_dshow.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_dshow.c 2012-11-10 14:22:16 UTC (rev 323) @@ -95,13 +95,13 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ mp_image_t* mpi; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame if(flags&3){ // framedrop: - DS_VideoDecoder_DecodeInternal(sh->context, data, len, sh->ds->flags&1, 0); + DS_VideoDecoder_DecodeInternal(sh->context, frame->data, frame->len, sh->ds->flags&1, 0); return NULL; } @@ -109,7 +109,7 @@ sh->src_w, sh->src_h); if(mpi->flags&MP_IMGFLAG_DIRECT) mpi->flags|=MP_IMGFLAG_RENDERED; - DS_VideoDecoder_DecodeInternal(sh->context, data, len, sh->ds->flags&1, mpi->planes[0]); + DS_VideoDecoder_DecodeInternal(sh->context, frame->data, frame->len, sh->ds->flags&1, mpi->planes[0]); return mpi; } Modified: mplayerxp/libmpcodecs/vd_ffmpeg.c =================================================================== --- mplayerxp/libmpcodecs/vd_ffmpeg.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_ffmpeg.c 2012-11-10 14:22:16 UTC (rev 323) @@ -242,7 +242,7 @@ static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ unsigned avc_version=0; priv_t *priv; - int pp_flags,rc; + int pp_flags; if(mp_conf.npp_options) pp2_init(); if(!vcodec_inited){ // avcodec_init(); @@ -646,14 +646,16 @@ } dp_hdr_t; // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ int got_picture=0; int ret,has_b_frames; + unsigned len=frame->len; + any_t* data=frame->data; priv_t *priv=sh->context; mp_image_t* mpi=NULL; priv->ctx->opaque=sh; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame priv->ctx->skip_frame=(flags&3)?((flags&2)?AVDISCARD_NONKEY:AVDISCARD_DEFAULT):AVDISCARD_NONE; if(priv->cap_slices) priv->use_slices= !(sh->vf_flags&VF_FLAGS_SLICES)?0:(priv->ctx->skip_frame!=AVDISCARD_NONE)?0:1; @@ -685,16 +687,16 @@ || sh->fourcc == mmioFOURCC('R', 'V', '4', '0')) if(sh->bih->biSize==sizeof(*sh->bih)+8){ int i; - dp_hdr_t *hdr= (dp_hdr_t*)data; + const dp_hdr_t *hdr= (const dp_hdr_t*)data; - if(priv->ctx->slice_offset==NULL) + if(priv->ctx->slice_offset==NULL) priv->ctx->slice_offset= mp_malloc(sizeof(int)*1000); // for(i=0; i<25; i++) printf("%02X ", ((uint8_t*)data)[i]); priv->ctx->slice_count= hdr->chunks+1; for(i=0; i<priv->ctx->slice_count; i++) - priv->ctx->slice_offset[i]= ((uint32_t*)(data+hdr->chunktab))[2*i+1]; + priv->ctx->slice_offset[i]= ((const uint32_t*)(data+hdr->chunktab))[2*i+1]; len=hdr->len; data+= sizeof(dp_hdr_t); } Modified: mplayerxp/libmpcodecs/vd_huffyuv.c =================================================================== --- mplayerxp/libmpcodecs/vd_huffyuv.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_huffyuv.c 2012-11-10 14:22:16 UTC (rev 323) @@ -463,7 +463,7 @@ * Decode a HuffYUV frame * */ -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags) +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags) { mp_image_t* mpi; int pixel_ptr; @@ -472,8 +472,8 @@ unsigned char tmp, mi, mx, med; unsigned char *swap; int row, col; - signed int pos = 32; - unsigned char *encoded = (unsigned char *)data; + unsigned int pos = 32; + const unsigned char *encoded = (const unsigned char *)frame->data; priv_t *priv = (priv_t *) sh->context; // Decoder context unsigned char *abovebuf = priv->abovebuf1; unsigned char *curbuf = priv->abovebuf2; @@ -483,7 +483,7 @@ int bgr32; // skipped frame - if(len <= 0) return NULL; + if(frame->len <= 0) return NULL; /* Do not accept stride for rgb, it gives me wrong output :-( */ if (priv->bitmaptype == BMPTYPE_YUV) Modified: mplayerxp/libmpcodecs/vd_internal.h =================================================================== --- mplayerxp/libmpcodecs/vd_internal.h 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_internal.h 2012-11-10 14:22:16 UTC (rev 323) @@ -17,7 +17,7 @@ static MPXP_Rc control(sh_video_t *sh,int cmd,any_t* arg,...); static int __FASTCALL__ init(sh_video_t *sh,any_t* libinput); static void __FASTCALL__ uninit(sh_video_t *sh); -static mp_image_t* __FASTCALL__ decode(sh_video_t *sh,any_t* data,int len,int flags); +static mp_image_t* __FASTCALL__ decode(sh_video_t *sh,const enc_frame_t* frame,int flags); #define LIBVD_EXTERN(x) const vd_functions_t mpcodecs_vd_##x = {\ &info,\ Modified: mplayerxp/libmpcodecs/vd_libdv.c =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_libdv.c 2012-11-10 14:22:16 UTC (rev 323) @@ -59,17 +59,17 @@ static void uninit(sh_video_t *sh) {} // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags) +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags) { mp_image_t* mpi; dv_decoder_t *priv=sh->context; - if(len<=0 || (flags&3)){ + if(frame->len<=0 || (flags&3)){ // fprintf(stderr,"decode() (rawdv) SKIPPED\n"); return NULL; // skipped frame } - dv_parse_header(priv, data); + dv_parse_header(priv, frame->data); mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, sh->src_w, sh->src_h); @@ -78,7 +78,7 @@ return NULL; } - dv_decode_full_frame(priv, data, e_dv_color_yuv, mpi->planes, mpi->stride); + dv_decode_full_frame(priv, frame->data, e_dv_color_yuv, mpi->planes, mpi->stride); return mpi; } Modified: mplayerxp/libmpcodecs/vd_libmpeg2.c =================================================================== --- mplayerxp/libmpcodecs/vd_libmpeg2.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_libmpeg2.c 2012-11-10 14:22:16 UTC (rev 323) @@ -209,22 +209,14 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ priv_t *priv=sh->context; mp_image_t *mpi; - const mpeg2_info_t *info; + const mpeg2_info_t *_info; int state,buf; - if(len<=0) return NULL; // skipped null frame + if(frame->len<=0) return NULL; // skipped null frame -#if 0 - // append extra 'end of frame' code: - ((char*)data+len)[0]=0; - ((char*)data+len)[1]=0; - ((char*)data+len)[2]=1; - ((char*)data+len)[3]=0xff; - len+=4; -#endif - info=mpeg2_info(priv->mpeg2dec); + _info=mpeg2_info(priv->mpeg2dec); mpi=NULL; buf=0; MSG_DBG2("len=%u ***mpeg2_info***\n",len); @@ -235,7 +227,7 @@ switch(state) { case STATE_BUFFER: - mpeg2_buffer(priv->mpeg2dec,data,data+len); + mpeg2_buffer(priv->mpeg2dec,frame->data,frame->data+frame->len); buf++; if(buf>2) return NULL; /* parsing of the passed buffer finished, return. */ break; @@ -243,31 +235,31 @@ #if 0 if(!priv->mpeg2dec->decoder.mpq_store) { - priv->mpeg2dec->decoder.mpq_stride=(info->sequence->picture_width+15)>>4; - priv->mpeg2dec->decoder.mpq_store=mp_malloc(priv->mpeg2dec->decoder.mpq_stride*((info->sequence->picture_height+15)>>4)); + priv->mpeg2dec->decoder.mpq_stride=(_info->sequence->picture_width+15)>>4; + priv->mpeg2dec->decoder.mpq_store=mp_malloc(priv->mpeg2dec->decoder.mpq_stride*((_info->sequence->picture_height+15)>>4)); } #endif mpi=mpcodecs_get_image(sh,MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_DRAW_CALLBACK - ,info->sequence->width,info->sequence->height); + ,_info->sequence->width,_info->sequence->height); mpeg2_stride(priv->mpeg2dec,mpi->stride[0]); break; case STATE_SLICE: case STATE_END: case STATE_INVALID: /* we must call draw_frame() only after STATE_BUFFER and STATE_PICTURE events */ - MSG_DBG2("display=%X discard=%X current=%X mpi=%X\n",info->display_fbuf,info->discard_fbuf,info->current_fbuf,mpi); + MSG_DBG2("display=%X discard=%X current=%X mpi=%X\n",_info->display_fbuf,_info->discard_fbuf,_info->current_fbuf,mpi); /* Workaround for broken (badly demuxed) streams. Reset libmpeg2 to start decoding at the next picture. */ if(state==STATE_END) mpeg2_reset(priv->mpeg2dec,0); - if (info->display_fbuf && mpi) + if (_info->display_fbuf && mpi) { - mpi->pict_type=info->current_picture->flags&PIC_MASK_CODING_TYPE; + mpi->pict_type=_info->current_picture->flags&PIC_MASK_CODING_TYPE; #if 0 mpi->qscale_type= 1; mpi->qscale=priv->mpeg2dec->decoder.mpq_store; mpi->qstride=priv->mpeg2dec->decoder.mpq_stride; #endif - draw_frame (mpi,sh,info->sequence->width,info->display_fbuf); + draw_frame (mpi,sh,_info->sequence->width,_info->display_fbuf); return mpi; } break; Modified: mplayerxp/libmpcodecs/vd_mpegpes.c =================================================================== --- mplayerxp/libmpcodecs/vd_mpegpes.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_mpegpes.c 2012-11-10 14:22:16 UTC (rev 323) @@ -32,13 +32,13 @@ static void uninit(sh_video_t *sh) {} // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ mp_image_t* mpi; static vo_mpegpes_t packet; mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,sh->src_w, sh->src_h); if(mpi->flags&MP_IMGFLAG_DIRECT) mpi->flags|=MP_IMGFLAG_RENDERED; - packet.data=data; - packet.size=len-4; + packet.data=frame->data; + packet.size=frame->len-4; packet.timestamp=sh->ds->pts; packet.id=0x1E0; //+sh_video->ds->id; mpi->planes[0]=(uint8_t*)(&packet); Modified: mplayerxp/libmpcodecs/vd_null.c =================================================================== --- mplayerxp/libmpcodecs/vd_null.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_null.c 2012-11-10 14:22:16 UTC (rev 323) @@ -34,7 +34,7 @@ static void uninit(sh_video_t *sh) {} // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ return NULL; } Modified: mplayerxp/libmpcodecs/vd_nuv.c =================================================================== --- mplayerxp/libmpcodecs/vd_nuv.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_nuv.c 2012-11-10 14:22:16 UTC (rev 323) @@ -40,15 +40,15 @@ static void uninit(sh_video_t *sh) {} // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ mp_image_t* mpi; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0, sh->src_w, sh->src_h); if(mpi->flags&MP_IMGFLAG_DIRECT) mpi->flags|=MP_IMGFLAG_RENDERED; - decode_nuv(data, len, mpi->planes[0], sh->src_w, sh->src_h); + decode_nuv(frame->data, frame->len, mpi->planes[0], sh->src_w, sh->src_h); return mpi; } Modified: mplayerxp/libmpcodecs/vd_qtvideo.c =================================================================== --- mplayerxp/libmpcodecs/vd_qtvideo.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_qtvideo.c 2012-11-10 14:22:16 UTC (rev 323) @@ -303,21 +303,21 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ long result = 1; int i; mp_image_t* mpi; ComponentResult cres; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, sh->src_w, sh->src_h); if(mpi->flags&MP_IMGFLAG_DIRECT) mpi->flags|=MP_IMGFLAG_RENDERED; - decpar.data = (char*)data; - decpar.bufferSize = len; - (**framedescHandle).dataSize=len; + decpar.data = (const char*)frame->data; + decpar.bufferSize = frame->len; + (**framedescHandle).dataSize=frame->len; if(!codec_inited){ result = QTNewGWorldFromPtr( Modified: mplayerxp/libmpcodecs/vd_raw.c =================================================================== --- mplayerxp/libmpcodecs/vd_raw.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_raw.c 2012-11-10 14:22:16 UTC (rev 323) @@ -49,16 +49,15 @@ static void uninit(sh_video_t *sh) {} // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ mp_image_t* mpi; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, - sh->src_w, sh->src_h); + mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->src_w, sh->src_h); if(mpi->flags&MP_IMGFLAG_DIRECT) mpi->flags|=MP_IMGFLAG_RENDERED; if(mpi->flags&MP_IMGFLAG_PLANAR){ - mpi->planes[0]=data; + mpi->planes[0]=frame->data; mpi->stride[0]=mpi->width; switch(sh->codec->outfmt[sh->outfmtidx]) { @@ -66,7 +65,7 @@ case IMGFMT_I420: case IMGFMT_IYUV: case IMGFMT_YV12: - mpi->planes[1]=data+mpi->width*mpi->height; + mpi->planes[1]=frame->data+mpi->width*mpi->height; mpi->stride[1]=mpi->width/2; mpi->planes[2]=mpi->planes[1]+(mpi->width/2)*(mpi->height/2); mpi->stride[2]=mpi->width/2; @@ -78,7 +77,7 @@ mpi->stride[3]=mpi->width/4; */ case IMGFMT_YVU9: - mpi->planes[1]=data+mpi->width*mpi->height; + mpi->planes[1]=frame->data+mpi->width*mpi->height; mpi->stride[1]=mpi->width/4; mpi->planes[2]=mpi->planes[1]+(mpi->width/4)*(mpi->height/4); mpi->stride[2]=mpi->width/4; @@ -87,7 +86,7 @@ break; } } else { - mpi->planes[0]=data; + mpi->planes[0]=frame->data; mpi->stride[0]=mpi->width*((mpi->bpp+7)/8); } return mpi; Modified: mplayerxp/libmpcodecs/vd_real.c =================================================================== --- mplayerxp/libmpcodecs/vd_real.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_real.c 2012-11-10 14:22:16 UTC (rev 323) @@ -49,7 +49,7 @@ uint32_t len; uint32_t unknown1; uint32_t chunks; - uint32_t* extra; + const uint32_t* extra; uint32_t unknown2; uint32_t timestamp; } transform_in_t; @@ -191,31 +191,31 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ - mp_image_t* mpi; - unsigned long result; - dp_hdr_t* dp_hdr=(dp_hdr_t*)data; - unsigned char* dp_data=((unsigned char*)data)+sizeof(dp_hdr_t); - uint32_t* extra=(uint32_t*)(((char*)data)+dp_hdr->chunktab); +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ + mp_image_t* mpi; + unsigned long result; + const dp_hdr_t* dp_hdr=(const dp_hdr_t*)frame->data; + const unsigned char* dp_data=((const unsigned char*)frame->data)+sizeof(dp_hdr_t); + const uint32_t* extra=(const uint32_t*)(((const char*)frame->data)+dp_hdr->chunktab); - unsigned int transform_out[5]; - transform_in_t transform_in={ - dp_hdr->len, // length of the packet (sub-packets appended) - 0, // unknown, seems to be unused - dp_hdr->chunks, // number of sub-packets - 1 - extra, // table of sub-packet offsets - 0, // unknown, seems to be unused - dp_hdr->timestamp,// timestamp (the integer value from the stream) - }; + unsigned int transform_out[5]; + transform_in_t transform_in={ + dp_hdr->len, // length of the packet (sub-packets appended) + 0, // unknown, seems to be unused + dp_hdr->chunks, // number of sub-packets - 1 + extra, // table of sub-packet offsets + 0, // unknown, seems to be unused + dp_hdr->timestamp,// timestamp (the integer value from the stream) + }; - if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop + if(frame->len<=0 || flags&2) return NULL; // skipped frame || hardframedrop - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, + mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, sh->src_w, sh->src_h); if(mpi->flags&MP_IMGFLAG_DIRECT) mpi->flags|=MP_IMGFLAG_RENDERED; - - result=(*rvyuv_transform)(dp_data, mpi->planes[0], &transform_in, - transform_out, sh->context); - return (result?NULL:mpi); + result=(*rvyuv_transform)(dp_data, mpi->planes[0], &transform_in, + transform_out, sh->context); + + return (result?NULL:mpi); } Modified: mplayerxp/libmpcodecs/vd_theora.c =================================================================== --- mplayerxp/libmpcodecs/vd_theora.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_theora.c 2012-11-10 14:22:16 UTC (rev 323) @@ -129,18 +129,17 @@ /* * decode frame */ -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags) +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags) { priv_t *priv = (priv_t *)sh->context; int errorCode = 0; ogg_packet op; yuv_buffer yuv; mp_image_t* mpi; - int i; bzero (&op, sizeof (op)); - op.bytes = len; - op.packet = data; + op.bytes = frame->len; + op.packet = frame->data; op.granulepos = -1; errorCode = theora_decode_packetin (&priv->st, &op); Modified: mplayerxp/libmpcodecs/vd_vfw.c =================================================================== --- mplayerxp/libmpcodecs/vd_vfw.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_vfw.c 2012-11-10 14:22:16 UTC (rev 323) @@ -112,7 +112,7 @@ ex = priv->ex; MSG_V("======= Win32 (VFW) VIDEO Codec init =======\n"); - priv->hic = ICOpen(IC_FCCTYPE, sh_video->fourcc, ICMODE_DECOMPRESS); + priv->hic = ICOpen((long)IC_FCCTYPE, sh_video->fourcc, ICMODE_DECOMPRESS); if(!priv->hic){ MSG_ERR("ICOpen failed! unknown codec / wrong parameters?\n"); return MPXP_False; @@ -169,7 +169,7 @@ // avi_header.our_in_buffer=mp_malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!! - ICSendMessage(priv->hic, ICM_USER+80, (long)(&divx_quality) ,NULL); + ICSendMessage(priv->hic, ICM_USER+80, (long)(&divx_quality), 0); // don't do this palette mess always, it makes div3 dll crashing... if(sh_video->codec->outfmt[sh_video->outfmtidx]==IMGFMT_BGR8){ @@ -188,7 +188,7 @@ static int vfw_set_postproc(sh_video_t* sh_video,int quality){ // Works only with opendivx/divx4 based DLL priv_t *priv=sh_video->context; - return ICSendMessage(priv->hic, ICM_USER+80, (long)(&quality) ,NULL); + return ICSendMessage(priv->hic, ICM_USER+80, (long)(&quality), 0); } static MPXP_Rc vfw_close_video_codec(sh_video_t *sh_video) @@ -268,12 +268,12 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ priv_t *priv = sh->context; mp_image_t* mpi; HRESULT ret; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH, @@ -284,18 +284,18 @@ sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8); priv->o_bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8); - sh->bih->biSizeImage = len; + sh->bih->biSizeImage = frame->len; if(priv->ex) ret = ICDecompressEx(priv->hic, ( (sh->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) | ( ((flags&3)==2 && !(sh->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ), - sh->bih, data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]); + sh->bih, frame->data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]); else ret = ICDecompress(priv->hic, ( (sh->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) | ( ((flags&3)==2 && !(sh->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ), - sh->bih, data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]); + sh->bih, frame->data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]); if ((int)ret){ MSG_WARN("Error decompressing frame, err=%d\n",ret); Modified: mplayerxp/libmpcodecs/vd_xanim.c =================================================================== --- mplayerxp/libmpcodecs/vd_xanim.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_xanim.c 2012-11-10 14:22:16 UTC (rev 323) @@ -884,13 +884,13 @@ } // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ mp_image_t* mpi; xacodec_image_t* image; - if(len<=0) return NULL; // skipped frame + if(frame->len<=0) return NULL; // skipped frame - image=xacodec_decode_frame(data,len,(flags&3)?1:0); + image=xacodec_decode_frame(frame->data,frame->len,(flags&3)?1:0); if(!image) return NULL; mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, Modified: mplayerxp/libmpcodecs/vd_xvid.c =================================================================== --- mplayerxp/libmpcodecs/vd_xvid.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpcodecs/vd_xvid.c 2012-11-10 14:22:16 UTC (rev 323) @@ -394,22 +394,22 @@ // decode a frame -static mp_image_t* decode(sh_video_t *sh,any_t* data,int len,int flags){ +static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame,int flags){ xvid_dec_frame_t dec; xvid_dec_stats_t stats; mp_image_t* mpi = NULL; int consumed; priv_t* priv = sh->context; - if(!data || len <= 0) return NULL; + if(frame->len <= 0) return NULL; memset(&dec,0,sizeof(xvid_dec_frame_t)); memset(&stats, 0, sizeof(xvid_dec_stats_t)); dec.version = XVID_VERSION; stats.version = XVID_VERSION; - dec.bitstream = data; - dec.length = len; + dec.bitstream = frame->data; + dec.length = frame->len; dec.general = 0; dec.brightness = priv->brightness; if(!priv->pp_level) dec.general |= XVID_LOWDELAY | XVID_DEC_FAST; Modified: mplayerxp/libmpdemux/demuxer_r.c =================================================================== --- mplayerxp/libmpdemux/demuxer_r.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpdemux/demuxer_r.c 2012-11-10 14:22:16 UTC (rev 323) @@ -9,11 +9,25 @@ #include "demuxer_r.h" #include "libmpsub/vobsub.h" #include "osdep/timer.h" +#include "osdep/mplib.h" #include "mplayerxp.h" #include "xmpcore/xmp_core.h" #include "demux_msg.h" +enc_frame_t* new_enc_frame(enc_frame_type_e type,unsigned len,float pts,float duration) { + enc_frame_t* frame=mp_mallocz(sizeof(enc_frame_t)); + frame->type=type; + frame->pts=pts; + frame->duration=duration; + frame->len=len; + return frame; +} +void free_enc_frame(enc_frame_t* frame) { + if(frame->data && frame->type!=VideoFrame) mp_free(frame->data); + mp_free(frame); +} + pthread_mutex_t demuxer_mutex=PTHREAD_MUTEX_INITIALIZER; #define LOCK_DEMUXER() { pthread_mutex_lock(&demuxer_mutex); } #define UNLOCK_DEMUXER() { pthread_mutex_unlock(&demuxer_mutex); } @@ -81,15 +95,21 @@ return retval; } -int video_read_frame_r(sh_video_t* sh_video,float* frame_time_ptr,float *v_pts,unsigned char** start,int force_fps) +enc_frame_t* video_read_frame_r(sh_video_t* sh_video,int force_fps) { + enc_frame_t* frame; + float frame_time,v_pts; + unsigned char* start; int retval; unsigned int t=0; unsigned int t2=0; double tt; LOCK_DEMUXER(); if(mp_conf.benchmark) t=GetTimer(); - retval = video_read_frame(sh_video,frame_time_ptr,v_pts,start,force_fps); + retval = video_read_frame(sh_video,&frame_time,&v_pts,&start,force_fps); + if(retval<=0) return NULL; + frame=new_enc_frame(VideoFrame,retval,v_pts,frame_time); + frame->data=start; if(mp_conf.benchmark) { t2=GetTimer();t=t2-t; @@ -99,7 +119,7 @@ if(tt < mp_data->bench->min_demux) mp_data->bench->min_demux=tt; } UNLOCK_DEMUXER(); - return retval; + return frame; } int demux_read_data_r(demux_stream_t *ds,unsigned char* mem,int len,float *pts) Modified: mplayerxp/libmpdemux/demuxer_r.h =================================================================== --- mplayerxp/libmpdemux/demuxer_r.h 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/libmpdemux/demuxer_r.h 2012-11-10 14:22:16 UTC (rev 323) @@ -11,10 +11,26 @@ extern "C" { #endif +typedef enum enc_frame_type { + AudioFrame =0, + VideoFrame +}enc_frame_type_e; + +typedef struct enc_frame_s { + enc_frame_type_e type; + float pts; + float duration; + unsigned len; + any_t* data; +}enc_frame_t; + +extern enc_frame_t* new_enc_frame(enc_frame_type_e type,unsigned len,float pts,float duration); +extern void free_enc_frame(enc_frame_t* frame); + static inline int ds_tell_pts_r(demux_stream_t *ds) { return ds_tell_pts(ds); } extern int demux_getc_r(demux_stream_t *ds,float *pts); -extern int video_read_frame_r(sh_video_t* sh_video,float* frame_time_ptr,float *v_pts,unsigned char** start,int force_fps); +extern enc_frame_t* video_read_frame_r(sh_video_t* sh_video,int force_fps); extern int demux_read_data_r(demux_stream_t *ds,unsigned char* mem,int len,float *pts); extern int ds_get_packet_r(demux_stream_t *ds,unsigned char **start,float *pts); extern int ds_get_packet_sub_r(demux_stream_t *ds,unsigned char **start); Modified: mplayerxp/xmpcore/xmp_vdecoder.c =================================================================== --- mplayerxp/xmpcore/xmp_vdecoder.c 2012-11-10 13:27:24 UTC (rev 322) +++ mplayerxp/xmpcore/xmp_vdecoder.c 2012-11-10 14:22:16 UTC (rev 323) @@ -115,13 +115,14 @@ demux_stream_t *d_video=sh_video->ds; demuxer_t* demuxer=d_video->demuxer; demux_stream_t* d_audio=demuxer->audio; + enc_frame_t* frame; float duration=0; float drop_barrier; int blit_frame=0; int drop_param=0; unsigned xp_n_frame_to_drop; - float v_pts,mpeg_timer=HUGE; + float mpeg_timer=HUGE; priv->state=Pth_Run; priv->dae->eof = 0; @@ -141,8 +142,6 @@ else xp_core->bad_pts = mp_conf.av_sync_pts?0:1; while(!priv->dae->eof){ - unsigned char* start=NULL; - int in_size; if(priv->state==Pth_Canceling) break; if(priv->state==Pth_Sleep) { pt_sleep: @@ -163,24 +162,22 @@ } #endif /*-------------------- Decode a frame: -----------------------*/ - in_size=video_read_frame_r(sh_video,&duration,&v_pts,&start,sh_video->fps); - if(in_size<0) { + frame=video_read_frame_r(sh_video,sh_video->fps); + if(!frame) { pt_exit_loop: dae_decoded_mark_eof(xp_core->video); priv->dae->eof=1; break; } if(mp_conf.play_n_frames>0 && xp_core->video->num_decoded_frames >= mp_conf.play_n_frames) goto pt_exit_loop; - /* in_size==0: it's or broken stream or demuxer's bug */ - if(in_size==0 && priv->state!=Pth_Canceling) continue; /* frame was decoded into current decoder_idx */ if(xp_core->bad_pts) { - if(mpeg_timer==HUGE) mpeg_timer=v_pts; - else if( mpeg_timer-duration<v_pts ) { - mpeg_timer=v_pts; + if(mpeg_timer==HUGE) mpeg_timer=frame->pts; + else if( mpeg_timer-duration<frame->pts ) { + mpeg_timer=frame->pts; MSG_DBG2("Sync mpeg pts %f\n", mpeg_timer); } - else mpeg_timer+=duration; + else mpeg_timer+=frame->duration; } /* compute frame dropping */ xp_n_frame_to_drop=0; @@ -188,9 +185,9 @@ int cur_time; cur_time = GetTimerMS(); /* Ugly solution: disable frame dropping right after seeking! */ - if(cur_time - mp_data->seek_time > (xp_core->num_v_buffs/sh_video->fps)*100) xp_n_frame_to_drop=compute_frame_dropping(sh_video,v_pts,drop_barrier); + if(cur_time - mp_data->seek_time > (xp_core->num_v_buffs/sh_video->fps)*100) xp_n_frame_to_drop=compute_frame_dropping(sh_video,frame->pts,drop_barrier); } /* if( mp_conf.frame_dropping ) */ - if(!finite(v_pts)) MSG_WARN("Bug of demuxer! Value of video pts=%f\n",v_pts); + if(!finite(frame->pts)) MSG_WARN("Bug of demuxer! Value of video pts=%f\n",frame->pts); #if 0 /* We can't seriously examine question of too slow machines @@ -215,7 +212,7 @@ else if(mp_conf.autoq) mpcv_set_quality(sh_video,our_quality>0?our_quality:0); } - blit_frame=mpcv_decode(sh_video,start,in_size,drop_param,v_pts); + blit_frame=mpcv_decode(sh_video,frame,drop_param); MSG_DBG2("DECODER: %i[%i] %f\n",dae_curr_vdecoded(xp_core),in_size,v_pts); if(mp_data->output_quality) { if(drop_param) mpcv_set_quality(sh_video,mp_data->output_quality); @@ -226,12 +223,12 @@ if(xp_core->bad_pts) xp_core->video->frame[idx].v_pts=mpeg_timer; else - xp_core->video->frame[idx].v_pts = v_pts; + xp_core->video->frame[idx].v_pts = frame->pts; xp_core->video->frame[idx].duration=duration; dae_decoded_clear_eof(xp_core->video); if(!xp_core->bad_pts) { int _idx = dae_prev_vdecoded(xp_core); - xp_core->video->frame[_idx].duration=v_pts-xp_core->video->frame[_idx].v_pts; + xp_core->video->frame[_idx].duration=frame->pts-xp_core->video->frame[_idx].v_pts; } if(mp_conf.frame_reorder) reorder_pts_in_mpeg(); } /* if (blit_frame) */ @@ -251,6 +248,7 @@ } usleep(1); } + free_enc_frame(frame); /*------------------------ frame decoded. --------------------*/ } /* while(!priv->dae->eof)*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |