[svn] / branches / dev-api-4 / xvidcore / src / plugins / plugin_2pass1.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/plugins/plugin_2pass1.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1285, Sat Dec 20 11:54:37 2003 UTC revision 1286, Sat Dec 20 15:30:03 2003 UTC
# Line 22  Line 22 
22   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
23   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24   *   *
25   * $Id: plugin_2pass1.c,v 1.1.2.11 2003-12-18 17:43:32 edgomez Exp $   * $Id: plugin_2pass1.c,v 1.1.2.12 2003-12-20 15:30:03 edgomez Exp $
26   *   *
27   *****************************************************************************/   *****************************************************************************/
28    
29  #include <stdio.h>  #include <stdio.h>
30    #include <errno.h> /* errno var (or function with recent libc) */
31    #include <string.h> /* strerror() */
32    
33  #include "../xvid.h"  #include "../xvid.h"
34  #include "../image/image.h"  #include "../image/image.h"
# Line 63  Line 65 
65          if((rc->stat_file = fopen(param->filename, "w+b")) == NULL)          if((rc->stat_file = fopen(param->filename, "w+b")) == NULL)
66                  return(XVID_ERR_FAIL);                  return(XVID_ERR_FAIL);
67    
68            /* I swear xvidcore isn't buggy, but when using mencoder+xvid4 i observe
69             * this weird bug.
70             *
71             * Symptoms: The stats file grows until it's fclosed, but at this moment
72             *           a large part of the file is filled by 0x00 bytes w/o any
73             *           reasonable cause. The stats file is then completly unusable
74             *
75             * So far, i think i found "the why":
76             *  - take a MPEG stream containing 2 sequences (concatenate 2 MPEG files
77             *    together)
78             *  - Encode this MPEG file
79             *
80             * It should trigger the bug
81             *
82             * I think this is caused by some kind of race condition on mencoder module
83             * start/stop.
84             *  - mencoder encodes the first sequence
85             *    + xvid4 module opens xvid-twopass.stats and writes stats in it.
86             *  - mencoder detects the second sequence and initialize a second
87             *    module and stops the old encoder
88             *    + new xvid4 module opens a new xvid-twopass.stats, old xvid4
89             *      module closes it
90             *
91             * This is IT, got a racing condition.
92             * Unbuffered IO, may help ... */
93            setbuf(rc->stat_file, NULL);
94    
95          /*          /*
96           * The File Header           * The File Header
97           */           */
# Line 81  Line 110 
110    
111  static int rc_2pass1_destroy(rc_2pass1_t * rc, xvid_plg_destroy_t * destroy)  static int rc_2pass1_destroy(rc_2pass1_t * rc, xvid_plg_destroy_t * destroy)
112  {  {
113          fclose(rc->stat_file);          if (rc->stat_file) {
114          free(rc);                  if (fclose(rc->stat_file) == EOF) {
115                            DPRINTF(XVID_DEBUG_RC, "Error closing stats file (%s)", strerror(errno));
116                    }
117            }
118            rc->stat_file = NULL; /* Just a paranoid reset */
119            free(rc); /* as the container structure is freed anyway */
120          return(0);          return(0);
121  }  }
122    

Legend:
Removed from v.1285  
changed lines
  Added in v.1286

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4