summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhenry <henry@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-03-01 20:21:58 +0000
committerhenry <henry@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-03-01 20:21:58 +0000
commit18abbb69a1198ab205444219aad830d20a8acd9c (patch)
treea0a29016c7a1d17bc8e7cdac20108975f73b1608
parent9bc6e8097212e5358a0dce1dda158b0f05e017d9 (diff)
downloadmpv-18abbb69a1198ab205444219aad830d20a8acd9c.tar.bz2
mpv-18abbb69a1198ab205444219aad830d20a8acd9c.tar.xz
fixes for encoding of multiple files
- do not uninitialize video encoder between files - checks for image size & format change moved from mencoder.c to vfilters by Oded Shimon <ods15@ods15.dyndns.org> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14879 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--help/help_mp-en.h2
-rw-r--r--libmpcodecs/vd.c8
-rw-r--r--libmpcodecs/ve_divx4.c1
-rw-r--r--libmpcodecs/ve_lavc.c1
-rw-r--r--libmpcodecs/ve_libdv.c1
-rw-r--r--libmpcodecs/ve_nuv.c1
-rw-r--r--libmpcodecs/ve_qtvideo.c1
-rw-r--r--libmpcodecs/ve_raw.c1
-rw-r--r--libmpcodecs/ve_vfw.c1
-rw-r--r--libmpcodecs/ve_x264.c1
-rw-r--r--libmpcodecs/ve_xvid.c1
-rw-r--r--libmpcodecs/ve_xvid4.c1
-rw-r--r--libmpcodecs/vf.c33
-rw-r--r--libmpcodecs/vf.h9
-rw-r--r--libmpcodecs/vfcap.h2
-rw-r--r--mencoder.c46
16 files changed, 81 insertions, 29 deletions
diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index cf2d13b403..061d1a4f3c 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -215,7 +215,7 @@ static char help_text[]=
#define MSGTR_WritingAVIHeader "Writing AVI header...\n"
#define MSGTR_DuplicateFrames "\n%d duplicate frame(s)!\n"
#define MSGTR_SkipFrame "\nSkipping frame!\n"
-#define MSGTR_ResolutionDoesntMatch "\nNew video file has different resolution than the previous one.\n"
+#define MSGTR_ResolutionDoesntMatch "\nNew video file has different resolution or colorspace than the previous one.\n"
#define MSGTR_FrameCopyFileMismatch "\nAll video files must have identical fps, resolution, and codec for -ovc copy.\n"
#define MSGTR_AudioCopyFileMismatch "\nAll files must have identical audio codec and format for -oac copy.\n"
#define MSGTR_ErrorWritingFile "%s: Error writing file.\n"
diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c
index 439cc8383a..4b20ab4fee 100644
--- a/libmpcodecs/vd.c
+++ b/libmpcodecs/vd.c
@@ -309,10 +309,10 @@ csp_again:
vf->w = sh->disp_w;
vf->h = sh->disp_h;
- if(vf->config(vf,sh->disp_w,sh->disp_h,
- screen_size_x,screen_size_y,
- fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3),
- out_fmt)==0){
+ if(vf_config_wrapper(vf,sh->disp_w,sh->disp_h,
+ screen_size_x,screen_size_y,
+ fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3),
+ out_fmt)==0){
// "MPlayer",out_fmt)){
mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_CannotInitVO);
sh->vf_inited=-1;
diff --git a/libmpcodecs/ve_divx4.c b/libmpcodecs/ve_divx4.c
index 11f18b9f00..0e4a7e3c1d 100644
--- a/libmpcodecs/ve_divx4.c
+++ b/libmpcodecs/ve_divx4.c
@@ -453,6 +453,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
static int vf_open(vf_instance_t *vf, char* args){
vf->config=config;
+ vf->default_caps=VFCAP_CONSTANT;
vf->control=control;
vf->query_format=query_format;
vf->put_image=put_image;
diff --git a/libmpcodecs/ve_lavc.c b/libmpcodecs/ve_lavc.c
index c9a43974e8..b6d6228c73 100644
--- a/libmpcodecs/ve_lavc.c
+++ b/libmpcodecs/ve_lavc.c
@@ -923,6 +923,7 @@ static void uninit(struct vf_instance_s* vf){
static int vf_open(vf_instance_t *vf, char* args){
vf->uninit=uninit;
vf->config=config;
+ vf->default_caps=VFCAP_CONSTANT;
vf->control=control;
vf->query_format=query_format;
vf->put_image=put_image;
diff --git a/libmpcodecs/ve_libdv.c b/libmpcodecs/ve_libdv.c
index cb8a7b7dbd..22d9e92b4b 100644
--- a/libmpcodecs/ve_libdv.c
+++ b/libmpcodecs/ve_libdv.c
@@ -85,6 +85,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
static int vf_open(vf_instance_t *vf, char* args){
vf->config=config;
+ vf->default_caps=VFCAP_CONSTANT;
vf->control=control;
vf->query_format=query_format;
vf->put_image=put_image;
diff --git a/libmpcodecs/ve_nuv.c b/libmpcodecs/ve_nuv.c
index 96719e06c5..f1a9f92b4b 100644
--- a/libmpcodecs/ve_nuv.c
+++ b/libmpcodecs/ve_nuv.c
@@ -192,6 +192,7 @@ static void uninit(struct vf_instance_s* vf) {
static int vf_open(vf_instance_t *vf, char* args){
vf->config=config;
+ vf->default_caps=VFCAP_CONSTANT;
vf->control=control;
vf->query_format=query_format;
vf->put_image=put_image;
diff --git a/libmpcodecs/ve_qtvideo.c b/libmpcodecs/ve_qtvideo.c
index 58bfc30924..f871de2755 100644
--- a/libmpcodecs/ve_qtvideo.c
+++ b/libmpcodecs/ve_qtvideo.c
@@ -278,6 +278,7 @@ if(!codec_inited){
static int vf_open(vf_instance_t *vf, char* args){
OSErr cres = 1;
vf->config=config;
+ vf->default_caps=VFCAP_CONSTANT;
vf->control=control;
vf->query_format=query_format;
vf->put_image=put_image;
diff --git a/libmpcodecs/ve_raw.c b/libmpcodecs/ve_raw.c
index 620dec483f..fe4470017a 100644
--- a/libmpcodecs/ve_raw.c
+++ b/libmpcodecs/ve_raw.c
@@ -125,6 +125,7 @@ static int put_image(struct vf_instance_s *vf, mp_image_t *mpi) {
static int vf_open(vf_instance_t *vf, char* args){
vf->config = config;
+ vf->default_caps = VFCAP_CONSTANT;
vf->control = control;
vf->query_format = query_format;
vf->put_image = put_image;
diff --git a/libmpcodecs/ve_vfw.c b/libmpcodecs/ve_vfw.c
index f30b5b53df..1d31302085 100644
--- a/libmpcodecs/ve_vfw.c
+++ b/libmpcodecs/ve_vfw.c
@@ -251,6 +251,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
static int vf_open(vf_instance_t *vf, char* args){
vf->config=config;
+ vf->default_caps=VFCAP_CONSTANT;
vf->control=control;
vf->query_format=query_format;
vf->put_image=put_image;
diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c
index e26e7e11a4..06d5512fba 100644
--- a/libmpcodecs/ve_x264.c
+++ b/libmpcodecs/ve_x264.c
@@ -375,6 +375,7 @@ static int vf_open(vf_instance_t *vf, char *args) {
h264_module_t *mod;
vf->config = config;
+ vf->default_caps = VFCAP_CONSTANT;
vf->control = control;
vf->query_format = query_format;
vf->put_image = put_image;
diff --git a/libmpcodecs/ve_xvid.c b/libmpcodecs/ve_xvid.c
index 5303e13d2f..d2979dddb2 100644
--- a/libmpcodecs/ve_xvid.c
+++ b/libmpcodecs/ve_xvid.c
@@ -539,6 +539,7 @@ vf_open(vf_instance_t *vf, char* args)
{
XVID_INIT_PARAM params = { 0, 0, 0};
vf->config = config;
+ vf->default_caps = VFCAP_CONSTANT;
vf->control = control;
vf->uninit = uninit;
vf->query_format = query_format;
diff --git a/libmpcodecs/ve_xvid4.c b/libmpcodecs/ve_xvid4.c
index 8457b5f2ce..5e0c4087b0 100644
--- a/libmpcodecs/ve_xvid4.c
+++ b/libmpcodecs/ve_xvid4.c
@@ -546,6 +546,7 @@ vf_open(vf_instance_t *vf, char* args)
/* Setting libmpcodec module API pointers */
vf->config = config;
+ vf->default_caps = VFCAP_CONSTANT;
vf->control = control;
vf->uninit = uninit;
vf->query_format = query_format;
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 0bebfcc49e..e510d99e31 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -541,6 +541,37 @@ void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src){
dst->qscale= src->qscale;
}
}
+/**
+ * \brief Video config() function wrapper
+ *
+ * Blocks config() calls with different size or format for filters
+ * with VFCAP_CONSTANT
+ *
+ * First call is redirected to vf->config.
+ *
+ * In following calls, it verifies that the configuration parameters
+ * are unchanged, and returns either success or error.
+ *
+*/
+int vf_config_wrapper(struct vf_instance_s* vf,
+ int width, int height, int d_width, int d_height,
+ unsigned int flags, unsigned int outfmt)
+{
+ if ((vf->default_caps&VFCAP_CONSTANT) && vf->fmt.have_configured) {
+ if ((vf->fmt.orig_width != width)
+ || (vf->fmt.orig_height != height)
+ || (vf->fmt.orig_fmt != outfmt)) {
+ mp_msg(MSGT_VFILTER,MSGL_FATAL,MSGTR_ResolutionDoesntMatch);
+ return 0;
+ }
+ return 1;
+ }
+ vf->fmt.have_configured = 1;
+ vf->fmt.orig_height = height;
+ vf->fmt.orig_width = width;
+ vf->fmt.orig_fmt = outfmt;
+ vf->config(vf, width, height, d_width, d_height, flags, outfmt);
+}
int vf_next_config(struct vf_instance_s* vf,
int width, int height, int d_width, int d_height,
@@ -571,7 +602,7 @@ int vf_next_config(struct vf_instance_s* vf,
vf->next=vf2;
}
vf->next->w = width; vf->next->h = height;
- return vf->next->config(vf->next,width,height,d_width,d_height,voflags,outfmt);
+ return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt);
}
int vf_next_control(struct vf_instance_s* vf, int request, void* data){
diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h
index 85ae9a6f89..77f80d2897 100644
--- a/libmpcodecs/vf.h
+++ b/libmpcodecs/vf.h
@@ -19,6 +19,11 @@ typedef struct vf_image_context_s {
int static_idx;
} vf_image_context_t;
+typedef struct vf_format_context_t {
+ int have_configured;
+ int orig_width, orig_height, orig_fmt;
+} vf_format_context_t;
+
typedef struct vf_instance_s {
vf_info_t* info;
// funcs:
@@ -44,6 +49,7 @@ typedef struct vf_instance_s {
// data:
int w, h;
vf_image_context_t imgctx;
+ vf_format_context_t fmt;
struct vf_instance_s* next;
mp_image_t *dmpi;
struct vf_priv_s* priv;
@@ -99,3 +105,6 @@ void vf_list_plugins();
void vf_uninit_filter(vf_instance_t* vf);
void vf_uninit_filter_chain(vf_instance_t* vf);
+int vf_config_wrapper(struct vf_instance_s* vf,
+ int width, int height, int d_width, int d_height,
+ unsigned int flags, unsigned int outfmt);
diff --git a/libmpcodecs/vfcap.h b/libmpcodecs/vfcap.h
index 2a0d12d4ff..aafdd334e7 100644
--- a/libmpcodecs/vfcap.h
+++ b/libmpcodecs/vfcap.h
@@ -24,4 +24,6 @@
#define VFCAP_ACCEPT_STRIDE 0x400
// filter does postprocessing (so you shouldn't scale/filter image before it)
#define VFCAP_POSTPROC 0x800
+// filter cannot be reconfigured to different size & format
+#define VFCAP_CONSTANT 0x1000
diff --git a/mencoder.c b/mencoder.c
index 016dac2977..78a5e22992 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -392,8 +392,6 @@ char* frameno_filename="frameno.avi";
int decoded_frameno=0;
int next_frameno=-1;
int curfile=0;
-int prevwidth = 0;
-int prevhieght = 0; ///< When different from 0, after decoding a frame, Resolution must be checked to match previous file
unsigned int timer_start;
@@ -739,8 +737,9 @@ case VCODEC_FRAMENO:
mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
}
break;
-default:
-
+default: {
+ static vf_instance_t * ve = NULL;
+ if (!ve) {
switch(mux_v->codec){
case VCODEC_DIVX4:
sh_video->vfilter=vf_open_encoder(NULL,"divx4",(char *)mux_v); break;
@@ -765,6 +764,8 @@ default:
mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_EncoderOpenFailed);
mencoder_exit(1,NULL);
}
+ ve = sh_video->vfilter;
+ } else sh_video->vfilter = ve;
// append 'expand' filter, it fixes stride problems and renders osd:
if (auto_expand) {
char* vf_args[] = { "osd", "1", NULL };
@@ -776,7 +777,7 @@ default:
init_best_video_codec(sh_video,video_codec_list,video_fm_list);
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
if(!sh_video->inited) mencoder_exit(1,NULL);
-
+ }
}
if (!curfile) {
@@ -1544,13 +1545,7 @@ default:
blit_frame=decode_video(sh_video,start,in_size,
skip_flag>0 && (!sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE));
- if (prevwidth) {
- if ((mux_v->bih->biWidth != prevwidth) || (mux_v->bih->biHeight != prevhieght)) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ResolutionDoesntMatch);
- mencoder_exit(1,NULL);
- }
- prevhieght = prevwidth = 0;
- }
+ if (sh_video->vf_inited < 0) mencoder_exit(1, NULL);
if(!blit_frame){
badframes++;
@@ -1724,28 +1719,33 @@ if(sh_audio && !demuxer2){
} // while(!at_eof)
-/* Emit the remaining frames in the video system */
-/*TODO emit frmaes delayed by decoder lag*/
- if(sh_video && sh_video->vfilter){
- mp_msg(MSGT_FIXME, MSGL_FIXME, "\nFlushing video frames\n");
- ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter,
- VFCTRL_FLUSH_FRAMES, 0);
- }
-
if (!interrupted && filelist[++curfile].name != 0) {
+ // Before uniniting sh_video and the filter chain, break apart the VE.
+ vf_instance_t * ve; // this will be the filter right before the ve.
+ for (ve = sh_video->vfilter; ve->next && ve->next->next; ve = ve->next);
+ if (ve->next)
+ ve->next = NULL; // I'm telling the last filter, before the VE, there is nothing after it
+ else // There is no chain except the VE.
+ sh_video->vfilter = NULL;
+
if(sh_video){ uninit_video(sh_video);sh_video=NULL; }
if(demuxer) free_demuxer(demuxer);
if(stream) free_stream(stream); // kill cache thread
- prevwidth = mux_v->bih->biWidth;
- prevhieght = mux_v->bih->biHeight;
-
at_eof = 0;
m_config_pop(mconfig);
goto play_next_file;
}
+/* Emit the remaining frames in the video system */
+/*TODO emit frmaes delayed by decoder lag*/
+if(sh_video && sh_video->vfilter){
+ mp_msg(MSGT_MENCODER, MSGL_INFO, "\nFlushing video frames\n");
+ ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter,
+ VFCTRL_FLUSH_FRAMES, 0);
+}
+
#ifdef HAVE_MP3LAME
// fixup CBR mp3 audio header:
if(sh_audio && mux_a->codec==ACODEC_VBRMP3 && !lame_param_vbr){