aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpcodecs
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad_acm.c5
-rw-r--r--libmpcodecs/ad_dmo.c3
-rw-r--r--libmpcodecs/ad_dshow.c3
-rw-r--r--libmpcodecs/ad_dvdpcm.c3
-rw-r--r--libmpcodecs/ad_faad.c2
-rw-r--r--libmpcodecs/ad_ffmpeg.c26
-rw-r--r--libmpcodecs/ad_hwac3.c3
-rw-r--r--libmpcodecs/ad_hwmpa.c1
-rw-r--r--libmpcodecs/ad_liba52.c1
-rw-r--r--libmpcodecs/ad_libdv.c3
-rw-r--r--libmpcodecs/ad_msadpcm.c2
-rw-r--r--libmpcodecs/ad_pcm.c55
-rw-r--r--libmpcodecs/ad_realaud.c39
-rw-r--r--libmpcodecs/ad_twin.c1
-rw-r--r--libmpcodecs/ae_lame.c184
-rw-r--r--libmpcodecs/ae_lavc.c48
-rw-r--r--libmpcodecs/dec_audio.c71
-rw-r--r--libmpcodecs/dec_teletext.c7
-rw-r--r--libmpcodecs/dec_video.c155
-rw-r--r--libmpcodecs/dec_video.h3
-rw-r--r--libmpcodecs/img_format.c2
-rw-r--r--libmpcodecs/vd.c161
-rw-r--r--libmpcodecs/vd.h12
-rw-r--r--libmpcodecs/vd_dmo.c9
-rw-r--r--libmpcodecs/vd_dshow.c9
-rw-r--r--libmpcodecs/vd_ffmpeg.c324
-rw-r--r--libmpcodecs/vd_ijpg.c2
-rw-r--r--libmpcodecs/vd_libmpeg2.c4
-rw-r--r--libmpcodecs/vd_realvid.c23
-rw-r--r--libmpcodecs/vd_theora.c3
-rw-r--r--libmpcodecs/vd_vfw.c3
-rw-r--r--libmpcodecs/vd_xanim.c31
-rw-r--r--libmpcodecs/ve.c4
-rw-r--r--libmpcodecs/ve_lavc.c9
-rw-r--r--libmpcodecs/ve_nuv.c2
-rw-r--r--libmpcodecs/ve_raw.c3
-rw-r--r--libmpcodecs/ve_vfw.c13
-rw-r--r--libmpcodecs/vf.c95
-rw-r--r--libmpcodecs/vf.h24
-rw-r--r--libmpcodecs/vf_ass.c143
-rw-r--r--libmpcodecs/vf_crop.c8
-rw-r--r--libmpcodecs/vf_cropdetect.c3
-rw-r--r--libmpcodecs/vf_divtc.c2
-rw-r--r--libmpcodecs/vf_expand.c49
-rw-r--r--libmpcodecs/vf_filmdint.c5
-rw-r--r--libmpcodecs/vf_fixpts.c1
-rw-r--r--libmpcodecs/vf_format.c1
-rw-r--r--libmpcodecs/vf_framestep.c3
-rw-r--r--libmpcodecs/vf_geq.c4
-rw-r--r--libmpcodecs/vf_gradfun.c2
-rw-r--r--libmpcodecs/vf_lavc.c5
-rw-r--r--libmpcodecs/vf_lavcdeint.c1
-rw-r--r--libmpcodecs/vf_mcdeint.c5
-rw-r--r--libmpcodecs/vf_noformat.c1
-rw-r--r--libmpcodecs/vf_palette.c3
-rw-r--r--libmpcodecs/vf_pp.c33
-rw-r--r--libmpcodecs/vf_qp.c2
-rw-r--r--libmpcodecs/vf_scale.c6
-rw-r--r--libmpcodecs/vf_spp.c5
-rw-r--r--libmpcodecs/vf_test.c3
-rw-r--r--libmpcodecs/vf_tfields.c27
-rw-r--r--libmpcodecs/vf_tile.c5
-rw-r--r--libmpcodecs/vf_vo.c106
-rw-r--r--libmpcodecs/vf_yadif.c10
-rw-r--r--libmpcodecs/vf_yvu9.c3
65 files changed, 901 insertions, 883 deletions
diff --git a/libmpcodecs/ad_acm.c b/libmpcodecs/ad_acm.c
index b179515754..46af4fae7d 100644
--- a/libmpcodecs/ad_acm.c
+++ b/libmpcodecs/ad_acm.c
@@ -22,7 +22,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "libmpdemux/aviprint.h"
#include "loader/wineacm.h"
@@ -75,7 +74,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;
}
@@ -106,7 +105,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_dmo.c b/libmpcodecs/ad_dmo.c
index d89e9d646c..1501c21078 100644
--- a/libmpcodecs/ad_dmo.c
+++ b/libmpcodecs/ad_dmo.c
@@ -22,7 +22,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "ad_internal.h"
#include "libaf/reorder_ch.h"
@@ -52,7 +51,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 e88ed0c2fa..8fb94660a4 100644
--- a/libmpcodecs/ad_dshow.c
+++ b/libmpcodecs/ad_dshow.c
@@ -22,7 +22,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "ad_internal.h"
@@ -49,7 +48,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 b0bb169d95..41f6a1426d 100644
--- a/libmpcodecs/ad_dvdpcm.c
+++ b/libmpcodecs/ad_dvdpcm.c
@@ -22,7 +22,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "ad_internal.h"
static const ad_info_t info =
@@ -56,7 +55,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 4f62765257..14fe9a6280 100644
--- a/libmpcodecs/ad_faad.c
+++ b/libmpcodecs/ad_faad.c
@@ -172,7 +172,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 9d1b8356ad..c954fb2311 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -22,7 +22,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "ad_internal.h"
#include "libaf/reorder_ch.h"
@@ -68,7 +67,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 +107,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);
@@ -143,19 +142,18 @@ static int init(sh_audio_t *sh_audio)
mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Unsupported sample format\n");
return 0;
}
- if(sh_audio->wf){
+ /* If the audio is AAC the container level data may be unreliable
+ * because of SBR handling problems (possibly half real sample rate at
+ * container level). Default AAC decoding with ad_faad has used codec-level
+ * values for a long time without generating complaints so it should be OK.
+ */
+ if (sh_audio->wf && lavc_context->codec_id != CODEC_ID_AAC) {
// If the decoder uses the wrong number of channels all is lost anyway.
// sh_audio->channels=sh_audio->wf->nChannels;
-
- if (lavc_context->codec_id == CODEC_ID_AAC &&
- sh_audio->samplerate == 2*sh_audio->wf->nSamplesPerSec) {
- mp_msg(MSGT_DECAUDIO, MSGL_WARN,
- "Ignoring broken container sample rate for ACC with SBR\n");
- } else if (sh_audio->wf->nSamplesPerSec)
- sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
-
+ if (sh_audio->wf->nSamplesPerSec)
+ sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
if (sh_audio->wf->nAvgBytesPerSec)
- sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
+ sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
}
sh_audio->samplesize=af_fmt2bits(sh_audio->sample_format)/ 8;
return 1;
@@ -166,7 +164,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 119839b9bc..f45fd00a17 100644
--- a/libmpcodecs/ad_hwac3.c
+++ b/libmpcodecs/ad_hwac3.c
@@ -28,10 +28,9 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "mpbswap.h"
#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
+#include "ffmpeg_files/intreadwrite.h"
#include "ad_internal.h"
diff --git a/libmpcodecs/ad_hwmpa.c b/libmpcodecs/ad_hwmpa.c
index 30caa9b0f9..87c00b6f42 100644
--- a/libmpcodecs/ad_hwmpa.c
+++ b/libmpcodecs/ad_hwmpa.c
@@ -24,7 +24,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "libaf/af_format.h"
#include "ad_internal.h"
diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c
index 2e2006abc1..29e546a602 100644
--- a/libmpcodecs/ad_liba52.c
+++ b/libmpcodecs/ad_liba52.c
@@ -26,7 +26,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "mpbswap.h"
#include "ad_internal.h"
diff --git a/libmpcodecs/ad_libdv.c b/libmpcodecs/ad_libdv.c
index 8485a8883f..cbcb46efea 100644
--- a/libmpcodecs/ad_libdv.c
+++ b/libmpcodecs/ad_libdv.c
@@ -25,7 +25,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
@@ -102,7 +101,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_msadpcm.c b/libmpcodecs/ad_msadpcm.c
index 64dc39c485..162c7c04d3 100644
--- a/libmpcodecs/ad_msadpcm.c
+++ b/libmpcodecs/ad_msadpcm.c
@@ -30,7 +30,7 @@
#include "config.h"
#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
+#include "ffmpeg_files/intreadwrite.h"
#include "mpbswap.h"
#include "ad_internal.h"
diff --git a/libmpcodecs/ad_pcm.c b/libmpcodecs/ad_pcm.c
index 0dd50e0c65..29e78d69af 100644
--- a/libmpcodecs/ad_pcm.c
+++ b/libmpcodecs/ad_pcm.c
@@ -19,7 +19,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <stdbool.h>
+#include "talloc.h"
#include "config.h"
#include "ad_internal.h"
#include "libaf/af_format.h"
@@ -33,6 +35,13 @@ static const ad_info_t info = {
""
};
+struct ad_pcm_context {
+ unsigned char *buffer;
+ int buffer_pos;
+ int buffer_len;
+ int buffer_size;
+};
+
LIBAD_EXTERN(pcm)
static int init(sh_audio_t * sh_audio)
@@ -114,6 +123,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;
}
@@ -125,12 +135,17 @@ 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, ...)
{
+ struct ad_pcm_context *ctx = sh->context;
int skip;
switch (cmd) {
+ case ADCTRL_RESYNC_STREAM:
+ ctx->buffer_len = 0;
+ return true;
case ADCTRL_SKIP_FRAME:
skip = sh->i_bps / 16;
skip = skip & (~3);
@@ -143,13 +158,45 @@ 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)
+ int len = sh_audio->channels * sh_audio->samplesize;
+ 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->buffer_len - ctx->buffer_pos <= 0) {
+ double pts;
+ unsigned char *ptr;
+ int plen = ds_get_packet_pts(sh_audio->ds, &ptr, &pts);
+ if (plen < 0)
+ break;
+ if (ctx->buffer_size < plen) {
+ talloc_free(ctx->buffer);
+ ctx->buffer = talloc_size(ctx, plen);
+ ctx->buffer_size = plen;
+ }
+ memcpy(ctx->buffer, ptr, plen);
+ ctx->buffer_len = plen;
+ ctx->buffer_pos = 0;
+ if (pts != MP_NOPTS_VALUE) {
+ sh_audio->pts = pts;
+ sh_audio->pts_bytes = 0;
+ }
+ }
+ int from_stored = ctx->buffer_len - ctx->buffer_pos;
+ if (from_stored > minlen - len)
+ from_stored = minlen - len;
+ memcpy(buf + len, ctx->buffer + ctx->buffer_pos, from_stored);
+ ctx->buffer_pos += 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_realaud.c b/libmpcodecs/ad_realaud.c
index 1d475f8dda..0b7fb219f7 100644
--- a/libmpcodecs/ad_realaud.c
+++ b/libmpcodecs/ad_realaud.c
@@ -26,7 +26,6 @@
#ifdef HAVE_LIBDL
#include <dlfcn.h>
#endif
-#include "help_mp.h"
#include "path.h"
#include "ad_internal.h"
@@ -42,46 +41,16 @@ static const ad_info_t info = {
LIBAD_EXTERN(realaud)
-/* These functions are required for loading Real binary libs.
- * Add forward declarations to avoid warnings with -Wmissing-prototypes. */
-void *__builtin_new(unsigned long size);
-void __builtin_delete(void *ize);
-void *__builtin_vec_new(unsigned long size);
-void __builtin_vec_delete(void *mem);
-void __pure_virtual(void);
-
-void *__builtin_new(unsigned long size)
-{
+void *__builtin_new(unsigned long size) {
return malloc(size);
}
-void __builtin_delete(void* ize)
-{
+// required for cook's uninit:
+void __builtin_delete(void* ize) {
free(ize);
}
-void *__builtin_vec_new(unsigned long size)
-{
- return malloc(size);
-}
-
-void __builtin_vec_delete(void *mem)
-{
- free(mem);
-}
-
-void __pure_virtual(void)
-{
- printf("FATAL: __pure_virtual() called!\n");
-// exit(1);
-}
-
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-void ___brk_addr(void);
-void ___brk_addr(void) {exit(0);}
-char **__environ={NULL};
-#undef stderr
-FILE *stderr=NULL;
void *__ctype_b=NULL;
#endif
@@ -266,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_twin.c b/libmpcodecs/ad_twin.c
index 823ace89dd..954ca17809 100644
--- a/libmpcodecs/ad_twin.c
+++ b/libmpcodecs/ad_twin.c
@@ -28,7 +28,6 @@
#include "loader/wine/windef.h"
#include "libaf/af_format.h"
-#include "help_mp.h"
static const ad_info_t info =
{
diff --git a/libmpcodecs/ae_lame.c b/libmpcodecs/ae_lame.c
index 14f81409e7..90ed31dfe7 100644
--- a/libmpcodecs/ae_lame.c
+++ b/libmpcodecs/ae_lame.c
@@ -28,8 +28,6 @@
#include "libmpdemux/ms_hdr.h"
#include "stream/stream.h"
#include "libmpdemux/muxer.h"
-#include "help_mp.h"
-#include "ae_lame.h"
#include "ae_pcm.h"
#include "libaf/af_format.h"
#include "libmpdemux/mp3_hdr.h"
@@ -58,6 +56,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")
+
+
const m_option_t lameopts_conf[] = {
{"q", &lame_param_quality, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
@@ -83,18 +130,18 @@ const 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);
@@ -162,7 +209,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);
}
}
@@ -193,20 +240,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) ) {
@@ -230,8 +280,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;
}
@@ -326,14 +455,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 b4e437fada..7c584daac3 100644
--- a/libmpcodecs/ae_lavc.c
+++ b/libmpcodecs/ae_lavc.c
@@ -30,11 +30,10 @@
#include "stream/stream.h"
#include "libmpdemux/muxer.h"
#include "ae_lavc.h"
-#include "help_mp.h"
#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 +43,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 +147,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 +154,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 +167,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 +183,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 +224,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;
}
diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c
index 4311380fbb..1a06b85921 100644
--- a/libmpcodecs/dec_audio.c
+++ b/libmpcodecs/dec_audio.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "stream/stream.h"
#include "libmpdemux/demuxer.h"
@@ -52,7 +51,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++)
@@ -70,6 +69,8 @@ void afm_help(void)
static int init_audio_codec(sh_audio_t *sh_audio)
{
+ assert(!sh_audio->initialized);
+ resync_audio_stream(sh_audio);
if ((af_cfg.force & AF_INIT_FORMAT_MASK) == AF_INIT_FLOAT) {
int fmt = AF_FORMAT_FLOAT_NE;
if (sh_audio->ad_driver->control(sh_audio, ADCTRL_QUERY_FORMAT,
@@ -78,34 +79,36 @@ static int init_audio_codec(sh_audio_t *sh_audio)
sh_audio->samplesize = 4;
}
}
+ sh_audio->audio_out_minsize = 8192; // default, preinit() may change it
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 +116,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 +219,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 +258,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 +271,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 +289,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 +308,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 +348,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 +373,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 +391,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,9 +475,8 @@ 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
+ sh_audio->pts = MP_NOPTS_VALUE;
if (!sh_audio->initialized)
return;
sh_audio->ad_driver->control(sh_audio, ADCTRL_RESYNC_STREAM, NULL);
diff --git a/libmpcodecs/dec_teletext.c b/libmpcodecs/dec_teletext.c
index c2f125439d..215246af89 100644
--- a/libmpcodecs/dec_teletext.c
+++ b/libmpcodecs/dec_teletext.c
@@ -102,7 +102,6 @@
#include "dec_teletext.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "libmpcodecs/img_format.h"
#include "libavutil/common.h"
#include "input/input.h"
@@ -821,7 +820,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;);
}
@@ -1703,7 +1702,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);
@@ -1716,7 +1715,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 51da1adf7b..8cc7a6407c 100644
--- a/libmpcodecs/dec_video.c
+++ b/libmpcodecs/dec_video.c
@@ -17,13 +17,14 @@
*/
#include "config.h"
+#include "options.h"
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <unistd.h>
#include "mp_msg.h"
-#include "help_mp.h"
#include "osdep/timer.h"
#include "osdep/shmem.h"
@@ -57,26 +58,24 @@ int field_dominance = -1;
int divx_quality = 0;
-const 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);
+ 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);
+ 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_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_UsingCodecPP, ret);
+ 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;
}
@@ -88,8 +87,9 @@ void set_video_quality(sh_video_t *sh_video, int quality)
if (ret == CONTROL_TRUE)
return; // success
}
- if (mpvdec)
- mpvdec->control(sh_video, VDCTRL_SET_PP_LEVEL, (void *) (&quality));
+ 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)
@@ -107,12 +107,12 @@ int set_video_colors(sh_video_t *sh_video, const char *item, int value)
return 1;
}
/* try software control */
- if (mpvdec)
- if (mpvdec->control
- (sh_video, VDCTRL_SET_EQUALIZER, item, (int *) value)
+ 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_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_VideoAttributeNotSupportedByVO_VD,
+ return 1;
+ mp_tmsg(MSGT_DECVIDEO, MSGL_V, "Video attribute '%s' is not supported by selected vo & vd.\n",
item);
return 0;
}
@@ -133,8 +133,9 @@ int get_video_colors(sh_video_t *sh_video, const char *item, int *value)
}
}
/* 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;
}
@@ -152,23 +153,29 @@ int set_rectangle(sh_video_t *sh_video, int param, int value)
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)
+ const struct vd_functions *vd = sh_video->vd_driver;
+ if (!vd)
return -1;
- ret = mpvdec->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL);
+ int ret = vd->control(sh_video, VDCTRL_QUERY_UNSEEN_FRAMES, NULL);
if (ret >= 10)
return ret - 10;
return -1;
@@ -178,8 +185,8 @@ 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);
+ 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);
@@ -191,7 +198,7 @@ void uninit_video(sh_video_t *sh_video)
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++)
@@ -223,10 +230,9 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
if (!
(sh_video->codec =
find_video_codec(sh_video->format,
- sh_video->
- bih ? ((unsigned int *) &sh_video->bih->
- biCompression) : NULL, sh_video->codec,
- force)))
+ 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))
@@ -240,14 +246,12 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
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))
+ if (!strcmp(mpcodecs_vd_drivers[i]->info->short_name,
+ sh_video->codec->drv))
break;
- mpvdec = mpcodecs_vd_drivers[i];
+ sh_video->vd_driver = mpcodecs_vd_drivers[i];
#ifdef CONFIG_DYNAMIC_PLUGINS
- if (!mpvdec) {
+ if (!sh_video->vd_driver) {
/* try to open shared decoder plugin */
int buf_len;
char *buf;
@@ -276,15 +280,15 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
if (strcmp(info_sym->short_name, sh_video->codec->drv))
break;
free(buf);
- mpvdec = funcs_sym;
+ 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,
+ 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;
}
@@ -302,14 +306,16 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
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);
+ 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 (!mpvdec->init(sh_video)) {
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_VDecoderInitFailed);
+ 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) {
@@ -320,6 +326,8 @@ static int init_video(sh_video_t *sh_video, char *codecname, char *vfm,
}
// 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;
@@ -344,7 +352,7 @@ int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list,
stringset_add(&selected, video_codec + 1);
} else {
// forced codec by name:
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_ForcedVideoCodec,
+ mp_tmsg(MSGT_DECVIDEO, MSGL_INFO, "Forced video codec: %s\n",
video_codec);
init_video(sh_video, video_codec, NULL, -1, &selected);
}
@@ -356,7 +364,7 @@ int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list,
// try first the preferred codec families:
while (!sh_video->initialized && *fmlist) {
char *video_fm = *(fmlist++);
- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_TryForceVideoFmtStr,
+ 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)
@@ -375,12 +383,12 @@ int init_best_video_codec(sh_video_t *sh_video, char **video_codec_list,
stringset_free(&selected);
if (!sh_video->initialized) {
- mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantFindVideoCodec,
+ 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,
+ 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
}
@@ -392,8 +400,9 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
unsigned int t = GetTimer();
unsigned int t2;
double tt;
+ struct MPOpts *opts = sh_video->opts;
- if (correct_pts && pts != MP_NOPTS_VALUE) {
+ 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)
@@ -423,7 +432,14 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
}
}
- 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. --------------------
@@ -431,9 +447,9 @@ 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");
+ __asm__ volatile("femms\n\t":::"memory");
} else if (gCpuCaps.hasMMX) {
- __asm__ volatile ("emms\n\t":::"memory");
+ __asm__ volatile("emms\n\t":::"memory");
}
#endif
@@ -450,16 +466,28 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
else if (field_dominance == 1)
mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
- if (correct_pts) {
+ 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->pts = sh_video->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->pts = MP_NOPTS_VALUE;
+ 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;
}
@@ -470,15 +498,6 @@ 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;
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 bdf4d2f6f8..df47ce043b 100644
--- a/libmpcodecs/img_format.c
+++ b/libmpcodecs/img_format.c
@@ -99,7 +99,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/vd.c b/libmpcodecs/vd.c
index 2aaeb65f65..1e7d87312b 100644
--- a/libmpcodecs/vd.c
+++ b/libmpcodecs/vd.c
@@ -22,10 +22,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,8 +36,6 @@
#include "vd.h"
#include "vf.h"
-//#include "vd_internal.h"
-
extern const vd_functions_t mpcodecs_vd_null;
extern const vd_functions_t mpcodecs_vd_ffmpeg;
extern const vd_functions_t mpcodecs_vd_theora;
@@ -121,41 +118,14 @@ const vd_functions_t * const mpcodecs_vd_drivers[] = {
#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 const 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)
{
+ struct MPOpts *opts = sh->opts;
int i, j;
unsigned int out_fmt = 0;
- int screen_size_x = 0; //SCREEN_SIZE_X;
- int screen_size_y = 0; //SCREEN_SIZE_Y;
+ 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;
@@ -169,14 +139,12 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int 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
+ "VDec: vo config request - %d x %d (preferred colorspace: %s)\n",
+ w, h, vo_format_name(preferred_outfmt));
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);
+ sh->vfilter = vf = vf_open_filter(opts, vf, "pp", NULL);
}
// check if libvo and codec has common outfmt (no conversion):
csp_again:
@@ -202,8 +170,8 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h,
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) ==
+ 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",
@@ -211,15 +179,15 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h,
continue;
}
j = i;
- vo_flags = flags;
+ 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 (mpvdec->control(sh, VDCTRL_QUERY_FORMAT, &out_fmt) !=
+ 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;
}
@@ -227,17 +195,19 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h,
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);
+ 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(vf, "palette", NULL);
+ 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
+ } 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
+ // Remove the scale filter if we added it ourselves
if (vf == sc) {
ve = vf;
vf = vf->next;
@@ -250,22 +220,25 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h,
}
if (vo->query_format(vo, IMGFMT_MPEGPES)
&& (!vp || (vp && strcmp(vp->info->name, "lavc")))) {
- ve = vf_open_filter(vo, "lavc", NULL);
+ 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)
+ if (vp && !strcmp(vp->info->name,"lavc")) {
+ if (vpp)
vpp->next = vo;
- else
+ else
vf = vo;
- vf_uninit_filter(vp);
+ vf_uninit_filter(vp);
}
}
- mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_VOincompCodec);
+ 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
}
@@ -276,35 +249,34 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h,
sh->vfilter = vf;
// autodetect flipping
- if (flip == -1) {
- flip = 0;
+ if (opts->flip == -1) {
+ opts->flip = 0;
if (sh->codec->outflags[j] & CODECS_FLAG_FLIP)
if (!(sh->codec->outflags[j] & CODECS_FLAG_NOFLIP))
- flip = 1;
+ opts->flip = 1;
}
- if (vo_flags & VFCAP_FLIPPED)
- flip ^= 1;
- if (flip && !(vo_flags & VFCAP_FLIP)) {
+ 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
+ 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(!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 (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 = SCREEN_SIZE_X;
+ screen_size_x = 1;
if (!screen_size_y)
- screen_size_y = SCREEN_SIZE_Y;
+ screen_size_y = 1;
if (screen_size_x <= 8)
screen_size_x *= sh->disp_w;
if (screen_size_y <= 8)
@@ -314,41 +286,41 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h,
// 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) {
+ if (opts->screen_size_xy >= 0.001) {
+ if (opts->screen_size_xy <= 8) {
// -xy means x+y scale
- screen_size_x *= screen_size_xy;
- screen_size_y *= screen_size_xy;
+ 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 = screen_size_xy;
- screen_size_y = screen_size_xy * sh->disp_h / sh->disp_w;
+ 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_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_MovieAspectIsSet,
+ 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 || screen_size_xy > 8) {
+ 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_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_MovieAspectUndefined);
+ 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,
@@ -361,24 +333,23 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int 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);
+ mp_tmsg(MSGT_CPLAYER, MSGL_WARN, "FATAL: Cannot initialize video driver.\n");
sh->vf_initialized = -1;
return 0;
}
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;
}
diff --git a/libmpcodecs/vd.h b/libmpcodecs/vd.h
index 30b10ce651..4615a9dc6e 100644
--- a/libmpcodecs/vd.h
+++ b/libmpcodecs/vd.h
@@ -33,21 +33,13 @@ typedef struct vd_functions
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 flip;
-extern int fullscreen;
-extern int opt_screen_size_x;
-extern int opt_screen_size_y;
-extern int softzoom;
-extern int vd_use_slices;
-extern int vidmode;
-extern float movie_aspect;
-extern float screen_size_xy;
-
#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 ffb0844a6e..31d9f1e351 100644
--- a/libmpcodecs/vd_dmo.c
+++ b/libmpcodecs/vd_dmo.c
@@ -26,7 +26,6 @@
#include <stdarg.h>
#include "mp_msg.h"
-#include "help_mp.h"
#include "vd_internal.h"
@@ -59,8 +58,8 @@ static int init(sh_video_t *sh){
struct context *ctx;
void *decoder;
if(!(decoder=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,out_fmt)) return 0;
@@ -89,7 +88,7 @@ static int init(sh_video_t *sh){
DMO_VideoDecoder_SetDestFmt(ctx->decoder,out_fmt&255,0); // RGB/BGR
}
DMO_VideoDecoder_StartInternal(ctx->decoder);
- mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DMOInitOK);
+ mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO video codec init OK.\n");
return 1;
}
@@ -128,7 +127,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
}
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 82a0193b35..7e8fe35ce0 100644
--- a/libmpcodecs/vd_dshow.c
+++ b/libmpcodecs/vd_dshow.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "vd_internal.h"
@@ -76,8 +75,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,out_fmt)) return 0;
@@ -98,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;
}
@@ -124,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 a54254b80b..6bee762ed2 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -20,18 +20,22 @@
#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 const vd_info_t info = {
"FFmpeg's libavcodec codec family",
@@ -41,8 +45,6 @@ static const vd_info_t info = {
"native codecs"
};
-LIBVD_EXTERN(ffmpeg)
-
#include "libavcodec/avcodec.h"
#if AVPALETTE_SIZE > 1024
@@ -71,57 +73,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,97 +150,26 @@ 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;
+ case VDCTRL_QUERY_UNSEEN_FRAMES:;
+ int delay = avctx->has_b_frames;
+ return delay + 10;
}
return CONTROL_UNKNOWN;
}
-static 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;
-#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;
- }
-}
-
// 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));
@@ -266,12 +179,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)
@@ -286,19 +199,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;
@@ -306,38 +232,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;
}
@@ -429,17 +355,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);
}
@@ -449,12 +372,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)
);
@@ -462,7 +385,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);
@@ -476,15 +399,16 @@ 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]};
int strides[MP_MAX_PLANES] = {src->linesize[0], src->linesize[1], src->linesize[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){
@@ -533,8 +457,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()
@@ -545,9 +469,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,
@@ -615,7 +536,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;
@@ -650,13 +571,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
@@ -723,6 +644,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;
}
@@ -788,12 +716,15 @@ static 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;
@@ -813,7 +744,12 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){
}
}
- avctx->hurry_up=(flags&3)?((flags&2)?2:1):0;
+ if (flags & 2)
+ avctx->skip_frame = AVDISCARD_ALL;
+ else if (flags & 1)
+ avctx->skip_frame = AVDISCARD_NONREF;
+ else
+ avctx->skip_frame = 0;
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "vd_ffmpeg data: %04x, %04x, %04x, %04x\n",
((int *)data)[0], ((int *)data)[1], ((int *)data)[2], ((int *)data)[3]);
@@ -822,13 +758,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;
@@ -847,7 +786,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);*/
}
@@ -856,8 +795,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++)
@@ -912,7 +851,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;
}
@@ -954,7 +893,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;
@@ -965,13 +903,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_ijpg.c b/libmpcodecs/vd_ijpg.c
index 81d681ad1f..e1b8766f7e 100644
--- a/libmpcodecs/vd_ijpg.c
+++ b/libmpcodecs/vd_ijpg.c
@@ -110,7 +110,7 @@ METHODDEF(void) skip_input_data (j_decompress_ptr cinfo, long num_bytes)
METHODDEF(void) term_source (j_decompress_ptr cinfo) { }
-static 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_libmpeg2.c b/libmpcodecs/vd_libmpeg2.c
index 77529405ce..2e9c0edf24 100644
--- a/libmpcodecs/vd_libmpeg2.c
+++ b/libmpcodecs/vd_libmpeg2.c
@@ -20,7 +20,7 @@
#include <stdlib.h>
#include "config.h"
-
+#include "options.h"
#include "mp_msg.h"
#include "vd_internal.h"
@@ -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_realvid.c b/libmpcodecs/vd_realvid.c
index 24d68657b2..5f4d7cb8a8 100644
--- a/libmpcodecs/vd_realvid.c
+++ b/libmpcodecs/vd_realvid.c
@@ -26,7 +26,6 @@
#endif
#include "mp_msg.h"
-#include "help_mp.h"
#include "mpbswap.h"
#include "path.h"
@@ -85,6 +84,26 @@ static int bufsz = 0;
static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */
#endif
+void *__builtin_vec_new(unsigned long size) {
+ return malloc(size);
+}
+
+void __builtin_vec_delete(void *mem) {
+ free(mem);
+}
+
+void __pure_virtual(void) {
+ printf("FATAL: __pure_virtual() called!\n");
+// exit(1);
+}
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+void ___brk_addr(void) {exit(0);}
+char **__environ={NULL};
+#undef stderr
+FILE *stderr=NULL;
+#endif
+
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
// switch(cmd){
@@ -287,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_theora.c b/libmpcodecs/vd_theora.c
index f0efa250b7..5ad3b35691 100644
--- a/libmpcodecs/vd_theora.c
+++ b/libmpcodecs/vd_theora.c
@@ -23,11 +23,10 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "vd_internal.h"
-#include "libavutil/intreadwrite.h"
+#include "ffmpeg_files/intreadwrite.h"
static const vd_info_t info = {
"Theora/VP3",
diff --git a/libmpcodecs/vd_vfw.c b/libmpcodecs/vd_vfw.c
index c87f5ef5d9..55cc1642f0 100644
--- a/libmpcodecs/vd_vfw.c
+++ b/libmpcodecs/vd_vfw.c
@@ -21,7 +21,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "vd_internal.h"
#include "libmpdemux/aviprint.h"
@@ -316,7 +315,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 cca4f23dd5..da61f73245 100644
--- a/libmpcodecs/vd_xanim.c
+++ b/libmpcodecs/vd_xanim.c
@@ -335,22 +335,6 @@ static int xacodec_query(sh_video_t *sh, XA_CODEC_HDR *codec_hdr)
}
}
-/* These functions are required for loading XAnim binary libs.
- * Add forward declarations to avoid warnings with -Wmissing-prototypes. */
-void XA_Print(char *fmt, ...);
-void TheEnd1(char *err_mess);
-void XA_Add_Func_To_Free_Chain(XA_ANIM_HDR *anim_hdr, void (*function)());
-unsigned long XA_Time_Read(void);
-void XA_Gen_YUV_Tabs(XA_ANIM_HDR *anim_hdr);
-void JPG_Setup_Samp_Limit_Table(XA_ANIM_HDR *anim_hdr);
-void JPG_Alloc_MCU_Bufs(XA_ANIM_HDR *anim_hdr, unsigned int width,
- unsigned int height, unsigned int full_flag);
-void *YUV2x2_Blk_Func(unsigned int image_type, int blks,
- unsigned int dith_flag);
-void *YUV2x2_Map_Func(unsigned int image_type, unsigned int dith_type);
-void *XA_YUV1611_Func(unsigned int image_type);
-void *XA_YUV221111_Func(unsigned int image_type);
-
void XA_Print(char *fmt, ...)
{
va_list vallist;
@@ -386,12 +370,13 @@ void XA_Add_Func_To_Free_Chain(XA_ANIM_HDR *anim_hdr, void (*function)())
return;
}
+
unsigned long XA_Time_Read(void)
{
return GetTimer(); //(GetRelativeTime());
}
-static void XA_dummy(void)
+void XA_dummy(void)
{
XA_Print("dummy() called");
}
@@ -409,7 +394,7 @@ void JPG_Setup_Samp_Limit_Table(XA_ANIM_HDR *anim_hdr)
}
void JPG_Alloc_MCU_Bufs(XA_ANIM_HDR *anim_hdr, unsigned int width,
- unsigned int height, unsigned int full_flag)
+ unsigned int height, unsigned int full_flag)
{
XA_Print("JPG_Alloc_MCU_Bufs('anim_hdr: %08x', 'width: %d', 'height: %d', 'full_flag: %d')",
anim_hdr, width, height, full_flag);
@@ -438,7 +423,7 @@ typedef struct
image->planes[1][((x)>>1)+((y)>>1)*image->stride[1]]=cmap2x2->clr1_0;\
image->planes[2][((x)>>1)+((y)>>1)*image->stride[2]]=cmap2x2->clr1_1;
-static void XA_2x2_OUT_1BLK_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
+void XA_2x2_OUT_1BLK_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
unsigned int imagex, XA_2x2_Color *cmap2x2)
{
mp_image_t *mpi = (mp_image_t *)image_p;
@@ -455,7 +440,7 @@ static void XA_2x2_OUT_1BLK_Convert(unsigned char *image_p, unsigned int x, unsi
return;
}
-static void XA_2x2_OUT_4BLKS_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
+void XA_2x2_OUT_4BLKS_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
unsigned int imagex, XA_2x2_Color *cm0, XA_2x2_Color *cm1, XA_2x2_Color *cm2,
XA_2x2_Color *cm3)
{
@@ -485,7 +470,7 @@ void *YUV2x2_Blk_Func(unsigned int image_type, int blks, unsigned int dith_flag)
// Take Four Y's and UV and put them into a 2x2 Color structure.
-static void XA_YUV_2x2_clr(XA_2x2_Color *cmap2x2, unsigned int Y0, unsigned int Y1,
+void XA_YUV_2x2_clr(XA_2x2_Color *cmap2x2, unsigned int Y0, unsigned int Y1,
unsigned int Y2, unsigned int Y3, unsigned int U, unsigned int V,
unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
{
@@ -537,7 +522,7 @@ YUVTabs def_yuv_tabs;
/* -------------- YUV 4x4 1x1 1x1 (4:1:0 aka YVU9) [Indeo 3,4,5] ------------------ */
-static void XA_YUV1611_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
+void XA_YUV1611_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs,
unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
{
@@ -617,7 +602,7 @@ void *XA_YUV1611_Func(unsigned int image_type)
/* --------------- YUV 2x2 1x1 1x1 (4:2:0 aka YV12) [3ivX,H263] ------------ */
-static void XA_YUV221111_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
+void XA_YUV221111_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs, unsigned int map_flag,
unsigned int *map, XA_CHDR *chdr)
{
diff --git a/libmpcodecs/ve.c b/libmpcodecs/ve.c
index 7cf789d857..d140559530 100644
--- a/libmpcodecs/ve.c
+++ b/libmpcodecs/ve.c
@@ -69,7 +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 49cd4ade97..4cd7cd778d 100644
--- a/libmpcodecs/ve_lavc.c
+++ b/libmpcodecs/ve_lavc.c
@@ -31,7 +31,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "av_opts.h"
#include "osdep/strsep.h"
@@ -549,7 +548,7 @@ static int config(struct vf_instance *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;
}
@@ -680,7 +679,7 @@ static int config(struct vf_instance *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);
@@ -690,7 +689,7 @@ static int config(struct vf_instance *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;
}
@@ -1039,7 +1038,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_nuv.c b/libmpcodecs/ve_nuv.c
index f288f2db7b..9fe25d4154 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"
diff --git a/libmpcodecs/ve_raw.c b/libmpcodecs/ve_raw.c
index b40cae6dce..f2b8e9528c 100644
--- a/libmpcodecs/ve_raw.c
+++ b/libmpcodecs/ve_raw.c
@@ -22,7 +22,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "codec-cfg.h"
#include "stream/stream.h"
@@ -92,7 +91,7 @@ static int set_format(struct vf_instance *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;
}
diff --git a/libmpcodecs/ve_vfw.c b/libmpcodecs/ve_vfw.c
index 3ca53734c6..2825502293 100644
--- a/libmpcodecs/ve_vfw.c
+++ b/libmpcodecs/ve_vfw.c
@@ -26,7 +26,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "codec-cfg.h"
//#include "stream/stream.h"
@@ -101,16 +100,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)
@@ -356,7 +355,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/vf.c b/libmpcodecs/vf.c
index 64d1696be4..217e802a84 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -30,7 +30,6 @@
#endif
#include "mp_msg.h"
-#include "help_mp.h"
#include "m_option.h"
#include "m_struct.h"
@@ -137,15 +136,20 @@ static const vf_info_t* const filter_list[]={
&vf_info_format,
&vf_info_noformat,
&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 +162,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 +196,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,
@@ -216,7 +221,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),
@@ -432,18 +436,22 @@ static int vf_default_query_format(struct vf_instance *vf, unsigned int fmt){
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;
@@ -465,13 +473,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->vf_open(vf,(char*)args)>0) return vf; // Success!
+ *retcode = vf->info->vf_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++)
@@ -483,17 +505,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);
}
/**
@@ -504,11 +527,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
@@ -520,6 +544,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;
@@ -533,7 +558,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
@@ -584,12 +609,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;
}
@@ -617,7 +636,7 @@ int vf_config_wrapper(struct vf_instance *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;
@@ -634,6 +653,7 @@ int vf_config_wrapper(struct vf_instance *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){
@@ -641,12 +661,12 @@ int vf_next_config(struct vf_instance *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
}
}
@@ -655,7 +675,7 @@ int vf_next_config(struct vf_instance *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;
}
@@ -667,14 +687,6 @@ 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 *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 *vf, unsigned int fmt){
int flags=vf->next->query_format(vf->next,fmt);
if(flags) flags|=vf->default_caps;
@@ -709,7 +721,10 @@ void vf_next_draw_slice(struct vf_instance *vf,unsigned char** src, int * stride
//============================================================================
-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;
@@ -719,7 +734,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;
}
}
@@ -734,6 +749,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 6bff30de9a..89874e7162 100644
--- a/libmpcodecs/vf.h
+++ b/libmpcodecs/vf.h
@@ -21,6 +21,7 @@
#include "mp_image.h"
+struct MPOpts;
struct vf_instance;
struct vf_priv_s;
@@ -80,6 +81,7 @@ typedef struct vf_instance {
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);
@@ -133,12 +143,12 @@ 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 *vf, int request, void* data);
-void vf_extra_flip(struct vf_instance *vf);
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);
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index f2d3ebac08..0af76a7ee0 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -30,11 +30,10 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
-#include "vd.h"
#include "vf.h"
#include "libvo/fastmemcpy.h"
@@ -42,7 +41,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)
@@ -62,13 +61,16 @@ 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 ass_track_t* ass_track;
+extern ASS_Track *ass_track;
extern float sub_delay;
extern int sub_visibility;
@@ -76,27 +78,24 @@ 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, 1, 1);
-#else
- ass_set_aspect_ratio(vf->priv->ass_priv, 1);
-#endif
}
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, d_height, flags, outfmt);
@@ -116,7 +115,7 @@ static void get_image(struct vf_instance *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;
}
@@ -165,7 +164,7 @@ 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)
@@ -206,50 +205,49 @@ static int prepare_image(struct vf_instance *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 *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;
}
/**
@@ -258,7 +256,7 @@ static void copy_from_image(struct vf_instance *vf, int first_row, int last_row)
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;
@@ -266,18 +264,14 @@ static void copy_to_image(struct vf_instance *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;
@@ -302,10 +296,10 @@ static void my_draw_bitmap(struct vf_instance *vf, unsigned char* bitmap, int bi
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];
@@ -314,12 +308,15 @@ static void my_draw_bitmap(struct vf_instance *vf, unsigned char* bitmap, int bi
}
}
-static int render_frame(struct vf_instance *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,7 +328,7 @@ static int render_frame(struct vf_instance *vf, mp_image_t *mpi, const ass_image
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);
@@ -356,7 +353,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;
@@ -371,12 +368,10 @@ 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[]={
@@ -392,10 +387,12 @@ static int vf_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)
diff --git a/libmpcodecs/vf_crop.c b/libmpcodecs/vf_crop.c
index 20b0228d82..c4e0b4253b 100644
--- a/libmpcodecs/vf_crop.c
+++ b/libmpcodecs/vf_crop.c
@@ -22,11 +22,10 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
-#include "vd.h"
#include "vf.h"
#include "m_option.h"
@@ -45,6 +44,7 @@ static const struct vf_priv_s {
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;
@@ -74,10 +74,10 @@ static int config(struct vf_instance *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;
}
diff --git a/libmpcodecs/vf_cropdetect.c b/libmpcodecs/vf_cropdetect.c
index e281f3ec72..2401db19d4 100644
--- a/libmpcodecs/vf_cropdetect.c
+++ b/libmpcodecs/vf_cropdetect.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
@@ -153,7 +152,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);
diff --git a/libmpcodecs/vf_divtc.c b/libmpcodecs/vf_divtc.c
index b19a73f281..d632a4c60d 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];
diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c
index f843d8fe43..57226acb93 100644
--- a/libmpcodecs/vf_expand.c
+++ b/libmpcodecs/vf_expand.c
@@ -21,14 +21,14 @@
#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"
-#include "vd.h"
#include "vf.h"
#include "libvo/fastmemcpy.h"
@@ -52,12 +52,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,
@@ -120,7 +121,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
@@ -202,10 +203,10 @@ static void draw_osd(struct vf_instance *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)
@@ -217,7 +218,9 @@ static void draw_osd(struct vf_instance *vf_,int w,int h){
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);
@@ -257,7 +260,7 @@ static int config(struct vf_instance *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;
}
@@ -273,9 +276,9 @@ static int config(struct vf_instance *vf,
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;
}
@@ -289,7 +292,7 @@ static void get_image(struct vf_instance *vf, mp_image_t *mpi){
FFMAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
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;
}
// set up mpi as a cropped-down image of dmpi:
@@ -329,7 +332,7 @@ static void start_slice(struct vf_instance *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;
}
@@ -395,10 +398,10 @@ static int put_image(struct vf_instance *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,7 +436,7 @@ static int put_image(struct vf_instance *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);
}
@@ -443,8 +446,16 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
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);
@@ -467,19 +478,19 @@ static int vf_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;
}
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
-static const m_option_t vf_opts_fields[] = {
+static m_option_t vf_opts_fields[] = {
{"w", ST_OFF(cfg_exp_w), CONF_TYPE_INT, 0, 0 ,0, NULL},
{"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 }
diff --git a/libmpcodecs/vf_filmdint.c b/libmpcodecs/vf_filmdint.c
index 1838a197ca..c8da011d81 100644
--- a/libmpcodecs/vf_filmdint.c
+++ b/libmpcodecs/vf_filmdint.c
@@ -24,10 +24,10 @@
#include "config.h"
#include "mp_msg.h"
#include "cpudetect.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
-#include "vd.h"
#include "vf.h"
#include "cmmx.h"
@@ -1353,6 +1353,7 @@ 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;
@@ -1387,7 +1388,7 @@ static int config(struct vf_instance *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;
}
diff --git a/libmpcodecs/vf_fixpts.c b/libmpcodecs/vf_fixpts.c
index 5ceb516c6b..2881a073d8 100644
--- a/libmpcodecs/vf_fixpts.c
+++ b/libmpcodecs/vf_fixpts.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
diff --git a/libmpcodecs/vf_format.c b/libmpcodecs/vf_format.c
index fa511e9e79..5a28801966 100644
--- a/libmpcodecs/vf_format.c
+++ b/libmpcodecs/vf_format.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
diff --git a/libmpcodecs/vf_framestep.c b/libmpcodecs/vf_framestep.c
index 8b2451fac8..f4ded017ae 100644
--- a/libmpcodecs/vf_framestep.c
+++ b/libmpcodecs/vf_framestep.c
@@ -68,7 +68,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "cpudetect.h"
#include "img_format.h"
@@ -186,7 +185,7 @@ static int vf_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;
}
}
diff --git a/libmpcodecs/vf_geq.c b/libmpcodecs/vf_geq.c
index 61e6d5cdf7..46f449b811 100644
--- a/libmpcodecs/vf_geq.c
+++ b/libmpcodecs/vf_geq.c
@@ -152,7 +152,7 @@ static int vf_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",
@@ -164,7 +164,7 @@ static int vf_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 2732f55d9a..813b9ecb3f 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;
diff --git a/libmpcodecs/vf_lavc.c b/libmpcodecs/vf_lavc.c
index 6c1f1e95f2..757a05cdc2 100644
--- a/libmpcodecs/vf_lavc.c
+++ b/libmpcodecs/vf_lavc.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
@@ -75,7 +74,7 @@ static int config(struct vf_instance *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;
}
@@ -148,7 +147,7 @@ static int vf_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 e97d450112..8d2cca43c0 100644
--- a/libmpcodecs/vf_lavcdeint.c
+++ b/libmpcodecs/vf_lavcdeint.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
diff --git a/libmpcodecs/vf_mcdeint.c b/libmpcodecs/vf_mcdeint.c
index 4df76b28c8..3253d59033 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"
diff --git a/libmpcodecs/vf_noformat.c b/libmpcodecs/vf_noformat.c
index f92014f88d..17f7844121 100644
--- a/libmpcodecs/vf_noformat.c
+++ b/libmpcodecs/vf_noformat.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
diff --git a/libmpcodecs/vf_palette.c b/libmpcodecs/vf_palette.c
index cef47df788..b62773d81a 100644
--- a/libmpcodecs/vf_palette.c
+++ b/libmpcodecs/vf_palette.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
@@ -208,7 +207,7 @@ static int vf_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_pp.c b/libmpcodecs/vf_pp.c
index 2a0c964a90..f3dc4d9537 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];
@@ -198,35 +190,10 @@ static int vf_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;
diff --git a/libmpcodecs/vf_qp.c b/libmpcodecs/vf_qp.c
index cd933f1c3a..fa25a4508f 100644
--- a/libmpcodecs/vf_qp.c
+++ b/libmpcodecs/vf_qp.c
@@ -59,7 +59,7 @@ static int config(struct vf_instance *vf,
i,
0
};
- static const char *const_names[]={
+ const char * const const_names[]={
"PI",
"E",
"known",
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c
index 887bf3d2e2..7579e98ace 100644
--- a/libmpcodecs/vf_scale.c
+++ b/libmpcodecs/vf_scale.c
@@ -24,10 +24,10 @@
#include "config.h"
#include "mp_msg.h"
#include "cpudetect.h"
+#include "options.h"
#include "img_format.h"
#include "mp_image.h"
-#include "vd.h"
#include "vf.h"
#include "fmt-conversion.h"
#include "mpbswap.h"
@@ -168,6 +168,7 @@ static unsigned int find_best_out(vf_instance_t *vf, int in_format){
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;
@@ -349,7 +350,8 @@ static int config(struct vf_instance *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) {
diff --git a/libmpcodecs/vf_spp.c b/libmpcodecs/vf_spp.c
index 10a3489b96..e53a95174b 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"
diff --git a/libmpcodecs/vf_test.c b/libmpcodecs/vf_test.c
index 90386390bd..aeb2763200 100644
--- a/libmpcodecs/vf_test.c
+++ b/libmpcodecs/vf_test.c
@@ -25,7 +25,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
@@ -52,7 +51,7 @@ static int config(struct vf_instance *vf,
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;
}
diff --git a/libmpcodecs/vf_tfields.c b/libmpcodecs/vf_tfields.c
index ff4dd62434..ee50d4f6ca 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"
@@ -326,7 +327,6 @@ static void (*qpel_li)(unsigned char *d, unsigned char *s, int w, int h, int ds,
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 *vf);
-extern int correct_pts;
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
@@ -336,11 +336,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
return continue_buffered_image(vf);
}
-static double calc_pts(double base_pts, int field)
-{
- // FIXME this assumes 25 fps / 50 fields per second
- return base_pts + 0.02 * field;
-}
+extern const int under_mencoder;
static int continue_buffered_image(struct vf_instance *vf)
{
@@ -355,6 +351,7 @@ static int continue_buffered_image(struct vf_instance *vf)
if (i == 0)
vf_queue_frame(vf, continue_buffered_image);
+ pts += i * .02; // XXX not right
if (!(mpi->flags & MP_IMGFLAG_PLANAR)) bpp = mpi->bpp/8;
if (vf->priv->parity < 0) {
@@ -392,11 +389,9 @@ static int continue_buffered_image(struct vf_instance *vf)
dmpi->stride[1] = 2*mpi->stride[1];
dmpi->stride[2] = 2*mpi->stride[2];
}
- ret |= vf_next_put_image(vf, dmpi, calc_pts(pts, i));
- if (correct_pts)
+ ret |= vf_next_put_image(vf, dmpi, pts);
+ if (!under_mencoder)
break;
- else
- if (!i) vf_extra_flip(vf);
}
break;
case 1:
@@ -422,11 +417,9 @@ static int continue_buffered_image(struct vf_instance *vf)
deint(dmpi->planes[2], dmpi->stride[2], mpi->planes[2], mpi->stride[2],
mpi->chroma_width, mpi->chroma_height, (i^!tff));
}
- ret |= vf_next_put_image(vf, dmpi, calc_pts(pts, i));
- if (correct_pts)
+ ret |= vf_next_put_image(vf, dmpi, pts);
+ if (!under_mencoder)
break;
- else
- if (!i) vf_extra_flip(vf);
}
break;
case 2:
@@ -448,11 +441,9 @@ static int continue_buffered_image(struct vf_instance *vf)
mpi->chroma_width, mpi->chroma_height/2,
dmpi->stride[2], mpi->stride[2]*2, (i^!tff));
}
- ret |= vf_next_put_image(vf, dmpi, calc_pts(pts, i));
- if (correct_pts)
+ ret |= vf_next_put_image(vf, dmpi, pts);
+ if (!under_mencoder)
break;
- else
- if (!i) vf_extra_flip(vf);
}
break;
}
diff --git a/libmpcodecs/vf_tile.c b/libmpcodecs/vf_tile.c
index 31193881f6..ad3d662875 100644
--- a/libmpcodecs/vf_tile.c
+++ b/libmpcodecs/vf_tile.c
@@ -55,7 +55,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "cpudetect.h"
#include "img_format.h"
@@ -198,7 +197,7 @@ static void uninit(struct vf_instance *vf)
free(vf->priv);
}
-/* rgb/bgr 12...32 supported & some Yxxx */
+/* rgb/bgr 12->32 supported & some Yxxx */
static int query_format(struct vf_instance *vf, unsigned int fmt)
{
switch (fmt) {
@@ -297,7 +296,7 @@ static int vf_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_vo.c b/libmpcodecs/vf_vo.c
index 115aed411b..3d48b5fce0 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,11 +40,11 @@ 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)
@@ -61,8 +62,7 @@ static int config(struct vf_instance *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,21 +75,21 @@ static int config(struct vf_instance *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;
}
@@ -99,41 +99,41 @@ static int control(struct vf_instance *vf, int request, void* data)
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, &param) == 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, &param) == 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,20 +142,15 @@ static int control(struct vf_instance *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) {
- double dar = (double) (res.w - res.ml - res.mr) / (res.h - res.mt - res.mb);
+ 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, dar, (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);
@@ -165,21 +160,15 @@ static int control(struct vf_instance *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 *vf, unsigned int fmt){
- int flags=video_out->control(VOCTRL_QUERY_FORMAT,&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)
@@ -189,47 +178,50 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){
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 *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 *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 *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 *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);
@@ -249,7 +241,7 @@ static int vf_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 ?
return 1;
}
diff --git a/libmpcodecs/vf_yadif.c b/libmpcodecs/vf_yadif.c
index 6c23f16088..bcca97398a 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"
@@ -382,7 +383,6 @@ static int config(struct vf_instance *vf,
}
static int continue_buffered_image(struct vf_instance *vf);
-extern int correct_pts;
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
int tff;
@@ -411,6 +411,8 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
return continue_buffered_image(vf);
}
+extern const int under_mencoder;
+
static int continue_buffered_image(struct vf_instance *vf)
{
mp_image_t *mpi = vf->priv->buffered_mpi;
@@ -429,13 +431,11 @@ static int continue_buffered_image(struct vf_instance *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;
diff --git a/libmpcodecs/vf_yvu9.c b/libmpcodecs/vf_yvu9.c
index c81478a3a3..1e4e7be561 100644
--- a/libmpcodecs/vf_yvu9.c
+++ b/libmpcodecs/vf_yvu9.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "mp_msg.h"
-#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
@@ -38,7 +37,7 @@ static int config(struct vf_instance *vf,
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;
}