Mercurial > mplayer.hg
annotate libmpdemux/demux_avs.c @ 36182:8587ae275646
Rename HAVE_CMOV to HAVE_I686 for FFmpeg.
Keep the cmov name in configure since it is less
confusing, since cmov is what we test for and
also since for example VIA C3 sometimes is considered
i686 that does not implement the optional CMOV
instruction.
author | reimar |
---|---|
date | Fri, 17 May 2013 15:59:38 +0000 |
parents | 958431e2cde0 |
children | 63be95f0e125 |
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 |
31348
8df8a7c20f46
Replace forward declarations by proper loader/wine/winbase.h #include.
diego
parents:
30570
diff
changeset
|
36 #include "loader/wine/winbase.h" |
22606
97343cedd966
Use explicit path for headers from the loader/ directory.
diego
parents:
22605
diff
changeset
|
37 #include "loader/wine/windef.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
38 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
39 #ifdef WIN32_LOADER |
22606
97343cedd966
Use explicit path for headers from the loader/ directory.
diego
parents:
22605
diff
changeset
|
40 #include "loader/ldt_keeper.h" |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
41 #endif |
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 #include "demux_avs.h" |
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 #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
|
46 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 typedef WINAPI void (*imp_avs_release_video_frame)(AVS_VideoFrame *); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
54 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
|
55 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
56 #define Q(string) # string |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
57 #define IMPORT_FUNC(x) \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
58 AVS->x = ( imp_##x ) GetProcAddress(AVS->dll, Q(x)); \ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
59 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
|
60 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
61 typedef struct tagAVS |
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 AVS_ScriptEnvironment *avs_env; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
64 AVS_Value handler; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
65 AVS_Clip *clip; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
66 const AVS_VideoInfo *video_info; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
67 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
68 ldt_fs_t* ldt_fs; |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
69 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
70 HMODULE dll; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
71 int frameno; |
22420 | 72 uint64_t sampleno; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
73 int init; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
74 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
75 imp_avs_create_script_environment avs_create_script_environment; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
76 imp_avs_invoke avs_invoke; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
77 imp_avs_get_video_info avs_get_video_info; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
78 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
|
79 imp_avs_release_clip avs_release_clip; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
80 imp_avs_get_frame avs_get_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
81 imp_avs_release_video_frame avs_release_video_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
82 imp_avs_get_audio avs_get_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
83 } AVS_T; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
84 |
30570
98dc6ae7ede2
libmpdemux: Mark functions not used outside of their files as static.
diego
parents:
29263
diff
changeset
|
85 static AVS_T *initAVS(const char *filename) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
86 { |
22428 | 87 AVS_T *AVS = malloc (sizeof(AVS_T)); |
14695 | 88 AVS_Value arg0 = avs_new_value_string(filename); |
89 AVS_Value args = avs_new_value_array(&arg0, 1); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
90 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
91 memset(AVS, 0, sizeof(AVS_T)); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
92 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
93 #ifdef WIN32_LOADER |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
94 AVS->ldt_fs = Setup_LDT_Keeper(); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
95 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
96 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
97 AVS->dll = LoadLibraryA("avisynth.dll"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
98 if(!AVS->dll) |
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 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
|
101 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
102 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
103 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
104 /* Dynamic import of needed stuff from avisynth.dll */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
105 IMPORT_FUNC(avs_create_script_environment); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
106 IMPORT_FUNC(avs_invoke); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
107 IMPORT_FUNC(avs_get_video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
108 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
|
109 IMPORT_FUNC(avs_release_clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
110 IMPORT_FUNC(avs_get_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
111 IMPORT_FUNC(avs_release_video_frame); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
112 IMPORT_FUNC(avs_get_audio); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
113 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
114 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
|
115 if (!AVS->avs_env) |
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 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
|
118 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
119 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
120 |
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 AVS->handler = AVS->avs_invoke(AVS->avs_env, "Import", args, 0); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
123 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
124 if (avs_is_error(AVS->handler)) |
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 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
|
127 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
128 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
129 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
130 if (!avs_is_clip(AVS->handler)) |
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 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
|
133 goto avs_err; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
134 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
135 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
136 return AVS; |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
137 |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
138 avs_err: |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
139 if (AVS->dll) FreeLibrary(AVS->dll); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
140 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
141 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
142 #endif |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
143 free(AVS); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
144 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
145 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
146 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
147 /* Implement RGB MODES ?? */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
148 #if 0 |
34653 | 149 static inline int get_mmioFOURCC(const AVS_VideoInfo *v) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
150 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 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
|
155 if (avs_is_yuy(v)) return mmioFOURCC('Y', 'U', 'Y', ' '); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
156 if (avs_is_yuy2(v)) return mmioFOURCC('Y', 'U', 'Y', '2'); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
157 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
158 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
159 #endif |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
160 |
16175 | 161 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
|
162 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
163 AVS_VideoFrame *curr_frame; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
164 demux_packet_t *dp = NULL; |
22428 | 165 AVS_T *AVS = demuxer->priv; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
166 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
167 if (ds == demuxer->video) |
19213
606d2f7cd307
Move more stuff under if (avs_has_video... to simplify later patches.
reimar
parents:
19212
diff
changeset
|
168 { |
22422 | 169 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
|
170 char *dst; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
171 int w, h; |
22431
0cf22436ef75
Already frameno == num_frames means we reached EOF.
reimar
parents:
22430
diff
changeset
|
172 if (AVS->video_info->num_frames <= AVS->frameno) return 0; // EOF |
19214 | 173 |
174 curr_frame = AVS->avs_get_frame(AVS->clip, AVS->frameno); | |
175 if (!curr_frame) | |
176 { | |
177 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: error getting frame -- EOF??\n"); | |
178 return 0; | |
179 } | |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
180 w = curr_frame->row_size; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
181 h = curr_frame->height; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
182 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
183 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
|
184 |
19212 | 185 dp->pts=AVS->frameno / sh_video->fps; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
186 |
19218
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
187 dst = dp->buffer; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
188 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
|
189 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
|
190 dst += w * h; |
950f60b90cf5
Handle frames with stride correctly (e.g. the "Version" source of current AVS).
reimar
parents:
19217
diff
changeset
|
191 w /= 2; h /= 2; |
19219 | 192 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
|
193 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
|
194 dst += w * h; |
19219 | 195 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
|
196 w, h, w, curr_frame->pitchUV); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
197 ds_add_packet(demuxer->video, dp); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
198 |
19214 | 199 AVS->frameno++; |
200 AVS->avs_release_video_frame(curr_frame); | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
201 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
202 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
203 /* Audio */ |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
204 if (ds == demuxer->audio) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
205 { |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
206 sh_audio_t *sh_audio = ds->sh; |
22420 | 207 int samples = sh_audio->samplerate; |
22427 | 208 uint64_t l; |
209 samples = FFMIN(samples, AVS->video_info->num_audio_samples - AVS->sampleno); | |
210 if (!samples) return 0; | |
211 l = samples * sh_audio->channels * sh_audio->samplesize; | |
22420 | 212 if (l > INT_MAX) { |
22426 | 213 mp_msg(MSGT_DEMUX, MSGL_FATAL, "AVS: audio packet too big\n"); |
22420 | 214 return 0; |
215 } | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
216 dp = new_demux_packet(l); |
22432 | 217 dp->pts = AVS->sampleno / sh_audio->samplerate; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
218 |
22420 | 219 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
|
220 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
221 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
|
222 return 0; |
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 ds_add_packet(demuxer->audio, dp); |
22420 | 225 |
226 AVS->sampleno += samples; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
227 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
228 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
229 return 1; |
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 |
16175 | 232 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
|
233 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
234 int found = 0; |
22428 | 235 AVS_T *AVS = demuxer->priv; |
22429
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
236 int audio_samplesize = 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
237 AVS->frameno = 0; |
22420 | 238 AVS->sampleno = 0; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
239 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
240 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: demux_open_avs()\n"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
241 demuxer->seekable = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
242 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
243 AVS->clip = AVS->avs_take_clip(AVS->handler, AVS->avs_env); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
244 if(!AVS->clip) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
245 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
246 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 247 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
248 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
249 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
250 AVS->video_info = AVS->avs_get_video_info(AVS->clip); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
251 if (!AVS->video_info) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
252 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
253 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 254 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
255 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
256 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
257 if (!avs_is_yv12(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
258 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
259 AVS->handler = AVS->avs_invoke(AVS->avs_env, "ConvertToYV12", avs_new_value_array(&AVS->handler, 1), 0); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
260 if (avs_is_error(AVS->handler)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
261 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
262 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Cannot convert input video to YV12: %s\n", avs_as_string(AVS->handler)); |
16175 | 263 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
264 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
265 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
266 AVS->clip = AVS->avs_take_clip(AVS->handler, AVS->avs_env); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
267 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
268 if(!AVS->clip) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
269 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
270 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_take_clip() failed\n"); |
16175 | 271 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
272 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
273 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
274 AVS->video_info = AVS->avs_get_video_info(AVS->clip); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
275 if (!AVS->video_info) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
276 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
277 mp_msg(MSGT_DEMUX, MSGL_V, "AVS: avs_get_video_info() call failed\n"); |
16175 | 278 return NULL; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
279 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
280 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
281 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
282 // TODO check field-based ?? |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
283 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
284 /* Video */ |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
285 if (avs_has_video(AVS->video_info)) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
286 { |
19211
f6be1a409147
Move variable declarations to the block level where they are actually used
reimar
parents:
19210
diff
changeset
|
287 sh_video_t *sh_video = new_sh_video(demuxer, 0); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
288 found = 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
289 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
290 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
|
291 if (demuxer->video->id == 0) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
292 demuxer->video->sh = sh_video; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
293 sh_video->ds = demuxer->video; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
294 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
295 sh_video->disp_w = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
296 sh_video->disp_h = AVS->video_info->height; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
297 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
298 //sh_video->format = get_mmioFOURCC(AVS->video_info); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
299 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
|
300 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
|
301 sh_video->frametime = 1.0 / sh_video->fps; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
302 |
32100 | 303 sh_video->bih = malloc(sizeof(*sh_video->bih) + (256 * 4)); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
304 sh_video->bih->biCompression = sh_video->format; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
305 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
|
306 //sh_video->bih->biPlanes = 2; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
307 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
308 sh_video->bih->biWidth = AVS->video_info->width; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
309 sh_video->bih->biHeight = AVS->video_info->height; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
310 sh_video->num_frames = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
311 sh_video->num_frames_decoded = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
312 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
313 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
314 /* Audio */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
315 if (avs_has_audio(AVS->video_info)) |
22429
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
316 switch (AVS->video_info->sample_type) { |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
317 case AVS_SAMPLE_INT8: audio_samplesize = 1; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
318 case AVS_SAMPLE_INT16: audio_samplesize = 2; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
319 case AVS_SAMPLE_INT24: audio_samplesize = 3; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
320 case AVS_SAMPLE_INT32: |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
321 case AVS_SAMPLE_FLOAT: audio_samplesize = 4; break; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
322 default: |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
323 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
|
324 } |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
325 if (audio_samplesize) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
326 { |
31609
cd81fce1f010
Make the stream language an argument to the stream creation function
reimar
parents:
31348
diff
changeset
|
327 sh_audio_t *sh_audio = new_sh_audio(demuxer, 0, NULL); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
328 found = 1; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
329 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
|
330 |
22417
0d507228e65b
Enable aid/vid stream selection, although it is quite useless currently.
reimar
parents:
22414
diff
changeset
|
331 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
|
332 if (demuxer->audio->id == 0) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
333 demuxer->audio->sh = sh_audio; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
334 sh_audio->ds = demuxer->audio; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
335 |
32100 | 336 sh_audio->wf = malloc(sizeof(*sh_audio->wf)); |
22425
dacdd07fec16
Set format tag for float samples correctly (currently useless)
reimar
parents:
22422
diff
changeset
|
337 sh_audio->wf->wFormatTag = sh_audio->format = |
dacdd07fec16
Set format tag for float samples correctly (currently useless)
reimar
parents:
22422
diff
changeset
|
338 (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
|
339 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
|
340 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
|
341 sh_audio->samplesize = audio_samplesize; |
e0c231d90b7c
Support more avisynth audio sample types (untested)
reimar
parents:
22428
diff
changeset
|
342 sh_audio->wf->nAvgBytesPerSec = sh_audio->channels * sh_audio->samplesize * sh_audio->samplerate; |
22420 | 343 sh_audio->wf->nBlockAlign = sh_audio->channels * sh_audio->samplesize; |
344 sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
345 sh_audio->wf->cbSize = 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
346 sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
347 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
348 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
349 AVS->init = 1; |
16175 | 350 if (found) |
351 return demuxer; | |
352 else | |
353 return NULL; | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
354 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
355 |
16175 | 356 static int demux_avs_control(demuxer_t *demuxer, int cmd, void *arg) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
357 { |
22422 | 358 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
|
359 sh_audio_t *sh_audio=demuxer->audio->sh; |
22428 | 360 AVS_T *AVS = demuxer->priv; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
361 |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
362 switch(cmd) |
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 case DEMUXER_CTRL_GET_TIME_LENGTH: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
365 { |
22430
1c12f4697cec
Fix crash with avisynth audio-only files and take audio length into account when length is queried.
reimar
parents:
22429
diff
changeset
|
366 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
|
367 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
|
368 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
|
369 *((double *)arg) = res; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
370 return DEMUXER_CTRL_OK; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
371 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
372 case DEMUXER_CTRL_GET_PERCENT_POS: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
373 { |
22447 | 374 if (sh_video) |
22446 | 375 *((int *)arg) = AVS->frameno * 100 / AVS->video_info->num_frames; |
22447 | 376 else |
377 *((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
|
378 return DEMUXER_CTRL_OK; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
379 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
380 default: |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
381 return DEMUXER_CTRL_NOTIMPL; |
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 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
384 |
16175 | 385 static void demux_close_avs(demuxer_t* demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
386 { |
22428 | 387 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
|
388 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
389 if (AVS) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
390 { |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
391 if (AVS->dll) |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
392 { |
19210
bef4df2fa6c6
call av_release_clip at uninit, part of a patch by Gianluigi Tiesi <mplayer at netfarm it>
reimar
parents:
17636
diff
changeset
|
393 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
|
394 AVS->avs_release_clip(AVS->clip); |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
395 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
|
396 FreeLibrary(AVS->dll); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
397 } |
15613
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
398 #ifdef WIN32_LOADER |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
399 Restore_LDT_Keeper(AVS->ldt_fs); |
5b57ccc4b640
memory leak fixes, patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
15298
diff
changeset
|
400 #endif |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
401 free(AVS); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
402 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
403 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
404 |
17636 | 405 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
|
406 { |
22434
a7438b68f5d5
Remove variable that is unnecessary after last patch
reimar
parents:
22433
diff
changeset
|
407 sh_video_t *sh_video=demuxer->video->sh; |
22448 | 408 sh_audio_t *sh_audio=demuxer->audio->sh; |
22428 | 409 AVS_T *AVS = demuxer->priv; |
22448 | 410 double video_pos = sh_video ? |
411 (double)AVS->frameno / sh_video->fps : | |
412 (double)AVS->sampleno / sh_audio->samplerate; | |
22449 | 413 double duration = sh_video ? |
414 (double)AVS->video_info->num_frames / sh_video->fps : | |
415 (double)AVS->video_info->num_audio_samples / sh_audio->samplerate; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
416 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
417 //mp_msg(MSGT_DEMUX, MSGL_V, "AVS: seek rel_seek_secs = %f - flags = %x\n", rel_seek_secs, flags); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
418 |
25883
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
419 if (flags&SEEK_ABSOLUTE) video_pos=0; |
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
420 if (flags&SEEK_FACTOR) rel_seek_secs *= duration; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
421 |
22448 | 422 video_pos += rel_seek_secs; |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
423 if (video_pos < 0) video_pos = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
424 |
22448 | 425 if (sh_video) { |
426 AVS->frameno = FFMIN(video_pos * sh_video->fps, | |
427 AVS->video_info->num_frames); | |
428 sh_video->num_frames_decoded = AVS->frameno; | |
429 sh_video->num_frames = AVS->frameno; | |
430 } | |
26473
47864c18ff54
Take audio delay into account when seeking in avisynth demuxer.
reimar
parents:
26472
diff
changeset
|
431 video_pos += audio_delay; |
47864c18ff54
Take audio delay into account when seeking in avisynth demuxer.
reimar
parents:
26472
diff
changeset
|
432 if (video_pos < 0) video_pos = 0; |
22448 | 433 if (sh_audio) |
434 AVS->sampleno = FFMIN(video_pos * sh_audio->samplerate, | |
435 AVS->video_info->num_audio_samples); | |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
436 } |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
437 |
16175 | 438 static int avs_check_file(demuxer_t *demuxer) |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
439 { |
16175 | 440 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
|
441 |
16175 | 442 if (!demuxer->filename) return 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
443 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
444 /* Avoid crazy memory eating when passing an mpg stream */ |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
445 if (demuxer->movi_end > MAX_AVS_SIZE) |
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 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
|
448 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
449 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
450 |
16175 | 451 demuxer->priv = initAVS(demuxer->filename); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27582
diff
changeset
|
452 |
14693
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
453 if (demuxer->priv) |
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 mp_msg(MSGT_DEMUX,MSGL_V, "AVS: Init Ok\n"); |
16175 | 456 return DEMUXER_TYPE_AVS; |
14693
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 failed\n"); |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
459 return 0; |
37116118ab6a
avisynth demuxer patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
diff
changeset
|
460 } |
16175 | 461 |
462 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
22606
diff
changeset
|
463 const demuxer_desc_t demuxer_desc_avs = { |
16175 | 464 "Avisynth demuxer", |
465 "avs", | |
466 "AVS", | |
467 "Gianluigi Tiesi", | |
468 "Requires binary dll", | |
469 DEMUXER_TYPE_AVS, | |
470 0, // unsafe autodetect | |
471 avs_check_file, | |
472 demux_avs_fill_buffer, | |
473 demux_open_avs, | |
474 demux_close_avs, | |
475 demux_seek_avs, | |
476 demux_avs_control | |
477 }; |