Mercurial > libavformat.hg
annotate asf-enc.c @ 1191:976a91cec1ad libavformat
add error messages
author | bcoudurier |
---|---|
date | Fri, 28 Jul 2006 22:53:15 +0000 |
parents | 6a5e58d2114b |
children | 0a74030d9dd7 |
rev | line source |
---|---|
0 | 1 /* |
372
2e12cd1b68ed
split asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
370
diff
changeset
|
2 * Adaptive stream format encoder |
0 | 3 * Copyright (c) 2000, 2001 Fabrice Bellard. |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 */ |
19 #include "avformat.h" | |
1172
6a5e58d2114b
move common stuff from avienc.c and wav.c to new file riff.c
mru
parents:
1169
diff
changeset
|
20 #include "riff.h" |
372
2e12cd1b68ed
split asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
370
diff
changeset
|
21 #include "asf.h" |
0 | 22 |
348 | 23 #undef NDEBUG |
24 #include <assert.h> | |
25 | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
26 |
887 | 27 #define ASF_INDEXED_INTERVAL 10000000 |
28 #define ASF_INDEX_BLOCK 600 | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
29 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
30 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
31 #define ASF_PACKET_ERROR_CORRECTION_FLAGS (\ |
887 | 32 ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \ |
33 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE\ | |
34 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
35 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
36 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
37 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
38 #else |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
39 # define ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
40 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
41 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
42 #define ASF_PPI_PROPERTY_FLAGS (\ |
887 | 43 ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \ |
44 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \ | |
45 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \ | |
46 ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE \ | |
47 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
48 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
49 #define ASF_PPI_LENGTH_TYPE_FLAGS 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
50 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
51 #define ASF_PAYLOAD_FLAGS ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
52 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
53 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
54 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
55 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
56 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
57 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
58 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
59 #if (ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_SEQUENCE_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
60 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
61 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
62 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
63 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
64 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
65 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
66 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
67 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
68 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
69 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
70 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
71 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
72 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
73 #if (ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
74 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
75 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
76 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
77 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
78 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
79 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
80 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
81 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
82 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
83 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
84 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
85 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
86 #if (ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD == (ASF_PPI_LENGTH_TYPE_FLAGS & ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
87 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
88 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
89 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
90 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
91 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
92 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
93 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
94 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
95 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
96 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
97 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
98 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
99 #if (ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
100 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 4 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
101 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
102 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
103 # define ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
104 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
105 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
106 #if (ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
107 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
108 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
109 #if (ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
110 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
111 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
112 #if (ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
113 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 4 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
114 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
115 #ifndef ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
116 # define ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
117 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
118 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
119 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
120 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
121 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
122 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
123 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
124 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
125 #if (ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD == (ASF_PPI_PROPERTY_FLAGS & ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
126 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 4 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
127 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
128 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
129 # define ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
130 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
131 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
132 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
133 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
134 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
135 #if (ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD == (ASF_PAYLOAD_FLAGS & ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
136 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
137 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
138 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
139 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
140 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
141 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
142 #define PACKET_HEADER_MIN_SIZE (\ |
887 | 143 ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \ |
144 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \ | |
145 1 + /*Length Type Flags*/ \ | |
146 1 + /*Property Flags*/ \ | |
147 ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \ | |
148 ASF_PPI_SEQUENCE_FIELD_SIZE + \ | |
149 ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \ | |
150 4 + /*Send Time Field*/ \ | |
151 2 /*Duration Field*/ \ | |
152 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
153 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
154 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
155 // Replicated Data shall be at least 8 bytes long. |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
156 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
157 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
158 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD (\ |
887 | 159 1 + /*Stream Number*/ \ |
160 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \ | |
161 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \ | |
162 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \ | |
163 ASF_PAYLOAD_REPLICATED_DATA_LENGTH \ | |
164 ) | |
885 | 165 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
166 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS (\ |
887 | 167 1 + /*Stream Number*/ \ |
168 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \ | |
169 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \ | |
170 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \ | |
171 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \ | |
172 ASF_PAYLOAD_LENGTH_FIELD_SIZE \ | |
173 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
174 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
175 #define SINGLE_PAYLOAD_DATA_LENGTH (\ |
887 | 176 PACKET_SIZE - \ |
177 PACKET_HEADER_MIN_SIZE - \ | |
178 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \ | |
179 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
180 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
181 #define MULTI_PAYLOAD_CONSTANT (\ |
887 | 182 PACKET_SIZE - \ |
183 PACKET_HEADER_MIN_SIZE - \ | |
184 1 - /*Payload Flags*/ \ | |
185 2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \ | |
186 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
187 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
188 static int preroll_time = 2000; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
189 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
190 static const uint8_t error_spread_ADPCM_G726[] = { 0x01, 0x90, 0x01, 0x90, 0x01, 0x01, 0x00, 0x00 }; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
191 |
0 | 192 static void put_guid(ByteIOContext *s, const GUID *g) |
193 { | |
194 int i; | |
195 | |
196 put_le32(s, g->v1); | |
197 put_le16(s, g->v2); | |
198 put_le16(s, g->v3); | |
199 for(i=0;i<8;i++) | |
200 put_byte(s, g->v4[i]); | |
201 } | |
202 | |
203 static void put_str16(ByteIOContext *s, const char *tag) | |
204 { | |
205 int c; | |
206 | |
207 put_le16(s,strlen(tag) + 1); | |
208 for(;;) { | |
65 | 209 c = (uint8_t)*tag++; |
0 | 210 put_le16(s, c); |
211 if (c == '\0') | |
212 break; | |
213 } | |
214 } | |
215 | |
216 static void put_str16_nolen(ByteIOContext *s, const char *tag) | |
217 { | |
218 int c; | |
219 | |
220 for(;;) { | |
65 | 221 c = (uint8_t)*tag++; |
0 | 222 put_le16(s, c); |
223 if (c == '\0') | |
224 break; | |
225 } | |
226 } | |
227 | |
65 | 228 static int64_t put_header(ByteIOContext *pb, const GUID *g) |
0 | 229 { |
65 | 230 int64_t pos; |
0 | 231 |
232 pos = url_ftell(pb); | |
233 put_guid(pb, g); | |
234 put_le64(pb, 24); | |
235 return pos; | |
236 } | |
237 | |
238 /* update header size */ | |
65 | 239 static void end_header(ByteIOContext *pb, int64_t pos) |
0 | 240 { |
65 | 241 int64_t pos1; |
0 | 242 |
243 pos1 = url_ftell(pb); | |
244 url_fseek(pb, pos + 16, SEEK_SET); | |
245 put_le64(pb, pos1 - pos); | |
246 url_fseek(pb, pos1, SEEK_SET); | |
247 } | |
248 | |
249 /* write an asf chunk (only used in streaming case) */ | |
250 static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags) | |
251 { | |
252 ASFContext *asf = s->priv_data; | |
253 ByteIOContext *pb = &s->pb; | |
254 int length; | |
255 | |
256 length = payload_length + 8; | |
257 put_le16(pb, type); | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
258 put_le16(pb, length); //size |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
259 put_le32(pb, asf->seqno);//sequence number |
0 | 260 put_le16(pb, flags); /* unknown bytes */ |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
261 put_le16(pb, length); //size_confirm |
0 | 262 asf->seqno++; |
263 } | |
264 | |
265 /* convert from unix to windows time */ | |
65 | 266 static int64_t unix_to_file_time(int ti) |
0 | 267 { |
65 | 268 int64_t t; |
0 | 269 |
65 | 270 t = ti * int64_t_C(10000000); |
271 t += int64_t_C(116444736000000000); | |
0 | 272 return t; |
273 } | |
274 | |
275 /* write the header (used two times if non streamed) */ | |
65 | 276 static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size) |
0 | 277 { |
278 ASFContext *asf = s->priv_data; | |
279 ByteIOContext *pb = &s->pb; | |
280 int header_size, n, extra_size, extra_size2, wav_extra_size, file_time; | |
281 int has_title; | |
282 AVCodecContext *enc; | |
65 | 283 int64_t header_offset, cur_pos, hpos; |
0 | 284 int bit_rate; |
285 | |
286 has_title = (s->title[0] || s->author[0] || s->copyright[0] || s->comment[0]); | |
287 | |
288 bit_rate = 0; | |
289 for(n=0;n<s->nb_streams;n++) { | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
290 enc = s->streams[n]->codec; |
0 | 291 |
462
b69898ffc92a
move time_base (pts_num/pts_den) from AVFormatContext -> AVStream
michael
parents:
373
diff
changeset
|
292 av_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */ |
b69898ffc92a
move time_base (pts_num/pts_den) from AVFormatContext -> AVStream
michael
parents:
373
diff
changeset
|
293 |
0 | 294 bit_rate += enc->bit_rate; |
295 } | |
296 | |
297 if (asf->is_streamed) { | |
298 put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */ | |
299 } | |
300 | |
301 put_guid(pb, &asf_header); | |
302 put_le64(pb, -1); /* header length, will be patched after */ | |
303 put_le32(pb, 3 + has_title + s->nb_streams); /* number of chunks in header */ | |
304 put_byte(pb, 1); /* ??? */ | |
305 put_byte(pb, 2); /* ??? */ | |
306 | |
307 /* file header */ | |
308 header_offset = url_ftell(pb); | |
309 hpos = put_header(pb, &file_header); | |
310 put_guid(pb, &my_guid); | |
311 put_le64(pb, file_size); | |
312 file_time = 0; | |
313 put_le64(pb, unix_to_file_time(file_time)); | |
314 put_le64(pb, asf->nb_packets); /* number of packets */ | |
315 put_le64(pb, asf->duration); /* end time stamp (in 100ns units) */ | |
316 put_le64(pb, asf->duration); /* duration (in 100ns units) */ | |
468 | 317 put_le32(pb, preroll_time); /* start time stamp */ |
0 | 318 put_le32(pb, 0); /* ??? */ |
319 put_le32(pb, asf->is_streamed ? 1 : 0); /* ??? */ | |
320 put_le32(pb, asf->packet_size); /* packet size */ | |
321 put_le32(pb, asf->packet_size); /* packet size */ | |
322 put_le32(pb, bit_rate); /* Nominal data rate in bps */ | |
323 end_header(pb, hpos); | |
324 | |
325 /* unknown headers */ | |
326 hpos = put_header(pb, &head1_guid); | |
327 put_guid(pb, &head2_guid); | |
328 put_le32(pb, 6); | |
329 put_le16(pb, 0); | |
330 end_header(pb, hpos); | |
331 | |
332 /* title and other infos */ | |
333 if (has_title) { | |
334 hpos = put_header(pb, &comment_header); | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
335 if ( s->title[0] ) { put_le16(pb, 2 * (strlen(s->title ) + 1)); } else { put_le16(pb, 0); } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
336 if ( s->author[0] ) { put_le16(pb, 2 * (strlen(s->author ) + 1)); } else { put_le16(pb, 0); } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
337 if ( s->copyright[0] ) { put_le16(pb, 2 * (strlen(s->copyright) + 1)); } else { put_le16(pb, 0); } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
338 if ( s->comment[0] ) { put_le16(pb, 2 * (strlen(s->comment ) + 1)); } else { put_le16(pb, 0); } |
0 | 339 put_le16(pb, 0); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
340 if ( s->title[0] ) put_str16_nolen(pb, s->title); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
341 if ( s->author[0] ) put_str16_nolen(pb, s->author); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
342 if ( s->copyright[0] ) put_str16_nolen(pb, s->copyright); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
343 if ( s->comment[0] ) put_str16_nolen(pb, s->comment); |
0 | 344 end_header(pb, hpos); |
345 } | |
346 | |
347 /* stream headers */ | |
348 for(n=0;n<s->nb_streams;n++) { | |
65 | 349 int64_t es_pos; |
1123
6992dd78ff68
Add (mostly) const to variable and parameter declaration, where a char* was
diego
parents:
896
diff
changeset
|
350 const uint8_t *er_spr = NULL; |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
351 int er_spr_len = 0; |
0 | 352 // ASFStream *stream = &asf->streams[n]; |
353 | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
354 enc = s->streams[n]->codec; |
0 | 355 asf->streams[n].num = n + 1; |
356 asf->streams[n].seq = 0; | |
357 | |
885 | 358 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
359 if (enc->codec_type == CODEC_TYPE_AUDIO) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
360 if (enc->codec_id == CODEC_ID_ADPCM_G726) { |
1123
6992dd78ff68
Add (mostly) const to variable and parameter declaration, where a char* was
diego
parents:
896
diff
changeset
|
361 er_spr = error_spread_ADPCM_G726; |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
362 er_spr_len = sizeof(error_spread_ADPCM_G726); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
363 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
364 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
365 |
0 | 366 switch(enc->codec_type) { |
367 case CODEC_TYPE_AUDIO: | |
368 wav_extra_size = 0; | |
369 extra_size = 18 + wav_extra_size; | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
370 extra_size2 = er_spr_len; |
0 | 371 break; |
372 default: | |
373 case CODEC_TYPE_VIDEO: | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
374 wav_extra_size = enc->extradata_size; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
375 extra_size = 0x33 + wav_extra_size; |
0 | 376 extra_size2 = 0; |
377 break; | |
378 } | |
379 | |
380 hpos = put_header(pb, &stream_header); | |
381 if (enc->codec_type == CODEC_TYPE_AUDIO) { | |
382 put_guid(pb, &audio_stream); | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
383 if ((er_spr != NULL) && (er_spr_len != 0)) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
384 put_guid(pb, &audio_conceal_spread); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
385 } else { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
386 put_guid(pb, &video_conceal_none); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
387 } |
0 | 388 } else { |
389 put_guid(pb, &video_stream); | |
390 put_guid(pb, &video_conceal_none); | |
391 } | |
392 put_le64(pb, 0); /* ??? */ | |
393 es_pos = url_ftell(pb); | |
394 put_le32(pb, extra_size); /* wav header len */ | |
395 put_le32(pb, extra_size2); /* additional data len */ | |
396 put_le16(pb, n + 1); /* stream number */ | |
397 put_le32(pb, 0); /* ??? */ | |
398 | |
399 if (enc->codec_type == CODEC_TYPE_AUDIO) { | |
400 /* WAVEFORMATEX header */ | |
401 int wavsize = put_wav_header(pb, enc); | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
402 if ((enc->codec_id != CODEC_ID_MP3) && (enc->codec_id != CODEC_ID_MP2) && (enc->codec_id != CODEC_ID_ADPCM_IMA_WAV) && (enc->extradata_size==0)) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
403 wavsize += 2; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
404 put_le16(pb, 0); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
405 } |
0 | 406 |
407 if (wavsize < 0) | |
408 return -1; | |
409 if (wavsize != extra_size) { | |
410 cur_pos = url_ftell(pb); | |
411 url_fseek(pb, es_pos, SEEK_SET); | |
412 put_le32(pb, wavsize); /* wav header len */ | |
413 url_fseek(pb, cur_pos, SEEK_SET); | |
414 } | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
415 /* ERROR Correction */ |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
416 if ((er_spr != NULL) && (er_spr_len != 0)) |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
417 put_buffer(pb, er_spr, er_spr_len); |
0 | 418 } else { |
419 put_le32(pb, enc->width); | |
420 put_le32(pb, enc->height); | |
421 put_byte(pb, 2); /* ??? */ | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
422 put_le16(pb, 40 + enc->extradata_size); /* size */ |
0 | 423 |
424 /* BITMAPINFOHEADER header */ | |
425 put_bmp_header(pb, enc, codec_bmp_tags, 1); | |
426 } | |
427 end_header(pb, hpos); | |
428 } | |
429 | |
430 /* media comments */ | |
431 | |
432 hpos = put_header(pb, &codec_comment_header); | |
433 put_guid(pb, &codec_comment1_header); | |
434 put_le32(pb, s->nb_streams); | |
435 for(n=0;n<s->nb_streams;n++) { | |
436 AVCodec *p; | |
437 | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
438 enc = s->streams[n]->codec; |
0 | 439 p = avcodec_find_encoder(enc->codec_id); |
440 | |
441 put_le16(pb, asf->streams[n].num); | |
442 put_str16(pb, p ? p->name : enc->codec_name); | |
443 put_le16(pb, 0); /* no parameters */ | |
885 | 444 |
445 | |
0 | 446 /* id */ |
447 if (enc->codec_type == CODEC_TYPE_AUDIO) { | |
448 put_le16(pb, 2); | |
196 | 449 if(!enc->codec_tag) |
450 enc->codec_tag = codec_get_tag(codec_wav_tags, enc->codec_id); | |
451 if(!enc->codec_tag) | |
452 return -1; | |
453 put_le16(pb, enc->codec_tag); | |
0 | 454 } else { |
455 put_le16(pb, 4); | |
196 | 456 if(!enc->codec_tag) |
457 enc->codec_tag = codec_get_tag(codec_bmp_tags, enc->codec_id); | |
458 if(!enc->codec_tag) | |
459 return -1; | |
460 put_le32(pb, enc->codec_tag); | |
0 | 461 } |
462 } | |
463 end_header(pb, hpos); | |
464 | |
465 /* patch the header size fields */ | |
466 | |
467 cur_pos = url_ftell(pb); | |
468 header_size = cur_pos - header_offset; | |
469 if (asf->is_streamed) { | |
470 header_size += 8 + 30 + 50; | |
471 | |
472 url_fseek(pb, header_offset - 10 - 30, SEEK_SET); | |
473 put_le16(pb, header_size); | |
474 url_fseek(pb, header_offset - 2 - 30, SEEK_SET); | |
475 put_le16(pb, header_size); | |
476 | |
477 header_size -= 8 + 30 + 50; | |
478 } | |
479 header_size += 24 + 6; | |
480 url_fseek(pb, header_offset - 14, SEEK_SET); | |
481 put_le64(pb, header_size); | |
482 url_fseek(pb, cur_pos, SEEK_SET); | |
483 | |
484 /* movie chunk, followed by packets of packet_size */ | |
485 asf->data_offset = cur_pos; | |
486 put_guid(pb, &data_header); | |
487 put_le64(pb, data_chunk_size); | |
488 put_guid(pb, &my_guid); | |
489 put_le64(pb, asf->nb_packets); /* nb packets */ | |
490 put_byte(pb, 1); /* ??? */ | |
491 put_byte(pb, 1); /* ??? */ | |
492 return 0; | |
493 } | |
494 | |
495 static int asf_write_header(AVFormatContext *s) | |
496 { | |
497 ASFContext *asf = s->priv_data; | |
498 | |
499 asf->packet_size = PACKET_SIZE; | |
500 asf->nb_packets = 0; | |
885 | 501 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
502 asf->last_indexed_pts = 0; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
503 asf->index_ptr = (ASFIndex*)av_malloc( sizeof(ASFIndex) * ASF_INDEX_BLOCK ); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
504 asf->nb_index_memory_alloc = ASF_INDEX_BLOCK; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
505 asf->nb_index_count = 0; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
506 asf->maximum_packet = 0; |
0 | 507 |
508 if (asf_write_header1(s, 0, 50) < 0) { | |
509 //av_free(asf); | |
510 return -1; | |
511 } | |
512 | |
513 put_flush_packet(&s->pb); | |
514 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
515 asf->packet_nb_payloads = 0; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
516 asf->prev_packet_sent_time = 0; |
0 | 517 asf->packet_timestamp_start = -1; |
518 asf->packet_timestamp_end = -1; | |
519 init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1, | |
520 NULL, NULL, NULL, NULL); | |
521 | |
522 return 0; | |
523 } | |
524 | |
525 static int asf_write_stream_header(AVFormatContext *s) | |
526 { | |
527 ASFContext *asf = s->priv_data; | |
528 | |
529 asf->is_streamed = 1; | |
530 | |
531 return asf_write_header(s); | |
532 } | |
533 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
534 static int put_payload_parsing_info( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
535 AVFormatContext *s, |
885 | 536 unsigned int sendtime, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
537 unsigned int duration, |
885 | 538 int nb_payloads, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
539 int padsize |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
540 ) |
0 | 541 { |
542 ASFContext *asf = s->priv_data; | |
543 ByteIOContext *pb = &s->pb; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
544 int ppi_size, i; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
545 unsigned char *start_ppi_ptr = pb->buf_ptr; |
0 | 546 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
547 int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS; |
885 | 548 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
549 put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
550 for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){ |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
551 put_byte(pb, 0x0); |
0 | 552 } |
553 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
554 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
555 iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT; |
0 | 556 |
557 if (padsize > 0) { | |
558 if (padsize < 256) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
559 iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE; |
0 | 560 else |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
561 iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD; |
0 | 562 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
563 put_byte(pb, iLengthTypeFlags); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
564 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
565 put_byte(pb, ASF_PPI_PROPERTY_FLAGS); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
566 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
567 if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD) |
0 | 568 put_le16(pb, padsize - 2); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
569 if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE) |
0 | 570 put_byte(pb, padsize - 1); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
571 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
572 put_le32(pb, sendtime); |
0 | 573 put_le16(pb, duration); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
574 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
575 put_byte(pb, nb_payloads | ASF_PAYLOAD_FLAGS); |
0 | 576 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
577 ppi_size = pb->buf_ptr - start_ppi_ptr; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
578 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
579 return ppi_size; |
0 | 580 } |
581 | |
582 static void flush_packet(AVFormatContext *s) | |
583 { | |
584 ASFContext *asf = s->priv_data; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
585 int packet_hdr_size, packet_filled_size; |
0 | 586 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
587 if (asf->is_streamed) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
588 put_chunk(s, 0x4424, asf->packet_size, 0); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
589 } |
0 | 590 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
591 packet_hdr_size = put_payload_parsing_info( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
592 s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
593 asf->packet_timestamp_start, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
594 asf->packet_timestamp_end - asf->packet_timestamp_start, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
595 asf->packet_nb_payloads, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
596 asf->packet_size_left |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
597 ); |
0 | 598 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
599 packet_filled_size = PACKET_SIZE - packet_hdr_size - asf->packet_size_left; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
600 memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
601 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
602 put_buffer(&s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size); |
0 | 603 |
604 put_flush_packet(&s->pb); | |
605 asf->nb_packets++; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
606 asf->packet_nb_payloads = 0; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
607 asf->prev_packet_sent_time = asf->packet_timestamp_start; |
0 | 608 asf->packet_timestamp_start = -1; |
609 asf->packet_timestamp_end = -1; | |
610 init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1, | |
611 NULL, NULL, NULL, NULL); | |
612 } | |
613 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
614 static void put_payload_header( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
615 AVFormatContext *s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
616 ASFStream *stream, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
617 int presentation_time, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
618 int m_obj_size, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
619 int m_obj_offset, |
470 | 620 int payload_len, |
621 int flags | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
622 ) |
0 | 623 { |
624 ASFContext *asf = s->priv_data; | |
625 ByteIOContext *pb = &asf->pb; | |
626 int val; | |
885 | 627 |
0 | 628 val = stream->num; |
470 | 629 if (flags & PKT_FLAG_KEY) |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
630 val |= ASF_PL_FLAG_KEY_FRAME; |
0 | 631 put_byte(pb, val); |
885 | 632 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
633 put_byte(pb, stream->seq); //Media object number |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
634 put_le32(pb, m_obj_offset); //Offset Into Media Object |
885 | 635 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
636 // Replicated Data shall be at least 8 bytes long. |
885 | 637 // The first 4 bytes of data shall contain the |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
638 // Size of the Media Object that the payload belongs to. |
885 | 639 // The next 4 bytes of data shall contain the |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
640 // Presentation Time for the media object that the payload belongs to. |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
641 put_byte(pb, ASF_PAYLOAD_REPLICATED_DATA_LENGTH); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
642 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
643 put_le32(pb, m_obj_size); //Replicated Data - Media Object Size |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
644 put_le32(pb, presentation_time);//Replicated Data - Presentation Time |
885 | 645 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
646 if (asf->multi_payloads_present){ |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
647 put_le16(pb, payload_len); //payload length |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
648 } |
0 | 649 } |
650 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
651 static void put_frame( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
652 AVFormatContext *s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
653 ASFStream *stream, |
887 | 654 int timestamp, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
655 const uint8_t *buf, |
887 | 656 int m_obj_size, |
470 | 657 int flags |
887 | 658 ) |
0 | 659 { |
660 ASFContext *asf = s->priv_data; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
661 int m_obj_offset, payload_len, frag_len1; |
0 | 662 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
663 m_obj_offset = 0; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
664 while (m_obj_offset < m_obj_size) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
665 payload_len = m_obj_size - m_obj_offset; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
666 if (asf->packet_timestamp_start == -1) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
667 asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT); |
885 | 668 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
669 if (asf->multi_payloads_present){ |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
670 asf->packet_size_left = PACKET_SIZE; //For debug |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
671 asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE - 1; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
672 frag_len1 = MULTI_PAYLOAD_CONSTANT - 1; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
673 } |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
674 else { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
675 asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
676 frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
677 } |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
678 if (asf->prev_packet_sent_time > timestamp) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
679 asf->packet_timestamp_start = asf->prev_packet_sent_time; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
680 else |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
681 asf->packet_timestamp_start = timestamp; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
682 } |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
683 else { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
684 // multi payloads |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
685 frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
686 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
687 if (asf->prev_packet_sent_time > timestamp) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
688 asf->packet_timestamp_start = asf->prev_packet_sent_time; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
689 else if (asf->packet_timestamp_start >= timestamp) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
690 asf->packet_timestamp_start = timestamp; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
691 } |
0 | 692 if (frag_len1 > 0) { |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
693 if (payload_len > frag_len1) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
694 payload_len = frag_len1; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
695 else if (payload_len == (frag_len1 - 1)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
696 payload_len = frag_len1 - 2; //additional byte need to put padding length |
885 | 697 |
470 | 698 put_payload_header(s, stream, timestamp+preroll_time, m_obj_size, m_obj_offset, payload_len, flags); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
699 put_buffer(&asf->pb, buf, payload_len); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
700 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
701 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
702 asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
703 else |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
704 asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD); |
0 | 705 asf->packet_timestamp_end = timestamp; |
885 | 706 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
707 asf->packet_nb_payloads++; |
0 | 708 } else { |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
709 payload_len = 0; |
0 | 710 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
711 m_obj_offset += payload_len; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
712 buf += payload_len; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
713 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
714 if (!asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
715 flush_packet(s); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
716 else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + 1)) |
0 | 717 flush_packet(s); |
718 } | |
719 stream->seq++; | |
720 } | |
721 | |
468 | 722 static int asf_write_packet(AVFormatContext *s, AVPacket *pkt) |
0 | 723 { |
724 ASFContext *asf = s->priv_data; | |
725 ASFStream *stream; | |
65 | 726 int64_t duration; |
0 | 727 AVCodecContext *codec; |
885 | 728 int64_t packet_st,pts; |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
729 int start_sec,i; |
0 | 730 |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
731 codec = s->streams[pkt->stream_index]->codec; |
468 | 732 stream = &asf->streams[pkt->stream_index]; |
0 | 733 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
734 //XXX /FIXME use duration from AVPacket (quick hack by) |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
735 pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
736 if (pts == AV_NOPTS_VALUE) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
737 if (codec->codec_type == CODEC_TYPE_AUDIO) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
738 duration = (codec->frame_number * (int64_t)codec->frame_size * int64_t_C(10000000)) / |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
739 codec->sample_rate; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
740 } else { |
743 | 741 duration = av_rescale(codec->frame_number * (int64_t)codec->time_base.num, 10000000, codec->time_base.den); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
742 } |
0 | 743 } else { |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
744 duration = pts * 10000; |
0 | 745 } |
746 if (duration > asf->duration) | |
747 asf->duration = duration; | |
748 | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
749 packet_st = asf->nb_packets; |
470 | 750 put_frame(s, stream, pkt->pts, pkt->data, pkt->size, pkt->flags); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
751 |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
752 /* check index */ |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
753 if ((!asf->is_streamed) && (codec->codec_type == CODEC_TYPE_VIDEO) && (pkt->flags & PKT_FLAG_KEY)) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
754 start_sec = (int)(duration / int64_t_C(10000000)); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
755 if (start_sec != (int)(asf->last_indexed_pts / int64_t_C(10000000))) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
756 for(i=asf->nb_index_count;i<start_sec;i++) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
757 if (i>=asf->nb_index_memory_alloc) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
758 asf->nb_index_memory_alloc += ASF_INDEX_BLOCK; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
759 asf->index_ptr = (ASFIndex*)av_realloc( asf->index_ptr, sizeof(ASFIndex) * asf->nb_index_memory_alloc ); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
760 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
761 // store |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
762 asf->index_ptr[i].packet_number = (uint32_t)packet_st; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
763 asf->index_ptr[i].packet_count = (uint16_t)(asf->nb_packets-packet_st); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
764 if (asf->maximum_packet < (uint16_t)(asf->nb_packets-packet_st)) |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
765 asf->maximum_packet = (uint16_t)(asf->nb_packets-packet_st); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
766 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
767 asf->nb_index_count = start_sec; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
768 asf->last_indexed_pts = duration; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
769 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
770 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
771 return 0; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
772 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
773 |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
774 // |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
775 static int asf_write_index(AVFormatContext *s, ASFIndex *index, uint16_t max, uint32_t count) |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
776 { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
777 ByteIOContext *pb = &s->pb; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
778 int i; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
779 |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
780 put_guid(pb, &simple_index_header); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
781 put_le64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2)*count); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
782 put_guid(pb, &my_guid); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
783 put_le64(pb, ASF_INDEXED_INTERVAL); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
784 put_le32(pb, max); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
785 put_le32(pb, count); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
786 for(i=0; i<count; i++) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
787 put_le32(pb, index[i].packet_number); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
788 put_le16(pb, index[i].packet_count); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
789 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
790 |
0 | 791 return 0; |
792 } | |
793 | |
794 static int asf_write_trailer(AVFormatContext *s) | |
795 { | |
796 ASFContext *asf = s->priv_data; | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
797 int64_t file_size,data_size; |
0 | 798 |
799 /* flush the current packet */ | |
800 if (asf->pb.buf_ptr > asf->pb.buffer) | |
801 flush_packet(s); | |
802 | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
803 /* write index */ |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
804 data_size = url_ftell(&s->pb); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
805 if ((!asf->is_streamed) && (asf->nb_index_count != 0)) { |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
806 asf_write_index(s, asf->index_ptr, asf->maximum_packet, asf->nb_index_count); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
807 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
808 put_flush_packet(&s->pb); |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
809 |
0 | 810 if (asf->is_streamed) { |
811 put_chunk(s, 0x4524, 0, 0); /* end of stream */ | |
812 } else { | |
813 /* rewrite an updated header */ | |
814 file_size = url_ftell(&s->pb); | |
815 url_fseek(&s->pb, 0, SEEK_SET); | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
816 asf_write_header1(s, file_size, data_size - asf->data_offset); |
0 | 817 } |
818 | |
819 put_flush_packet(&s->pb); | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
820 av_free(asf->index_ptr); |
0 | 821 return 0; |
822 } | |
823 | |
1169 | 824 #ifdef CONFIG_ASF_MUXER |
1167 | 825 AVOutputFormat asf_muxer = { |
0 | 826 "asf", |
827 "asf format", | |
14
b167760cd0aa
mimetype fixes patch by (Ryutaroh Matsumoto <ryutaroh at it dot ss dot titech dot ac dot jp>)
michaelni
parents:
7
diff
changeset
|
828 "video/x-ms-asf", |
672 | 829 "asf,wmv,wma", |
0 | 830 sizeof(ASFContext), |
831 #ifdef CONFIG_MP3LAME | |
232 | 832 CODEC_ID_MP3, |
0 | 833 #else |
834 CODEC_ID_MP2, | |
835 #endif | |
836 CODEC_ID_MSMPEG4V3, | |
837 asf_write_header, | |
838 asf_write_packet, | |
839 asf_write_trailer, | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
840 .flags = AVFMT_GLOBALHEADER, |
0 | 841 }; |
1169 | 842 #endif |
0 | 843 |
1169 | 844 #ifdef CONFIG_ASF_STREAM_MUXER |
1167 | 845 AVOutputFormat asf_stream_muxer = { |
0 | 846 "asf_stream", |
847 "asf format", | |
14
b167760cd0aa
mimetype fixes patch by (Ryutaroh Matsumoto <ryutaroh at it dot ss dot titech dot ac dot jp>)
michaelni
parents:
7
diff
changeset
|
848 "video/x-ms-asf", |
672 | 849 "asf,wmv,wma", |
0 | 850 sizeof(ASFContext), |
851 #ifdef CONFIG_MP3LAME | |
232 | 852 CODEC_ID_MP3, |
0 | 853 #else |
854 CODEC_ID_MP2, | |
855 #endif | |
856 CODEC_ID_MSMPEG4V3, | |
857 asf_write_stream_header, | |
858 asf_write_packet, | |
859 asf_write_trailer, | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
860 .flags = AVFMT_GLOBALHEADER, |
0 | 861 }; |
1169 | 862 #endif //CONFIG_ASF_STREAM_MUXER |