]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avisynth.c
asfenc: return error on negative timestamp
[ffmpeg] / libavformat / avisynth.c
index 78eb5e6025981da974e474835cc2bcd536409d19..43b3da5bc7c08e201bf388680c067c481b40b0bb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * AVISynth support for ffmpeg system
+ * AVISynth support
  * Copyright (c) 2006 DivX, Inc.
  *
  * This file is part of Libav.
@@ -20,6 +20,7 @@
  */
 
 #include "avformat.h"
+#include "internal.h"
 #include "riff.h"
 
 #include <windows.h>
@@ -40,7 +41,7 @@ typedef struct {
   int next_stream;
 } AVISynthContext;
 
-static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap)
+static int avisynth_read_header(AVFormatContext *s)
 {
   AVISynthContext *avs = s->priv_data;
   HRESULT res;
@@ -48,10 +49,15 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap)
   DWORD id;
   AVStream *st;
   AVISynthStream *stream;
+  wchar_t filename_wchar[1024] = { 0 };
+  char filename_char[1024] = { 0 };
 
   AVIFileInit();
 
-  res = AVIFileOpen(&avs->file, s->filename, OF_READ|OF_SHARE_DENY_WRITE, NULL);
+  /* avisynth can't accept UTF-8 filename */
+  MultiByteToWideChar(CP_UTF8, 0, s->filename, -1, filename_wchar, 1024);
+  WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wchar, -1, filename_char, 1024, NULL, NULL);
+  res = AVIFileOpen(&avs->file, filename_char, OF_READ|OF_SHARE_DENY_WRITE, NULL);
   if (res != S_OK)
     {
       av_log(s, AV_LOG_ERROR, "AVIFileOpen failed with error %ld", res);
@@ -114,8 +120,8 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap)
                   st = avformat_new_stream(s, NULL);
                   st->id = id;
                   st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-                  st->r_frame_rate.num = stream->info.dwRate;
-                  st->r_frame_rate.den = stream->info.dwScale;
+                  st->avg_frame_rate.num = stream->info.dwRate;
+                  st->avg_frame_rate.den = stream->info.dwScale;
 
                   st->codec->width = imgfmt.bmiHeader.biWidth;
                   st->codec->height = imgfmt.bmiHeader.biHeight;
@@ -137,7 +143,7 @@ static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap)
 
               st->codec->stream_codec_tag = stream->info.fccHandler;
 
-              av_set_pts_info(st, 64, info.dwScale, info.dwRate);
+              avpriv_set_pts_info(st, 64, info.dwScale, info.dwRate);
               st->start_time = stream->info.dwStart;
             }
         }
@@ -210,7 +216,7 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t pts,
 }
 
 AVInputFormat ff_avisynth_demuxer = {
-    .name           = "avs",
+    .name           = "avisynth",
     .long_name      = NULL_IF_CONFIG_SMALL("AVISynth"),
     .priv_data_size = sizeof(AVISynthContext),
     .read_header    = avisynth_read_header,