From 18abbb69a1198ab205444219aad830d20a8acd9c Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 1 Mar 2005 20:21:58 +0000 Subject: 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 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14879 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mencoder.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'mencoder.c') 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){ -- cgit v1.2.3