Index: cmdutils.c
===================================================================
--- cmdutils.c	(revision 14819)
+++ cmdutils.c	(working copy)
@@ -216,6 +216,18 @@
 
 void show_banner(void)
 {
+    fprintf(stderr, "%s version from svn, Copyright (c) %d-2008 Fabrice Bellard, et al.\n",
+            program_name, program_birth_year);
+
+    fprintf(stderr, 
+      "\n"
+      "NOTICE: This file contains changes made by SlySoft Inc. in compliance with GPL.\n"
+      "        All changes are available as patches from http://oss.slysoft.com\n"
+      "\n"
+      );
+    
+    return;
+
     fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-2008 Fabrice Bellard, et al.\n",
             program_name, program_birth_year);
     fprintf(stderr, "  configuration: " FFMPEG_CONFIGURATION "\n");
@@ -230,12 +242,14 @@
 
 void show_version(void) {
     printf("%s " FFMPEG_VERSION "\n", program_name);
+    return;
+
     print_all_lib_versions(stdout, 0);
 }
 
 void show_license(void)
 {
#ifdef CONFIG_NONFREE
     printf(
     "This version of %s has nonfree parts compiled in.\n"
     "Therefore it is not legally redistributable.\n",
@@ -287,6 +301,9 @@
     AVBitStreamFilter *bsf=NULL;
     const char *last_name;
 
+    printf("NOTICE: Program cannot be called directly. No format information available.\n");
+    return;
+
     printf("File formats:\n");
     last_name= "000";
     for(;;){
Index: configure
===================================================================
--- configure	(revision 14819)
+++ configure	(working copy)
@@ -628,7 +628,7 @@
 apply(){
     file=$1
     shift
-    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
+    "$@" < "$file" > "$file.tmp" && cp "$file.tmp" "$file" || rm "$file.tmp"
 }
 
 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
@@ -1126,7 +1126,7 @@
 TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
 
 check_cflags -fasm
-check_cflags -std=c99
+# check_cflags -std=c99                    libfaac is broken
 
 case "$arch" in
     i386|i486|i586|i686|i86pc|BePC)
@@ -1712,7 +1712,7 @@
                         && require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
 enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
-enabled libx264    && require  x264 x264.h x264_encoder_open -lx264 -lm
+enabled libx264    && require  x264 x264.h x264_encoder_open -lx264 -lm -lpthreadGC2
 enabled libxvid    && require  Xvid xvid.h xvid_global -lxvidcore
 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
 
@@ -1867,7 +1867,7 @@
         add_cflags  "-O5"
         add_ldflags "-O5"
     else
-        add_cflags "-O3"
+        add_cflags "-O4 -g -ggdb"
     fi
 fi
 check_cflags -fno-math-errno
@@ -2164,7 +2164,7 @@
 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
 cmp -s $TMPH config.h &&
     echo "config.h is unchanged" ||
-    mv -f $TMPH config.h
+    cp -f $TMPH config.h
 
 rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
 
Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 14819)
+++ ffmpeg.c	(working copy)
@@ -38,6 +38,7 @@
 #include "libavcodec/opt.h"
 #include "libavcodec/audioconvert.h"
 #include "libavutil/fifo.h"
+#include "libavutil/file.h"
 #include "libavutil/avstring.h"
 #include "libavformat/os_support.h"
 
@@ -117,6 +118,8 @@
 static int frame_bottomBand = 0;
 static int frame_leftBand  = 0;
 static int frame_rightBand = 0;
+static int video_width = 0;
+static int video_height = 0;
 static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
 static AVRational frame_rate;
 static float video_qscale = 0;
@@ -152,6 +155,8 @@
 static char *audio_language = NULL;
 
 static int subtitle_disable = 0;
+static int subtitle_etching = 0;
+static int subtitle_id = 0;
 static char *subtitle_codec_name = NULL;
 static char *subtitle_language = NULL;
 
@@ -160,6 +165,7 @@
 
 static int64_t recording_time = INT64_MAX;
 static int64_t start_time = 0;
+static int64_t last_delta = 0;
 static int64_t rec_timestamp = 0;
 static int64_t input_ts_offset = 0;
 static int file_overwrite = 0;
@@ -765,6 +771,10 @@
 /* we begin to correct av delay at this threshold */
 #define AV_DELAY_MAX 0.100
 
+static AVSubtitle subtitle_etch;
+static uint64_t subtitle_etch_start;
+static uint64_t subtitle_etch_end;
+
 static void do_subtitle_out(AVFormatContext *s,
                             AVOutputStream *ost,
                             AVInputStream *ist,
@@ -819,6 +829,7 @@
 
 static int bit_buffer_size= 1024*256;
 static uint8_t *bit_buffer= NULL;
+static int frame_dropping = 0;
 
 static void do_video_out(AVFormatContext *s,
                          AVOutputStream *ost,
@@ -827,10 +838,11 @@
                          int *frame_size)
 {
     int nb_frames, i, ret;
-    AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
-    AVFrame picture_crop_temp, picture_pad_temp;
+    AVFrame *final_picture, *formatted_picture, *etched_picture, *resampling_dst, *padding_src;
+    AVFrame picture_etching_temp, picture_crop_temp, picture_pad_temp;
     AVCodecContext *enc, *dec;
 
+    avcodec_get_frame_defaults(&picture_etching_temp);
     avcodec_get_frame_defaults(&picture_crop_temp);
     avcodec_get_frame_defaults(&picture_pad_temp);
 
@@ -852,7 +864,18 @@
             ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
         else if (vdelta > 1.1)
             nb_frames = lrintf(vdelta);
-//fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, ost->sync_ipts, nb_frames);
+//fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, get_sync_ipts(ost), nb_frames);
+        if (nb_frames > 3) {
+            fprintf(stderr, "*** BONG! %d frames dup, vdelta = %f (method=%d) last_delta = %f, [%d, %I64d, %I64d, %I64d]\n", nb_frames, vdelta, video_sync_method, 1.0 * last_delta / 1000.0, ost->sync_ist->frame, ost->sync_ist->start, ost->sync_ist->pts, ost->sync_ist->next_pts);
+            exit(1);
+        }
+        if (nb_frames == 0 && ++frame_dropping > 3) {
+            fprintf(stderr, "*** BONG! %d frames drop, vdelta = %f (method=%d) last_delta = %f, [%d, %I64d, %I64d, %I64d]\n", nb_frames, vdelta, video_sync_method, 1.0 * last_delta / 1000.0, ost->sync_ist->frame, ost->sync_ist->start, ost->sync_ist->pts, ost->sync_ist->next_pts);
+            exit(1);
+        }  
+        if (nb_frames > 0)
+          frame_dropping = 0;
+      
         if (nb_frames == 0){
             ++nb_frames_drop;
             if (verbose>2)
@@ -869,14 +892,24 @@
     if (nb_frames <= 0)
         return;
 
+    if (subtitle_etch.num_rects && subtitle_etch_start <= ist->pts && ist->pts <= subtitle_etch_end) {
+        if (av_picture_harddup((AVPicture *)&picture_etching_temp, in_picture, dec->pix_fmt, dec->width, dec->height, &subtitle_etch) < 0) {
+              av_log(NULL, AV_LOG_ERROR, "error harddupping picture\n");
+              return;
+        }
+        etched_picture = &picture_etching_temp;
+    } else {
+        etched_picture = in_picture;
+    }
+
     if (ost->video_crop) {
-        if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
+        if (av_picture_crop((AVPicture *)&picture_crop_temp, etched_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
             av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
             return;
         }
         formatted_picture = &picture_crop_temp;
     } else {
-        formatted_picture = in_picture;
+        formatted_picture = etched_picture;
     }
 
     final_picture = formatted_picture;
@@ -1000,7 +1033,7 @@
 
     /* this is executed just the first time do_video_stats is called */
     if (!vstats_file) {
-        vstats_file = fopen(vstats_filename, "w");
+        vstats_file = av_fopen(vstats_filename, "w");
         if (!vstats_file) {
             perror("fopen");
             av_exit(1);
@@ -1044,13 +1077,13 @@
 
     if (!is_last_report) {
         int64_t cur_time;
-        /* display the report every 0.5 seconds */
+        /* display the report every 0.1 seconds */
         cur_time = av_gettime();
         if (last_time == -1) {
             last_time = cur_time;
             return;
         }
-        if ((cur_time - last_time) < 500000)
+        if ((cur_time - last_time) < 100000)
             return;
         last_time = cur_time;
     }
@@ -1230,6 +1263,9 @@
                     /* XXX: allocate picture correctly */
                     avcodec_get_frame_defaults(&picture);
 
+                    video_width = ist->st->codec->width;
+                    video_height = ist->st->codec->height;
+
                     ret = avcodec_decode_video(ist->st->codec,
                                                &picture, &got_picture, ptr, len);
                     ist->st->quality= picture.quality;
@@ -1247,14 +1283,166 @@
                     len = 0;
                     break;
             case CODEC_TYPE_SUBTITLE:
+
+                if (ist->st->id != subtitle_id)
+                  goto discard_packet;
+                
+                if (subtitle_etching) {
+                    if (subtitle_etch.rects != NULL) {
+                        for (i = 0; i < subtitle_etch.num_rects; i++) {
+                            av_free(subtitle_etch.rects[i].image);
+                            av_free(subtitle_etch.rects[i].bitmap);
+                            av_free(subtitle_etch.rects[i].rgba_palette);
+                        }
+                        av_freep(&subtitle_etch.rects);
+                    }
+                    subtitle_etch.num_rects = 0;
+
+                    /* initialize decoder if it wasn't initialized (no mapped stream) */
+                    if (!ist->st->codec->codec) {
+                        AVCodec *codec;
+                        codec = avcodec_find_decoder(ist->st->codec->codec_id);
+                        if (!codec) {
+                            fprintf(stderr, "Unsupported codec (id=%d) for input stream #%d.%d\n",
+                                    ist->st->codec->codec_id, ist->file_index, ist->index);
+                            av_exit(1);
+                        }
+                        if (avcodec_open(ist->st->codec, codec) < 0) {
+                            fprintf(stderr, "Error while opening codec for input stream #%d.%d\n",
+                                    ist->file_index, ist->index);
+                            av_exit(1);
+                        }
+                    }
+                }
+
                 ret = avcodec_decode_subtitle(ist->st->codec,
-                                              &subtitle, &got_subtitle, ptr, len);
+                                              &subtitle_etch, &got_subtitle, ptr, len);
+                subtitle = subtitle_etch;
+
                 if (ret < 0)
                     goto fail_decode;
                 if (!got_subtitle) {
                     goto discard_packet;
                 }
-                subtitle_to_free = &subtitle;
+
+                subtitle_etch_start = ist->pts + 1000 * subtitle_etch.start_display_time;
+                subtitle_etch_end   = ist->pts + 1000 * subtitle_etch.end_display_time;
+
+                if (verbose > 2)
+                    fprintf(stderr, "subtitle: base %"PRId64", start= %"PRId64", stop= %"PRId64"\n", ist->pts, subtitle_etch_start, subtitle_etch_end);
+
+                BOOL Shrink = TRUE;
+again:
+
+                if (!subtitle_etching)
+                    subtitle_to_free = &subtitle;  
+                else {
+                    INT i;
+                    INT l, t, r, b;
+                    INT cl, ct, cr, cb;
+                    INT dx, dy;
+                    double scale = 0;
+                    
+                    l = video_width;
+                    t = video_height;
+                    r = 0;
+                    b = 0;
+
+                    for (i = 0; i < subtitle_etch.num_rects; ++i) {
+                        AVSubtitleRect *rr = &subtitle_etch.rects[i];
+
+                        if (rr->x < l)
+                          l = rr->x;
+                        if (rr->y < t)
+                          t = rr->y;
+                        if (rr->x + rr->w > r)
+                          r = rr->x + rr->w;
+                        if (rr->y + rr->h > b)
+                          b = rr->y + rr->h;
+                    }
+
+                    cl = frame_leftBand + 15;
+                    ct = frame_topBand + 15;
+                    cr = video_width - frame_rightBand - 15;
+                    cb = video_height - frame_bottomBand - 15;
+
+                    dx = 0;
+                    dy = 0;
+
+                    if (l < cl)
+                      dx = cl - l;
+                    if (r > cr)
+                      if (!dx) dx = cr - r; // else scale = 1.0 * (cr - cl) / (r - l);
+                    if (t < ct)
+                      dy = ct - t;
+                    if (b > cb)
+                      if (!dy) dy = cb - b;
+
+                    if (Shrink)
+                    {
+                      INT crop = frame_leftBand + frame_rightBand;
+
+                      scale = 1.0 * (video_width - crop) / video_width;
+                    }
+
+                    if (scale && scale < 1 && subtitle_etch.num_rects == 1) {
+                      
+                      for (i = 0; i < subtitle_etch.num_rects; ++i) {
+                          AVSubtitleRect *rr = &subtitle_etch.rects[i];
+                          
+                          INT x, y;
+                          INT nw = (INT)(rr->w * scale + 0.5);
+                          INT nh = (INT)(rr->h * scale + 0.5); 
+
+                          rr->image = av_malloc(nw * nh * 4);
+
+                          for (y = 0; y < nh; y++) {
+                              for (x = 0; x < nw; x++) {
+                                double ix = x / scale;
+                                double iy = y / scale;
+                                double px = 1 - (ix - (INT) ix);
+                                double py = 1 - (iy - (INT) iy);
+
+                                INT ix1 = (INT) ix;     if (ix1 >= rr->w) px = 1, ix1 = rr->w - 1;
+                                INT ix2 = (INT) ix + 1; if (ix2 >= rr->w) px = 1, ix2 = rr->w - 1;
+                                INT iy1 = (INT) iy;     if (iy1 >= rr->h) py = 1, iy1 = rr->h - 1;
+                                INT iy2 = (INT) iy + 1; if (iy2 >= rr->h) py = 1, iy2 = rr->h - 1;
+
+                                INT vx1y1 = rr->rgba_palette[rr->bitmap[iy1 * rr->linesize + ix1]];
+                                INT vx2y1 = rr->rgba_palette[rr->bitmap[iy1 * rr->linesize + ix2]];
+                                INT vx1y2 = rr->rgba_palette[rr->bitmap[iy2 * rr->linesize + ix1]];
+                                INT vx2y2 = rr->rgba_palette[rr->bitmap[iy2 * rr->linesize + ix2]];
+
+                                INT ccA = (INT)( (vx1y1 >> 24 & 0xFF) * px * py + (vx2y1 >> 24 & 0xFF) * (1 - px) * py + (vx1y2 >> 24 & 0xFF) * px * (1 - py) + (vx2y2 >> 24 & 0xFF) * (1 - px) * (1 - py) + 0.5 ) ;
+                                INT ccY = (INT)( (vx1y1 >> 16 & 0xFF) * px * py + (vx2y1 >> 16 & 0xFF) * (1 - px) * py + (vx1y2 >> 16 & 0xFF) * px * (1 - py) + (vx2y2 >> 16 & 0xFF) * (1 - px) * (1 - py) + 0.5 ) ;
+                                INT ccU = (INT)( (vx1y1 >>  8 & 0xFF) * px * py + (vx2y1 >>  8 & 0xFF) * (1 - px) * py + (vx1y2 >>  8 & 0xFF) * px * (1 - py) + (vx2y2 >>  8 & 0xFF) * (1 - px) * (1 - py) + 0.5 ) ;
+                                INT ccV = (INT)( (vx1y1 >>  0 & 0xFF) * px * py + (vx2y1 >>  0 & 0xFF) * (1 - px) * py + (vx1y2 >>  0 & 0xFF) * px * (1 - py) + (vx2y2 >>  0 & 0xFF) * (1 - px) * (1 - py) + 0.5 ) ;
+
+                                INT cc  = ccA << 24 | ccY << 16 | ccU << 8 | ccV;
+
+                                rr->image[y * nw + x] = cc;
+                              }
+                          }
+
+                          rr->linesize = nw;
+                          rr->x += (rr->w - nw) / 2;
+                          rr->y += (rr->h - nh) / 2;
+                          rr->w = nw;
+                          rr->h = nh;
+                      } 
+                      
+                      Shrink = FALSE;
+                      goto again;
+                    }
+
+                    for (i = 0; i < subtitle_etch.num_rects; ++i) {
+                        AVSubtitleRect *rr = &subtitle_etch.rects[i];
+
+                        rr->x += dx;
+                        rr->y += dy;
+                    } 
+                }
+
                 len = 0;
                 break;
             default:
@@ -1844,11 +2032,17 @@
                 int size;
                 char *logbuffer;
 
+                snprintf(logfilename, sizeof(logfilename), "%s-%d-enc.log",
+                         pass_logfilename ?
+                         pass_logfilename : DEFAULT_PASS_LOGFILENAME, i);
+
+                codec->encoder_stage_log = av_strdup(logfilename);
+                
                 snprintf(logfilename, sizeof(logfilename), "%s-%d.log",
                          pass_logfilename ?
                          pass_logfilename : DEFAULT_PASS_LOGFILENAME, i);
                 if (codec->flags & CODEC_FLAG_PASS1) {
-                    f = fopen(logfilename, "w");
+                    f = av_fopen(logfilename, "w");
                     if (!f) {
                         perror(logfilename);
                         av_exit(1);
@@ -1856,7 +2050,7 @@
                     ost->logfile = f;
                 } else {
                     /* read the log file */
-                    f = fopen(logfilename, "r");
+                    f = av_fopen(logfilename, "r");
                     if (!f) {
                         perror(logfilename);
                         av_exit(1);
@@ -2096,6 +2290,11 @@
             goto discard_packet;
         ist_index = file_table[file_index].ist_index + pkt.stream_index;
         ist = ist_table[ist_index];
+
+        if (subtitle_etching && ist->st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
+            if (ist->discard && !ist->decoding_needed) ist->discard = 0, ist->decoding_needed = 1;
+        }
+
         if (ist->discard)
             goto discard_packet;
 
@@ -2115,13 +2314,35 @@
         if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE) {
             int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
             int64_t delta= pkt_dts - ist->next_pts;
-            if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){
+            
+            if (FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE && FFABS(pkt_dts - (ist->next_pts + last_delta)) <= 1LL*dts_delta_threshold*AV_TIME_BASE) {
+                ist->next_pts += last_delta, delta= pkt_dts - ist->next_pts; // this packet is still on old clock (delayed audio)
+
+                if (verbose > 2)
+                    fprintf(stderr, "clock of packet is still on old timing\n");
+            }
+
+            if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts && delta){
                 input_files_ts_offset[ist->file_index]-= delta;
+                last_delta = delta;
                 if (verbose > 2)
-                    fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]);
+                    fprintf(stderr, "timestamp discontinuity [%d] %"PRId64", new offset= %"PRId64", clock delta= %"PRId64"\n", pkt.stream_index, delta, input_files_ts_offset[ist->file_index], last_delta);
                 pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
                 if(pkt.pts != AV_NOPTS_VALUE)
                     pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
+
+                // now we have to fix ALL next_pts values OR we flip delta every new packet type
+                for (i = 0 ; i < file_table[file_index].nb_streams ; ++i)
+                {
+                  int istp_index;
+                  AVInputStream *istp;
+
+                  istp_index = file_table[file_index].ist_index + i;
+                  istp = ist_table[istp_index];
+
+                  if (istp->next_pts != AV_NOPTS_VALUE)
+                      istp->next_pts -= delta;        
+                }  
             }
         }
 
@@ -2136,6 +2357,10 @@
             goto redo;
         }
 
+        /* don't accept next_pts from non-video/audio - they don't have that information */
+        if (ist->st->codec->codec_type != CODEC_TYPE_VIDEO && ist->st->codec->codec_type != CODEC_TYPE_AUDIO)
+          ist->next_pts = AV_NOPTS_VALUE;
+
     discard_packet:
         av_free_packet(&pkt);
 
@@ -2673,6 +2898,56 @@
     opt_codec(&subtitle_stream_copy, &subtitle_codec_name, CODEC_TYPE_SUBTITLE, arg);
 }
 
+static void opt_subtitle_palette(const char *arg)
+{
+    FILE *ifo_file;
+    size_t ifo_size;
+    uint8_t *ifo;
+    int vts_pgcit, pgcs, pgc;
+    
+    ifo_file = av_fopen(arg, "rb");
+    if (!ifo_file) return;
+
+    fseek(ifo_file, 0, FILE_END);
+    ifo_size = ftell(ifo_file);
+    ifo = av_malloc(ifo_size);
+
+    fseek(ifo_file, 0, FILE_BEGIN);
+    fread(ifo, 1, ifo_size, ifo_file);
+    fclose(ifo_file);
+
+    if (memcmp(ifo, "DVDVIDEO-VTS", 12) != 0)
+      goto quit;
+
+    vts_pgcit = (ifo[0xcc] << 24 | ifo[0xcd] << 16 | ifo[0xce] << 8 | ifo[0xcf]) * 2048;
+    if (!vts_pgcit) goto quit; 
+    
+    pgcs = ifo[vts_pgcit + 0] << 8 | ifo[vts_pgcit + 1];
+    for (pgc = 0; pgc < pgcs; ++pgc) {
+        int pgc_start, pal_start;
+        int empty, i, yuv;
+        
+        pgc_start = vts_pgcit + (ifo[vts_pgcit + 8 + 8 * pgc + 4] << 24 | ifo[vts_pgcit + 8 + 8 * pgc + 5] << 16 | ifo[vts_pgcit + 8 + 8 * pgc + 6] << 8 | ifo[vts_pgcit + 8 + 8 * pgc + 7]);
+        pal_start = pgc_start + 0xA5;
+
+        empty = 1;
+        for (i = 0; empty && i < 16 * 4; ++i) empty = ifo[pal_start + i] == 0;
+
+        if (!empty) {
+            for (i = 0; i < 16; ++i) {
+                yuv = ifo[pal_start + i * 4 + 0] << 16 | ifo[pal_start + i * 4 + 1] << 8 | ifo[pal_start + i * 4 + 2];
+                subtitle_etch.palette[i] = yuv;
+            }
+
+            subtitle_etch.have_palette = 1;
+            break;
+        }
+    }
+
+quit:
+    av_free(ifo);
+}
+
 static void opt_map(const char *arg)
 {
     AVStreamMap *m;
@@ -2780,6 +3055,14 @@
         char buf[256];
         const AVOption *opt;
         const char *str= av_get_string(opts_ctx, opt_names[i], &opt, buf, sizeof(buf));
+
+        /* bug/workaround: av_get_string returns FF_OPT_TYPE_FLAGS as hex which av_set_string2 can't process */
+        if (str && opt->type == FF_OPT_TYPE_FLAGS && strncmp(str, "0x00", 4) == 0)
+        {
+          long val = strtol(str + 2, NULL, 16); 
+          str = itoa(val, buf, 10);
+        }
+
         /* if an option with name opt_names[i] is present in opts_ctx then str is non-NULL */
         if(str && ((opt->flags & flags) == flags))
             av_set_string2(ctx, opt_names[i], str, 1);
@@ -2924,6 +3207,27 @@
         }
     }
 
+    // always append subtitle stream
+    if (subtitle_id) {
+        AVStream *st;
+
+        for(i=0;i<ic->nb_streams;i++) {
+            st = ic->streams[i];
+            if (st->id == subtitle_id)
+                goto found;
+        }
+
+        st = av_new_stream(ic, subtitle_id);
+        if (st) {
+            st->codec->codec_type = CODEC_TYPE_SUBTITLE;
+            st->codec->codec_id = CODEC_ID_DVD_SUBTITLE;
+            st->need_parsing = AVSTREAM_PARSE_FULL;
+        }
+
+found:
+        ;
+    }
+
     input_files[nb_input_files] = ic;
     input_files_ts_offset[nb_input_files] = input_ts_offset - (copy_ts ? 0 : timestamp);
     /* dump the file content */
@@ -3114,8 +3418,10 @@
         if (do_pass) {
             if (do_pass == 1) {
                 video_enc->flags |= CODEC_FLAG_PASS1;
+            } else if (do_pass == 2) {
+                video_enc->flags |= CODEC_FLAG_PASS2;
             } else {
-                video_enc->flags |= CODEC_FLAG_PASS2;
+                video_enc->flags |= CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2;
             }
         }
     }
@@ -3424,8 +3730,8 @@
 {
     int pass;
     pass = atoi(pass_str);
-    if (pass != 1 && pass != 2) {
-        fprintf(stderr, "pass number can be only 1 or 2\n");
+    if (pass != 1 && pass != 2 && pass != 3) {
+        fprintf(stderr, "pass number can be only 1, 2 or 3\n");
         av_exit(1);
     }
     do_pass = pass;
@@ -3487,8 +3793,18 @@
     vfprintf(stdout, fmt, vl);
 }
 
+#include "build_clonedvd\appinfo.h"
+#include "libextern\libx264\x264\libinfo.h"
+
 static void show_help(void)
 {
+    printf("NOTICE: Program cannot be called directly. No parameter information given.\n\n");
+    printf("        Compiled on " FFMPEG_NOW " by gcc " __VERSION__ "\n");
+    printf("          with ffmpeg revision " FFMPEG_REV " from " FFMPEG_REV_DATE "\n");
+    printf("          with x264   revision " LIBX264_REV "   from " LIBX264_REV_DATE "\n");
+    printf("                      featuring " LIBX264_NOTE "\n");
+    return;
+
     av_log_set_callback(log_callback_help);
     printf("usage: ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...\n"
            "Hyper fast Audio and Video encoder\n");
@@ -3588,7 +3904,7 @@
 
         opt_frame_size(norm ? "352x240" : "352x288");
         opt_frame_rate(frame_rates[norm]);
-        opt_default("gop", norm ? "18" : "15");
+        opt_default("g", norm ? "18" : "15");
 
         opt_default("b", "1150000");
         opt_default("maxrate", "1150000");
@@ -3616,7 +3932,7 @@
 
         opt_frame_size(norm ? "480x480" : "480x576");
         opt_frame_rate(frame_rates[norm]);
-        opt_default("gop", norm ? "18" : "15");
+        opt_default("g", norm ? "18" : "15");
 
         opt_default("b", "2040000");
         opt_default("maxrate", "2516000");
@@ -3638,7 +3954,7 @@
 
         opt_frame_size(norm ? "720x480" : "720x576");
         opt_frame_rate(frame_rates[norm]);
-        opt_default("gop", norm ? "18" : "15");
+        opt_default("g", norm ? "18" : "15");
 
         opt_default("b", "6000000");
         opt_default("maxrate", "9000000");
@@ -3719,13 +4035,13 @@
 
     for(i=!base[0]; i<3 && !f; i++){
         snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);
-        f= fopen(tmp, "r");
+        f= av_fopen(tmp, "r");
         if(!f){
             char *codec_name= *opt == 'v' ? video_codec_name :
                               *opt == 'a' ? audio_codec_name :
                                             subtitle_codec_name;
               snprintf(tmp, sizeof(tmp), "%s/%sffmpeg/%s-%s.ffpreset", base[i],  i ? "" : ".", codec_name, arg);
-            f= fopen(tmp, "r");
+            f= av_fopen(tmp, "r");
         }
     }
 
@@ -3863,6 +4179,9 @@
     { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" },
     { "newsubtitle", OPT_SUBTITLE, {(void*)opt_new_subtitle_stream}, "add a new subtitle stream to the current output stream" },
     { "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language}, "set the ISO 639 language code (3 letters) of the current subtitle stream" , "code" },
+    { "se", OPT_BOOL | OPT_SUBTITLE, {(void*)&subtitle_etching}, "subtitle etching" },
+    { "sid", HAS_ARG | OPT_INT | OPT_SUBTITLE, {(void*)&subtitle_id}, "subtitle identifer (0x20..0x3F)" },
+    { "spal", HAS_ARG | OPT_SUBTITLE, {(void*)&opt_subtitle_palette}, "subtitle palette (from .ifo file)" },
 
     /* grab options */
     { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "set video grab channel (DV1394 only)", "channel" },
@@ -3890,6 +4209,52 @@
     int i;
     int64_t ti;
 
+    /* load parameters by UNICODE and then convert them to UTF-8
+     * linux normally initiates parameters as UTF-8, windows has UNICODE, so sync them
+     */
+    {
+        WCHAR *CommandLineW = GetCommandLineW(); 
+        CHAR   CommandLineA[2048]; 
+        
+        CHAR *PR = CommandLineA, *PW = PR, *PP[256]; INT PPN = 0; BOOL InEscape = FALSE; PP[PPN++] = PW;
+
+        WideCharToMultiByte(CP_UTF8, 0, CommandLineW, -1, CommandLineA, sizeof(CommandLineA), NULL, NULL);        
+
+        while (*PR) {
+
+            if (*PR == '\\' && PR[1] == '\\')
+                *PW++ = '\\', PR++;
+            
+            else if (*PR == '\\' && PR[1] == '"')
+                *PW++ = '"', PR++;
+
+            else if (*PR == '"') 
+                InEscape = !InEscape;
+            
+            else if (*PR == ' ' && !InEscape) {
+                *PW++ = 0, PP[PPN++] = PW;
+
+                if (PPN >= sizeof(PP) / sizeof(PP[0])) 
+                    return av_exit(1);
+            }
+
+            else
+                *PW++ = *PR;
+
+            PR++;
+        }
+
+        *PW = 0;
+
+        argc = PPN;
+        argv = PP;
+    }
+
+    /* those pthread-"be"holes don't check for initialized crit_sects nor do they call it themselves. 
+     * it should be pthreads responsibilty to check for a proper environment, not ours!!!
+     */
+    pthread_win32_process_attach_np();
+
     avcodec_register_all();
     avdevice_register_all();
     av_register_all();
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h	(revision 14819)
+++ libavcodec/avcodec.h	(working copy)
@@ -1429,6 +1429,20 @@
 #define FF_PRED_PLANE  1
 #define FF_PRED_MEDIAN 2
 
+     /**
+     * enhanced encoder configuration (for x264)
+     * - encoding: Set by user.
+     * - decoding: unused
+     */
+     char *encoder_cfg;
+
+     /**
+     * enhanced encoder staging file (for x264)
+     * - encoding: Set by user.
+     * - decoding: unused
+     */
+     char *encoder_stage_log;
+
     /**
      * sample aspect ratio (0 if unknown)
      * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
@@ -2311,6 +2325,7 @@
     int linesize;
     uint32_t *rgba_palette;
     uint8_t *bitmap;
+    uint32_t *image;
 } AVSubtitleRect;
 
 typedef struct AVSubtitle {
@@ -2319,6 +2334,8 @@
     uint32_t end_display_time; /* relative to packet pts, in ms */
     uint32_t num_rects;
     AVSubtitleRect *rects;
+    int have_palette;
+    uint32_t palette[16];
 } AVSubtitle;
 
 
@@ -2965,6 +2982,12 @@
 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
             int padtop, int padbottom, int padleft, int padright, int *color);
 
+/**
+ * Harddup image.
+ */
+int av_picture_harddup(AVPicture *dst, const AVPicture *src, int pix_fmt, int width, int height, 
+            const AVSubtitle *subtitle);
+
 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
 /**
  * @deprecated Use the software scaler (swscale) instead.
Index: libavcodec/dvdsubdec.c
===================================================================
--- libavcodec/dvdsubdec.c	(revision 14819)
+++ libavcodec/dvdsubdec.c	(working copy)
@@ -158,6 +158,20 @@
     }
 }
 
+static void have_palette(uint32_t *rgba_palette,
+                         uint8_t *colormap,
+                         uint8_t *alpha,
+                         uint32_t *palette)
+{
+    int i, a, c;
+
+    for (i = 0; i < 4; i++) {
+        a = alpha[i];
+        c = palette[colormap[i]];
+        rgba_palette[i] = (c & 0x00ffffff) | ((a * 17) << 24);
+    }
+}
+
 #define READ_OFFSET(a) (big_offsets ? AV_RB32(a) : AV_RB16(a))
 
 static int decode_dvd_subtitles(AVSubtitle *sub_header,
@@ -313,7 +327,7 @@
             w = x2 - x1 + 1;
             if (w < 0)
                 w = 0;
-            h = y2 - y1;
+            h = y2 - y1 + 1;
             if (h < 0)
                 h = 0;
             if (w > 0 && h > 0) {
@@ -343,8 +357,12 @@
                 } else {
                     sub_header->rects[0].rgba_palette = av_malloc(4 * 4);
                     sub_header->rects[0].nb_colors = 4;
-                    guess_palette(sub_header->rects[0].rgba_palette,
-                                  colormap, alpha, 0xffff00);
+                    if (sub_header->have_palette)
+                        have_palette(sub_header->rects[0].rgba_palette,
+                                     colormap, alpha, sub_header->palette);
+                    else
+                        guess_palette(sub_header->rects[0].rgba_palette,
+                                      colormap, alpha, 0xffff00);
                 }
                 sub_header->rects[0].x = x1;
                 sub_header->rects[0].y = y1;
Index: libavcodec/i386/fft_mmx.asm
===================================================================
--- libavcodec/i386/fft_mmx.asm	(revision 14819)
+++ libavcodec/i386/fft_mmx.asm	(working copy)
@@ -27,7 +27,7 @@
 %include "x86inc.asm"
 
 SECTION_RODATA
-
+                                                    
 %define M_SQRT1_2 0.70710678118654752440
 ps_root2: times 4 dd M_SQRT1_2
 ps_root2mppm: dd -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
@@ -129,9 +129,9 @@
 %macro PASS_SMALL 3 ; (to load m4-m7), wre, wim
 IF%1 mova    m4, Z(4)
 IF%1 mova    m5, Z(5)
-    mova     m0, %2 ; wre
+    movu     m0, %2 ; wre
     mova     m2, m4
-    mova     m1, %3 ; wim
+    movu     m1, %3 ; wim
     mova     m3, m5
     mulps    m2, m0 ; r2*wre
 IF%1 mova    m6, Z(6)
@@ -184,9 +184,9 @@
     mova     m4, Z(4) ; r2
     mova     m5, Z(5) ; i2
     mova     m2, m4
-    mova     m0, [wq] ; wre
+    movu     m0, [wq] ; wre
     mova     m3, m5
-    mova     m1, [wq+o1q] ; wim
+    movu     m1, [wq+o1q] ; wim
     mulps    m2, m0 ; r2*wre
     mova     m6, Z(6) ; r3
     mulps    m3, m1 ; i2*wim
Index: libavcodec/imgconvert.c
===================================================================
--- libavcodec/imgconvert.c	(revision 14819)
+++ libavcodec/imgconvert.c	(working copy)
@@ -427,6 +427,8 @@
     }
 }
 
+#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
+
 int ff_fill_linesize(AVPicture *picture, int pix_fmt, int width)
 {
     int w2;
@@ -446,6 +448,7 @@
     case PIX_FMT_YUVJ422P:
     case PIX_FMT_YUVJ444P:
     case PIX_FMT_YUVJ440P:
+        width = ALIGN(width, 64);
         w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
         picture->linesize[0] = width;
         picture->linesize[1] = w2;
@@ -2005,6 +2008,65 @@
         ps->pixel_type == FF_PIXEL_PLANAR;
 }
 
+static AVPicture temp_harddup;
+
+int av_picture_harddup(AVPicture *dst, const AVPicture *src, int pix_fmt, int width, int height, const AVSubtitle *subtitle)
+{
+    uint8_t *optr;
+    int y_shift;
+    int x_shift;
+    int i, j, h, w, y, x, dy, dx;
+    int cc, c;    
+    double a;
+    uint32_t v;
+
+    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB ||
+        !is_yuv_planar(&pix_fmt_info[pix_fmt])) return -1;
+
+    if (!temp_harddup.data[0])
+      avpicture_alloc(&temp_harddup, pix_fmt, width, height);
+
+    dst->data[0] = temp_harddup.data[0];
+    dst->data[1] = temp_harddup.data[1];
+    dst->data[2] = temp_harddup.data[2];
+
+    dst->linesize[0] = temp_harddup.linesize[0];
+    dst->linesize[1] = temp_harddup.linesize[1];
+    dst->linesize[2] = temp_harddup.linesize[2];
+
+    av_picture_copy(dst, src, pix_fmt, width, height);
+    
+    for (i = 0; i < 3; i++) {
+        x_shift = i ? pix_fmt_info[pix_fmt].x_chroma_shift : 0;
+        y_shift = i ? pix_fmt_info[pix_fmt].y_chroma_shift : 0;
+
+        for (j = 0; j < subtitle->num_rects; ++j) {
+            AVSubtitleRect *r = &subtitle->rects[j];
+
+            optr = dst->data[i] + dst->linesize[i] * (r->y >> y_shift) + (r->x >> x_shift);
+
+            dy = 1 << y_shift;
+            dx = 1 << x_shift;                        
+            h  = r->h;
+            w  = r->w;
+            cc = 16 - i * 8; 
+
+            for (y = 0; y < h; y += dy) {
+                for (x = 0; x < w; x += dx) {
+                    v = r->image ? r->image[y * r->linesize + x] : r->rgba_palette[r->bitmap[y * r->linesize + x]];
+                    if (v & 0xFF000000) {
+                        a = 1.0 / 255.0 * (v >> 24);
+                        c = (v >> cc) & 0xff;
+                        optr[x >> x_shift] = av_clip((int)((1 - a) * optr[x >> x_shift] + a * c), 0, 255);
+                    }
+                }
+                optr += dst->linesize[i]; 
+            }
+        }         
+    }
+    return 0;
+}
+
 int av_picture_crop(AVPicture *dst, const AVPicture *src,
               int pix_fmt, int top_band, int left_band)
 {
Index: libavcodec/libx264.c
===================================================================
--- libavcodec/libx264.c	(revision 14819)
+++ libavcodec/libx264.c	(working copy)
@@ -253,7 +253,7 @@
     x4->params.rc.f_ip_factor = 1/fabs(avctx->i_quant_factor);
     x4->params.rc.f_pb_factor = avctx->b_quant_factor;
     x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
-    x4->params.rc.psz_rc_eq = avctx->rc_eq;
+    if (avctx->rc_eq) x4->params.rc.psz_rc_eq = avctx->rc_eq;
 
     x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
     x4->params.i_log_level = X264_LOG_DEBUG;
@@ -268,6 +268,30 @@
         x4->params.b_repeat_headers = 0;
     }
 
+    if (avctx->encoder_stage_log) {
+        x4->params.rc.psz_stat_in  = avctx->encoder_stage_log;
+        x4->params.rc.psz_stat_out = avctx->encoder_stage_log;
+    }
+
+    if (avctx->encoder_cfg) {
+        char *P = avctx->encoder_cfg, *V, *N; int Last = 0;
+
+        while (!Last) {
+            N = strchr(P, '|');
+            V = strchr(P, '='); 
+
+            if (!N) N = P + strlen(P), Last = 1;
+            if (V > N) V = NULL;
+
+            *N = 0; if (V) *V++ = 0;
+
+            if (x264_param_parse(&x4->params, P, V))
+              return -1;
+
+            P = N + 1;
+        }
+    }
+
     x4->enc = x264_encoder_open(&x4->params);
     if(!x4->enc)
         return -1;
Index: libavcodec/mpegvideo.c
===================================================================
--- libavcodec/mpegvideo.c	(revision 14819)
+++ libavcodec/mpegvideo.c	(working copy)
@@ -671,6 +671,30 @@
     avcodec_default_free_buffers(s->avctx);
 }
 
+AVFrame *MPV_get_current_picture(AVCodecContext *avctx)
+{
+   MpegEncContext *s = avctx->priv_data;
+
+   /* current_picture_ptr is of type Picture* with is derived from AVFrame* [FF_COMMON_FRAME] */
+   return (AVFrame *) s->current_picture_ptr;
+}
+
+AVFrame *MPV_get_next_picture(AVCodecContext *avctx)
+{
+   MpegEncContext *s = avctx->priv_data;
+
+   /* next_picture_ptr is of type Picture* with is derived from AVFrame* [FF_COMMON_FRAME] */
+   return (AVFrame *) s->next_picture_ptr;
+}
+
+AVFrame *MPV_get_last_picture(AVCodecContext *avctx)
+{
+   MpegEncContext *s = avctx->priv_data;
+
+   /* last_picture_ptr is of type Picture* with is derived from AVFrame* [FF_COMMON_FRAME] */
+   return (AVFrame *) s->last_picture_ptr;
+}
+
 void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3])
 {
     int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
Index: libavcodec/mpegvideo.h
===================================================================
--- libavcodec/mpegvideo.h	(revision 14819)
+++ libavcodec/mpegvideo.h	(working copy)
@@ -669,6 +669,9 @@
 void MPV_decode_defaults(MpegEncContext *s);
 int MPV_common_init(MpegEncContext *s);
 void MPV_common_end(MpegEncContext *s);
+AVFrame *MPV_get_current_picture(AVCodecContext *avctx);
+AVFrame *MPV_get_next_picture(AVCodecContext *avctx);
+AVFrame *MPV_get_last_picture(AVCodecContext *avctx);
 void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]);
 int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx);
 void MPV_frame_end(MpegEncContext *s);
Index: libavcodec/mpegvideo_enc.c
===================================================================
--- libavcodec/mpegvideo_enc.c	(revision 14819)
+++ libavcodec/mpegvideo_enc.c	(working copy)
@@ -464,8 +464,12 @@
     if(s->avctx->thread_count > 1 && s->codec_id != CODEC_ID_MPEG4
        && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO
        && (s->codec_id != CODEC_ID_H263P || !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT))){
+#if VETO_MULTITHREADED
         av_log(avctx, AV_LOG_ERROR, "multi threaded encoding not supported by codec\n");
         return -1;
+#else   
+        s->avctx->thread_count = 1;
+#endif
     }
 
     if(s->avctx->thread_count > 1)
Index: libavcodec/utils.c
===================================================================
--- libavcodec/utils.c	(revision 14819)
+++ libavcodec/utils.c	(working copy)
@@ -522,6 +522,7 @@
 {"rc_qmod_freq", "experimental quantizer modulation", OFFSET(rc_qmod_freq), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
 {"rc_override_count", NULL, OFFSET(rc_override_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
 {"rc_eq", "set rate control equation", OFFSET(rc_eq), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E},
+{"encoder_cfg", "set encoder configuarion", OFFSET(encoder_cfg), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E},
 {"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
 {"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
 {"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|V|E},
@@ -989,7 +990,7 @@
 
     if (ENABLE_THREADS && avctx->thread_opaque)
         avcodec_thread_free(avctx);
-    if (avctx->codec->close)
+    if (avctx->codec && avctx->codec->close) // subtitle decoder without subs are not opened
         avctx->codec->close(avctx);
     avcodec_default_free_buffers(avctx);
     av_freep(&avctx->priv_data);
@@ -1373,7 +1374,7 @@
         return -1;
     }
 #if !defined(HAVE_MKSTEMP)
-    fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
+    fd = av_open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
 #else
     snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
     fd = mkstemp(*filename);
Index: libavformat/avformat.h
===================================================================
--- libavformat/avformat.h	(revision 14819)
+++ libavformat/avformat.h	(working copy)
@@ -34,6 +34,7 @@
 #define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
 
 #define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
+#define LIBAVFORMAT_IDENT_EX    "CloneDVD mobile 2.0.0.0 (using FFmpeg)"
 
 /**
  * Returns the LIBAVFORMAT_VERSION_INT constant.
@@ -508,6 +509,8 @@
 #define AVFMT_FLAG_GENPTS       0x0001 ///< generate pts if missing even if it requires parsing future frames
 #define AVFMT_FLAG_IGNIDX       0x0002 ///< ignore index
 #define AVFMT_FLAG_NONBLOCK     0x0004 ///< do not block when reading packets from input
+#define AVFMT_FLAG_NOODML       0x1000 ///< do not create odml avi files (avi muxer)
+#define AVFMT_FLAG_NOINFO       0x2000 ///< do not create info/vprp data in avi files (avi muxer)
 
     int loop_input;
     /** decoding: size of data to probe; encoding unused */
Index: libavformat/avienc.c
===================================================================
--- libavformat/avienc.c	(revision 14819)
+++ libavformat/avienc.c	(working copy)
@@ -152,6 +152,14 @@
     put_le32(pb, 14 * 4);
     bitrate = 0;
 
+    //if (s->flags & AVFMT_FLAG_NOODML)
+    //    s->flags |= AVFMT_FLAG_NOINFO;
+
+    if (s->flags & AVFMT_FLAG_NOODML)
+        av_log(s, AV_LOG_INFO, "switching to no-odml mode\n");
+    if (s->flags & AVFMT_FLAG_NOINFO)
+        av_log(s, AV_LOG_INFO, "switching to non-info/vprp data store mode\n");
+
     video_enc = NULL;
     for(n=0;n<s->nb_streams;n++) {
         stream = s->streams[n]->codec;
@@ -259,7 +267,7 @@
         end_tag(pb, strf);
       }
 
-        if (!url_is_streamed(pb)) {
+        if (!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_NOODML)) {
             unsigned char tag[5];
             int j;
 
@@ -283,7 +291,7 @@
             end_tag(pb, avi->indexes[i].indx_start);
         }
 
-        if(   stream->codec_type == CODEC_TYPE_VIDEO
+        if(   stream->codec_type == CODEC_TYPE_VIDEO && !(s->flags & AVFMT_FLAG_NOINFO)
            && stream->sample_aspect_ratio.num>0
            && stream->sample_aspect_ratio.den>0){
             int vprp= start_tag(pb, "vprp");
@@ -318,7 +326,7 @@
         end_tag(pb, list2);
     }
 
-    if (!url_is_streamed(pb)) {
+    if (!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_NOODML)) {
         /* AVI could become an OpenDML one, if it grows beyond 2Gb range */
         avi->odml_list = start_tag(pb, "JUNK");
         put_tag(pb, "odml");
@@ -331,22 +339,24 @@
 
     end_tag(pb, list1);
 
-    list2 = start_tag(pb, "LIST");
-    put_tag(pb, "INFO");
-    avi_write_info_tag(pb, "INAM", s->title);
-    avi_write_info_tag(pb, "IART", s->author);
-    avi_write_info_tag(pb, "ICOP", s->copyright);
-    avi_write_info_tag(pb, "ICMT", s->comment);
-    avi_write_info_tag(pb, "IPRD", s->album);
-    avi_write_info_tag(pb, "IGNR", s->genre);
-    if (s->track) {
-        char str_track[4];
-        snprintf(str_track, 4, "%d", s->track);
-        avi_write_info_tag(pb, "IPRT", str_track);
+    if (!(s->flags & AVFMT_FLAG_NOINFO)) {
+      list2 = start_tag(pb, "LIST");
+      put_tag(pb, "INFO");
+      avi_write_info_tag(pb, "INAM", s->title);
+      avi_write_info_tag(pb, "IART", s->author);
+      avi_write_info_tag(pb, "ICOP", s->copyright);
+      avi_write_info_tag(pb, "ICMT", s->comment);
+      avi_write_info_tag(pb, "IPRD", s->album);
+      avi_write_info_tag(pb, "IGNR", s->genre);
+      if (s->track) {
+          char str_track[4];
+          snprintf(str_track, 4, "%d", s->track);
+          avi_write_info_tag(pb, "IPRT", str_track);
+      }
+      if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
+          avi_write_info_tag(pb, "ISFT", LIBAVFORMAT_IDENT_EX);
+      end_tag(pb, list2);
     }
-    if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
-        avi_write_info_tag(pb, "ISFT", LIBAVFORMAT_IDENT);
-    end_tag(pb, list2);
 
     /* some padding for easier tag editing */
     list2 = start_tag(pb, "JUNK");
@@ -370,7 +380,7 @@
     char ix_tag[] = "ix00";
     int i, j;
 
-    assert(!url_is_streamed(pb));
+    assert(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_NOODML));
 
     if (avi->riff_id > AVI_MASTER_INDEX_SIZE)
         return -1;
@@ -488,7 +498,7 @@
     avi->packet_count[stream_index]++;
 
     // Make sure to put an OpenDML chunk when the file size exceeds the limits
-    if (!url_is_streamed(pb) &&
+    if (!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_NOODML) &&
         (url_ftell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) {
 
         avi_write_ix(s);
@@ -551,7 +561,7 @@
             end_tag(pb, avi->movi_list);
             res = avi_write_idx1(s);
             end_tag(pb, avi->riff_start);
-        } else {
+        } else if (!(s->flags & AVFMT_FLAG_NOODML)) {
             avi_write_ix(s);
             end_tag(pb, avi->movi_list);
             end_tag(pb, avi->riff_start);
Index: libavformat/file.c
===================================================================
--- libavformat/file.c	(revision 14819)
+++ libavformat/file.c	(working copy)
@@ -47,7 +47,7 @@
 #ifdef O_BINARY
     access |= O_BINARY;
 #endif
-    fd = open(filename, access, 0666);
+    fd = av_open(filename, access, 0666);
     if (fd < 0)
         return AVERROR(ENOENT);
     h->priv_data = (void *)(size_t)fd;
Index: libavformat/matroskaenc.c
===================================================================
--- libavformat/matroskaenc.c	(revision 14819)
+++ libavformat/matroskaenc.c	(working copy)
@@ -679,8 +679,8 @@
     if (strlen(s->title))
         put_ebml_string(pb, MATROSKA_ID_TITLE, s->title);
     if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
-        put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , LIBAVFORMAT_IDENT);
-        put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT);
+        put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , LIBAVFORMAT_IDENT_EX);
+        put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT_EX);
 
         // reserve space to write the segment UID later
         mkv->segment_uid = url_ftell(pb);
Index: libavformat/movenc.c
===================================================================
--- libavformat/movenc.c	(revision 14819)
+++ libavformat/movenc.c	(working copy)
@@ -1162,7 +1162,7 @@
     mov_write_string_tag(pb, "\251wrt", s->author        , 1);
     mov_write_string_tag(pb, "\251alb", s->album         , 1);
     mov_write_day_tag(pb, s->year ,1);
-    mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 1);
+    mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT_EX, 1);
     mov_write_string_tag(pb, "\251cmt", s->comment       , 1);
     mov_write_string_tag(pb, "\251gen", s->genre         , 1);
     mov_write_trkn_tag(pb, mov, s);
@@ -1267,7 +1267,7 @@
             mov_write_string_tag(pb, "\251aut", s->author        , 0);
             mov_write_string_tag(pb, "\251alb", s->album         , 0);
             mov_write_day_tag(pb, s->year, 0);
-            mov_write_string_tag(pb, "\251enc", LIBAVFORMAT_IDENT, 0);
+            mov_write_string_tag(pb, "\251enc", LIBAVFORMAT_IDENT_EX, 0);
             mov_write_string_tag(pb, "\251des", s->comment       , 0);
             mov_write_string_tag(pb, "\251gen", s->genre         , 0);
         } else {
Index: libavformat/mp3.c
===================================================================
--- libavformat/mp3.c	(revision 14819)
+++ libavformat/mp3.c	(working copy)
@@ -597,7 +597,7 @@
     if(s->track)        totlen += 11 + strlen(tracktxt);
     if(s->year)         totlen += 11 + strlen(yeartxt);
     if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
-        totlen += strlen(LIBAVFORMAT_IDENT) + 11;
+        totlen += strlen(LIBAVFORMAT_IDENT_EX) + 11;
 
     if(totlen == 0)
         return 0;
@@ -616,7 +616,7 @@
     if(s->track)        id3v2_put_ttag(s, tracktxt,     MKBETAG('T', 'R', 'C', 'K'));
     if(s->year)         id3v2_put_ttag(s, yeartxt,      MKBETAG('T', 'Y', 'E', 'R'));
     if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
-        id3v2_put_ttag(s, LIBAVFORMAT_IDENT,            MKBETAG('T', 'E', 'N', 'C'));
+      id3v2_put_ttag(s, LIBAVFORMAT_IDENT_EX,           MKBETAG('T', 'E', 'N', 'C'));
     return 0;
 }
 
Index: libavformat/mpeg.c
===================================================================
--- libavformat/mpeg.c	(revision 14819)
+++ libavformat/mpeg.c	(working copy)
@@ -373,16 +373,33 @@
         startcode = get_byte(s->pb);
         len--;
         if (startcode >= 0x80 && startcode <= 0xcf) {
-            /* audio: skip header */
-            get_byte(s->pb);
-            get_byte(s->pb);
-            get_byte(s->pb);
+            int frame_headers, frame_start, i;
+            
+            /* audio: header */
+            frame_headers = get_byte(s->pb);
+            frame_start = get_be16(s->pb) - 1;
             len -= 3;
+
+            if (frame_start == -1 || frame_start > len)
+              frame_start = 0;
+           
             if (startcode >= 0xb0 && startcode <= 0xbf) {
                 /* MLP/TrueHD audio has a 4-byte header */
                 get_byte(s->pb);
                 len--;
             }
+
+            /* new streams have to skip audio part data */
+            for (i = 0; i < s->nb_streams; i++) {
+                if (startcode == s->streams[i]->id)
+                    goto known_stream;
+            }
+
+            url_fskip(s->pb, frame_start);
+            len -= frame_start;
+
+known_stream:
+            ;
         }
     }
     if(len<0)
@@ -459,7 +476,7 @@
         if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
             codec_id = CODEC_ID_CAVS;
         else
-            codec_id = CODEC_ID_PROBE;
+            codec_id = CODEC_ID_MPEG2VIDEO; /* fixme: CODEC_ID_PROBE */
         type = CODEC_TYPE_VIDEO;
     } else if (startcode >= 0x1c0 && startcode <= 0x1df) {
         type = CODEC_TYPE_AUDIO;
Index: libavformat/nutenc.c
===================================================================
--- libavformat/nutenc.c	(revision 14819)
+++ libavformat/nutenc.c	(working copy)
@@ -457,7 +457,7 @@
     if(s->author   [0]) count+= add_info(dyn_bc, "Author"   , s->author);
     if(s->copyright[0]) count+= add_info(dyn_bc, "Copyright", s->copyright);
     if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
-                        count+= add_info(dyn_bc, "Encoder"  , LIBAVFORMAT_IDENT);
+                        count+= add_info(dyn_bc, "Encoder"  , LIBAVFORMAT_IDENT_EX);
 
     put_v(bc, 0); //stream_if_plus1
     put_v(bc, 0); //chapter_id
Index: libavformat/oggenc.c
===================================================================
--- libavformat/oggenc.c	(revision 14819)
+++ libavformat/oggenc.c	(working copy)
@@ -84,7 +84,7 @@
 static int ogg_build_flac_headers(const uint8_t *extradata, int extradata_size,
                                   OGGStreamContext *oggstream, int bitexact)
 {
-    const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
+    const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT_EX;
     uint8_t *p;
     if (extradata_size != 34)
         return -1;
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c	(revision 14819)
+++ libavformat/utils.c	(working copy)
@@ -391,6 +391,8 @@
 {"fflags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, D|E, "fflags"},
 {"ignidx", "ignore index", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNIDX, INT_MIN, INT_MAX, D, "fflags"},
 {"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_GENPTS, INT_MIN, INT_MAX, D, "fflags"},
+{"noodml", "don't create odml avi files", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOODML, INT_MIN, INT_MAX, E, "fflags"},
+{"noinfo", "don't create info/vprp data in avi files", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOINFO, INT_MIN, INT_MAX, E, "fflags"},
 {"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
 {"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 3*AV_TIME_BASE, 0, INT_MAX, D},
@@ -1981,7 +1983,7 @@
        || c->time_base.den <    5L*c->time_base.num
 /*       || c->codec_tag == ff_get_fourcc("DIVX")
        || c->codec_tag == ff_get_fourcc("XVID")*/
-       || c->codec_id == CODEC_ID_MPEG2VIDEO)
+/*       || c->codec_id == CODEC_ID_MPEG2VIDEO */)
         return 1;
     return 0;
 }
@@ -2533,7 +2535,7 @@
         pkt->dts= st->pts_buffer[0];
     }
 
-    if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts){
+    if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts + 3){
         av_log(st->codec, AV_LOG_ERROR, "error, non monotone timestamps %"PRId64" >= %"PRId64"\n", st->cur_dts, pkt->dts);
         return -1;
     }
Index: libavutil/common.h
===================================================================
--- libavutil/common.h	(revision 14819)
+++ libavutil/common.h	(working copy)
@@ -26,7 +26,11 @@
 #ifndef FFMPEG_COMMON_H
 #define FFMPEG_COMMON_H
 
+#ifndef _MSC_VER
 #include <inttypes.h>
+#else
+#include <stdint.h>
+#endif
 
 #ifdef HAVE_AV_CONFIG_H
 /* only include the following when compiling package */
@@ -75,7 +79,7 @@
 
 #ifndef av_cold
 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 2)
-#    define av_cold __attribute__((cold))
+#    define av_cold
 #else
 #    define av_cold
 #endif
Index: libavutil/Makefile
===================================================================
--- libavutil/Makefile	(revision 14819)
+++ libavutil/Makefile	(working copy)
@@ -8,6 +8,7 @@
        crc.o \
        des.o \
        fifo.o \
+       file.o \
        intfloat_readwrite.o \
        lfg.o \
        lls.o \
@@ -31,6 +32,7 @@
           common.h \
           crc.h \
           fifo.h \
+          file.h \
           intfloat_readwrite.h \
           log.h \
           lzo.h \
Index: stdint.h
===================================================================
--- stdint.h	(revision 0)
+++ stdint.h	(revision 0)
@@ -0,0 +1,206 @@
+/* ISO C9x  7.18  Integer types <stdint.h>
+ * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
+ *
+ *  THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ *  Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
+ *
+ *  This source code is offered for use in the public domain. You may
+ *  use, modify or distribute it freely.
+ *
+ *  This code is distributed in the hope that it will be useful but
+ *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ *  DISCLAIMED. This includes but is not limited to warranties of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *  Date: 2000-12-02
+ */
+
+
+#ifndef _STDINT_H
+#define _STDINT_H
+#define __need_wint_t
+#define __need_wchar_t
+#include <stddef.h>
+
+/* 7.18.1.1  Exact-width integer types */
+typedef signed char int8_t;
+typedef unsigned char   uint8_t;
+typedef short  int16_t;
+typedef unsigned short  uint16_t;
+typedef int  int32_t;
+typedef unsigned   uint32_t;
+typedef long long  int64_t;
+typedef unsigned long long   uint64_t;
+
+/* 7.18.1.2  Minimum-width integer types */
+typedef signed char int_least8_t;
+typedef unsigned char   uint_least8_t;
+typedef short  int_least16_t;
+typedef unsigned short  uint_least16_t;
+typedef int  int_least32_t;
+typedef unsigned   uint_least32_t;
+typedef long long  int_least64_t;
+typedef unsigned long long   uint_least64_t;
+
+/*  7.18.1.3  Fastest minimum-width integer types 
+ *  Not actually guaranteed to be fastest for all purposes
+ *  Here we use the exact-width types for 8 and 16-bit ints. 
+ */
+typedef char int_fast8_t;
+typedef unsigned char uint_fast8_t;
+typedef short  int_fast16_t;
+typedef unsigned short  uint_fast16_t;
+typedef int  int_fast32_t;
+typedef unsigned  int  uint_fast32_t;
+typedef long long  int_fast64_t;
+typedef unsigned long long   uint_fast64_t;
+
+/* 7.18.1.4  Integer types capable of holding object pointers */
+
+#ifndef _INTPTR_T_DEFINED
+#define _INTPTR_T_DEFINED
+#ifdef _WIN64
+  typedef __int64 intptr_t;
+#else
+  typedef int intptr_t;
+#endif
+#endif
+
+#ifndef _UINTPTR_T_DEFINED
+#define _UINTPTR_T_DEFINED
+#ifdef _WIN64
+  typedef unsigned __int64 uintptr_t;
+#else
+  typedef unsigned int uintptr_t;
+#endif
+#endif
+
+/* 7.18.1.5  Greatest-width integer types */
+typedef long long  intmax_t;
+typedef unsigned long long uintmax_t;
+
+/* 7.18.2  Limits of specified-width integer types */
+#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
+
+/* 7.18.2.1  Limits of exact-width integer types */
+#define INT8_MIN (-128) 
+#define INT16_MIN (-32768)
+#define INT32_MIN (-2147483647 - 1)
+#define INT64_MIN  (-9223372036854775807LL - 1)
+
+#define INT8_MAX 127
+#define INT16_MAX 32767
+#define INT32_MAX 2147483647
+#define INT64_MAX 9223372036854775807LL
+
+#define UINT8_MAX 0xff /* 255U */
+#define UINT16_MAX 0xffff /* 65535U */
+#define UINT32_MAX 0xffffffff  /* 4294967295U */
+#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
+
+/* 7.18.2.2  Limits of minimum-width integer types */
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST64_MIN INT64_MIN
+
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MAX INT64_MAX
+
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+/* 7.18.2.3  Limits of fastest minimum-width integer types */
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST64_MIN INT64_MIN
+
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MAX INT32_MAX
+#define INT_FAST64_MAX INT64_MAX
+
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+/* 7.18.2.4  Limits of integer types capable of holding
+    object pointers */
+#ifdef _WIN64
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+#define UINTPTR_MAX UINT64_MAX
+#else
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+#endif
+
+/* 7.18.2.5  Limits of greatest-width integer types */
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+/* 7.18.3  Limits of other integer types */
+#define PTRDIFF_MIN INTPTR_MIN
+#define PTRDIFF_MAX INTPTR_MAX
+
+#define SIG_ATOMIC_MIN INTPTR_MIN
+#define SIG_ATOMIC_MAX INTPTR_MAX
+
+#define SIZE_MAX UINTPTR_MAX
+
+#ifndef WCHAR_MIN  /* also in wchar.h */ 
+#define WCHAR_MIN 0
+#define WCHAR_MAX 0xffff /* UINT16_MAX */
+#endif
+
+/*
+ * wint_t is unsigned short for compatibility with MS runtime
+ */
+#define WINT_MIN 0
+#define WINT_MAX 0xffff /* UINT16_MAX */
+
+#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
+
+
+/* 7.18.4  Macros for integer constants */
+#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
+
+/* 7.18.4.1  Macros for minimum-width integer constants
+
+    Accoding to Douglas Gwyn <gwyn@arl.mil>:
+	"This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
+	9899:1999 as initially published, the expansion was required
+	to be an integer constant of precisely matching type, which
+	is impossible to accomplish for the shorter types on most
+	platforms, because C99 provides no standard way to designate
+	an integer constant with width less than that of type int.
+	TC1 changed this to require just an integer constant
+	*expression* with *promoted* type."
+*/
+
+#define INT8_C(val) ((int8_t) + (val))
+#define UINT8_C(val) ((uint8_t) + (val##U))
+#define INT16_C(val) ((int16_t) + (val))
+#define UINT16_C(val) ((uint16_t) + (val##U))
+
+#define INT32_C(val) val##L
+#define UINT32_C(val) val##UL
+#define INT64_C(val) val##LL
+#define UINT64_C(val) val##ULL
+
+/* 7.18.4.2  Macros for greatest-width integer constants */
+#define INTMAX_C(val)  INT64_C(val)
+#define UINTMAX_C(val) UINT64_C(val)
+
+#endif  /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
+
+#endif
