
Property changes on: .
___________________________________________________________________
Modified: svn:ignore
   - *.d
*.ho
config.*
ffmpeg
ffmpeg_g
ffplay
ffplay_g
ffserver
ffserver_g
output_example
version.h

   + *.d
*.ho
*.pc
config.*
ffmpeg
ffmpeg_g
ffplay
ffplay_g
ffserver
ffserver_g
output_example
version.h
build
build_clonedvd
build_full
libextern
build_cgr
configure_cgr
configure_clonedvd
configure_cougar


Index: cmdutils.c
===================================================================
--- cmdutils.c	(revision 14521)
+++ cmdutils.c	(working copy)
@@ -198,8 +198,10 @@
 
 void show_banner(void)
 {
+    /*
     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");
     fprintf(stderr, "  libavutil version: " AV_STRINGIFY(LIBAVUTIL_VERSION) "\n");
     fprintf(stderr, "  libavcodec version: " AV_STRINGIFY(LIBAVCODEC_VERSION) "\n");
@@ -214,11 +216,24 @@
 #else
     fprintf(stderr, ", using a non-gcc compiler\n");
 #endif
+    */
+
+    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"
+      "        These changes are available as patches from http://oss.slysoft.com/ffmpeg\n"
+      "\n"
+      );
 }
 
 void show_version(void) {
      /* TODO: add function interface to avutil and avformat avdevice*/
     printf("%s " FFMPEG_VERSION "\n", program_name);
+    return;
+
     printf("libavutil   %d\n"
            "libavcodec  %d\n"
            "libavformat %d\n"
@@ -280,6 +295,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 14521)
+++ configure	(working copy)
@@ -620,7 +620,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
@@ -1687,7 +1687,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
 
@@ -2136,7 +2136,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 14521)
+++ ffmpeg.c	(working copy)
@@ -149,6 +149,7 @@
 static char *audio_language = NULL;
 
 static int subtitle_disable = 0;
+static int subtitle_etching = 0;
 static char *subtitle_codec_name = NULL;
 static char *subtitle_language = NULL;
 
@@ -762,6 +763,8 @@
 /* we begin to correct av delay at this threshold */
 #define AV_DELAY_MAX 0.100
 
+static AVSubtitle subtitle_etch;
+
 static void do_subtitle_out(AVFormatContext *s,
                             AVOutputStream *ost,
                             AVInputStream *ist,
@@ -824,10 +827,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);
 
@@ -866,14 +870,24 @@
     if (nb_frames <= 0)
         return;
 
+    if (subtitle_etch.num_rects && subtitle_etch.start_display_time <= ist->pts && ist->pts <= subtitle_etch.end_display_time) {
+        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;
@@ -1041,13 +1055,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;
     }
@@ -1220,7 +1234,7 @@
                     (ist->st->codec->sample_rate * ist->st->codec->channels);
                 break;}
             case CODEC_TYPE_VIDEO:
-                    data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
+                data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
                     /* XXX: allocate picture correctly */
                     avcodec_get_frame_defaults(&picture);
 
@@ -1241,14 +1255,50 @@
                     len = 0;
                     break;
             case CODEC_TYPE_SUBTITLE:
+                
+                if (subtitle_etching) {
+                    if (subtitle_etch.rects != NULL) {
+                        for (i = 0; i < subtitle_etch.num_rects; i++) {
+                            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_display_time = ist->pts + 1000 * subtitle_etch.start_display_time;
+                subtitle_etch.end_display_time   = ist->pts + 1000 * subtitle_etch.end_display_time;
+
+                if (!subtitle_etching)
+                  subtitle_to_free = &subtitle;               
+
                 len = 0;
                 break;
             default:
@@ -2090,6 +2140,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;
 
@@ -2109,13 +2164,26 @@
         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 || pkt_dts+1<ist->pts)&& !copy_ts && delta){
                 input_files_ts_offset[ist->file_index]-= delta;
                 if (verbose > 2)
                     fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]);
                 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;              
+                }  
             }
         }
 
@@ -2130,6 +2198,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);
 
@@ -2667,6 +2739,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 = 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;
@@ -2774,6 +2896,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);
@@ -3481,8 +3611,17 @@
     vfprintf(stdout, fmt, vl);
 }
 
+#include "build_clonedvd\appinfo.h"
+#include "libextern\libx264\libinfo.h"
+
 static void show_help(void)
 {
+    printf("NOTICE: Program cannot be called directly. No parameter information available.\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");
+    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");
@@ -3857,6 +3996,8 @@
     { "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" },
+    { "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" },
@@ -3884,6 +4025,11 @@
     int i;
     int64_t ti;
 
+    /* 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 14521)
+++ libavcodec/avcodec.h	(working copy)
@@ -2318,6 +2318,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;
 
 
@@ -2961,6 +2963,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 14521)
+++ 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,
@@ -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/imgconvert.c
===================================================================
--- libavcodec/imgconvert.c	(revision 14521)
+++ 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,69 @@
         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 stride, cc, c;    
+    double a;
+    uint32_t *palette, v;
+    uint8_t *bitmap;
+
+    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);
+            palette = r->rgba_palette;
+            bitmap = r->bitmap;  
+            stride = r->linesize;
+
+            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 = palette[bitmap[y * stride + 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/mpegvideo.c
===================================================================
--- libavcodec/mpegvideo.c	(revision 14521)
+++ 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 14521)
+++ 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 14521)
+++ 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: libavformat/avformat.h
===================================================================
--- libavformat/avformat.h	(revision 14521)
+++ 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 1.2.0.1 (using FFmpeg)"
 
 #include <time.h>
 #include <stdio.h>  /* FILE */
@@ -499,6 +500,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 14521)
+++ 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/matroskaenc.c
===================================================================
--- libavformat/matroskaenc.c	(revision 14521)
+++ 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 14521)
+++ 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 14521)
+++ libavformat/mp3.c	(working copy)
@@ -596,7 +596,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;
@@ -615,7 +615,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 14521)
+++ libavformat/mpeg.c	(working copy)
@@ -459,7 +459,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 14521)
+++ 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 14521)
+++ 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 14521)
+++ libavformat/utils.c	(working copy)
@@ -338,6 +338,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},
Index: libavutil/common.h
===================================================================
--- libavutil/common.h	(revision 14521)
+++ 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: 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
