Mercurial > mplayer.hg
annotate libmpdemux/demux_avs.c @ 21659:da09e69a0f01
support functions for writing to streams
author | nicodvb |
---|---|
date | Mon, 18 Dec 2006 20:56:24 +0000 |
parents | 36589811e5d0 |
children | 01f781618827 |
rev | line source |
---|---|
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
1 /* |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
2 * Demuxer for avisynth |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
3 * Copyright (c) 2005 Gianluigi Tiesi <sherpya@netfarm.it> |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
4 * |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Library General Public |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
9 * |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
13 * Library General Public License for more details. |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
14 * |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Library General Public |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
16 * License along with this library; if not, write to the |
19614 | 17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301 USA. | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
19 */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
20 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
21 #include <stdio.h> |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
22 #include <stdlib.h> |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
23 #include <unistd.h> |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
24 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
25 #include "config.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
26 #include "mp_msg.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
27 #include "help_mp.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
28 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
29 #include "stream.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
30 #include "demuxer.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
31 #include "stheader.h" |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
32 #include "libvo/fastmemcpy.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
33 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
34 #include "wine/windef.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
35 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
36 #ifdef WIN32_LOADER |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
37 #include "ldt_keeper.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
38 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
39 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
40 #include "demux_avs.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
41 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
42 #define MAX_AVS_SIZE 16 * 1024 /* 16k should be enough */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
43 #undef ENABLE_AUDIO |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
44 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
45 HMODULE WINAPI LoadLibraryA(LPCSTR); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
46 FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
47 int WINAPI FreeLibrary(HMODULE); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
48 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
49 typedef WINAPI AVS_ScriptEnvironment* (*imp_avs_create_script_environment)(int version); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
50 typedef WINAPI AVS_Value (*imp_avs_invoke)(AVS_ScriptEnvironment *, const char * name, AVS_Value args, const char** arg_names); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
51 typedef WINAPI const AVS_VideoInfo *(*imp_avs_get_video_info)(AVS_Clip *); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
52 typedef WINAPI AVS_Clip* (*imp_avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *); |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
53 typedef WINAPI void (*imp_avs_release_clip)(AVS_Clip *); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
54 typedef WINAPI AVS_VideoFrame* (*imp_avs_get_frame)(AVS_Clip *, int n); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
55 typedef WINAPI void (*imp_avs_release_video_frame)(AVS_VideoFrame *); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
56 #ifdef ENABLE_AUDIO |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
57 //typedef WINAPI int (*imp_avs_get_audio)(AVS_Clip *, void * buf, uint64_t start, uint64_t count); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
58 typedef WINAPI int (*imp_avs_get_audio)(AVS_ScriptEnvironment *, void * buf, uint64_t start, uint64_t count); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
59 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
60 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
61 #define Q(string) # string |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
62 #define IMPORT_FUNC(x) \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
63 AVS->x = ( imp_##x ) GetProcAddress(AVS->dll, Q(x)); \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
64 if (!AVS->x) { mp_msg(MSGT_DEMUX,MSGL_V,"AVS: failed to load "Q(x)"()\n"); return 0; } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
65 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
66 typedef struct tagAVS |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
67 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
68 AVS_ScriptEnvironment *avs_env; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
69 AVS_Value handler; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
70 AVS_Clip *clip; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
71 const AVS_VideoInfo *video_info; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
72 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
73 ldt_fs_t* ldt_fs; |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
74 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
75 HMODULE dll; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
76 int frameno; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
77 int init; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
78 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
79 imp_avs_create_script_environment avs_create_script_environment; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
80 imp_avs_invoke avs_invoke; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
81 imp_avs_get_video_info avs_get_video_info; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
82 imp_avs_take_clip avs_take_clip; |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
83 imp_avs_release_clip avs_release_clip; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
84 imp_avs_get_frame avs_get_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
85 imp_avs_release_video_frame avs_release_video_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
86 #ifdef ENABLE_AUDIO |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
87 imp_avs_get_audio avs_get_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
88 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
89 } AVS_T; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
90 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
91 AVS_T *initAVS(const char *filename) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
92 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
93 AVS_T *AVS = (AVS_T *) malloc (sizeof(AVS_T)); |
14695 | 94 AVS_Value arg0 = avs_new_value_string(filename); |
95 AVS_Value args = avs_new_value_array(&arg0, 1); | |
96 | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
97 memset(AVS, 0, sizeof(AVS_T)); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
98 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
99 #ifdef WIN32_LOADER |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
100 AVS->ldt_fs = Setup_LDT_Keeper(); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
101 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
102 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
103 AVS->dll = LoadLibraryA("avisynth.dll"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
104 if(!AVS->dll) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
105 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
106 mp_msg(MSGT_DEMUX ,MSGL_V, "AVS: failed to load avisynth.dll\n"); |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
107 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
108 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
109 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
110 /* Dynamic import of needed stuff from avisynth.dll */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
111 IMPORT_FUNC(avs_create_script_environment); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
112 IMPORT_FUNC(avs_invoke); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
113 IMPORT_FUNC(avs_get_video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
114 IMPORT_FUNC(avs_take_clip); |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
115 IMPORT_FUNC(avs_release_clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
116 IMPORT_FUNC(avs_get_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
117 IMPORT_FUNC(avs_release_video_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
118 #ifdef ENABLE_AUDIO |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
119 IMPORT_FUNC(avs_get_audio); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
120 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
121 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
122 AVS->avs_env = AVS->avs_create_script_environment(AVISYNTH_INTERFACE_VERSION); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
123 if (!AVS->avs_env) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
124 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
125 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_create_script_environment failed\n"); |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
126 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
127 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
128 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
129 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
130 AVS->handler = AVS->avs_invoke(AVS->avs_env, "Import", args, 0); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
131 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
132 if (avs_is_error(AVS->handler)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
133 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
134 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Avisynth error: %s\n", avs_as_string(AVS->handler)); |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
135 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
136 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
137 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
138 if (!avs_is_clip(AVS->handler)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
139 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
140 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Avisynth doesn't return a clip\n"); |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
141 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
142 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
143 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
144 return AVS; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
145 |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
146 avs_err: |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
147 if (AVS->dll) FreeLibrary(AVS->dll); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
148 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
149 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
150 #endif |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
151 free(AVS); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
152 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
153 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
154 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
155 /* Implement RGB MODES ?? */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
156 #if 0 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
157 static __inline int get_mmioFOURCC(const AVS_VideoInfo *v) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
158 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
159 if (avs_is_rgb(v)) return mmioFOURCC(8, 'R', 'G', 'B'); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
160 if (avs_is_rgb24(v)) return mmioFOURCC(24, 'R', 'G', 'B'); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
161 if (avs_is_rgb32(v)) return mmioFOURCC(32, 'R', 'G', 'B'); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
162 if (avs_is_yv12(v)) return mmioFOURCC('Y', 'V', '1', '2'); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
163 if (avs_is_yuy(v)) return mmioFOURCC('Y', 'U', 'Y', ' '); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
164 if (avs_is_yuy2(v)) return mmioFOURCC('Y', 'U', 'Y', '2'); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
165 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
166 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
167 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
168 |
16175 | 169 static int demux_avs_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
170 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
171 AVS_VideoFrame *curr_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
172 demux_packet_t *dp = NULL; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
173 AVS_T *AVS = (AVS_T *) demuxer->priv; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
174 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
175 demux_stream_t *d_video=demuxer->video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
176 sh_video_t *sh_video=d_video->sh; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
177 |
19213
606d2f7cd307
Move more stuff under if (avs_has_video... to simplify later patches.
reimar
parents:
19212
diff
changeset
|
178 if (avs_has_video(AVS->video_info)) |
606d2f7cd307
Move more stuff under if (avs_has_video... to simplify later patches.
reimar
parents:
19212
diff
changeset
|
179 { |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
180 char *dst; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
181 int w, h; |
19214 | 182 if (AVS->video_info->num_frames < AVS->frameno) return 0; // EOF |
183 | |
184 curr_frame = AVS->avs_get_frame(AVS->clip, AVS->frameno); | |
185 if (!curr_frame) | |
186 { | |
187 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: error getting frame -- EOF??\n"); | |
188 return 0; | |
189 } | |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
190 w = curr_frame->row_size; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
191 h = curr_frame->height; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
192 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
193 dp = new_demux_packet(w * h + 2 * (w / 2) * (h / 2)); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
194 |
19212 | 195 dp->pts=AVS->frameno / sh_video->fps; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
196 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
197 dst = dp->buffer; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
198 memcpy_pic(dst, curr_frame->vfb->data + curr_frame->offset, |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
199 w, h, w, curr_frame->pitch); |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
200 dst += w * h; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
201 w /= 2; h /= 2; |
19219 | 202 memcpy_pic(dst, curr_frame->vfb->data + curr_frame->offsetV, |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
203 w, h, w, curr_frame->pitchUV); |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
204 dst += w * h; |
19219 | 205 memcpy_pic(dst, curr_frame->vfb->data + curr_frame->offsetU, |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
206 w, h, w, curr_frame->pitchUV); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
207 ds_add_packet(demuxer->video, dp); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
208 |
19214 | 209 AVS->frameno++; |
210 AVS->avs_release_video_frame(curr_frame); | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
211 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
212 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
213 #ifdef ENABLE_AUDIO |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
214 /* Audio */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
215 if (avs_has_audio(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
216 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
217 demux_stream_t *d_audio=demuxer->audio; |
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
218 sh_audio_t *sh_audio=d_audio->sh; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
219 int l = sh_audio->wf->nAvgBytesPerSec; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
220 dp = new_demux_packet(l); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
221 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
222 if (AVS->avs_get_audio(AVS->avs_env, dp->buffer, AVS->frameno*sh_video->fps*l, l)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
223 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
224 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_audio() failed\n"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
225 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
226 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
227 ds_add_packet(demuxer->audio, dp); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
228 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
229 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
230 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
231 return 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
232 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
233 |
16175 | 234 static demuxer_t* demux_open_avs(demuxer_t* demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
235 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
236 int found = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
237 AVS_T *AVS = (AVS_T *) demuxer->priv; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
238 AVS->frameno = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
239 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
240 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: demux_open_avs()\n"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
241 demuxer->seekable = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
242 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
243 AVS->clip = AVS->avs_take_clip(AVS->handler, AVS->avs_env); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
244 if(!AVS->clip) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
245 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
246 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 247 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
248 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
249 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
250 AVS->video_info = AVS->avs_get_video_info(AVS->clip); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
251 if (!AVS->video_info) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
252 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
253 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 254 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
255 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
256 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
257 if (!avs_is_yv12(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
258 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
259 AVS->handler = AVS->avs_invoke(AVS->avs_env, "ConvertToYV12", avs_new_value_array(&AVS->handler, 1), 0); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
260 if (avs_is_error(AVS->handler)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
261 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
262 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Cannot convert input video to YV12: %s\n", avs_as_string(AVS->handler)); |
16175 | 263 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
264 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
265 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
266 AVS->clip = AVS->avs_take_clip(AVS->handler, AVS->avs_env); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
267 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
268 if(!AVS->clip) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
269 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
270 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 271 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
272 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
273 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
274 AVS->video_info = AVS->avs_get_video_info(AVS->clip); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
275 if (!AVS->video_info) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
276 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
277 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 278 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
279 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
280 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
281 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
282 // TODO check field-based ?? |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
283 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
284 /* Video */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
285 if (avs_has_video(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
286 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
287 sh_video_t *sh_video = new_sh_video(demuxer, 0); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
288 found = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
289 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
290 demuxer->video->sh = sh_video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
291 sh_video->ds = demuxer->video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
292 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
293 sh_video->disp_w = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
294 sh_video->disp_h = AVS->video_info->height; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
295 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
296 //sh_video->format = get_mmioFOURCC(AVS->video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
297 sh_video->format = mmioFOURCC('Y', 'V', '1', '2'); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
298 sh_video->fps = (float) ((float) AVS->video_info->fps_numerator / (float) AVS->video_info->fps_denominator); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
299 sh_video->frametime = 1.0 / sh_video->fps; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
300 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
301 sh_video->bih = (BITMAPINFOHEADER*) malloc(sizeof(BITMAPINFOHEADER) + (256 * 4)); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
302 sh_video->bih->biCompression = sh_video->format; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
303 sh_video->bih->biBitCount = avs_bits_per_pixel(AVS->video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
304 //sh_video->bih->biPlanes = 2; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
305 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
306 sh_video->bih->biWidth = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
307 sh_video->bih->biHeight = AVS->video_info->height; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
308 sh_video->num_frames = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
309 sh_video->num_frames_decoded = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
310 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
311 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
312 #ifdef ENABLE_AUDIO |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
313 /* Audio */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
314 if (avs_has_audio(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
315 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
316 sh_audio_t *sh_audio = new_sh_audio(demuxer, 0); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
317 found = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
318 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Clip has audio -> Channels = %d - Freq = %d\n", AVS->video_info->nchannels, AVS->video_info->audio_samples_per_second); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
319 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
320 demuxer->audio->sh = sh_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
321 sh_audio->ds = demuxer->audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
322 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
323 sh_audio->wf = (WAVEFORMATEX*) malloc(sizeof(WAVEFORMATEX)); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
324 sh_audio->wf->wFormatTag = sh_audio->format = 0x1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
325 sh_audio->wf->nChannels = sh_audio->channels = AVS->video_info->nchannels; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
326 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate = AVS->video_info->audio_samples_per_second; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
327 sh_audio->wf->nAvgBytesPerSec = AVS->video_info->audio_samples_per_second * 4; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
328 sh_audio->wf->nBlockAlign = 4; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
329 sh_audio->wf->wBitsPerSample = sh_audio->samplesize = 16; // AVS->video_info->sample_type ?? |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
330 sh_audio->wf->cbSize = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
331 sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
332 sh_audio->o_bps = sh_audio->wf->nAvgBytesPerSec; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
333 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
334 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
335 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
336 AVS->init = 1; |
16175 | 337 if (found) |
338 return demuxer; | |
339 else | |
340 return NULL; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
341 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
342 |
16175 | 343 static int demux_avs_control(demuxer_t *demuxer, int cmd, void *arg) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
344 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
345 demux_stream_t *d_video=demuxer->video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
346 sh_video_t *sh_video=d_video->sh; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
347 AVS_T *AVS = (AVS_T *) demuxer->priv; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
348 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
349 switch(cmd) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
350 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
351 case DEMUXER_CTRL_GET_TIME_LENGTH: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
352 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
353 if (!AVS->video_info->num_frames) return DEMUXER_CTRL_DONTKNOW; |
16346
6ff303d2876b
Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents:
16175
diff
changeset
|
354 *((double *)arg) = (double)AVS->video_info->num_frames / sh_video->fps; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
355 return DEMUXER_CTRL_OK; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
356 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
357 case DEMUXER_CTRL_GET_PERCENT_POS: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
358 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
359 if (!AVS->video_info->num_frames) return DEMUXER_CTRL_DONTKNOW; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
360 *((int *)arg) = (int) (AVS->frameno * 100 / AVS->video_info->num_frames); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
361 return DEMUXER_CTRL_OK; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
362 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
363 default: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
364 return DEMUXER_CTRL_NOTIMPL; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
365 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
366 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
367 |
16175 | 368 static void demux_close_avs(demuxer_t* demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
369 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
370 AVS_T *AVS = (AVS_T *) demuxer->priv; |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
371 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
372 if (AVS) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
373 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
374 if (AVS->dll) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
375 { |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
376 if (AVS->clip) |
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
377 AVS->avs_release_clip(AVS->clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
378 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Unloading avisynth.dll\n"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
379 FreeLibrary(AVS->dll); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
380 } |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
381 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
382 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
383 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
384 free(AVS); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
385 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
386 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
387 |
17636 | 388 static void demux_seek_avs(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
389 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
390 demux_stream_t *d_video=demuxer->video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
391 sh_video_t *sh_video=d_video->sh; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
392 AVS_T *AVS = (AVS_T *) demuxer->priv; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
393 int video_pos=AVS->frameno; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
394 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
395 //mp_msg(MSGT_DEMUX, MSGL_V, "AVS: seek rel_seek_secs = %f - flags = %x\n", rel_seek_secs, flags); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
396 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
397 // seek absolute |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
398 if (flags&1) video_pos=0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
399 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
400 video_pos += (rel_seek_secs * sh_video->fps); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
401 if (video_pos < 0) video_pos = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
402 if (video_pos > AVS->video_info->num_frames) video_pos = AVS->video_info->num_frames; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
403 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
404 AVS->frameno = video_pos; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
405 sh_video->num_frames_decoded = video_pos; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
406 sh_video->num_frames = video_pos; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
407 d_video->pts=AVS->frameno / sh_video->fps; // OSD |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
408 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
409 |
16175 | 410 static int avs_check_file(demuxer_t *demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
411 { |
16175 | 412 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_check_file - attempting to open file %s\n", demuxer->filename); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
413 |
16175 | 414 if (!demuxer->filename) return 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
415 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
416 /* Avoid crazy memory eating when passing an mpg stream */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
417 if (demuxer->movi_end > MAX_AVS_SIZE) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
418 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
419 mp_msg(MSGT_DEMUX,MSGL_V, "AVS: File is too big, aborting...\n"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
420 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
421 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
422 |
16175 | 423 demuxer->priv = initAVS(demuxer->filename); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
424 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
425 if (demuxer->priv) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
426 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
427 mp_msg(MSGT_DEMUX,MSGL_V, "AVS: Init Ok\n"); |
16175 | 428 return DEMUXER_TYPE_AVS; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
429 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
430 mp_msg(MSGT_DEMUX,MSGL_V, "AVS: Init failed\n"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
431 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
432 } |
16175 | 433 |
434 | |
435 demuxer_desc_t demuxer_desc_avs = { | |
436 "Avisynth demuxer", | |
437 "avs", | |
438 "AVS", | |
439 "Gianluigi Tiesi", | |
440 "Requires binary dll", | |
441 DEMUXER_TYPE_AVS, | |
442 0, // unsafe autodetect | |
443 avs_check_file, | |
444 demux_avs_fill_buffer, | |
445 demux_open_avs, | |
446 demux_close_avs, | |
447 demux_seek_avs, | |
448 demux_avs_control | |
449 }; |