Mercurial > mplayer.hg
annotate libmpdemux/demux_avs.c @ 25312:643c5e2b6b56
Comment out unused variable.
author | diego |
---|---|
date | Mon, 10 Dec 2007 14:13:34 +0000 |
parents | 97343cedd966 |
children | d4fe6e23283e |
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> |
22420 | 24 #include <limits.h> |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
25 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
26 #include "config.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
27 #include "mp_msg.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
28 #include "help_mp.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
29 |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22450
diff
changeset
|
30 #include "stream/stream.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
31 #include "demuxer.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
32 #include "stheader.h" |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
33 #include "libvo/fastmemcpy.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
34 |
22606
97343cedd966
Use explicit path for headers from the loader/ directory.
diego
parents:
22605
diff
changeset
|
35 #include "loader/wine/windef.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
36 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
37 #ifdef WIN32_LOADER |
22606
97343cedd966
Use explicit path for headers from the loader/ directory.
diego
parents:
22605
diff
changeset
|
38 #include "loader/ldt_keeper.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
39 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
40 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
41 #include "demux_avs.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
42 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
43 #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
|
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 *); |
22414 | 56 typedef WINAPI int (*imp_avs_get_audio)(AVS_Clip *, void * buf, uint64_t start, uint64_t count); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
57 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
58 #define Q(string) # string |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
59 #define IMPORT_FUNC(x) \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
60 AVS->x = ( imp_##x ) GetProcAddress(AVS->dll, Q(x)); \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
61 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
|
62 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
63 typedef struct tagAVS |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
64 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
65 AVS_ScriptEnvironment *avs_env; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
66 AVS_Value handler; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
67 AVS_Clip *clip; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
68 const AVS_VideoInfo *video_info; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
69 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
70 ldt_fs_t* ldt_fs; |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
71 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
72 HMODULE dll; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
73 int frameno; |
22420 | 74 uint64_t sampleno; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
75 int init; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
76 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
77 imp_avs_create_script_environment avs_create_script_environment; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
78 imp_avs_invoke avs_invoke; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
79 imp_avs_get_video_info avs_get_video_info; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
80 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
|
81 imp_avs_release_clip avs_release_clip; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
82 imp_avs_get_frame avs_get_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
83 imp_avs_release_video_frame avs_release_video_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
84 imp_avs_get_audio avs_get_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
85 } AVS_T; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
86 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
87 AVS_T *initAVS(const char *filename) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
88 { |
22428 | 89 AVS_T *AVS = malloc (sizeof(AVS_T)); |
14695 | 90 AVS_Value arg0 = avs_new_value_string(filename); |
91 AVS_Value args = avs_new_value_array(&arg0, 1); | |
92 | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
93 memset(AVS, 0, sizeof(AVS_T)); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
94 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
95 #ifdef WIN32_LOADER |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
96 AVS->ldt_fs = Setup_LDT_Keeper(); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
97 #endif |
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 AVS->dll = LoadLibraryA("avisynth.dll"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
100 if(!AVS->dll) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
101 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
102 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
|
103 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
104 } |
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 /* Dynamic import of needed stuff from avisynth.dll */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
107 IMPORT_FUNC(avs_create_script_environment); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
108 IMPORT_FUNC(avs_invoke); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
109 IMPORT_FUNC(avs_get_video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
110 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
|
111 IMPORT_FUNC(avs_release_clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
112 IMPORT_FUNC(avs_get_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
113 IMPORT_FUNC(avs_release_video_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
114 IMPORT_FUNC(avs_get_audio); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
115 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
116 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
|
117 if (!AVS->avs_env) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
118 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
119 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
|
120 goto avs_err; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
123 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
124 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
|
125 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
126 if (avs_is_error(AVS->handler)) |
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 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
|
129 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
130 } |
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_clip(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 doesn't return a clip\n"); |
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 return AVS; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
139 |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
140 avs_err: |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
141 if (AVS->dll) FreeLibrary(AVS->dll); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
142 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
143 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
144 #endif |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
145 free(AVS); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
146 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
147 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
148 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
149 /* Implement RGB MODES ?? */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
150 #if 0 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
151 static __inline int get_mmioFOURCC(const AVS_VideoInfo *v) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
152 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
160 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
161 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
162 |
16175 | 163 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
|
164 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
165 AVS_VideoFrame *curr_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
166 demux_packet_t *dp = NULL; |
22428 | 167 AVS_T *AVS = demuxer->priv; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
168 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
169 if (ds == demuxer->video) |
19213
606d2f7cd307
Move more stuff under if (avs_has_video... to simplify later patches.
reimar
parents:
19212
diff
changeset
|
170 { |
22422 | 171 sh_video_t *sh_video = demuxer->video->sh; |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
172 char *dst; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
173 int w, h; |
22431
0cf22436ef75
Already frameno == num_frames means we reached EOF.
reimar
parents:
22430
diff
changeset
|
174 if (AVS->video_info->num_frames <= AVS->frameno) return 0; // EOF |
19214 | 175 |
176 curr_frame = AVS->avs_get_frame(AVS->clip, AVS->frameno); | |
177 if (!curr_frame) | |
178 { | |
179 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: error getting frame -- EOF??\n"); | |
180 return 0; | |
181 } | |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
182 w = curr_frame->row_size; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
183 h = curr_frame->height; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
184 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
185 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
|
186 |
19212 | 187 dp->pts=AVS->frameno / sh_video->fps; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
188 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
189 dst = dp->buffer; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
190 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
|
191 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
|
192 dst += w * h; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
193 w /= 2; h /= 2; |
19219 | 194 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
|
195 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
|
196 dst += w * h; |
19219 | 197 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
|
198 w, h, w, curr_frame->pitchUV); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
199 ds_add_packet(demuxer->video, dp); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
200 |
19214 | 201 AVS->frameno++; |
202 AVS->avs_release_video_frame(curr_frame); | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
203 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
204 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
205 /* Audio */ |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
206 if (ds == demuxer->audio) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
207 { |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
208 sh_audio_t *sh_audio = ds->sh; |
22420 | 209 int samples = sh_audio->samplerate; |
22427 | 210 uint64_t l; |
211 samples = FFMIN(samples, AVS->video_info->num_audio_samples - AVS->sampleno); | |
212 if (!samples) return 0; | |
213 l = samples * sh_audio->channels * sh_audio->samplesize; | |
22420 | 214 if (l > INT_MAX) { |
22426 | 215 mp_msg(MSGT_DEMUX, MSGL_FATAL, "AVS: audio packet too big\n"); |
22420 | 216 return 0; |
217 } | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
218 dp = new_demux_packet(l); |
22432 | 219 dp->pts = AVS->sampleno / sh_audio->samplerate; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
220 |
22420 | 221 if (AVS->avs_get_audio(AVS->clip, dp->buffer, AVS->sampleno, samples)) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
222 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
223 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
|
224 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
225 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
226 ds_add_packet(demuxer->audio, dp); |
22420 | 227 |
228 AVS->sampleno += samples; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
229 } |
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; |
22428 | 237 AVS_T *AVS = demuxer->priv; |
22429
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
238 int audio_samplesize = 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
239 AVS->frameno = 0; |
22420 | 240 AVS->sampleno = 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
241 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
242 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
|
243 demuxer->seekable = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
244 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
245 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
|
246 if(!AVS->clip) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
247 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
248 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 249 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
250 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
251 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
252 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
|
253 if (!AVS->video_info) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
254 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
255 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 256 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
257 } |
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 if (!avs_is_yv12(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
260 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
261 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
|
262 if (avs_is_error(AVS->handler)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
263 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
264 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Cannot convert input video to YV12: %s\n", avs_as_string(AVS->handler)); |
16175 | 265 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
266 } |
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 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
|
269 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
270 if(!AVS->clip) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
271 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
272 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 273 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
274 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
275 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
276 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
|
277 if (!AVS->video_info) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
278 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
279 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 280 return NULL; |
14693
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 } |
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 // TODO check field-based ?? |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
285 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
286 /* Video */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
287 if (avs_has_video(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
288 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
289 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
|
290 found = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
291 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
292 if (demuxer->video->id == -1) demuxer->video->id = 0; |
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
293 if (demuxer->video->id == 0) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
294 demuxer->video->sh = sh_video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
295 sh_video->ds = demuxer->video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
296 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
297 sh_video->disp_w = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
298 sh_video->disp_h = AVS->video_info->height; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
299 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
300 //sh_video->format = get_mmioFOURCC(AVS->video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
301 sh_video->format = mmioFOURCC('Y', 'V', '1', '2'); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
302 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
|
303 sh_video->frametime = 1.0 / sh_video->fps; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
304 |
22428 | 305 sh_video->bih = malloc(sizeof(BITMAPINFOHEADER) + (256 * 4)); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
306 sh_video->bih->biCompression = sh_video->format; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
307 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
|
308 //sh_video->bih->biPlanes = 2; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
309 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
310 sh_video->bih->biWidth = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
311 sh_video->bih->biHeight = AVS->video_info->height; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
312 sh_video->num_frames = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
313 sh_video->num_frames_decoded = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
314 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
315 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
316 /* Audio */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
317 if (avs_has_audio(AVS->video_info)) |
22429
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
318 switch (AVS->video_info->sample_type) { |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
319 case AVS_SAMPLE_INT8: audio_samplesize = 1; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
320 case AVS_SAMPLE_INT16: audio_samplesize = 2; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
321 case AVS_SAMPLE_INT24: audio_samplesize = 3; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
322 case AVS_SAMPLE_INT32: |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
323 case AVS_SAMPLE_FLOAT: audio_samplesize = 4; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
324 default: |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
325 mp_msg(MSGT_DEMUX, MSGL_ERR, "AVS: unknown audio type, disabling\n"); |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
326 } |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
327 if (audio_samplesize) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
328 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
329 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
|
330 found = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
331 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
|
332 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
333 if (demuxer->audio->id == -1) demuxer->audio->id = 0; |
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
334 if (demuxer->audio->id == 0) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
335 demuxer->audio->sh = sh_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
336 sh_audio->ds = demuxer->audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
337 |
22428 | 338 sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); |
22425
dacdd07fec16
Set format tag for float samples correctly (currently useless)
reimar
parents:
22422
diff
changeset
|
339 sh_audio->wf->wFormatTag = sh_audio->format = |
dacdd07fec16
Set format tag for float samples correctly (currently useless)
reimar
parents:
22422
diff
changeset
|
340 (AVS->video_info->sample_type == AVS_SAMPLE_FLOAT) ? 0x3 : 0x1; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
341 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
|
342 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate = AVS->video_info->audio_samples_per_second; |
22429
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
343 sh_audio->samplesize = audio_samplesize; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
344 sh_audio->wf->nAvgBytesPerSec = sh_audio->channels * sh_audio->samplesize * sh_audio->samplerate; |
22420 | 345 sh_audio->wf->nBlockAlign = sh_audio->channels * sh_audio->samplesize; |
346 sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
347 sh_audio->wf->cbSize = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
348 sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
349 } |
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 AVS->init = 1; |
16175 | 352 if (found) |
353 return demuxer; | |
354 else | |
355 return NULL; | |
14693
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 |
16175 | 358 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
|
359 { |
22422 | 360 sh_video_t *sh_video=demuxer->video->sh; |
22430
1c12f4697cec
Fix crash with avisynth audio-only files and take audio length into account when length is queried.
reimar
parents:
22429
diff
changeset
|
361 sh_audio_t *sh_audio=demuxer->audio->sh; |
22428 | 362 AVS_T *AVS = demuxer->priv; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
363 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
364 switch(cmd) |
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 case DEMUXER_CTRL_GET_TIME_LENGTH: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
367 { |
22430
1c12f4697cec
Fix crash with avisynth audio-only files and take audio length into account when length is queried.
reimar
parents:
22429
diff
changeset
|
368 double res = sh_video ? (double)AVS->video_info->num_frames / sh_video->fps : 0; |
1c12f4697cec
Fix crash with avisynth audio-only files and take audio length into account when length is queried.
reimar
parents:
22429
diff
changeset
|
369 if (sh_audio) |
1c12f4697cec
Fix crash with avisynth audio-only files and take audio length into account when length is queried.
reimar
parents:
22429
diff
changeset
|
370 res = FFMAX(res, (double)AVS->video_info->num_audio_samples / sh_audio->samplerate); |
1c12f4697cec
Fix crash with avisynth audio-only files and take audio length into account when length is queried.
reimar
parents:
22429
diff
changeset
|
371 *((double *)arg) = res; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
372 return DEMUXER_CTRL_OK; |
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 case DEMUXER_CTRL_GET_PERCENT_POS: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
375 { |
22447 | 376 if (sh_video) |
22446 | 377 *((int *)arg) = AVS->frameno * 100 / AVS->video_info->num_frames; |
22447 | 378 else |
379 *((int *)arg) = AVS->sampleno * 100 / AVS->video_info->num_audio_samples; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
380 return DEMUXER_CTRL_OK; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
381 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
382 default: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
383 return DEMUXER_CTRL_NOTIMPL; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
384 } |
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 |
16175 | 387 static void demux_close_avs(demuxer_t* demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
388 { |
22428 | 389 AVS_T *AVS = 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
|
390 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
391 if (AVS) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
392 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
393 if (AVS->dll) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
394 { |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
395 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
|
396 AVS->avs_release_clip(AVS->clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
397 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
|
398 FreeLibrary(AVS->dll); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
399 } |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
400 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
401 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
402 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
403 free(AVS); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
404 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
405 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
406 |
17636 | 407 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
|
408 { |
22434
a7438b68f5d5
Remove variable that is unnecessary after last patch
reimar
parents:
22433
diff
changeset
|
409 sh_video_t *sh_video=demuxer->video->sh; |
22448 | 410 sh_audio_t *sh_audio=demuxer->audio->sh; |
22428 | 411 AVS_T *AVS = demuxer->priv; |
22448 | 412 double video_pos = sh_video ? |
413 (double)AVS->frameno / sh_video->fps : | |
414 (double)AVS->sampleno / sh_audio->samplerate; | |
22449 | 415 double duration = sh_video ? |
416 (double)AVS->video_info->num_frames / sh_video->fps : | |
417 (double)AVS->video_info->num_audio_samples / sh_audio->samplerate; | |
14693
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: 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
|
420 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
421 // seek absolute |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
422 if (flags&1) video_pos=0; |
22449 | 423 // seek precent |
424 if (flags&2) rel_seek_secs *= duration; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
425 |
22448 | 426 video_pos += rel_seek_secs; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
427 if (video_pos < 0) video_pos = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
428 |
22448 | 429 if (sh_video) { |
430 AVS->frameno = FFMIN(video_pos * sh_video->fps, | |
431 AVS->video_info->num_frames); | |
432 sh_video->num_frames_decoded = AVS->frameno; | |
433 sh_video->num_frames = AVS->frameno; | |
434 } | |
435 if (sh_audio) | |
436 AVS->sampleno = FFMIN(video_pos * sh_audio->samplerate, | |
437 AVS->video_info->num_audio_samples); | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
438 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
439 |
16175 | 440 static int avs_check_file(demuxer_t *demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
441 { |
16175 | 442 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
|
443 |
16175 | 444 if (!demuxer->filename) return 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
445 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
446 /* Avoid crazy memory eating when passing an mpg stream */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
447 if (demuxer->movi_end > MAX_AVS_SIZE) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
448 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
449 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
|
450 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
451 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
452 |
16175 | 453 demuxer->priv = initAVS(demuxer->filename); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
454 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
455 if (demuxer->priv) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
456 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
457 mp_msg(MSGT_DEMUX,MSGL_V, "AVS: Init Ok\n"); |
16175 | 458 return DEMUXER_TYPE_AVS; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
459 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
460 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
|
461 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
462 } |
16175 | 463 |
464 | |
465 demuxer_desc_t demuxer_desc_avs = { | |
466 "Avisynth demuxer", | |
467 "avs", | |
468 "AVS", | |
469 "Gianluigi Tiesi", | |
470 "Requires binary dll", | |
471 DEMUXER_TYPE_AVS, | |
472 0, // unsafe autodetect | |
473 avs_check_file, | |
474 demux_avs_fill_buffer, | |
475 demux_open_avs, | |
476 demux_close_avs, | |
477 demux_seek_avs, | |
478 demux_avs_control | |
479 }; |