]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avisynth.c
hls: Set stream offset before opening a chained demuxer
[ffmpeg] / libavformat / avisynth.c
index 3b695a9a0aaa19cf0f622aa191c93171e193f0f1..b846c9f2979db3480bc8e998017a267d9d6d696d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * AVISynth support
+ * AviSynth support
  * Copyright (c) 2006 DivX, Inc.
  *
  * This file is part of Libav.
@@ -32,27 +32,32 @@ typedef struct {
   DWORD read;
   LONG chunck_size;
   LONG chunck_samples;
-} AVISynthStream;
+} AviSynthStream;
 
 typedef struct {
   PAVIFILE file;
   AVISynthStream *streams;
   int nb_streams;
   int next_stream;
-} AVISynthContext;
+} AviSynthContext;
 
 static int avisynth_read_header(AVFormatContext *s)
 {
-  AVISynthContext *avs = s->priv_data;
+  AviSynthContext *avs = s->priv_data;
   HRESULT res;
   AVIFILEINFO info;
   DWORD id;
   AVStream *st;
-  AVISynthStream *stream;
+  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 cannot accept UTF-8 file names. */
+  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);
@@ -68,7 +73,7 @@ static int avisynth_read_header(AVFormatContext *s)
       return -1;
     }
 
-  avs->streams = av_mallocz(info.dwStreams * sizeof(AVISynthStream));
+  avs->streams = av_mallocz(info.dwStreams * sizeof(AviSynthStream));
 
   for (id=0; id<info.dwStreams; id++)
     {
@@ -115,8 +120,8 @@ static int avisynth_read_header(AVFormatContext *s)
                   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;
@@ -149,9 +154,9 @@ static int avisynth_read_header(AVFormatContext *s)
 
 static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-  AVISynthContext *avs = s->priv_data;
+  AviSynthContext *avs = s->priv_data;
   HRESULT res;
-  AVISynthStream *stream;
+  AviSynthStream *stream;
   int stream_id = avs->next_stream;
   LONG read_size;
 
@@ -183,7 +188,7 @@ static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
 
 static int avisynth_read_close(AVFormatContext *s)
 {
-  AVISynthContext *avs = s->priv_data;
+  AviSynthContext *avs = s->priv_data;
   int i;
 
   for (i=0;i<avs->nb_streams;i++)
@@ -199,7 +204,7 @@ static int avisynth_read_close(AVFormatContext *s)
 
 static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
 {
-  AVISynthContext *avs = s->priv_data;
+  AviSynthContext *avs = s->priv_data;
   int stream_id;
 
   for (stream_id = 0; stream_id < avs->nb_streams; stream_id++)
@@ -211,9 +216,9 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, int64_t pts,
 }
 
 AVInputFormat ff_avisynth_demuxer = {
-    .name           = "avs",
-    .long_name      = NULL_IF_CONFIG_SMALL("AVISynth"),
-    .priv_data_size = sizeof(AVISynthContext),
+    .name           = "avisynth",
+    .long_name      = NULL_IF_CONFIG_SMALL("AviSynth"),
+    .priv_data_size = sizeof(AviSynthContext),
     .read_header    = avisynth_read_header,
     .read_packet    = avisynth_read_packet,
     .read_close     = avisynth_read_close,