[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[79] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2010-01-06 14:57:16
|
Revision: 79 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=79&view=rev Author: nickols_k Date: 2010-01-06 14:57:04 +0000 (Wed, 06 Jan 2010) Log Message: ----------- add libdv support Modified Paths: -------------- etc/codecs.conf mplayerxp/configure mplayerxp/libmpcodecs/Makefile mplayerxp/libmpcodecs/ad.c mplayerxp/libmpcodecs/vd.c mplayerxp/libmpcodecs/vd_dmo.c mplayerxp/libmpdemux/Makefile mplayerxp/libmpdemux/demux_avi.c mplayerxp/libmpdemux/demux_fli.c mplayerxp/libmpdemux/demux_lavf.c mplayerxp/libmpdemux/demuxer.c mplayerxp/libmpdemux/demuxer.h Added Paths: ----------- mplayerxp/libmpcodecs/ad_libdv.c mplayerxp/libmpcodecs/vd_libdv.c mplayerxp/libmpdemux/demux_dv.c Modified: etc/codecs.conf =================================================================== --- etc/codecs.conf 2010-01-06 13:34:27 UTC (rev 78) +++ etc/codecs.conf 2010-01-06 14:57:04 UTC (rev 79) @@ -859,6 +859,19 @@ guid 0x31666973, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 out BGR32 +videocodec libdv + info "Raw DV decoder (libdv)" + status working + fourcc DVSD,dvsd ; PAL + fourcc DVCS,dvcs ; NTSC ? + fourcc "dvcp" ; PAL DV in .mov + fourcc "dvc " ; NTSC DV in .mov + fourcc dvpp ; DVCPRO - PAL + fourcc AVdv ; AVID DV + driver libdv + dll libdv.so.2 + out YUY2 + videocodec qdv info "Sony Digital Video (DV)" status working @@ -1888,6 +1901,7 @@ ; out IDCT_MPEG2 ; out MOCO_MPEG2 + videocodec ffdv info "Raw DV decoder using libavcodec" status working @@ -2765,13 +2779,19 @@ ; driver acm ; dll "vorbis.acm" - audiocodec TwinVQ info "VQF codec by NTTLabs" status working fourcc TWIN driver vqf dll "tvqdec.dll" + +audiocodec libdv + info "raw DV audio (libdv)" + status working + fourcc RADV + driver libdv + dll libdv.so.2 ;==========RealCodecs================== audiocodec ra144 Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/configure 2010-01-06 14:57:04 UTC (rev 79) @@ -79,6 +79,7 @@ "libcss|build with libcss support|http://download.videolan.org/pub/videolan/libdvdcss", "libdvdread|build with libdvdread support|http://www.dtek.chalmers.se/groups/dvd/downloads.shtml", "libdvdnav|build with libdvdnav support|http://dvd.sourceforge.net", + "libdv|build with libdv support|http://libdv.sourceforge.net/", "libvcd|build with libvcd support|http://www.gnu.org/software/vcdimager", "libvorbis|build with libvorbis support|http://www.vorbis.com", "libtheora|build with libtheora support|http://www.theora.org", @@ -704,6 +705,11 @@ print_config USE_ mp_config.h mp_config.mak libvcd enabled libvcd && inputmodules="libvcd $inputmodules" || noinputmodules="libvcd $noinputmodules" +enabled libdv && check_pkg libdv libdv +enabled libdv && require2 libdv "libdv/dv.h" dv_encoder_new -ldv +print_config HAVE_ mp_config.h mp_config.mak libdv +enabled libdv && inputmodules="libdv $inputmodules" || noinputmodules="libdv $noinputmodules" + enabled fastmemcpy && x86 || disable fastmemcpy print_config USE_ mp_config.h mp_config.mak fastmemcpy @@ -718,11 +724,11 @@ enabled libvorbis && check_pkg libvorbis vorbis print_config HAVE_ mp_config.h mp_config.mak libvorbis -enabled libvorbis && inputmodules="vorbis $inputmodules" || noinputmodules="vorbis $noinputmodules" +enabled libvorbis && inputmodules="libvorbis $inputmodules" || noinputmodules="libvorbis $noinputmodules" enabled libtheora && check_pkg libtheora theora print_config HAVE_ mp_config.h mp_config.mak libtheora -enabled libtheora && inputmodules="theora $inputmodules" || noinputmodules="theora $noinputmodules" +enabled libtheora && inputmodules="libtheora $inputmodules" || noinputmodules="libtheora $noinputmodules" enabled libbz2 && require2 libbz2 bzlib.h BZ2_bzlibVersion -lbz2 || disable libbz2 print_config HAVE_ mp_config.h mp_config.mak libbz2 Modified: mplayerxp/libmpcodecs/Makefile =================================================================== --- mplayerxp/libmpcodecs/Makefile 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpcodecs/Makefile 2010-01-06 14:57:04 UTC (rev 79) @@ -38,6 +38,9 @@ ifeq ($(HAVE_LIBTHEORA),yes) SRCS+=vd_theora.c endif +ifeq ($(HAVE_LIBDV),yes) +SRCS+= ad_libdv.c vd_libdv.c +endif ifeq ($(HAVE_WIN32LOADER),yes) SRCS+=vd_dshow.c \ Modified: mplayerxp/libmpcodecs/ad.c =================================================================== --- mplayerxp/libmpcodecs/ad.c 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpcodecs/ad.c 2010-01-06 14:57:04 UTC (rev 79) @@ -22,6 +22,7 @@ extern const ad_functions_t mpcodecs_ad_dca; extern const ad_functions_t mpcodecs_ad_hwac3; extern const ad_functions_t mpcodecs_ad_pcm; +extern const ad_functions_t mpcodecs_ad_libdv; extern const ad_functions_t mpcodecs_ad_dvdpcm; extern const ad_functions_t mpcodecs_ad_dshow; extern const ad_functions_t mpcodecs_ad_msacm; @@ -46,6 +47,9 @@ #ifdef HAVE_LIBVORBIS &mpcodecs_ad_vorbis, #endif +#ifdef HAVE_LIBDV + &mpcodecs_ad_libdv, +#endif &mpcodecs_ad_real, #ifdef HAVE_WIN32LOADER &mpcodecs_ad_dshow, Added: mplayerxp/libmpcodecs/ad_libdv.c =================================================================== --- mplayerxp/libmpcodecs/ad_libdv.c (rev 0) +++ mplayerxp/libmpcodecs/ad_libdv.c 2010-01-06 14:57:04 UTC (rev 79) @@ -0,0 +1,110 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <unistd.h> +#include <math.h> + +#include "mp_config.h" +#include "../help_mp.h" + +#include <libdv/dv.h> +#include <libdv/dv_types.h> + +#include "libmpdemux/stream.h" +#include "libmpdemux/demuxer.h" +#include "libmpdemux/stheader.h" + +#include "ad_internal.h" + +static ad_info_t info = +{ + "Raw DV Audio Decoder", + "libdv", + "Alexander Neundorf <neu...@kd...>", + "http://libdv.sourceforge.net" +}; + +static const config_t options[] = { + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBAD_EXTERN(libdv) + +// defined in vd_libdv.c: +dv_decoder_t* init_global_rawdv_decoder(void); + +static int preinit(sh_audio_t *sh_audio) +{ + sh_audio->audio_out_minsize=4*DV_AUDIO_MAX_SAMPLES*2; + return 1; +} + +static int16_t *audioBuffers[4]={NULL,NULL,NULL,NULL}; + +static int init(sh_audio_t *sh) +{ + int i; + WAVEFORMATEX *h=sh->wf; + + if(!h) return 0; + + sh->i_bps=h->nAvgBytesPerSec; + sh->channels=h->nChannels; + sh->samplerate=h->nSamplesPerSec; + sh->samplesize=(h->wBitsPerSample+7)/8; + + sh->context=init_global_rawdv_decoder(); + + for (i=0; i < 4; i++) + audioBuffers[i] = malloc(2*DV_AUDIO_MAX_SAMPLES); + + return 1; +} + +static void uninit(sh_audio_t *sh_audio) +{ + int i; + for (i=0; i < 4; i++) + free(audioBuffers[i]); +} + +static int control(sh_audio_t *sh,int cmd,void* arg, ...) +{ + // TODO!!! + return CONTROL_UNKNOWN; +} + +static int decode_audio(sh_audio_t *audio, unsigned char *buf, int minlen, int maxlen,float *pts) +{ + dv_decoder_t* decoder=audio->context; //global_rawdv_decoder; + unsigned char* dv_audio_frame=NULL; + int xx; + size_t len=0; + float apts; + while(len<minlen) { + xx=ds_get_packet_r(audio->ds,&dv_audio_frame,len>0?&apts:pts); + if(xx<=0 || !dv_audio_frame) return 0; // EOF? + + dv_parse_header(decoder, dv_audio_frame); + + if(xx!=decoder->frame_size) + MSG_WARN("AudioFramesize differs %u %u\n",xx, decoder->frame_size); + + if (dv_decode_full_audio(decoder, dv_audio_frame,(int16_t**) audioBuffers)) { + /* Interleave the audio into a single buffer */ + int i=0; + int16_t *bufP=(int16_t*)buf; + + for (i=0; i < decoder->audio->samples_this_frame; i++) + { + int ch; + for (ch=0; ch < decoder->audio->num_channels; ch++) + bufP[len++] = audioBuffers[ch][i]; + } + } + len+=decoder->audio->samples_this_frame; + buf+=decoder->audio->samples_this_frame; + } + return len*2; +} Property changes on: mplayerxp/libmpcodecs/ad_libdv.c ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/libmpcodecs/vd.c =================================================================== --- mplayerxp/libmpcodecs/vd.c 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpcodecs/vd.c 2010-01-06 14:57:04 UTC (rev 79) @@ -27,6 +27,7 @@ extern const vd_functions_t mpcodecs_vd_vfwex; extern const vd_functions_t mpcodecs_vd_divx4; extern const vd_functions_t mpcodecs_vd_raw; +extern const vd_functions_t mpcodecs_vd_libdv; extern const vd_functions_t mpcodecs_vd_xanim; extern const vd_functions_t mpcodecs_vd_fli; extern const vd_functions_t mpcodecs_vd_nuv; @@ -64,6 +65,9 @@ #ifdef HAVE_LIBTHEORA &mpcodecs_vd_theora, #endif +#ifdef HAVE_LIBDV + &mpcodecs_vd_libdv, +#endif NULL }; static unsigned int nddrivers=sizeof(mpcodecs_vd_drivers)/sizeof(vd_functions_t*); Modified: mplayerxp/libmpcodecs/vd_dmo.c =================================================================== --- mplayerxp/libmpcodecs/vd_dmo.c 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpcodecs/vd_dmo.c 2010-01-06 14:57:04 UTC (rev 79) @@ -18,7 +18,7 @@ "Win32/DMO video codecs", "dmo", "A'rpi", - "build-in + "build-in" }; static const config_t options[] = { Added: mplayerxp/libmpcodecs/vd_libdv.c =================================================================== --- mplayerxp/libmpcodecs/vd_libdv.c (rev 0) +++ mplayerxp/libmpcodecs/vd_libdv.c 2010-01-06 14:57:04 UTC (rev 79) @@ -0,0 +1,86 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <unistd.h> +#include <math.h> + +#include "mp_config.h" + +#include "libvo/img_format.h" + +#include <libdv/dv.h> +#include <libdv/dv_types.h> + +#include "libmpdemux/stream.h" +#include "libmpdemux/demuxer.h" +#include "libmpdemux/stheader.h" + +#include "vd_internal.h" + +static vd_info_t info = +{ + "Raw DV Video Decoder", + "libdv", + "Alexander Neundorf <neu...@kd...>", + "http://libdv.sourceforge.net" +}; + +static const config_t options[] = { + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBVD_EXTERN(libdv) + +// to set/get/query special features/parameters +static int control(sh_video_t *sh,int cmd,void* arg,...){ + return CONTROL_UNKNOWN; +} + +static dv_decoder_t* global_rawdv_decoder=NULL; + +dv_decoder_t* init_global_rawdv_decoder(void) +{ + if(!global_rawdv_decoder){ + global_rawdv_decoder=dv_decoder_new(TRUE,TRUE,FALSE); + global_rawdv_decoder->quality=DV_QUALITY_BEST; + global_rawdv_decoder->prev_frame_decoded = 0; + } + return global_rawdv_decoder; +} + +// init driver +static int init(sh_video_t *sh) +{ + sh->context = (void *)init_global_rawdv_decoder(); + return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,NULL); +} + +// uninit driver +static void uninit(sh_video_t *sh){ +} + +// decode a frame +static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags) +{ + mp_image_t* mpi; + dv_decoder_t *decoder=sh->context; + + if(len<=0 || (flags&3)){ +// fprintf(stderr,"decode() (rawdv) SKIPPED\n"); + return NULL; // skipped frame + } + + dv_parse_header(decoder, data); + + mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, sh->disp_w, sh->disp_h); + + if(!mpi){ // temporary! + MSG_ERR("couldn't allocate image for stderr codec\n"); + return NULL; + } + + dv_decode_full_frame(decoder, data, e_dv_color_yuv, mpi->planes, mpi->stride); + + return mpi; +} Property changes on: mplayerxp/libmpcodecs/vd_libdv.c ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/libmpdemux/Makefile =================================================================== --- mplayerxp/libmpdemux/Makefile 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpdemux/Makefile 2010-01-06 14:57:04 UTC (rev 79) @@ -26,6 +26,9 @@ ifeq ($(USE_LIBVCD),yes) SRCS += s_vcdnav.c endif +ifeq ($(HAVE_LIBDV),yes) +SRCS += demux_dv.c +endif SRCS += cache2.c dvdauth.c stream.c tvi_dummy.c tvi_v4l.c SRCS += tvi_bsdbt848.c frequencies.c mrl.c Modified: mplayerxp/libmpdemux/demux_avi.c =================================================================== --- mplayerxp/libmpdemux/demux_avi.c 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpdemux/demux_avi.c 2010-01-06 14:57:04 UTC (rev 79) @@ -283,7 +283,7 @@ *(uint32_t *)s->dwChunkId = stream_read_dword_le(demuxer->stream); stream_read(demuxer->stream, (char *)s->dwReserved, 3*4); memset(s->dwReserved, 0, 3*4); - + print_avisuperindex_chunk(s); msize = sizeof (uint32_t) * s->wLongsPerEntry * s->nEntriesInUse; @@ -483,7 +483,7 @@ } else if(chunksize>0) stream_skip(demuxer->stream,chunksize); else if((int)chunksize<0) MSG_WARN("chunksize=%u (id=%.4s)\n",chunksize,(char *) &id); - + } if (priv->suidx_size > 0 && priv->idx_size == 0) { @@ -660,7 +660,7 @@ // build index for file: stream_reset(demuxer->stream); stream_seek(demuxer->stream,demuxer->movi_start); - + priv->idx_pos=0; priv->idx_size=0; priv->idx=NULL; @@ -701,8 +701,8 @@ if(idxfix_divx) if(avi_stream_id(id)==idxfix_videostream){ switch(idxfix_divx){ - case 3: c=stream_read_dword(demuxer->stream)<<5; //skip 32+5 bits for m$mpeg4v1 - case 1: if(c&0x40000000) idx->dwFlags&=~AVIIF_KEYFRAME;break; // divx 3 + case 3: c=stream_read_dword(demuxer->stream)<<5; //skip 32+5 bits for m$mpeg4v1 + case 1: if(c&0x40000000) idx->dwFlags&=~AVIIF_KEYFRAME;break; // divx 3 case 2: if(c==0x1B6) idx->dwFlags&=~AVIIF_KEYFRAME;break; // divx 4 } } @@ -839,7 +839,7 @@ avi_priv_t *priv=demux->priv; int skip; float pts=0; - + MSG_DBG3("demux_avi.read_packet: %X\n",id); if(ds==demux->audio){ @@ -867,7 +867,7 @@ // update blockcount: priv->audio_block_no+=priv->audio_block_size ? ((len+priv->audio_block_size-1)/priv->audio_block_size) : 1; - } else + } else if(ds==demux->video){ // video if(priv->skip_video_frames>0){ @@ -887,10 +887,10 @@ if(ds) ++priv->video_pack_no; } - + // len=stream_read_dword_le(demux->stream); skip=(len+1)&(~1); // total bytes in this chunk - + if(ds){ MSG_DBG2("DEMUX_AVI: Read %d data bytes from packet %04X\n",len,id); ds_read_packet(ds,demux->stream,len,pts,idxpos,flags); @@ -918,9 +918,9 @@ AVIINDEXENTRY *idx=NULL; if(priv->idx_size>0 && priv->idx_pos<priv->idx_size){ off_t pos; - + idx=&((AVIINDEXENTRY *)priv->idx)[priv->idx_pos++]; - + //stream_seek(demux->stream,idx.dwChunkOffset); // pos-4,idx->dwChunkLength,idx->dwFlags); if(idx->dwFlags&AVIIF_LIST){ @@ -946,7 +946,7 @@ demux->filepos=stream_tell(demux->stream); id=stream_read_dword_le(demux->stream); if(stream_eof(demux->stream)) return 0; // EOF! - + if(id!=idx->ckid){ MSG_V("ChunkID mismatch! raw=%.4s idx=%.4s \n",(char *)&id,(char *)&idx->ckid); if(valid_fourcc(idx->ckid)) @@ -972,7 +972,7 @@ id=stream_read_dword_le(demux->stream); len=stream_read_dword_le(demux->stream); if(stream_eof(demux->stream)) return 0; // EOF! - + if(id==mmioFOURCC('L','I','S','T') || id==mmioFOURCC('R', 'I', 'F', 'F')){ id=stream_read_dword_le(demux->stream); // list or RIFF type continue; @@ -1018,16 +1018,16 @@ AVIINDEXENTRY *idx=NULL; int idx_pos=0; demux->filepos=stream_tell(demux->stream); - + if(ds==demux->video) idx_pos=priv->idx_pos_v++; else if(ds==demux->audio) idx_pos=priv->idx_pos_a++; else idx_pos=priv->idx_pos++; - + if(priv->idx_size>0 && idx_pos<priv->idx_size){ off_t pos; idx=&((AVIINDEXENTRY *)priv->idx)[idx_pos]; // idx=&priv->idx[idx_pos]; - + if(idx->dwFlags&AVIIF_LIST){ // LIST continue; @@ -1112,7 +1112,7 @@ id=stream_read_dword_le(demux->stream); // "AVIX" continue; } - + if(ds==demux_avi_select_stream(demux,id)){ // read it! ret=demux_avi_read_packet(demux,ds,id,len,priv->idx_pos-1,DP_NONKEYFRAME); @@ -1121,7 +1121,7 @@ int skip=(len+1)&(~1); // total bytes in this chunk stream_skip(demux->stream,skip); } - + } while(ret!=1); fpos[0]=stream_tell(demux->stream); return 1; @@ -1160,7 +1160,7 @@ MSG_WARN("AVI: invalid video stream ID: %d - ignoring (using default)\n",demuxer->video->id); demuxer->video->id=-1; // autodetect } - + stream_reset(demuxer->stream); stream_seek(demuxer->stream,demuxer->movi_start); priv->idx_pos=0; @@ -1186,7 +1186,7 @@ (int)((AVIINDEXENTRY *)priv->idx)[1].dwChunkOffset); } // demuxer->endpos=avi_header.movi_end; - + if(priv->idx_size>0){ // check that file is non-interleaved: int i; @@ -1354,11 +1354,11 @@ // seek absolute video_chunk_pos=0; } - + if(flags&DEMUX_SEEK_PERCENTS){ rel_seek_frames=rel_seek_secs*priv->numberofframes; } - + priv->skip_video_frames=0; priv->avi_audio_pts=0; Added: mplayerxp/libmpdemux/demux_dv.c =================================================================== --- mplayerxp/libmpdemux/demux_dv.c (rev 0) +++ mplayerxp/libmpdemux/demux_dv.c 2010-01-06 14:57:04 UTC (rev 79) @@ -0,0 +1,258 @@ +/* + * raw DV file parser + * copyright (c) 2002 Alexander Neundorf <neu...@kd...> + * based on the fli demuxer + * + * This file is part of MPlayer. + * + * MPlayer 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.1 of the License, or (at your option) any later version. + * + * MPlayer 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 MPlayer; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "../mp_config.h" +#include "demux_msg.h" + +#include "stream.h" +#include "demuxer.h" +#include "stheader.h" + +#include <libdv/dv.h> +#include <libdv/dv_types.h> + +#define DV_PAL_FRAME_SIZE 144000 +#define DV_NTSC_FRAME_SIZE 122000 + +typedef struct +{ + int current_frame; + int frame_size; + off_t current_filepos; + int frame_number; + dv_decoder_t *decoder; +} rawdv_frames_t; + +static void dv_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags) +{ + rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv; + sh_video_t *sh_video = demuxer->video->sh; + off_t newpos=(flags&DEMUX_SEEK_SET)?0:frames->current_frame; + if(flags&DEMUX_SEEK_PERCENTS) + { + // float 0..1 + newpos+=rel_seek_secs*frames->frame_number; + } + else + { + // secs + newpos+=rel_seek_secs*sh_video->fps; + } + if(newpos<0) + newpos=0; + else if(newpos>frames->frame_number) + newpos=frames->frame_number; + frames->current_frame=newpos; + frames->current_filepos=newpos*frames->frame_size; +} + +static int dv_probe(demuxer_t *demuxer) +{ + unsigned char tmp_buffer[DV_PAL_FRAME_SIZE]; + int bytes_read=0; + int result=0; + dv_decoder_t *td; + + MSG_V("Checking for DV\n"); + + bytes_read=stream_read(demuxer->stream,tmp_buffer,DV_PAL_FRAME_SIZE); + if ((bytes_read!=DV_PAL_FRAME_SIZE) && (bytes_read!=DV_NTSC_FRAME_SIZE)) + return 0; + + td=dv_decoder_new(TRUE,TRUE,FALSE); + if (!td) + return 0; + + td->quality=DV_QUALITY_BEST; + result=dv_parse_header(td, tmp_buffer); + if (result<0) + return 0; + + if ((( td->num_dif_seqs==10) || (td->num_dif_seqs==12)) + && (td->width==720) + && ((td->height==576) || (td->height==480))) + result=1; + dv_decoder_free(td); + if (result) + return 1; + else + return 0; +} + +// return value: +// 0 = EOF or no stream found +// 1 = successfully read a packet +static int dv_demux(demuxer_t *demuxer, demux_stream_t *ds) +{ + rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv; + demux_packet_t* dp_video=NULL; + sh_video_t *sh_video = demuxer->video->sh; + int bytes_read=0; +// fprintf(stderr,"demux_rawdv_fill_buffer() seek to %qu, size: %d\n",frames->current_filepos,frames->frame_size); + // fetch the frame from the file + // first, position the file properly since ds_read_packet() doesn't + // seem to do it, even though it takes a file offset as a parameter + stream_seek(demuxer->stream, frames->current_filepos); + + dp_video=new_demux_packet(frames->frame_size); + bytes_read=stream_read(demuxer->stream,dp_video->buffer,frames->frame_size); + if (bytes_read<frames->frame_size) + return 0; + dp_video->pts=frames->current_frame/sh_video->fps; + dp_video->pos=frames->current_filepos; + dp_video->flags=0; + + if (demuxer->audio && demuxer->audio->id>=-1) + { + demux_packet_t* dp_audio=clone_demux_packet(dp_video); + ds_add_packet(demuxer->audio,dp_audio); + } + ds_add_packet(demuxer->video,dp_video); + // get the next frame ready + frames->current_filepos+=frames->frame_size; + frames->current_frame++; +// fprintf(stderr," audio->packs: %d , video->packs: %d \n",demuxer->audio->packs, demuxer->video->packs); + return 1; +} + +static demuxer_t* dv_open(demuxer_t* demuxer) +{ + unsigned char dv_frame[DV_PAL_FRAME_SIZE]; + sh_video_t *sh_video = NULL; + rawdv_frames_t *frames = malloc(sizeof(rawdv_frames_t)); + dv_decoder_t *dv_decoder=NULL; + + MSG_V("demux_open_rawdv() end_pos %"PRId64"\n",(int64_t)demuxer->stream->end_pos); + + // go back to the beginning + stream_reset(demuxer->stream); + stream_seek(demuxer->stream, 0); + + //get the first frame + stream_read(demuxer->stream, dv_frame, DV_PAL_FRAME_SIZE); + + //read params from this frame + dv_decoder=dv_decoder_new(TRUE,TRUE,FALSE); + dv_decoder->quality=DV_QUALITY_BEST; + + if (dv_parse_header(dv_decoder, dv_frame) == -1) + return NULL; + + // create a new video stream header + sh_video = new_sh_video(demuxer, 0); + if (!sh_video) + return NULL; + + // make sure the demuxer knows about the new video stream header + // (even though new_sh_video() ought to take care of it) + demuxer->flags |= DEMUXF_SEEKABLE; + demuxer->video->sh = sh_video; + + // make sure that the video demuxer stream header knows about its + // parent video demuxer stream (this is getting wacky), or else + // video_read_properties() will choke + sh_video->ds = demuxer->video; + + // custom fourcc for internal MPlayer use +// sh_video->format = mmioFOURCC('R', 'A', 'D', 'V'); + sh_video->format = mmioFOURCC('D', 'V', 'S', 'D'); + + sh_video->disp_w = dv_decoder->width; + sh_video->disp_h = dv_decoder->height; + mp_msg(MSGT_DEMUXER,MSGL_V,"demux_open_rawdv() frame_size: %d w: %d h: %d dif_seq: %d system: %d\n",dv_decoder->frame_size,dv_decoder->width, dv_decoder->height,dv_decoder->num_dif_seqs,dv_decoder->system); + + sh_video->fps= (dv_decoder->system==e_dv_system_525_60?29.97:25); + sh_video->frametime = 1.0/sh_video->fps; + + // emulate BITMAPINFOHEADER for win32 decoders: + sh_video->bih=calloc(1, sizeof(BITMAPINFOHEADER)); + sh_video->bih->biSize=40; + sh_video->bih->biWidth = dv_decoder->width; + sh_video->bih->biHeight = dv_decoder->height; + sh_video->bih->biPlanes=1; + sh_video->bih->biBitCount=24; + sh_video->bih->biCompression=sh_video->format; // "DVSD" + sh_video->bih->biSizeImage=sh_video->bih->biWidth*sh_video->bih->biHeight*3; + + + frames->current_filepos=0; + frames->current_frame=0; + frames->frame_size=dv_decoder->frame_size; + frames->frame_number=demuxer->stream->end_pos/frames->frame_size; + + MSG_V("demux_open_rawdv() seek to %qu, size: %d, dv_dec->frame_size: %d\n",frames->current_filepos,frames->frame_size, dv_decoder->frame_size); + if (dv_decoder->audio != NULL && demuxer->audio->id>=-1){ + sh_audio_t *sh_audio = new_sh_audio(demuxer, 0); + demuxer->audio->id = 0; + demuxer->audio->sh = sh_audio; + sh_audio->ds = demuxer->audio; + MSG_V("demux_open_rawdv() chan: %d samplerate: %d\n",dv_decoder->audio->num_channels,dv_decoder->audio->frequency ); + // custom fourcc for internal MPlayer use + sh_audio->format = mmioFOURCC('R', 'A', 'D', 'V'); + + sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); + memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX)); + sh_audio->wf->wFormatTag = sh_audio->format; + sh_audio->wf->nChannels = dv_decoder->audio->num_channels; + sh_audio->wf->wBitsPerSample = 16; + sh_audio->wf->nSamplesPerSec = dv_decoder->audio->frequency; + // info about the input stream: + sh_audio->wf->nAvgBytesPerSec = sh_video->fps*dv_decoder->frame_size; + sh_audio->wf->nBlockAlign = dv_decoder->frame_size; + +// sh_audio->context=(void*)dv_decoder; + } + stream_reset(demuxer->stream); + stream_seek(demuxer->stream, 0); + dv_decoder_free(dv_decoder); //we keep this in the context of both stream headers + demuxer->priv=frames; + return demuxer; +} + +static void dv_close(demuxer_t* demuxer) +{ + rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv; + + if(frames==0) + return; + free(frames); +} + +static int dv_control(demuxer_t *demuxer,int cmd, void *arg) { + return DEMUX_UNKNOWN; +} + +demuxer_driver_t demux_dv = { + "DV video: IEC 61834 and SMPTE 314M", + ".dv", + NULL, // no options + dv_probe, + dv_open, + dv_demux, + dv_seek, + dv_close, + dv_control +}; Property changes on: mplayerxp/libmpdemux/demux_dv.c ___________________________________________________________________ Added: svn:eol-style + native Modified: mplayerxp/libmpdemux/demux_fli.c =================================================================== --- mplayerxp/libmpdemux/demux_fli.c 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpdemux/demux_fli.c 2010-01-06 14:57:04 UTC (rev 79) @@ -51,7 +51,7 @@ // seem to do it, even though it takes a file offset as a parameter stream_seek(demuxer->stream, frames->filepos[frames->current_frame]); ds_read_packet(demuxer->video, - demuxer->stream, + demuxer->stream, frames->frame_size[frames->current_frame], frames->current_frame/sh_video->fps, frames->filepos[frames->current_frame], Modified: mplayerxp/libmpdemux/demux_lavf.c =================================================================== --- mplayerxp/libmpdemux/demux_lavf.c 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpdemux/demux_lavf.c 2010-01-06 14:57:04 UTC (rev 79) @@ -454,7 +454,7 @@ if(av_read_frame(priv->avfc, &pkt) < 0) return 0; - + id= pkt.stream_index; if(id==demux->audio->id){ @@ -475,7 +475,7 @@ av_free_packet(&pkt); return 1; } - + if(0/*pkt.destruct == av_destruct_packet*/){ //ok kids, dont try this at home :) dp=(demux_packet_t*)malloc(sizeof(demux_packet_t)); @@ -510,7 +510,7 @@ static void lavf_seek(demuxer_t *demuxer, float rel_seek_secs, int flags){ lavf_priv_t *priv = demuxer->priv; MSG_DBG2("lavf_demux(%p, %f, %d)\n", demuxer, rel_seek_secs, flags); - + #if LIBAVFORMAT_BUILD < 4619 av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE); #else Modified: mplayerxp/libmpdemux/demuxer.c =================================================================== --- mplayerxp/libmpdemux/demuxer.c 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpdemux/demuxer.c 2010-01-06 14:57:04 UTC (rev 79) @@ -452,6 +452,17 @@ ds->pts_bytes=0; } +demux_packet_t* clone_demux_packet(demux_packet_t* pack){ + demux_packet_t* dp=(demux_packet_t*)malloc(sizeof(demux_packet_t)); +// while(pack->master) pack=pack->master; // find the master + memcpy(dp,pack,sizeof(demux_packet_t)); +// dp->next=NULL; +// dp->refcount=0; +// dp->master=pack; +// pack->refcount++; + return dp; +} + int ds_get_packet(demux_stream_t *ds,unsigned char **start){ while(1){ int len; Modified: mplayerxp/libmpdemux/demuxer.h =================================================================== --- mplayerxp/libmpdemux/demuxer.h 2010-01-06 13:34:27 UTC (rev 78) +++ mplayerxp/libmpdemux/demuxer.h 2010-01-06 14:57:04 UTC (rev 79) @@ -191,6 +191,7 @@ free(dp); } +demux_packet_t* clone_demux_packet(demux_packet_t* pack); demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id); demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id); void free_demuxer_stream(demux_stream_t *ds); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |