diff --git a/configure b/configure
index de6afd9..3bf85e7 100755
--- a/configure
+++ b/configure
@@ -31,6 +31,7 @@ Configuration options:
   --enable-visualize       enable visualization (X11 only)
   --bit-depth=BIT_DEPTH    set output bit depth (8-10) [8]
   --chroma-format=FORMAT   output chroma format (420, 422, 444, all) [all]
+  --enable-itvfr           enable ITVFR support
 
 Advanced options:
   --disable-asm            disable platform-specific assembly optimizations
@@ -240,6 +241,7 @@ vis="no"
 bit_depth="8"
 chroma_format="all"
 compiler="GNU"
+itvfr="no"
 
 CFLAGS="$CFLAGS -Wall -I."
 LDFLAGS="$LDFLAGS"
@@ -366,6 +368,9 @@ for opt do
                 exit 1
             fi
             ;;
+        --enable-itvfr)
+            itvfr="yes"
+            ;;
         *)
             echo "Unknown option $opt, ignored"
             ;;
@@ -898,6 +903,10 @@ else
     CFLAGS="-O3 -ffast-math $CFLAGS"
 fi
 
+if [ "$itvfr" = "yes" ]; then
+    define HAVE_ITVFR
+fi
+
 if cc_check '' -fno-tree-vectorize ; then
     CFLAGS="$CFLAGS -fno-tree-vectorize"
 fi
@@ -1132,6 +1141,7 @@ PIC:           $pic
 visualize:     $vis
 bit depth:     $bit_depth
 chroma format: $chroma_format
+itvfr:         $itvfr
 EOF
 
 echo >> config.log
diff --git a/vfrout.h b/vfrout.h
new file mode 100644
index 0000000..453081a
--- /dev/null
+++ b/vfrout.h
@@ -0,0 +1,56 @@
+//
+// vfrout.h
+//
+#ifndef vfrout_h
+#define vfrout_h
+
+#include <windows.h>
+#include <stdio.h>
+#include <process.h>
+
+static HANDLE m_hMemMap = NULL;
+static char *m_MemView = NULL;
+static int itvfr_pid = 0;
+
+FILE* Tmc_Outfile( char *outfile )
+{
+    FILE *tmc_fp = NULL;
+    char tmc_outfile[_MAX_PATH];
+
+    if( !strncasecmp( outfile + strlen(outfile) - 4, ".264", 4 ) )
+    {
+        _snprintf( tmc_outfile, _MAX_PATH, "%s.tmc", outfile );
+        tmc_fp = fopen( tmc_outfile, "wb" );
+    }
+
+    return tmc_fp;
+}
+
+HANDLE VfrOut( void )
+{
+    char MemFile[100];
+    if( itvfr_pid == 0 ) itvfr_pid = _getpid();
+    _snprintf( MemFile, 100, "vfrout_%d", itvfr_pid );
+    m_hMemMap = OpenFileMapping( FILE_MAP_ALL_ACCESS, FALSE, MemFile );
+    if( m_hMemMap == NULL ) return NULL;
+    m_MemView = (char*) MapViewOfFile( m_hMemMap, FILE_MAP_ALL_ACCESS, 0, 0, 0 );
+    return m_hMemMap;
+}
+
+char GetStatus( int frame )
+{
+    return m_MemView[frame];
+}
+
+void VfrOutClose( void )
+{
+    if( m_hMemMap )
+    {
+        UnmapViewOfFile( m_MemView );
+        CloseHandle( m_hMemMap );
+        m_MemView = NULL;
+        m_hMemMap = NULL;
+    }
+}
+
+#endif //vfrout.h
diff --git a/x264.c b/x264.c
index d735ab4..5440742 100644
--- a/x264.c
+++ b/x264.c
@@ -60,6 +60,11 @@
 #include <ffms.h>
 #endif
 
+#if HAVE_ITVFR
+#include "vfrout.h"
+static int itvfr = 0;
+#endif
+
 /* Ctrl-C handler */
 static volatile int b_ctrl_c = 0;
 static int          b_exit_on_ctrl_c = 0;
@@ -247,6 +252,9 @@ static void print_version_info()
     printf( "using an unknown compiler\n" );
 #endif
     printf( "configuration: --bit-depth=%d --chroma-format=%s\n", x264_bit_depth, X264_CHROMA_FORMAT ? (output_csp_names[0]+1) : "all" );
+#if HAVE_ITVFR
+    printf( "add option: ITVFR support\n" );
+#endif
     printf( "x264 license: " );
 #if HAVE_GPL
     printf( "GPL version 2 or later\n" );
@@ -385,6 +393,9 @@ static void help( x264_param_t *defaults, int longhelp )
         " .flv -> Flash Video\n"
         " .mp4 -> MP4 if compiled with GPAC support (%s)\n"
         "Output bit depth: %d (configured at compile time)\n"
+#if HAVE_ITVFR
+        "VFR output: ITVFR support (auto select)\n"
+#endif
         "\n"
         "Options:\n"
         "\n"
@@ -808,6 +819,9 @@ static void help( x264_param_t *defaults, int longhelp )
     H2( "      --timebase <int/int>    Specify timebase numerator and denominator\n"
         "                 <integer>    Specify timebase numerator for input timecode file\n"
         "                              or specify timebase denominator for other input\n" );
+#if HAVE_ITVFR
+    H1( "      --pid                   Set process id if use x264out.auo\n" );
+#endif
     H2( "      --dts-compress          Eliminate initial delay with container DTS hack\n" );
     H0( "\n" );
     H0( "Filtering:\n" );
@@ -852,6 +866,9 @@ typedef enum
     OPT_INPUT_RES,
     OPT_INPUT_CSP,
     OPT_INPUT_DEPTH,
+#if HAVE_ITVFR
+    OPT_PID,
+#endif 
     OPT_DTS_COMPRESSION,
     OPT_OUTPUT_CSP
 } OptionsOPT;
@@ -1011,6 +1028,9 @@ static struct option long_options[] =
     { "input-res",   required_argument, NULL, OPT_INPUT_RES },
     { "input-csp",   required_argument, NULL, OPT_INPUT_CSP },
     { "input-depth", required_argument, NULL, OPT_INPUT_DEPTH },
+#if HAVE_ITVFR
+    { "pid",         required_argument, NULL, OPT_PID },
+#endif
     { "dts-compress",      no_argument, NULL, OPT_DTS_COMPRESSION },
     { "output-csp",  required_argument, NULL, OPT_OUTPUT_CSP },
     {0, 0, 0, 0}
@@ -1389,6 +1409,11 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )
             case OPT_INPUT_DEPTH:
                 input_opt.bit_depth = atoi( optarg );
                 break;
+#if HAVE_ITVFR
+            case OPT_PID:
+                itvfr_pid = atoi( optarg );
+                break;
+#endif
             case OPT_DTS_COMPRESSION:
                 output_opt.use_dts_compress = 1;
                 break;
@@ -1478,6 +1503,27 @@ generic_option:
                   info.height, info.interlaced ? 'i' : 'p', info.sar_width, info.sar_height,
                   info.fps_num, info.fps_den, info.vfr ? 'v' : 'c' );
 
+#if HAVE_ITVFR
+    itvfr = 0;
+    if( VfrOut() != NULL )
+    {
+        b_user_fps = 0;
+        tcfile_name = NULL;
+        input_opt.timebase = NULL;
+
+        if( !opt->tcfile_out )
+            opt->tcfile_out = Tmc_Outfile( output_filename );
+
+        info.vfr          = 1;
+        info.fps_num      = 120000;
+        info.fps_den      = 1001;
+        info.timebase_num = info.fps_den;
+        info.timebase_den = info.fps_num;
+
+        itvfr = 1;
+        x264_cli_log( "x264", X264_LOG_INFO, "ITVFR enabled. timebase: %d/%d\n", info.timebase_num, info.timebase_den );
+    }
+#endif
     if( tcfile_name )
     {
         FAIL_IF_ERROR( b_user_fps, "--fps + --tcfile-in is incompatible.\n" )
@@ -1721,6 +1767,16 @@ static int encode( x264_param_t *param, cli_opt_t *opt )
     double  duration;
     double  pulldown_pts = 0;
     int     retval = 0;
+#if HAVE_ITVFR
+    int     drop = 0;
+    int     i_frame_out = 0;
+    double  timecode = 0;
+    int8_t  status = 0;
+    char    *stat_out;
+
+    if( itvfr )
+        stat_out = strdup( param->rc.psz_stat_out );
+#endif
 
     opt->b_progress &= param->i_log_level < X264_LOG_DEBUG;
 
@@ -1771,6 +1827,24 @@ static int encode( x264_param_t *param, cli_opt_t *opt )
         x264_picture_init( &pic );
         convert_cli_to_lib_pic( &pic, &cli_pic );
 
+#if HAVE_ITVFR
+        if( itvfr )
+        {
+            pic.i_pts = (int64_t)timecode;
+            status = GetStatus(i_frame);
+            switch( status )
+            {
+                case '2': timecode += 5; break;
+                case '3': timecode += 4; break;
+                case '6': timecode += 2; break;
+                default:
+                    if( ((uint8_t)status & 0xF0) == 0x80 )
+                        timecode += ((uint8_t)status & 0x0F);
+                    break;
+            }
+        }
+        else
+#endif
         if( !param->b_vfr_input )
             pic.i_pts = i_frame;
 
@@ -1794,14 +1868,25 @@ static int encode( x264_param_t *param, cli_opt_t *opt )
             pic.i_pts = largest_pts + ticks_per_frame;
         }
 
+#if HAVE_ITVFR
+      if( status != 'D' )
+      {
+#endif
         second_largest_pts = largest_pts;
         largest_pts = pic.i_pts;
         if( opt->tcfile_out )
             fprintf( opt->tcfile_out, "%.6f\n", pic.i_pts * ((double)param->i_timebase_num / param->i_timebase_den) * 1e3 );
+#if HAVE_ITVFR
+      }
+#endif
 
         if( opt->qpfile )
             parse_qpfile( opt, &pic, i_frame + opt->i_seek );
 
+#if HAVE_ITVFR
+      if( status != 'D' )
+      {
+#endif
         prev_dts = last_dts;
         i_frame_size = encode_frame( h, opt->hout, &pic, &last_dts );
         if( i_frame_size < 0 )
@@ -1816,6 +1901,10 @@ static int encode( x264_param_t *param, cli_opt_t *opt )
             if( i_frame_output == 1 )
                 first_dts = prev_dts = last_dts;
         }
+#if HAVE_ITVFR
+        i_frame_out++;
+      } else drop++;
+#endif
 
         if( filter.release_frame( opt->hin, &cli_pic, i_frame + opt->i_seek ) )
             break;
@@ -1870,11 +1959,47 @@ fail:
     cli_output.close_file( opt->hout, largest_pts, second_largest_pts );
     opt->hout = NULL;
 
+#if HAVE_ITVFR
+    VfrOutClose();
+    if( itvfr && opt->tcfile_out )
+    {
+        fprintf( opt->tcfile_out, "# LASTTIME %.6f\n", timecode * ((double)param->i_timebase_num / param->i_timebase_den) * 1e3 );
+    }
+
+    /* statusファイルの終端補完／エンコーダーがファイルを閉じた後 */
+    if( itvfr && param->rc.b_stat_write && !param->rc.b_stat_read )
+    {
+        if( stat_out )
+        {
+            FILE *fpstat = fopen( stat_out, "ab" );
+            if( fpstat )
+            {
+                for( int i = 0; i < drop; i++ ){
+                    fprintf( fpstat,
+                             "in:%d out:%d type:I dur:0 cpbdur:0 q:1.0 tex:0 mv:0 misc:0 imb:0 pmb:0 smb:0 d:- ref:0 ;\n",
+                             i_frame_out + i, i_frame_out + i );
+                }
+                fclose( fpstat );
+                fpstat = NULL;
+            }
+            free( stat_out );
+            stat_out = NULL;
+        }
+    }
+#endif
+
     if( i_frame_output > 0 )
     {
         double fps = (double)i_frame_output * (double)1000000 /
                      (double)( i_end - i_start );
 
+#if HAVE_ITVFR
+      if( itvfr )
+        fprintf( stderr, "encoded %d/%d frames, %.2f fps, %.2f kb/s\n", i_frame - drop,i_frame, fps,
+                 (double) i_file * 8 * param->i_fps_num /
+                 ( (double) param->i_fps_den * i_frame_output * 1000 ) );
+      else
+#endif
         fprintf( stderr, "encoded %d frames, %.2f fps, %.2f kb/s\n", i_frame_output, fps,
                  (double) i_file * 8 / ( 1000 * duration ) );
     }
