Mercurial > mplayer.hg
annotate libmpdemux/demux_avs.c @ 28921:62f0032e736a
Get rid of pointless preprocessor condition indirection and use ARCH_X86
directly instead of CAN_COMPILE_X86_ASM.
author | diego |
---|---|
date | Sun, 15 Mar 2009 10:01:02 +0000 |
parents | 34d3e0c8487a |
children | 0f1b5b68af32 |
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 * |
27582
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
5 * This file is part of MPlayer. |
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
6 * |
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
7 * MPlayer is free software; you can redistribute it and/or |
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
27582
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
11 * |
27582
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
12 * MPlayer is distributed in the hope that it will be useful, |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
13 * 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
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27582
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
15 * Lesser General Public License for more details. |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
16 * |
27582
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public License |
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
18 * along with MPlayer; if not, write to the Free Software Foundation, Inc., |
34d3e0c8487a
Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents:
26473
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
22 #include <stdio.h> |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
23 #include <stdlib.h> |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
24 #include <unistd.h> |
22420 | 25 #include <limits.h> |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
26 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
27 #include "config.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
28 #include "mp_msg.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
29 #include "help_mp.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
30 |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22450
diff
changeset
|
31 #include "stream/stream.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
32 #include "demuxer.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
33 #include "stheader.h" |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
34 #include "libvo/fastmemcpy.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
35 |
22606
97343cedd966
Use explicit path for headers from the loader/ directory.
diego
parents:
22605
diff
changeset
|
36 #include "loader/wine/windef.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
37 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
38 #ifdef WIN32_LOADER |
22606
97343cedd966
Use explicit path for headers from the loader/ directory.
diego
parents:
22605
diff
changeset
|
39 #include "loader/ldt_keeper.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
40 #endif |
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 #include "demux_avs.h" |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
43 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
44 #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
|
45 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
46 HMODULE WINAPI LoadLibraryA(LPCSTR); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
47 FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
48 int WINAPI FreeLibrary(HMODULE); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
49 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 typedef WINAPI void (*imp_avs_release_video_frame)(AVS_VideoFrame *); |
22414 | 57 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
|
58 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
59 #define Q(string) # string |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
60 #define IMPORT_FUNC(x) \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
61 AVS->x = ( imp_##x ) GetProcAddress(AVS->dll, Q(x)); \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
62 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
|
63 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
64 typedef struct tagAVS |
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 AVS_ScriptEnvironment *avs_env; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
67 AVS_Value handler; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
68 AVS_Clip *clip; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
69 const AVS_VideoInfo *video_info; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
70 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
71 ldt_fs_t* ldt_fs; |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
72 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
73 HMODULE dll; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
74 int frameno; |
22420 | 75 uint64_t sampleno; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
76 int init; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
77 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
78 imp_avs_create_script_environment avs_create_script_environment; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
79 imp_avs_invoke avs_invoke; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
80 imp_avs_get_video_info avs_get_video_info; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
81 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
|
82 imp_avs_release_clip avs_release_clip; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
83 imp_avs_get_frame avs_get_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
84 imp_avs_release_video_frame avs_release_video_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
85 imp_avs_get_audio avs_get_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
86 } AVS_T; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
87 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
88 AVS_T *initAVS(const char *filename) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
89 { |
22428 | 90 AVS_T *AVS = malloc (sizeof(AVS_T)); |
14695 | 91 AVS_Value arg0 = avs_new_value_string(filename); |
92 AVS_Value args = avs_new_value_array(&arg0, 1); | |
93 | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
94 memset(AVS, 0, sizeof(AVS_T)); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
95 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
96 #ifdef WIN32_LOADER |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
97 AVS->ldt_fs = Setup_LDT_Keeper(); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
98 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
99 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
100 AVS->dll = LoadLibraryA("avisynth.dll"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
101 if(!AVS->dll) |
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 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
|
104 goto avs_err; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
107 /* Dynamic import of needed stuff from avisynth.dll */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
108 IMPORT_FUNC(avs_create_script_environment); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
109 IMPORT_FUNC(avs_invoke); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
110 IMPORT_FUNC(avs_get_video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
111 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
|
112 IMPORT_FUNC(avs_release_clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
113 IMPORT_FUNC(avs_get_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
114 IMPORT_FUNC(avs_release_video_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
115 IMPORT_FUNC(avs_get_audio); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
116 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
117 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
|
118 if (!AVS->avs_env) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
119 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
120 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
|
121 goto avs_err; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
125 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
|
126 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
127 if (avs_is_error(AVS->handler)) |
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 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
|
130 goto avs_err; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
133 if (!avs_is_clip(AVS->handler)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
134 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
135 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
|
136 goto avs_err; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
139 return AVS; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
140 |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
141 avs_err: |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
142 if (AVS->dll) FreeLibrary(AVS->dll); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
143 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
144 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
145 #endif |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
146 free(AVS); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
147 return NULL; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
150 /* Implement RGB MODES ?? */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
151 #if 0 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
152 static __inline int get_mmioFOURCC(const AVS_VideoInfo *v) |
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 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 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
|
160 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
161 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
162 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
163 |
16175 | 164 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
|
165 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
166 AVS_VideoFrame *curr_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
167 demux_packet_t *dp = NULL; |
22428 | 168 AVS_T *AVS = demuxer->priv; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
169 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
170 if (ds == demuxer->video) |
19213
606d2f7cd307
Move more stuff under if (avs_has_video... to simplify later patches.
reimar
parents:
19212
diff
changeset
|
171 { |
22422 | 172 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
|
173 char *dst; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
174 int w, h; |
22431
0cf22436ef75
Already frameno == num_frames means we reached EOF.
reimar
parents:
22430
diff
changeset
|
175 if (AVS->video_info->num_frames <= AVS->frameno) return 0; // EOF |
19214 | 176 |
177 curr_frame = AVS->avs_get_frame(AVS->clip, AVS->frameno); | |
178 if (!curr_frame) | |
179 { | |
180 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: error getting frame -- EOF??\n"); | |
181 return 0; | |
182 } | |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
183 w = curr_frame->row_size; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
184 h = curr_frame->height; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
185 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
186 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
|
187 |
19212 | 188 dp->pts=AVS->frameno / sh_video->fps; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
189 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
190 dst = dp->buffer; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
191 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
|
192 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
|
193 dst += w * h; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
194 w /= 2; h /= 2; |
19219 | 195 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
|
196 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
|
197 dst += w * h; |
19219 | 198 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
|
199 w, h, w, curr_frame->pitchUV); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
200 ds_add_packet(demuxer->video, dp); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
201 |
19214 | 202 AVS->frameno++; |
203 AVS->avs_release_video_frame(curr_frame); | |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
206 /* Audio */ |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
207 if (ds == demuxer->audio) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
208 { |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
209 sh_audio_t *sh_audio = ds->sh; |
22420 | 210 int samples = sh_audio->samplerate; |
22427 | 211 uint64_t l; |
212 samples = FFMIN(samples, AVS->video_info->num_audio_samples - AVS->sampleno); | |
213 if (!samples) return 0; | |
214 l = samples * sh_audio->channels * sh_audio->samplesize; | |
22420 | 215 if (l > INT_MAX) { |
22426 | 216 mp_msg(MSGT_DEMUX, MSGL_FATAL, "AVS: audio packet too big\n"); |
22420 | 217 return 0; |
218 } | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
219 dp = new_demux_packet(l); |
22432 | 220 dp->pts = AVS->sampleno / sh_audio->samplerate; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
221 |
22420 | 222 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
|
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); |
22420 | 228 |
229 AVS->sampleno += samples; | |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
232 return 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
233 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
234 |
16175 | 235 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
|
236 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
237 int found = 0; |
22428 | 238 AVS_T *AVS = demuxer->priv; |
22429
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
239 int audio_samplesize = 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
240 AVS->frameno = 0; |
22420 | 241 AVS->sampleno = 0; |
14693
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 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
|
244 demuxer->seekable = 1; |
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 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
|
247 if(!AVS->clip) |
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 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 250 return NULL; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
253 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
|
254 if (!AVS->video_info) |
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 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 257 return NULL; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
260 if (!avs_is_yv12(AVS->video_info)) |
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 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
|
263 if (avs_is_error(AVS->handler)) |
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 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Cannot convert input video to YV12: %s\n", avs_as_string(AVS->handler)); |
16175 | 266 return NULL; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
269 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
|
270 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
271 if(!AVS->clip) |
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 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 274 return NULL; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
277 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
|
278 if (!AVS->video_info) |
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 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 281 return NULL; |
14693
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
285 // TODO check field-based ?? |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
286 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
287 /* Video */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
288 if (avs_has_video(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
289 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
290 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
|
291 found = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
292 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
293 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
|
294 if (demuxer->video->id == 0) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
295 demuxer->video->sh = sh_video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
296 sh_video->ds = demuxer->video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
297 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
298 sh_video->disp_w = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
299 sh_video->disp_h = AVS->video_info->height; |
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->format = get_mmioFOURCC(AVS->video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
302 sh_video->format = mmioFOURCC('Y', 'V', '1', '2'); |
26472
67930b46705d
Calculate fps as double-precision to make switching to double-precision fps values easier.
reimar
parents:
25883
diff
changeset
|
303 sh_video->fps = (double) AVS->video_info->fps_numerator / (double) AVS->video_info->fps_denominator; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
304 sh_video->frametime = 1.0 / sh_video->fps; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
305 |
22428 | 306 sh_video->bih = malloc(sizeof(BITMAPINFOHEADER) + (256 * 4)); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
307 sh_video->bih->biCompression = sh_video->format; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
308 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
|
309 //sh_video->bih->biPlanes = 2; |
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 sh_video->bih->biWidth = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
312 sh_video->bih->biHeight = AVS->video_info->height; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
313 sh_video->num_frames = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
314 sh_video->num_frames_decoded = 0; |
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
317 /* Audio */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
318 if (avs_has_audio(AVS->video_info)) |
22429
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
319 switch (AVS->video_info->sample_type) { |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
320 case AVS_SAMPLE_INT8: audio_samplesize = 1; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
321 case AVS_SAMPLE_INT16: audio_samplesize = 2; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
322 case AVS_SAMPLE_INT24: audio_samplesize = 3; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
323 case AVS_SAMPLE_INT32: |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
324 case AVS_SAMPLE_FLOAT: audio_samplesize = 4; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
325 default: |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
326 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
|
327 } |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
328 if (audio_samplesize) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
329 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
330 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
|
331 found = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
332 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
|
333 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
334 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
|
335 if (demuxer->audio->id == 0) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
336 demuxer->audio->sh = sh_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
337 sh_audio->ds = demuxer->audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
338 |
22428 | 339 sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); |
22425
dacdd07fec16
Set format tag for float samples correctly (currently useless)
reimar
parents:
22422
diff
changeset
|
340 sh_audio->wf->wFormatTag = sh_audio->format = |
dacdd07fec16
Set format tag for float samples correctly (currently useless)
reimar
parents:
22422
diff
changeset
|
341 (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
|
342 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
|
343 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
|
344 sh_audio->samplesize = audio_samplesize; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
345 sh_audio->wf->nAvgBytesPerSec = sh_audio->channels * sh_audio->samplesize * sh_audio->samplerate; |
22420 | 346 sh_audio->wf->nBlockAlign = sh_audio->channels * sh_audio->samplesize; |
347 sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
348 sh_audio->wf->cbSize = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
349 sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; |
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 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
352 AVS->init = 1; |
16175 | 353 if (found) |
354 return demuxer; | |
355 else | |
356 return NULL; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
357 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
358 |
16175 | 359 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
|
360 { |
22422 | 361 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
|
362 sh_audio_t *sh_audio=demuxer->audio->sh; |
22428 | 363 AVS_T *AVS = demuxer->priv; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
364 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
365 switch(cmd) |
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 case DEMUXER_CTRL_GET_TIME_LENGTH: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
368 { |
22430
1c12f4697cec
Fix crash with avisynth audio-only files and take audio length into account when length is queried.
reimar
parents:
22429
diff
changeset
|
369 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
|
370 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
|
371 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
|
372 *((double *)arg) = res; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
373 return DEMUXER_CTRL_OK; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
374 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
375 case DEMUXER_CTRL_GET_PERCENT_POS: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
376 { |
22447 | 377 if (sh_video) |
22446 | 378 *((int *)arg) = AVS->frameno * 100 / AVS->video_info->num_frames; |
22447 | 379 else |
380 *((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
|
381 return DEMUXER_CTRL_OK; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
382 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
383 default: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
384 return DEMUXER_CTRL_NOTIMPL; |
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 |
16175 | 388 static void demux_close_avs(demuxer_t* demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
389 { |
22428 | 390 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
|
391 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
392 if (AVS) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
393 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
394 if (AVS->dll) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
395 { |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
396 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
|
397 AVS->avs_release_clip(AVS->clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
398 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
|
399 FreeLibrary(AVS->dll); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
400 } |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
401 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
402 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
403 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
404 free(AVS); |
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 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
407 |
17636 | 408 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
|
409 { |
22434
a7438b68f5d5
Remove variable that is unnecessary after last patch
reimar
parents:
22433
diff
changeset
|
410 sh_video_t *sh_video=demuxer->video->sh; |
22448 | 411 sh_audio_t *sh_audio=demuxer->audio->sh; |
22428 | 412 AVS_T *AVS = demuxer->priv; |
22448 | 413 double video_pos = sh_video ? |
414 (double)AVS->frameno / sh_video->fps : | |
415 (double)AVS->sampleno / sh_audio->samplerate; | |
22449 | 416 double duration = sh_video ? |
417 (double)AVS->video_info->num_frames / sh_video->fps : | |
418 (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
|
419 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
420 //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
|
421 |
25883
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
422 if (flags&SEEK_ABSOLUTE) video_pos=0; |
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
423 if (flags&SEEK_FACTOR) rel_seek_secs *= duration; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
424 |
22448 | 425 video_pos += rel_seek_secs; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
426 if (video_pos < 0) video_pos = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
427 |
22448 | 428 if (sh_video) { |
429 AVS->frameno = FFMIN(video_pos * sh_video->fps, | |
430 AVS->video_info->num_frames); | |
431 sh_video->num_frames_decoded = AVS->frameno; | |
432 sh_video->num_frames = AVS->frameno; | |
433 } | |
26473
47864c18ff54
Take audio delay into account when seeking in avisynth demuxer.
reimar
parents:
26472
diff
changeset
|
434 video_pos += audio_delay; |
47864c18ff54
Take audio delay into account when seeking in avisynth demuxer.
reimar
parents:
26472
diff
changeset
|
435 if (video_pos < 0) video_pos = 0; |
22448 | 436 if (sh_audio) |
437 AVS->sampleno = FFMIN(video_pos * sh_audio->samplerate, | |
438 AVS->video_info->num_audio_samples); | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
439 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
440 |
16175 | 441 static int avs_check_file(demuxer_t *demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
442 { |
16175 | 443 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
|
444 |
16175 | 445 if (!demuxer->filename) return 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
446 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
447 /* Avoid crazy memory eating when passing an mpg stream */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
448 if (demuxer->movi_end > MAX_AVS_SIZE) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
449 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
450 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
|
451 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
452 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
453 |
16175 | 454 demuxer->priv = initAVS(demuxer->filename); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
455 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
456 if (demuxer->priv) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
457 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
458 mp_msg(MSGT_DEMUX,MSGL_V, "AVS: Init Ok\n"); |
16175 | 459 return DEMUXER_TYPE_AVS; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
460 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
461 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
|
462 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
463 } |
16175 | 464 |
465 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
22606
diff
changeset
|
466 const demuxer_desc_t demuxer_desc_avs = { |
16175 | 467 "Avisynth demuxer", |
468 "avs", | |
469 "AVS", | |
470 "Gianluigi Tiesi", | |
471 "Requires binary dll", | |
472 DEMUXER_TYPE_AVS, | |
473 0, // unsafe autodetect | |
474 avs_check_file, | |
475 demux_avs_fill_buffer, | |
476 demux_open_avs, | |
477 demux_close_avs, | |
478 demux_seek_avs, | |
479 demux_avs_control | |
480 }; |