[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[441] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-23 11:55:54
|
Revision: 441 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=441&view=rev Author: nickols_k Date: 2012-11-23 11:55:38 +0000 (Fri, 23 Nov 2012) Log Message: ----------- project uses libav* only, thus rename ffmpeg -> lavc Modified Paths: -------------- Makefile mplayerxp/Makefile mplayerxp/configure mplayerxp/libmpcodecs/Makefile mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/dec_audio.h mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/dec_video.h mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpstream/Makefile mplayerxp/libmpstream/stream.cpp mplayerxp/mplayerxp.cpp mplayerxp/nls/help_mp-cz.h mplayerxp/nls/help_mp-de.h mplayerxp/nls/help_mp-dk.h mplayerxp/nls/help_mp-en.h mplayerxp/nls/help_mp-es.h mplayerxp/nls/help_mp-fr.h mplayerxp/nls/help_mp-hu.h mplayerxp/nls/help_mp-it.h mplayerxp/nls/help_mp-ko.h mplayerxp/nls/help_mp-nl.h mplayerxp/nls/help_mp-no.h mplayerxp/nls/help_mp-pl.h mplayerxp/nls/help_mp-ro.h mplayerxp/nls/help_mp-ru.h mplayerxp/nls/help_mp-sk.h Added Paths: ----------- lavc/ mplayerxp/libmpcodecs/ad_lavc.cpp mplayerxp/libmpcodecs/vd_lavc.cpp mplayerxp/libmpstream/s_lavc.cpp Removed Paths: ------------- ffmpeg/ mplayerxp/libmpcodecs/ad_ffmpeg.cpp mplayerxp/libmpcodecs/vd_ffmpeg.cpp mplayerxp/libmpstream/s_ffmpeg.cpp Modified: Makefile =================================================================== --- Makefile 2012-11-23 10:53:52 UTC (rev 440) +++ Makefile 2012-11-23 11:55:38 UTC (rev 441) @@ -1,5 +1,5 @@ INSTALLABLE_SUBDIRS = mplayerxp etc DOCS -SUBDIRS = ffmpeg $(INSTALLABLE_SUBDIRS) +SUBDIRS = lavc $(INSTALLABLE_SUBDIRS) DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@ || exit; done DO_IMAKE = @ for i in $(INSTALLABLE_SUBDIRS); do $(MAKE) -C $$i $@ || exit; done Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/Makefile 2012-11-23 11:55:38 UTC (rev 441) @@ -25,12 +25,12 @@ OBJS = $(SRCS:.cpp=.o) -FF_LIBS = ../ffmpeg/libavcodec/libavcodec$(FF_SUFFIX).a \ - ../ffmpeg/libswscale/libswscale$(FF_SUFFIX).a \ - ../ffmpeg/libswresample/libswresample$(FF_SUFFIX).a \ - ../ffmpeg/libpostproc/libpostproc$(FF_SUFFIX).a \ - ../ffmpeg/libavformat/libavformat$(FF_SUFFIX).a \ - ../ffmpeg/libavutil/libavutil$(FF_SUFFIX).a +FF_LIBS = ../lavc/libavcodec/libavcodec$(LAVC_SUFFIX).a \ + ../lavc/libswscale/libswscale$(LAVC_SUFFIX).a \ + ../lavc/libswresample/libswresample$(LAVC_SUFFIX).a \ + ../lavc/libpostproc/libpostproc$(LAVC_SUFFIX).a \ + ../lavc/libavformat/libavformat$(LAVC_SUFFIX).a \ + ../lavc/libavutil/libavutil$(LAVC_SUFFIX).a MP_LIBS = libmpstream/libmpstream.a \ libmpdemux/libmpdemux.a \ Modified: mplayerxp/configure =================================================================== --- mplayerxp/configure 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/configure 2012-11-23 11:55:38 UTC (rev 441) @@ -360,30 +360,30 @@ add_cflags "-I$srcdir" -disable ffmpeg -# Checking for FFMPEG -test -f "../ffmpeg/libavcodec/avcodec.h" && enable ffmpeg -disabled ffmpeg && die "**FATAL**: local copy of ffmpeg doesn't exist!" -add_cflags "-I$srcdir/../ffmpeg" -print_config HAVE_ mp_config.h mp_config.mak ffmpeg -# Configuring external ffmpeg stuff -ffmpeg_args="--enable-static --disable-shared --enable-gpl --enable-pthreads --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe --disable-avdevice --disable-avfilter --disable-avresample" +disable lavc +# Checking for LAVC +test -f "../lavc/libavcodec/avcodec.h" && enable lavc +disabled lavc && die "**FATAL**: local copy of lavc doesn't exist!" +add_cflags "-I$srcdir/../lavc" +print_config HAVE_ mp_config.h mp_config.mak lavc +# Configuring external lavc stuff +lavc_args="--enable-static --disable-shared --enable-gpl --enable-pthreads --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe --disable-avdevice --disable-avfilter --disable-avresample" if test -n $host ; then _arch=$host_arch x86_32 && _arch="i686" x86_64 && _arch="x86_64" -x86_32 && ff_libsuffix="32" -x86_64 && ff_libsuffix="64" -ffmpeg_args="--arch=$_arch --build-suffix=$ff_libsuffix $ffmpeg_args" +x86_32 && lavc_libsuffix="32" +x86_64 && lavc_libsuffix="64" +lavc_args="--arch=$_arch --build-suffix=$lavc_libsuffix $lavc_args" fi -test "$debug" != "0" && ffmpeg_args="$ffmpeg_args --enable-debug=$debug" -enabled $profile && ffmpeg_args="$ffmpeg_args --enable-profile" -if test -f "../ffmpeg/libavcodec/libavcodec$ff_libsuffix.a"; then -echocheck "ffmpeg was already configured for $_arch" +test "$debug" != "0" && lavc_args="$lavc_args --enable-debug=$debug" +enabled $profile && lavc_args="$lavc_args --enable-profile" +if test -f "../lavc/libavcodec/libavcodec$lavc_libsuffix.a"; then +echocheck "lavc was already configured for $_arch" else -echocheck "configuring ffmpeg stuff: --cc=\"$cc\" $ffmpeg_args" -cd ../ffmpeg -$(LC_ALL=C ./configure --cc="$cc" $ffmpeg_args) +echocheck "configuring lavc stuff: --cc=\"$cc\" $lavc_args" +cd ../lavc +$(LC_ALL=C ./configure --cc="$cc" $lavc_args) cd $srcdir fi echores "done" @@ -905,7 +905,7 @@ LIBDIR = $libdir DESTDIR = $DESTDIR PROGNAME = $prog_alias -FF_SUFFIX=$ff_libsuffix +LAVC_SUFFIX=$lavc_libsuffix AR = ar CC = $cc CXX = $cxx @@ -1159,17 +1159,17 @@ #define UINT64_C __UINT64_C #define FF_API_OLD_DECODE_AUDIO 1 -#include "$srcdir/../ffmpeg/libavcodec/avcodec.h" -#include "$srcdir/../ffmpeg/libpostproc/postprocess.h" -#include "$srcdir/../ffmpeg/libswscale/swscale.h" -#include "$srcdir/../ffmpeg/libswscale/rgb2rgb.h" -#include "$srcdir/../ffmpeg/libavutil/fifo.h" -#include "$srcdir/../ffmpeg/libavutil/audioconvert.h" -#include "$srcdir/../ffmpeg/libswresample/swresample.h" -#include "$srcdir/../ffmpeg/libavformat/riff.h" -#include "$srcdir/../ffmpeg/libavformat/avformat.h" -#include "$srcdir/../ffmpeg/libavformat/avio.h" -#include "$srcdir/../ffmpeg/libavformat/url.h" +#include "$srcdir/../lavc/libavcodec/avcodec.h" +#include "$srcdir/../lavc/libpostproc/postprocess.h" +#include "$srcdir/../lavc/libswscale/swscale.h" +#include "$srcdir/../lavc/libswscale/rgb2rgb.h" +#include "$srcdir/../lavc/libavutil/fifo.h" +#include "$srcdir/../lavc/libavutil/audioconvert.h" +#include "$srcdir/../lavc/libswresample/swresample.h" +#include "$srcdir/../lavc/libavformat/riff.h" +#include "$srcdir/../lavc/libavformat/avformat.h" +#include "$srcdir/../lavc/libavformat/avio.h" +#include "$srcdir/../lavc/libavformat/url.h" #ifdef __cplusplus } Modified: mplayerxp/libmpcodecs/Makefile =================================================================== --- mplayerxp/libmpcodecs/Makefile 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/Makefile 2012-11-23 11:55:38 UTC (rev 441) @@ -9,7 +9,7 @@ CXXSRCS+=ad_a52.cpp ad_hwac3.cpp -CXXSRCS+=vd_ffmpeg.cpp \ +CXXSRCS+=vd_lavc.cpp \ vd_null.cpp \ vd_nuv.cpp \ vd_raw.cpp \ @@ -19,7 +19,7 @@ vd_huffyuv.cpp \ ad_dca.cpp \ ad_faad.cpp \ - ad_ffmpeg.cpp \ + ad_lavc.cpp \ ad_null.cpp \ ad_mp3.cpp \ ad_pcm.cpp \ Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/ad.cpp 2012-11-23 11:55:38 UTC (rev 441) @@ -21,7 +21,7 @@ extern const ad_functions_t mpcodecs_ad_null; extern const ad_functions_t mpcodecs_ad_mp3; -extern const ad_functions_t mpcodecs_ad_ffmpeg; +extern const ad_functions_t mpcodecs_ad_lavc; extern const ad_functions_t mpcodecs_ad_a52; extern const ad_functions_t mpcodecs_ad_dca; extern const ad_functions_t mpcodecs_ad_hwac3; @@ -61,7 +61,7 @@ &mpcodecs_ad_dmo, &mpcodecs_ad_qtaudio, #endif - &mpcodecs_ad_ffmpeg, + &mpcodecs_ad_lavc, &mpcodecs_ad_null, }; Deleted: mplayerxp/libmpcodecs/ad_ffmpeg.cpp =================================================================== --- mplayerxp/libmpcodecs/ad_ffmpeg.cpp 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/ad_ffmpeg.cpp 2012-11-23 11:55:38 UTC (rev 441) @@ -1,230 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#define __USE_GNU 1 -#define __USE_XOPEN 1 -#include <unistd.h> -#include <assert.h> -#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ -#include "libao2/afmt.h" -#include "ad_internal.h" - -#include "mp_config.h" -#include "help_mp.h" -#include "osdep/bswap.h" -#include "osdep/mplib.h" -#include "libmpconf/codec-cfg.h" - -#include "mp_conf_lavc.h"" -#include "codecs_ld.h" - -using namespace mpxp; - -typedef struct priv_s { - AVCodecContext *lavc_ctx; - audio_probe_t* probe; -}priv_t; - -static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { - unsigned i; - audio_probe_t* acodec = NULL; - const char *what="AVCodecID"; - priv_t* priv=reinterpret_cast<priv_t*>(sh->context); - enum AVCodecID id = ff_codec_get_id(ff_codec_wav_tags,wtag); - if (id <= 0) { - prn_err: - MSG_ERR("Cannot find %s for '0x%X' tag! Try force -ac option\n" - ,what - ,sh->wtag); - return NULL; - } - if(!priv){ - priv=new(zeromem) priv_t; - sh->context=priv; -// avcodec_init(); - avcodec_register_all(); - } - AVCodec *codec=avcodec_find_decoder(id); - if(!codec) { what="AVCodec"; goto prn_err; } - - acodec=new(zeromem) audio_probe_t; - acodec->codec_dll=mp_strdup(avcodec_get_name(id)); - acodec->driver="ffmpeg"; - acodec->wtag=wtag; - if(codec->sample_fmts) - for(i=0;i<Audio_MaxOutSample;i++) { - if(codec->sample_fmts[i]==-1) break; - acodec->sample_fmt[i]=ff_codec_get_tag(ff_codec_wav_tags,id); - } - priv->probe=acodec; - return acodec; -} - -struct codecs_st* __FASTCALL__ find_ffmpeg_audio(sh_audio_t* sh) { - const audio_probe_t* aprobe=probe(sh,sh->wtag); - struct codecs_st* acodec = NULL; - if(aprobe) { - acodec=new(zeromem) struct codecs_st; - strcpy(acodec->dll_name,aprobe->codec_dll); - strcpy(acodec->driver_name,aprobe->driver); - strcpy(acodec->codec_name,acodec->dll_name); - memcpy(acodec->outfmt,aprobe->sample_fmt,sizeof(aprobe->sample_fmt)); - } - return acodec; -} - -#ifndef FF_INPUT_BUFFER_PADDING_SIZE -#define FF_INPUT_BUFFER_PADDING_SIZE 8 -#endif - -static const ad_info_t info = { - "FFmpeg/libavcodec audio decoders", - "ffmpeg", - "Nickols_K", - "build-in" -}; - -static const config_t options[] = { - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -LIBAD_EXTERN(ffmpeg) - -MPXP_Rc preinit(sh_audio_t *sh) -{ - sh->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; - return MPXP_Ok; -} - -MPXP_Rc init(sh_audio_t *sh_audio) -{ - int x; - float pts; - AVCodec *lavc_codec=NULL; - priv_t* priv=reinterpret_cast<priv_t*>(sh_audio->context); - MSG_V("FFmpeg's libavcodec audio codec\n"); - if(!priv){ - priv=new(zeromem) priv_t; - sh_audio->context=priv; -// avcodec_init(); - avcodec_register_all(); - } - lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll_name); - if(!lavc_codec) { - MSG_ERR(MSGTR_MissingLAVCcodec,sh_audio->codec->dll_name); - return MPXP_False; - } - priv->lavc_ctx = avcodec_alloc_context3(lavc_codec); - if(sh_audio->wf) { - priv->lavc_ctx->channels = sh_audio->wf->nChannels; - priv->lavc_ctx->sample_rate = sh_audio->wf->nSamplesPerSec; - priv->lavc_ctx->bit_rate = sh_audio->wf->nAvgBytesPerSec * 8; - priv->lavc_ctx->block_align = sh_audio->wf->nBlockAlign; - priv->lavc_ctx->bits_per_coded_sample = sh_audio->wf->wBitsPerSample; - /* alloc extra data */ - if (sh_audio->wf->cbSize > 0) { - priv->lavc_ctx->extradata = new uint8_t[sh_audio->wf->cbSize+FF_INPUT_BUFFER_PADDING_SIZE]; - priv->lavc_ctx->extradata_size = sh_audio->wf->cbSize; - memcpy(priv->lavc_ctx->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX), - priv->lavc_ctx->extradata_size); - } - } - // for QDM2 - if (sh_audio->codecdata_len && sh_audio->codecdata && !priv->lavc_ctx->extradata) { - priv->lavc_ctx->extradata = new uint8_t[sh_audio->codecdata_len]; - priv->lavc_ctx->extradata_size = sh_audio->codecdata_len; - memcpy(priv->lavc_ctx->extradata, (char *)sh_audio->codecdata, - priv->lavc_ctx->extradata_size); - } - priv->lavc_ctx->codec_tag = sh_audio->wtag; - priv->lavc_ctx->codec_type = lavc_codec->type; - priv->lavc_ctx->codec_id = lavc_codec->id; - /* open it */ - if (avcodec_open2(priv->lavc_ctx, lavc_codec, NULL) < 0) { - MSG_ERR( MSGTR_CantOpenCodec); - return MPXP_False; - } - MSG_V("INFO: libavcodec init OK!\n"); - - // Decode at least 1 byte: (to get header filled) - x=decode(sh_audio,reinterpret_cast<unsigned char*>(sh_audio->a_buffer),1,sh_audio->a_buffer_size,&pts); - if(x>0) sh_audio->a_buffer_len=x; - - sh_audio->nch=priv->lavc_ctx->channels; - sh_audio->rate=priv->lavc_ctx->sample_rate; - switch(priv->lavc_ctx->sample_fmt) { - case AV_SAMPLE_FMT_U8: ///< unsigned 8 bits - sh_audio->afmt=AFMT_U8; - break; - default: - case AV_SAMPLE_FMT_S16: ///< signed 16 bits - sh_audio->afmt=AFMT_S16_LE; - break; - case AV_SAMPLE_FMT_S32: ///< signed 32 bits - sh_audio->afmt=AFMT_S32_LE; - break; - case AV_SAMPLE_FMT_FLT: ///< float - sh_audio->afmt=AFMT_FLOAT32; - break; - } - sh_audio->i_bps=priv->lavc_ctx->bit_rate/8; - return MPXP_Ok; -} - -void uninit(sh_audio_t *sh) -{ - priv_t* priv=reinterpret_cast<priv_t*>(sh->context); - avcodec_close(priv->lavc_ctx); - if (priv->lavc_ctx->extradata) delete priv->lavc_ctx->extradata; - delete priv->lavc_ctx; - if(priv->probe) { delete priv->probe->codec_dll; delete priv->probe; } - delete priv; - sh->context=NULL; -} - -MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) -{ - UNUSED(arg); - priv_t* priv = reinterpret_cast<priv_t*>(sh->context); - switch(cmd){ - case ADCTRL_RESYNC_STREAM: - avcodec_flush_buffers(priv->lavc_ctx); - return MPXP_True; - default: break; - } - return MPXP_Unknown; -} - -unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) -{ - priv_t* priv = reinterpret_cast<priv_t*>(sh_audio->context); - unsigned char *start=NULL; - int y; - unsigned len=0; - float apts=0.,null_pts; - while(len<minlen){ - AVPacket pkt; - int len2=maxlen; - int x=ds_get_packet_r(sh_audio->ds,&start,apts?&null_pts:&apts); - if(x<=0) break; // error - if(sh_audio->wtag==mmioFOURCC('d','n','e','t')) swab(start,start,x&(~1)); - av_init_packet(&pkt); - pkt.data = start; - pkt.size = x; - y=avcodec_decode_audio3(priv->lavc_ctx,(int16_t*)buf,&len2,&pkt); - if(y<0){ MSG_V("lavc_audio: error\n");break; } - if(y<x) - { - sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) - if(sh_audio->wtag==mmioFOURCC('d','n','e','t')) - swab(start+y,start+y,(x-y)&~(1)); - } - if(len2>0){ - //len=len2;break; - if(len==0) len=len2; else len+=len2; - buf+=len2; - } - MSG_DBG2("Decoded %d -> %d \n",y,len2); - } - *pts=apts; - return len; -} Copied: mplayerxp/libmpcodecs/ad_lavc.cpp (from rev 437, mplayerxp/libmpcodecs/ad_ffmpeg.cpp) =================================================================== --- mplayerxp/libmpcodecs/ad_lavc.cpp (rev 0) +++ mplayerxp/libmpcodecs/ad_lavc.cpp 2012-11-23 11:55:38 UTC (rev 441) @@ -0,0 +1,230 @@ +#include <stdio.h> +#include <stdlib.h> +#define __USE_GNU 1 +#define __USE_XOPEN 1 +#include <unistd.h> +#include <assert.h> +#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ +#include "libao2/afmt.h" +#include "ad_internal.h" + +#include "mp_config.h" +#include "help_mp.h" +#include "osdep/bswap.h" +#include "osdep/mplib.h" +#include "libmpconf/codec-cfg.h" + +#include "mp_conf_lavc.h"" +#include "codecs_ld.h" + +using namespace mpxp; + +typedef struct priv_s { + AVCodecContext *lavc_ctx; + audio_probe_t* probe; +}priv_t; + +static const audio_probe_t* __FASTCALL__ probe(sh_audio_t* sh,uint32_t wtag) { + unsigned i; + audio_probe_t* acodec = NULL; + const char *what="AVCodecID"; + priv_t* priv=reinterpret_cast<priv_t*>(sh->context); + enum AVCodecID id = ff_codec_get_id(ff_codec_wav_tags,wtag); + if (id <= 0) { + prn_err: + MSG_ERR("Cannot find %s for '0x%X' tag! Try force -ac option\n" + ,what + ,sh->wtag); + return NULL; + } + if(!priv){ + priv=new(zeromem) priv_t; + sh->context=priv; +// avcodec_init(); + avcodec_register_all(); + } + AVCodec *codec=avcodec_find_decoder(id); + if(!codec) { what="AVCodec"; goto prn_err; } + + acodec=new(zeromem) audio_probe_t; + acodec->codec_dll=mp_strdup(avcodec_get_name(id)); + acodec->driver="lavc"; + acodec->wtag=wtag; + if(codec->sample_fmts) + for(i=0;i<Audio_MaxOutSample;i++) { + if(codec->sample_fmts[i]==-1) break; + acodec->sample_fmt[i]=ff_codec_get_tag(ff_codec_wav_tags,id); + } + priv->probe=acodec; + return acodec; +} + +struct codecs_st* __FASTCALL__ find_lavc_audio(sh_audio_t* sh) { + const audio_probe_t* aprobe=probe(sh,sh->wtag); + struct codecs_st* acodec = NULL; + if(aprobe) { + acodec=new(zeromem) struct codecs_st; + strcpy(acodec->dll_name,aprobe->codec_dll); + strcpy(acodec->driver_name,aprobe->driver); + strcpy(acodec->codec_name,acodec->dll_name); + memcpy(acodec->outfmt,aprobe->sample_fmt,sizeof(aprobe->sample_fmt)); + } + return acodec; +} + +#ifndef FF_INPUT_BUFFER_PADDING_SIZE +#define FF_INPUT_BUFFER_PADDING_SIZE 8 +#endif + +static const ad_info_t info = { + "lavc audio decoders", + "lavc", + "Nickols_K", + "build-in" +}; + +static const config_t options[] = { + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBAD_EXTERN(lavc) + +MPXP_Rc preinit(sh_audio_t *sh) +{ + sh->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; + return MPXP_Ok; +} + +MPXP_Rc init(sh_audio_t *sh_audio) +{ + int x; + float pts; + AVCodec *lavc_codec=NULL; + priv_t* priv=reinterpret_cast<priv_t*>(sh_audio->context); + MSG_V("LAVC audio codec\n"); + if(!priv){ + priv=new(zeromem) priv_t; + sh_audio->context=priv; +// avcodec_init(); + avcodec_register_all(); + } + lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll_name); + if(!lavc_codec) { + MSG_ERR(MSGTR_MissingLAVCcodec,sh_audio->codec->dll_name); + return MPXP_False; + } + priv->lavc_ctx = avcodec_alloc_context3(lavc_codec); + if(sh_audio->wf) { + priv->lavc_ctx->channels = sh_audio->wf->nChannels; + priv->lavc_ctx->sample_rate = sh_audio->wf->nSamplesPerSec; + priv->lavc_ctx->bit_rate = sh_audio->wf->nAvgBytesPerSec * 8; + priv->lavc_ctx->block_align = sh_audio->wf->nBlockAlign; + priv->lavc_ctx->bits_per_coded_sample = sh_audio->wf->wBitsPerSample; + /* alloc extra data */ + if (sh_audio->wf->cbSize > 0) { + priv->lavc_ctx->extradata = new uint8_t[sh_audio->wf->cbSize+FF_INPUT_BUFFER_PADDING_SIZE]; + priv->lavc_ctx->extradata_size = sh_audio->wf->cbSize; + memcpy(priv->lavc_ctx->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX), + priv->lavc_ctx->extradata_size); + } + } + // for QDM2 + if (sh_audio->codecdata_len && sh_audio->codecdata && !priv->lavc_ctx->extradata) { + priv->lavc_ctx->extradata = new uint8_t[sh_audio->codecdata_len]; + priv->lavc_ctx->extradata_size = sh_audio->codecdata_len; + memcpy(priv->lavc_ctx->extradata, (char *)sh_audio->codecdata, + priv->lavc_ctx->extradata_size); + } + priv->lavc_ctx->codec_tag = sh_audio->wtag; + priv->lavc_ctx->codec_type = lavc_codec->type; + priv->lavc_ctx->codec_id = lavc_codec->id; + /* open it */ + if (avcodec_open2(priv->lavc_ctx, lavc_codec, NULL) < 0) { + MSG_ERR( MSGTR_CantOpenCodec); + return MPXP_False; + } + MSG_V("INFO: libavcodec init OK!\n"); + + // Decode at least 1 byte: (to get header filled) + x=decode(sh_audio,reinterpret_cast<unsigned char*>(sh_audio->a_buffer),1,sh_audio->a_buffer_size,&pts); + if(x>0) sh_audio->a_buffer_len=x; + + sh_audio->nch=priv->lavc_ctx->channels; + sh_audio->rate=priv->lavc_ctx->sample_rate; + switch(priv->lavc_ctx->sample_fmt) { + case AV_SAMPLE_FMT_U8: ///< unsigned 8 bits + sh_audio->afmt=AFMT_U8; + break; + default: + case AV_SAMPLE_FMT_S16: ///< signed 16 bits + sh_audio->afmt=AFMT_S16_LE; + break; + case AV_SAMPLE_FMT_S32: ///< signed 32 bits + sh_audio->afmt=AFMT_S32_LE; + break; + case AV_SAMPLE_FMT_FLT: ///< float + sh_audio->afmt=AFMT_FLOAT32; + break; + } + sh_audio->i_bps=priv->lavc_ctx->bit_rate/8; + return MPXP_Ok; +} + +void uninit(sh_audio_t *sh) +{ + priv_t* priv=reinterpret_cast<priv_t*>(sh->context); + avcodec_close(priv->lavc_ctx); + if (priv->lavc_ctx->extradata) delete priv->lavc_ctx->extradata; + delete priv->lavc_ctx; + if(priv->probe) { delete priv->probe->codec_dll; delete priv->probe; } + delete priv; + sh->context=NULL; +} + +MPXP_Rc control(sh_audio_t *sh,int cmd,any_t* arg, ...) +{ + UNUSED(arg); + priv_t* priv = reinterpret_cast<priv_t*>(sh->context); + switch(cmd){ + case ADCTRL_RESYNC_STREAM: + avcodec_flush_buffers(priv->lavc_ctx); + return MPXP_True; + default: break; + } + return MPXP_Unknown; +} + +unsigned decode(sh_audio_t *sh_audio,unsigned char *buf,unsigned minlen,unsigned maxlen,float *pts) +{ + priv_t* priv = reinterpret_cast<priv_t*>(sh_audio->context); + unsigned char *start=NULL; + int y; + unsigned len=0; + float apts=0.,null_pts; + while(len<minlen){ + AVPacket pkt; + int len2=maxlen; + int x=ds_get_packet_r(sh_audio->ds,&start,apts?&null_pts:&apts); + if(x<=0) break; // error + if(sh_audio->wtag==mmioFOURCC('d','n','e','t')) swab(start,start,x&(~1)); + av_init_packet(&pkt); + pkt.data = start; + pkt.size = x; + y=avcodec_decode_audio3(priv->lavc_ctx,(int16_t*)buf,&len2,&pkt); + if(y<0){ MSG_V("lavc_audio: error\n");break; } + if(y<x) + { + sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) + if(sh_audio->wtag==mmioFOURCC('d','n','e','t')) + swab(start+y,start+y,(x-y)&~(1)); + } + if(len2>0){ + //len=len2;break; + if(len==0) len=len2; else len+=len2; + buf+=len2; + } + MSG_DBG2("Decoded %d -> %d \n",y,len2); + } + *pts=apts; + return len; +} Modified: mplayerxp/libmpcodecs/dec_audio.h =================================================================== --- mplayerxp/libmpcodecs/dec_audio.h 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/dec_audio.h 2012-11-23 11:55:38 UTC (rev 441) @@ -12,7 +12,7 @@ extern void __FASTCALL__ mpca_resync_stream(any_t *handle); extern void __FASTCALL__ mpca_skip_frame(any_t *handle); struct codecs_st; -extern struct codecs_st* __FASTCALL__ find_ffmpeg_audio(sh_audio_t*); +extern struct codecs_st* __FASTCALL__ find_lavc_audio(sh_audio_t*); extern MPXP_Rc mpca_init_filters(sh_audio_t *sh_audio, unsigned in_samplerate, unsigned in_channels, mpaf_format_e in_format, Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-11-23 11:55:38 UTC (rev 441) @@ -127,19 +127,19 @@ #endif } -any_t * mpcv_ffmpeg_init(sh_video_t* sh_video,any_t* libinput) { +any_t * mpcv_lavc_init(sh_video_t* sh_video,any_t* libinput) { priv_t* priv = new(zeromem) priv_t; priv->parent=sh_video; sh_video->decoder=priv; - /* Use ffmpeg's drivers as last hope */ - priv->mpvdec=vfm_find_driver("ffmpeg"); + /* Use lavc's drivers as last hope */ + priv->mpvdec=vfm_find_driver("lavc"); if(priv->mpvdec) { if(priv->mpvdec->init(sh_video,libinput)!=MPXP_Ok){ MSG_ERR(MSGTR_CODEC_CANT_INITV); return NULL; } } else { - MSG_ERR("Cannot find ffmpeg video decoder\n"); + MSG_ERR("Cannot find lavc video decoder\n"); return NULL; } mpcv_print_codec_info(priv); Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/dec_video.h 2012-11-23 11:55:38 UTC (rev 441) @@ -8,7 +8,7 @@ // dec_video.c: extern any_t* __FASTCALL__ mpcv_init(sh_video_t *sh_video, const char *codec_name,const char *family,int status,any_t*libinput); extern void __FASTCALL__ mpcv_uninit(any_t *handle); -extern any_t* __FASTCALL__ mpcv_ffmpeg_init(sh_video_t*,any_t* libinput); +extern any_t* __FASTCALL__ mpcv_lavc_init(sh_video_t*,any_t* libinput); extern int __FASTCALL__ mpcv_decode(any_t *handle,const enc_frame_t* frame); extern MPXP_Rc __FASTCALL__ mpcv_get_quality_max(any_t *handle,unsigned *qual); Modified: mplayerxp/libmpcodecs/vd.cpp =================================================================== --- mplayerxp/libmpcodecs/vd.cpp 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/vd.cpp 2012-11-23 11:55:38 UTC (rev 441) @@ -21,7 +21,7 @@ using namespace mpxp; extern const vd_functions_t mpcodecs_vd_null; -extern const vd_functions_t mpcodecs_vd_ffmpeg; +extern const vd_functions_t mpcodecs_vd_lavc; extern const vd_functions_t mpcodecs_vd_dshow; extern const vd_functions_t mpcodecs_vd_vfw; extern const vd_functions_t mpcodecs_vd_vfwex; @@ -68,7 +68,7 @@ #ifdef HAVE_LIBDV &mpcodecs_vd_libdv, #endif - &mpcodecs_vd_ffmpeg, + &mpcodecs_vd_lavc, &mpcodecs_vd_null, NULL }; Deleted: mplayerxp/libmpcodecs/vd_ffmpeg.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_ffmpeg.cpp 2012-11-23 10:53:52 UTC (rev 440) +++ mplayerxp/libmpcodecs/vd_ffmpeg.cpp 2012-11-23 11:55:38 UTC (rev 441) @@ -1,780 +0,0 @@ -#include <algorithm> - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <assert.h> -#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ - -#include "mp_config.h" -#include "mplayerxp.h" -#include "xmpcore/xmp_core.h" -#ifdef HAVE_GOMP -#include <omp.h> -#endif - -#include "help_mp.h" - -#include "osdep/bswap.h" -#include "osdep/mplib.h" - -#include "vd_internal.h" -#include "codecs_ld.h" -#include "postproc/postprocess.h" -#include "postproc/vf.h" -#include "libvo/video_out.h" -#include "osdep/bswap.h" - -using namespace mpxp; - -static const vd_info_t info = { - "FFmpeg's libavcodec codec family", - "ffmpeg", - "A'rpi", - "build-in" -}; - -static int lavc_param_error_resilience=2; -static int lavc_param_error_concealment=3; -static int lavc_param_vstats=0; -static int lavc_param_idct_algo=0; -static int lavc_param_debug=0; -static int lavc_param_vismv=0; -static int lavc_param_skip_top=0; -static int lavc_param_skip_bottom=0; -static int lavc_param_lowres=0; -static char *lavc_param_lowres_str=NULL; -static char *lavc_param_skip_loop_filter_str = NULL; -static char *lavc_param_skip_idct_str = NULL; -static char *lavc_param_skip_frame_str = NULL; -static int lavc_param_threads=-1; -static char *lavc_avopt = NULL; - -static int enable_ffslices=1; -static const config_t ff_options[] = { - {"slices", &enable_ffslices, CONF_TYPE_FLAG, 0, 0, 1, "enables slice-based method of frame rendering in ffmpeg decoder"}, - {"noslices", &enable_ffslices, CONF_TYPE_FLAG, 0, 1, 0, "disables slice-based method of frame rendering in ffmpeg decoder"}, - {"er", &lavc_param_error_resilience, CONF_TYPE_INT, CONF_RANGE, 0, 99, "specifies error resilience for ffmpeg decoders"}, - {"idct", &lavc_param_idct_algo, CONF_TYPE_INT, CONF_RANGE, 0, 99, "specifies idct algorithm for ffmpeg decoders"}, - {"ec", &lavc_param_error_concealment, CONF_TYPE_INT, CONF_RANGE, 0, 99, "specifies error concealment for ffmpeg decoders"}, - {"vstats", &lavc_param_vstats, CONF_TYPE_FLAG, 0, 0, 1, "specifies vstat for ffmpeg decoders"}, - {"debug", &lavc_param_debug, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, "specifies debug level for ffmpeg decoders"}, - {"vismv", &lavc_param_vismv, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, "specifies visualize motion vectors (MVs) for ffmpeg decoders"}, - {"st", &lavc_param_skip_top, CONF_TYPE_INT, CONF_RANGE, 0, 999, "specifies skipping top lines for ffmpeg decoders"}, - {"sb", &lavc_param_skip_bottom, CONF_TYPE_INT, CONF_RANGE, 0, 999, "specifies skipping bottom lines for ffmpeg decoders"}, - {"lowres", &lavc_param_lowres_str, CONF_TYPE_STRING, 0, 0, 0, "specifies decoding at 1= 1/2, 2=1/4, 3=1/8 resolutions for ffmpeg decoders"}, - {"skiploopfilter", &lavc_param_skip_loop_filter_str, CONF_TYPE_STRING, 0, 0, 0, "specifies skipping of loop filters for ffmpeg decoders"}, - {"skipidct", &lavc_param_skip_idct_str, CONF_TYPE_STRING, 0, 0, 0, "specifies skipping of IDCT filters for ffmpeg decoders"}, - {"skipframe", &lavc_param_skip_frame_str, CONF_TYPE_STRING, 0, 0, 0, "indicates frame skipping for ffmpeg decoders"}, - {"threads", &lavc_param_threads, CONF_TYPE_INT, CONF_RANGE, 1, 8, "specifies number of threads for ffmpeg decoders"}, - {"o", &lavc_avopt, CONF_TYPE_STRING, 0, 0, 0, "specifies additional option for ffmpeg decoders"}, - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -static const config_t options[] = { - {"ffmpeg", (any_t*)&ff_options, CONF_TYPE_SUBCONFIG, 0, 0, 0, "FFMPEG specific options"}, - { NULL, NULL, 0, 0, 0, 0, NULL} -}; - -LIBVD_EXTERN(ffmpeg) - -#include "libavcodec/avcodec.h" -#include "libavformat/riff.h" -#include "libvo/video_out.h" - - -static int vcodec_inited=0; -typedef struct priv_s { - int use_slices; - int cap_slices; - int use_dr1; - int cap_dr1; - AVCodec *lavc_codec; - AVCodecContext *ctx; - AVFrame *lavc_picture; - mp_image_t* mpi; - unsigned long long frame_number; /* total frame number since begin of movie */ - int b_age; - int ip_age[2]; - int qp_stat[32]; -// double qp_sum; -// double inv_qp_sum; - int ip_count; - int b_count; - int vo_inited; - int hello_printed; - video_probe_t* probe; -}priv_t; -static pp_context* ppContext=NULL; -static void draw_slice(struct AVCodecContext *s, const AVFrame *src, int offset[4], int y, int type, int height); - -static enum AVDiscard str2AVDiscard(char *str) { - if (!str) return AVDISCARD_DEFAULT; - if (strcasecmp(str, "none" ) == 0) return AVDISCARD_NONE; - if (strcasecmp(str, "default") == 0) return AVDISCARD_DEFAULT; - if (strcasecmp(str, "nonref" ) == 0) return AVDISCARD_NONREF; - if (strcasecmp(str, "bidir" ) == 0) return AVDISCARD_BIDIR; - if (strcasecmp(str, "nonkey" ) == 0) return AVDISCARD_NONKEY; - if (strcasecmp(str, "all" ) == 0) return AVDISCARD_ALL; - MSG_ERR("Unknown discard value %s\n", str); - return AVDISCARD_DEFAULT; -} - -/* stupid workaround for current version of ffmpeg */ -const __attribute((used)) uint8_t last_coeff_flag_offset_8x8[63] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8 -}; - -/* to set/get/query special features/parameters */ -static MPXP_Rc control(sh_video_t *sh,int cmd,any_t* arg,...){ - priv_t *ctx = reinterpret_cast<priv_t*>(sh->context); - uint32_t out_fourcc; - AVCodecContext *avctx = ctx->ctx; - switch(cmd){ - case VDCTRL_QUERY_MAX_PP_LEVEL: - *((unsigned*)arg)=PP_QUALITY_MAX; - return MPXP_Ok; - case VDCTRL_SET_PP_LEVEL: { - int quality=*((int*)arg); - if(quality<0 || quality>PP_QUALITY_MAX) quality=PP_QUALITY_MAX; - return MPXP_Ok; - } - case VDCTRL_QUERY_FORMAT: - { - uint32_t format =(*((int*)arg)); - if(avctx->pix_fmt == -1 && - avctx->get_format && - avctx->codec->pix_fmts) - avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); - MSG_DBG2("[vd_ffmpeg QUERY_FORMAT for %c%c%c%c] pixfmt = %X\n" - ,((char *)&format)[0],((char *)&format)[1],((char *)&format)[2],((char *)&format)[3] - ,avctx->pix_fmt); - if(avctx->codec->pix_fmts) { - unsigned i; - MSG_DBG2("[vd_ffmpeg]avctx->codec->pix_fmts:"); - for(i=0;;i++) { MSG_DBG2(" %X",avctx->codec->pix_fmts[i]); if(avctx->codec->pix_fmts[i]==-1) break; } - MSG_DBG2("\n"); - } - else - MSG_DBG2("[vd_ffmpeg]avctx->codec->pix_fmts doesn't exist\n"); - out_fourcc = fourcc_from_pixfmt(avctx->pix_fmt); - if(out_fourcc==format) return MPXP_True; - // possible conversions: - switch( format ){ - case IMGFMT_YV12: - case IMGFMT_IYUV: - case IMGFMT_I420: - // "converted" using pointer/stride modification - if( avctx->pix_fmt==PIX_FMT_YUV420P || // u/v swap - avctx->pix_fmt==PIX_FMT_YUV422P || - avctx->pix_fmt==PIX_FMT_YUVJ420P) return MPXP_True;// half stride - /* these codecs may return only: PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_YUV420P*/ - /* TODO: we must test pix_fmt after decoding first frame at least */ - if( avctx->codec_id == CODEC_ID_MPEG1VIDEO || - avctx->codec_id == CODEC_ID_MPEG2VIDEO) return MPXP_True; - break; -#ifdef HAVE_XVMC - case IMGFMT_XVMC_IDCT_MPEG2: - case IMGFMT_XVMC_MOCO_MPEG2: - if(avctx->pix_fmt==PIX_FMT_XVMC_MPEG2_IDCT) return MPXP_True; -#endif - } - return MPXP_False; - } - break; - case VDCTRL_RESYNC_STREAM: - avcodec_flush_buffers(avctx); - return MPXP_True; - } - return MPXP_Unknown; -} - -static const video_probe_t* __FASTCALL__ probe(sh_video_t *sh,uint32_t fcc) { - unsigned i; - unsigned char flag = CODECS_FLAG_NOFLIP; - video_probe_t* vprobe = NULL; - priv_t* priv=reinterpret_cast<priv_t*>(sh->context); - const char* what="AVCodecID"; - if(!priv) priv=new(zeromem) priv_t; - sh->context = priv; - if(!vcodec_inited){ -// avcodec_init(); - avcodec_register_all(); - vcodec_inited=1; - } - enum AVCodecID ff_id = ff_codec_get_id(ff_codec_bmp_tags,fcc); - if (ff_id == AV_CODEC_ID_NONE) { - const char *fourcc; - prn_err: - fourcc=reinterpret_cast<char*>(&fcc); - MSG_ERR("Cannot find %s for '%c%c%c%c' fourcc! Try force -vc option\n" - ,what - ,fourcc[0],fourcc[1],fourcc[2],fourcc[3]); - return NULL; - } - AVCodec *codec=avcodec_find_decoder(ff_id); - if(!codec) { what="AVCodec"; goto prn_err; } - vprobe=new(zeromem) video_probe_t; - vprobe->driver="ffmpeg"; - vprobe->codec_dll=mp_strdup(avcodec_get_name(ff_id)); - if(codec->pix_fmts) - for(i=0;i<Video_MaxOutFmt;i++) { - if(codec->pix_fmts[i]==-1) break; - vprobe->pix_fmt[i]=avcodec_pix_fmt_to_codec_tag(codec->pix_fmts[i]); - vprobe->flags[i]=video_flags_e(flag); - } - if(!i) { vprobe->pix_fmt[i]=IMGFMT_YV12; vprobe->flags[i]=video_flags_e(flag); } - priv->probe=vprobe; - return vprobe; -} - -static MPXP_Rc find_vdecoder(sh_video_t* sh) { - const video_probe_t* vprobe=probe(sh,sh->fourcc); - if(vprobe) { - sh->codec=new(zeromem) struct codecs_st; - strcpy(sh->codec->dll_name,vprobe->codec_dll); - strcpy(sh->codec->driver_name,vprobe->driver); - strcpy(sh->codec->codec_name,sh->codec->dll_name); - memcpy(sh->codec->outfmt,vprobe->pix_fmt,sizeof(vprobe->pix_fmt)); - return MPXP_Ok; - } - return MPXP_False; -} - -extern unsigned xp_num_cpu; -static MPXP_Rc init(sh_video_t *sh,any_t* libinput){ - unsigned avc_version=0; - priv_t *priv = reinterpret_cast<priv_t*>(sh->context); - int pp_flags; - if(mp_conf.npp_options) pp2_init(); - if(!vcodec_inited){ -// avcodec_init(); - avcodec_register_all(); - vcodec_inited=1; - } - if(!priv) priv=new(zeromem) priv_t; - sh->context = priv; - priv->frame_number=-2; - if(!sh->codec) if(find_vdecoder(sh)!=MPXP_False) { - MSG_ERR("Can't find ffmpeg decoder\n"); - return MPXP_False; - } - priv->lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll_name); - if(!priv->lavc_codec){ - MSG_ERR(MSGTR_MissingLAVCcodec,sh->codec->dll_name); - return MPXP_False; - } - - priv->ctx = avcodec_alloc_context3(priv->lavc_codec); - priv->lavc_picture = avcodec_alloc_frame(); - if(!(priv->ctx && priv->lavc_picture)) { - MSG_ERR(MSGTR_OutOfMemory); - return MPXP_False; - } - - priv->ctx->width = sh->src_w; - priv->ctx->height= sh->src_h; - // priv->ctx->error_recognition= lavc_param_error_resilience; - priv->ctx->error_concealment= lavc_param_error_concealment; - priv->ctx->debug= lavc_param_debug; - priv->ctx->codec_tag= sh->fourcc; - priv->ctx->stream_codec_tag=sh->video.fccHandler; - priv->ctx->idct_algo=0; /*auto*/ -#if 0 - if (lavc_param_debug) - av_log_set_level(AV_LOG_DEBUG); -#endif - priv->ctx->debug_mv= lavc_param_vismv; - priv->ctx->skip_top = lavc_param_skip_top; - priv->ctx->skip_bottom= lavc_param_skip_bottom; - if(lavc_param_lowres_str != NULL) { - int lowres_w=0; - sscanf(lavc_param_lowres_str, "%d,%d", &lavc_param_lowres, &lowres_w); - if(lavc_param_lowres < 1 || lavc_param_lowres > 16 || (lowres_w > 0 && priv->ctx->width < lowres_w)) - lavc_param_lowres = 0; - priv->ctx->lowres = lavc_param_lowres; - } - priv->ctx->skip_loop_filter = str2AVDiscard(lavc_param_skip_loop_filter_str); - priv->ctx->skip_idct = str2AVDiscard(lavc_param_skip_idct_str); - priv->ctx->skip_frame = str2AVDiscard(lavc_param_skip_frame_str); - if(sh->bih) - priv->ctx->bits_per_coded_sample= sh->bih->biBitCount; - MSG_DBG2("libavcodec.size: %d x %d\n",priv->ctx->width,priv->ctx->height); - /* AVRn stores huffman table in AVI header */ - /* Pegasus MJPEG stores it also in AVI header, but it uses the common - MJPG fourcc :( */ - if (sh->bih && (sh->bih->biSize != sizeof(BITMAPINFOHEADER)) && - (sh->fourcc == mmioFOURCC('A','V','R','n') || - sh->fourcc == mmioFOURCC('M','J','P','G'))) { -// priv->ctx->flags |= CODEC_FLAG_EXTERN_HUFF; - priv->ctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER); - priv->ctx->extradata = new uint8_t [priv->ctx->extradata_size]; - memcpy(priv->ctx->extradata, sh->bih+sizeof(BITMAPINFOHEADER), - priv->ctx->extradata_size); - } - if(sh->fourcc == mmioFOURCC('R', 'V', '1', '0') - || sh->fourcc == mmioFOURCC('R', 'V', '1', '3') - || sh->fourcc == mmioFOURCC('R', 'V', '2', '0') - || sh->fourcc == mmioFOURCC('R', 'V', '3', '0') - || sh->fourcc == mmioFOURCC('R', 'V', '4', '0')) { - priv->ctx->extradata_size= 8; - priv->ctx->extradata = new uint8_t[priv->ctx->extradata_size]; - if(sh->bih->biSize!=sizeof(*sh->bih)+8){ - /* only 1 packet per frame & sub_id from fourcc */ - ((uint32_t*)priv->ctx->extradata)[0] = 0; - ((uint32_t*)priv->ctx->extradata)[1] = - (sh->fourcc == mmioFOURCC('R', 'V', '1', '3')) ? 0x10003001 : 0x10000000; - } else { - /* has extra slice header (demux_rm or rm->avi streamcopy) */ - unsigned int* extrahdr=(unsigned int*)(sh->bih+1); - ((uint32_t*)priv->ctx->extradata)[0] = extrahdr[0]; - ((uint32_t*)priv->ctx->extradata)[1] = extrahdr[1]; - } - } - if (sh->bih && (sh->bih->biSize != sizeof(BITMAPINFOHEADER)) && - (sh->fourcc == mmioFOURCC('M','4','S','2') || - sh->fourcc == mmioFOURCC('M','P','4','S') || - sh->fourcc == mmioFOURCC('H','F','Y','U') || - sh->fourcc == mmioFOURCC('F','F','V','H') || - sh->fourcc == mmioFOURCC('W','M','V','2') || - sh->fourcc == mmioFOURCC('W','M','V','3') || - sh->fourcc == mmioFOURCC('A','S','V','1') || - sh->fourcc == mmioFOURCC('A','S','V','2') || - sh->fourcc == mmioFOURCC('V','S','S','H') || - sh->fourcc == mmioFOURCC('M','S','Z','H') || - sh->fourcc == mmioFOURCC('Z','L','I','B') || - sh->fourcc == mmioFOURCC('M','P','4','V') || - sh->fourcc == mmioFOURCC('F','L','I','C') || - sh->fourcc == mmioFOURCC('S','N','O','W') || - sh->fourcc == mmioFOURCC('a','v','c','1') || - sh->fourcc == mmioFOURCC('L','O','C','O') || - sh->fourcc == mmioFOURCC('t','h','e','o') - )) { - priv->ctx->extradata_size = sh->bih->biSize-sizeof(BITMAPINFOHEADER); - priv->ctx->extradata = new uint8_t [priv->ctx->extradata_size]; - memcpy(priv->ctx->extradata, sh->bih+1, priv->ctx->extradata_size); - } - if (sh->ImageDesc && - sh->fourcc == mmioFOURCC('S','V','Q','3')){ - priv->ctx->extradata_size = *(int*)sh->ImageDesc; - priv->ctx->extradata = new uint8_t [priv->ctx->extradata_size]; - memcpy(priv->ctx->extradata, ((int*)sh->ImageDesc)+1, priv->ctx->extradata_size); - } - /* Pass palette to codec */ -#if 0 - if (sh->bih && (sh->bih->biBitCount <= 8)) { - priv->ctx->palctrl = (AVPaletteControl*)mp_calloc(1,sizeof(AVPaletteControl)); - priv->ctx->palctrl->palette_changed = 1; - if (sh->bih->biSize-sizeof(BITMAPINFOHEADER)) - /* Palette size in biSize */ - memcpy(priv->ctx->palctrl->palette, sh->bih+1, - std::min(sh->bih->biSize-sizeof(BITMAPINFOHEADER), AVPALETTE_SIZE)); - else - /* Palette size in biClrUsed */ - memcpy(priv->ctx->palctrl->palette, sh->bih+1, - std::min(sh->bih->biClrUsed * 4, AVPALETTE_SIZE)); - } -#endif - if(sh->bih) - priv->ctx->bits_per_coded_sample= sh->bih->biBitCount; - -#ifdef _OPENMP - /* Note: Slices have effect on UNI-processor machines only */ - if(enable_ffslices && omp_get_num_procs()>1 && mp_conf.gomp) enable_ffslices=0; -#endif - if(priv->lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND && enable_ffslices) priv->cap_slices=1; -/* enable DR1 method */ - if(priv->lavc_codec->capabilities&CODEC_CAP_DR1) priv->cap_dr1=1; - priv->ctx->flags|= CODEC_FLAG_EMU_EDGE; - - if(lavc_param_threads < 0) lavc_param_threads = xp_num_cpu; - if(lavc_param_threads > 1) { - priv->ctx->thread_count = lavc_param_threads; - MSG_STATUS("Using %i threads in FFMPEG\n",lavc_param_threads); - } - /* open it */ - if (avcodec_open2(priv->ctx, priv->lavc_codec, NULL) < 0) { - MSG_ERR(MSGTR_CantOpenCodec); - return MPXP_False; - } - MSG_V("INFO: libavcodec.so (%06X) video codec[%c%c%c%c] init OK!\n" - ,avc_version - ,((char *)&sh->fourcc)[0],((char *)&sh->fourcc)[1],((char *)&sh->fourcc)[2],((char *)&sh->fourcc)[3]); - if(mp_conf.npp_options) { - pp_flags=0; - switch(sh->codec->outfmt[sh->outfmtidx]) { - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: pp_flags = PP_FORMAT_420; - break; - case IMGFMT_YVYU: - case IMGFMT_YUY2: pp_flags = PP_FORMAT_422; - break; - case IMGFMT_411P: pp_flags = PP_FORMAT_411; - break; - default: { - const char *fmt; - fmt = (const char *)&sh->codec->outfmt[sh->outfmtidx]; - MSG_WARN("Can't apply postprocessing for"); - if(isprint(fmt[0]) && isprint(fmt[1]) && isprint(fmt[2]) && isprint(fmt[3])) - MSG_WARN(" '%c%c%c%c'!\n",fmt[0],fmt[1],fmt[2],fmt[3]); - else MSG_ERR(" 0x%08X!\n",sh->codec->outfmt[sh->outfmtidx]); - break; - } - } - if(pp_flags) ppContext=pp2_get_context(sh->src_w,sh->src_h,pp_flags); - } - return mpcodecs_config_vo(sh,sh->src_w,sh->src_h,libinput); -} - -// uninit driver -static void uninit(sh_video_t *sh){ - priv_t *priv=reinterpret_cast<priv_t*>(sh->context); - if (avcodec_close(priv->ctx) < 0) - MSG_ERR( MSGTR_CantCloseCodec); - if (priv->ctx->extradata_size) - delete priv->ctx->extradata; - delete priv->ctx; - delete priv->lavc_picture; - if(priv->probe) { delete priv->probe->codec_dll; delete priv->probe; } - delete priv; - if(ppContext) pp_free_context(ppContext); - ppContext=NULL; - pp2_uninit(); - vcodec_inited=0; -} - -static int get_buffer(AVCodecContext *avctx, AVFrame *pic){ - sh_video_t * sh = reinterpret_cast<sh_video_t*>(avctx->opaque); - priv_t *priv = reinterpret_cast<priv_t*>(sh->context); - mp_image_t* mpi=NULL; - int flags= MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE; - int type= MP_IMGTYPE_IPB; - int width= avctx->width; - int height= avctx->height; - int align=15; -//printf("get_buffer %d %d %d\n", pic->reference, ctx->ip_count, ctx->b_count); - if(avctx->pix_fmt == PIX_FMT_YUV410P) - align=63; //yes seriously, its really needed (16x16 chroma blocks in SVQ1 -> 64x64) - - if (pic->buffer_hints) { - MSG_DBG2( "Buffer hints: %u\n", pic->buffer_hints); - type = MP_IMGTYPE_TEMP; - if (pic->buffer_hints & FF_BUFFER_HINTS_READABLE) - flags |= MP_IMGFLAG_READABLE; - if (pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) { - type = MP_IMGTYPE_STATIC; - flags |= MP_IMGFLAG_PRESERVE; - } - if (pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) { - type = MP_IMGTYPE_STATIC; - flags |= MP_IMGFLAG_PRESERVE; - } - flags|=((avctx->skip_frame==AVDISCARD_NONE) && priv->use_slices) ? - MP_IMGFLAG_DRAW_CALLBACK:0; - MSG_DBG2( type == MP_IMGTYPE_STATIC ? "using STATIC\n" : "using TEMP\n"); - } else { - if(!pic->reference){ - priv->b_count++; - flags|=((avctx->skip_frame==AVDISCARD_NONE) && priv->use_slices) ? - MP_IMGFLAG_DRAW_CALLBACK:0; - }else{ - priv->ip_count++; - flags|= MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE - | (priv->use_slices ? MP_IMGFLAG_DRAW_CALLBACK : 0); - } - } - - if (!pic->buffer_hints) { - if(priv->b_count>1 || priv->ip_count>2){ - MSG_WARN("DR1 failure\n"); - priv->use_dr1=0; //FIXME - avctx->get_buffer= avcodec_default_get_buffer; - return avctx->get_buffer(avctx, pic); - } - if(avctx->has_b_frames){ - type= MP_IMGTYPE_IPB; - }else{ - type= MP_IMGTYPE_IP; - } - MSG_DBG2( type== MP_IMGTYPE_IPB ? "using IPB\n" : "using IP\n"); - } - - MSG_V("ff width=%i height=%i\n",width,height); - mpi= mpcodecs_get_image(sh,type, flags, (width+align)&(~align), (height+align)&(~align)); - if(mpi->flags & MP_IMGFLAG_DIRECT) mpi->flags |= MP_IMGFLAG_RENDERED; - // Palette support: libavcodec copies palette to *data[1] - if (mpi->bpp == 8) mpi->planes[1] = new unsigned char [AVPALETTE_SIZE]; - - pic->data[0]= mpi->planes[0]; - pic->data[1]= mpi->planes[1]; - pic->data[2]= mpi->planes[2]; - - /* Note, some (many) codecs in libavcodec must have stride1==stride2 && no changes between frames - * lavc will check that and die with an error message, if its not true - */ - pic->linesize[0]= mpi->stride[0]; - pic->linesize[1]= mpi->stride[1]; - pic->linesize[2]= mpi->stride[2]; - - pic->opaque = mpi; - - if(pic->reference) { -// pic->age= priv->ip_age[0]; - priv->ip_age[0]= priv->ip_age[1]+1; - priv->ip_age[1]= 1; - priv->b_age++; - } else { -// pic->age= priv->b_age; - priv->ip_age[0]++; - priv->ip_age[1]++; - priv->b_age=1; - } - pic->type= FF_BUFFER_TYPE_USER; - return 0; -} - -static void release_buffer(struct AVCodecContext *avctx, AVFrame *pic){ - mp_image_t* mpi= reinterpret_cast<mp_image_t*>(pic->opaque); - sh_video_t * sh = reinterpret_cast<sh_video_t*>(avctx->opaque); - priv_t *priv = reinterpret_cast<priv_t*>(sh->context); - int i; - - if(priv->ip_count <= 2 && priv->b_count<=1){ - if(mpi->flags&MP_IMGFLAG_PRESERVE) - priv->ip_count--; - else - priv->b_count--; - } - - if(mpi) { - if(mpi->bpp == 8 && mpi->planes[1]) delete mpi->planes[1]; - if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK) free_mp_image(mpi); - } - - if(pic->type!=FF_BUFFER_TYPE_USER){ - avcodec_default_release_buffer(avctx, pic); - return; - } - - for(i=0; i<4; i++){ - pic->data[i]= NULL; - } -//printf("R%X %X\n", pic->linesize[0], pic->data[0]); -} - - -static void draw_slice(struct AVCodecContext *s, - const AVFrame *src, int offset[4], - int y, int type, int height) -{ - UNUSED(offset); - UNUSED(type); - sh_video_t *sh=reinterpret_cast<sh_video_t*>(s->opaque); - priv_t *priv=reinterpret_cast<priv_t*>(sh->context); - mp_image_t *mpi=priv->mpi; - unsigned long long int total_frame; - unsigned orig_idx = mpi->xp_idx; - /* sync-point*/ - if(src->pict_type==AV_PICTURE_TYPE_I) priv->frame_number = src->coded_picture_number; - total_frame = priv->frame_number; - if(priv->use_dr1) { MSG_DBG2("Ignoring draw_slice due dr1\n"); return; } /* we may call vo_start_slice() here */ -// mpi=mpcodecs_get_image(sh,MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_DIRECT,s->width,s->height); - - mpi->stride[0]=src->linesize[0]; - mpi->stride[1]=src->linesize[1]; - mpi->stride[2]=src->linesize[2]; - mpi->planes[0] = src->data[0]; - mpi->planes[1] = src->data[1]; - mpi->planes[2] = src->data[2]; - mpi->w=s->width; - mpi->y=y; - mpi->h=height; - mpi->chroma_height = height >> mpi->chroma_y_shift; - /* provide info for pp */ - mpi->qscale=(char *)priv->lavc_picture->qscale_table; - mpi->qstride=priv->lavc_picture->qstride; - mpi->pict_type=priv->lavc_picture->pict_type; - mpi->qscale_type=priv->lavc_picture->qscale_type; - - if(sh->codec->outfmt[sh->outfmtidx] == IMGFMT_I420 || - sh->codec->outfmt[sh->outfmtidx] == IMGFMT_IYUV) - { - uint8_t *tmp; - unsigned ls; - tmp=mpi->planes[2]; - mpi->planes[2]=mpi->planes[1]; - mpi->planes[1]=tmp; - ls=mpi->stride[2]; - mpi->stride[2]=mpi->stride[1]; - mpi->stride[1]=ls; - } -#if 0 - /* handle IPB-frames here */ - if(total_frame!=src->coded_picture_number) { - unsigned long long int tf = total_frame; - /* we can do only 1 step forward */ - if(total_frame<src->coded_picture_number) - mpi->xp_idx = vo_get_decoding_next_frame(mpi->xp_idx); - else - while(tf>src->coded_picture_number) { - mpi->xp_idx = vo_get_decoding_prev_frame(mpi->xp_idx); - tf--; - } - } -#endif - MSG_DBG2("ff_draw_callback<%u->%u:%u:%u-%s>[%ux%u] %i %i %i %i\n", - orig_idx,mpi->xp_idx,(unsigned)total_frame,src->coded_picture_number, - src->pict_type==AV_PICTURE_TYPE_BI?"bi": - src->pict_type==AV_PICTURE_TYPE_SP?"sp": - src->pict_type==AV_PICTURE_TYPE_SI?"si": - src->pict_type==AV_PICTURE_TYPE_S?"s": - src->pict_type==AV_PICTURE_TYPE_B?"b": - src->pict_type==AV_PICTURE_TYPE_P?"p": - src->pict_type==AV_PICTURE_TYPE_I?"i":"??" - ,mpi->width,mpi->height,mpi->x,mpi->y,mpi->w,mpi->h); - __MP_ATOMIC(sh->active_slices++); - mpcodecs_draw_slice (sh, mpi); - mpi->xp_idx = orig_idx; - __MP_ATOMIC(sh->active_slices--); -} - -/* copypaste from demux_real.c - it should match to get it working!*/ - -typedef struct __attribute__((__packed__)) dp_hdr_s { - uint32_t chunks; - uint32_t timestamp; - uint32_t len; - uint32_t chunktab; -} dp_hdr_t; - -// decode a frame -static mp_image_t* decode(sh_video_t *sh,const enc_frame_t* frame){ - int got_picture=0; - int ret,has_b_frames; - unsigned len=frame->len; - any_t* data=frame->data; - priv_t *priv=reinterpret_cast<priv_t*>(sh->context); - mp_image_t* mpi=NULL; - - priv->ctx->opaque=sh; - if(frame->len<=0) return NULL; // skipped frame - - priv->ctx->skip_frame=(frame->flags&3)?((frame->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; - else priv->use_slices=0; -/* - if codec is capable DR1 - if sh->vfilter==vf_vo (DR1 is meaningless into temp buffer) - It always happens with (vidix+bus mastering), (if (src_w%16==0)) with xv -*/ - has_b_frames=priv->ctx->has_b_frames|| - sh->fourcc==0x10000001 || /* mpeg1 may have b frames */ - priv->lavc_codec->id==CODEC_ID_SVQ3|| - 1; - mpi= mpcodecs_get_image(sh,has_b_frames?MP_IMGTYPE_IPB:MP_IMGTYPE_IP,MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE|MP_IMGFLAG_READABLE|MP_IMGFLAG_PRESERVE, - 16,16); - if(priv->cap_dr1 && - priv->lavc_codec->id != CODEC_ID_H264 && - priv->use_slices && mpi->flags&MP_IMGFLAG_DIRECT) - priv->use_dr1=1; - if(has_b_frames) { - MSG_V("Disable slice-based rendering in FFMPEG due possible B-frames in video-stream\n"); - priv->use_slices=0; - } - if(priv->use_slices) priv->use_dr1=0; - if( sh->fourcc == mmioFOURCC('R', 'V', '1', '0') - || sh->fourcc == mmioFOURCC('R', 'V', '1', '3') - || sh->fourcc == mmioFOURCC('R', 'V', '2', '0') - || sh->fourcc == mmioFOURCC('R', 'V', '3', '0') - || sh->fourcc == mmioFOURCC('R', 'V', '4', '0')) - if(sh->bih->biSize==sizeof(*sh->bih)+8){ - int i; - const dp_hdr_t *hdr= (const dp_hdr_t*)data; - - if(priv->ctx->slice_offset==NULL) - priv->ctx->slice_offset= new 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]= ((const uint32_t*)(data+hdr->chunktab))[2*i+1]; - len=hdr->len; - data=reinterpret_cast<any_t*>(reinterpret_cast<long>(data)+sizeof(dp_hdr_t)); - } - if(priv->use_dr1){ - priv->b_age= priv->ip_age[0]= priv->ip_age[1]= 256*256*256*64; - priv->ip_count= priv->b_count= 0; - priv->ctx->get_buffer= get_buffer; - priv->ctx->release_buffer= release_buffer; - priv->ctx->reget_buffer= get_buffer; - } - if(!(frame->flags&3) && priv->use_slices) - { - if(mpi) free_mp_image(mpi); - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_DIRECT,sh->src_w, sh->src_h); - priv->mpi = mpi; - priv->frame_number++; - priv->ctx->draw_horiz_band=draw_slice; - } - else priv->ctx->draw_horiz_band=NULL; /* skip draw_slice on framedropping */ - if(!priv->hello_printed) { - if(priv->use_slices) - MSG_STATUS("Use slice-based rendering in FFMPEG\n"); - else if (priv->use_dr1) - MSG_STATUS("Use DR1 rendering in FFMPEG\n"); - else - priv->hello_printed=1; - } - AVPacket pkt; - av_init_packet(&pkt); - pkt.data=reinterpret_cast<uint8_t*>(data); - pkt.size=len; - ret = avcodec_decode_video2(priv->ctx, priv->lavc_picture, - &got_picture, &pkt); - if(ret<0) MSG_WARN("Error while decoding frame!\n"); - if(!got_picture) return NULL; // skipped image - if(!priv->ctx->draw_horiz_band) - { - if(mpi) free_mp_image(mpi); - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,sh->src_w,sh->src_h); - if(!mpi){ // temporary! - MSG_ERR("couldn't allocate image for ffmpeg codec\n"); - return NULL; - } - mpi->planes[0]=priv->lavc_picture->data[0]; - mpi->planes[1]=priv->lavc_picture->data[1]; - mpi->planes[2]=priv->lavc_picture->data[2]; - mpi->stride[0]=priv->lavc_picture->linesize[0]; - mpi->stride[1]=priv->lavc_picture->linesize[1]; - mpi->stride[2]=priv->lavc_picture->linesize[2]; - /* provide info for pp */ - mpi->qscale=(char *)priv->lavc_picture->qscale_table; - mpi->qstride=priv->lavc_picture->qstride; - mpi->pict_type=priv->lavc_picture->pict_type; - mpi->qscale_type=priv->lavc_picture->qscale_type; - /* - if(sh->codec->outfmt[sh->outfmtidx] == IMGFMT_I420 || - sh->codec->outfmt[sh->outfmtidx] == IMGFMT_IYUV) - { - uint8_t *tmp; - unsigned ls; - tmp=mpi->planes[2]; - mpi->planes[2]=mpi->planes[1]; - mpi->planes[1]=tmp; - ls=mpi->stride[2]; - mpi->stride[2]=mpi->stride[1]; - mpi->stride[1]=ls; - }*/ - if(priv->ctx->pix_fmt==PIX_FMT_YUV422P){ - mpi->stride[1]*=2; - mpi->stride[2]*=2; - } - } /* endif use_slices */ - return mpi; -} - Copied: mplayerxp/libmpcodecs/vd_lavc.cpp (from rev 437, mplayerxp/libmpcodecs/vd_ffmpeg.cpp) =================================================================== --- mplayerxp/libmpcodecs/vd_lavc.cpp (rev 0) +++ mplayerxp/libmpcodecs/vd_lavc.cpp 2012-11-23 11:55:38 UTC (rev 441) @@ -0,0 +1,780 @@ +#include <algorithm> + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> +#include <dlfcn.h> /* GLIBC specific. Exists under cygwin too! */ + +#include "mp_config.h" +#include "mplayerxp.h" +#include "xmpcore/xmp_core.h" +#ifdef HAVE_GOMP +#include <omp.h> +#endif + +#include "help_mp.h" + +#include "osdep/bswap.h" +#include "osdep/mplib.h" + +#include "vd_internal.h" +#include "codecs_ld.h" +#include "postproc/postprocess.h" +#include "postproc/vf.h" +#include "libvo/video_out.h" +#include "osdep/bswap.h" + +using namespace mpxp; + +static const vd_info_t info = { + "lavc codec family", + "lavc", + "A'rpi", + "build-in" +}; + +static int lavc_param_error_resilience=2; +static int lavc_param_error_concealment=3; +static int lavc_param_vstats=0; +static int lavc_param_idct_algo=0; +static int lavc_param_debug=0; +static int lavc_param_vismv=0; +static int lavc_param_skip_top=0; +static int lavc_param_skip_bottom=0; +static int lavc_param_lowres=0; +static char *lavc_param_lowres_str=NULL; +static char *lavc_param_skip_loop_filter_str = NULL; +static char *lavc_param_skip_idct_str = NULL; +static char *lavc_param_skip_frame_str = NULL; +static int lavc_param_threads=-1; +static char *lavc_avopt = NULL; + +static int enable_ffslices=1; +static const config_t ff_options[] = { + {"slices", &enable_ffslices, CONF_TYPE_FLAG, 0, 0, 1, "enables slice-based method of frame rendering in lavc decoder"}, + {"noslices", &enable_ffslices, CONF_TYPE_FLAG, 0, 1, 0, "disables slice-based method of frame rendering in lavc decoder"}, + {"er", &lavc_param_error_resilience, CONF_TYPE_INT, CONF_RANGE, 0, 99, "specifies error resilience for lavc decoders"}, + {"idct", &lavc_param_idct_algo, CONF_TYPE_INT, CONF_RANGE, 0, 99, "specifies idct algorithm for lavc decoders"}, + {"ec", &lavc_param_error_concealment, CONF_TYPE_INT, CONF_RANGE, 0, 99, "specifies error concealment for lavc decoders"}, + {"vstats", &lavc_param_vstats, CONF_TYPE_FLAG, 0, 0, 1, "specifies vstat for lavc decoders"}, + {"debug", &lavc_param_debug, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, "specifies debug level for lavc decoders"}, + {"vismv", &lavc_param_vismv, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, "specifies visualize motion vectors (MVs) for lavc decoders"}, + {"st", &lavc_param_skip_top, CONF_TYPE_INT, CONF_RANGE, 0, 999, "specifies skipping top lines for lavc decoders"}, + {"sb", &lavc_param_skip_bottom, CONF_TYPE_INT, CONF_RANGE, 0, 999, "specifies skipping bottom lines for lavc decoders"}, + {"lowres", &lavc_param_lowres_str, CONF_TYPE_STRING, 0, 0, 0, "specifies decoding at 1= 1/2, 2=1/4, 3=1/8 resolutions for lavc decoders"}, + {"skiploopfilter", &lavc_param_skip_loop_filter_str, CONF_TYPE_STRING, 0, 0, 0, "specifies skipping of loop filters for lavc decoders"}, + {"skipidct", &lavc_param_skip_idct_str, CONF_TYPE_STRING, 0, 0, 0, "specifies skipping of IDCT filters for lavc decoders"}, + {"skipframe", &lavc_param_skip_frame_str, CONF_TYPE_STRING, 0, 0, 0, "indicates frame skipping for lavc decoders"}, + {"threads", &lavc_param_threads, CONF_TYPE_INT, CONF_RANGE, 1, 8, "specifies number of threads for lavc decoders"}, + {"o", &lavc_avopt, CONF_TYPE_STRING, 0, 0, 0, "specifies additional option for lavc decoders"}, + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +static const config_t options[] = { + {"lavc", (any_t*)&ff_options, CONF_TYPE_SUBCONFIG, 0, 0, 0, "lavc specific options"}, + { NULL, NULL, 0, 0, 0, 0, NULL} +}; + +LIBVD_EXTERN(lavc) + +#include "libavcodec/avcodec.h" +#include "libavformat/riff.h" +#include "libvo/video_out.h" + + +static int vcodec_inited=0; +typedef struct priv_s { + int use_slices; + int cap_slices; + int use_dr1; + int cap_dr1; + AVCodec *lavc_codec; + AVCodecContext *ctx; + AVFrame *lavc_picture; + mp_image_t* mpi; + unsigned long long frame_number; /* total frame number since begin of movie */ + int b_age; + int ip_age[2]; + int qp_stat[32]; +// double qp_sum; +// double inv_qp_sum; + int ip_count; + int b_count; + int vo_inited; + int hello_printed; + video_probe_t* probe; +}priv_t; +static pp_context* ppContext=NULL; +static void draw_slice(struct AVCodecContext *s, const AVFrame *src, int offset[4], int y, int type, int height); + +static enum AVDiscard str2AVDiscard(char *str) { + if (!str) return AVDISCARD_DEFAULT; + if (strcasecmp(str, "none" ) == 0) return AVDISCARD_NONE; + if (strcasecmp(str, "default") == 0) return AVDISCARD_DEFAULT; + if (strcasecmp(str, "nonref" ) == 0) return AVDISCARD_NONREF; + if (strcasecmp(str, "bidir" ) == 0) return AVDISCARD_BIDIR; + if (strcasecmp(str, "nonkey" ) == 0) return AVDISCARD_NONKEY; + if (strcasecmp(str, "all" ) == 0) return AVDISCARD_ALL; + MSG_ERR("Unknown discard value %s\n", str); + return AVDISCARD_DEFAULT; +} + +/* stupid workaround for current version of lavc */ +const __attribute((used)) uint8_t last_coeff_flag_offset_8x8[63] = { + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2... [truncated message content] |