Mercurial > libavformat.hg
annotate asfenc.c @ 4852:ecf9f13948f1 libavformat
Use get_le32/get_be32 in wc3movie demuxer instead of reading everything into
a buffer first.
author | reimar |
---|---|
date | Sat, 11 Apr 2009 18:58:55 +0000 |
parents | 86dd0cab30d3 |
children | 33a244b7ca65 |
rev | line source |
---|---|
0 | 1 /* |
3931
b1deda6b74c3
ASF stands for "advanced stream format" not "adaptive ...", changing it to "ASF".
michael
parents:
3766
diff
changeset
|
2 * ASF muxer |
4251
77e0c7511d41
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
4206
diff
changeset
|
3 * Copyright (c) 2000, 2001 Fabrice Bellard |
0 | 4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1345
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1345
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1345
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
0 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1345
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
0 | 11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1345
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
0 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1345
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 20 */ |
21 #include "avformat.h" | |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
22 #include "metadata.h" |
1172
6a5e58d2114b
move common stuff from avienc.c and wav.c to new file riff.c
mru
parents:
1169
diff
changeset
|
23 #include "riff.h" |
372
2e12cd1b68ed
split asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
370
diff
changeset
|
24 #include "asf.h" |
0 | 25 |
348 | 26 #undef NDEBUG |
27 #include <assert.h> | |
28 | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
29 |
887 | 30 #define ASF_INDEXED_INTERVAL 10000000 |
31 #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
|
32 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
33 #define ASF_PACKET_ERROR_CORRECTION_DATA_SIZE 0x2 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
34 #define ASF_PACKET_ERROR_CORRECTION_FLAGS (\ |
887 | 35 ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT | \ |
36 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE\ | |
37 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
38 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
39 #if (ASF_PACKET_ERROR_CORRECTION_FLAGS != 0) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
40 # 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
|
41 #else |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
42 # 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
|
43 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
44 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
45 #define ASF_PPI_PROPERTY_FLAGS (\ |
887 | 46 ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE | \ |
47 ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD | \ | |
48 ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE | \ | |
49 ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE \ | |
50 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
51 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
52 #define ASF_PPI_LENGTH_TYPE_FLAGS 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
53 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
54 #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
|
55 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
56 #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
|
57 # define ASF_PPI_SEQUENCE_FIELD_SIZE 1 |
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_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
|
60 # define ASF_PPI_SEQUENCE_FIELD_SIZE 2 |
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 #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
|
63 # define ASF_PPI_SEQUENCE_FIELD_SIZE 4 |
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 #ifndef ASF_PPI_SEQUENCE_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
66 # define ASF_PPI_SEQUENCE_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
67 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
68 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
69 |
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_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
|
71 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 1 |
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_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
|
74 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 2 |
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 #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
|
77 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 4 |
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 #ifndef ASF_PPI_PACKET_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
80 # define ASF_PPI_PACKET_LENGTH_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
81 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
82 |
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_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
|
84 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 1 |
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_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
|
87 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 2 |
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 #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
|
90 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 4 |
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 #ifndef ASF_PPI_PADDING_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
93 # define ASF_PPI_PADDING_LENGTH_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
94 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
95 |
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_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
|
97 # 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
|
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_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
|
100 # 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
|
101 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
102 #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
|
103 # 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
|
104 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
105 #ifndef ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
106 # 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
|
107 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
108 |
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_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
|
110 # 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
|
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_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
|
113 # 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
|
114 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
115 #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
|
116 # 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
|
117 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
118 #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
|
119 # 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
|
120 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
121 |
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_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
|
123 # 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
|
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_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
|
126 # 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
|
127 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
128 #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
|
129 # 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
|
130 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
131 #ifndef ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
132 # 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
|
133 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
134 |
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_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
|
136 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 1 |
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 #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
|
139 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 2 |
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 #ifndef ASF_PAYLOAD_LENGTH_FIELD_SIZE |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
142 # define ASF_PAYLOAD_LENGTH_FIELD_SIZE 0 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
143 #endif |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
144 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
145 #define PACKET_HEADER_MIN_SIZE (\ |
887 | 146 ASF_PACKET_ERROR_CORRECTION_FLAGS_FIELD_SIZE + \ |
147 ASF_PACKET_ERROR_CORRECTION_DATA_SIZE + \ | |
148 1 + /*Length Type Flags*/ \ | |
149 1 + /*Property Flags*/ \ | |
150 ASF_PPI_PACKET_LENGTH_FIELD_SIZE + \ | |
151 ASF_PPI_SEQUENCE_FIELD_SIZE + \ | |
152 ASF_PPI_PADDING_LENGTH_FIELD_SIZE + \ | |
153 4 + /*Send Time Field*/ \ | |
154 2 /*Duration Field*/ \ | |
155 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
156 |
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 // 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
|
159 #define ASF_PAYLOAD_REPLICATED_DATA_LENGTH 0x08 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
160 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
161 #define PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD (\ |
887 | 162 1 + /*Stream Number*/ \ |
163 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \ | |
164 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \ | |
165 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \ | |
166 ASF_PAYLOAD_REPLICATED_DATA_LENGTH \ | |
167 ) | |
885 | 168 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
169 #define PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS (\ |
887 | 170 1 + /*Stream Number*/ \ |
171 ASF_PAYLOAD_MEDIA_OBJECT_NUMBER_FIELD_SIZE + \ | |
172 ASF_PAYLOAD_OFFSET_INTO_MEDIA_OBJECT_FIELD_SIZE + \ | |
173 ASF_PAYLOAD_REPLICATED_DATA_LENGTH_FIELD_SIZE + \ | |
174 ASF_PAYLOAD_REPLICATED_DATA_LENGTH + \ | |
175 ASF_PAYLOAD_LENGTH_FIELD_SIZE \ | |
176 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
177 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
178 #define SINGLE_PAYLOAD_DATA_LENGTH (\ |
887 | 179 PACKET_SIZE - \ |
180 PACKET_HEADER_MIN_SIZE - \ | |
181 PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD \ | |
182 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
183 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
184 #define MULTI_PAYLOAD_CONSTANT (\ |
887 | 185 PACKET_SIZE - \ |
186 PACKET_HEADER_MIN_SIZE - \ | |
187 1 - /*Payload Flags*/ \ | |
188 2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \ | |
189 ) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
190 |
1677
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1622
diff
changeset
|
191 static const AVCodecTag codec_asf_bmp_tags[] = { |
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1622
diff
changeset
|
192 { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') }, |
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1622
diff
changeset
|
193 { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') }, |
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1622
diff
changeset
|
194 { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, |
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1622
diff
changeset
|
195 { CODEC_ID_NONE, 0 }, |
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1622
diff
changeset
|
196 }; |
2a85c82b8538
add codec_id <-> codec_tag tables to AVIn/OutputFormat
michael
parents:
1622
diff
changeset
|
197 |
1887
490aa34aef0f
move preroll_time from static variable into definition, might be a good idea moving this into the context and making user-settable
alex
parents:
1880
diff
changeset
|
198 #define PREROLL_TIME 3100 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
199 |
4748
86dd0cab30d3
Rename GUID typedef to ff_asf_guid to fix MinGW compilation failure
reimar
parents:
4618
diff
changeset
|
200 static void put_guid(ByteIOContext *s, const ff_asf_guid *g) |
0 | 201 { |
1687 | 202 assert(sizeof(*g) == 16); |
2991
4591452ec78c
typo, typedef uint8_t GUID[16] in asf.h, and fix warning: asf-enc.c:202: warning: passing argument 2 of 'put_buffer' from incompatible pointer type
bcoudurier
parents:
2801
diff
changeset
|
203 put_buffer(s, *g, sizeof(*g)); |
0 | 204 } |
205 | |
1685 | 206 static void put_str16_nolen(ByteIOContext *s, const char *tag); |
0 | 207 static void put_str16(ByteIOContext *s, const char *tag) |
208 { | |
209 put_le16(s,strlen(tag) + 1); | |
1685 | 210 put_str16_nolen(s, tag); |
0 | 211 } |
212 | |
213 static void put_str16_nolen(ByteIOContext *s, const char *tag) | |
214 { | |
215 int c; | |
216 | |
1685 | 217 do{ |
65 | 218 c = (uint8_t)*tag++; |
0 | 219 put_le16(s, c); |
1685 | 220 }while(c); |
0 | 221 } |
222 | |
4748
86dd0cab30d3
Rename GUID typedef to ff_asf_guid to fix MinGW compilation failure
reimar
parents:
4618
diff
changeset
|
223 static int64_t put_header(ByteIOContext *pb, const ff_asf_guid *g) |
0 | 224 { |
65 | 225 int64_t pos; |
0 | 226 |
227 pos = url_ftell(pb); | |
228 put_guid(pb, g); | |
229 put_le64(pb, 24); | |
230 return pos; | |
231 } | |
232 | |
233 /* update header size */ | |
65 | 234 static void end_header(ByteIOContext *pb, int64_t pos) |
0 | 235 { |
65 | 236 int64_t pos1; |
0 | 237 |
238 pos1 = url_ftell(pb); | |
239 url_fseek(pb, pos + 16, SEEK_SET); | |
240 put_le64(pb, pos1 - pos); | |
241 url_fseek(pb, pos1, SEEK_SET); | |
242 } | |
243 | |
244 /* write an asf chunk (only used in streaming case) */ | |
245 static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags) | |
246 { | |
247 ASFContext *asf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
248 ByteIOContext *pb = s->pb; |
0 | 249 int length; |
250 | |
251 length = payload_length + 8; | |
252 put_le16(pb, type); | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
253 put_le16(pb, length); //size |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
254 put_le32(pb, asf->seqno);//sequence number |
0 | 255 put_le16(pb, flags); /* unknown bytes */ |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
256 put_le16(pb, length); //size_confirm |
0 | 257 asf->seqno++; |
258 } | |
259 | |
260 /* convert from unix to windows time */ | |
65 | 261 static int64_t unix_to_file_time(int ti) |
0 | 262 { |
65 | 263 int64_t t; |
0 | 264 |
1556 | 265 t = ti * INT64_C(10000000); |
266 t += INT64_C(116444736000000000); | |
0 | 267 return t; |
268 } | |
269 | |
270 /* write the header (used two times if non streamed) */ | |
65 | 271 static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size) |
0 | 272 { |
273 ASFContext *asf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
274 ByteIOContext *pb = s->pb; |
4372 | 275 AVMetadataTag *title, *author, *copyright, *comment; |
0 | 276 int header_size, n, extra_size, extra_size2, wav_extra_size, file_time; |
277 int has_title; | |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
278 int metadata_count; |
0 | 279 AVCodecContext *enc; |
65 | 280 int64_t header_offset, cur_pos, hpos; |
0 | 281 int bit_rate; |
1345 | 282 int64_t duration; |
0 | 283 |
4372 | 284 title = av_metadata_get(s->metadata, "title" , NULL, 0); |
285 author = av_metadata_get(s->metadata, "author" , NULL, 0); | |
286 copyright = av_metadata_get(s->metadata, "copyright", NULL, 0); | |
287 comment = av_metadata_get(s->metadata, "comment" , NULL, 0); | |
288 | |
1887
490aa34aef0f
move preroll_time from static variable into definition, might be a good idea moving this into the context and making user-settable
alex
parents:
1880
diff
changeset
|
289 duration = asf->duration + PREROLL_TIME * 10000; |
4372 | 290 has_title = title || author || copyright || comment; |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
291 metadata_count = s->metadata ? s->metadata->count : 0; |
0 | 292 |
293 bit_rate = 0; | |
294 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
|
295 enc = s->streams[n]->codec; |
0 | 296 |
462
b69898ffc92a
move time_base (pts_num/pts_den) from AVFormatContext -> AVStream
michael
parents:
373
diff
changeset
|
297 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
|
298 |
0 | 299 bit_rate += enc->bit_rate; |
300 } | |
301 | |
302 if (asf->is_streamed) { | |
303 put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */ | |
304 } | |
305 | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
306 put_guid(pb, &ff_asf_header); |
0 | 307 put_le64(pb, -1); /* header length, will be patched after */ |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
308 put_le32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */ |
0 | 309 put_byte(pb, 1); /* ??? */ |
310 put_byte(pb, 2); /* ??? */ | |
311 | |
312 /* file header */ | |
313 header_offset = url_ftell(pb); | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
314 hpos = put_header(pb, &ff_asf_file_header); |
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
315 put_guid(pb, &ff_asf_my_guid); |
0 | 316 put_le64(pb, file_size); |
317 file_time = 0; | |
318 put_le64(pb, unix_to_file_time(file_time)); | |
319 put_le64(pb, asf->nb_packets); /* number of packets */ | |
1345 | 320 put_le64(pb, duration); /* end time stamp (in 100ns units) */ |
1862
7ac4b32fd3fc
all asf files i have have the 2 redundant duration fields differ by the preroll time so lets set them up like that too
michael
parents:
1861
diff
changeset
|
321 put_le64(pb, asf->duration); /* duration (in 100ns units) */ |
1887
490aa34aef0f
move preroll_time from static variable into definition, might be a good idea moving this into the context and making user-settable
alex
parents:
1880
diff
changeset
|
322 put_le64(pb, PREROLL_TIME); /* start time stamp */ |
1895 | 323 put_le32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */ |
0 | 324 put_le32(pb, asf->packet_size); /* packet size */ |
325 put_le32(pb, asf->packet_size); /* packet size */ | |
326 put_le32(pb, bit_rate); /* Nominal data rate in bps */ | |
327 end_header(pb, hpos); | |
328 | |
329 /* unknown headers */ | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
330 hpos = put_header(pb, &ff_asf_head1_guid); |
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
331 put_guid(pb, &ff_asf_head2_guid); |
0 | 332 put_le32(pb, 6); |
333 put_le16(pb, 0); | |
334 end_header(pb, hpos); | |
335 | |
336 /* title and other infos */ | |
337 if (has_title) { | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
338 hpos = put_header(pb, &ff_asf_comment_header); |
4372 | 339 put_le16(pb, title ? 2 * (strlen(title->value ) + 1) : 0); |
340 put_le16(pb, author ? 2 * (strlen(author->value ) + 1) : 0); | |
341 put_le16(pb, copyright ? 2 * (strlen(copyright->value) + 1) : 0); | |
342 put_le16(pb, comment ? 2 * (strlen(comment->value ) + 1) : 0); | |
0 | 343 put_le16(pb, 0); |
4372 | 344 if (title ) put_str16_nolen(pb, title->value ); |
345 if (author ) put_str16_nolen(pb, author->value ); | |
346 if (copyright) put_str16_nolen(pb, copyright->value); | |
347 if (comment ) put_str16_nolen(pb, comment->value ); | |
0 | 348 end_header(pb, hpos); |
349 } | |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
350 if (metadata_count) { |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
351 AVMetadataTag *tag = NULL; |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
352 hpos = put_header(pb, &ff_asf_extended_content_header); |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
353 put_le16(pb, metadata_count); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
354 while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) { |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
355 put_le16(pb, 2*(strlen(tag->key) + 3) + 1); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
356 put_le16(pb, 'W'); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
357 put_le16(pb, 'M'); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
358 put_le16(pb, '/'); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
359 put_str16_nolen(pb, tag->key); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
360 put_le16(pb, 0); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
361 put_le16(pb, 2*strlen(tag->value) + 1); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
362 put_str16_nolen(pb, tag->value); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
363 } |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
364 end_header(pb, hpos); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
365 } |
0 | 366 |
367 /* stream headers */ | |
368 for(n=0;n<s->nb_streams;n++) { | |
65 | 369 int64_t es_pos; |
0 | 370 // ASFStream *stream = &asf->streams[n]; |
371 | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
372 enc = s->streams[n]->codec; |
0 | 373 asf->streams[n].num = n + 1; |
374 asf->streams[n].seq = 0; | |
375 | |
885 | 376 |
0 | 377 switch(enc->codec_type) { |
378 case CODEC_TYPE_AUDIO: | |
379 wav_extra_size = 0; | |
380 extra_size = 18 + wav_extra_size; | |
1784
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
381 extra_size2 = 8; |
0 | 382 break; |
383 default: | |
384 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
|
385 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
|
386 extra_size = 0x33 + wav_extra_size; |
0 | 387 extra_size2 = 0; |
388 break; | |
389 } | |
390 | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
391 hpos = put_header(pb, &ff_asf_stream_header); |
0 | 392 if (enc->codec_type == CODEC_TYPE_AUDIO) { |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
393 put_guid(pb, &ff_asf_audio_stream); |
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
394 put_guid(pb, &ff_asf_audio_conceal_spread); |
0 | 395 } else { |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
396 put_guid(pb, &ff_asf_video_stream); |
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
397 put_guid(pb, &ff_asf_video_conceal_none); |
0 | 398 } |
399 put_le64(pb, 0); /* ??? */ | |
400 es_pos = url_ftell(pb); | |
401 put_le32(pb, extra_size); /* wav header len */ | |
402 put_le32(pb, extra_size2); /* additional data len */ | |
403 put_le16(pb, n + 1); /* stream number */ | |
404 put_le32(pb, 0); /* ??? */ | |
405 | |
406 if (enc->codec_type == CODEC_TYPE_AUDIO) { | |
407 /* WAVEFORMATEX header */ | |
408 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
|
409 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
|
410 wavsize += 2; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
411 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
|
412 } |
0 | 413 |
414 if (wavsize < 0) | |
415 return -1; | |
416 if (wavsize != extra_size) { | |
417 cur_pos = url_ftell(pb); | |
418 url_fseek(pb, es_pos, SEEK_SET); | |
419 put_le32(pb, wavsize); /* wav header len */ | |
420 url_fseek(pb, cur_pos, SEEK_SET); | |
421 } | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
422 /* ERROR Correction */ |
1784
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
423 put_byte(pb, 0x01); |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
424 if(enc->codec_id == CODEC_ID_ADPCM_G726 || !enc->block_align){ |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
425 put_le16(pb, 0x0190); |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
426 put_le16(pb, 0x0190); |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
427 }else{ |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
428 put_le16(pb, enc->block_align); |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
429 put_le16(pb, enc->block_align); |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
430 } |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
431 put_le16(pb, 0x01); |
597e5dd62399
always use audio spread (instead of "video no spread" for audio ...)
michael
parents:
1783
diff
changeset
|
432 put_byte(pb, 0x00); |
0 | 433 } else { |
434 put_le32(pb, enc->width); | |
435 put_le32(pb, enc->height); | |
436 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
|
437 put_le16(pb, 40 + enc->extradata_size); /* size */ |
0 | 438 |
439 /* BITMAPINFOHEADER header */ | |
440 put_bmp_header(pb, enc, codec_bmp_tags, 1); | |
441 } | |
442 end_header(pb, hpos); | |
443 } | |
444 | |
445 /* media comments */ | |
446 | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
447 hpos = put_header(pb, &ff_asf_codec_comment_header); |
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
448 put_guid(pb, &ff_asf_codec_comment1_header); |
0 | 449 put_le32(pb, s->nb_streams); |
450 for(n=0;n<s->nb_streams;n++) { | |
451 AVCodec *p; | |
452 | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
453 enc = s->streams[n]->codec; |
0 | 454 p = avcodec_find_encoder(enc->codec_id); |
455 | |
1863
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
456 if(enc->codec_type == CODEC_TYPE_AUDIO) |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
457 put_le16(pb, 2); |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
458 else if(enc->codec_type == CODEC_TYPE_VIDEO) |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
459 put_le16(pb, 1); |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
460 else |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
461 put_le16(pb, -1); |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
462 |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
463 if(enc->codec_id == CODEC_ID_WMAV2) |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
464 put_str16(pb, "Windows Media Audio V8"); |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
465 else |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
466 put_str16(pb, p ? p->name : enc->codec_name); |
0 | 467 put_le16(pb, 0); /* no parameters */ |
885 | 468 |
469 | |
0 | 470 /* id */ |
471 if (enc->codec_type == CODEC_TYPE_AUDIO) { | |
472 put_le16(pb, 2); | |
196 | 473 put_le16(pb, enc->codec_tag); |
0 | 474 } else { |
475 put_le16(pb, 4); | |
196 | 476 put_le32(pb, enc->codec_tag); |
0 | 477 } |
1685 | 478 if(!enc->codec_tag) |
479 return -1; | |
0 | 480 } |
481 end_header(pb, hpos); | |
482 | |
483 /* patch the header size fields */ | |
484 | |
485 cur_pos = url_ftell(pb); | |
486 header_size = cur_pos - header_offset; | |
487 if (asf->is_streamed) { | |
488 header_size += 8 + 30 + 50; | |
489 | |
490 url_fseek(pb, header_offset - 10 - 30, SEEK_SET); | |
491 put_le16(pb, header_size); | |
492 url_fseek(pb, header_offset - 2 - 30, SEEK_SET); | |
493 put_le16(pb, header_size); | |
494 | |
495 header_size -= 8 + 30 + 50; | |
496 } | |
497 header_size += 24 + 6; | |
498 url_fseek(pb, header_offset - 14, SEEK_SET); | |
499 put_le64(pb, header_size); | |
500 url_fseek(pb, cur_pos, SEEK_SET); | |
501 | |
502 /* movie chunk, followed by packets of packet_size */ | |
503 asf->data_offset = cur_pos; | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
504 put_guid(pb, &ff_asf_data_header); |
0 | 505 put_le64(pb, data_chunk_size); |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
506 put_guid(pb, &ff_asf_my_guid); |
0 | 507 put_le64(pb, asf->nb_packets); /* nb packets */ |
508 put_byte(pb, 1); /* ??? */ | |
509 put_byte(pb, 1); /* ??? */ | |
510 return 0; | |
511 } | |
512 | |
513 static int asf_write_header(AVFormatContext *s) | |
514 { | |
515 ASFContext *asf = s->priv_data; | |
516 | |
517 asf->packet_size = PACKET_SIZE; | |
518 asf->nb_packets = 0; | |
885 | 519 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
520 asf->last_indexed_pts = 0; |
2787
8453787462c1
stupid code (casting of void*) found by checktree.sh
michael
parents:
2771
diff
changeset
|
521 asf->index_ptr = av_malloc( sizeof(ASFIndex) * ASF_INDEX_BLOCK ); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
522 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
|
523 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
|
524 asf->maximum_packet = 0; |
0 | 525 |
2615 | 526 /* the data-chunk-size has to be 50, which is data_size - asf->data_offset |
527 * at the moment this function is done. It is needed to use asf as | |
528 * streamable format. */ | |
529 if (asf_write_header1(s, 0, 50) < 0) { | |
0 | 530 //av_free(asf); |
531 return -1; | |
532 } | |
533 | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
534 put_flush_packet(s->pb); |
0 | 535 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
536 asf->packet_nb_payloads = 0; |
0 | 537 asf->packet_timestamp_start = -1; |
538 asf->packet_timestamp_end = -1; | |
539 init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1, | |
540 NULL, NULL, NULL, NULL); | |
541 | |
542 return 0; | |
543 } | |
544 | |
545 static int asf_write_stream_header(AVFormatContext *s) | |
546 { | |
547 ASFContext *asf = s->priv_data; | |
548 | |
549 asf->is_streamed = 1; | |
550 | |
551 return asf_write_header(s); | |
552 } | |
553 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
554 static int put_payload_parsing_info( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
555 AVFormatContext *s, |
885 | 556 unsigned int sendtime, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
557 unsigned int duration, |
885 | 558 int nb_payloads, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
559 int padsize |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
560 ) |
0 | 561 { |
562 ASFContext *asf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
563 ByteIOContext *pb = s->pb; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
564 int ppi_size, i; |
1766
49b67c70e9c9
remove senseless and wrong direct access to ByteIOContext internals
michael
parents:
1764
diff
changeset
|
565 int64_t start= url_ftell(pb); |
0 | 566 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
567 int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS; |
885 | 568 |
1775 | 569 padsize -= PACKET_HEADER_MIN_SIZE; |
570 if(asf->multi_payloads_present) | |
571 padsize--; | |
572 assert(padsize>=0); | |
573 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
574 put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
575 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
|
576 put_byte(pb, 0x0); |
0 | 577 } |
578 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
579 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
580 iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT; |
0 | 581 |
582 if (padsize > 0) { | |
583 if (padsize < 256) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
584 iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE; |
0 | 585 else |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
586 iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD; |
0 | 587 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
588 put_byte(pb, iLengthTypeFlags); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
589 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
590 put_byte(pb, ASF_PPI_PROPERTY_FLAGS); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
591 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
592 if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD) |
0 | 593 put_le16(pb, padsize - 2); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
594 if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE) |
0 | 595 put_byte(pb, padsize - 1); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
596 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
597 put_le32(pb, sendtime); |
0 | 598 put_le16(pb, duration); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
599 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
600 put_byte(pb, nb_payloads | ASF_PAYLOAD_FLAGS); |
0 | 601 |
1766
49b67c70e9c9
remove senseless and wrong direct access to ByteIOContext internals
michael
parents:
1764
diff
changeset
|
602 ppi_size = url_ftell(pb) - start; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
603 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
604 return ppi_size; |
0 | 605 } |
606 | |
607 static void flush_packet(AVFormatContext *s) | |
608 { | |
609 ASFContext *asf = s->priv_data; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
610 int packet_hdr_size, packet_filled_size; |
0 | 611 |
2801
dafc142ae2e2
add assert to detect invalid packet_timestamp_start/end
michael
parents:
2800
diff
changeset
|
612 assert(asf->packet_timestamp_end >= asf->packet_timestamp_start); |
dafc142ae2e2
add assert to detect invalid packet_timestamp_start/end
michael
parents:
2800
diff
changeset
|
613 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
614 if (asf->is_streamed) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
615 put_chunk(s, 0x4424, asf->packet_size, 0); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
616 } |
0 | 617 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
618 packet_hdr_size = put_payload_parsing_info( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
619 s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
620 asf->packet_timestamp_start, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
621 asf->packet_timestamp_end - asf->packet_timestamp_start, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
622 asf->packet_nb_payloads, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
623 asf->packet_size_left |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
624 ); |
0 | 625 |
1775 | 626 packet_filled_size = PACKET_SIZE - asf->packet_size_left; |
627 assert(packet_hdr_size <= asf->packet_size_left); | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
628 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
|
629 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
630 put_buffer(s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size); |
0 | 631 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
632 put_flush_packet(s->pb); |
0 | 633 asf->nb_packets++; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
634 asf->packet_nb_payloads = 0; |
0 | 635 asf->packet_timestamp_start = -1; |
636 asf->packet_timestamp_end = -1; | |
637 init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1, | |
638 NULL, NULL, NULL, NULL); | |
639 } | |
640 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
641 static void put_payload_header( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
642 AVFormatContext *s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
643 ASFStream *stream, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
644 int presentation_time, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
645 int m_obj_size, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
646 int m_obj_offset, |
470 | 647 int payload_len, |
648 int flags | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
649 ) |
0 | 650 { |
651 ASFContext *asf = s->priv_data; | |
652 ByteIOContext *pb = &asf->pb; | |
653 int val; | |
885 | 654 |
0 | 655 val = stream->num; |
470 | 656 if (flags & PKT_FLAG_KEY) |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
657 val |= ASF_PL_FLAG_KEY_FRAME; |
0 | 658 put_byte(pb, val); |
885 | 659 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
660 put_byte(pb, stream->seq); //Media object number |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
661 put_le32(pb, m_obj_offset); //Offset Into Media Object |
885 | 662 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
663 // Replicated Data shall be at least 8 bytes long. |
885 | 664 // 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
|
665 // Size of the Media Object that the payload belongs to. |
885 | 666 // 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
|
667 // 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
|
668 put_byte(pb, ASF_PAYLOAD_REPLICATED_DATA_LENGTH); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
669 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
670 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
|
671 put_le32(pb, presentation_time);//Replicated Data - Presentation Time |
885 | 672 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
673 if (asf->multi_payloads_present){ |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
674 put_le16(pb, payload_len); //payload length |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
675 } |
0 | 676 } |
677 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
678 static void put_frame( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
679 AVFormatContext *s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
680 ASFStream *stream, |
1880
54f814d6708c
prevent audio packets from being fragmented, wmp mac doesnt seem to like that and microshitty also doesnt seem to ever fragment them
michael
parents:
1863
diff
changeset
|
681 AVStream *avst, |
887 | 682 int timestamp, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
683 const uint8_t *buf, |
887 | 684 int m_obj_size, |
470 | 685 int flags |
887 | 686 ) |
0 | 687 { |
688 ASFContext *asf = s->priv_data; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
689 int m_obj_offset, payload_len, frag_len1; |
0 | 690 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
691 m_obj_offset = 0; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
692 while (m_obj_offset < m_obj_size) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
693 payload_len = m_obj_size - m_obj_offset; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
694 if (asf->packet_timestamp_start == -1) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
695 asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT); |
885 | 696 |
1775 | 697 asf->packet_size_left = PACKET_SIZE; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
698 if (asf->multi_payloads_present){ |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
699 frag_len1 = MULTI_PAYLOAD_CONSTANT - 1; |
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 else { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
702 frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
703 } |
1764 | 704 asf->packet_timestamp_start = timestamp; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
705 } |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
706 else { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
707 // multi payloads |
1775 | 708 frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS - PACKET_HEADER_MIN_SIZE - 1; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
709 |
1880
54f814d6708c
prevent audio packets from being fragmented, wmp mac doesnt seem to like that and microshitty also doesnt seem to ever fragment them
michael
parents:
1863
diff
changeset
|
710 if(frag_len1 < payload_len && avst->codec->codec_type == CODEC_TYPE_AUDIO){ |
54f814d6708c
prevent audio packets from being fragmented, wmp mac doesnt seem to like that and microshitty also doesnt seem to ever fragment them
michael
parents:
1863
diff
changeset
|
711 flush_packet(s); |
54f814d6708c
prevent audio packets from being fragmented, wmp mac doesnt seem to like that and microshitty also doesnt seem to ever fragment them
michael
parents:
1863
diff
changeset
|
712 continue; |
54f814d6708c
prevent audio packets from being fragmented, wmp mac doesnt seem to like that and microshitty also doesnt seem to ever fragment them
michael
parents:
1863
diff
changeset
|
713 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
714 } |
0 | 715 if (frag_len1 > 0) { |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
716 if (payload_len > frag_len1) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
717 payload_len = frag_len1; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
718 else if (payload_len == (frag_len1 - 1)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
719 payload_len = frag_len1 - 2; //additional byte need to put padding length |
885 | 720 |
1887
490aa34aef0f
move preroll_time from static variable into definition, might be a good idea moving this into the context and making user-settable
alex
parents:
1880
diff
changeset
|
721 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
|
722 put_buffer(&asf->pb, buf, payload_len); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
723 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
724 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
725 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
|
726 else |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
727 asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD); |
0 | 728 asf->packet_timestamp_end = timestamp; |
885 | 729 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
730 asf->packet_nb_payloads++; |
0 | 731 } else { |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
732 payload_len = 0; |
0 | 733 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
734 m_obj_offset += payload_len; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
735 buf += payload_len; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
736 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
737 if (!asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
738 flush_packet(s); |
1775 | 739 else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + PACKET_HEADER_MIN_SIZE + 1)) |
0 | 740 flush_packet(s); |
741 } | |
742 stream->seq++; | |
743 } | |
744 | |
468 | 745 static int asf_write_packet(AVFormatContext *s, AVPacket *pkt) |
0 | 746 { |
747 ASFContext *asf = s->priv_data; | |
748 ASFStream *stream; | |
65 | 749 int64_t duration; |
0 | 750 AVCodecContext *codec; |
885 | 751 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
|
752 int start_sec,i; |
1782
4f4edbced58a
dont set the keyframe flag for audio as microshitty doesnt do it and some things have problems with our asfs, maybe that has a positive effect?
michael
parents:
1775
diff
changeset
|
753 int flags= pkt->flags; |
0 | 754 |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
755 codec = s->streams[pkt->stream_index]->codec; |
468 | 756 stream = &asf->streams[pkt->stream_index]; |
0 | 757 |
1782
4f4edbced58a
dont set the keyframe flag for audio as microshitty doesnt do it and some things have problems with our asfs, maybe that has a positive effect?
michael
parents:
1775
diff
changeset
|
758 if(codec->codec_type == CODEC_TYPE_AUDIO) |
4f4edbced58a
dont set the keyframe flag for audio as microshitty doesnt do it and some things have problems with our asfs, maybe that has a positive effect?
michael
parents:
1775
diff
changeset
|
759 flags &= ~PKT_FLAG_KEY; |
4f4edbced58a
dont set the keyframe flag for audio as microshitty doesnt do it and some things have problems with our asfs, maybe that has a positive effect?
michael
parents:
1775
diff
changeset
|
760 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
761 pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts; |
1762
cb8b538021cd
muxing packets with unknown timestamps is not allowed
michael
parents:
1687
diff
changeset
|
762 assert(pts != AV_NOPTS_VALUE); |
cb8b538021cd
muxing packets with unknown timestamps is not allowed
michael
parents:
1687
diff
changeset
|
763 duration = pts * 10000; |
3236 | 764 asf->duration= FFMAX(asf->duration, duration + pkt->duration * 10000); |
0 | 765 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
766 packet_st = asf->nb_packets; |
1880
54f814d6708c
prevent audio packets from being fragmented, wmp mac doesnt seem to like that and microshitty also doesnt seem to ever fragment them
michael
parents:
1863
diff
changeset
|
767 put_frame(s, stream, s->streams[pkt->stream_index], pkt->dts, pkt->data, pkt->size, flags); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
768 |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
769 /* check index */ |
1782
4f4edbced58a
dont set the keyframe flag for audio as microshitty doesnt do it and some things have problems with our asfs, maybe that has a positive effect?
michael
parents:
1775
diff
changeset
|
770 if ((!asf->is_streamed) && (flags & PKT_FLAG_KEY)) { |
1556 | 771 start_sec = (int)(duration / INT64_C(10000000)); |
772 if (start_sec != (int)(asf->last_indexed_pts / INT64_C(10000000))) { | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
773 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
|
774 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
|
775 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
|
776 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
|
777 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
778 // store |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
779 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
|
780 asf->index_ptr[i].packet_count = (uint16_t)(asf->nb_packets-packet_st); |
1685 | 781 asf->maximum_packet = FFMAX(asf->maximum_packet, (uint16_t)(asf->nb_packets-packet_st)); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
782 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
783 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
|
784 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
|
785 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
786 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
787 return 0; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
788 } |
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 // |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
791 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
|
792 { |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
793 ByteIOContext *pb = s->pb; |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
794 int i; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
795 |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
796 put_guid(pb, &ff_asf_simple_index_header); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
797 put_le64(pb, 24 + 16 + 8 + 4 + 4 + (4 + 2)*count); |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
798 put_guid(pb, &ff_asf_my_guid); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 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
|
805 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
806 |
0 | 807 return 0; |
808 } | |
809 | |
810 static int asf_write_trailer(AVFormatContext *s) | |
811 { | |
812 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
|
813 int64_t file_size,data_size; |
0 | 814 |
815 /* flush the current packet */ | |
816 if (asf->pb.buf_ptr > asf->pb.buffer) | |
817 flush_packet(s); | |
818 | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
819 /* write index */ |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
820 data_size = url_ftell(s->pb); |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
821 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
|
822 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
|
823 } |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
824 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
|
825 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
826 if (asf->is_streamed || url_is_streamed(s->pb)) { |
0 | 827 put_chunk(s, 0x4524, 0, 0); /* end of stream */ |
828 } else { | |
829 /* rewrite an updated header */ | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
830 file_size = url_ftell(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
831 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
|
832 asf_write_header1(s, file_size, data_size - asf->data_offset); |
0 | 833 } |
834 | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
835 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
|
836 av_free(asf->index_ptr); |
0 | 837 return 0; |
838 } | |
839 | |
4206 | 840 #if CONFIG_ASF_MUXER |
1167 | 841 AVOutputFormat asf_muxer = { |
0 | 842 "asf", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3236
diff
changeset
|
843 NULL_IF_CONFIG_SMALL("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
|
844 "video/x-ms-asf", |
672 | 845 "asf,wmv,wma", |
0 | 846 sizeof(ASFContext), |
4206 | 847 #if CONFIG_LIBMP3LAME |
232 | 848 CODEC_ID_MP3, |
0 | 849 #else |
850 CODEC_ID_MP2, | |
851 #endif | |
852 CODEC_ID_MSMPEG4V3, | |
853 asf_write_header, | |
854 asf_write_packet, | |
855 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
|
856 .flags = AVFMT_GLOBALHEADER, |
3766
f062deeedb8d
Change codec_tag type from const struct AVCodecTag ** to const struct AVCodecTag * const *
reimar
parents:
3424
diff
changeset
|
857 .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0}, |
4618
5b9eddbee9c4
Add some basic metadata conversion tables for matroska and asf.
aurel
parents:
4593
diff
changeset
|
858 .metadata_conv = ff_asf_metadata_conv, |
0 | 859 }; |
1169 | 860 #endif |
0 | 861 |
4206 | 862 #if CONFIG_ASF_STREAM_MUXER |
1167 | 863 AVOutputFormat asf_stream_muxer = { |
0 | 864 "asf_stream", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3236
diff
changeset
|
865 NULL_IF_CONFIG_SMALL("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
|
866 "video/x-ms-asf", |
672 | 867 "asf,wmv,wma", |
0 | 868 sizeof(ASFContext), |
4206 | 869 #if CONFIG_LIBMP3LAME |
232 | 870 CODEC_ID_MP3, |
0 | 871 #else |
872 CODEC_ID_MP2, | |
873 #endif | |
874 CODEC_ID_MSMPEG4V3, | |
875 asf_write_stream_header, | |
876 asf_write_packet, | |
877 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
|
878 .flags = AVFMT_GLOBALHEADER, |
3766
f062deeedb8d
Change codec_tag type from const struct AVCodecTag ** to const struct AVCodecTag * const *
reimar
parents:
3424
diff
changeset
|
879 .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0}, |
4618
5b9eddbee9c4
Add some basic metadata conversion tables for matroska and asf.
aurel
parents:
4593
diff
changeset
|
880 .metadata_conv = ff_asf_metadata_conv, |
0 | 881 }; |
1169 | 882 #endif //CONFIG_ASF_STREAM_MUXER |