diff options
Diffstat (limited to 'libmpcodecs')
154 files changed, 1779 insertions, 1680 deletions
diff --git a/libmpcodecs/ad.c b/libmpcodecs/ad.c index 3b4fb87c1e..f81f11ef0f 100644 --- a/libmpcodecs/ad.c +++ b/libmpcodecs/ad.c @@ -32,34 +32,34 @@ /* Missed vorbis, mad, dshow */ //extern ad_functions_t mpcodecs_ad_null; -extern ad_functions_t mpcodecs_ad_mp3lib; -extern ad_functions_t mpcodecs_ad_ffmpeg; -extern ad_functions_t mpcodecs_ad_liba52; -extern ad_functions_t mpcodecs_ad_hwac3; -extern ad_functions_t mpcodecs_ad_hwmpa; -extern ad_functions_t mpcodecs_ad_pcm; -extern ad_functions_t mpcodecs_ad_dvdpcm; -extern ad_functions_t mpcodecs_ad_alaw; -extern ad_functions_t mpcodecs_ad_imaadpcm; -extern ad_functions_t mpcodecs_ad_msadpcm; -extern ad_functions_t mpcodecs_ad_dk3adpcm; -extern ad_functions_t mpcodecs_ad_dk4adpcm; -extern ad_functions_t mpcodecs_ad_dshow; -extern ad_functions_t mpcodecs_ad_dmo; -extern ad_functions_t mpcodecs_ad_acm; -extern ad_functions_t mpcodecs_ad_msgsm; -extern ad_functions_t mpcodecs_ad_faad; -extern ad_functions_t mpcodecs_ad_libvorbis; -extern ad_functions_t mpcodecs_ad_speex; -extern ad_functions_t mpcodecs_ad_libmad; -extern ad_functions_t mpcodecs_ad_realaud; -extern ad_functions_t mpcodecs_ad_libdv; -extern ad_functions_t mpcodecs_ad_qtaudio; -extern ad_functions_t mpcodecs_ad_twin; -extern ad_functions_t mpcodecs_ad_libmusepack; -extern ad_functions_t mpcodecs_ad_libdca; +extern const ad_functions_t mpcodecs_ad_mp3lib; +extern const ad_functions_t mpcodecs_ad_ffmpeg; +extern const ad_functions_t mpcodecs_ad_liba52; +extern const ad_functions_t mpcodecs_ad_hwac3; +extern const ad_functions_t mpcodecs_ad_hwmpa; +extern const ad_functions_t mpcodecs_ad_pcm; +extern const ad_functions_t mpcodecs_ad_dvdpcm; +extern const ad_functions_t mpcodecs_ad_alaw; +extern const ad_functions_t mpcodecs_ad_imaadpcm; +extern const ad_functions_t mpcodecs_ad_msadpcm; +extern const ad_functions_t mpcodecs_ad_dk3adpcm; +extern const ad_functions_t mpcodecs_ad_dk4adpcm; +extern const ad_functions_t mpcodecs_ad_dshow; +extern const ad_functions_t mpcodecs_ad_dmo; +extern const ad_functions_t mpcodecs_ad_acm; +extern const ad_functions_t mpcodecs_ad_msgsm; +extern const ad_functions_t mpcodecs_ad_faad; +extern const ad_functions_t mpcodecs_ad_libvorbis; +extern const ad_functions_t mpcodecs_ad_speex; +extern const ad_functions_t mpcodecs_ad_libmad; +extern const ad_functions_t mpcodecs_ad_realaud; +extern const ad_functions_t mpcodecs_ad_libdv; +extern const ad_functions_t mpcodecs_ad_qtaudio; +extern const ad_functions_t mpcodecs_ad_twin; +extern const ad_functions_t mpcodecs_ad_libmusepack; +extern const ad_functions_t mpcodecs_ad_libdca; -ad_functions_t* mpcodecs_ad_drivers[] = +const ad_functions_t * const mpcodecs_ad_drivers[] = { // &mpcodecs_ad_null, #ifdef CONFIG_MP3LIB diff --git a/libmpcodecs/ad.h b/libmpcodecs/ad.h index ddf02a569a..9b1daf9e48 100644 --- a/libmpcodecs/ad.h +++ b/libmpcodecs/ad.h @@ -25,9 +25,9 @@ typedef mp_codec_info_t ad_info_t; /* interface of video decoder drivers */ -typedef struct ad_functions_s +typedef struct ad_functions { - ad_info_t *info; + const ad_info_t *info; int (*preinit)(sh_audio_t *sh); int (*init)(sh_audio_t *sh); void (*uninit)(sh_audio_t *sh); @@ -36,7 +36,7 @@ typedef struct ad_functions_s } ad_functions_t; // NULL terminated array of all drivers -extern ad_functions_t* mpcodecs_ad_drivers[]; +extern const ad_functions_t * const mpcodecs_ad_drivers[]; // fallback if ADCTRL_RESYNC not implemented: sh_audio->a_in_buffer_len=0; #define ADCTRL_RESYNC_STREAM 1 /* resync, called after seeking! */ diff --git a/libmpcodecs/ad_acm.c b/libmpcodecs/ad_acm.c index 5fe4a13222..026f7c4550 100644 --- a/libmpcodecs/ad_acm.c +++ b/libmpcodecs/ad_acm.c @@ -29,7 +29,7 @@ #include "ad_internal.h" #include "osdep/timer.h" -static ad_info_t info = +static const ad_info_t info = { "Win32/ACM decoders", "acm", @@ -77,7 +77,7 @@ static int preinit(sh_audio_t *sh_audio) priv->o_wf = malloc(sizeof(WAVEFORMATEX)); if (!priv->o_wf) { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n"); return 0; } @@ -108,7 +108,7 @@ static int preinit(sh_audio_t *sh_audio) else mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: acmStreamOpen error: %d\n", (int)ret); - mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n"); return 0; } mp_msg(MSGT_WIN32, MSGL_V, "Audio codec opened OK! ;-)\n"); diff --git a/libmpcodecs/ad_alaw.c b/libmpcodecs/ad_alaw.c index 88ebc601ae..4a8f3849cf 100644 --- a/libmpcodecs/ad_alaw.c +++ b/libmpcodecs/ad_alaw.c @@ -23,7 +23,7 @@ #include "config.h" #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "aLaw/uLaw audio decoder", "alaw", diff --git a/libmpcodecs/ad_dk3adpcm.c b/libmpcodecs/ad_dk3adpcm.c index ddcfcce484..9ee168dc45 100644 --- a/libmpcodecs/ad_dk3adpcm.c +++ b/libmpcodecs/ad_dk3adpcm.c @@ -36,7 +36,7 @@ #include "mpbswap.h" #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "Duck Corp. DK3 ADPCM decoder", "dk3adpcm", diff --git a/libmpcodecs/ad_dmo.c b/libmpcodecs/ad_dmo.c index e3f6ae9a96..c9835cf635 100644 --- a/libmpcodecs/ad_dmo.c +++ b/libmpcodecs/ad_dmo.c @@ -27,7 +27,7 @@ #include "ad_internal.h" #include "libaf/reorder_ch.h" -static ad_info_t info = +static const ad_info_t info = { "Win32/DMO decoders", "dmo", @@ -52,7 +52,7 @@ static int preinit(sh_audio_t *sh_audio) audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1); if(!(ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf,chans))) { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll); return 0; } sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; diff --git a/libmpcodecs/ad_dshow.c b/libmpcodecs/ad_dshow.c index 8365c90240..85d79cd52b 100644 --- a/libmpcodecs/ad_dshow.c +++ b/libmpcodecs/ad_dshow.c @@ -26,7 +26,7 @@ #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "Win32/DirectShow decoders", "dshow", @@ -49,7 +49,7 @@ static int preinit(sh_audio_t *sh_audio) DS_AudioDecoder* ds_adec; if(!(ds_adec=DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf))) { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll); return 0; } sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; diff --git a/libmpcodecs/ad_dvdpcm.c b/libmpcodecs/ad_dvdpcm.c index 671346d7a6..50593a8e70 100644 --- a/libmpcodecs/ad_dvdpcm.c +++ b/libmpcodecs/ad_dvdpcm.c @@ -25,7 +25,7 @@ #include "help_mp.h" #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "Uncompressed DVD/VOB LPCM audio decoder", "dvdpcm", @@ -56,7 +56,7 @@ static int init(sh_audio_t *sh) sh->samplesize = 2; break; case 1: - mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SamplesWanted); + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Samples of this format are needed to improve support. Please contact the developers.\n"); sh->i_bps = sh->channels * sh->samplerate * 5 / 2; case 2: sh->sample_format = AF_FORMAT_S24_BE; diff --git a/libmpcodecs/ad_faad.c b/libmpcodecs/ad_faad.c index b5d65d4883..f3795058ff 100644 --- a/libmpcodecs/ad_faad.c +++ b/libmpcodecs/ad_faad.c @@ -28,7 +28,7 @@ #include "ad_internal.h" #include "libaf/reorder_ch.h" -static ad_info_t info = +static const ad_info_t info = { "AAC (MPEG2/4 Advanced Audio Coding)", "faad", @@ -174,7 +174,7 @@ static int init(sh_audio_t *sh) sh->samplesize=2; //sh->o_bps = sh->samplesize*faac_channels*faac_samplerate; if(!sh->i_bps) { - mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: compressed input bitrate missing, assuming 128kbit/s!\n"); + mp_msg(MSGT_DECAUDIO, MSGL_V, "FAAD: compressed input bitrate missing, assuming 128kbit/s!\n"); sh->i_bps = 128*1000/8; // XXX: HACK!!! ::atmos } else mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: got %dkbit/s bitrate from MP4 header!\n",sh->i_bps*8/1000); diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 147f635a29..9cf0567d6a 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -29,7 +29,7 @@ #include "mpbswap.h" -static ad_info_t info = +static const ad_info_t info = { "FFmpeg/libavcodec audio decoders", "ffmpeg", @@ -68,7 +68,7 @@ static int init(sh_audio_t *sh_audio) lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll); if(!lavc_codec){ - mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_audio->codec->dll); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Cannot find codec '%s' in libavcodec...\n",sh_audio->codec->dll); return 0; } @@ -108,7 +108,7 @@ static int init(sh_audio_t *sh_audio) /* open it */ if (avcodec_open(lavc_context, lavc_codec) < 0) { - mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec); + mp_tmsg(MSGT_DECAUDIO,MSGL_ERR, "Could not open codec.\n"); return 0; } mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec \"%s\" init OK!\n", lavc_codec->name); @@ -160,7 +160,7 @@ static void uninit(sh_audio_t *sh) AVCodecContext *lavc_context = sh->context; if (avcodec_close(lavc_context) < 0) - mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec); + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n"); av_freep(&lavc_context->extradata); av_freep(&lavc_context); } diff --git a/libmpcodecs/ad_hwac3.c b/libmpcodecs/ad_hwac3.c index ceeb61859a..45518f82c0 100644 --- a/libmpcodecs/ad_hwac3.c +++ b/libmpcodecs/ad_hwac3.c @@ -31,14 +31,14 @@ #include "help_mp.h" #include "mpbswap.h" #include "libavutil/common.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" #include "ad_internal.h" static int isdts = -1; -static ad_info_t info = +static const ad_info_t info = { "AC3/DTS pass-through S/PDIF", "hwac3", diff --git a/libmpcodecs/ad_hwmpa.c b/libmpcodecs/ad_hwmpa.c index 506adbef42..fe804e1e13 100644 --- a/libmpcodecs/ad_hwmpa.c +++ b/libmpcodecs/ad_hwmpa.c @@ -33,7 +33,7 @@ //based on ad_hwac3.c and ad_libmad.c -static ad_info_t info = +static const ad_info_t info = { "MPEG audio pass-through (fake decoder)", "hwmpa", diff --git a/libmpcodecs/ad_imaadpcm.c b/libmpcodecs/ad_imaadpcm.c index ef3e4b20c1..11a561315a 100644 --- a/libmpcodecs/ad_imaadpcm.c +++ b/libmpcodecs/ad_imaadpcm.c @@ -79,7 +79,7 @@ static const int8_t adpcm_index[8] = // clamp a number above 16 #define CLAMP_ABOVE_16(x) if (x < 16) x = 16; -static ad_info_t info = +static const ad_info_t info = { "IMA ADPCM audio decoder", "imaadpcm", diff --git a/libmpcodecs/ad_internal.h b/libmpcodecs/ad_internal.h index 928db50be6..2a5dbc43ea 100644 --- a/libmpcodecs/ad_internal.h +++ b/libmpcodecs/ad_internal.h @@ -35,7 +35,7 @@ static void uninit(sh_audio_t *sh); static int control(sh_audio_t *sh,int cmd,void* arg, ...); static int decode_audio(sh_audio_t *sh,unsigned char *buffer,int minlen,int maxlen); -#define LIBAD_EXTERN(x) ad_functions_t mpcodecs_ad_##x = {\ +#define LIBAD_EXTERN(x) const ad_functions_t mpcodecs_ad_##x = {\ &info,\ preinit,\ init,\ diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c index b9d5171c61..29734ffc73 100644 --- a/libmpcodecs/ad_liba52.c +++ b/libmpcodecs/ad_liba52.c @@ -63,7 +63,7 @@ static sample_t a52_level = 1; float a52_drc_level = 1.0; static int a52_drc_action = DRC_NO_ACTION; -static ad_info_t info = +static const ad_info_t info = { "AC3 decoding with liba52", "liba52", @@ -74,7 +74,7 @@ static ad_info_t info = LIBAD_EXTERN(liba52) -int a52_fillbuff(sh_audio_t *sh_audio){ +static int a52_fillbuff(sh_audio_t *sh_audio){ int length=0; int flags=0; int sample_rate=0; @@ -138,7 +138,7 @@ int channels=0; return (flags&A52_LFE) ? (channels+1) : channels; } -sample_t dynrng_call (sample_t c, void *data) { +static sample_t dynrng_call (sample_t c, void *data) { // fprintf(stderr, "(%lf, %lf): %lf\n", (double)c, (double)a52_drc_level, (double)pow((double)c, a52_drc_level)); return pow((double)c, a52_drc_level); } diff --git a/libmpcodecs/ad_libdca.c b/libmpcodecs/ad_libdca.c index 1514a9953a..c167c92490 100644 --- a/libmpcodecs/ad_libdca.c +++ b/libmpcodecs/ad_libdca.c @@ -32,7 +32,7 @@ #include <dts.h> -static ad_info_t info = +static const ad_info_t info = { "DTS decoding with libdca", "libdca", diff --git a/libmpcodecs/ad_libdv.c b/libmpcodecs/ad_libdv.c index b3cc1163c7..384627462d 100644 --- a/libmpcodecs/ad_libdv.c +++ b/libmpcodecs/ad_libdv.c @@ -38,7 +38,7 @@ #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "Raw DV Audio Decoder", "libdv", @@ -104,7 +104,7 @@ static int decode_audio(sh_audio_t *audio, unsigned char *buf, int minlen, int m dv_parse_header(decoder, dv_audio_frame); if(xx!=decoder->frame_size) - mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_MPCODECS_AudioFramesizeDiffers, + mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[AD_LIBDV] Warning! Audio framesize differs! read=%d hdr=%d.\n", xx, decoder->frame_size); if (dv_decode_full_audio(decoder, dv_audio_frame,(int16_t**) audioBuffers)) diff --git a/libmpcodecs/ad_libmad.c b/libmpcodecs/ad_libmad.c index 1f62fd49b1..ce10249595 100644 --- a/libmpcodecs/ad_libmad.c +++ b/libmpcodecs/ad_libmad.c @@ -24,7 +24,7 @@ #include "ad_internal.h" -static ad_info_t info = { +static const ad_info_t info = { "libmad mpeg audio decoder", "libmad", "A'rpi", diff --git a/libmpcodecs/ad_libvorbis.c b/libmpcodecs/ad_libvorbis.c index c6948a3356..a768095187 100644 --- a/libmpcodecs/ad_libvorbis.c +++ b/libmpcodecs/ad_libvorbis.c @@ -26,7 +26,7 @@ #include "ad_internal.h" #include "libaf/reorder_ch.h" -static ad_info_t info = +static const ad_info_t info = { "Ogg/Vorbis audio decoder", #ifdef CONFIG_TREMOR diff --git a/libmpcodecs/ad_mp3lib.c b/libmpcodecs/ad_mp3lib.c index b213e17fde..5b50557c96 100644 --- a/libmpcodecs/ad_mp3lib.c +++ b/libmpcodecs/ad_mp3lib.c @@ -24,7 +24,7 @@ #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "MPEG layer-2, layer-3", "mp3lib", diff --git a/libmpcodecs/ad_mpc.c b/libmpcodecs/ad_mpc.c index a5d53e04de..33ed911f72 100644 --- a/libmpcodecs/ad_mpc.c +++ b/libmpcodecs/ad_mpc.c @@ -32,7 +32,7 @@ #include "libaf/af_format.h" #include "libvo/fastmemcpy.h" -static ad_info_t info = +static const ad_info_t info = { "Musepack audio decoder", "mpcdec", @@ -231,4 +231,3 @@ static int control(sh_audio_t *sh, int cmd, void* arg, ...) { } return CONTROL_UNKNOWN; } - diff --git a/libmpcodecs/ad_msadpcm.c b/libmpcodecs/ad_msadpcm.c index 0ff705ba71..162c7c04d3 100644 --- a/libmpcodecs/ad_msadpcm.c +++ b/libmpcodecs/ad_msadpcm.c @@ -30,11 +30,11 @@ #include "config.h" #include "libavutil/common.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "MS ADPCM audio decoder", "msadpcm", diff --git a/libmpcodecs/ad_msgsm.c b/libmpcodecs/ad_msgsm.c index 8c7151d1dc..d4b4a020fe 100644 --- a/libmpcodecs/ad_msgsm.c +++ b/libmpcodecs/ad_msgsm.c @@ -23,7 +23,7 @@ #include "config.h" #include "ad_internal.h" -static ad_info_t info = +static const ad_info_t info = { "native GSM/MSGSM audio decoder", "msgsm", diff --git a/libmpcodecs/ad_pcm.c b/libmpcodecs/ad_pcm.c index 8788a2e1cd..a5a17e1a49 100644 --- a/libmpcodecs/ad_pcm.c +++ b/libmpcodecs/ad_pcm.c @@ -20,12 +20,13 @@ #include <stdlib.h> #include <unistd.h> +#include "talloc.h" #include "config.h" #include "ad_internal.h" #include "libaf/af_format.h" #include "libaf/reorder_ch.h" -static ad_info_t info = +static const ad_info_t info = { "Uncompressed PCM audio decoder", "pcm", @@ -34,6 +35,11 @@ static ad_info_t info = "" }; +struct ad_pcm_context { + unsigned char *packet_ptr; + int packet_len; +}; + LIBAD_EXTERN(pcm) static int init(sh_audio_t *sh_audio) @@ -111,6 +117,7 @@ static int init(sh_audio_t *sh_audio) } if (!sh_audio->samplesize) // this would cause MPlayer to hang later sh_audio->samplesize = 2; + sh_audio->context = talloc_zero(NULL, struct ad_pcm_context); return 1; } @@ -122,6 +129,7 @@ static int preinit(sh_audio_t *sh) static void uninit(sh_audio_t *sh) { + talloc_free(sh->context); } static int control(sh_audio_t *sh,int cmd,void* arg, ...) @@ -141,12 +149,37 @@ static int control(sh_audio_t *sh,int cmd,void* arg, ...) static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) { unsigned len = sh_audio->channels*sh_audio->samplesize; - len = (minlen + len - 1) / len * len; - if (len > maxlen) + minlen = (minlen + len - 1) / len * len; + if (minlen > maxlen) // if someone needs hundreds of channels adjust audio_out_minsize // based on channels in preinit() return -1; - len=demux_read_data(sh_audio->ds,buf,len); + + len = 0; + struct ad_pcm_context *ctx = sh_audio->context; + while (len < minlen) { + if (ctx->packet_len == 0) { + double pts; + int plen = ds_get_packet_pts(sh_audio->ds, &ctx->packet_ptr, &pts); + if (plen < 0) + break; + ctx->packet_len = plen; + if (pts != MP_NOPTS_VALUE) { + sh_audio->pts = pts; + sh_audio->pts_bytes = 0; + } + } + int from_stored = ctx->packet_len; + if (from_stored > minlen - len) + from_stored = minlen - len; + memcpy(buf + len, ctx->packet_ptr, from_stored); + ctx->packet_len -= from_stored; + ctx->packet_ptr += from_stored; + sh_audio->pts_bytes += from_stored; + len += from_stored; + } + if (len == 0) + len = -1; // The loop above only exits at error/EOF if (len > 0 && sh_audio->channels >= 5) { reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, diff --git a/libmpcodecs/ad_qtaudio.c b/libmpcodecs/ad_qtaudio.c index 66481c80b5..4e785ca5bf 100644 --- a/libmpcodecs/ad_qtaudio.c +++ b/libmpcodecs/ad_qtaudio.c @@ -33,7 +33,7 @@ #include "loader/wine/windef.h" #endif -static ad_info_t info = { +static const ad_info_t info = { "QuickTime Audio Decoder", "qtaudio", "A'rpi", diff --git a/libmpcodecs/ad_realaud.c b/libmpcodecs/ad_realaud.c index 16ca8134ab..74cd5b7bb4 100644 --- a/libmpcodecs/ad_realaud.c +++ b/libmpcodecs/ad_realaud.c @@ -31,7 +31,7 @@ #include "ad_internal.h" #include "loader/wine/windef.h" -static ad_info_t info = { +static const ad_info_t info = { "RealAudio decoder", "realaud", "Alex Beregszaszi", @@ -235,7 +235,7 @@ static int preinit(sh_audio_t *sh){ if (!load_syms_windows(sh->codec->dll)) #endif { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_MissingDLLcodec, sh->codec->dll); + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "ERROR: Could not open required DirectShow codec %s.\n", sh->codec->dll); mp_msg(MSGT_DECVIDEO, MSGL_HINT, "Read the RealAudio section of the DOCS!\n"); free(path); return 0; diff --git a/libmpcodecs/ad_sample.c b/libmpcodecs/ad_sample.c index 582007979a..69f4b20dfc 100644 --- a/libmpcodecs/ad_sample.c +++ b/libmpcodecs/ad_sample.c @@ -25,7 +25,7 @@ #include "config.h" #include "ad_internal.h" -static ad_info_t info = { +static const ad_info_t info = { "Sample audio decoder", // name of the driver "sample", // driver name. should be the same as filename without ad_ "A'rpi", // writer/maintainer of _this_ file diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c index 33526c2955..73655e5ac1 100644 --- a/libmpcodecs/ad_speex.c +++ b/libmpcodecs/ad_speex.c @@ -28,7 +28,7 @@ #include <speex/speex_header.h> #include "ad_internal.h" -static ad_info_t info = { +static const ad_info_t info ={ "Speex audio decoder", "speex", "Reimar Döffinger", @@ -135,4 +135,3 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf, static int control(sh_audio_t *sh, int cmd, void *arg, ...) { return CONTROL_UNKNOWN; } - diff --git a/libmpcodecs/ad_twin.c b/libmpcodecs/ad_twin.c index 34f8cdaa6d..f387821a5b 100644 --- a/libmpcodecs/ad_twin.c +++ b/libmpcodecs/ad_twin.c @@ -29,7 +29,7 @@ #include "help_mp.h" -static ad_info_t info = +static const ad_info_t info = { "TWinVQ decoder", "vqf", diff --git a/libmpcodecs/ae.c b/libmpcodecs/ae.c index 4c4e65e5fe..acf16319a9 100644 --- a/libmpcodecs/ae.c +++ b/libmpcodecs/ae.c @@ -114,5 +114,3 @@ audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params encoder->codec = stream->codec; return encoder; } - - diff --git a/libmpcodecs/ae_lame.c b/libmpcodecs/ae_lame.c index db7fe3b32e..c7ca89b4fe 100644 --- a/libmpcodecs/ae_lame.c +++ b/libmpcodecs/ae_lame.c @@ -57,6 +57,55 @@ static char* lame_param_preset=NULL; // unset static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_name ); #endif +#define MEncoderMP3LameHelp _("\n\n"\ +" vbr=<0-4> variable bitrate method\n"\ +" 0: cbr (constant bitrate)\n"\ +" 1: mt (Mark Taylor VBR algorithm)\n"\ +" 2: rh (Robert Hegemann VBR algorithm - default)\n"\ +" 3: abr (average bitrate)\n"\ +" 4: mtrh (Mark Taylor Robert Hegemann VBR algorithm)\n"\ +"\n"\ +" abr average bitrate\n"\ +"\n"\ +" cbr constant bitrate\n"\ +" Also forces CBR mode encoding on subsequent ABR presets modes.\n"\ +"\n"\ +" br=<0-1024> specify bitrate in kBit (CBR and ABR only)\n"\ +"\n"\ +" q=<0-9> quality (0-highest, 9-lowest) (only for VBR)\n"\ +"\n"\ +" aq=<0-9> algorithmic quality (0-best/slowest, 9-worst/fastest)\n"\ +"\n"\ +" ratio=<1-100> compression ratio\n"\ +"\n"\ +" vol=<0-10> set audio input gain\n"\ +"\n"\ +" mode=<0-3> (default: auto)\n"\ +" 0: stereo\n"\ +" 1: joint-stereo\n"\ +" 2: dualchannel\n"\ +" 3: mono\n"\ +"\n"\ +" padding=<0-2>\n"\ +" 0: no\n"\ +" 1: all\n"\ +" 2: adjust\n"\ +"\n"\ +" fast Switch on faster encoding on subsequent VBR presets modes,\n"\ +" slightly lower quality and higher bitrates.\n"\ +"\n"\ +" preset=<value> Provide the highest possible quality settings.\n"\ +" medium: VBR encoding, good quality\n"\ +" (150-180 kbps bitrate range)\n"\ +" standard: VBR encoding, high quality\n"\ +" (170-210 kbps bitrate range)\n"\ +" extreme: VBR encoding, very high quality\n"\ +" (200-240 kbps bitrate range)\n"\ +" insane: CBR encoding, highest preset quality\n"\ +" (320 kbps bitrate)\n"\ +" <8-320>: ABR encoding at average given kbps bitrate.\n\n") + + m_option_t lameopts_conf[]={ {"q", &lame_param_quality, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL}, @@ -82,18 +131,18 @@ m_option_t lameopts_conf[]={ {"fast", "MPlayer was built without -lameopts fast support (requires libmp3lame >=3.92).\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, {"preset", "MPlayer was built without -lameopts preset support (requires libmp3lame >=3.92).\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, #endif - {"help", MSGTR_MEncoderMP3LameHelp, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, + {"help", MEncoderMP3LameHelp, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, {NULL, NULL, 0, 0, 0, 0, NULL} }; static int bind_lame(audio_encoder_t *encoder, muxer_stream_t *mux_a) { - mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MP3AudioSelected); + mp_tmsg(MSGT_MENCODER, MSGL_INFO, "MP3 audio selected.\n"); mux_a->h.dwSampleSize=0; // VBR mux_a->h.dwRate=encoder->params.sample_rate; mux_a->h.dwScale=encoder->params.samples_per_frame; // samples/frame - if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_msg(MSGT_MENCODER,MSGL_WARN,MSGTR_MP3WaveFormatSizeNot30,sizeof(MPEGLAYER3WAVEFORMAT)); + if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_tmsg(MSGT_MENCODER,MSGL_WARN,"sizeof(MPEGLAYER3WAVEFORMAT)==%d!=30, maybe broken C compiler?\n",sizeof(MPEGLAYER3WAVEFORMAT)); mux_a->wf=malloc(sizeof(MPEGLAYER3WAVEFORMAT)); // should be 30 mux_a->wf->wFormatTag=0x55; // MP3 mux_a->wf->nChannels= (lame_param_mode<0) ? encoder->params.channels : ((lame_param_mode==3) ? 1 : 2); @@ -161,7 +210,7 @@ static void fixup(audio_encoder_t *encoder) encoder->stream->h.dwRate=encoder->stream->wf->nAvgBytesPerSec; encoder->stream->h.dwScale=1; encoder->stream->wf->nBlockAlign=1; - mp_msg(MSGT_MENCODER, MSGL_V, MSGTR_CBRAudioByterate, + mp_tmsg(MSGT_MENCODER, MSGL_V, "\n\nCBR audio: %d bytes/sec, %d bytes/block\n", encoder->stream->h.dwRate,((MPEGLAYER3WAVEFORMAT*)(encoder->stream->wf))->nBlockSize); } } @@ -192,20 +241,23 @@ int mpae_init_lame(audio_encoder_t *encoder) if(lame_param_mode>=0) lame_set_mode(lame,lame_param_mode); // j-st if(lame_param_ratio>0) lame_set_compression_ratio(lame,lame_param_ratio); if(lame_param_scale>0) { - mp_msg(MSGT_MENCODER, MSGL_V, MSGTR_SettingAudioInputGain, lame_param_scale); + mp_tmsg(MSGT_MENCODER, MSGL_V, "Setting audio input gain to %f.\n", lame_param_scale); lame_set_scale(lame,lame_param_scale); } if(lame_param_lowpassfreq>=-1) lame_set_lowpassfreq(lame,lame_param_lowpassfreq); if(lame_param_highpassfreq>=-1) lame_set_highpassfreq(lame,lame_param_highpassfreq); #ifdef CONFIG_MP3LAME_PRESET if(lame_param_preset != NULL) { - mp_msg(MSGT_MENCODER, MSGL_V, MSGTR_LamePresetEquals,lame_param_preset); + mp_tmsg(MSGT_MENCODER, MSGL_V, "\npreset=%s\n\n",lame_param_preset); if(lame_presets_set(lame,lame_param_fast, (lame_param_vbr==0), lame_param_preset) < 0) return 0; } #endif if(lame_init_params(lame) == -1) { - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameCantInit); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, + "Cannot set LAME options, check bitrate/samplerate, some very low bitrates\n"\ + "(<32) need lower samplerates (i.e. -srate 8000).\n"\ + "If everything else fails, try a preset."); return 0; } if( mp_msg_test(MSGT_MENCODER,MSGL_V) ) { @@ -229,8 +281,87 @@ static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_ int mono = 0; if (strcmp(preset_name, "help") == 0) { - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameVersion, get_lame_version(), get_lame_url()); - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LamePresetsLongInfo); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url()); + +#define LamePresetsLongInfo _("\n"\ +"The preset switches are designed to provide the highest possible quality.\n"\ +"\n"\ +"They have for the most part been subjected to and tuned via rigorous double\n"\ +"blind listening tests to verify and achieve this objective.\n"\ +"\n"\ +"These are continually updated to coincide with the latest developments that\n"\ +"occur and as a result should provide you with nearly the best quality\n"\ +"currently possible from LAME.\n"\ +"\n"\ +"To activate these presets:\n"\ +"\n"\ +" For VBR modes (generally highest quality):\n"\ +"\n"\ +" \"preset=standard\" This preset should generally be transparent\n"\ +" to most people on most music and is already\n"\ +" quite high in quality.\n"\ +"\n"\ +" \"preset=extreme\" If you have extremely good hearing and similar\n"\ +" equipment, this preset will generally provide\n"\ +" slightly higher quality than the \"standard\"\n"\ +" mode.\n"\ +"\n"\ +" For CBR 320kbps (highest quality possible from the preset switches):\n"\ +"\n"\ +" \"preset=insane\" This preset will usually be overkill for most\n"\ +" people and most situations, but if you must\n"\ +" have the absolute highest quality with no\n"\ +" regard to filesize, this is the way to go.\n"\ +"\n"\ +" For ABR modes (high quality per given bitrate but not as high as VBR):\n"\ +"\n"\ +" \"preset=<kbps>\" Using this preset will usually give you good\n"\ +" quality at a specified bitrate. Depending on the\n"\ +" bitrate entered, this preset will determine the\n"\ +" optimal settings for that particular situation.\n"\ +" While this approach works, it is not nearly as\n"\ +" flexible as VBR, and usually will not attain the\n"\ +" same level of quality as VBR at higher bitrates.\n"\ +"\n"\ +"The following options are also available for the corresponding profiles:\n"\ +"\n"\ +" <fast> standard\n"\ +" <fast> extreme\n"\ +" insane\n"\ +" <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"\ +" simply specify a bitrate. For example:\n"\ +" \"preset=185\" activates this\n"\ +" preset and uses 185 as an average kbps.\n"\ +"\n"\ +" \"fast\" - Enables the new fast VBR for a particular profile. The\n"\ +" disadvantage to the speed switch is that often times the\n"\ +" bitrate will be slightly higher than with the normal mode\n"\ +" and quality may be slightly lower also.\n"\ +" Warning: with the current version fast presets might result in too\n"\ +" high bitrate compared to regular presets.\n"\ +"\n"\ +" \"cbr\" - If you use the ABR mode (read above) with a significant\n"\ +" bitrate such as 80, 96, 112, 128, 160, 192, 224, 256, 320,\n"\ +" you can use the \"cbr\" option to force CBR mode encoding\n"\ +" instead of the standard abr mode. ABR does provide higher\n"\ +" quality but CBR may be useful in situations such as when\n"\ +" streaming an MP3 over the internet may be important.\n"\ +"\n"\ +" For example:\n"\ +"\n"\ +" \"-lameopts fast:preset=standard \"\n"\ +" or \"-lameopts cbr:preset=192 \"\n"\ +" or \"-lameopts preset=172 \"\n"\ +" or \"-lameopts preset=extreme \"\n"\ +"\n"\ +"\n"\ +"A few aliases are available for ABR mode:\n"\ +"phone => 16kbps/mono phon+/lw/mw-eu/sw => 24kbps/mono\n"\ +"mw-us => 40kbps/mono voice => 56kbps/mono\n"\ +"fm/radio/tape => 112kbps hifi => 160kbps\n"\ +"cd => 192kbps studio => 256kbps") + + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, LamePresetsLongInfo); return -1; } @@ -325,14 +456,39 @@ static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_ } else { - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameVersion, get_lame_version(), get_lame_url()); - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_InvalidBitrateForLamePreset); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url()); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, + "Error: The bitrate specified is out of the valid range for this preset.\n"\ + "\n"\ + "When using this mode you must enter a value between \"8\" and \"320\".\n"\ + "\n"\ + "For further information try: \"-lameopts preset=help\"\n"); return -1; } } - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LameVersion, get_lame_version(), get_lame_url()); - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_InvalidLamePresetOptions); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url()); +#define InvalidLamePresetOptions _("Error: You did not enter a valid profile and/or options with preset.\n"\ +"\n"\ +"Available profiles are:\n"\ +"\n"\ +" <fast> standard\n"\ +" <fast> extreme\n"\ +" insane\n"\ +" <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"\ +" simply specify a bitrate. For example:\n"\ +" \"preset=185\" activates this\n"\ +" preset and uses 185 as an average kbps.\n"\ +"\n"\ +" Some examples:\n"\ +"\n"\ +" \"-lameopts fast:preset=standard \"\n"\ +" or \"-lameopts cbr:preset=192 \"\n"\ +" or \"-lameopts preset=172 \"\n"\ +" or \"-lameopts preset=extreme \"\n"\ +"\n"\ +"For further information try: \"-lameopts preset=help\"\n") + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, InvalidLamePresetOptions); return -1; } #endif diff --git a/libmpcodecs/ae_lavc.c b/libmpcodecs/ae_lavc.c index 9c87205e11..2122535ee2 100644 --- a/libmpcodecs/ae_lavc.c +++ b/libmpcodecs/ae_lavc.c @@ -34,7 +34,7 @@ #include "libaf/af_format.h" #include "libaf/reorder_ch.h" #include "libavcodec/avcodec.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" static AVCodec *lavc_acodec; static AVCodecContext *lavc_actx; @@ -44,10 +44,7 @@ extern int lavc_param_atag; extern int lavc_param_audio_global_header; extern int avcodec_initialized; static int compressed_frame_size = 0; -#ifdef CONFIG_LIBAVFORMAT -#include "libavformat/avformat.h" -extern const struct AVCodecTag *mp_wav_taglists[]; -#endif +#include "libmpdemux/mp_taglists.h" static int bind_lavc(audio_encoder_t *encoder, muxer_stream_t *mux_a) { @@ -151,32 +148,6 @@ static int get_frame_size(audio_encoder_t *encoder) return sz; } -#ifndef CONFIG_LIBAVFORMAT -static uint32_t lavc_find_atag(char *codec) -{ - if(codec == NULL) - return 0; - - if(! strcasecmp(codec, "mp2")) - return 0x50; - - if(! strcasecmp(codec, "mp3")) - return 0x55; - - if(! strcasecmp(codec, "ac3")) - return 0x2000; - - if(! strcasecmp(codec, "adpcm_ima_wav")) - return 0x11; - - if(! strncasecmp(codec, "bonk", 4)) - return 0x2048; - - return 0; -} -#endif - - int mpae_init_lavc(audio_encoder_t *encoder) { encoder->params.samples_per_frame = encoder->params.sample_rate; @@ -184,7 +155,7 @@ int mpae_init_lavc(audio_encoder_t *encoder) if(!lavc_param_acodec) { - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_NoLavcAudioCodecName); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, Missing codec name!\n"); return 0; } @@ -197,16 +168,12 @@ int mpae_init_lavc(audio_encoder_t *encoder) lavc_acodec = avcodec_find_encoder_by_name(lavc_param_acodec); if (!lavc_acodec) { - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LavcAudioCodecNotFound, lavc_param_acodec); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, couldn't find encoder for codec %s.\n", lavc_param_acodec); return 0; } if(lavc_param_atag == 0) { -#ifdef CONFIG_LIBAVFORMAT - lavc_param_atag = av_codec_get_tag(mp_wav_taglists, lavc_acodec->id); -#else - lavc_param_atag = lavc_find_atag(lavc_param_acodec); -#endif + lavc_param_atag = mp_av_codec_get_tag(mp_wav_taglists, lavc_acodec->id); if(!lavc_param_atag) { mp_msg(MSGT_MENCODER, MSGL_FATAL, "Couldn't find wav tag for specified codec, exit\n"); @@ -217,7 +184,7 @@ int mpae_init_lavc(audio_encoder_t *encoder) lavc_actx = avcodec_alloc_context(); if(lavc_actx == NULL) { - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CouldntAllocateLavcContext); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, couldn't allocate context!\n"); return 0; } @@ -258,7 +225,7 @@ int mpae_init_lavc(audio_encoder_t *encoder) if(avcodec_open(lavc_actx, lavc_acodec) < 0) { - mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CouldntOpenCodec, lavc_param_acodec, lavc_param_abitrate); + mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Couldn't open codec %s, br=%d.\n", lavc_param_acodec, lavc_param_abitrate); return 0; } @@ -276,4 +243,3 @@ int mpae_init_lavc(audio_encoder_t *encoder) return 1; } - diff --git a/libmpcodecs/ae_pcm.c b/libmpcodecs/ae_pcm.c index 12c4c0a85c..cbae42dc87 100644 --- a/libmpcodecs/ae_pcm.c +++ b/libmpcodecs/ae_pcm.c @@ -99,4 +99,3 @@ int mpae_init_pcm(audio_encoder_t *encoder) return 1; } - diff --git a/libmpcodecs/ae_toolame.c b/libmpcodecs/ae_toolame.c index a498eb629d..7e64b2a41f 100644 --- a/libmpcodecs/ae_toolame.c +++ b/libmpcodecs/ae_toolame.c @@ -234,4 +234,3 @@ int mpae_init_toolame(audio_encoder_t *encoder) return 1; } - diff --git a/libmpcodecs/ae_twolame.c b/libmpcodecs/ae_twolame.c index 6b63529496..7aa0398586 100644 --- a/libmpcodecs/ae_twolame.c +++ b/libmpcodecs/ae_twolame.c @@ -233,4 +233,3 @@ int mpae_init_twolame(audio_encoder_t *encoder) return 1; } - diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c index 4311380fbb..1c028dd6e7 100644 --- a/libmpcodecs/dec_audio.c +++ b/libmpcodecs/dec_audio.c @@ -52,7 +52,7 @@ af_cfg_t af_cfg = { 1, NULL }; // Configuration for audio filters void afm_help(void) { int i; - mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_AvailableAudioFm); + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Available (compiled-in) audio codec families/drivers:\n"); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_DRIVERS\n"); mp_msg(MSGT_DECAUDIO, MSGL_INFO, " afm: info: (comment)\n"); for (i = 0; mpcodecs_ad_drivers[i] != NULL; i++) @@ -79,33 +79,35 @@ static int init_audio_codec(sh_audio_t *sh_audio) } } if (!sh_audio->ad_driver->preinit(sh_audio)) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_ADecoderPreinitFailed); + mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "ADecoder preinit failed :(\n"); return 0; } /* allocate audio in buffer: */ if (sh_audio->audio_in_minsize > 0) { sh_audio->a_in_buffer_size = sh_audio->audio_in_minsize; - mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_AllocatingBytesForInputBuffer, + mp_tmsg(MSGT_DECAUDIO, MSGL_V, "dec_audio: Allocating %d bytes for input buffer.\n", sh_audio->a_in_buffer_size); sh_audio->a_in_buffer = av_mallocz(sh_audio->a_in_buffer_size); sh_audio->a_in_buffer_len = 0; } - sh_audio->a_buffer_size = sh_audio->audio_out_minsize + MAX_OUTBURST; + const int base_size = 65536; + // At least 64 KiB plus rounding up to next decodable unit size + sh_audio->a_buffer_size = base_size + sh_audio->audio_out_minsize; - mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_AllocatingBytesForOutputBuffer, - sh_audio->audio_out_minsize, MAX_OUTBURST, sh_audio->a_buffer_size); + mp_tmsg(MSGT_DECAUDIO, MSGL_V, "dec_audio: Allocating %d + %d = %d bytes for output buffer.\n", + sh_audio->audio_out_minsize, base_size, sh_audio->a_buffer_size); sh_audio->a_buffer = av_mallocz(sh_audio->a_buffer_size); if (!sh_audio->a_buffer) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_CantAllocAudioBuf); + mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Cannot allocate audio out buffer.\n"); return 0; } sh_audio->a_buffer_len = 0; if (!sh_audio->ad_driver->init(sh_audio)) { - mp_msg(MSGT_DECAUDIO, MSGL_WARN, MSGTR_ADecoderInitFailed); + mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "ADecoder init failed :(\n"); uninit_audio(sh_audio); // free buffers return 0; } @@ -113,7 +115,7 @@ static int init_audio_codec(sh_audio_t *sh_audio) sh_audio->initialized = 1; if (!sh_audio->channels || !sh_audio->samplerate) { - mp_msg(MSGT_DECAUDIO, MSGL_WARN, MSGTR_UnknownAudio); + mp_tmsg(MSGT_DECAUDIO, MSGL_WARN, "Unknown/missing audio format -> no sound\n"); uninit_audio(sh_audio); // free buffers return 0; } @@ -216,18 +218,18 @@ static int init_audio(sh_audio_t *sh_audio, char *codecname, char *afm, } #endif if (!mpadec) { // driver not available (==compiled in) - mp_msg(MSGT_DECAUDIO, MSGL_ERR, - MSGTR_AudioCodecFamilyNotAvailableStr, + mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, + "Requested audio codec family [%s] (afm=%s) not available.\nEnable it at compilation.\n", sh_audio->codec->name, sh_audio->codec->drv); continue; } // it's available, let's try to init! // init() - mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_OpeningAudioDecoder, + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Opening audio decoder: [%s] %s\n", mpadec->info->short_name, mpadec->info->name); sh_audio->ad_driver = mpadec; if (!init_audio_codec(sh_audio)) { - mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_ADecoderInitFailed); + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "ADecoder init failed :(\n"); continue; // try next... } // Yeah! We got it! @@ -255,7 +257,7 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list, stringset_add(&selected, audio_codec + 1); } else { // forced codec by name: - mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_ForcedAudioCodec, + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Forced audio codec: %s\n", audio_codec); init_audio(sh_audio, audio_codec, NULL, -1, &selected); } @@ -268,7 +270,7 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list, // try first the preferred codec families: while (!sh_audio->initialized && *fmlist) { char *audio_fm = *(fmlist++); - mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_TryForceAudioFmtStr, + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Trying to force audio codec driver family %s...\n", audio_fm); for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN; --status) @@ -286,12 +288,12 @@ int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list, stringset_free(&selected); if (!sh_audio->initialized) { - mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_CantFindAudioCodec, + mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Cannot find codec for audio format 0x%X.\n", sh_audio->format); return 0; // failed } - mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SelectedAudioCodec, + mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: [%s] afm: %s (%s)\n", sh_audio->codec->name, sh_audio->codec->drv, sh_audio->codec->info); return 1; // success } @@ -305,7 +307,7 @@ void uninit_audio(sh_audio_t *sh_audio) sh_audio->afilter = NULL; } if (sh_audio->initialized) { - mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_UninitAudioStr, + mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Uninit audio: %s\n", sh_audio->codec->drv); sh_audio->ad_driver->uninit(sh_audio); #ifdef CONFIG_DYNAMIC_PLUGINS @@ -345,7 +347,7 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, // filter config: memcpy(&afs->cfg, &af_cfg, sizeof(af_cfg_t)); - mp_msg(MSGT_DECAUDIO, MSGL_V, MSGTR_BuildingAudioFilterChain, + mp_tmsg(MSGT_DECAUDIO, MSGL_V, "Building audio filter chain for %dHz/%dch/%s -> %dHz/%dch/%s...\n", afs->input.rate, afs->input.nch, af_fmt2str_short(afs->input.format), afs->output.rate, afs->output.nch, af_fmt2str_short(afs->output.format)); @@ -370,18 +372,10 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, static int filter_n_bytes(sh_audio_t *sh, int len) { - int error = 0; - // Filter - af_data_t filter_input = { - .audio = sh->a_buffer, - .rate = sh->samplerate, - .nch = sh->channels, - .format = sh->sample_format - }; - af_data_t *filter_output; - assert(len-1 + sh->audio_out_minsize <= sh->a_buffer_size); + int error = 0; + // Decode more bytes if needed while (sh->a_buffer_len < len) { unsigned char *buf = sh->a_buffer + sh->a_buffer_len; @@ -396,9 +390,16 @@ static int filter_n_bytes(sh_audio_t *sh, int len) sh->a_buffer_len += ret; } - filter_input.len = len; + // Filter + af_data_t filter_input = { + .audio = sh->a_buffer, + .len = len, + .rate = sh->samplerate, + .nch = sh->channels, + .format = sh->sample_format + }; af_fix_parameters(&filter_input); - filter_output = af_play(sh->afilter, &filter_input); + af_data_t *filter_output = af_play(sh->afilter, &filter_input); if (!filter_output) return -1; if (sh->a_out_buffer_size < sh->a_out_buffer_len + filter_output->len) { @@ -473,8 +474,6 @@ int decode_audio(sh_audio_t *sh_audio, int minlen) void resync_audio_stream(sh_audio_t *sh_audio) { - sh_audio->a_buffer_len = 0; - sh_audio->a_out_buffer_len = 0; sh_audio->a_in_buffer_len = 0; // clear audio input buffer if (!sh_audio->initialized) return; diff --git a/libmpcodecs/dec_teletext.c b/libmpcodecs/dec_teletext.c index 5be9812086..ac12b9aa4a 100644 --- a/libmpcodecs/dec_teletext.c +++ b/libmpcodecs/dec_teletext.c @@ -821,7 +821,7 @@ static void prepare_visible_page(priv_vbi_t* priv){ curr_pg=get_from_cache(priv,priv->curr_pagenum, get_subpagenum_from_cache(priv,priv->curr_pagenum)); if (!pg && !curr_pg){ - p=MSGTR_TV_NoTeletext; + p=_("No teletext"); for(i=0;i<VBI_COLUMNS && *p;i++){ GET_UTF8(priv->display_page[i].unicode,*p++,break;); } @@ -1705,7 +1705,7 @@ int teletext_control(void* p, int cmd, void *arg) priv->subpagenum=0x3f7f; pll_reset(priv,fine_tune); if(tt_param->lang==-1){ - mp_msg(MSGT_TELETEXT,MSGL_INFO,MSGTR_TV_TTSupportedLanguages); + mp_tmsg(MSGT_TELETEXT,MSGL_INFO,"Supported Teletext languages:\n"); for(i=0; tt_languages[i].lang_code; i++){ mp_msg(MSGT_TELETEXT,MSGL_INFO," %3d %s\n", tt_languages[i].lang_code, tt_languages[i].lang_name); @@ -1718,7 +1718,7 @@ int teletext_control(void* p, int cmd, void *arg) break; } if (priv->primary_language!=tt_languages[i].lang_code){ - mp_msg(MSGT_TELETEXT,MSGL_INFO,MSGTR_TV_TTSelectedLanguage, + mp_tmsg(MSGT_TELETEXT,MSGL_INFO,"Selected default teletext language: %s\n", tt_languages[i].lang_name); priv->primary_language=tt_languages[i].lang_code; } diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c index 3572565556..5781698185 100644 --- a/libmpcodecs/dec_video.c +++ b/libmpcodecs/dec_video.c @@ -17,9 +17,11 @@ */ #include "config.h" +#include "options.h" #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <unistd.h> #include "mp_msg.h" @@ -53,337 +55,392 @@ extern double vout_time_usage; #include "cpudetect.h" -int field_dominance=-1; +int field_dominance = -1; -int divx_quality=0; +int divx_quality = 0; -vd_functions_t* mpvdec=NULL; - -int get_video_quality_max(sh_video_t *sh_video){ - vf_instance_t* vf=sh_video->vfilter; - if(vf){ - int ret=vf->control(vf,VFCTRL_QUERY_MAX_PP_LEVEL,NULL); - if(ret>0){ - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingExternalPP,ret); - return ret; +int get_video_quality_max(sh_video_t *sh_video) +{ + vf_instance_t *vf = sh_video->vfilter; + if (vf) { + int ret = vf->control(vf, VFCTRL_QUERY_MAX_PP_LEVEL, NULL); + if (ret > 0) { + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[PP] Using external postprocessing filter, max q = %d.\n", ret); + return ret; + } } - } - if(mpvdec){ - int ret=mpvdec->control(sh_video,VDCTRL_QUERY_MAX_PP_LEVEL,NULL); - if(ret>0){ - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_UsingCodecPP,ret); - return ret; + const struct vd_functions *vd = sh_video->vd_driver; + if (vd) { + int ret = vd->control(sh_video, VDCTRL_QUERY_MAX_PP_LEVEL, NULL); + if (ret > 0) { + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[PP] Using codec's postprocessing, max q = %d.\n", ret); + return ret; + } } - } -// mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[PP] Sorry, postprocessing is not available\n"); - return 0; + return 0; } -void set_video_quality(sh_video_t *sh_video,int quality){ - vf_instance_t* vf=sh_video->vfilter; - if(vf){ - int ret=vf->control(vf,VFCTRL_SET_PP_LEVEL, (void*)(&quality)); - if(ret==CONTROL_TRUE) return; // success - } - if(mpvdec) - mpvdec->control(sh_video,VDCTRL_SET_PP_LEVEL, (void*)(&quality)); +void set_video_quality(sh_video_t *sh_video, int quality) +{ + vf_instance_t *vf = sh_video->vfilter; + if (vf) { + int ret = vf->control(vf, VFCTRL_SET_PP_LEVEL, (void *) (&quality)); + if (ret == CONTROL_TRUE) + return; // success + } + const struct vd_functions *vd = sh_video->vd_driver; + if (vd) + vd->control(sh_video, VDCTRL_SET_PP_LEVEL, (void *) (&quality)); } -int set_video_colors(sh_video_t *sh_video,const char *item,int value) +int set_video_colors(sh_video_t *sh_video, const char *item, int value) { - vf_instance_t* vf=sh_video->vfilter; + vf_instance_t *vf = sh_video->vfilter; vf_equalizer_t data; data.item = item; data.value = value; - mp_dbg(MSGT_DECVIDEO,MSGL_V,"set video colors %s=%d \n", item, value); - if (vf) - { - int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data); - if (ret == CONTROL_TRUE) - return 1; + mp_dbg(MSGT_DECVIDEO, MSGL_V, "set video colors %s=%d \n", item, value); + if (vf) { + int ret = vf->control(vf, VFCTRL_SET_EQUALIZER, &data); + if (ret == CONTROL_TRUE) + return 1; } /* try software control */ - if(mpvdec) - if( mpvdec->control(sh_video,VDCTRL_SET_EQUALIZER, item, (int *)value) - == CONTROL_OK) return 1; - mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_VideoAttributeNotSupportedByVO_VD,item); + const struct vd_functions *vd = sh_video->vd_driver; + if (vd && + vd->control(sh_video, VDCTRL_SET_EQUALIZER, item, (int *) value) + == CONTROL_OK) + return 1; + mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Video attribute '%s' is not supported by selected vo & vd.\n", + item); return 0; } -int get_video_colors(sh_video_t *sh_video,const char *item,int *value) +int get_video_colors(sh_video_t *sh_video, const char *item, int *value) { - vf_instance_t* vf=sh_video->vfilter; + vf_instance_t *vf = sh_video->vfilter; vf_equalizer_t data; data.item = item; - mp_dbg(MSGT_DECVIDEO,MSGL_V,"get video colors %s \n", item); - if (vf) - { + mp_dbg(MSGT_DECVIDEO, MSGL_V, "get video colors %s \n", item); + if (vf) { int ret = vf->control(vf, VFCTRL_GET_EQUALIZER, &data); - if (ret == CONTROL_TRUE){ - *value = data.value; - return 1; - } + if (ret == CONTROL_TRUE) { + *value = data.value; + return 1; + } } /* try software control */ - if(mpvdec) return mpvdec->control(sh_video,VDCTRL_GET_EQUALIZER, item, value); + const struct vd_functions *vd = sh_video->vd_driver; + if (vd) + return vd->control(sh_video, VDCTRL_GET_EQUALIZER, item, value); return 0; } -int set_rectangle(sh_video_t *sh_video,int param,int value) +int set_rectangle(sh_video_t *sh_video, int param, int value) { - vf_instance_t* vf=sh_video->vfilter; - int data[] = {param, value}; + vf_instance_t *vf = sh_video->vfilter; + int data[] = { param, value }; - mp_dbg(MSGT_DECVIDEO,MSGL_V,"set rectangle \n"); - if (vf) - { + mp_dbg(MSGT_DECVIDEO, MSGL_V, "set rectangle \n"); + if (vf) { int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data); - if (ret) - return 1; + if (ret) + return 1; } return 0; } +int redraw_osd(struct sh_video *sh_video, struct osd_state *osd) +{ + struct vf_instance *vf = sh_video->vfilter; + if (vf->control(vf, VFCTRL_REDRAW_OSD, osd) == true) + return 0; + return -1; +} + void resync_video_stream(sh_video_t *sh_video) { - sh_video->timer = 0; - sh_video->next_frame_time = 0; - sh_video->num_buffered_pts = 0; - sh_video->last_pts = MP_NOPTS_VALUE; - if(mpvdec) mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL); + const struct vd_functions *vd = sh_video->vd_driver; + if (vd) + vd->control(sh_video, VDCTRL_RESYNC_STREAM, NULL); + sh_video->prev_codec_reordered_pts = MP_NOPTS_VALUE; + sh_video->prev_sorted_pts = MP_NOPTS_VALUE; } int get_current_video_decoder_lag(sh_video_t *sh_video) { - int ret; - - if (!mpvdec) - return -1; - ret = mpvdec->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL); + const struct vd_functions *vd = sh_video->vd_driver; + if (!vd) + return -1; + int ret = vd->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL); if (ret >= 10) - return ret-10; + return ret - 10; return -1; } -void uninit_video(sh_video_t *sh_video){ - if(!sh_video->initialized) return; - mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_UninitVideoStr,sh_video->codec->drv); - mpvdec->uninit(sh_video); +void uninit_video(sh_video_t *sh_video) +{ + if (!sh_video->initialized) + return; + mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Uninit video: %s\n", sh_video->codec->drv); + sh_video->vd_driver->uninit(sh_video); #ifdef CONFIG_DYNAMIC_PLUGINS if (sh_video->dec_handle) - dlclose(sh_video->dec_handle); + dlclose(sh_video->dec_handle); #endif vf_uninit_filter_chain(sh_video->vfilter); - sh_video->initialized=0; + sh_video->initialized = 0; } -void vfm_help(void){ +void vfm_help(void) +{ int i; - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_AvailableVideoFm); + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Available (compiled-in) video codec families/drivers:\n"); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_DRIVERS\n"); - mp_msg(MSGT_DECVIDEO,MSGL_INFO," vfm: info: (comment)\n"); - for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) - mp_msg(MSGT_DECVIDEO,MSGL_INFO,"%8s %s (%s)\n", - mpcodecs_vd_drivers[i]->info->short_name, - mpcodecs_vd_drivers[i]->info->name, - mpcodecs_vd_drivers[i]->info->comment); + mp_msg(MSGT_DECVIDEO, MSGL_INFO, " vfm: info: (comment)\n"); + for (i = 0; mpcodecs_vd_drivers[i] != NULL; i++) + mp_msg(MSGT_DECVIDEO, MSGL_INFO, "%8s %s (%s)\n", + mpcodecs_vd_drivers[i]->info->short_name, + mpcodecs_vd_drivers[i]->info->name, + mpcodecs_vd_drivers[i]->info->comment); } -static int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status, - stringset_t *selected){ +static int init_video(sh_video_t *sh_video, char *codecname, char *vfm, + int status, stringset_t *selected) +{ int force = 0; - unsigned int orig_fourcc=sh_video->bih?sh_video->bih->biCompression:0; - sh_video->codec=NULL; - sh_video->vf_initialized=0; + unsigned int orig_fourcc = + sh_video->bih ? sh_video->bih->biCompression : 0; + sh_video->codec = NULL; + sh_video->vf_initialized = 0; if (codecname && codecname[0] == '+') { - codecname = &codecname[1]; - force = 1; + codecname = &codecname[1]; + force = 1; } - while(1){ - int i; - int orig_w, orig_h; - // restore original fourcc: - if(sh_video->bih) sh_video->bih->biCompression=orig_fourcc; - if(!(sh_video->codec=find_video_codec(sh_video->format, - sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL, - sh_video->codec,force) )) break; - // ok we found one codec - if(stringset_test(selected, sh_video->codec->name)) continue; // already tried & failed - if(codecname && strcmp(sh_video->codec->name,codecname)) continue; // -vc - if(vfm && strcmp(sh_video->codec->drv,vfm)) continue; // vfm doesn't match - if(!force && sh_video->codec->status<status) continue; // too unstable - stringset_add(selected, sh_video->codec->name); // tagging it - // ok, it matches all rules, let's find the driver! - for (i=0; mpcodecs_vd_drivers[i] != NULL; i++) -// if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break; - if(!strcmp(mpcodecs_vd_drivers[i]->info->short_name,sh_video->codec->drv)) break; - mpvdec=mpcodecs_vd_drivers[i]; + while (1) { + int i; + int orig_w, orig_h; + // restore original fourcc: + if (sh_video->bih) + sh_video->bih->biCompression = orig_fourcc; + if (! + (sh_video->codec = + find_video_codec(sh_video->format, + sh_video->bih ? ((unsigned int *) &sh_video-> + bih->biCompression) : NULL, + sh_video->codec, force))) + break; + // ok we found one codec + if (stringset_test(selected, sh_video->codec->name)) + continue; // already tried & failed + if (codecname && strcmp(sh_video->codec->name, codecname)) + continue; // -vc + if (vfm && strcmp(sh_video->codec->drv, vfm)) + continue; // vfm doesn't match + if (!force && sh_video->codec->status < status) + continue; // too unstable + stringset_add(selected, sh_video->codec->name); // tagging it + // ok, it matches all rules, let's find the driver! + for (i = 0; mpcodecs_vd_drivers[i] != NULL; i++) + if (!strcmp(mpcodecs_vd_drivers[i]->info->short_name, + sh_video->codec->drv)) + break; + sh_video->vd_driver = mpcodecs_vd_drivers[i]; #ifdef CONFIG_DYNAMIC_PLUGINS - if (!mpvdec) - { - /* try to open shared decoder plugin */ - int buf_len; - char *buf; - vd_functions_t *funcs_sym; - vd_info_t *info_sym; - - buf_len = strlen(MPLAYER_LIBDIR)+strlen(sh_video->codec->drv)+16; - buf = malloc(buf_len); - if (!buf) - break; - snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR, sh_video->codec->drv); - mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf); - sh_video->dec_handle = dlopen(buf, RTLD_LAZY); - if (!sh_video->dec_handle) - break; - snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv); - funcs_sym = dlsym(sh_video->dec_handle, buf); - if (!funcs_sym || !funcs_sym->info || !funcs_sym->init || - !funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode) - break; - info_sym = funcs_sym->info; - if (strcmp(info_sym->short_name, sh_video->codec->drv)) - break; - free(buf); - mpvdec = funcs_sym; - mp_msg(MSGT_DECVIDEO, MSGL_V, "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n", - MPLAYER_LIBDIR, sh_video->codec->drv); - } + if (!sh_video->vd_driver) { + /* try to open shared decoder plugin */ + int buf_len; + char *buf; + vd_functions_t *funcs_sym; + vd_info_t *info_sym; + + buf_len = + strlen(MPLAYER_LIBDIR) + strlen(sh_video->codec->drv) + 16; + buf = malloc(buf_len); + if (!buf) + break; + snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", MPLAYER_LIBDIR, + sh_video->codec->drv); + mp_msg(MSGT_DECVIDEO, MSGL_DBG2, + "Trying to open external plugin: %s\n", buf); + sh_video->dec_handle = dlopen(buf, RTLD_LAZY); + if (!sh_video->dec_handle) + break; + snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv); + funcs_sym = dlsym(sh_video->dec_handle, buf); + if (!funcs_sym || !funcs_sym->info || !funcs_sym->init + || !funcs_sym->uninit || !funcs_sym->control + || !funcs_sym->decode) + break; + info_sym = funcs_sym->info; + if (strcmp(info_sym->short_name, sh_video->codec->drv)) + break; + free(buf); + sh_video->vd_driver = funcs_sym; + mp_msg(MSGT_DECVIDEO, MSGL_V, + "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n", + MPLAYER_LIBDIR, sh_video->codec->drv); + } #endif - if(!mpvdec){ // driver not available (==compiled in) - mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_VideoCodecFamilyNotAvailableStr, - sh_video->codec->name, sh_video->codec->drv); - continue; - } - orig_w = sh_video->bih ? sh_video->bih->biWidth : sh_video->disp_w; - orig_h = sh_video->bih ? sh_video->bih->biHeight : sh_video->disp_h; - sh_video->disp_w = orig_w; - sh_video->disp_h = orig_h; - // it's available, let's try to init! - if(sh_video->codec->flags & CODECS_FLAG_ALIGN16){ - // align width/height to n*16 - sh_video->disp_w=(sh_video->disp_w+15)&(~15); - sh_video->disp_h=(sh_video->disp_h+15)&(~15); - } - if (sh_video->bih) { - sh_video->bih->biWidth = sh_video->disp_w; - sh_video->bih->biHeight = sh_video->disp_h; - } - // init() - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_OpeningVideoDecoder,mpvdec->info->short_name,mpvdec->info->name); - // clear vf init error, it is no longer relevant - if (sh_video->vf_initialized < 0) - sh_video->vf_initialized = 0; - if(!mpvdec->init(sh_video)){ - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_VDecoderInitFailed); - sh_video->disp_w=orig_w; - sh_video->disp_h=orig_h; - if (sh_video->bih) { - sh_video->bih->biWidth = sh_video->disp_w; - sh_video->bih->biHeight = sh_video->disp_h; - } - continue; // try next... - } - // Yeah! We got it! - sh_video->initialized=1; - return 1; + if (!sh_video->vd_driver) { // driver not available (==compiled in) + mp_tmsg(MSGT_DECVIDEO, MSGL_WARN, + _("Requested video codec family [%s] (vfm=%s) not available.\nEnable it at compilation.\n"), + sh_video->codec->name, sh_video->codec->drv); + continue; + } + orig_w = sh_video->bih ? sh_video->bih->biWidth : sh_video->disp_w; + orig_h = sh_video->bih ? sh_video->bih->biHeight : sh_video->disp_h; + sh_video->disp_w = orig_w; + sh_video->disp_h = orig_h; + // it's available, let's try to init! + if (sh_video->codec->flags & CODECS_FLAG_ALIGN16) { + // align width/height to n*16 + sh_video->disp_w = (sh_video->disp_w + 15) & (~15); + sh_video->disp_h = (sh_video->disp_h + 15) & (~15); + } + if (sh_video->bih) { + sh_video->bih->biWidth = sh_video->disp_w; + sh_video->bih->biHeight = sh_video->disp_h; + } + + // init() + const struct vd_functions *vd = sh_video->vd_driver; + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Opening video decoder: [%s] %s\n", + vd->info->short_name, vd->info->name); + // clear vf init error, it is no longer relevant + if (sh_video->vf_initialized < 0) + sh_video->vf_initialized = 0; + if (!vd->init(sh_video)) { + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "VDecoder init failed :(\n"); + sh_video->disp_w = orig_w; + sh_video->disp_h = orig_h; + if (sh_video->bih) { + sh_video->bih->biWidth = sh_video->disp_w; + sh_video->bih->biHeight = sh_video->disp_h; + } + continue; // try next... + } + // Yeah! We got it! + sh_video->initialized = 1; + sh_video->prev_codec_reordered_pts = MP_NOPTS_VALUE; + sh_video->prev_sorted_pts = MP_NOPTS_VALUE; + return 1; } return 0; } -int init_best_video_codec(sh_video_t *sh_video,char** video_codec_list,char** video_fm_list){ -char* vc_l_default[2]={"",(char*)NULL}; -stringset_t selected; -// hack: -if(!video_codec_list) video_codec_list=vc_l_default; -// Go through the codec.conf and find the best codec... -sh_video->initialized=0; -stringset_init(&selected); -while(!sh_video->initialized && *video_codec_list){ - char* video_codec=*(video_codec_list++); - if(video_codec[0]){ - if(video_codec[0]=='-'){ - // disable this codec: - stringset_add(&selected, video_codec+1); - } else { - // forced codec by name: - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_ForcedVideoCodec,video_codec); - init_video(sh_video,video_codec,NULL,-1, &selected); - } - } else { - int status; - // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING. - if(video_fm_list){ - char** fmlist=video_fm_list; - // try first the preferred codec families: - while(!sh_video->initialized && *fmlist){ - char* video_fm=*(fmlist++); - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_TryForceVideoFmtStr,video_fm); - for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) - if(init_video(sh_video,NULL,video_fm,status, &selected)) break; - } +int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list, + char **video_fm_list) +{ + char *vc_l_default[2] = { "", (char *) NULL }; + stringset_t selected; + // hack: + if (!video_codec_list) + video_codec_list = vc_l_default; + // Go through the codec.conf and find the best codec... + sh_video->initialized = 0; + stringset_init(&selected); + while (!sh_video->initialized && *video_codec_list) { + char *video_codec = *(video_codec_list++); + if (video_codec[0]) { + if (video_codec[0] == '-') { + // disable this codec: + stringset_add(&selected, video_codec + 1); + } else { + // forced codec by name: + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Forced video codec: %s\n", + video_codec); + init_video(sh_video, video_codec, NULL, -1, &selected); + } + } else { + int status; + // try in stability order: UNTESTED, WORKING, BUGGY. never try CRASHING. + if (video_fm_list) { + char **fmlist = video_fm_list; + // try first the preferred codec families: + while (!sh_video->initialized && *fmlist) { + char *video_fm = *(fmlist++); + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Trying to force video codec driver family %s...\n", + video_fm); + for (status = CODECS_STATUS__MAX; + status >= CODECS_STATUS__MIN; --status) + if (init_video + (sh_video, NULL, video_fm, status, &selected)) + break; + } + } + if (!sh_video->initialized) + for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN; + --status) + if (init_video(sh_video, NULL, NULL, status, &selected)) + break; + } } - if(!sh_video->initialized) - for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status) - if(init_video(sh_video,NULL,NULL,status, &selected)) break; - } -} -stringset_free(&selected); + stringset_free(&selected); -if(!sh_video->initialized){ - mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format); - return 0; // failed -} + if (!sh_video->initialized) { + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Cannot find codec matching selected -vo and video format 0x%X.\n", + sh_video->format); + return 0; // failed + } -mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_SelectedVideoCodec, - sh_video->codec->name,sh_video->codec->drv,sh_video->codec->info); -return 1; // success + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Selected video codec: [%s] vfm: %s (%s)\n", + sh_video->codec->name, sh_video->codec->drv, sh_video->codec->info); + return 1; // success } void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size, - int drop_frame, double pts) + int drop_frame, double pts) { mp_image_t *mpi = NULL; unsigned int t = GetTimer(); unsigned int t2; double tt; + struct MPOpts *opts = sh_video->opts; - if (correct_pts && pts != MP_NOPTS_VALUE) { - int delay = get_current_video_decoder_lag(sh_video); - if (delay >= 0) { - if (delay > sh_video->num_buffered_pts) + if (opts->correct_pts && pts != MP_NOPTS_VALUE) { + int delay = get_current_video_decoder_lag(sh_video); + if (delay >= 0) { + if (delay > sh_video->num_buffered_pts) #if 0 - // this is disabled because vd_ffmpeg reports the same lag - // after seek even when there are no buffered frames, - // leading to incorrect error messages - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n"); + // this is disabled because vd_ffmpeg reports the same lag + // after seek even when there are no buffered frames, + // leading to incorrect error messages + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Not enough buffered pts\n"); #else - ; + ; #endif - else - sh_video->num_buffered_pts = delay; - } - if (sh_video->num_buffered_pts == - sizeof(sh_video->buffered_pts)/sizeof(double)) - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n"); - else { - int i, j; - for (i = 0; i < sh_video->num_buffered_pts; i++) - if (sh_video->buffered_pts[i] < pts) - break; - for (j = sh_video->num_buffered_pts; j > i; j--) - sh_video->buffered_pts[j] = sh_video->buffered_pts[j-1]; - sh_video->buffered_pts[i] = pts; - sh_video->num_buffered_pts++; - } + else + sh_video->num_buffered_pts = delay; + } + if (sh_video->num_buffered_pts == + sizeof(sh_video->buffered_pts) / sizeof(double)) + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Too many buffered pts\n"); + else { + int i, j; + for (i = 0; i < sh_video->num_buffered_pts; i++) + if (sh_video->buffered_pts[i] < pts) + break; + for (j = sh_video->num_buffered_pts; j > i; j--) + sh_video->buffered_pts[j] = sh_video->buffered_pts[j - 1]; + sh_video->buffered_pts[i] = pts; + sh_video->num_buffered_pts++; + } } - mpi = mpvdec->decode(sh_video, start, in_size, drop_frame); + if (sh_video->vd_driver->decode2) { + mpi = sh_video->vd_driver->decode2(sh_video, start, in_size, + drop_frame, &pts); + } else { + mpi = sh_video->vd_driver->decode(sh_video, start, in_size, + drop_frame); + pts = MP_NOPTS_VALUE; + } //------------------------ frame decoded. -------------------- @@ -391,36 +448,47 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size, // some codecs are broken, and doesn't restore MMX state :( // it happens usually with broken/damaged files. if (gCpuCaps.has3DNow) { - __asm__ volatile ("femms\n\t":::"memory"); - } - else if (gCpuCaps.hasMMX) { - __asm__ volatile ("emms\n\t":::"memory"); + __asm__ volatile("femms\n\t":::"memory"); + } else if (gCpuCaps.hasMMX) { + __asm__ volatile("emms\n\t":::"memory"); } #endif - t2 = GetTimer(); t = t2-t; - tt = t*0.000001f; + t2 = GetTimer(); + t = t2 - t; + tt = t * 0.000001f; video_time_usage += tt; if (!mpi || drop_frame) - return NULL; // error / skipped frame + return NULL; // error / skipped frame if (field_dominance == 0) - mpi->fields |= MP_IMGFIELD_TOP_FIRST; + mpi->fields |= MP_IMGFIELD_TOP_FIRST; else if (field_dominance == 1) - mpi->fields &= ~MP_IMGFIELD_TOP_FIRST; - - if (correct_pts) { - if (sh_video->num_buffered_pts) { - sh_video->num_buffered_pts--; - sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts]; - } - else { - mp_msg(MSGT_CPLAYER, MSGL_ERR, "No pts value from demuxer to " - "use for frame!\n"); - sh_video->pts = MP_NOPTS_VALUE; - } + mpi->fields &= ~MP_IMGFIELD_TOP_FIRST; + + double prevpts = sh_video->codec_reordered_pts; + sh_video->prev_codec_reordered_pts = prevpts; + sh_video->codec_reordered_pts = pts; + if (prevpts != MP_NOPTS_VALUE && pts <= prevpts + || pts == MP_NOPTS_VALUE) + sh_video->num_reordered_pts_problems++; + prevpts = sh_video->sorted_pts; + if (opts->correct_pts) { + if (sh_video->num_buffered_pts) { + sh_video->num_buffered_pts--; + sh_video->sorted_pts = + sh_video->buffered_pts[sh_video->num_buffered_pts]; + } else { + mp_msg(MSGT_CPLAYER, MSGL_ERR, + "No pts value from demuxer to " "use for frame!\n"); + sh_video->sorted_pts = MP_NOPTS_VALUE; + } } + pts = sh_video->sorted_pts; + if (prevpts != MP_NOPTS_VALUE && pts <= prevpts + || pts == MP_NOPTS_VALUE) + sh_video->num_sorted_pts_problems++; return mpi; } @@ -431,18 +499,9 @@ int filter_video(sh_video_t *sh_video, void *frame, double pts) vf_instance_t *vf = sh_video->vfilter; // apply video filters and call the leaf vo/ve int ret = vf->put_image(vf, mpi, pts); - if (ret > 0) { - // draw EOSD first so it ends up below the OSD. - // Note that changing this is will not work right with vf_ass and the - // vos currently always draw the EOSD first in paused mode. -#ifdef CONFIG_ASS - vf->control(vf, VFCTRL_DRAW_EOSD, NULL); -#endif - vf->control(vf, VFCTRL_DRAW_OSD, NULL); - } - t2 = GetTimer()-t2; - vout_time_usage += t2*0.000001; + t2 = GetTimer() - t2; + vout_time_usage += t2 * 0.000001; return ret; } diff --git a/libmpcodecs/dec_video.h b/libmpcodecs/dec_video.h index 8b28202a19..f4b72a7d3f 100644 --- a/libmpcodecs/dec_video.h +++ b/libmpcodecs/dec_video.h @@ -21,6 +21,8 @@ #include "libmpdemux/stheader.h" +struct osd_state; + // dec_video.c: void vfm_help(void); @@ -36,6 +38,7 @@ void set_video_quality(sh_video_t *sh_video, int quality); int get_video_colors(sh_video_t *sh_video, const char *item, int *value); int set_video_colors(sh_video_t *sh_video, const char *item, int value); int set_rectangle(sh_video_t *sh_video, int param, int value); +int redraw_osd(struct sh_video *sh_video, struct osd_state *osd); void resync_video_stream(sh_video_t *sh_video); int get_current_video_decoder_lag(sh_video_t *sh_video); diff --git a/libmpcodecs/img_format.c b/libmpcodecs/img_format.c index 5b858fa065..830180a55c 100644 --- a/libmpcodecs/img_format.c +++ b/libmpcodecs/img_format.c @@ -97,7 +97,7 @@ const char *vo_format_name(int format) case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration"; case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration"; - case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG4: return "MPEG-4 Part 2 VDPAU acceleration"; case IMGFMT_VDPAU_WMV3: return "WMV3 VDPAU acceleration"; case IMGFMT_VDPAU_VC1: return "VC1 VDPAU acceleration"; } diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h index ba69e720ef..38238db2a7 100644 --- a/libmpcodecs/mp_image.h +++ b/libmpcodecs/mp_image.h @@ -96,7 +96,7 @@ #define MP_IMGFIELD_BOTTOM 0x10 #define MP_IMGFIELD_INTERLACED 0x20 -typedef struct mp_image_s { +typedef struct mp_image { unsigned int flags; unsigned char type; int number; diff --git a/libmpcodecs/native/xa_gsm.c b/libmpcodecs/native/xa_gsm.c index 73bf31c3d8..2fc2357c13 100644 --- a/libmpcodecs/native/xa_gsm.c +++ b/libmpcodecs/native/xa_gsm.c @@ -258,7 +258,7 @@ register word * s; } /**** 4.3.2 */ -void Gsm_Long_Term_Synthesis_Filtering (S,Ncr,bcr,erp,drp) +static void Gsm_Long_Term_Synthesis_Filtering (S,Ncr,bcr,erp,drp) XA_GSM_STATE * S; word Ncr; word bcr; diff --git a/libmpcodecs/pullup.c b/libmpcodecs/pullup.c index 189d0cb24d..2675be6146 100644 --- a/libmpcodecs/pullup.c +++ b/libmpcodecs/pullup.c @@ -820,12 +820,3 @@ void pullup_free_context(struct pullup_context *c) free(c->frame); free(c); } - - - - - - - - - diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c index 12b9b8c153..19ac82bf83 100644 --- a/libmpcodecs/vd.c +++ b/libmpcodecs/vd.c @@ -23,9 +23,9 @@ #include "config.h" #include "mp_msg.h" #include "help_mp.h" +#include "options.h" #include "codec-cfg.h" -//#include "mp_image.h" #include "img_format.h" @@ -37,322 +37,320 @@ #include "vd.h" #include "vf.h" -//#include "vd_internal.h" - -extern vd_functions_t mpcodecs_vd_null; -extern vd_functions_t mpcodecs_vd_ffmpeg; -extern vd_functions_t mpcodecs_vd_theora; -extern vd_functions_t mpcodecs_vd_dshow; -extern vd_functions_t mpcodecs_vd_dmo; -extern vd_functions_t mpcodecs_vd_vfw; -extern vd_functions_t mpcodecs_vd_vfwex; -extern vd_functions_t mpcodecs_vd_raw; -extern vd_functions_t mpcodecs_vd_hmblck; -extern vd_functions_t mpcodecs_vd_xanim; -extern vd_functions_t mpcodecs_vd_mpng; -extern vd_functions_t mpcodecs_vd_ijpg; -extern vd_functions_t mpcodecs_vd_mtga; -extern vd_functions_t mpcodecs_vd_sgi; -extern vd_functions_t mpcodecs_vd_libmpeg2; -extern vd_functions_t mpcodecs_vd_mpegpes; -extern vd_functions_t mpcodecs_vd_zrmjpeg; -extern vd_functions_t mpcodecs_vd_realvid; -extern vd_functions_t mpcodecs_vd_xvid; -extern vd_functions_t mpcodecs_vd_libdv; -extern vd_functions_t mpcodecs_vd_lzo; -extern vd_functions_t mpcodecs_vd_qtvideo; +extern const vd_functions_t mpcodecs_vd_null; +extern const vd_functions_t mpcodecs_vd_ffmpeg; +extern const vd_functions_t mpcodecs_vd_theora; +extern const vd_functions_t mpcodecs_vd_dshow; +extern const vd_functions_t mpcodecs_vd_dmo; +extern const vd_functions_t mpcodecs_vd_vfw; +extern const vd_functions_t mpcodecs_vd_vfwex; +extern const vd_functions_t mpcodecs_vd_raw; +extern const vd_functions_t mpcodecs_vd_hmblck; +extern const vd_functions_t mpcodecs_vd_xanim; +extern const vd_functions_t mpcodecs_vd_mpng; +extern const vd_functions_t mpcodecs_vd_ijpg; +extern const vd_functions_t mpcodecs_vd_mtga; +extern const vd_functions_t mpcodecs_vd_sgi; +extern const vd_functions_t mpcodecs_vd_libmpeg2; +extern const vd_functions_t mpcodecs_vd_mpegpes; +extern const vd_functions_t mpcodecs_vd_zrmjpeg; +extern const vd_functions_t mpcodecs_vd_realvid; +extern const vd_functions_t mpcodecs_vd_xvid; +extern const vd_functions_t mpcodecs_vd_libdv; +extern const vd_functions_t mpcodecs_vd_lzo; +extern const vd_functions_t mpcodecs_vd_qtvideo; /* Please do not add any new decoders here. If you want to implement a new * decoder, add it to libavcodec, except for wrappers around external * libraries and decoders requiring binary support. */ const vd_functions_t * const mpcodecs_vd_drivers[] = { - &mpcodecs_vd_null, + &mpcodecs_vd_null, #ifdef CONFIG_LIBAVCODEC - &mpcodecs_vd_ffmpeg, + &mpcodecs_vd_ffmpeg, #endif #ifdef CONFIG_OGGTHEORA - &mpcodecs_vd_theora, + &mpcodecs_vd_theora, #endif #ifdef CONFIG_WIN32DLL - &mpcodecs_vd_dshow, - &mpcodecs_vd_dmo, - &mpcodecs_vd_vfw, - &mpcodecs_vd_vfwex, + &mpcodecs_vd_dshow, + &mpcodecs_vd_dmo, + &mpcodecs_vd_vfw, + &mpcodecs_vd_vfwex, #endif - &mpcodecs_vd_lzo, - &mpcodecs_vd_raw, - &mpcodecs_vd_hmblck, + &mpcodecs_vd_lzo, + &mpcodecs_vd_raw, + &mpcodecs_vd_hmblck, #ifdef CONFIG_XANIM - &mpcodecs_vd_xanim, + &mpcodecs_vd_xanim, #endif #ifdef CONFIG_PNG - &mpcodecs_vd_mpng, + &mpcodecs_vd_mpng, #endif #ifdef CONFIG_JPEG - &mpcodecs_vd_ijpg, + &mpcodecs_vd_ijpg, #endif - &mpcodecs_vd_mtga, - &mpcodecs_vd_sgi, + &mpcodecs_vd_mtga, + &mpcodecs_vd_sgi, #ifdef CONFIG_LIBMPEG2 - &mpcodecs_vd_libmpeg2, + &mpcodecs_vd_libmpeg2, #endif - &mpcodecs_vd_mpegpes, + &mpcodecs_vd_mpegpes, #ifdef CONFIG_ZR - &mpcodecs_vd_zrmjpeg, + &mpcodecs_vd_zrmjpeg, #endif #ifdef CONFIG_REALCODECS - &mpcodecs_vd_realvid, + &mpcodecs_vd_realvid, #endif #ifdef CONFIG_XVID4 - &mpcodecs_vd_xvid, + &mpcodecs_vd_xvid, #endif #ifdef CONFIG_LIBDV095 - &mpcodecs_vd_libdv, + &mpcodecs_vd_libdv, #endif #ifdef CONFIG_QTX_CODECS - &mpcodecs_vd_qtvideo, + &mpcodecs_vd_qtvideo, #endif /* Please do not add any new decoders here. If you want to implement a new * decoder, add it to libavcodec, except for wrappers around external * libraries and decoders requiring binary support. */ - NULL + NULL }; #include "libvo/video_out.h" -// libvo opts: -int fullscreen=0; -int vidmode=0; -int softzoom=0; -int flip=-1; -int opt_screen_size_x=0; -int opt_screen_size_y=0; -float screen_size_xy=0; -float movie_aspect=-1.0; -int vo_flags=0; -int vd_use_slices=1; - -/** global variables for gamma, brightness, contrast, saturation and hue - modified by mplayer.c and gui/mplayer/gtk/eq.c: - ranges -100 - 100 - 1000 if the vo default should be used -*/ -int vo_gamma_gamma = 1000; -int vo_gamma_brightness = 1000; -int vo_gamma_contrast = 1000; -int vo_gamma_saturation = 1000; -int vo_gamma_hue = 1000; - -extern vd_functions_t* mpvdec; // FIXME! - -#define SCREEN_SIZE_X 1 -#define SCREEN_SIZE_Y 1 - -int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){ - int i,j; - unsigned int out_fmt=0; - int screen_size_x=0;//SCREEN_SIZE_X; - int screen_size_y=0;//SCREEN_SIZE_Y; - vf_instance_t* vf=sh->vfilter,*sc=NULL; - int palette=0; - int vocfg_flags=0; - - if(w) - sh->disp_w=w; - if(h) - sh->disp_h=h; - - if(!sh->disp_w || !sh->disp_h) - return 0; +int mpcodecs_config_vo(sh_video_t *sh, int w, int h, + unsigned int preferred_outfmt) +{ + struct MPOpts *opts = sh->opts; + int i, j; + unsigned int out_fmt = 0; + int screen_size_x = 0; + int screen_size_y = 0; + vf_instance_t *vf = sh->vfilter, *sc = NULL; + int palette = 0; + int vocfg_flags = 0; + + if (w) + sh->disp_w = w; + if (h) + sh->disp_h = h; + + if (!sh->disp_w || !sh->disp_h) + return 0; mp_msg(MSGT_DECVIDEO, MSGL_V, "VDec: vo config request - %d x %d (preferred colorspace: %s)\n", w, h, vo_format_name(preferred_outfmt)); -// if(!vf) return 1; // temp hack - - if(get_video_quality_max(sh)<=0 && divx_quality){ - // user wants postprocess but no pp filter yet: - sh->vfilter=vf=vf_open_filter(vf,"pp",NULL); + if (get_video_quality_max(sh) <= 0 && divx_quality) { + // user wants postprocess but no pp filter yet: + sh->vfilter = vf = vf_open_filter(opts, vf, "pp", NULL); } - // check if libvo and codec has common outfmt (no conversion): -csp_again: - - if( mp_msg_test(MSGT_DECVIDEO,MSGL_V) ){ - vf_instance_t* f=vf; - mp_msg(MSGT_DECVIDEO,MSGL_V,"Trying filter chain:"); - for(f = vf ; f ; f = f->next) - mp_msg(MSGT_DECVIDEO,MSGL_V," %s",f->info->name); - mp_msg(MSGT_DECVIDEO,MSGL_V,"\n"); + csp_again: + + if (mp_msg_test(MSGT_DECVIDEO, MSGL_V)) { + vf_instance_t *f = vf; + mp_msg(MSGT_DECVIDEO, MSGL_V, "Trying filter chain:"); + for (f = vf; f; f = f->next) + mp_msg(MSGT_DECVIDEO, MSGL_V, " %s", f->info->name); + mp_msg(MSGT_DECVIDEO, MSGL_V, "\n"); } - j=-1; - for(i=0;i<CODECS_MAX_OUTFMT;i++){ - int flags; - out_fmt=sh->codec->outfmt[i]; - if(out_fmt==(unsigned int)0xFFFFFFFF) continue; - flags=vf->query_format(vf,out_fmt); - mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: query(%s) returned 0x%X (i=%d) \n",vo_format_name(out_fmt),flags,i); - if((flags&VFCAP_CSP_SUPPORTED_BY_HW) || (flags&VFCAP_CSP_SUPPORTED && j<0)){ - // check (query) if codec really support this outfmt... - sh->outfmtidx=j; // pass index to the control() function this way - if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)==CONTROL_FALSE){ - mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: codec query_format(%s) returned FALSE\n",vo_format_name(out_fmt)); - continue; - } - j=i; vo_flags=flags; if(flags&VFCAP_CSP_SUPPORTED_BY_HW) break; - } else - if(!palette && !(flags&(VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_CSP_SUPPORTED)) && (out_fmt==IMGFMT_RGB8||out_fmt==IMGFMT_BGR8)){ - sh->outfmtidx=j; // pass index to the control() function this way - if(mpvdec->control(sh,VDCTRL_QUERY_FORMAT,&out_fmt)!=CONTROL_FALSE) - palette=1; - } + j = -1; + for (i = 0; i < CODECS_MAX_OUTFMT; i++) { + int flags; + out_fmt = sh->codec->outfmt[i]; + if (out_fmt == (unsigned int) 0xFFFFFFFF) + continue; + flags = vf->query_format(vf, out_fmt); + mp_msg(MSGT_CPLAYER, MSGL_DBG2, + "vo_debug: query(%s) returned 0x%X (i=%d) \n", + vo_format_name(out_fmt), flags, i); + if ((flags & VFCAP_CSP_SUPPORTED_BY_HW) + || (flags & VFCAP_CSP_SUPPORTED && j < 0)) { + // check (query) if codec really support this outfmt... + sh->outfmtidx = j; // pass index to the control() function this way + if (sh->vd_driver->control(sh, VDCTRL_QUERY_FORMAT, &out_fmt) == + CONTROL_FALSE) { + mp_msg(MSGT_CPLAYER, MSGL_DBG2, + "vo_debug: codec query_format(%s) returned FALSE\n", + vo_format_name(out_fmt)); + continue; + } + j = i; + sh->output_flags = flags; + if (flags & VFCAP_CSP_SUPPORTED_BY_HW) + break; + } else if (!palette + && !(flags & + (VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_CSP_SUPPORTED)) + && (out_fmt == IMGFMT_RGB8 || out_fmt == IMGFMT_BGR8)) { + sh->outfmtidx = j; // pass index to the control() function this way + if (sh->vd_driver->control(sh, VDCTRL_QUERY_FORMAT, &out_fmt) != + CONTROL_FALSE) + palette = 1; + } } - if(j<0){ - // TODO: no match - we should use conversion... - if(strcmp(vf->info->name,"scale") && palette!=-1){ - mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_CouldNotFindColorspace); - sc=vf=vf_open_filter(vf,"scale",NULL); - goto csp_again; - } else - if(palette==1){ - mp_msg(MSGT_DECVIDEO,MSGL_V,"vd: Trying -vf palette...\n"); - palette=-1; - vf=vf_open_filter(vf,"palette",NULL); - goto csp_again; - } else - { // sws failed, if the last filter (vf_vo) support MPEGPES try to append vf_lavc - vf_instance_t* vo, *vp = NULL, *ve, *vpp = NULL; - // Remove the scale filter if we added it ourself - if(vf == sc) { - ve = vf; - vf = vf->next; - vf_uninit_filter(ve); - } - // Find the last filter (vf_vo) - for(vo = vf ; vo->next ; vo = vo->next) { - vpp = vp; - vp = vo; - } - if(vo->query_format(vo,IMGFMT_MPEGPES) && (!vp || (vp && strcmp(vp->info->name,"lavc")))) { - ve = vf_open_filter(vo,"lavc",NULL); - if(vp) vp->next = ve; - else vf = ve; - goto csp_again; - } - if (vp && !strcmp(vp->info->name,"lavc")) { - if (vpp) vpp->next = vo; - else vf = vo; + if (j < 0) { + // TODO: no match - we should use conversion... + if (strcmp(vf->info->name, "scale") && palette != -1) { + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Could not find matching colorspace - retrying with -vf scale...\n"); + sc = vf = vf_open_filter(opts, vf, "scale", NULL); + goto csp_again; + } else if (palette == 1) { + mp_msg(MSGT_DECVIDEO, MSGL_V, "vd: Trying -vf palette...\n"); + palette = -1; + vf = vf_open_filter(opts, vf, "palette", NULL); + goto csp_again; + } else { + // sws failed, if the last filter (vf_vo) support MPEGPES try + // to append vf_lavc + vf_instance_t *vo, *vp = NULL, *ve, *vpp = NULL; + // Remove the scale filter if we added it ourselves + if (vf == sc) { + ve = vf; + vf = vf->next; + vf_uninit_filter(ve); + } + // Find the last filter (vf_vo) + for (vo = vf; vo->next; vo = vo->next) { + vpp = vp; + vp = vo; + } + if (vo->query_format(vo, IMGFMT_MPEGPES) + && (!vp || (vp && strcmp(vp->info->name, "lavc")))) { + ve = vf_open_filter(opts, vo, "lavc", NULL); + if (vp) + vp->next = ve; + else + vf = ve; + goto csp_again; + } + if (vp && !strcmp(vp->info->name,"lavc")) { + if (vpp) + vpp->next = vo; + else + vf = vo; vf_uninit_filter(vp); - } - } - mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_VOincompCodec); - sh->vf_initialized=-1; - return 0; // failed + } + } + mp_tmsg(MSGT_CPLAYER, MSGL_WARN, + "The selected video_out device is incompatible with this codec.\n"\ + "Try appending the scale filter to your filter list,\n"\ + "e.g. -vf spp,scale instead of -vf spp.\n"); + sh->vf_initialized = -1; + return 0; // failed } - out_fmt=sh->codec->outfmt[j]; + out_fmt = sh->codec->outfmt[j]; mp_msg(MSGT_CPLAYER, MSGL_V, "VDec: using %s as output csp (no %d)\n", vo_format_name(out_fmt), j); - sh->outfmtidx=j; - sh->vfilter=vf; + sh->outfmtidx = j; + sh->vfilter = vf; // autodetect flipping - if(flip==-1){ - flip=0; - if(sh->codec->outflags[j]&CODECS_FLAG_FLIP) - if(!(sh->codec->outflags[j]&CODECS_FLAG_NOFLIP)) - flip=1; + if (opts->flip == -1) { + opts->flip = 0; + if (sh->codec->outflags[j] & CODECS_FLAG_FLIP) + if (!(sh->codec->outflags[j] & CODECS_FLAG_NOFLIP)) + opts->flip = 1; } - if(vo_flags&VFCAP_FLIPPED) flip^=1; - if(flip && !(vo_flags&VFCAP_FLIP)){ - // we need to flip, but no flipping filter avail. - vf_add_before_vo(&vf, "flip", NULL); - sh->vfilter = vf; + if (sh->output_flags & VFCAP_FLIPPED) + opts->flip ^= 1; + if (opts->flip && !(sh->output_flags & VFCAP_FLIP)) { + // we need to flip, but no flipping filter avail. + vf_add_before_vo(&vf, "flip", NULL); + sh->vfilter = vf; } - // time to do aspect ratio corrections... - if(movie_aspect>-1.0) sh->aspect = movie_aspect; // cmdline overrides autodetect - else if(sh->stream_aspect!=0.0) sh->aspect = sh->stream_aspect; -// if(!sh->aspect) sh->aspect=1.0; - - if(opt_screen_size_x||opt_screen_size_y){ - screen_size_x = opt_screen_size_x; - screen_size_y = opt_screen_size_y; - if(!vidmode){ - if(!screen_size_x) screen_size_x=SCREEN_SIZE_X; - if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y; - if(screen_size_x<=8) screen_size_x*=sh->disp_w; - if(screen_size_y<=8) screen_size_y*=sh->disp_h; - } - } else { - // check source format aspect, calculate prescale ::atmos - screen_size_x=sh->disp_w; - screen_size_y=sh->disp_h; - if(screen_size_xy>=0.001){ - if(screen_size_xy<=8){ - // -xy means x+y scale - screen_size_x*=screen_size_xy; - screen_size_y*=screen_size_xy; - } else { - // -xy means forced width while keeping correct aspect - screen_size_x=screen_size_xy; - screen_size_y=screen_size_xy*sh->disp_h/sh->disp_w; - } - } - if(sh->aspect>0.01){ - int w; - mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MovieAspectIsSet,sh->aspect); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect); - w=(int)((float)screen_size_y*sh->aspect); w+=w%2; // round - // we don't like horizontal downscale || user forced width: - if(w<screen_size_x || screen_size_xy>8){ - screen_size_y=(int)((float)screen_size_x*(1.0/sh->aspect)); - screen_size_y+=screen_size_y%2; // round - } else screen_size_x=w; // keep new width + if (opts->movie_aspect > -1.0) + sh->aspect = opts->movie_aspect; // cmdline overrides autodetect + else if (sh->stream_aspect != 0.0) + sh->aspect = sh->stream_aspect; + + if (opts->screen_size_x || opts->screen_size_y) { + screen_size_x = opts->screen_size_x; + screen_size_y = opts->screen_size_y; + if (!opts->vidmode) { + if (!screen_size_x) + screen_size_x = 1; + if (!screen_size_y) + screen_size_y = 1; + if (screen_size_x <= 8) + screen_size_x *= sh->disp_w; + if (screen_size_y <= 8) + screen_size_y *= sh->disp_h; + } } else { - mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MovieAspectUndefined); + // check source format aspect, calculate prescale ::atmos + screen_size_x = sh->disp_w; + screen_size_y = sh->disp_h; + if (opts->screen_size_xy >= 0.001) { + if (opts->screen_size_xy <= 8) { + // -xy means x+y scale + screen_size_x *= opts->screen_size_xy; + screen_size_y *= opts->screen_size_xy; + } else { + // -xy means forced width while keeping correct aspect + screen_size_x = opts->screen_size_xy; + screen_size_y = opts->screen_size_xy * sh->disp_h / sh->disp_w; + } + } + if (sh->aspect > 0.01) { + int w; + mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n", + sh->aspect); + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", + sh->aspect); + w = (int) ((float) screen_size_y * sh->aspect); + w += w % 2; // round + // we don't like horizontal downscale || user forced width: + if (w < screen_size_x || opts->screen_size_xy > 8) { + screen_size_y = + (int) ((float) screen_size_x * (1.0 / sh->aspect)); + screen_size_y += screen_size_y % 2; // round + } else + screen_size_x = w; // keep new width + } else { + mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Movie-Aspect is undefined - no prescaling applied.\n"); + } } - } - vocfg_flags = (fullscreen ? VOFLAG_FULLSCREEN:0) - | (vidmode ? VOFLAG_MODESWITCHING:0) - | (softzoom ? VOFLAG_SWSCALE:0) - | (flip ? VOFLAG_FLIPPING:0); + vocfg_flags = (opts->fullscreen ? VOFLAG_FULLSCREEN : 0) + | (opts->vidmode ? VOFLAG_MODESWITCHING : 0) + | (opts->softzoom ? VOFLAG_SWSCALE : 0) + | (opts->flip ? VOFLAG_FLIPPING : 0); // Time to config libvo! - mp_msg(MSGT_CPLAYER,MSGL_V,"VO Config (%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", - sh->disp_w,sh->disp_h, - screen_size_x,screen_size_y, - vocfg_flags, - "MPlayer",out_fmt); + mp_msg(MSGT_CPLAYER, MSGL_V, + "VO Config (%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", sh->disp_w, + sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, "MPlayer", + out_fmt); vf->w = sh->disp_w; vf->h = sh->disp_h; - if(vf_config_wrapper(vf,sh->disp_w,sh->disp_h, - screen_size_x,screen_size_y, - vocfg_flags, - out_fmt)==0){ -// "MPlayer",out_fmt)){ - mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_CannotInitVO); - sh->vf_initialized=-1; - return 0; + if (vf_config_wrapper + (vf, sh->disp_w, sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, + out_fmt) == 0) { + mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "FATAL: Cannot initialize video driver.\n"); + sh->vf_initialized = -1; + return 0; } - sh->vf_initialized=1; + sh->vf_initialized = 1; - if (vo_gamma_gamma != 1000) - set_video_colors(sh, "gamma", vo_gamma_gamma); - if (vo_gamma_brightness != 1000) - set_video_colors(sh, "brightness", vo_gamma_brightness); - if (vo_gamma_contrast != 1000) - set_video_colors(sh, "contrast", vo_gamma_contrast); - if (vo_gamma_saturation != 1000) - set_video_colors(sh, "saturation", vo_gamma_saturation); - if (vo_gamma_hue != 1000) - set_video_colors(sh, "hue", vo_gamma_hue); + if (opts->vo_gamma_gamma != 1000) + set_video_colors(sh, "gamma", opts->vo_gamma_gamma); + if (opts->vo_gamma_brightness != 1000) + set_video_colors(sh, "brightness", opts->vo_gamma_brightness); + if (opts->vo_gamma_contrast != 1000) + set_video_colors(sh, "contrast", opts->vo_gamma_contrast); + if (opts->vo_gamma_saturation != 1000) + set_video_colors(sh, "saturation", opts->vo_gamma_saturation); + if (opts->vo_gamma_hue != 1000) + set_video_colors(sh, "hue", opts->vo_gamma_hue); return 1; } @@ -361,15 +359,22 @@ csp_again: // mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h // returns NULL or allocated mp_image_t* // Note: buffer allocation may be moved to mpcodecs_config_vo() later... -mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h){ - mp_image_t* mpi=vf_get_image(sh->vfilter,sh->codec->outfmt[sh->outfmtidx],mp_imgtype,mp_imgflag,w,h); - if (mpi) mpi->x=mpi->y=0; - return mpi; +mp_image_t *mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, + int w, int h) +{ + mp_image_t *mpi = + vf_get_image(sh->vfilter, sh->codec->outfmt[sh->outfmtidx], mp_imgtype, + mp_imgflag, w, h); + if (mpi) + mpi->x = mpi->y = 0; + return mpi; } -void mpcodecs_draw_slice(sh_video_t *sh, unsigned char** src, int* stride, int w,int h, int x, int y) { - struct vf_instance_s* vf = sh->vfilter; +void mpcodecs_draw_slice(sh_video_t *sh, unsigned char **src, int *stride, + int w, int h, int x, int y) +{ + struct vf_instance *vf = sh->vfilter; - if(vf->draw_slice) - vf->draw_slice(vf,src,stride,w,h,x,y); + if (vf->draw_slice) + vf->draw_slice(vf, src, stride, w, h, x, y); } diff --git a/libmpcodecs/vd.h b/libmpcodecs/vd.h index b033513664..4615a9dc6e 100644 --- a/libmpcodecs/vd.h +++ b/libmpcodecs/vd.h @@ -26,20 +26,20 @@ typedef mp_codec_info_t vd_info_t; /* interface of video decoder drivers */ -typedef struct vd_functions_s +typedef struct vd_functions { - vd_info_t *info; + const vd_info_t *info; int (*init)(sh_video_t *sh); void (*uninit)(sh_video_t *sh); int (*control)(sh_video_t *sh,int cmd,void* arg, ...); mp_image_t* (*decode)(sh_video_t *sh,void* data,int len,int flags); + struct mp_image *(*decode2)(struct sh_video *sh, void *data, int len, + int flags, double *reordered_pts); } vd_functions_t; // NULL terminated array of all drivers extern const vd_functions_t * const mpcodecs_vd_drivers[]; -extern int vd_use_slices; - #define VDCTRL_QUERY_FORMAT 3 /* test for availabilty of a format */ #define VDCTRL_QUERY_MAX_PP_LEVEL 4 /* test for postprocessing support (max level) */ #define VDCTRL_SET_PP_LEVEL 5 /* set postprocessing level */ diff --git a/libmpcodecs/vd_dmo.c b/libmpcodecs/vd_dmo.c index 830f304057..217fd05725 100644 --- a/libmpcodecs/vd_dmo.c +++ b/libmpcodecs/vd_dmo.c @@ -29,7 +29,7 @@ #include "loader/dmo/DMO_VideoDecoder.h" -static vd_info_t info = { +static const vd_info_t info = { "DMO video codecs", "dmo", "A'rpi", @@ -48,8 +48,8 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){ static int init(sh_video_t *sh){ unsigned int out_fmt; if(!(sh->context=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){ - mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll); - mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage); + mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll); + mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n"); return 0; } if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; @@ -68,7 +68,7 @@ static int init(sh_video_t *sh){ DMO_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR } DMO_VideoDecoder_StartInternal(sh->context); - mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DMOInitOK); + mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO video codec init OK.\n"); return 1; } @@ -94,7 +94,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ sh->disp_w, sh->disp_h); if(!mpi){ // temporary! - mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec); + mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n"); return NULL; } diff --git a/libmpcodecs/vd_dshow.c b/libmpcodecs/vd_dshow.c index c50b0e7f80..f75294eecc 100644 --- a/libmpcodecs/vd_dshow.c +++ b/libmpcodecs/vd_dshow.c @@ -29,7 +29,7 @@ #include "loader/dshow/DS_VideoDecoder.h" -static vd_info_t info = { +static const vd_info_t info = { "DirectShow video codecs", "dshow", "A'rpi", @@ -76,8 +76,8 @@ static int init(sh_video_t *sh){ return 0; if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){ - mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll); - mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage); + mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll); + mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n"); return 0; } if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; @@ -97,7 +97,7 @@ static int init(sh_video_t *sh){ } DS_SetAttr_DivX("Quality",divx_quality); DS_VideoDecoder_StartInternal(sh->context); - mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DShowInitOK); + mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK.\n"); return 1; } @@ -123,7 +123,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ sh->disp_w, sh->disp_h); if(!mpi){ // temporary! - mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec); + mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n"); return NULL; } diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index 910dd447ae..83fe050051 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -20,20 +20,25 @@ #include <stdlib.h> #include <assert.h> #include <time.h> +#include <stdbool.h> #include "config.h" #include "mp_msg.h" #include "help_mp.h" +#include "options.h" #include "av_opts.h" #include "libavutil/common.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" #include "mpbswap.h" #include "fmt-conversion.h" -#include "vd_internal.h" +#include "vd.h" +#include "img_format.h" +#include "libmpdemux/stheader.h" +#include "codec-cfg.h" -static vd_info_t info = { +static const vd_info_t info = { "FFmpeg's libavcodec codec family", "ffmpeg", "A'rpi", @@ -41,8 +46,6 @@ static vd_info_t info = { "native codecs" }; -LIBVD_EXTERN(ffmpeg) - #include "libavcodec/avcodec.h" #if AVPALETTE_SIZE > 1024 @@ -71,57 +74,39 @@ typedef struct { int ip_count; int b_count; AVRational last_sample_aspect_ratio; + int lowres; } vd_ffmpeg_ctx; #include "m_option.h" static int get_buffer(AVCodecContext *avctx, AVFrame *pic); static void release_buffer(AVCodecContext *avctx, AVFrame *pic); -static void draw_slice(struct AVCodecContext *s, const AVFrame *src, int offset[4], - int y, int type, int height); +static void draw_slice(struct AVCodecContext *s, const AVFrame *src, + int offset[4], int y, int type, int height); static enum PixelFormat get_format(struct AVCodecContext *avctx, const enum PixelFormat *pix_fmt); - -static int lavc_param_workaround_bugs= FF_BUG_AUTODETECT; -static int lavc_param_error_resilience=2; -static int lavc_param_error_concealment=3; -static int lavc_param_gray=0; -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_fast=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 int lavc_param_bitexact=0; -static char *lavc_avopt = NULL; +static void uninit(struct sh_video *sh); const m_option_t lavc_decode_opts_conf[]={ - {"bug", &lavc_param_workaround_bugs, CONF_TYPE_INT, CONF_RANGE, -1, 999999, NULL}, - {"er", &lavc_param_error_resilience, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL}, - {"gray", &lavc_param_gray, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART, NULL}, - {"idct", &lavc_param_idct_algo, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL}, - {"ec", &lavc_param_error_concealment, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL}, - {"vstats", &lavc_param_vstats, CONF_TYPE_FLAG, 0, 0, 1, NULL}, - {"debug", &lavc_param_debug, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, NULL}, - {"vismv", &lavc_param_vismv, CONF_TYPE_INT, CONF_RANGE, 0, 9999999, NULL}, - {"st", &lavc_param_skip_top, CONF_TYPE_INT, CONF_RANGE, 0, 999, NULL}, - {"sb", &lavc_param_skip_bottom, CONF_TYPE_INT, CONF_RANGE, 0, 999, NULL}, - {"fast", &lavc_param_fast, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG2_FAST, NULL}, - {"lowres", &lavc_param_lowres_str, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"skiploopfilter", &lavc_param_skip_loop_filter_str, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"skipidct", &lavc_param_skip_idct_str, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"skipframe", &lavc_param_skip_frame_str, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"threads", &lavc_param_threads, CONF_TYPE_INT, CONF_RANGE, 1, 8, NULL}, - {"bitexact", &lavc_param_bitexact, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_BITEXACT, NULL}, - {"o", &lavc_avopt, CONF_TYPE_STRING, 0, 0, 0, NULL}, + OPT_INTRANGE("bug", lavc_param.workaround_bugs, 0, -1, 999999), + OPT_INTRANGE("er", lavc_param.error_resilience, 0, 0, 99), + OPT_FLAG_ON("gray", lavc_param.gray, 0), + OPT_INTRANGE("idct", lavc_param.idct_algo, 0, 0, 99), + OPT_INTRANGE("ec", lavc_param.error_concealment, 0, 0, 99), + OPT_FLAG_ON("vstats", lavc_param.vstats, 0), + OPT_INTRANGE("debug", lavc_param.debug, 0, 0, 9999999), + OPT_INTRANGE("vismv", lavc_param.vismv, 0, 0, 9999999), + OPT_INTRANGE("st", lavc_param.skip_top, 0, 0, 999), + OPT_INTRANGE("sb", lavc_param.skip_bottom, 0, 0, 999), + OPT_FLAG_CONSTANTS("fast", lavc_param.fast, 0, 0, CODEC_FLAG2_FAST), + OPT_STRING("lowres", lavc_param.lowres_str, 0), + OPT_STRING("skiploopfilter", lavc_param.skip_loop_filter_str, 0), + OPT_STRING("skipidct", lavc_param.skip_idct_str, 0), + OPT_STRING("skipframe", lavc_param.skip_frame_str, 0), + OPT_INTRANGE("threads", lavc_param.threads, 0, 1, 8), + OPT_FLAG_CONSTANTS("bitexact", lavc_param.bitexact, 0, 0, CODEC_FLAG_BITEXACT), + OPT_STRING("o", lavc_param.avopt, 0), {NULL, NULL, 0, 0, 0, 0, NULL} }; @@ -166,96 +151,32 @@ static int control(sh_video_t *sh, int cmd, void *arg, ...){ case VDCTRL_RESYNC_STREAM: avcodec_flush_buffers(avctx); return CONTROL_TRUE; - case VDCTRL_QUERY_UNSEEN_FRAMES: - return avctx->has_b_frames + 10; - } - return CONTROL_UNKNOWN; -} - -void mp_msp_av_log_callback(void *ptr, int level, const char *fmt, va_list vl) -{ - static int print_prefix=1; - AVClass *avc= ptr ? *(AVClass **)ptr : NULL; - int type= MSGT_FIXME; - int mp_level; - char buf[256]; - - switch(level){ - case AV_LOG_VERBOSE: mp_level = MSGL_V ; break; - case AV_LOG_DEBUG: mp_level= MSGL_V ; break; - case AV_LOG_INFO : mp_level= MSGL_INFO; break; - case AV_LOG_ERROR: mp_level= MSGL_ERR ; break; - default : mp_level= MSGL_ERR ; break; - } - - if (!mp_msg_test(type, mp_level)) return; - - if(ptr){ - if(!strcmp(avc->class_name, "AVCodecContext")){ - AVCodecContext *s= ptr; - if(s->codec){ - if(s->codec->type == CODEC_TYPE_AUDIO){ - if(s->codec->decode) - type= MSGT_DECAUDIO; - }else if(s->codec->type == CODEC_TYPE_VIDEO){ - if(s->codec->decode) - type= MSGT_DECVIDEO; - } - //FIXME subtitles, encoders (what msgt for them? there is no appropriate ...) - } - }else if(!strcmp(avc->class_name, "AVFormatContext")){ -#if 0 //needs libavformat include FIXME iam too lazy to do this cleanly, probably the whole should be moved out of this file ... - AVFormatContext *s= ptr; - if(s->iformat) - type= MSGT_DEMUXER; - else if(s->oformat) - type= MSGT_MUXER; + case VDCTRL_QUERY_UNSEEN_FRAMES:; + int delay = avctx->has_b_frames; +#if defined(FF_THREAD_FRAME) && LIBAVCODEC_VERSION_MAJOR <= 52 && LIBAVCODEC_VERSION_MINOR < 49 + // FFmpeg-mt has extra delay when using frame threading + // In newer versions that is included in has_b_frames + if (avctx->thread_type & FF_THREAD_FRAME) + delay += avctx->thread_count - 1; #endif - } - } - - if(print_prefix && avc) { - mp_msg(type, mp_level, "[%s @ %p]", avc->item_name(ptr), avc); - } - - print_prefix= strchr(fmt, '\n') != NULL; - vsnprintf(buf, sizeof(buf), fmt, vl); - mp_msg(type, mp_level, buf); -} - -static void set_format_params(struct AVCodecContext *avctx, enum PixelFormat fmt){ - int imgfmt; - if (fmt == PIX_FMT_NONE) - return; - imgfmt = pixfmt2imgfmt(fmt); - if (IMGFMT_IS_XVMC(imgfmt) || IMGFMT_IS_VDPAU(imgfmt)) { - sh_video_t *sh = avctx->opaque; - vd_ffmpeg_ctx *ctx = sh->context; - ctx->do_dr1 = 1; - ctx->do_slices = 1; - avctx->thread_count = 1; - avctx->get_buffer = get_buffer; - avctx->release_buffer = release_buffer; - avctx->reget_buffer = get_buffer; - avctx->draw_horiz_band = draw_slice; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedMPEG2); - avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; + return delay + 10; } + return CONTROL_UNKNOWN; } // init driver static int init(sh_video_t *sh){ + struct lavc_param *lavc_param = &sh->opts->lavc_param; AVCodecContext *avctx; vd_ffmpeg_ctx *ctx; AVCodec *lavc_codec; int lowres_w=0; - int do_vis_debug= lavc_param_vismv || (lavc_param_debug&(FF_DEBUG_VIS_MB_TYPE|FF_DEBUG_VIS_QP)); + int do_vis_debug= lavc_param->vismv || (lavc_param->debug&(FF_DEBUG_VIS_MB_TYPE|FF_DEBUG_VIS_QP)); if(!avcodec_initialized){ avcodec_init(); avcodec_register_all(); avcodec_initialized=1; - av_log_set_callback(mp_msp_av_log_callback); } ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx)); @@ -265,12 +186,12 @@ static int init(sh_video_t *sh){ lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll); if(!lavc_codec){ - mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_MissingLAVCcodec, sh->codec->dll); + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Cannot find codec '%s' in libavcodec...\n", sh->codec->dll); uninit(sh); return 0; } - if(vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug) + if(sh->opts->vd_use_slices && (lavc_codec->capabilities&CODEC_CAP_DRAW_HORIZ_BAND) && !do_vis_debug) ctx->do_slices=1; if(lavc_codec->capabilities&CODEC_CAP_DR1 && !do_vis_debug && lavc_codec->id != CODEC_ID_H264 && lavc_codec->id != CODEC_ID_INTERPLAY_VIDEO && lavc_codec->id != CODEC_ID_ROQ) @@ -285,19 +206,32 @@ static int init(sh_video_t *sh){ avctx->codec_type = CODEC_TYPE_VIDEO; avctx->codec_id = lavc_codec->id; -#if CONFIG_VDPAU - if(lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU){ - avctx->get_format = get_format; + if (lavc_codec->capabilities & CODEC_CAP_HWACCEL // XvMC + || lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) { + ctx->do_dr1 = true; + ctx->do_slices = true; + lavc_param->threads = 1; + avctx->get_format = get_format; + avctx->get_buffer = get_buffer; + avctx->release_buffer = release_buffer; + avctx->reget_buffer = get_buffer; + avctx->draw_horiz_band = draw_slice; + if (lavc_codec->capabilities & CODEC_CAP_HWACCEL) + mp_msg(MSGT_DECVIDEO, MSGL_V, "[VD_FFMPEG] XVMC-accelerated " + "MPEG-2.\n"); + if (lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) + mp_msg(MSGT_DECVIDEO, MSGL_V, "[VD_FFMPEG] VDPAU hardware " + "decoding.\n"); + avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; } -#endif /* CONFIG_VDPAU */ -#if CONFIG_XVMC - if(lavc_codec->capabilities & CODEC_CAP_HWACCEL){ - mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_XVMCAcceleratedCodec); - avctx->get_format= get_format;//for now only this decoder will use it - // HACK around badly placed checks in mpeg_mc_decode_init - set_format_params(avctx, PIX_FMT_XVMC_MPEG2_IDCT); + + /* Our get_buffer and draw_horiz_band callbacks are not safe to call + * from other threads. */ + if (lavc_param->threads > 1) { + ctx->do_dr1 = false; + ctx->do_slices = false; } -#endif /* CONFIG_XVMC */ + if(ctx->do_dr1){ avctx->flags|= CODEC_FLAG_EMU_EDGE; avctx->get_buffer= get_buffer; @@ -305,38 +239,38 @@ static int init(sh_video_t *sh){ avctx->reget_buffer= get_buffer; } - avctx->flags|= lavc_param_bitexact; + avctx->flags|= lavc_param->bitexact; avctx->width = sh->disp_w; avctx->height= sh->disp_h; - avctx->workaround_bugs= lavc_param_workaround_bugs; - avctx->error_recognition= lavc_param_error_resilience; - if(lavc_param_gray) avctx->flags|= CODEC_FLAG_GRAY; - avctx->flags2|= lavc_param_fast; + avctx->workaround_bugs= lavc_param->workaround_bugs; + avctx->error_recognition= lavc_param->error_resilience; + if(lavc_param->gray) avctx->flags|= CODEC_FLAG_GRAY; + avctx->flags2|= lavc_param->fast; avctx->codec_tag= sh->format; avctx->stream_codec_tag= sh->video.fccHandler; - avctx->idct_algo= lavc_param_idct_algo; - avctx->error_concealment= lavc_param_error_concealment; - avctx->debug= lavc_param_debug; - if (lavc_param_debug) + avctx->idct_algo= lavc_param->idct_algo; + avctx->error_concealment= lavc_param->error_concealment; + avctx->debug= lavc_param->debug; + if (lavc_param->debug) av_log_set_level(AV_LOG_DEBUG); - avctx->debug_mv= lavc_param_vismv; - avctx->skip_top = lavc_param_skip_top; - avctx->skip_bottom= lavc_param_skip_bottom; - if(lavc_param_lowres_str != NULL) + avctx->debug_mv= lavc_param->vismv; + avctx->skip_top = lavc_param->skip_top; + avctx->skip_bottom= lavc_param->skip_bottom; + if(lavc_param->lowres_str != NULL) { - sscanf(lavc_param_lowres_str, "%d,%d", &lavc_param_lowres, &lowres_w); - if(lavc_param_lowres < 1 || lavc_param_lowres > 16 || (lowres_w > 0 && avctx->width < lowres_w)) - lavc_param_lowres = 0; - avctx->lowres = lavc_param_lowres; - } - avctx->skip_loop_filter = str2AVDiscard(lavc_param_skip_loop_filter_str); - avctx->skip_idct = str2AVDiscard(lavc_param_skip_idct_str); - avctx->skip_frame = str2AVDiscard(lavc_param_skip_frame_str); - - if(lavc_avopt){ - if(parse_avopts(avctx, lavc_avopt) < 0){ - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", lavc_avopt); + sscanf(lavc_param->lowres_str, "%d,%d", &ctx->lowres, &lowres_w); + if(ctx->lowres < 1 || ctx->lowres > 16 || (lowres_w > 0 && avctx->width < lowres_w)) + ctx->lowres = 0; + avctx->lowres = ctx->lowres; + } + avctx->skip_loop_filter = str2AVDiscard(lavc_param->skip_loop_filter_str); + avctx->skip_idct = str2AVDiscard(lavc_param->skip_idct_str); + avctx->skip_frame = str2AVDiscard(lavc_param->skip_frame_str); + + if(lavc_param->avopt){ + if(parse_avopts(avctx, lavc_param->avopt) < 0){ + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", lavc_param->avopt); uninit(sh); return 0; } @@ -428,17 +362,14 @@ static int init(sh_video_t *sh){ if(sh->bih) avctx->bits_per_coded_sample= sh->bih->biBitCount; - if(lavc_param_threads > 1) - avcodec_thread_init(avctx, lavc_param_threads); + if(lavc_param->threads > 1) + avcodec_thread_init(avctx, lavc_param->threads); /* open it */ if (avcodec_open(avctx, lavc_codec) < 0) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantOpenCodec); + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n"); uninit(sh); return 0; } - // this is necessary in case get_format was never called and init_vo is - // too late e.g. for H.264 VDPAU - set_format_params(avctx, avctx->pix_fmt); mp_msg(MSGT_DECVIDEO, MSGL_V, "INFO: libavcodec init OK!\n"); return 1; //mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_YV12); } @@ -448,12 +379,12 @@ static void uninit(sh_video_t *sh){ vd_ffmpeg_ctx *ctx = sh->context; AVCodecContext *avctx = ctx->avctx; - if(lavc_param_vstats){ + if(sh->opts->lavc_param.vstats){ int i; for(i=1; i<32; i++){ mp_msg(MSGT_DECVIDEO, MSGL_INFO, "QP: %d, count: %d\n", i, ctx->qp_stat[i]); } - mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_ArithmeticMeanOfQP, + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[VD_FFMPEG] Arithmetic mean of QP: %2.4f, Harmonic mean of QP: %2.4f\n", ctx->qp_sum / avctx->coded_frame->coded_picture_number, 1.0/(ctx->inv_qp_sum / avctx->coded_frame->coded_picture_number) ); @@ -461,7 +392,7 @@ static void uninit(sh_video_t *sh){ if (avctx) { if (avctx->codec && avcodec_close(avctx) < 0) - mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec); + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n"); av_freep(&avctx->extradata); av_freep(&avctx->palctrl); @@ -475,14 +406,15 @@ static void uninit(sh_video_t *sh){ } static void draw_slice(struct AVCodecContext *s, - const AVFrame *src, int offset[4], - int y, int type, int height){ + const AVFrame *src, int offset[4], + int y, int type, int height){ sh_video_t *sh = s->opaque; uint8_t *source[MP_MAX_PLANES]= {src->data[0] + offset[0], src->data[1] + offset[1], src->data[2] + offset[2]}; #if 0 int start=0, i; int width= s->width; - int skip_stride= ((width<<lavc_param_lowres)+15)>>4; + vd_ffmpeg_ctx *ctx = sh->context; + int skip_stride= ((width << ctx->lowres)+15)>>4; uint8_t *skip= &s->coded_frame->mbskip_table[(y>>4)*skip_stride]; int threshold= s->coded_frame->age; if(s->pict_type!=B_TYPE){ @@ -520,8 +452,8 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt){ // if sh->ImageDesc is non-NULL, it means we decode QuickTime(tm) video. // use dimensions from BIH to avoid black borders at the right and bottom. if (sh->bih && sh->ImageDesc) { - width = sh->bih->biWidth>>lavc_param_lowres; - height = sh->bih->biHeight>>lavc_param_lowres; + width = sh->bih->biWidth >> ctx->lowres; + height = sh->bih->biHeight >> ctx->lowres; } // it is possible another vo buffers to be used after vo config() @@ -532,9 +464,6 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt){ pix_fmt != ctx->pix_fmt || !ctx->vo_initialized) { - // this is a special-case HACK for MPEG-1/2 VDPAU that uses neither get_format nor - // sets the value correctly in avcodec_open. - set_format_params(avctx, avctx->pix_fmt); mp_msg(MSGT_DECVIDEO, MSGL_V, "[ffmpeg] aspect_ratio: %f\n", aspect); if (sh->aspect == 0 || av_cmp_q(avctx->sample_aspect_ratio, @@ -602,7 +531,7 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){ } else if (!pic->buffer_hints) { if(ctx->b_count>1 || ctx->ip_count>2){ - mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_DRIFailure); + mp_tmsg(MSGT_DECVIDEO, MSGL_WARN, "[VD_FFMPEG] DRI failure.\n"); ctx->do_dr1=0; //FIXME avctx->get_buffer= avcodec_default_get_buffer; @@ -637,13 +566,13 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){ struct xvmc_pix_fmt *render = mpi->priv; //same as data[2] avctx->draw_horiz_band= draw_slice; if(!avctx->xvmc_acceleration) { - mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_McGetBufferShouldWorkOnlyWithXVMC); + mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "[VD_FFMPEG] The mc_get_buffer should work only with XVMC acceleration!!"); assert(0); exit(1); // return -1;//!!fixme check error conditions in ffmpeg } if(!(mpi->flags & MP_IMGFLAG_DIRECT)) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_MPCODECS_OnlyBuffersAllocatedByVoXvmcAllowed); + mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "[VD_FFMPEG] Only buffers allocated by vo_xvmc allowed.\n"); assert(0); exit(1); // return -1;//!!fixme check error conditions in ffmpeg @@ -710,6 +639,13 @@ else ctx->b_age=1; } pic->type= FF_BUFFER_TYPE_USER; + + /* The libavcodec reordered_opaque functionality is implemented by + * a similar copy in avcodec_default_get_buffer() and without a + * workaround like this it'd stop working when a custom buffer + * callback is used. + */ + pic->reordered_opaque = avctx->reordered_opaque; return 0; } @@ -766,7 +702,7 @@ typedef struct dp_hdr_s { uint32_t chunktab; // offset to chunk offset array } dp_hdr_t; -void swap_palette(void *pal) { +static void swap_palette(void *pal) { int i; uint32_t *p = pal; for (i = 0; i < AVPALETTE_COUNT; i++) @@ -774,12 +710,15 @@ void swap_palette(void *pal) { } // decode a frame -static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ +static struct mp_image *decode(struct sh_video *sh, void *data, int len, + int flags, double *reordered_pts) +{ int got_picture=0; int ret; vd_ffmpeg_ctx *ctx = sh->context; AVFrame *pic= ctx->pic; AVCodecContext *avctx = ctx->avctx; + struct lavc_param *lavc_param = &sh->opts->lavc_param; mp_image_t *mpi=NULL; int dr1= ctx->do_dr1; AVPacket pkt; @@ -808,13 +747,16 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ pkt.size = len; // HACK: make PNGs decode normally instead of as CorePNG delta frames pkt.flags = PKT_FLAG_KEY; + // The avcodec opaque field stupidly supports only int64_t type + *(double *)&avctx->reordered_opaque = *reordered_pts; ret = avcodec_decode_video2(avctx, pic, &got_picture, &pkt); + *reordered_pts = *(double *)&pic->reordered_opaque; dr1= ctx->do_dr1; if(ret<0) mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error while decoding frame!\n"); //printf("repeat: %d\n", pic->repeat_pict); //-- vstats generation - while(lavc_param_vstats){ // always one time loop + while(lavc_param->vstats){ // always one time loop static FILE *fvstats=NULL; char filename[20]; static long long int all_len=0; @@ -833,7 +775,7 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ fvstats = fopen(filename, "w"); if(!fvstats) { perror("fopen"); - lavc_param_vstats=0; // disable block + lavc_param->vstats=0; // disable block break; /*exit(1);*/ } @@ -842,8 +784,8 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ // average MB quantizer { int x, y; - int w = ((avctx->width << lavc_param_lowres)+15) >> 4; - int h = ((avctx->height << lavc_param_lowres)+15) >> 4; + int w = ((avctx->width << ctx->lowres)+15) >> 4; + int h = ((avctx->height << ctx->lowres)+15) >> 4; int8_t *q = pic->qscale_table; for(y = 0; y < h; y++) { for(x = 0; x < w; x++) @@ -898,7 +840,7 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, avctx->width, avctx->height); if(!mpi){ // temporary! - mp_msg(MSGT_DECVIDEO, MSGL_WARN, MSGTR_MPCODECS_CouldntAllocateImageForCodec); + mp_tmsg(MSGT_DECVIDEO, MSGL_WARN, "[VD_FFMPEG] Couldn't allocate image for codec.\n"); return NULL; } @@ -940,7 +882,6 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ return mpi; } -#if CONFIG_XVMC || CONFIG_VDPAU static enum PixelFormat get_format(struct AVCodecContext *avctx, const enum PixelFormat *fmt){ enum PixelFormat selected_format; @@ -951,13 +892,19 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx, for(i=0;fmt[i]!=PIX_FMT_NONE;i++){ imgfmt = pixfmt2imgfmt(fmt[i]); if(!IMGFMT_IS_XVMC(imgfmt) && !IMGFMT_IS_VDPAU(imgfmt)) continue; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_TryingPixfmt, i); + mp_msg(MSGT_DECVIDEO, MSGL_V, "[VD_FFMPEG] Trying pixfmt=%d.\n", i); if(init_vo(sh, fmt[i]) >= 0) { break; } } selected_format = fmt[i]; - set_format_params(avctx, selected_format); return selected_format; } -#endif /* CONFIG_XVMC || CONFIG_VDPAU */ + +const struct vd_functions mpcodecs_vd_ffmpeg = { + .info = &info, + .init = init, + .uninit = uninit, + .control = control, + .decode2 = decode +}; diff --git a/libmpcodecs/vd_hmblck.c b/libmpcodecs/vd_hmblck.c index e689daafe6..81b1c4373b 100644 --- a/libmpcodecs/vd_hmblck.c +++ b/libmpcodecs/vd_hmblck.c @@ -26,7 +26,7 @@ #define TEMP_BUF_SIZE (720*576) -static vd_info_t info = { +static const vd_info_t info = { "Hauppauge Macroblock/NV12/NV21 Decoder", "hmblck", "Alex <d18c7db@hotmail.com>, A'rpi, Alex Beregszaszi", diff --git a/libmpcodecs/vd_ijpg.c b/libmpcodecs/vd_ijpg.c index f4214a36a6..e1b8766f7e 100644 --- a/libmpcodecs/vd_ijpg.c +++ b/libmpcodecs/vd_ijpg.c @@ -33,7 +33,7 @@ #include "vd_internal.h" -static vd_info_t info = { +static const vd_info_t info = { "JPEG Images decoder", "ijpg", "Pontscho", @@ -110,7 +110,7 @@ METHODDEF(void) skip_input_data (j_decompress_ptr cinfo, long num_bytes) METHODDEF(void) term_source (j_decompress_ptr cinfo) { } -GLOBAL(void) jpeg_buf_src ( j_decompress_ptr cinfo, char * inbuf,int bufsize ) +static void jpeg_buf_src ( j_decompress_ptr cinfo, char * inbuf,int bufsize ) { my_src_ptr src; if (cinfo->src == NULL) cinfo->src=malloc( sizeof( my_source_mgr ) ); diff --git a/libmpcodecs/vd_internal.h b/libmpcodecs/vd_internal.h index 58693439c4..b4d74a6a48 100644 --- a/libmpcodecs/vd_internal.h +++ b/libmpcodecs/vd_internal.h @@ -37,7 +37,7 @@ static int init(sh_video_t *sh); static void uninit(sh_video_t *sh); static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags); -#define LIBVD_EXTERN(x) vd_functions_t mpcodecs_vd_##x = {\ +#define LIBVD_EXTERN(x) const vd_functions_t mpcodecs_vd_##x = {\ &info,\ init,\ uninit,\ diff --git a/libmpcodecs/vd_libdv.c b/libmpcodecs/vd_libdv.c index 13a9f01ea8..02d7e2fc54 100644 --- a/libmpcodecs/vd_libdv.c +++ b/libmpcodecs/vd_libdv.c @@ -36,7 +36,7 @@ #include "vd_internal.h" -static vd_info_t info = +static const vd_info_t info = { "Raw DV Video Decoder", "libdv", diff --git a/libmpcodecs/vd_libmpeg2.c b/libmpcodecs/vd_libmpeg2.c index d7c009370b..2e9c0edf24 100644 --- a/libmpcodecs/vd_libmpeg2.c +++ b/libmpcodecs/vd_libmpeg2.c @@ -20,14 +20,14 @@ #include <stdlib.h> #include "config.h" - +#include "options.h" #include "mp_msg.h" #include "vd_internal.h" //#undef MPEG12_POSTPROC -static vd_info_t info = +static const vd_info_t info = { "libmpeg2 MPEG 1/2 Video decoder", "libmpeg2", @@ -237,7 +237,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ } mpeg2_skip(mpeg2dec, 0); //mpeg2skip skips frames until set again to 0 - use_callback = (!framedrop && vd_use_slices && + use_callback = (!framedrop && sh->opts->vd_use_slices && (info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME)) ? MP_IMGFLAG_DRAW_CALLBACK:0; diff --git a/libmpcodecs/vd_lzo.c b/libmpcodecs/vd_lzo.c index 1948388746..e8521bfb43 100644 --- a/libmpcodecs/vd_lzo.c +++ b/libmpcodecs/vd_lzo.c @@ -27,7 +27,7 @@ #define MOD_NAME "DecLZO" -static vd_info_t info = { +static const vd_info_t info = { "LZO compressed Video", "lzo", "Tilmann Bitterberg", diff --git a/libmpcodecs/vd_mpegpes.c b/libmpcodecs/vd_mpegpes.c index c6cca1a4f7..22060bfc60 100644 --- a/libmpcodecs/vd_mpegpes.c +++ b/libmpcodecs/vd_mpegpes.c @@ -25,7 +25,7 @@ #include "vd_internal.h" -static vd_info_t info = +static const vd_info_t info = { "MPEG 1/2 Video passthrough", "mpegpes", diff --git a/libmpcodecs/vd_mpng.c b/libmpcodecs/vd_mpng.c index 3c0f233146..919364742e 100644 --- a/libmpcodecs/vd_mpng.c +++ b/libmpcodecs/vd_mpng.c @@ -30,7 +30,7 @@ #include "vd_internal.h" -static vd_info_t info = { +static const vd_info_t info = { "PNG Images decoder", "mpng", "A'rpi", diff --git a/libmpcodecs/vd_mtga.c b/libmpcodecs/vd_mtga.c index 1b6c71636a..f6eee54cbe 100644 --- a/libmpcodecs/vd_mtga.c +++ b/libmpcodecs/vd_mtga.c @@ -34,7 +34,7 @@ #include "vd_internal.h" -static vd_info_t info = +static const vd_info_t info = { "TGA Images decoder", "mtga", @@ -249,4 +249,3 @@ static mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags) return mpi; } - diff --git a/libmpcodecs/vd_null.c b/libmpcodecs/vd_null.c index 7b3246f43e..894585b42f 100644 --- a/libmpcodecs/vd_null.c +++ b/libmpcodecs/vd_null.c @@ -24,7 +24,7 @@ #include "vd_internal.h" -static vd_info_t info = +static const vd_info_t info = { "Null video decoder", "null", @@ -54,4 +54,3 @@ static void uninit(sh_video_t *sh){ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ return NULL; } - diff --git a/libmpcodecs/vd_qtvideo.c b/libmpcodecs/vd_qtvideo.c index bf6ac9ee2c..5120f612b5 100644 --- a/libmpcodecs/vd_qtvideo.c +++ b/libmpcodecs/vd_qtvideo.c @@ -34,7 +34,7 @@ #include "loader/wine/windef.h" #endif -static vd_info_t info = { +static const vd_info_t info = { "Quicktime Video decoder", "qtvideo", "A'rpi", diff --git a/libmpcodecs/vd_raw.c b/libmpcodecs/vd_raw.c index d3da2008f3..4e8ccd1446 100644 --- a/libmpcodecs/vd_raw.c +++ b/libmpcodecs/vd_raw.c @@ -24,7 +24,7 @@ #include "vd_internal.h" -static vd_info_t info = { +static const vd_info_t info = { "RAW Uncompressed Video", "raw", "A'rpi", diff --git a/libmpcodecs/vd_realvid.c b/libmpcodecs/vd_realvid.c index 1e3129df30..6a50c484c7 100644 --- a/libmpcodecs/vd_realvid.c +++ b/libmpcodecs/vd_realvid.c @@ -32,7 +32,7 @@ #include "vd_internal.h" #include "loader/wine/windef.h" -static vd_info_t info = { +static const vd_info_t info = { "RealVideo decoder", "realvid", "Alex Beregszaszi", @@ -306,7 +306,7 @@ static int init(sh_video_t *sh){ if (!load_syms_windows(sh->codec->dll)) #endif { - mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll); + mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll); mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Read the RealVideo section of the DOCS!\n"); free(path); return 0; diff --git a/libmpcodecs/vd_sgi.c b/libmpcodecs/vd_sgi.c index 3e31d471a4..07dd8ff60d 100644 --- a/libmpcodecs/vd_sgi.c +++ b/libmpcodecs/vd_sgi.c @@ -37,7 +37,7 @@ #define OUT_PIXEL_STRIDE 3 /* RGB */ -static vd_info_t info = +static const vd_info_t info = { "SGI Image decoder", "sgi", @@ -341,4 +341,3 @@ mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags) return mpi; } - diff --git a/libmpcodecs/vd_theora.c b/libmpcodecs/vd_theora.c index 1b87b9fdcd..df4968cd1f 100644 --- a/libmpcodecs/vd_theora.c +++ b/libmpcodecs/vd_theora.c @@ -27,7 +27,7 @@ #include "vd_internal.h" -static vd_info_t info = { +static const vd_info_t info = { "Theora/VP3", "theora", "David Kuehling", diff --git a/libmpcodecs/vd_vfw.c b/libmpcodecs/vd_vfw.c index ebff457598..e9c5304dd8 100644 --- a/libmpcodecs/vd_vfw.c +++ b/libmpcodecs/vd_vfw.c @@ -28,7 +28,7 @@ #include "loader/wine/driver.h" #include "loader/wine/vfw.h" -static vd_info_t info = { +static const vd_info_t info = { #ifdef BUILD_VFWEX "Win32/VfWex video codecs", "vfwex", @@ -322,7 +322,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH, sh->disp_w, sh->disp_h); if(!mpi){ // temporary! - mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec); + mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n"); return NULL; } diff --git a/libmpcodecs/vd_xanim.c b/libmpcodecs/vd_xanim.c index a18f2b4d14..a7f98add49 100644 --- a/libmpcodecs/vd_xanim.c +++ b/libmpcodecs/vd_xanim.c @@ -34,7 +34,7 @@ #include "vd_internal.h" -static vd_info_t info = { +static const vd_info_t info = { "XAnim codecs", "xanim", "A'rpi & Alex", diff --git a/libmpcodecs/vd_xvid4.c b/libmpcodecs/vd_xvid4.c index bf12ab12f0..62eab8c3ed 100644 --- a/libmpcodecs/vd_xvid4.c +++ b/libmpcodecs/vd_xvid4.c @@ -378,7 +378,7 @@ static float stats2aspect(xvid_dec_stats_t *stats) * Module structure definition ****************************************************************************/ -static vd_info_t info = +static const vd_info_t info = { "XviD 1.0 decoder", "xvid", diff --git a/libmpcodecs/vd_zrmjpeg.c b/libmpcodecs/vd_zrmjpeg.c index ab5bc59053..8dd460ab5b 100644 --- a/libmpcodecs/vd_zrmjpeg.c +++ b/libmpcodecs/vd_zrmjpeg.c @@ -36,7 +36,7 @@ #include "vd_internal.h" -static vd_info_t info = +static const vd_info_t info = { "Zoran MJPEG Video passthrough", "zrmjpeg", diff --git a/libmpcodecs/ve.c b/libmpcodecs/ve.c index 015b0aba91..d140559530 100644 --- a/libmpcodecs/ve.c +++ b/libmpcodecs/ve.c @@ -69,8 +69,7 @@ static vf_info_t* encoder_list[]={ NULL }; -vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args){ +vf_instance_t* vf_open_encoder(struct MPOpts *opts, vf_instance_t* next, const char *name, char *args){ char* vf_args[] = { "_oldargs_", args, NULL }; - return vf_open_plugin(encoder_list,next,name,vf_args); + return vf_open_plugin(opts, encoder_list,next,name,vf_args); } - diff --git a/libmpcodecs/ve_lavc.c b/libmpcodecs/ve_lavc.c index b3e5244bab..6c8d6b3064 100644 --- a/libmpcodecs/ve_lavc.c +++ b/libmpcodecs/ve_lavc.c @@ -345,9 +345,9 @@ struct vf_priv_s { #define mux_v (vf->priv->mux) #define lavc_venc_context (vf->priv->context) -static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts); +static int encode_frame(struct vf_instance* vf, AVFrame *pic, double pts); -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int size, i; @@ -551,7 +551,7 @@ static int config(struct vf_instance_s* vf, lavc_venc_context->flags = 0; if (lavc_param_mb_decision) { - mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_HighQualityEncodingSelected); + mp_tmsg(MSGT_MENCODER, MSGL_INFO, "[VE_LAVC] High quality encoding selected (non-realtime)!\n"); lavc_venc_context->mb_decision= lavc_param_mb_decision; } @@ -682,7 +682,7 @@ static int config(struct vf_instance_s* vf, /* fixed qscale :p */ if (lavc_param_vqscale >= 0.0) { - mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_UsingConstantQscale, lavc_param_vqscale); + mp_tmsg(MSGT_MENCODER, MSGL_INFO, "[VE_LAVC] Using constant qscale = %f (VBR).\n", lavc_param_vqscale); lavc_venc_context->flags |= CODEC_FLAG_QSCALE; lavc_venc_context->global_quality= vf->priv->pic->quality = (int)(FF_QP2LAMBDA * lavc_param_vqscale + 0.5); @@ -692,7 +692,7 @@ static int config(struct vf_instance_s* vf, avcodec_thread_init(lavc_venc_context, lavc_param_threads); if (avcodec_open(lavc_venc_context, vf->priv->codec) != 0) { - mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec); + mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Could not open codec.\n"); return 0; } @@ -716,7 +716,7 @@ static int config(struct vf_instance_s* vf, return 1; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ switch(request){ case VFCTRL_FLUSH_FRAMES: @@ -728,7 +728,7 @@ static int control(struct vf_instance_s* vf, int request, void* data){ } } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_IYUV: @@ -765,7 +765,7 @@ static double psnr(double d){ return -10.0*log(d)/log(10); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ AVFrame *pic= vf->priv->pic; pic->data[0]=mpi->planes[0]; @@ -788,7 +788,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return encode_frame(vf, pic, pts) >= 0; } -static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts){ +static int encode_frame(struct vf_instance* vf, AVFrame *pic, double pts){ const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; int out_size; double dts; @@ -893,7 +893,7 @@ static int encode_frame(struct vf_instance_s* vf, AVFrame *pic, double pts){ return out_size; } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(lavc_param_psnr){ double f= lavc_venc_context->width*lavc_venc_context->height*255.0*255.0; @@ -1041,7 +1041,7 @@ static int vf_open(vf_instance_t *vf, char* args){ vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name(lavc_param_vcodec); if (!vf->priv->codec) { - mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, lavc_param_vcodec); + mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Cannot find codec '%s' in libavcodec...\n", lavc_param_vcodec); return 0; } diff --git a/libmpcodecs/ve_libdv.c b/libmpcodecs/ve_libdv.c index b2d00aebd7..0e611fa7a0 100644 --- a/libmpcodecs/ve_libdv.c +++ b/libmpcodecs/ve_libdv.c @@ -55,7 +55,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -77,18 +77,18 @@ static int config(struct vf_instance_s* vf, return 1; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ return CONTROL_UNKNOWN; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt==IMGFMT_YUY2) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; if(fmt==IMGFMT_RGB24) return VFCAP_CSP_SUPPORTED; return 0; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ dv_encode_full_frame(vf->priv->enc, mpi->planes, (mpi->flags&MP_IMGFLAG_YUV) ? e_dv_color_yuv : e_dv_color_rgb, diff --git a/libmpcodecs/ve_nuv.c b/libmpcodecs/ve_nuv.c index ab774e97fe..5f4a0a2808 100644 --- a/libmpcodecs/ve_nuv.c +++ b/libmpcodecs/ve_nuv.c @@ -37,7 +37,7 @@ #include "mp_image.h" #include "vf.h" -#include "libavutil/intreadwrite.h" +#include "ffmpeg_files/intreadwrite.h" #include <lzo/lzo1x.h> #include "native/rtjpegn.h" @@ -88,7 +88,7 @@ m_option_t nuvopts_conf[]={ #define COMPDATASIZE (128*4) #define FRAMEHEADERSIZE 12 -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -110,17 +110,17 @@ static int config(struct vf_instance_s* vf, return 1; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ return CONTROL_UNKNOWN; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt==IMGFMT_I420) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; return 0; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ uint8_t *header = vf->priv->buffer; uint8_t* data = vf->priv->buffer + FRAMEHEADERSIZE; uint8_t* zdata = vf->priv->zbuffer + FRAMEHEADERSIZE; @@ -201,7 +201,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return 1; } -static void uninit(struct vf_instance_s* vf) { +static void uninit(struct vf_instance* vf) { if(vf->priv->buffer) free(vf->priv->buffer); diff --git a/libmpcodecs/ve_qtvideo.c b/libmpcodecs/ve_qtvideo.c index 88ceb45a64..92b76fb252 100644 --- a/libmpcodecs/ve_qtvideo.c +++ b/libmpcodecs/ve_qtvideo.c @@ -139,7 +139,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ // OSErr cres; @@ -177,19 +177,19 @@ static int config(struct vf_instance_s* vf, return 1; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ return CONTROL_UNKNOWN; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt==IMGFMT_YUY2) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; return 0; } static int codec_initialized = 0; -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ OSErr cres; long framesizemax; diff --git a/libmpcodecs/ve_raw.c b/libmpcodecs/ve_raw.c index 91b87555b6..1a43eab0b8 100644 --- a/libmpcodecs/ve_raw.c +++ b/libmpcodecs/ve_raw.c @@ -44,7 +44,7 @@ struct vf_priv_s { }; #define mux_v (vf->priv->mux) -static int set_format(struct vf_instance_s *vf, unsigned int fmt) { +static int set_format(struct vf_instance *vf, unsigned int fmt) { if (!force_fourcc) mux_v->bih->biCompression = fmt; @@ -92,7 +92,7 @@ static int set_format(struct vf_instance_s *vf, unsigned int fmt) { mux_v->bih->biBitCount = 8; break; default: - mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_OutputWithFourccNotSupported, fmt); + mp_tmsg(MSGT_MENCODER, MSGL_INFO, "[VE_RAW] Raw output with FourCC [%x] not supported!\n", fmt); mux_v->bih->biCompression = 0; return 0; } @@ -100,7 +100,7 @@ static int set_format(struct vf_instance_s *vf, unsigned int fmt) { } -static int config(struct vf_instance_s *vf, +static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -115,11 +115,11 @@ static int config(struct vf_instance_s *vf, return 1; } -static int control(struct vf_instance_s *vf, int request, void *data) { +static int control(struct vf_instance *vf, int request, void *data) { return CONTROL_UNKNOWN; } -static int query_format(struct vf_instance_s *vf, unsigned int fmt) { +static int query_format(struct vf_instance *vf, unsigned int fmt) { if (IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt)) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; switch (fmt) { @@ -140,7 +140,7 @@ static int query_format(struct vf_instance_s *vf, unsigned int fmt) { return 0; } -static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts) { +static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) { mux_v->buffer = mpi->planes[0]; muxer_write_chunk(mux_v, mpi->width*mpi->height*mux_v->bih->biBitCount/8, 0x10, pts, pts); return 1; diff --git a/libmpcodecs/ve_vfw.c b/libmpcodecs/ve_vfw.c index 44e27025fd..c04c6936a8 100644 --- a/libmpcodecs/ve_vfw.c +++ b/libmpcodecs/ve_vfw.c @@ -102,16 +102,16 @@ static BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, char *compdatafile, BI ret = ICGetInfo(encoder_hic, &icinfo, sizeof(ICINFO)); mp_msg(MSGT_WIN32,MSGL_INFO,"%ld - %ld - %d\n", ret, icinfo.dwSize, sizeof(ICINFO)); - mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorType, icinfo.fccType); - mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorSubtype, icinfo.fccHandler); - mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorFlags, + mp_tmsg(MSGT_WIN32,MSGL_INFO,"Compressor type: %.4lx\n", icinfo.fccType); + mp_tmsg(MSGT_WIN32,MSGL_INFO,"Compressor subtype: %.4lx\n", icinfo.fccHandler); + mp_tmsg(MSGT_WIN32,MSGL_INFO,"Compressor flags: %lu, version %lu, ICM version: %lu\n", icinfo.dwFlags, icinfo.dwVersion, icinfo.dwVersionICM); //printf("Compressor name: %s\n", icinfo.szName); //printf("Compressor description: %s\n", icinfo.szDescription); -mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Flags); +mp_tmsg(MSGT_WIN32,MSGL_INFO,"Flags:"); if (icinfo.dwFlags & VIDCF_QUALITY) - mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Quality); + mp_tmsg(MSGT_WIN32,MSGL_INFO," quality"); if (icinfo.dwFlags & VIDCF_FASTTEMPORALD) mp_msg(MSGT_WIN32,MSGL_INFO," fast-decompr"); if (icinfo.dwFlags & VIDCF_QUALITYTIME) @@ -277,7 +277,7 @@ static int vfw_encode_frame(BITMAPINFOHEADER* biOutput,void* OutBuf, #define mux_v (vf->priv->mux) #define vfw_bih (vf->priv->bih) -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -295,17 +295,17 @@ static int config(struct vf_instance_s* vf, return 1; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ return CONTROL_UNKNOWN; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt==IMGFMT_BGR24) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIPPED; return 0; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ long flags=0; int ret; // flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack @@ -316,7 +316,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return 1; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { HRESULT ret; @@ -358,7 +358,7 @@ static int vf_open(vf_instance_t *vf, char* args){ if (!vfw_param_codec) { - mp_msg(MSGT_WIN32,MSGL_WARN, MSGTR_MPCODECS_NoVfwCodecSpecified); + mp_tmsg(MSGT_WIN32,MSGL_WARN, "[VE_RAW] Required VfW codec not specified!!\n"); return 0; } // mux_v->bih=vfw_open_encoder("divxc32.dll",vfw_bih,mmioFOURCC('D', 'I', 'V', '3')); diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c index a3e51a08f1..303acdb6fe 100644 --- a/libmpcodecs/ve_x264.c +++ b/libmpcodecs/ve_x264.c @@ -59,8 +59,8 @@ static int turbo = 0; static x264_param_t param; static int parse_error = 0; -static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts); -static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in); +static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts); +static int encode_frame(struct vf_instance *vf, x264_picture_t *pic_in); void x264enc_set_param(const m_option_t* opt, char* arg) { @@ -134,7 +134,7 @@ void x264enc_set_param(const m_option_t* opt, char* arg) } } -static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { h264_module_t *mod=(h264_module_t*)vf->priv; if(parse_error) @@ -193,7 +193,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, return 1; } -static int control(struct vf_instance_s* vf, int request, void *data) +static int control(struct vf_instance* vf, int request, void *data) { h264_module_t *mod=(h264_module_t*)vf->priv; switch(request){ @@ -206,7 +206,7 @@ static int control(struct vf_instance_s* vf, int request, void *data) } } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch(fmt) { case IMGFMT_I420: @@ -225,7 +225,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) { h264_module_t *mod=(h264_module_t*)vf->priv; int i; @@ -243,7 +243,7 @@ static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts) return encode_frame(vf, &mod->pic) >= 0; } -static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in) +static int encode_frame(struct vf_instance *vf, x264_picture_t *pic_in) { h264_module_t *mod=(h264_module_t*)vf->priv; x264_picture_t pic_out; @@ -271,7 +271,7 @@ static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in) return i_size; } -static void uninit(struct vf_instance_s *vf) +static void uninit(struct vf_instance *vf) { h264_module_t *mod=(h264_module_t*)vf->priv; if (mod->x264) diff --git a/libmpcodecs/ve_xvid4.c b/libmpcodecs/ve_xvid4.c index c812e4c20a..858ca903f4 100644 --- a/libmpcodecs/ve_xvid4.c +++ b/libmpcodecs/ve_xvid4.c @@ -374,7 +374,7 @@ static const char *errorstring(int err); *==========================================================================*/ static int -config(struct vf_instance_s* vf, +config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -439,7 +439,7 @@ config(struct vf_instance_s* vf, *==========================================================================*/ static void -uninit(struct vf_instance_s* vf) +uninit(struct vf_instance* vf) { xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; @@ -477,7 +477,7 @@ uninit(struct vf_instance_s* vf) *==========================================================================*/ static int -control(struct vf_instance_s* vf, int request, void* data) +control(struct vf_instance* vf, int request, void* data) { xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; @@ -495,7 +495,7 @@ xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; *==========================================================================*/ static int -query_format(struct vf_instance_s* vf, unsigned int fmt) +query_format(struct vf_instance* vf, unsigned int fmt) { switch(fmt){ case IMGFMT_YV12: @@ -514,7 +514,7 @@ query_format(struct vf_instance_s* vf, unsigned int fmt) *==========================================================================*/ static int -put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { int size; xvid_enc_stats_t stats; diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index e6611efeb8..873b950910 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -135,17 +135,24 @@ static const vf_info_t* const filter_list[]={ &vf_info_vo, &vf_info_format, &vf_info_noformat, +#ifdef CONFIG_LIBSWSCALE_INTERNALS &vf_info_yuy2, +#endif &vf_info_flip, +#ifdef CONFIG_LIBSWSCALE_INTERNALS &vf_info_rgb2bgr, +#endif &vf_info_rotate, &vf_info_mirror, +#ifdef CONFIG_LIBSWSCALE_INTERNALS &vf_info_palette, +#endif &vf_info_pp7, #ifdef CONFIG_LIBAVCODEC &vf_info_lavc, &vf_info_lavcdeint, &vf_info_screenshot, + &vf_info_uspp, #endif #ifdef CONFIG_ZR &vf_info_zrmjpeg, @@ -158,7 +165,9 @@ static const vf_info_t* const filter_list[]={ &vf_info_eq, &vf_info_eq2, &vf_info_gradfun, +#ifdef CONFIG_LIBSWSCALE_INTERNALS &vf_info_halfpack, +#endif &vf_info_dint, &vf_info_1bpp, &vf_info_2xsai, @@ -190,9 +199,8 @@ static const vf_info_t* const filter_list[]={ &vf_info_delogo, &vf_info_remove_logo, &vf_info_hue, -#ifdef CONFIG_LIBAVCODEC_A +#ifdef CONFIG_LIBAVCODEC_INTERNALS &vf_info_spp, - &vf_info_uspp, &vf_info_fspp, &vf_info_qp, &vf_info_mcdeint, @@ -215,7 +223,6 @@ static const vf_info_t* const filter_list[]={ }; // For the vf option -m_obj_settings_t* vf_settings = NULL; const m_obj_list_t vf_obj_list = { (void**)filter_list, M_ST_OFF(vf_info_t,name), @@ -426,23 +433,27 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, //============================================================================ // By default vf doesn't accept MPEGPES -static int vf_default_query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int vf_default_query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt == IMGFMT_MPEGPES) return 0; return vf_next_query_format(vf,fmt); } -vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){ +struct vf_instance *vf_open_plugin_noerr(struct MPOpts *opts, + const vf_info_t * const *filter_list, + vf_instance_t *next, const char *name, + char **args, int *retcode) +{ vf_instance_t* vf; int i; for(i=0;;i++){ if(!filter_list[i]){ - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name); + mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Couldn't find video filter '%s'.\n",name); return NULL; // no such filter! } if(!strcmp(filter_list[i]->name,name)) break; } - vf=malloc(sizeof(vf_instance_t)); - memset(vf,0,sizeof(vf_instance_t)); + vf = calloc(1, sizeof *vf); + vf->opts = opts; vf->info=filter_list[i]; vf->next=next; vf->config=vf_next_config; @@ -464,13 +475,27 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t args = (char**)args[1]; else args = NULL; - if(vf->info->open(vf,(char*)args)>0) return vf; // Success! + *retcode = vf->info->open(vf,(char*)args); + if (*retcode > 0) + return vf; free(vf); - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name); return NULL; } -vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args){ +struct vf_instance *vf_open_plugin(struct MPOpts *opts, + const vf_info_t * const *filter_list, + vf_instance_t *next, const char *name, + char **args) +{ + struct vf_instance *vf = vf_open_plugin_noerr(opts, filter_list, next, + name, args, &(int){0}); + if (!vf) + mp_tmsg(MSGT_VFILTER, MSGL_ERR, "Couldn't open video filter '%s'.\n", + name); + return vf; +} + +vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, const char *name, char **args){ if(args && strcmp(args[0],"_oldargs_")) { int i,l = 0; for(i = 0 ; args && args[2*i] ; i++) @@ -482,17 +507,18 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args p += sprintf(str,"%s",name); for(i = 0 ; args && args[2*i] ; i++) p += sprintf(p," %s=%s",args[2*i],args[2*i+1]); - mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n",str); + mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s]\n", + mp_gtext("Opening video filter: "), str); } } else if(strcmp(name,"vo")) { if(args && strcmp(args[0],"_oldargs_") == 0) - mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter - "[%s=%s]\n", name,args[1]); + mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s=%s]\n", + mp_gtext("Opening video filter: "), name, args[1]); else - mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter - "[%s]\n", name); + mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s]\n", + mp_gtext("Opening video filter: "), name); } - return vf_open_plugin(filter_list,next,name,args); + return vf_open_plugin(opts, filter_list,next,name,args); } /** @@ -503,11 +529,12 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args * \return pointer to the filter instance that was created. */ vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) { + struct MPOpts *opts = (*vf)->opts; vf_instance_t *vo, *prev = NULL, *new; // Find the last filter (should be vf_vo) for (vo = *vf; vo->next; vo = vo->next) prev = vo; - new = vf_open_filter(vo, name, args); + new = vf_open_filter(opts, vo, name, args); if (prev) prev->next = new; else @@ -519,6 +546,7 @@ vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) { unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred){ vf_instance_t* vf=*vfp; + struct MPOpts *opts = vf->opts; const unsigned int* p; unsigned int best=0; int ret; @@ -532,7 +560,7 @@ unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned if(best) return best; // bingo, they have common csp! // ok, then try with scale: if(vf->info == &vf_info_scale) return 0; // avoid infinite recursion! - vf=vf_open_filter(vf,"scale",NULL); + vf=vf_open_filter(opts, vf,"scale",NULL); if(!vf) return 0; // failed to init "scale" // try the preferred csp first: if(preferred && vf->query_format(vf,preferred)) best=preferred; else @@ -583,12 +611,6 @@ int vf_output_queued_frame(vf_instance_t *vf) tmp = last->continue_buffered_image; last->continue_buffered_image = NULL; ret = tmp(last); - if (ret > 0) { - vf->control(vf, VFCTRL_DRAW_OSD, NULL); -#ifdef CONFIG_ASS - vf->control(vf, VFCTRL_DRAW_EOSD, NULL); -#endif - } if (ret) return ret; } @@ -607,7 +629,7 @@ int vf_output_queued_frame(vf_instance_t *vf) * are unchanged, and returns either success or error. * */ -int vf_config_wrapper(struct vf_instance_s* vf, +int vf_config_wrapper(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -616,7 +638,7 @@ int vf_config_wrapper(struct vf_instance_s* vf, if ((vf->fmt.orig_width != width) || (vf->fmt.orig_height != height) || (vf->fmt.orig_fmt != outfmt)) { - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_ResolutionDoesntMatch); + mp_tmsg(MSGT_VFILTER,MSGL_ERR,"\nNew video file has different resolution or colorspace than the previous one.\n"); return 0; } return 1; @@ -630,9 +652,10 @@ int vf_config_wrapper(struct vf_instance_s* vf, return r; } -int vf_next_config(struct vf_instance_s* vf, +int vf_next_config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int voflags, unsigned int outfmt){ + struct MPOpts *opts = vf->opts; int miss; int flags=vf->next->query_format(vf->next,outfmt); if(!flags){ @@ -640,12 +663,12 @@ int vf_next_config(struct vf_instance_s* vf, // let's insert the 'scale' filter, it does the job for us: vf_instance_t* vf2; if(vf->next->info==&vf_info_scale) return 0; // scale->scale - vf2=vf_open_filter(vf->next,"scale",NULL); + vf2=vf_open_filter(opts, vf->next,"scale",NULL); if(!vf2) return 0; // shouldn't happen! vf->next=vf2; flags=vf->next->query_format(vf->next,outfmt); if(!flags){ - mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CannotFindColorspace); + mp_tmsg(MSGT_VFILTER,MSGL_ERR,"Cannot find matching colorspace, even by inserting 'scale' :(\n"); return 0; // FAIL } } @@ -654,7 +677,7 @@ int vf_next_config(struct vf_instance_s* vf, if(miss&VFCAP_ACCEPT_STRIDE){ // vf requires stride support but vf->next doesn't support it! // let's insert the 'expand' filter, it does the job for us: - vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL); + vf_instance_t* vf2=vf_open_filter(opts, vf->next,"expand",NULL); if(!vf2) return 0; // shouldn't happen! vf->next=vf2; } @@ -662,29 +685,21 @@ int vf_next_config(struct vf_instance_s* vf, return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt); } -int vf_next_control(struct vf_instance_s* vf, int request, void* data){ +int vf_next_control(struct vf_instance* vf, int request, void* data){ return vf->next->control(vf->next,request,data); } -void vf_extra_flip(struct vf_instance_s* vf) { - vf_next_control(vf, VFCTRL_DRAW_OSD, NULL); -#ifdef CONFIG_ASS - vf_next_control(vf, VFCTRL_DRAW_EOSD, NULL); -#endif - vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL); -} - -int vf_next_query_format(struct vf_instance_s* vf, unsigned int fmt){ +int vf_next_query_format(struct vf_instance* vf, unsigned int fmt){ int flags=vf->next->query_format(vf->next,fmt); if(flags) flags|=vf->default_caps; return flags; } -int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi, double pts){ +int vf_next_put_image(struct vf_instance* vf,mp_image_t *mpi, double pts){ return vf->next->put_image(vf->next,mpi, pts); } -void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stride,int w, int h, int x, int y){ +void vf_next_draw_slice(struct vf_instance* vf,unsigned char** src, int * stride,int w, int h, int x, int y){ if (vf->next->draw_slice) { vf->next->draw_slice(vf->next,src,stride,w,h,x,y); return; @@ -708,7 +723,10 @@ void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stri //============================================================================ -vf_instance_t* append_filters(vf_instance_t* last){ +vf_instance_t *append_filters(vf_instance_t* last, + struct m_obj_settings *vf_settings) +{ + struct MPOpts *opts = last->opts; vf_instance_t* vf; int i; @@ -718,7 +736,7 @@ vf_instance_t* append_filters(vf_instance_t* last){ /* NOP */; for(i-- ; i >= 0 ; i--) { //printf("Open filter %s\n",vf_settings[i].name); - vf = vf_open_filter(last,vf_settings[i].name,vf_settings[i].attribs); + vf = vf_open_filter(opts, last,vf_settings[i].name,vf_settings[i].attribs); if(vf) last=vf; } } @@ -733,6 +751,8 @@ void vf_uninit_filter(vf_instance_t* vf){ free_mp_image(vf->imgctx.static_images[1]); free_mp_image(vf->imgctx.temp_images[0]); free_mp_image(vf->imgctx.export_images[0]); + for (int i = 0; i < NUM_NUMBERED_MPI; i++) + free_mp_image(vf->imgctx.numbered_images[i]); free(vf); } diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h index 91a57f2f9d..3d468d382a 100644 --- a/libmpcodecs/vf.h +++ b/libmpcodecs/vf.h @@ -21,7 +21,8 @@ #include "mp_image.h" -struct vf_instance_s; +struct MPOpts; +struct vf_instance; struct vf_priv_s; typedef struct vf_info_s { @@ -29,7 +30,7 @@ typedef struct vf_info_s { const char *name; const char *author; const char *comment; - int (*open)(struct vf_instance_s* vf,char* args); + int (*open)(struct vf_instance* vf,char* args); // Ptr to a struct dscribing the options const void* opts; } vf_info_t; @@ -49,27 +50,27 @@ typedef struct vf_format_context_t { int orig_width, orig_height, orig_fmt; } vf_format_context_t; -typedef struct vf_instance_s { +typedef struct vf_instance { const vf_info_t* info; // funcs: - int (*config)(struct vf_instance_s* vf, + int (*config)(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt); - int (*control)(struct vf_instance_s* vf, + int (*control)(struct vf_instance* vf, int request, void* data); - int (*query_format)(struct vf_instance_s* vf, + int (*query_format)(struct vf_instance* vf, unsigned int fmt); - void (*get_image)(struct vf_instance_s* vf, + void (*get_image)(struct vf_instance* vf, mp_image_t *mpi); - int (*put_image)(struct vf_instance_s* vf, + int (*put_image)(struct vf_instance* vf, mp_image_t *mpi, double pts); - void (*start_slice)(struct vf_instance_s* vf, + void (*start_slice)(struct vf_instance* vf, mp_image_t *mpi); - void (*draw_slice)(struct vf_instance_s* vf, + void (*draw_slice)(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y); - void (*uninit)(struct vf_instance_s* vf); + void (*uninit)(struct vf_instance* vf); - int (*continue_buffered_image)(struct vf_instance_s* vf); + int (*continue_buffered_image)(struct vf_instance* vf); // caps: unsigned int default_caps; // used by default query_format() unsigned int default_reqs; // used by default config() @@ -77,9 +78,10 @@ typedef struct vf_instance_s { int w, h; vf_image_context_t imgctx; vf_format_context_t fmt; - struct vf_instance_s* next; + struct vf_instance* next; mp_image_t *dmpi; struct vf_priv_s* priv; + struct MPOpts *opts; } vf_instance_t; // control codes: @@ -97,16 +99,20 @@ typedef struct vf_seteq_s #define VFCTRL_GET_EQUALIZER 8 /* gset color options (brightness,contrast etc) */ #define VFCTRL_DRAW_OSD 7 #define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */ -#define VFCTRL_FLIP_PAGE 10 /* Tell the vo to flip pages */ #define VFCTRL_DUPLICATE_FRAME 11 /* For encoding - encode zero-change frame */ #define VFCTRL_SKIP_NEXT_FRAME 12 /* For encoding - drop the next frame that passes thru */ #define VFCTRL_FLUSH_FRAMES 13 /* For encoding - flush delayed frames */ #define VFCTRL_SCREENSHOT 14 /* Make a screenshot */ #define VFCTRL_INIT_EOSD 15 /* Select EOSD renderer */ #define VFCTRL_DRAW_EOSD 16 /* Render EOSD */ -#define VFCTRL_GET_PTS 17 /* Return last pts value that reached vf_vo*/ #define VFCTRL_SET_DEINTERLACE 18 /* Set deinterlacing status */ #define VFCTRL_GET_DEINTERLACE 19 /* Get deinterlacing status */ +/* Hack to make the OSD state object available to vf_expand which accesses + * the OSD state outside of normal OSD draw time. */ +#define VFCTRL_SET_OSD_OBJ 20 +#define VFCTRL_REDRAW_OSD 21 /* Change user-visible OSD immediately */ +#define VFCTRL_SET_YUV_COLORSPACE 22 +#define VFCTRL_GET_YUV_COLORSPACE 23 #include "vfcap.h" @@ -118,10 +124,14 @@ typedef struct vf_seteq_s void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h); mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h); -vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args); -vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args); +vf_instance_t* vf_open_plugin(struct MPOpts *opts, const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args); +struct vf_instance *vf_open_plugin_noerr(struct MPOpts *opts, + const vf_info_t * const *filter_list, + vf_instance_t *next, const char *name, + char **args, int *retcode); +vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, const char *name, char **args); vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args); -vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args); +vf_instance_t* vf_open_encoder(struct MPOpts *opts, vf_instance_t* next, const char *name, char *args); unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred); void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src); @@ -129,21 +139,21 @@ void vf_queue_frame(vf_instance_t *vf, int (*)(vf_instance_t *)); int vf_output_queued_frame(vf_instance_t *vf); // default wrappers: -int vf_next_config(struct vf_instance_s* vf, +int vf_next_config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt); -int vf_next_control(struct vf_instance_s* vf, int request, void* data); -void vf_extra_flip(struct vf_instance_s* vf); -int vf_next_query_format(struct vf_instance_s* vf, unsigned int fmt); -int vf_next_put_image(struct vf_instance_s* vf,mp_image_t *mpi, double pts); -void vf_next_draw_slice (struct vf_instance_s* vf, unsigned char** src, int* stride, int w,int h, int x, int y); +int vf_next_control(struct vf_instance* vf, int request, void* data); +int vf_next_query_format(struct vf_instance* vf, unsigned int fmt); +int vf_next_put_image(struct vf_instance* vf,mp_image_t *mpi, double pts); +void vf_next_draw_slice (struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y); -vf_instance_t* append_filters(vf_instance_t* last); +struct m_obj_settings; +vf_instance_t* append_filters(vf_instance_t* last, struct m_obj_settings *vf_settings); void vf_uninit_filter(vf_instance_t* vf); void vf_uninit_filter_chain(vf_instance_t* vf); -int vf_config_wrapper(struct vf_instance_s* vf, +int vf_config_wrapper(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt); diff --git a/libmpcodecs/vf_1bpp.c b/libmpcodecs/vf_1bpp.c index 43c5677202..a9321f8924 100644 --- a/libmpcodecs/vf_1bpp.c +++ b/libmpcodecs/vf_1bpp.c @@ -58,7 +58,7 @@ static const unsigned int bgr_list[]={ 0 }; -static unsigned int find_best(struct vf_instance_s* vf){ +static unsigned int find_best(struct vf_instance* vf){ unsigned int best=0; int ret; const unsigned int* p=bgr_list; @@ -78,7 +78,7 @@ struct vf_priv_s { unsigned int fmt; }; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ if (!vf->priv->fmt) @@ -121,7 +121,7 @@ static void convert(mp_image_t *mpi, mp_image_t *dmpi, int value0, int value1,in } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; // hope we'll get DR buffer: @@ -172,7 +172,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ int best; if(fmt!=IMGFMT_RGB1 && fmt!=IMGFMT_BGR1) return 0; best=find_best(vf); diff --git a/libmpcodecs/vf_2xsai.c b/libmpcodecs/vf_2xsai.c index e28ada4818..26bbd58eb5 100644 --- a/libmpcodecs/vf_2xsai.c +++ b/libmpcodecs/vf_2xsai.c @@ -43,7 +43,7 @@ static int PixelsPerMask = 2; #define makecol(r,g,b) (r+(g<<8)+(b<<16)) #define makecol_depth(d,r,g,b) (r+(g<<8)+(b<<16)) -int Init_2xSaI(int d) +static int Init_2xSaI(int d) { int minr = 0, ming = 0, minb = 0; @@ -95,7 +95,7 @@ int Init_2xSaI(int d) + ((((A & qlowpixelMask) + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask)) >> 2) & qlowpixelMask) -void Super2xSaI_ex(uint8_t *src, uint32_t src_pitch, +static void Super2xSaI_ex(uint8_t *src, uint32_t src_pitch, uint8_t *dst, uint32_t dst_pitch, uint32_t width, uint32_t height, int sbpp) { @@ -280,7 +280,7 @@ void Super2xSaI_ex(uint8_t *src, uint32_t src_pitch, //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -289,7 +289,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,2*width,2*height,2*d_width,2*d_height,flags,outfmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; // hope we'll get DR buffer: @@ -306,7 +306,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ // case IMGFMT_BGR15: // case IMGFMT_BGR16: diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c index 3f5d6e352e..9076ed099e 100644 --- a/libmpcodecs/vf_ass.c +++ b/libmpcodecs/vf_ass.c @@ -31,6 +31,7 @@ #include "config.h" #include "mp_msg.h" #include "help_mp.h" +#include "options.h" #include "img_format.h" #include "mp_image.h" @@ -41,7 +42,7 @@ #include "m_option.h" #include "m_struct.h" -#include "libass/ass_mp.h" +#include "ass_mp.h" #define _r(c) ((c)>>24) #define _g(c) (((c)>>16)&0xFF) @@ -61,50 +62,47 @@ static const struct vf_priv_s { // 0 = insert always int auto_insert; - ass_renderer_t* ass_priv; + ASS_Renderer* ass_priv; unsigned char* planes[3]; - unsigned char* dirty_rows; + struct line_limits { + uint16_t start; + uint16_t end; + } *line_limits; } vf_priv_dflt; -extern int opt_screen_size_x; -extern int opt_screen_size_y; - -extern ass_track_t* ass_track; +extern ASS_Track *ass_track; extern float sub_delay; extern int sub_visibility; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { + struct MPOpts *opts = vf->opts; if (outfmt == IMGFMT_IF09) return 0; vf->priv->outh = height + ass_top_margin + ass_bottom_margin; vf->priv->outw = width; - if(!opt_screen_size_x && !opt_screen_size_y){ + if (!opts->screen_size_x && !opts->screen_size_y) { d_width = d_width * vf->priv->outw / width; d_height = d_height * vf->priv->outh / height; } vf->priv->planes[1] = malloc(vf->priv->outw * vf->priv->outh); vf->priv->planes[2] = malloc(vf->priv->outw * vf->priv->outh); - vf->priv->dirty_rows = malloc(vf->priv->outh); + vf->priv->line_limits = malloc((vf->priv->outh + 1) / 2 * sizeof(*vf->priv->line_limits)); if (vf->priv->ass_priv) { ass_configure(vf->priv->ass_priv, vf->priv->outw, vf->priv->outh, 0); -#if defined(LIBASS_VERSION) && LIBASS_VERSION >= 0x00908000 - ass_set_aspect_ratio(vf->priv->ass_priv, ((double)d_width) / d_height, ((double)width) / height); -#else - ass_set_aspect_ratio(vf->priv->ass_priv, ((double)d_width) / d_height); -#endif + ass_set_aspect_ratio(vf->priv->ass_priv, 1, 1); } return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, d_height, flags, outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) +static void get_image(struct vf_instance* vf, mp_image_t *mpi) { if(mpi->type == MP_IMGTYPE_IPB) return; if(mpi->flags & MP_IMGFLAG_PRESERVE) return; @@ -118,7 +116,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) && !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){ - mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible); + mp_tmsg(MSGT_ASS, MSGL_INFO, "Full DR not possible, trying SLICES instead!\n"); return; } @@ -163,11 +161,11 @@ static void blank(mp_image_t *mpi, int y1, int y2) } } -static int prepare_image(struct vf_instance_s* vf, mp_image_t *mpi) +static int prepare_image(struct vf_instance* vf, mp_image_t *mpi) { if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ vf->dmpi = mpi->priv; - if (!vf->dmpi) { mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; } + if (!vf->dmpi) { mp_tmsg(MSGT_ASS, MSGL_WARN, "Why do we get NULL??\n"); return 0; } mpi->priv = NULL; // we've used DR, so we're ready... if (ass_top_margin) @@ -208,59 +206,58 @@ static int prepare_image(struct vf_instance_s* vf, mp_image_t *mpi) return 0; } +static void update_limits(struct vf_instance *vf, int starty, int endy, + int startx, int endx) +{ + starty >>= 1; + endy = (endy + 1) >> 1; + startx >>= 1; + endx = (endx + 1) >> 1; + for (int i = starty; i < endy; i++) { + struct line_limits *ll = vf->priv->line_limits + i; + if (startx < ll->start) + ll->start = startx; + if (endx > ll->end) + ll->end = endx; + } +} + /** * \brief Copy specified rows from render_context.dmpi to render_context.planes, upsampling to 4:4:4 */ -static void copy_from_image(struct vf_instance_s* vf, int first_row, int last_row) +static void copy_from_image(struct vf_instance* vf) { int pl; - int i, j, k; - unsigned char val; - int chroma_rows; - - first_row -= (first_row % 2); - last_row += (last_row % 2); - chroma_rows = (last_row - first_row) / 2; - - assert(first_row >= 0); - assert(first_row <= last_row); - assert(last_row <= vf->priv->outh); for (pl = 1; pl < 3; ++pl) { int dst_stride = vf->priv->outw; int src_stride = vf->dmpi->stride[pl]; - unsigned char* src = vf->dmpi->planes[pl] + (first_row/2) * src_stride; - unsigned char* dst = vf->priv->planes[pl] + first_row * dst_stride; - unsigned char* dst_next = dst + dst_stride; - for(i = 0; i < chroma_rows; ++i) - { - if ((vf->priv->dirty_rows[first_row + i*2] == 0) || - (vf->priv->dirty_rows[first_row + i*2 + 1] == 0)) { - for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k+=2) { - val = *(src + j); - *(dst + k) = val; - *(dst + k + 1) = val; - *(dst_next + k) = val; - *(dst_next + k + 1) = val; - } + unsigned char* src = vf->dmpi->planes[pl]; + unsigned char* dst = vf->priv->planes[pl]; + for (int i = 0; i < (vf->priv->outh + 1) / 2; i++) { + struct line_limits *ll = vf->priv->line_limits + i; + unsigned char* dst_next = dst + dst_stride; + for (int j = ll->start; j < ll->end; j++) { + unsigned char val = src[j]; + dst[j << 1] = val; + dst[(j << 1) + 1] = val; + dst_next[j << 1] = val; + dst_next[(j << 1) + 1] = val; } src += src_stride; dst = dst_next + dst_stride; - dst_next = dst + dst_stride; } } - for (i = first_row; i < last_row; ++i) - vf->priv->dirty_rows[i] = 1; } /** * \brief Copy all previously copied rows back to render_context.dmpi */ -static void copy_to_image(struct vf_instance_s* vf) +static void copy_to_image(struct vf_instance* vf) { int pl; - int i, j, k; + int i, j; for (pl = 1; pl < 3; ++pl) { int dst_stride = vf->dmpi->stride[pl]; int src_stride = vf->priv->outw; @@ -268,18 +265,14 @@ static void copy_to_image(struct vf_instance_s* vf) unsigned char* dst = vf->dmpi->planes[pl]; unsigned char* src = vf->priv->planes[pl]; unsigned char* src_next = vf->priv->planes[pl] + src_stride; - for(i = 0; i < vf->dmpi->chroma_height; ++i) - { - if ((vf->priv->dirty_rows[i*2] == 1)) { - assert(vf->priv->dirty_rows[i*2 + 1] == 1); - for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k+=2) { - unsigned val = 0; - val += *(src + k); - val += *(src + k + 1); - val += *(src_next + k); - val += *(src_next + k + 1); - *(dst + j) = val >> 2; - } + for (i = 0; i < vf->dmpi->chroma_height; ++i) { + for (j = vf->priv->line_limits[i].start; j < vf->priv->line_limits[i].end; j++) { + unsigned val = 0; + val += src[j << 1]; + val += src[(j << 1) + 1]; + val += src_next[j << 1]; + val += src_next[(j << 1) + 1]; + dst[j] = val >> 2; } dst += dst_stride; src = src_next + src_stride; @@ -288,7 +281,7 @@ static void copy_to_image(struct vf_instance_s* vf) } } -static void my_draw_bitmap(struct vf_instance_s* vf, unsigned char* bitmap, int bitmap_w, int bitmap_h, int stride, int dst_x, int dst_y, unsigned color) +static void my_draw_bitmap(struct vf_instance* vf, unsigned char* bitmap, int bitmap_w, int bitmap_h, int stride, int dst_x, int dst_y, unsigned color) { unsigned char y = rgba2y(color); unsigned char u = rgba2u(color); @@ -304,10 +297,10 @@ static void my_draw_bitmap(struct vf_instance_s* vf, unsigned char* bitmap, int dstv = vf->priv->planes[2] + dst_x + dst_y * vf->priv->outw; for (i = 0; i < bitmap_h; ++i) { for (j = 0; j < bitmap_w; ++j) { - unsigned k = ((unsigned)src[j]) * opacity / 255; - dsty[j] = (k*y + (255-k)*dsty[j]) / 255; - dstu[j] = (k*u + (255-k)*dstu[j]) / 255; - dstv[j] = (k*v + (255-k)*dstv[j]) / 255; + unsigned k = (src[j] * opacity + 255) >> 8; + dsty[j] = (k*y + (255-k)*dsty[j] + 255) >> 8; + dstu[j] = (k*u + (255-k)*dstu[j] + 255) >> 8; + dstv[j] = (k*v + (255-k)*dstv[j] + 255) >> 8; } src += stride; dsty += dmpi->stride[0]; @@ -316,12 +309,15 @@ static void my_draw_bitmap(struct vf_instance_s* vf, unsigned char* bitmap, int } } -static int render_frame(struct vf_instance_s* vf, mp_image_t *mpi, const ass_image_t* img) +static int render_frame(struct vf_instance* vf, mp_image_t *mpi, const ASS_Image *img) { if (img) { - memset(vf->priv->dirty_rows, 0, vf->priv->outh); // reset dirty rows + for (int i = 0; i < (vf->priv->outh + 1) / 2; i++) + vf->priv->line_limits[i] = (struct line_limits){65535, 0}; + for (const ASS_Image *im = img; im; im = im->next) + update_limits(vf, im->dst_y, im->dst_y + im->h, im->dst_x, im->dst_x + im->w); + copy_from_image(vf); while (img) { - copy_from_image(vf, img->dst_y, img->dst_y + img->h); my_draw_bitmap(vf, img->bitmap, img->w, img->h, img->stride, img->dst_x, img->dst_y, img->color); img = img->next; @@ -331,9 +327,9 @@ static int render_frame(struct vf_instance_s* vf, mp_image_t *mpi, const ass_ima return 0; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { - ass_image_t* images = 0; + ASS_Image* images = 0; if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) images = ass_mp_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5, NULL); @@ -343,7 +339,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf, vf->dmpi, pts); } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch(fmt){ case IMGFMT_YV12: @@ -358,7 +354,7 @@ static int control(vf_instance_t *vf, int request, void *data) { switch (request) { case VFCTRL_INIT_EOSD: - vf->priv->ass_priv = ass_renderer_init((ass_library_t*)data); + vf->priv->ass_priv = ass_renderer_init((ASS_Library*)data); if (!vf->priv->ass_priv) return CONTROL_FALSE; ass_configure_fonts(vf->priv->ass_priv); return CONTROL_TRUE; @@ -369,16 +365,14 @@ static int control(vf_instance_t *vf, int request, void *data) return vf_next_control(vf, request, data); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { if (vf->priv->ass_priv) ass_renderer_done(vf->priv->ass_priv); - if (vf->priv->planes[1]) - free(vf->priv->planes[1]); - if (vf->priv->planes[2]) - free(vf->priv->planes[2]); - if (vf->priv->dirty_rows) - free(vf->priv->dirty_rows); + free(vf->priv->planes[1]); + free(vf->priv->planes[2]); + free(vf->priv->line_limits); + free(vf->priv); } static const unsigned int fmt_list[]={ @@ -394,10 +388,12 @@ static int open(vf_instance_t *vf, char* args) vf->priv->outfmt = vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12); if (vf->priv->outfmt) flags = vf_next_query_format(vf, vf->priv->outfmt); - if (!vf->priv->outfmt || (vf->priv->auto_insert && flags&VFCAP_EOSD)) - { + if (!vf->priv->outfmt) { uninit(vf); return 0; + } else if (vf->priv->auto_insert && flags&VFCAP_EOSD) { + uninit(vf); + return -1; } if (vf->priv->auto_insert) @@ -434,4 +430,3 @@ const vf_info_t vf_info_ass = { open, &vf_opts }; - diff --git a/libmpcodecs/vf_blackframe.c b/libmpcodecs/vf_blackframe.c index dce13ea927..34d2f1f506 100644 --- a/libmpcodecs/vf_blackframe.c +++ b/libmpcodecs/vf_blackframe.c @@ -40,12 +40,12 @@ struct vf_priv_s { unsigned int bamount, bthresh, frame, lastkeyframe; }; -static int config(struct vf_instance_s* vf, int width, int height, int d_width, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static int query_format(struct vf_instance_s *vf, unsigned fmt) { +static int query_format(struct vf_instance *vf, unsigned fmt) { switch(fmt) { case IMGFMT_YVU9: case IMGFMT_IF09: @@ -66,7 +66,7 @@ static int query_format(struct vf_instance_s *vf, unsigned fmt) { return 0; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int x, y; int nblack=0, pblack=0; @@ -110,11 +110,11 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf, dmpi, pts); } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ return vf_next_control(vf,request,data); } -static void uninit(struct vf_instance_s *vf) { +static void uninit(struct vf_instance *vf) { if (vf->priv) free(vf->priv); } diff --git a/libmpcodecs/vf_bmovl.c b/libmpcodecs/vf_bmovl.c index ee4eb9a942..0277751527 100644 --- a/libmpcodecs/vf_bmovl.c +++ b/libmpcodecs/vf_bmovl.c @@ -125,14 +125,14 @@ struct vf_priv_s { }; static int -query_format(struct vf_instance_s* vf, unsigned int fmt){ +query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt==IMGFMT_YV12) return VFCAP_CSP_SUPPORTED; return 0; } static int -config(struct vf_instance_s* vf, +config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -162,7 +162,7 @@ config(struct vf_instance_s* vf, } static void -uninit(struct vf_instance_s *vf) +uninit(struct vf_instance *vf) { if(vf->priv) { free(vf->priv->bitmap.y); @@ -214,7 +214,7 @@ _read_cmd(int fd, char *cmd, char *args) { static int -put_image(struct vf_instance_s* vf, mp_image_t* mpi, double pts){ +put_image(struct vf_instance* vf, mp_image_t* mpi, double pts){ int buf_x=0, buf_y=0, buf_pos=0; int have, got, want; int xpos=0, ypos=0, pos=0; diff --git a/libmpcodecs/vf_boxblur.c b/libmpcodecs/vf_boxblur.c index f8f2026566..e75f261375 100644 --- a/libmpcodecs/vf_boxblur.c +++ b/libmpcodecs/vf_boxblur.c @@ -46,7 +46,7 @@ struct vf_priv_s { /***************************************************************************/ -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -127,7 +127,7 @@ static void vBlur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int s } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int cw= mpi->w >> mpi->chroma_x_shift; int ch= mpi->h >> mpi->chroma_y_shift; @@ -156,7 +156,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: diff --git a/libmpcodecs/vf_crop.c b/libmpcodecs/vf_crop.c index 58683e01b1..96a90f606b 100644 --- a/libmpcodecs/vf_crop.c +++ b/libmpcodecs/vf_crop.c @@ -23,6 +23,7 @@ #include "config.h" #include "mp_msg.h" #include "help_mp.h" +#include "options.h" #include "img_format.h" #include "mp_image.h" @@ -39,14 +40,12 @@ static const struct vf_priv_s { -1,-1 }; -extern int opt_screen_size_x; -extern int opt_screen_size_y; - //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ + struct MPOpts *opts = vf->opts; // calculate the missing parameters: if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width; if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height; @@ -76,17 +75,17 @@ static int config(struct vf_instance_s* vf, // check: if(vf->priv->crop_w+vf->priv->crop_x>width || vf->priv->crop_h+vf->priv->crop_y>height){ - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_CropBadPositionWidthHeight); + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[CROP] Bad position/width/height - cropped area outside of the original!\n"); return 0; } - if(!opt_screen_size_x && !opt_screen_size_y){ + if(!opts->screen_size_x && !opts->screen_size_y){ d_width=d_width*vf->priv->crop_w/width; d_height=d_height*vf->priv->crop_h/height; } return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK) return vf_next_put_image(vf,vf->dmpi, pts); @@ -113,12 +112,12 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ +static void start_slice(struct vf_instance* vf, mp_image_t *mpi){ vf->dmpi = vf_get_image(vf->next, mpi->imgfmt, mpi->type, mpi->flags, vf->priv->crop_w, vf->priv->crop_h); } -static void draw_slice(struct vf_instance_s* vf, +static void draw_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ unsigned char *src2[3]; src2[0] = src[0]; diff --git a/libmpcodecs/vf_cropdetect.c b/libmpcodecs/vf_cropdetect.c index 5aee04ada9..f777107a77 100644 --- a/libmpcodecs/vf_cropdetect.c +++ b/libmpcodecs/vf_cropdetect.c @@ -61,7 +61,7 @@ static int checkline(unsigned char* src,int stride,int len,int bpp){ //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ vf->priv->x1=width - 1; @@ -72,7 +72,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int bpp=mpi->bpp/8; int w,h,x,y,shrink_by; @@ -153,7 +153,7 @@ if(++vf->priv->fno>0){ // ignore first 2 frames - they may be empty h -= shrink_by; y += (shrink_by / 2 + 1) & ~1; - mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea, + mp_tmsg(MSGT_VFILTER, MSGL_INFO, "[CROP] Crop area: X: %d..%d Y: %d..%d (-vf crop=%d:%d:%d:%d).\n", vf->priv->x1,vf->priv->x2, vf->priv->y1,vf->priv->y2, w,h,x,y); @@ -164,7 +164,7 @@ if(++vf->priv->fno>0){ // ignore first 2 frames - they may be empty return vf_next_put_image(vf,dmpi, pts); } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) { +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch(fmt) { // the default limit value works only right with YV12 right now. case IMGFMT_YV12: diff --git a/libmpcodecs/vf_decimate.c b/libmpcodecs/vf_decimate.c index 8a58562190..2d8dcb7931 100644 --- a/libmpcodecs/vf_decimate.c +++ b/libmpcodecs/vf_decimate.c @@ -128,7 +128,7 @@ static int diff_to_drop(int hi, int lo, float frac, mp_image_t *old, mp_image_t new->w*(new->bpp/8), new->h, old->stride[0], new->stride[0]); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; @@ -164,7 +164,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf, dmpi, pts); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -196,5 +196,3 @@ const vf_info_t vf_info_decimate = { open, NULL }; - - diff --git a/libmpcodecs/vf_delogo.c b/libmpcodecs/vf_delogo.c index b07fd4017e..2dd971fab9 100644 --- a/libmpcodecs/vf_delogo.c +++ b/libmpcodecs/vf_delogo.c @@ -117,7 +117,7 @@ static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int } } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -125,7 +125,7 @@ static int config(struct vf_instance_s* vf, } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ // ok, we can do pp in-place (or pp disabled): @@ -143,7 +143,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ @@ -169,7 +169,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; free(vf->priv); @@ -178,7 +178,7 @@ static void uninit(struct vf_instance_s* vf){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: @@ -189,7 +189,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; } -static unsigned int fmt_list[]={ +static const unsigned int fmt_list[]={ IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, @@ -233,7 +233,7 @@ static int open(vf_instance_t *vf, char* args){ } #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { +static const m_option_t vf_opts_fields[] = { { "x", ST_OFF(xoff), CONF_TYPE_INT, 0, 0, 0, NULL }, { "y", ST_OFF(yoff), CONF_TYPE_INT, 0, 0, 0, NULL }, { "w", ST_OFF(lw), CONF_TYPE_INT, 0, 0, 0, NULL }, @@ -243,7 +243,7 @@ static m_option_t vf_opts_fields[] = { { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "delogo", sizeof(struct vf_priv_s), &vf_priv_dflt, diff --git a/libmpcodecs/vf_denoise3d.c b/libmpcodecs/vf_denoise3d.c index 0958305936..fc9924cbe9 100644 --- a/libmpcodecs/vf_denoise3d.c +++ b/libmpcodecs/vf_denoise3d.c @@ -45,7 +45,7 @@ struct vf_priv_s { /***************************************************************************/ -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -58,7 +58,7 @@ static int config(struct vf_instance_s* vf, } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv->Line); } @@ -109,7 +109,7 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x] -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int cw= mpi->w >> mpi->chroma_x_shift; int ch= mpi->h >> mpi->chroma_y_shift; int W = mpi->w, H = mpi->h; @@ -147,7 +147,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: diff --git a/libmpcodecs/vf_detc.c b/libmpcodecs/vf_detc.c index 992ffcac66..73a70c40be 100644 --- a/libmpcodecs/vf_detc.c +++ b/libmpcodecs/vf_detc.c @@ -285,7 +285,7 @@ static void copy_image(mp_image_t *dmpi, mp_image_t *mpi, int field) } } -static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi) +static int do_put_image(struct vf_instance* vf, mp_image_t *dmpi) { struct vf_priv_s *p = vf->priv; int dropflag; @@ -313,7 +313,7 @@ static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi) return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { int ret=0; mp_image_t *dmpi; @@ -357,7 +357,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return ret; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - figure out which other formats work */ switch (fmt) { @@ -369,14 +369,14 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -451,5 +451,3 @@ const vf_info_t vf_info_detc = { open, NULL }; - - diff --git a/libmpcodecs/vf_dint.c b/libmpcodecs/vf_dint.c index 1d10f773d6..7314346493 100644 --- a/libmpcodecs/vf_dint.c +++ b/libmpcodecs/vf_dint.c @@ -42,7 +42,7 @@ struct vf_priv_s { #define MAXROWSIZE 1200 -static int config (struct vf_instance_s* vf, +static int config (struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -79,7 +79,7 @@ static int config (struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static int put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image (struct vf_instance* vf, mp_image_t *mpi, double pts) { char rrow0[MAXROWSIZE]; char rrow1[MAXROWSIZE]; diff --git a/libmpcodecs/vf_divtc.c b/libmpcodecs/vf_divtc.c index 7dbce06363..0fe9576251 100644 --- a/libmpcodecs/vf_divtc.c +++ b/libmpcodecs/vf_divtc.c @@ -224,7 +224,7 @@ static int imgop(int(*planeop)(unsigned char *, unsigned char *, static int match(struct vf_priv_s *p, int *diffs, int phase1, int phase2, double *strength) { - static const int pattern1[]={ -4, 1, 1, 1, 1 }, + const int pattern1[]={ -4, 1, 1, 1, 1 }, pattern2[]={ -2, -3, 4, 4, -3 }, *pattern; int f, m, n, t[5]; @@ -257,7 +257,7 @@ static int match(struct vf_priv_s *p, int *diffs, return m; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi, *tmpi=0; int n, m, f, newphase; @@ -568,7 +568,7 @@ static int analyze(struct vf_priv_s *p) return 1; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch(fmt) { @@ -583,7 +583,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { if(vf->priv) { diff --git a/libmpcodecs/vf_down3dright.c b/libmpcodecs/vf_down3dright.c index 4f2021397f..2cfceda7f3 100644 --- a/libmpcodecs/vf_down3dright.c +++ b/libmpcodecs/vf_down3dright.c @@ -96,7 +96,7 @@ static void toright(unsigned char *dst[3], unsigned char *src[3], } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; @@ -113,7 +113,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf,dmpi, pts); } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -123,7 +123,7 @@ static int config(struct vf_instance_s* vf, } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - really any YUV 4:2:0 input format should work */ switch (fmt) { @@ -135,7 +135,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -164,4 +164,3 @@ const vf_info_t vf_info_down3dright = { open, NULL }; - diff --git a/libmpcodecs/vf_dsize.c b/libmpcodecs/vf_dsize.c index 9d4140db98..6e451d540b 100644 --- a/libmpcodecs/vf_dsize.c +++ b/libmpcodecs/vf_dsize.c @@ -35,7 +35,7 @@ struct vf_priv_s { float aspect; }; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -121,4 +121,3 @@ const vf_info_t vf_info_dsize = { open, NULL }; - diff --git a/libmpcodecs/vf_dvbscale.c b/libmpcodecs/vf_dvbscale.c index d084ff61f5..e7ced30a34 100644 --- a/libmpcodecs/vf_dvbscale.c +++ b/libmpcodecs/vf_dvbscale.c @@ -34,7 +34,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ diff --git a/libmpcodecs/vf_eq.c b/libmpcodecs/vf_eq.c index 7e6e58e5d8..34f57d9311 100644 --- a/libmpcodecs/vf_eq.c +++ b/libmpcodecs/vf_eq.c @@ -132,7 +132,7 @@ static void (*process)(unsigned char *dest, int dstride, unsigned char *src, int /* FIXME: add packed yuv version of process */ -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; @@ -161,7 +161,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf,dmpi, pts); } -static int control(struct vf_instance_s* vf, int request, void* data) +static int control(struct vf_instance* vf, int request, void* data) { vf_equalizer_t *eq; @@ -192,7 +192,7 @@ static int control(struct vf_instance_s* vf, int request, void* data) return vf_next_control(vf, request, data); } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch (fmt) { case IMGFMT_YVU9: @@ -213,7 +213,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { if (vf->priv->buf) free(vf->priv->buf); free(vf->priv); @@ -235,13 +235,13 @@ static int open(vf_instance_t *vf, char* args) } #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { +static const m_option_t vf_opts_fields[] = { {"brightness", ST_OFF(brightness), CONF_TYPE_INT, M_OPT_RANGE,-100 ,100, NULL}, {"contrast", ST_OFF(contrast), CONF_TYPE_INT, M_OPT_RANGE,-100 ,100, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "eq", sizeof(struct vf_priv_s), &vf_priv_dflt, @@ -256,4 +256,3 @@ const vf_info_t vf_info_eq = { open, &vf_opts }; - diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c index f8d21fb762..e39bbeda7f 100644 --- a/libmpcodecs/vf_expand.c +++ b/libmpcodecs/vf_expand.c @@ -21,10 +21,12 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #include "config.h" #include "mp_msg.h" #include "help_mp.h" +#include "options.h" #include "img_format.h" #include "mp_image.h" @@ -51,12 +53,13 @@ static struct vf_priv_s { int cfg_exp_x, cfg_exp_y; int exp_w,exp_h; int exp_x,exp_y; - int osd; + int osd_enabled; double aspect; int round; unsigned char* fb_ptr; int passthrough; int first_slice; + struct osd_state *osd; } const vf_priv_dflt = { -1,-1, -1,-1, @@ -70,13 +73,10 @@ static struct vf_priv_s { 0 }; -extern int opt_screen_size_x; -extern int opt_screen_size_y; - //===========================================================================// #ifdef OSD_SUPPORT -static struct vf_instance_s* vf=NULL; // fixme (needs sub.c changes) +static struct vf_instance* vf=NULL; // fixme (needs sub.c changes) static int orig_w,orig_h; static void remove_func_2(int x0,int y0, int w,int h){ @@ -122,7 +122,7 @@ static void remove_func(int x0,int y0, int w,int h){ } } -static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){ +static void draw_func(void *ctx, int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){ unsigned char* dst; if(!vo_osd_changed_flag && vf->dmpi->planes[0]==vf->priv->fb_ptr){ // ok, enough to update the area inside the video, leave the black bands @@ -182,7 +182,7 @@ static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned ch } } -static void draw_osd(struct vf_instance_s* vf_,int w,int h){ +static void draw_osd(struct vf_instance* vf_,int w,int h){ vf=vf_;orig_w=w;orig_h=h; // printf("======================================\n"); if(vf->priv->exp_w!=w || vf->priv->exp_h!=h || @@ -200,10 +200,10 @@ static void draw_osd(struct vf_instance_s* vf_,int w,int h){ remove_func_2(vf->priv->exp_x+w,vf->priv->exp_y,vf->priv->exp_w-w-vf->priv->exp_x,h); } else { // partial clear: - vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func); + osd_remove_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,remove_func); } } - vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func); + osd_draw_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,draw_func, NULL); // save buffer pointer for double buffering detection - yes, i know it's // ugly method, but note that codecs with DR support does the same... if(vf->dmpi) @@ -213,9 +213,11 @@ static void draw_osd(struct vf_instance_s* vf_,int w,int h){ #endif //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ + unsigned int flags, unsigned int outfmt) +{ + struct MPOpts *opts = vf->opts; if(outfmt == IMGFMT_MPEGPES) { vf->priv->passthrough = 1; return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); @@ -255,7 +257,7 @@ static int config(struct vf_instance_s* vf, if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2; vf->priv->fb_ptr=NULL; - if(!opt_screen_size_x && !opt_screen_size_y){ + if(!opts->screen_size_x && !opts->screen_size_y){ d_width=d_width*vf->priv->exp_w/width; d_height=d_height*vf->priv->exp_h/height; } @@ -268,12 +270,12 @@ static int config(struct vf_instance_s* vf, // codec -copy-> expand --DR--> vo // codec -copy-> expand -copy-> vo (worst case) -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ // if(mpi->type==MP_IMGTYPE_IPB) return; // not yet working #ifdef OSD_SUPPORT - if(vf->priv->osd && (mpi->flags&MP_IMGFLAG_PRESERVE)){ + if(vf->priv->osd_enabled && (mpi->flags&MP_IMGFLAG_PRESERVE)){ // check if we have to render osd! - vo_update_osd(vf->priv->exp_w, vf->priv->exp_h); + osd_update(vf->priv->osd, vf->priv->exp_w, vf->priv->exp_h); if(vo_osd_check_range_update(vf->priv->exp_x,vf->priv->exp_y, vf->priv->exp_x+mpi->w,vf->priv->exp_y+mpi->h)) return; } @@ -288,7 +290,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ #if 1 if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) && !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){ - mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible); + mp_tmsg(MSGT_VFILTER, MSGL_INFO, "Full DR not possible, trying SLICES instead!\n"); return; } #endif @@ -315,7 +317,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ } } -static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ +static void start_slice(struct vf_instance* vf, mp_image_t *mpi){ // printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK); if(!vf->next->draw_slice){ mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; @@ -329,11 +331,11 @@ static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ FFMAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x), FFMAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupportSlices); // shouldn't happen. + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "WARNING! Next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen. vf->priv->first_slice = 1; } -static void draw_top_blackbar_slice(struct vf_instance_s* vf, +static void draw_top_blackbar_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ if(vf->priv->exp_y>0 && y == 0) { vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride, @@ -342,7 +344,7 @@ static void draw_top_blackbar_slice(struct vf_instance_s* vf, } -static void draw_bottom_blackbar_slice(struct vf_instance_s* vf, +static void draw_bottom_blackbar_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ if(vf->priv->exp_y+vf->h<vf->dmpi->h && y+h == vf->h) { unsigned char *src2[MP_MAX_PLANES]; @@ -362,7 +364,7 @@ static void draw_bottom_blackbar_slice(struct vf_instance_s* vf, } } -static void draw_slice(struct vf_instance_s* vf, +static void draw_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ // printf("draw_slice() called %d at %d\n",h,y); @@ -385,7 +387,7 @@ static void draw_slice(struct vf_instance_s* vf, vf->priv->first_slice = 0; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ if (vf->priv->passthrough) { mp_image_t *dmpi = vf_get_image(vf->next, IMGFMT_MPEGPES, MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h); @@ -395,10 +397,10 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ vf->dmpi=mpi->priv; - if(!vf->dmpi) { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; } + if(!vf->dmpi) { mp_tmsg(MSGT_VFILTER, MSGL_WARN, "Why do we get NULL??\n"); return 0; } mpi->priv=NULL; #ifdef OSD_SUPPORT - if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h); + if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h); #endif // we've used DR, so we're ready... if(!(mpi->flags&MP_IMGFLAG_PLANAR)) @@ -433,24 +435,32 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette } #ifdef OSD_SUPPORT - if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h); + if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h); #endif return vf_next_put_image(vf,vf->dmpi, pts); } //===========================================================================// -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ #ifdef OSD_SUPPORT switch(request){ + case VFCTRL_SET_OSD_OBJ: + vf->priv->osd = data; + break; case VFCTRL_DRAW_OSD: - if(vf->priv->osd) return CONTROL_TRUE; + if(vf->priv->osd_enabled) return CONTROL_TRUE; + break; + case VFCTRL_REDRAW_OSD: + if (vf->priv->osd_enabled) + return false; + break; } #endif return vf_next_control(vf,request,data); } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ return vf_next_query_format(vf,fmt); } @@ -467,7 +477,7 @@ static int open(vf_instance_t *vf, char* args){ vf->priv->cfg_exp_h, vf->priv->cfg_exp_x, vf->priv->cfg_exp_y, - vf->priv->osd, + vf->priv->osd_enabled, vf->priv->aspect, vf->priv->round); return 1; @@ -479,13 +489,13 @@ static m_option_t vf_opts_fields[] = { {"h", ST_OFF(cfg_exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL}, {"x", ST_OFF(cfg_exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, {"y", ST_OFF(cfg_exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, - {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL}, + {"osd", ST_OFF(osd_enabled), CONF_TYPE_FLAG, 0 , 0, 1, NULL}, {"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL}, {"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "expand", sizeof(struct vf_priv_s), &vf_priv_dflt, diff --git a/libmpcodecs/vf_field.c b/libmpcodecs/vf_field.c index 3db6c5eef2..3640da1073 100644 --- a/libmpcodecs/vf_field.c +++ b/libmpcodecs/vf_field.c @@ -32,13 +32,13 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ return vf_next_config(vf,width,height/2,d_width,d_height,flags,outfmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE, mpi->width, mpi->height/2); @@ -61,7 +61,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } diff --git a/libmpcodecs/vf_fil.c b/libmpcodecs/vf_fil.c index ed45e8e2fb..60bb28b6a7 100644 --- a/libmpcodecs/vf_fil.c +++ b/libmpcodecs/vf_fil.c @@ -35,7 +35,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int pixel_stride= (width+15)&~15; //FIXME this is ust a guess ... especially for non planar its somewhat bad one @@ -63,7 +63,7 @@ static int config(struct vf_instance_s* vf, (d_width*vf->priv->stridefactor)>>1, 2*d_height/vf->priv->stridefactor, flags, outfmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ if(mpi->flags&MP_IMGFLAG_DIRECT){ // we've used DR, so we're ready... return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts); @@ -89,7 +89,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } diff --git a/libmpcodecs/vf_filmdint.c b/libmpcodecs/vf_filmdint.c index 47285c8bd1..33fd868654 100644 --- a/libmpcodecs/vf_filmdint.c +++ b/libmpcodecs/vf_filmdint.c @@ -24,6 +24,7 @@ #include "config.h" #include "mp_msg.h" #include "cpudetect.h" +#include "options.h" #include "img_format.h" #include "mp_image.h" @@ -97,9 +98,6 @@ struct vf_priv_s { static const struct frame_stats ppzs = {PPZ,PPZ,PPZ,PPZ,PPZ,PPZ,PPZ,0,0,9999}; static const struct frame_stats pprs = {PPR,PPR,PPR,PPR,PPR,PPR,PPR,0,0,9999}; -extern int opt_screen_size_x; -extern int opt_screen_size_y; - #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) #endif @@ -934,7 +932,7 @@ static inline double get_time(void) return tv.tv_sec + tv.tv_usec * 1e-6; } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) +static void get_image(struct vf_instance* vf, mp_image_t *mpi) { struct vf_priv_s *p = vf->priv; static unsigned char **planes, planes_idx; @@ -1138,7 +1136,7 @@ find_breaks(struct vf_priv_s *p, struct frame_stats *s) #define ITOC(X) (!(X) ? ' ' : (X) + ((X)>9 ? 'a'-10 : '0')) -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; struct vf_priv_s *p = vf->priv; @@ -1336,7 +1334,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return show_fields ? vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE) : 0; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - support more formats */ switch (fmt) { @@ -1351,10 +1349,11 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { + struct MPOpts *opts = vf->opts; unsigned long cxm = 0; unsigned long cym = 0; struct vf_priv_s *p = vf->priv; @@ -1389,14 +1388,14 @@ static int config(struct vf_instance_s* vf, if (p->crop_x + p->w > width ) p->crop_x = 0; if (p->crop_y + p->h > height) p->crop_y = 0; - if(!opt_screen_size_x && !opt_screen_size_y){ + if(!opts->screen_size_x && !opts->screen_size_y){ d_width = d_width * p->w/width; d_height = d_height * p->h/height; } return vf_next_config(vf, p->w, p->h, d_width, d_height, flags, outfmt); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { struct vf_priv_s *p = vf->priv; mp_msg(MSGT_VFILTER, MSGL_INFO, "diff_time: %.3f, merge_time: %.3f, " diff --git a/libmpcodecs/vf_flip.c b/libmpcodecs/vf_flip.c index 3a59450fcf..a6663600b9 100644 --- a/libmpcodecs/vf_flip.c +++ b/libmpcodecs/vf_flip.c @@ -30,14 +30,14 @@ //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ flags&=~VOFLAG_FLIPPING; // remove the FLIP flag return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE){ // try full DR ! vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, @@ -59,7 +59,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ if(mpi->flags&MP_IMGFLAG_DIRECT){ // we've used DR, so we're ready... if(!(mpi->flags&MP_IMGFLAG_PLANAR)) diff --git a/libmpcodecs/vf_format.c b/libmpcodecs/vf_format.c index a729016dc3..8711d2acef 100644 --- a/libmpcodecs/vf_format.c +++ b/libmpcodecs/vf_format.c @@ -40,7 +40,7 @@ static struct vf_priv_s { //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt==vf->priv->fmt) return vf_next_query_format(vf,fmt); return 0; @@ -53,12 +53,12 @@ static int open(vf_instance_t *vf, char* args){ } #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { +static const m_option_t vf_opts_fields[] = { {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "format", sizeof(struct vf_priv_s), &vf_priv_dflt, diff --git a/libmpcodecs/vf_framestep.c b/libmpcodecs/vf_framestep.c index ba24d07ec3..2c3d5ad2f9 100644 --- a/libmpcodecs/vf_framestep.c +++ b/libmpcodecs/vf_framestep.c @@ -89,7 +89,7 @@ struct vf_priv_s { }; /* Filter handler */ -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; struct vf_priv_s *priv; @@ -146,7 +146,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { /* Free private data */ free(vf->priv); @@ -186,7 +186,7 @@ static int open(vf_instance_t *vf, char* args) if (*args != '\0') { p->frame_step = atoi(args); if (p->frame_step <= 0) { - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_ErrorParsingArgument); + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[VF_FRAMESTEP] Error parsing argument.\n"); return 0; } } @@ -203,5 +203,3 @@ const vf_info_t vf_info_framestep = { open, NULL }; - - diff --git a/libmpcodecs/vf_fspp.c b/libmpcodecs/vf_fspp.c index 952dced086..a2507a22f0 100644 --- a/libmpcodecs/vf_fspp.c +++ b/libmpcodecs/vf_fspp.c @@ -485,7 +485,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, } } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -499,7 +499,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) +static void get_image(struct vf_instance* vf, mp_image_t *mpi) { if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place (or pp disabled): @@ -517,7 +517,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ @@ -571,7 +571,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { if(!vf->priv) return; @@ -590,7 +590,7 @@ static void uninit(struct vf_instance_s* vf) //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch(fmt){ case IMGFMT_YVU9: @@ -609,7 +609,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int control(struct vf_instance_s* vf, int request, void* data) +static int control(struct vf_instance* vf, int request, void* data) { switch(request){ case VFCTRL_QUERY_MAX_PP_LEVEL: diff --git a/libmpcodecs/vf_geq.c b/libmpcodecs/vf_geq.c index 21da7e2000..d2cbe6554b 100644 --- a/libmpcodecs/vf_geq.c +++ b/libmpcodecs/vf_geq.c @@ -42,13 +42,13 @@ struct vf_priv_s { mp_image_t *mpi; }; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static inline double getpix(struct vf_instance_s* vf, double x, double y, int plane){ +static inline double getpix(struct vf_instance* vf, double x, double y, int plane){ int xi, yi; mp_image_t *mpi= vf->priv->mpi; int stride= mpi->stride[plane]; @@ -66,19 +66,19 @@ static inline double getpix(struct vf_instance_s* vf, double x, double y, int pl //FIXME cubic interpolate //FIXME keep the last few frames -static double lum(struct vf_instance_s* vf, double x, double y){ +static double lum(struct vf_instance* vf, double x, double y){ return getpix(vf, x, y, 0); } -static double cb(struct vf_instance_s* vf, double x, double y){ +static double cb(struct vf_instance* vf, double x, double y){ return getpix(vf, x, y, 1); } -static double cr(struct vf_instance_s* vf, double x, double y){ +static double cr(struct vf_instance* vf, double x, double y){ return getpix(vf, x, y, 2); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int x,y, plane; @@ -126,7 +126,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; av_free(vf->priv); @@ -151,7 +151,7 @@ static int open(vf_instance_t *vf, char* args){ if (!eq[2][0]) strncpy(eq[2], eq[1], sizeof(eq[0])-1); for(plane=0; plane<3; plane++){ - static const char *const_names[]={ + const char * const const_names[]={ "PI", "E", "X", @@ -163,7 +163,7 @@ static int open(vf_instance_t *vf, char* args){ "SH", NULL }; - static const char *func2_names[]={ + const char * const func2_names[]={ "lum", "cb", "cr", diff --git a/libmpcodecs/vf_gradfun.c b/libmpcodecs/vf_gradfun.c index 7089af1b57..83ae6fb9d6 100644 --- a/libmpcodecs/vf_gradfun.c +++ b/libmpcodecs/vf_gradfun.c @@ -39,7 +39,7 @@ #include "vf.h" #include "libvo/fastmemcpy.h" #include "libavutil/avutil.h" -#include "libavutil/x86_cpu.h" +#include "ffmpeg_files/x86_cpu.h" struct vf_priv_s { int thresh; @@ -273,7 +273,7 @@ static void filter(struct vf_priv_s *ctx, uint8_t *dst, uint8_t *src, } } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) +static void get_image(struct vf_instance *vf, mp_image_t *mpi) { if (mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place: @@ -291,7 +291,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) mpi->flags |= MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi = vf->dmpi; int p; @@ -325,7 +325,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf, dmpi, pts); } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance *vf, unsigned int fmt) { switch (fmt){ case IMGFMT_YVU9: @@ -347,7 +347,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -356,7 +356,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance *vf) { if (!vf->priv) return; av_free(vf->priv->buf); diff --git a/libmpcodecs/vf_halfpack.c b/libmpcodecs/vf_halfpack.c index 1c7bdcad28..3c8a6b580a 100644 --- a/libmpcodecs/vf_halfpack.c +++ b/libmpcodecs/vf_halfpack.c @@ -163,7 +163,7 @@ static void (*halfpack)(unsigned char *dst, unsigned char *src[3], int dststride, int srcstride[3], int w, int h); -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { const uint8_t *src[MP_MAX_PLANES] = { mpi->planes[0] + mpi->stride[0]*vf->priv->field, @@ -190,7 +190,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf,dmpi, pts); } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -208,7 +208,7 @@ static int config(struct vf_instance_s* vf, } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - really any YUV 4:2:0 input format should work */ switch (fmt) { @@ -220,7 +220,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { sws_freeContext(vf->priv->ctx); free(vf->priv); @@ -252,4 +252,3 @@ const vf_info_t vf_info_halfpack = { open, NULL }; - diff --git a/libmpcodecs/vf_harddup.c b/libmpcodecs/vf_harddup.c index a276088288..07d47a1737 100644 --- a/libmpcodecs/vf_harddup.c +++ b/libmpcodecs/vf_harddup.c @@ -31,7 +31,7 @@ struct vf_priv_s { mp_image_t *last_mpi; }; -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; @@ -52,7 +52,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf, dmpi, pts); } -static int control(struct vf_instance_s* vf, int request, void* data) +static int control(struct vf_instance* vf, int request, void* data) { switch (request) { case VFCTRL_DUPLICATE_FRAME: @@ -68,7 +68,7 @@ static int control(struct vf_instance_s* vf, int request, void* data) return vf_next_control(vf, request, data); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -90,5 +90,3 @@ const vf_info_t vf_info_harddup = { open, NULL }; - - diff --git a/libmpcodecs/vf_hqdn3d.c b/libmpcodecs/vf_hqdn3d.c index 3e4246de91..a62854c2da 100644 --- a/libmpcodecs/vf_hqdn3d.c +++ b/libmpcodecs/vf_hqdn3d.c @@ -44,14 +44,14 @@ struct vf_priv_s { /***************************************************************************/ -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(vf->priv->Line){free(vf->priv->Line);vf->priv->Line=NULL;} if(vf->priv->Frame[0]){free(vf->priv->Frame[0]);vf->priv->Frame[0]=NULL;} if(vf->priv->Frame[1]){free(vf->priv->Frame[1]);vf->priv->Frame[1]=NULL;} if(vf->priv->Frame[2]){free(vf->priv->Frame[2]);vf->priv->Frame[2]=NULL;} } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -202,7 +202,7 @@ static void deNoise(unsigned char *Frame, // mpi->planes[x] } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int cw= mpi->w >> mpi->chroma_x_shift; int ch= mpi->h >> mpi->chroma_y_shift; int W = mpi->w, H = mpi->h; @@ -237,7 +237,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: diff --git a/libmpcodecs/vf_hue.c b/libmpcodecs/vf_hue.c index 2e8f04cf72..bc7ab21d34 100644 --- a/libmpcodecs/vf_hue.c +++ b/libmpcodecs/vf_hue.c @@ -76,7 +76,7 @@ static void (*process)(uint8_t *udst, uint8_t *vdst, uint8_t *usrc, uint8_t *vsr /* FIXME: add packed yuv version of process */ -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; @@ -110,7 +110,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf,dmpi, pts); } -static int control(struct vf_instance_s* vf, int request, void* data) +static int control(struct vf_instance* vf, int request, void* data) { vf_equalizer_t *eq; @@ -139,7 +139,7 @@ static int control(struct vf_instance_s* vf, int request, void* data) return vf_next_control(vf, request, data); } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch (fmt) { case IMGFMT_YVU9: @@ -156,7 +156,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { if (vf->priv->buf[0]) free(vf->priv->buf[0]); if (vf->priv->buf[1]) free(vf->priv->buf[1]); @@ -177,13 +177,13 @@ static int open(vf_instance_t *vf, char* args) } #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { +static const m_option_t vf_opts_fields[] = { {"hue", ST_OFF(hue), CONF_TYPE_FLOAT, M_OPT_RANGE,-180.0 ,180.0, NULL}, {"saturation", ST_OFF(saturation), CONF_TYPE_FLOAT, M_OPT_RANGE,-10.0 ,10.0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "hue", sizeof(struct vf_priv_s), &vf_priv_dflt, @@ -198,4 +198,3 @@ const vf_info_t vf_info_hue = { open, &vf_opts }; - diff --git a/libmpcodecs/vf_il.c b/libmpcodecs/vf_il.c index cc70192fe1..724dedb2d0 100644 --- a/libmpcodecs/vf_il.c +++ b/libmpcodecs/vf_il.c @@ -73,7 +73,7 @@ static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int w; FilterParam *luma = &vf->priv->lumaParam; FilterParam *chroma= &vf->priv->chromaParam; diff --git a/libmpcodecs/vf_ilpack.c b/libmpcodecs/vf_ilpack.c index 917d337702..0e0e48aefc 100644 --- a/libmpcodecs/vf_ilpack.c +++ b/libmpcodecs/vf_ilpack.c @@ -369,7 +369,7 @@ static void ilpack(unsigned char *dst, unsigned char *src[3], } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; @@ -383,7 +383,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf,dmpi, pts); } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -392,7 +392,7 @@ static int config(struct vf_instance_s* vf, } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - really any YUV 4:2:0 input format should work */ switch (fmt) { @@ -451,4 +451,3 @@ const vf_info_t vf_info_ilpack = { open, NULL }; - diff --git a/libmpcodecs/vf_ivtc.c b/libmpcodecs/vf_ivtc.c index 1a004efc96..d8db3b006f 100644 --- a/libmpcodecs/vf_ivtc.c +++ b/libmpcodecs/vf_ivtc.c @@ -426,7 +426,7 @@ static void copy_image(mp_image_t *dmpi, mp_image_t *mpi, int field) } } -static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi) +static int do_put_image(struct vf_instance* vf, mp_image_t *dmpi) { struct vf_priv_s *p = vf->priv; int dropflag=0; @@ -455,7 +455,7 @@ static int do_put_image(struct vf_instance_s* vf, mp_image_t *dmpi) return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { int ret=0; struct vf_priv_s *p = vf->priv; @@ -506,7 +506,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return ret; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch (fmt) { case IMGFMT_YV12: @@ -517,7 +517,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -548,5 +548,3 @@ const vf_info_t vf_info_ivtc = { open, NULL }; - - diff --git a/libmpcodecs/vf_kerndeint.c b/libmpcodecs/vf_kerndeint.c index a2bc0ed0c0..359dfb9469 100644 --- a/libmpcodecs/vf_kerndeint.c +++ b/libmpcodecs/vf_kerndeint.c @@ -47,7 +47,7 @@ struct vf_priv_s { /***************************************************************************/ -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -55,7 +55,7 @@ static int config(struct vf_instance_s* vf, } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -74,7 +74,7 @@ static inline int IsYUY2(mp_image_t *mpi) #define PLANAR_U 1 #define PLANAR_V 2 -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int cw= mpi->w >> mpi->chroma_x_shift; int ch= mpi->h >> mpi->chroma_y_shift; int W = mpi->w, H = mpi->h; @@ -278,7 +278,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: @@ -289,7 +289,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ switch (request) { case VFCTRL_GET_DEINTERLACE: diff --git a/libmpcodecs/vf_lavc.c b/libmpcodecs/vf_lavc.c index 888ec1d86b..767aeda8f4 100644 --- a/libmpcodecs/vf_lavc.c +++ b/libmpcodecs/vf_lavc.c @@ -45,7 +45,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ if(vf_next_query_format(vf,IMGFMT_MPEGPES)<=0) return 0; @@ -75,7 +75,7 @@ static int config(struct vf_instance_s* vf, vf->priv->outbuf = malloc(vf->priv->outbuf_size); if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) { - mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec); + mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Could not open codec.\n"); return 0; } @@ -87,7 +87,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_MPEGPES); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t* dmpi; int out_size; AVFrame *pic= vf->priv->pic; @@ -120,7 +120,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: @@ -148,7 +148,7 @@ static int open(vf_instance_t *vf, char* args){ vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name("mpeg1video"); if (!vf->priv->codec) { - mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, "mpeg1video"); + mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Cannot find codec '%s' in libavcodec...\n", "mpeg1video"); return 0; } diff --git a/libmpcodecs/vf_lavcdeint.c b/libmpcodecs/vf_lavcdeint.c index 605ff2a35f..7f1d764b1c 100644 --- a/libmpcodecs/vf_lavcdeint.c +++ b/libmpcodecs/vf_lavcdeint.c @@ -88,7 +88,7 @@ imgfmt_to_pixfmt (int imgfmt) static int -config (struct vf_instance_s* vf, +config (struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -114,7 +114,7 @@ config (struct vf_instance_s* vf, } static int -put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts) +put_image (struct vf_instance* vf, mp_image_t *mpi, double pts) { struct vf_priv_s *priv = vf->priv; mp_image_t* dmpi; @@ -151,7 +151,7 @@ put_image (struct vf_instance_s* vf, mp_image_t *mpi, double pts) static int -query_format (struct vf_instance_s* vf, unsigned int fmt) +query_format (struct vf_instance* vf, unsigned int fmt) { if(imgfmt_to_pixfmt(fmt) == -1) return 0; diff --git a/libmpcodecs/vf_mcdeint.c b/libmpcodecs/vf_mcdeint.c index 2bd3c9da73..1dbe096349 100644 --- a/libmpcodecs/vf_mcdeint.c +++ b/libmpcodecs/vf_mcdeint.c @@ -54,15 +54,10 @@ Known Issues: #include "mp_msg.h" #include "cpudetect.h" -#include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" -#undef fprintf -#undef free -#undef malloc - #include "img_format.h" #include "mp_image.h" #include "vf.h" @@ -178,7 +173,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int ds } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int i; @@ -235,7 +230,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change return; //caused problems, dunno why // ok, we can do pp in-place (or pp disabled): @@ -253,7 +248,7 @@ return; //caused problems, dunno why mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ @@ -272,7 +267,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; #if 0 @@ -294,7 +289,7 @@ static void uninit(struct vf_instance_s* vf){ } //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: diff --git a/libmpcodecs/vf_mirror.c b/libmpcodecs/vf_mirror.c index bb67643a7a..36441ddedb 100644 --- a/libmpcodecs/vf_mirror.c +++ b/libmpcodecs/vf_mirror.c @@ -83,7 +83,7 @@ static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcst //===========================================================================// -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; // hope we'll get DR buffer: diff --git a/libmpcodecs/vf_noformat.c b/libmpcodecs/vf_noformat.c index 8f4009189e..dfceb8c906 100644 --- a/libmpcodecs/vf_noformat.c +++ b/libmpcodecs/vf_noformat.c @@ -40,7 +40,7 @@ static struct vf_priv_s { //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if(fmt!=vf->priv->fmt) return vf_next_query_format(vf,fmt); return 0; @@ -53,12 +53,12 @@ static int open(vf_instance_t *vf, char* args){ } #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { +static const m_option_t vf_opts_fields[] = { {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "noformat", sizeof(struct vf_priv_s), &vf_priv_dflt, diff --git a/libmpcodecs/vf_noise.c b/libmpcodecs/vf_noise.c index 625fe67cc3..6fdc5e20c5 100644 --- a/libmpcodecs/vf_noise.c +++ b/libmpcodecs/vf_noise.c @@ -312,14 +312,14 @@ static void noise(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int if (fp->shiftptr == 3) fp->shiftptr = 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ // ok, we can do pp in-place (or pp disabled): @@ -337,7 +337,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ @@ -366,7 +366,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; if(vf->priv->chromaParam.noise) free(vf->priv->chromaParam.noise); @@ -381,7 +381,7 @@ static void uninit(struct vf_instance_s* vf){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: @@ -416,7 +416,7 @@ static void parse(FilterParam *fp, char* args){ if(fp->strength) initNoise(fp); } -static unsigned int fmt_list[]={ +static const unsigned int fmt_list[]={ IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, diff --git a/libmpcodecs/vf_ow.c b/libmpcodecs/vf_ow.c index 543d6c8289..16d6ccbc56 100644 --- a/libmpcodecs/vf_ow.c +++ b/libmpcodecs/vf_ow.c @@ -203,7 +203,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stri // printf("%f\n", sum/height/width); } -static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int h= (height+15)&(~15); int i,j; @@ -216,7 +216,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place (or pp disabled): vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, @@ -233,7 +233,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ @@ -254,7 +254,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ int i,j; if(!vf->priv) return; @@ -270,7 +270,7 @@ static void uninit(struct vf_instance_s* vf){ } //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YVU9: case IMGFMT_IF09: diff --git a/libmpcodecs/vf_palette.c b/libmpcodecs/vf_palette.c index 92b5092d3b..52bf3ceefc 100644 --- a/libmpcodecs/vf_palette.c +++ b/libmpcodecs/vf_palette.c @@ -37,14 +37,14 @@ // routines are incorrrect. they assume the palette to be of the same // depth as the output, which is incorrect. --Joey -static unsigned int bgr_list[]={ +static const unsigned int bgr_list[]={ IMGFMT_BGR32, IMGFMT_BGR24, // IMGFMT_BGR16, // IMGFMT_BGR15, 0 }; -static unsigned int rgb_list[]={ +static const unsigned int rgb_list[]={ IMGFMT_RGB32, IMGFMT_RGB24, // IMGFMT_RGB16, @@ -54,10 +54,10 @@ static unsigned int rgb_list[]={ static unsigned int gray_pal[256]; -static unsigned int find_best(struct vf_instance_s* vf, unsigned int fmt){ +static unsigned int find_best(struct vf_instance* vf, unsigned int fmt){ unsigned int best=0; int ret; - unsigned int* p; + const unsigned int* p; if(fmt==IMGFMT_BGR8) p=bgr_list; else if(fmt==IMGFMT_RGB8) p=rgb_list; else return 0; @@ -78,7 +78,7 @@ struct vf_priv_s { int pal_msg; }; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ if (!vf->priv->fmt) @@ -92,7 +92,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; uint8_t *old_palette = mpi->planes[1]; @@ -178,7 +178,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ int best=find_best(vf,fmt); if(!best) return 0; // no match return vf->next->query_format(vf->next,best); @@ -208,7 +208,7 @@ static int open(vf_instance_t *vf, char* args){ if (!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else if (!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else { - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args); + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "[VF_FORMAT] Unknown format name: '%s'.\n", args); return 0; } } diff --git a/libmpcodecs/vf_perspective.c b/libmpcodecs/vf_perspective.c index 8cc3dc8e17..daba3cd2a9 100644 --- a/libmpcodecs/vf_perspective.c +++ b/libmpcodecs/vf_perspective.c @@ -102,7 +102,7 @@ static double getCoeff(double d){ return coeff; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int i, j; @@ -129,7 +129,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; if(vf->priv->pv) free(vf->priv->pv); @@ -258,7 +258,7 @@ static inline void resampleLinear(uint8_t *dst, uint8_t *src, int w, int h, int } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int cw= mpi->w >> mpi->chroma_x_shift; int ch= mpi->h >> mpi->chroma_y_shift; @@ -289,7 +289,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: diff --git a/libmpcodecs/vf_phase.c b/libmpcodecs/vf_phase.c index 75b7293009..b299905373 100644 --- a/libmpcodecs/vf_phase.c +++ b/libmpcodecs/vf_phase.c @@ -196,7 +196,7 @@ static enum mode analyze_plane(unsigned char *old, unsigned char *new, return mode; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; int w; @@ -240,7 +240,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv->buf[0]); free(vf->priv->buf[1]); diff --git a/libmpcodecs/vf_pp.c b/libmpcodecs/vf_pp.c index d0b5f0ada8..8ede366973 100644 --- a/libmpcodecs/vf_pp.c +++ b/libmpcodecs/vf_pp.c @@ -33,16 +33,8 @@ #include "img_format.h" #include "mp_image.h" #include "vf.h" -#include "libavutil/internal.h" #include "libpostproc/postprocess.h" -#ifdef CONFIG_LIBPOSTPROC_A -#define EMU_OLD -#include "libpostproc/postprocess_internal.h" -#endif - -#undef malloc - struct vf_priv_s { int pp; pp_mode_t *ppMode[PP_QUALITY_MAX+1]; @@ -52,7 +44,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int voflags, unsigned int outfmt){ int flags= @@ -73,7 +65,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,voflags,outfmt); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ int i; for(i=0; i<=PP_QUALITY_MAX; i++){ if(vf->priv->ppMode[i]) @@ -82,7 +74,7 @@ static void uninit(struct vf_instance_s* vf){ if(vf->priv->context) pp_free_context(vf->priv->context); } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: @@ -95,7 +87,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ switch(request){ case VFCTRL_QUERY_MAX_PP_LEVEL: return PP_QUALITY_MAX; @@ -106,7 +98,7 @@ static int control(struct vf_instance_s* vf, int request, void* data){ return vf_next_control(vf,request,data); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(vf->priv->pp&0xFFFF) return; // non-local filters enabled if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) && mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change @@ -127,7 +119,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ // no DR, so get a new image! hope we'll get DR buffer: vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, @@ -159,7 +151,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ extern int divx_quality; -static unsigned int fmt_list[]={ +static const unsigned int fmt_list[]={ IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, @@ -198,35 +190,10 @@ static int open(vf_instance_t *vf, char* args){ name="de"; } -#ifdef EMU_OLD - if(name){ -#endif for(i=0; i<=PP_QUALITY_MAX; i++){ vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(name, i); if(vf->priv->ppMode[i]==NULL) return -1; } -#ifdef EMU_OLD - }else{ - /* hex mode for compatibility */ - for(i=0; i<=PP_QUALITY_MAX; i++){ - PPMode *ppMode; - - ppMode= (PPMode*)memalign(8, sizeof(PPMode)); - - ppMode->lumMode= hex_mode; - ppMode->chromMode= ((hex_mode&0xFF)>>4) | (hex_mode&0xFFFFFF00); - ppMode->maxTmpNoise[0]= 700; - ppMode->maxTmpNoise[1]= 1500; - ppMode->maxTmpNoise[2]= 3000; - ppMode->maxAllowedY= 234; - ppMode->minAllowedY= 16; - ppMode->baseDcDiff= 256/4; - ppMode->flatnessThreshold=40; - - vf->priv->ppMode[i]= ppMode; - } - } -#endif vf->priv->pp=PP_QUALITY_MAX; return 1; @@ -242,4 +209,3 @@ const vf_info_t vf_info_pp = { }; //===========================================================================// - diff --git a/libmpcodecs/vf_pp7.c b/libmpcodecs/vf_pp7.c index 78d2ba640d..56b196a3a3 100644 --- a/libmpcodecs/vf_pp7.c +++ b/libmpcodecs/vf_pp7.c @@ -344,7 +344,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stri } } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int h= (height+16+15)&(~15); @@ -355,7 +355,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place (or pp disabled): vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, @@ -372,7 +372,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(mpi->flags&MP_IMGFLAG_DIRECT){ @@ -407,7 +407,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; if(vf->priv->src) free(vf->priv->src); @@ -418,7 +418,7 @@ static void uninit(struct vf_instance_s* vf){ } //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YVU9: case IMGFMT_IF09: @@ -436,7 +436,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ return vf_next_control(vf,request,data); } diff --git a/libmpcodecs/vf_pullup.c b/libmpcodecs/vf_pullup.c index 1961f5f066..fe84307458 100644 --- a/libmpcodecs/vf_pullup.c +++ b/libmpcodecs/vf_pullup.c @@ -42,7 +42,7 @@ struct vf_priv_s { char *qbuf; }; -static void init_pullup(struct vf_instance_s* vf, mp_image_t *mpi) +static void init_pullup(struct vf_instance* vf, mp_image_t *mpi) { struct pullup_context *c = vf->priv->ctx; @@ -78,7 +78,7 @@ static void init_pullup(struct vf_instance_s* vf, mp_image_t *mpi) #if 0 -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) +static void get_image(struct vf_instance* vf, mp_image_t *mpi) { struct pullup_context *c = vf->priv->ctx; struct pullup_buffer *b; @@ -104,7 +104,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) } #endif -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { struct pullup_context *c = vf->priv->ctx; struct pullup_buffer *b; @@ -254,7 +254,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return ret; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - support more formats */ switch (fmt) { @@ -266,7 +266,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -274,7 +274,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { pullup_free_context(vf->priv->ctx); free(vf->priv); @@ -312,5 +312,3 @@ const vf_info_t vf_info_pullup = { open, NULL }; - - diff --git a/libmpcodecs/vf_qp.c b/libmpcodecs/vf_qp.c index 68449f62d0..ec0646265f 100644 --- a/libmpcodecs/vf_qp.c +++ b/libmpcodecs/vf_qp.c @@ -42,7 +42,7 @@ struct vf_priv_s { int qp_stride; }; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int h= (height+15)>>4; @@ -59,7 +59,7 @@ static int config(struct vf_instance_s* vf, i, 0 }; - static const char *const_names[]={ + const char * const const_names[]={ "PI", "E", "known", @@ -76,7 +76,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place (or pp disabled): vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, @@ -93,7 +93,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int x,y; @@ -136,7 +136,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; if(vf->priv->qp) av_free(vf->priv->qp); diff --git a/libmpcodecs/vf_rectangle.c b/libmpcodecs/vf_rectangle.c index c7d9980003..c80c3a0f39 100644 --- a/libmpcodecs/vf_rectangle.c +++ b/libmpcodecs/vf_rectangle.c @@ -31,7 +31,7 @@ struct vf_priv_s { }; static int -config(struct vf_instance_s* vf, +config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -52,7 +52,7 @@ config(struct vf_instance_s* vf, } static int -control(struct vf_instance_s* vf, int request, void *data) +control(struct vf_instance* vf, int request, void *data) { const int *const tmp = data; switch(request){ @@ -83,7 +83,7 @@ control(struct vf_instance_s* vf, int request, void *data) return 0; } static int -put_image(struct vf_instance_s* vf, mp_image_t* mpi, double pts){ +put_image(struct vf_instance* vf, mp_image_t* mpi, double pts){ mp_image_t* dmpi; unsigned int bpp = mpi->bpp / 8; int x, y, w, h; diff --git a/libmpcodecs/vf_remove_logo.c b/libmpcodecs/vf_remove_logo.c index 7b9c66aeb1..8397ae53cf 100644 --- a/libmpcodecs/vf_remove_logo.c +++ b/libmpcodecs/vf_remove_logo.c @@ -670,7 +670,7 @@ static pgm_structure * generate_half_size_image(vf_instance_t * vf, pgm_structur /** * \brief Checks if YV12 is supported by the next filter. */ -static unsigned int find_best(struct vf_instance_s* vf){ +static unsigned int find_best(struct vf_instance* vf){ int is_format_okay = vf->next->query_format(vf->next, IMGFMT_YV12); if ((is_format_okay & VFCAP_CSP_SUPPORTED_BY_HW) || (is_format_okay & VFCAP_CSP_SUPPORTED)) return IMGFMT_YV12; @@ -683,7 +683,7 @@ static unsigned int find_best(struct vf_instance_s* vf){ /** * \brief Configure the filter and call the next filter's config function. */ -static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { if(!(((vf_priv_s *)vf->priv)->fmt=find_best(vf))) return 0; @@ -764,7 +764,7 @@ static void convert_yv12(const vf_instance_t * const vf, const char * const sour * filter, has the logo removed by the filter, and is then sent to the next * filter. */ -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; dmpi=vf_get_image(vf->next,((vf_priv_s *)vf->priv)->fmt, @@ -811,7 +811,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ /** * \brief Checks to see if the next filter accepts YV12 images. */ -static int query_format(struct vf_instance_s * vf, unsigned int fmt) +static int query_format(struct vf_instance * vf, unsigned int fmt) { if (fmt == IMGFMT_YV12) return vf->next->query_format(vf->next, IMGFMT_YV12); @@ -877,7 +877,7 @@ static int open(vf_instance_t * vf, char * args) * * This is called at exit-time. */ -void uninit(vf_instance_t * vf) +static void uninit(vf_instance_t * vf) { /* Destroy our masks and images. */ destroy_pgm(((vf_priv_s *)vf->priv)->filter); diff --git a/libmpcodecs/vf_rgb2bgr.c b/libmpcodecs/vf_rgb2bgr.c index a32dd40995..b1fa17d098 100644 --- a/libmpcodecs/vf_rgb2bgr.c +++ b/libmpcodecs/vf_rgb2bgr.c @@ -54,14 +54,14 @@ static unsigned int getfmt(unsigned int outfmt,int forced){ return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ vf->priv->fmt=getfmt(outfmt,vf->priv->forced); return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; // hope we'll get DR buffer: @@ -94,7 +94,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int outfmt){ +static int query_format(struct vf_instance* vf, unsigned int outfmt){ unsigned int fmt=getfmt(outfmt,vf->priv->forced); if(!fmt) return 0; return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW); diff --git a/libmpcodecs/vf_rgbtest.c b/libmpcodecs/vf_rgbtest.c index d19315b63f..1252b4018a 100644 --- a/libmpcodecs/vf_rgbtest.c +++ b/libmpcodecs/vf_rgbtest.c @@ -95,7 +95,7 @@ static void put_pixel(uint8_t *buf, int x, int y, int stride, int r, int g, int } } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ if (vf->priv->w > 0) { d_width = width = vf->priv->w; } @@ -105,7 +105,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int x, y; int w = vf->priv->w > 0 ? vf->priv->w : mpi->w; @@ -134,7 +134,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int outfmt){ +static int query_format(struct vf_instance* vf, unsigned int outfmt){ unsigned int fmt=getfmt(outfmt); if(!fmt) return 0; return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW); diff --git a/libmpcodecs/vf_rotate.c b/libmpcodecs/vf_rotate.c index 04095da5f5..6a4672aa84 100644 --- a/libmpcodecs/vf_rotate.c +++ b/libmpcodecs/vf_rotate.c @@ -68,7 +68,7 @@ static void rotate(unsigned char* dst,unsigned char* src,int dststride,int srcst //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ if (vf->priv->direction & 4) { @@ -84,7 +84,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,height,width,d_height,d_width,flags,outfmt); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; // hope we'll get DR buffer: @@ -114,7 +114,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if(IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt)) return vf_next_query_format(vf, fmt); // we can support only symmetric (chroma_x_shift==chroma_y_shift) YUV formats: switch(fmt) { diff --git a/libmpcodecs/vf_sab.c b/libmpcodecs/vf_sab.c index 1616f1eba1..839392d9e0 100644 --- a/libmpcodecs/vf_sab.c +++ b/libmpcodecs/vf_sab.c @@ -135,7 +135,7 @@ static int allocStuff(FilterParam *f, int width, int height){ return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -160,7 +160,7 @@ static void freeBuffers(FilterParam *f){ f->distCoeff=NULL; } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; freeBuffers(&vf->priv->luma); @@ -238,7 +238,7 @@ if((x/32)&1){ } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int cw= mpi->w >> mpi->chroma_x_shift; int ch= mpi->h >> mpi->chroma_y_shift; @@ -257,7 +257,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c index 9f96ad84d9..208136e812 100644 --- a/libmpcodecs/vf_scale.c +++ b/libmpcodecs/vf_scale.c @@ -24,6 +24,7 @@ #include "config.h" #include "mp_msg.h" #include "cpudetect.h" +#include "options.h" #include "img_format.h" #include "mp_image.h" @@ -58,15 +59,11 @@ static struct vf_priv_s { NULL }; -extern int opt_screen_size_x; -extern int opt_screen_size_y; -extern float screen_size_xy; - //===========================================================================// void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); -static unsigned int outfmt_list[]={ +static const unsigned int outfmt_list[]={ // YUV: IMGFMT_444P, IMGFMT_444P16_LE, @@ -166,9 +163,10 @@ static unsigned int find_best_out(vf_instance_t *vf, int in_format){ return best; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ + struct MPOpts *opts = vf->opts; unsigned int best=find_best_out(vf, outfmt); int vo_flags; int int_sws_flags=0; @@ -350,7 +348,8 @@ static int config(struct vf_instance_s* vf, break; } } - if(!opt_screen_size_x && !opt_screen_size_y && !(screen_size_xy >= 0.001)){ + if (!opts->screen_size_x && !opts->screen_size_y + && !(opts->screen_size_xy >= 0.001)) { // Compute new d_width and d_height, preserving aspect // while ensuring that both are >= output size in pixels. if (vf->priv->h * d_width > vf->priv->w * d_height) { @@ -366,7 +365,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best); } -static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ +static void start_slice(struct vf_instance* vf, mp_image_t *mpi){ // printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK); if(!(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) return; // shouldn't happen // they want slices!!! allocate the buffer. @@ -406,7 +405,7 @@ static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src } } -static void draw_slice(struct vf_instance_s* vf, +static void draw_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ mp_image_t *dmpi=vf->dmpi; if(!dmpi){ @@ -417,7 +416,7 @@ static void draw_slice(struct vf_instance_s* vf, scale(vf->priv->ctx, vf->priv->ctx2, src, stride, y, h, dmpi->planes, dmpi->stride, vf->priv->interlaced); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi=mpi->priv; // printf("vf_scale::put_image(): processing whole frame! dmpi=%p flag=%d\n", @@ -444,7 +443,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ int *table; int *inv_table; int r; @@ -507,7 +506,7 @@ static int control(struct vf_instance_s* vf, int request, void* data){ // supported Input formats: YV12, I420, IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8, Y800 -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: @@ -556,7 +555,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; // nomatching in-fmt } -static void uninit(struct vf_instance_s *vf){ +static void uninit(struct vf_instance *vf){ if(vf->priv->ctx) sws_freeContext(vf->priv->ctx); if(vf->priv->ctx2) sws_freeContext(vf->priv->ctx2); if(vf->priv->palette) free(vf->priv->palette); @@ -658,7 +657,7 @@ struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat, } /// An example of presets usage -static struct size_preset { +static const struct size_preset { char* name; int w, h; } vf_size_presets_defs[] = { @@ -673,21 +672,21 @@ static struct size_preset { }; #define ST_OFF(f) M_ST_OFF(struct size_preset,f) -static m_option_t vf_size_preset_fields[] = { +static const m_option_t vf_size_preset_fields[] = { {"w", ST_OFF(w), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL}, {"h", ST_OFF(h), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_size_preset = { +static const m_struct_t vf_size_preset = { "scale_size_preset", sizeof(struct size_preset), NULL, vf_size_preset_fields }; -static m_struct_t vf_opts; -static m_obj_presets_t size_preset = { +static const m_struct_t vf_opts; +static const m_obj_presets_t size_preset = { &vf_size_preset, // Input struct desc &vf_opts, // Output struct desc vf_size_presets_defs, // The list of presets @@ -697,7 +696,7 @@ static m_obj_presets_t size_preset = { /// Now the options #undef ST_OFF #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { +static const m_option_t vf_opts_fields[] = { {"w", ST_OFF(w), CONF_TYPE_INT, M_OPT_MIN,-11,0, NULL}, {"h", ST_OFF(h), CONF_TYPE_INT, M_OPT_MIN,-11,0, NULL}, {"interlaced", ST_OFF(interlaced), CONF_TYPE_INT, M_OPT_RANGE, 0, 1, NULL}, @@ -712,7 +711,7 @@ static m_option_t vf_opts_fields[] = { { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "scale", sizeof(struct vf_priv_s), &vf_priv_dflt, diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c index c75a83be7f..a661ada3ab 100644 --- a/libmpcodecs/vf_screenshot.c +++ b/libmpcodecs/vf_screenshot.c @@ -58,7 +58,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -137,7 +137,7 @@ static void scale_image(struct vf_priv_s* priv, mp_image_t *mpi) sws_scale(priv->ctx, mpi->planes, mpi->stride, 0, priv->dh, dst, dst_stride); } -static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi) +static void start_slice(struct vf_instance* vf, mp_image_t *mpi) { vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, mpi->type, mpi->flags, mpi->width, mpi->height); @@ -149,7 +149,7 @@ static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi) } -static void draw_slice(struct vf_instance_s* vf, unsigned char** src, +static void draw_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y) { if (vf->priv->store_slices) { @@ -162,7 +162,7 @@ static void draw_slice(struct vf_instance_s* vf, unsigned char** src, vf_next_draw_slice(vf,src,stride,w,h,x,y); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) +static void get_image(struct vf_instance* vf, mp_image_t *mpi) { // FIXME: should vf.c really call get_image when using slices?? if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) @@ -185,7 +185,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) mpi->priv=(void*)vf->dmpi; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi = (mp_image_t *)mpi->priv; @@ -246,7 +246,7 @@ static int control (vf_instance_t *vf, int request, void *data) //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch(fmt){ case IMGFMT_YV12: diff --git a/libmpcodecs/vf_smartblur.c b/libmpcodecs/vf_smartblur.c index a5a1265111..92aeece529 100644 --- a/libmpcodecs/vf_smartblur.c +++ b/libmpcodecs/vf_smartblur.c @@ -94,7 +94,7 @@ static int allocStuff(FilterParam *f, int width, int height){ return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -113,7 +113,7 @@ static void freeBuffers(FilterParam *f){ f->filterContext=NULL; } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; freeBuffers(&vf->priv->luma); @@ -180,7 +180,7 @@ static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int cw= mpi->w >> mpi->chroma_x_shift; int ch= mpi->h >> mpi->chroma_y_shift; FilterParam *f= &vf->priv; @@ -201,7 +201,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: diff --git a/libmpcodecs/vf_softpulldown.c b/libmpcodecs/vf_softpulldown.c index 3bbf02944d..f9b32b8194 100644 --- a/libmpcodecs/vf_softpulldown.c +++ b/libmpcodecs/vf_softpulldown.c @@ -35,7 +35,7 @@ struct vf_priv_s { long long out; }; -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; int ret = 0; @@ -129,14 +129,14 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return ret; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { mp_msg(MSGT_VFILTER, MSGL_INFO, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out); free(vf->priv); diff --git a/libmpcodecs/vf_softskip.c b/libmpcodecs/vf_softskip.c index 1e735d989e..664a862d9a 100644 --- a/libmpcodecs/vf_softskip.c +++ b/libmpcodecs/vf_softskip.c @@ -31,7 +31,7 @@ struct vf_priv_s { int skipflag; }; -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; @@ -54,7 +54,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return vf_next_put_image(vf, dmpi, pts); } -static int control(struct vf_instance_s* vf, int request, void* data) +static int control(struct vf_instance* vf, int request, void* data) { switch (request) { case VFCTRL_SKIP_NEXT_FRAME: @@ -65,7 +65,7 @@ static int control(struct vf_instance_s* vf, int request, void* data) } #if 0 -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - figure out which other formats work */ switch (fmt) { @@ -78,7 +78,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) } #endif -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -100,5 +100,3 @@ const vf_info_t vf_info_softskip = { open, NULL }; - - diff --git a/libmpcodecs/vf_spp.c b/libmpcodecs/vf_spp.c index 0fcee9d665..c04e3b1e1f 100644 --- a/libmpcodecs/vf_spp.c +++ b/libmpcodecs/vf_spp.c @@ -37,15 +37,10 @@ #include "mp_msg.h" #include "cpudetect.h" -#include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavcodec/avcodec.h" #include "libavcodec/dsputil.h" -#undef fprintf -#undef free -#undef malloc - #include "img_format.h" #include "mp_image.h" #include "vf.h" @@ -435,7 +430,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stri //FIXME reorder for better caching } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int h= (height+16+15)&(~15); @@ -447,7 +442,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place (or pp disabled): vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, @@ -464,7 +459,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ @@ -516,7 +511,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ if(!vf->priv) return; if(vf->priv->temp) free(vf->priv->temp); @@ -533,7 +528,7 @@ static void uninit(struct vf_instance_s* vf){ } //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YVU9: case IMGFMT_IF09: @@ -551,7 +546,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ switch(request){ case VFCTRL_QUERY_MAX_PP_LEVEL: return 6; diff --git a/libmpcodecs/vf_swapuv.c b/libmpcodecs/vf_swapuv.c index 1800e583fd..5276c752f4 100644 --- a/libmpcodecs/vf_swapuv.c +++ b/libmpcodecs/vf_swapuv.c @@ -32,7 +32,7 @@ //===========================================================================// -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ mp_image_t *dmpi= vf_get_image(vf->next, mpi->imgfmt, mpi->type, mpi->flags, mpi->w, mpi->h); @@ -48,7 +48,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->priv=(void*)dmpi; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(mpi->flags&MP_IMGFLAG_DIRECT){ @@ -72,7 +72,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt) { case IMGFMT_YV12: diff --git a/libmpcodecs/vf_telecine.c b/libmpcodecs/vf_telecine.c index 4a372ddaf0..b08a455486 100644 --- a/libmpcodecs/vf_telecine.c +++ b/libmpcodecs/vf_telecine.c @@ -33,7 +33,7 @@ struct vf_priv_s { int frame; }; -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; int ret; @@ -106,7 +106,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) } #if 0 -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - figure out which other formats work */ switch (fmt) { @@ -118,7 +118,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -126,7 +126,7 @@ static int config(struct vf_instance_s* vf, } #endif -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -153,5 +153,3 @@ const vf_info_t vf_info_telecine = { open, NULL }; - - diff --git a/libmpcodecs/vf_test.c b/libmpcodecs/vf_test.c index 1f51011e57..a59f5c37b2 100644 --- a/libmpcodecs/vf_test.c +++ b/libmpcodecs/vf_test.c @@ -47,12 +47,12 @@ struct vf_priv_s { int frame_num; }; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ if(vf_next_query_format(vf,IMGFMT_YV12)<=0){ - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YV12"); + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "%s not supported by next filter/vo :(\n", "YV12"); return 0; } @@ -269,7 +269,7 @@ static void ring2Test(uint8_t *dst, int stride, int off) } } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int frame= vf->priv->frame_num; @@ -307,7 +307,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ return vf_next_query_format(vf,IMGFMT_YV12) & (~VFCAP_CSP_SUPPORTED_BY_HW); } diff --git a/libmpcodecs/vf_tfields.c b/libmpcodecs/vf_tfields.c index 851d3f24da..1261936293 100644 --- a/libmpcodecs/vf_tfields.c +++ b/libmpcodecs/vf_tfields.c @@ -21,6 +21,7 @@ #include <string.h> #include "config.h" +#include "options.h" #include "mp_msg.h" #include "cpudetect.h" @@ -319,10 +320,9 @@ static void qpel_4tap_C(unsigned char *d, unsigned char *s, int w, int h, int ds static void (*qpel_li)(unsigned char *d, unsigned char *s, int w, int h, int ds, int ss, int up); static void (*qpel_4tap)(unsigned char *d, unsigned char *s, int w, int h, int ds, int ss, int up); -static int continue_buffered_image(struct vf_instance_s *); -extern int correct_pts; +static int continue_buffered_image(struct vf_instance *); -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { vf->priv->buffered_mpi = mpi; vf->priv->buffered_pts = pts; @@ -330,7 +330,9 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return continue_buffered_image(vf); } -static int continue_buffered_image(struct vf_instance_s *vf) +extern const int under_mencoder; + +static int continue_buffered_image(struct vf_instance *vf) { int i=vf->priv->buffered_i; double pts = vf->priv->buffered_pts; @@ -382,10 +384,8 @@ static int continue_buffered_image(struct vf_instance_s *vf) dmpi->stride[2] = 2*mpi->stride[2]; } ret |= vf_next_put_image(vf, dmpi, pts); - if (correct_pts) + if (!under_mencoder) break; - else - if (!i) vf_extra_flip(vf); } break; case 1: @@ -412,10 +412,8 @@ static int continue_buffered_image(struct vf_instance_s *vf) mpi->chroma_width, mpi->chroma_height, (i^!tff)); } ret |= vf_next_put_image(vf, dmpi, pts); - if (correct_pts) + if (!under_mencoder) break; - else - if (!i) vf_extra_flip(vf); } break; case 2: @@ -438,10 +436,8 @@ static int continue_buffered_image(struct vf_instance_s *vf) dmpi->stride[2], mpi->stride[2]*2, (i^!tff)); } ret |= vf_next_put_image(vf, dmpi, pts); - if (correct_pts) + if (!under_mencoder) break; - else - if (!i) vf_extra_flip(vf); } break; } @@ -450,7 +446,7 @@ static int continue_buffered_image(struct vf_instance_s *vf) } #if 0 -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - figure out which other formats work */ switch (fmt) { @@ -463,7 +459,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) } #endif -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -479,7 +475,7 @@ static int config(struct vf_instance_s* vf, return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } @@ -521,5 +517,3 @@ const vf_info_t vf_info_tfields = { open, NULL }; - - diff --git a/libmpcodecs/vf_tile.c b/libmpcodecs/vf_tile.c index bfbf030697..8e9cc7e650 100644 --- a/libmpcodecs/vf_tile.c +++ b/libmpcodecs/vf_tile.c @@ -84,7 +84,7 @@ struct vf_priv_s { }; -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -107,7 +107,7 @@ static int config(struct vf_instance_s* vf, } /* Filter handler */ -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; struct vf_priv_s *priv; @@ -192,14 +192,14 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) } } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { /* free local data */ free(vf->priv); } /* rgb/bgr 15->32 supported & some Yxxx */ -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { switch (fmt) { /* rgb 15 -> 32 bit */ @@ -295,7 +295,7 @@ static int open(vf_instance_t *vf, char* args) // er |= parse_int( &args, &p->bkgSet, 0 ); if (er) { - mp_msg(MSGT_VFILTER, MSGL_ERR, MSGTR_MPCODECS_ErrorParsingArgument); + mp_tmsg(MSGT_VFILTER, MSGL_ERR, "[VF_FRAMESTEP] Error parsing argument.\n"); return 0; } /* Load some default */ diff --git a/libmpcodecs/vf_tinterlace.c b/libmpcodecs/vf_tinterlace.c index 988e55d8d0..fa69986856 100644 --- a/libmpcodecs/vf_tinterlace.c +++ b/libmpcodecs/vf_tinterlace.c @@ -37,7 +37,7 @@ struct vf_priv_s { mp_image_t *dmpi; }; -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts) { int ret = 0; mp_image_t *dmpi; @@ -176,7 +176,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) return ret; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt) +static int query_format(struct vf_instance* vf, unsigned int fmt) { /* FIXME - figure out which other formats work */ switch (fmt) { @@ -188,7 +188,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt) return 0; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { @@ -204,7 +204,7 @@ static int config(struct vf_instance_s* vf, return 0; } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { free(vf->priv); } diff --git a/libmpcodecs/vf_unsharp.c b/libmpcodecs/vf_unsharp.c index 1f7e16bc61..09d276d3d7 100644 --- a/libmpcodecs/vf_unsharp.c +++ b/libmpcodecs/vf_unsharp.c @@ -126,7 +126,7 @@ static void unsharp( uint8_t *dst, uint8_t *src, int dstStride, int srcStride, i //===========================================================================// -static int config( struct vf_instance_s* vf, +static int config( struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt ) { @@ -159,7 +159,7 @@ static int config( struct vf_instance_s* vf, //===========================================================================// -static void get_image( struct vf_instance_s* vf, mp_image_t *mpi ) { +static void get_image( struct vf_instance* vf, mp_image_t *mpi ) { if( mpi->flags & MP_IMGFLAG_PRESERVE ) return; // don't change if( mpi->imgfmt!=vf->priv->outfmt ) @@ -178,7 +178,7 @@ static void get_image( struct vf_instance_s* vf, mp_image_t *mpi ) { mpi->flags |= MP_IMGFLAG_DIRECT; } -static int put_image( struct vf_instance_s* vf, mp_image_t *mpi, double pts) { +static int put_image( struct vf_instance* vf, mp_image_t *mpi, double pts) { mp_image_t *dmpi; if( !(mpi->flags & MP_IMGFLAG_DIRECT) ) @@ -204,7 +204,7 @@ static int put_image( struct vf_instance_s* vf, mp_image_t *mpi, double pts) { return vf_next_put_image( vf, dmpi, pts); } -static void uninit( struct vf_instance_s* vf ) { +static void uninit( struct vf_instance* vf ) { unsigned int z; FilterParam *fp; @@ -227,7 +227,7 @@ static void uninit( struct vf_instance_s* vf ) { //===========================================================================// -static int query_format( struct vf_instance_s* vf, unsigned int fmt ) { +static int query_format( struct vf_instance* vf, unsigned int fmt ) { switch(fmt) { case IMGFMT_YV12: case IMGFMT_I420: @@ -263,7 +263,7 @@ static void parse( FilterParam *fp, char* args ) { //===========================================================================// -static unsigned int fmt_list[] = { +static const unsigned int fmt_list[] = { IMGFMT_YV12, IMGFMT_I420, IMGFMT_IYUV, diff --git a/libmpcodecs/vf_uspp.c b/libmpcodecs/vf_uspp.c index 19bdc67123..8ff3413422 100644 --- a/libmpcodecs/vf_uspp.c +++ b/libmpcodecs/vf_uspp.c @@ -204,7 +204,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int ds } } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int i; @@ -245,7 +245,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change // ok, we can do pp in-place (or pp disabled): vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, @@ -262,7 +262,7 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ mpi->flags|=MP_IMGFLAG_DIRECT; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ @@ -297,7 +297,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ int i; if(!vf->priv) return; @@ -316,7 +316,7 @@ static void uninit(struct vf_instance_s* vf){ } //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: @@ -328,7 +328,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ switch(request){ case VFCTRL_QUERY_MAX_PP_LEVEL: return 8; diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 96cbee6b8c..597d787e52 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -19,6 +19,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #include "config.h" #include "mp_msg.h" @@ -29,8 +30,8 @@ #include "libvo/video_out.h" #ifdef CONFIG_ASS -#include "libass/ass_mp.h" -extern ass_track_t* ass_track; +#include "ass_mp.h" +extern ASS_Track *ass_track; #endif //===========================================================================// @@ -39,19 +40,19 @@ extern int sub_visibility; extern float sub_delay; struct vf_priv_s { - double pts; - const vo_functions_t *vo; + struct vo *vo; #ifdef CONFIG_ASS - ass_renderer_t* ass_priv; + ASS_Renderer *ass_priv; int prev_visibility; + double scale_ratio; #endif }; #define video_out (vf->priv->vo) -static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */ -static void draw_slice(struct vf_instance_s* vf, unsigned char** src, int* stride, int w,int h, int x, int y); +static int query_format(struct vf_instance* vf, unsigned int fmt); /* forward declaration */ +static void draw_slice(struct vf_instance *vf, unsigned char **src, int *stride, int w,int h, int x, int y); -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -61,8 +62,7 @@ static int config(struct vf_instance_s* vf, return 0; } - if(video_out->info) - { const vo_info_t *info = video_out->info; + const vo_info_t *info = video_out->driver->info; mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name, width, height, d_width, d_height, @@ -75,65 +75,65 @@ static int config(struct vf_instance_s* vf, mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Author: %s\n", info->author); if(info->comment && strlen(info->comment) > 0) mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment); - } // save vo's stride capability for the wanted colorspace: vf->default_caps=query_format(vf,outfmt); vf->draw_slice = (vf->default_caps & VOCAP_NOSLICES) ? NULL : draw_slice; - if(config_video_out(video_out,width,height,d_width,d_height,flags,"MPlayer",outfmt)) + if (vo_config(video_out, width, height, d_width, d_height, flags, "MPlayer", outfmt)) return 0; #ifdef CONFIG_ASS + vf->priv->scale_ratio = (double) d_width / d_height * height / width; + if (vf->priv->ass_priv) ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED)); #endif - ++vo_config_count; return 1; } -static int control(struct vf_instance_s* vf, int request, void* data) +static int control(struct vf_instance* vf, int request, void* data) { switch(request){ case VFCTRL_GET_DEINTERLACE: { if(!video_out) return CONTROL_FALSE; // vo not configured? - return(video_out->control(VOCTRL_GET_DEINTERLACE, data) - == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE; + return vo_control(video_out, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE; } case VFCTRL_SET_DEINTERLACE: { if(!video_out) return CONTROL_FALSE; // vo not configured? - return(video_out->control(VOCTRL_SET_DEINTERLACE, data) - == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE; + return vo_control(video_out, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE; } + case VFCTRL_GET_YUV_COLORSPACE: + return vo_control(video_out, VOCTRL_GET_YUV_COLORSPACE, data) == true; + case VFCTRL_SET_YUV_COLORSPACE: + return vo_control(video_out, VOCTRL_SET_YUV_COLORSPACE, data) == true; case VFCTRL_DRAW_OSD: - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? - video_out->draw_osd(); + if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? + vo_draw_osd(video_out, data); return CONTROL_TRUE; - case VFCTRL_FLIP_PAGE: - { - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? - video_out->flip_page(); - return CONTROL_TRUE; - } + case VFCTRL_REDRAW_OSD: + return vo_control(video_out, VOCTRL_REDRAW_OSD, data) == true; case VFCTRL_SET_EQUALIZER: { vf_equalizer_t *eq=data; - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? - return (video_out->control(VOCTRL_SET_EQUALIZER, eq->item, eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE; + if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? + struct voctrl_set_equalizer_args param = {eq->item, eq->value}; + return vo_control(video_out, VOCTRL_SET_EQUALIZER, ¶m) == VO_TRUE; } case VFCTRL_GET_EQUALIZER: { vf_equalizer_t *eq=data; - if(!vo_config_count) return CONTROL_FALSE; // vo not configured? - return (video_out->control(VOCTRL_GET_EQUALIZER, eq->item, &eq->value) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE; + if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured? + struct voctrl_get_equalizer_args param = {eq->item, &eq->value}; + return vo_control(video_out, VOCTRL_GET_EQUALIZER, ¶m) == VO_TRUE; } #ifdef CONFIG_ASS case VFCTRL_INIT_EOSD: { - vf->priv->ass_priv = ass_renderer_init((ass_library_t*)data); + vf->priv->ass_priv = ass_renderer_init((ASS_Library*)data); if (!vf->priv->ass_priv) return CONTROL_FALSE; ass_configure_fonts(vf->priv->ass_priv); vf->priv->prev_visibility = 0; @@ -142,19 +142,15 @@ static int control(struct vf_instance_s* vf, int request, void* data) case VFCTRL_DRAW_EOSD: { mp_eosd_images_t images = {NULL, 2}; - double pts = vf->priv->pts; - if (!vo_config_count || !vf->priv->ass_priv) return CONTROL_FALSE; + double pts = video_out->next_pts; + if (!video_out->config_ok || !vf->priv->ass_priv) return CONTROL_FALSE; if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) { mp_eosd_res_t res; memset(&res, 0, sizeof(res)); - if (video_out->control(VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) { + if (vo_control(video_out, VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) { ass_set_frame_size(vf->priv->ass_priv, res.w, res.h); ass_set_margins(vf->priv->ass_priv, res.mt, res.mb, res.ml, res.mr); -#if defined(LIBASS_VERSION) && LIBASS_VERSION >= 0x00908000 - ass_set_aspect_ratio(vf->priv->ass_priv, (double)res.w / res.h, (double)res.srcw/res.srch); -#else - ass_set_aspect_ratio(vf->priv->ass_priv, (double)res.w / res.h); -#endif + ass_set_aspect_ratio(vf->priv->ass_priv, vf->priv->scale_ratio, 1); } images.imgs = ass_mp_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5, &images.changed); @@ -164,21 +160,15 @@ static int control(struct vf_instance_s* vf, int request, void* data) } else vf->priv->prev_visibility = 0; vf->priv->prev_visibility = sub_visibility; - return (video_out->control(VOCTRL_DRAW_EOSD, &images) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE; + return vo_control(video_out, VOCTRL_DRAW_EOSD, &images) == VO_TRUE; } #endif - case VFCTRL_GET_PTS: - { - *(double *)data = vf->priv->pts; - return CONTROL_TRUE; - } } - // return video_out->control(request,data); return CONTROL_UNKNOWN; } -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ - int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt); +static int query_format(struct vf_instance* vf, unsigned int fmt){ + int flags = vo_control(video_out, VOCTRL_QUERY_FORMAT, &fmt); // draw_slice() accepts stride, draw_frame() doesn't: if(flags) if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV) @@ -186,49 +176,52 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return flags; } -static void get_image(struct vf_instance_s* vf, +static void get_image(struct vf_instance* vf, mp_image_t *mpi){ - if(!vo_config_count) return; + if (!video_out->config_ok) + return; // GET_IMAGE is required for hardware-accelerated formats if(vo_directrendering || IMGFMT_IS_XVMC(mpi->imgfmt) || IMGFMT_IS_VDPAU(mpi->imgfmt)) - video_out->control(VOCTRL_GET_IMAGE,mpi); + vo_control(video_out, VOCTRL_GET_IMAGE, mpi); } -static int put_image(struct vf_instance_s* vf, +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ - if(!vo_config_count) return 0; // vo not configured? - // record pts (potentially modified by filters) for main loop - vf->priv->pts = pts; + if(!video_out->config_ok) return 0; // vo not configured? // first check, maybe the vo/vf plugin implements draw_image using mpi: - if(video_out->control(VOCTRL_DRAW_IMAGE,mpi)==VO_TRUE) return 1; // done. + if (vo_draw_image(video_out, mpi, pts) >= 0) + return 1; // nope, fallback to old draw_frame/draw_slice: if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){ // blit frame: // if(mpi->flags&MP_IMGFLAG_PLANAR) if(vf->default_caps&VFCAP_ACCEPT_STRIDE) - video_out->draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y); + vo_draw_slice(video_out, mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y); else - video_out->draw_frame(mpi->planes); + vo_draw_frame(video_out, mpi->planes); } return 1; } -static void start_slice(struct vf_instance_s* vf, +static void start_slice(struct vf_instance* vf, mp_image_t *mpi) { - if(!vo_config_count) return; // vo not configured? - video_out->control(VOCTRL_START_SLICE,mpi); + if(!video_out->config_ok) return; // vo not configured? + vo_control(video_out, VOCTRL_START_SLICE,mpi); } -static void draw_slice(struct vf_instance_s* vf, +static void draw_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ - if(!vo_config_count) return; // vo not configured? - video_out->draw_slice(src,stride,w,h,x,y); + if(!video_out->config_ok) return; // vo not configured? + vo_draw_slice(video_out, src,stride,w,h,x,y); } -static void uninit(struct vf_instance_s* vf) +static void uninit(struct vf_instance* vf) { if (vf->priv) { + /* Allow VO (which may live on to work with another instance of vf_vo) + * to get rid of numbered-mpi references that will now be invalid. */ + vo_seek_reset(video_out); #ifdef CONFIG_ASS if (vf->priv->ass_priv) ass_renderer_done(vf->priv->ass_priv); @@ -248,9 +241,8 @@ static int open(vf_instance_t *vf, char* args){ vf->start_slice=start_slice; vf->uninit=uninit; vf->priv=calloc(1, sizeof(struct vf_priv_s)); - vf->priv->vo = (const vo_functions_t *)args; + vf->priv->vo = (struct vo *)args; if(!video_out) return 0; // no vo ? -// if(video_out->preinit(args)) return 0; // preinit failed return 1; } diff --git a/libmpcodecs/vf_yadif.c b/libmpcodecs/vf_yadif.c index 4b408a2e21..477ea03c9b 100644 --- a/libmpcodecs/vf_yadif.c +++ b/libmpcodecs/vf_yadif.c @@ -26,6 +26,7 @@ #include "config.h" #include "cpudetect.h" +#include "options.h" #include "mp_msg.h" #include "img_format.h" @@ -363,7 +364,7 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], int dst_stride[3], int #endif } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ int i, j; @@ -381,10 +382,9 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); } -static int continue_buffered_image(struct vf_instance_s *vf); -extern int correct_pts; +static int continue_buffered_image(struct vf_instance *vf); -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int tff; if(vf->priv->parity < 0) { @@ -411,7 +411,9 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return continue_buffered_image(vf); } -static int continue_buffered_image(struct vf_instance_s *vf) +extern const int under_mencoder; + +static int continue_buffered_image(struct vf_instance *vf) { mp_image_t *mpi = vf->priv->buffered_mpi; int tff = vf->priv->buffered_tff; @@ -429,19 +431,17 @@ static int continue_buffered_image(struct vf_instance_s *vf) mpi->width,mpi->height); vf_clone_mpi_attributes(dmpi, mpi); filter(vf->priv, dmpi->planes, dmpi->stride, mpi->w, mpi->h, i ^ tff ^ 1, tff); - if (correct_pts && i < (vf->priv->mode & 1)) + if (i < (vf->priv->mode & 1) && !under_mencoder) vf_queue_frame(vf, continue_buffered_image); ret |= vf_next_put_image(vf, dmpi, pts /*FIXME*/); - if (correct_pts) + if (!under_mencoder) break; - if(i<(vf->priv->mode&1)) - vf_extra_flip(vf); } vf->priv->buffered_i = 1; return ret; } -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ int i; if(!vf->priv) return; @@ -455,7 +455,7 @@ static void uninit(struct vf_instance_s* vf){ } //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: @@ -467,7 +467,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ switch (request){ case VFCTRL_GET_DEINTERLACE: *(int*)data = vf->priv->do_deinterlace; diff --git a/libmpcodecs/vf_yuvcsp.c b/libmpcodecs/vf_yuvcsp.c index 0f3db68741..7fe176b00e 100644 --- a/libmpcodecs/vf_yuvcsp.c +++ b/libmpcodecs/vf_yuvcsp.c @@ -34,7 +34,7 @@ struct vf_priv_s { //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); @@ -48,7 +48,7 @@ static inline int clamp_c(int x){ return (x > 240) ? 240 : (x < 16) ? 16 : x; } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ int i,j; uint8_t *y_in, *cb_in, *cr_in; uint8_t *y_out, *cb_out, *cr_out; @@ -82,12 +82,12 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// /* -static void uninit(struct vf_instance_s* vf){ +static void uninit(struct vf_instance* vf){ free(vf->priv); } */ -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: diff --git a/libmpcodecs/vf_yuy2.c b/libmpcodecs/vf_yuy2.c index 36337e3a9c..8e1b6f0c8c 100644 --- a/libmpcodecs/vf_yuy2.c +++ b/libmpcodecs/vf_yuy2.c @@ -34,21 +34,21 @@ //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ sws_rgb2rgb_init(get_sws_cpuflags()); if(vf_next_query_format(vf,IMGFMT_YUY2)<=0){ - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YUY2"); + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "%s not supported by next filter/vo :(\n", "YUY2"); return 0; } return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YUY2); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; // hope we'll get DR buffer: @@ -70,7 +70,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: diff --git a/libmpcodecs/vf_yvu9.c b/libmpcodecs/vf_yvu9.c index a3027a85e3..bbae017ef8 100644 --- a/libmpcodecs/vf_yvu9.c +++ b/libmpcodecs/vf_yvu9.c @@ -33,19 +33,19 @@ //===========================================================================// -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ if(vf_next_query_format(vf,IMGFMT_YV12)<=0){ - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YVU9"); + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "%s not supported by next filter/vo :(\n", "YVU9"); return 0; } return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YV12); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int y,w,h; @@ -80,7 +80,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ //===========================================================================// -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ if (fmt == IMGFMT_YVU9 || fmt == IMGFMT_IF09) return vf_next_query_format(vf,IMGFMT_YV12) & (~VFCAP_CSP_SUPPORTED_BY_HW); return 0; diff --git a/libmpcodecs/vf_zrmjpeg.c b/libmpcodecs/vf_zrmjpeg.c index 6b4c9a7c64..87c50351d9 100644 --- a/libmpcodecs/vf_zrmjpeg.c +++ b/libmpcodecs/vf_zrmjpeg.c @@ -668,7 +668,7 @@ struct vf_priv_s { * arrange to dispatch to the config() entry pointer for the one * selected. */ -static int config(struct vf_instance_s* vf, int width, int height, int d_width, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ struct vf_priv_s *priv = vf->priv; float aspect_decision; @@ -828,7 +828,7 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, * \param mpi pointer to mp_image_t structure * \param pts */ -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ struct vf_priv_s *priv = vf->priv; int size = 0; int i; @@ -857,7 +857,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ * Given the image format specified by \a fmt, this routine is called * to ask if the format is supported or not. */ -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ VERBOSE("query_format() called\n"); switch (fmt) { @@ -1066,4 +1066,3 @@ const vf_info_t vf_info_zrmjpeg = { open, NULL }; - |