Mercurial > libavformat.hg
annotate asfenc.c @ 6043:f8d603e0850f libavformat
oups, 100l, revert unrelated hunk from commit r23266
author | bcoudurier |
---|---|
date | Sun, 23 May 2010 21:10:05 +0000 |
parents | 11bb10c37225 |
children |
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 | |
5720 | 206 static void put_str16(ByteIOContext *s, const char *tag) |
207 { | |
208 int len; | |
209 uint8_t *pb; | |
210 ByteIOContext *dyn_buf; | |
211 if (url_open_dyn_buf(&dyn_buf) < 0) | |
212 return; | |
213 | |
5876
2c0f0162a110
Move put_le16_nolen() to asf.c and give it a ff_ prefix. This way, it is easier
rbultje
parents:
5720
diff
changeset
|
214 ff_put_str16_nolen(dyn_buf, tag); |
5720 | 215 len = url_close_dyn_buf(dyn_buf, &pb); |
216 put_le16(s, len); | |
217 put_buffer(s, pb, len); | |
218 av_freep(&pb); | |
0 | 219 } |
220 | |
4748
86dd0cab30d3
Rename GUID typedef to ff_asf_guid to fix MinGW compilation failure
reimar
parents:
4618
diff
changeset
|
221 static int64_t put_header(ByteIOContext *pb, const ff_asf_guid *g) |
0 | 222 { |
65 | 223 int64_t pos; |
0 | 224 |
225 pos = url_ftell(pb); | |
226 put_guid(pb, g); | |
227 put_le64(pb, 24); | |
228 return pos; | |
229 } | |
230 | |
231 /* update header size */ | |
65 | 232 static void end_header(ByteIOContext *pb, int64_t pos) |
0 | 233 { |
65 | 234 int64_t pos1; |
0 | 235 |
236 pos1 = url_ftell(pb); | |
237 url_fseek(pb, pos + 16, SEEK_SET); | |
238 put_le64(pb, pos1 - pos); | |
239 url_fseek(pb, pos1, SEEK_SET); | |
240 } | |
241 | |
242 /* write an asf chunk (only used in streaming case) */ | |
243 static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags) | |
244 { | |
245 ASFContext *asf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
246 ByteIOContext *pb = s->pb; |
0 | 247 int length; |
248 | |
249 length = payload_length + 8; | |
250 put_le16(pb, type); | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
251 put_le16(pb, length); //size |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
252 put_le32(pb, asf->seqno);//sequence number |
0 | 253 put_le16(pb, flags); /* unknown bytes */ |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
254 put_le16(pb, length); //size_confirm |
0 | 255 asf->seqno++; |
256 } | |
257 | |
258 /* convert from unix to windows time */ | |
65 | 259 static int64_t unix_to_file_time(int ti) |
0 | 260 { |
65 | 261 int64_t t; |
0 | 262 |
1556 | 263 t = ti * INT64_C(10000000); |
264 t += INT64_C(116444736000000000); | |
0 | 265 return t; |
266 } | |
267 | |
268 /* write the header (used two times if non streamed) */ | |
65 | 269 static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size) |
0 | 270 { |
271 ASFContext *asf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
272 ByteIOContext *pb = s->pb; |
5719 | 273 AVMetadataTag *tags[5]; |
0 | 274 int header_size, n, extra_size, extra_size2, wav_extra_size, file_time; |
275 int has_title; | |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
276 int metadata_count; |
0 | 277 AVCodecContext *enc; |
65 | 278 int64_t header_offset, cur_pos, hpos; |
0 | 279 int bit_rate; |
1345 | 280 int64_t duration; |
0 | 281 |
5719 | 282 tags[0] = av_metadata_get(s->metadata, "title" , NULL, 0); |
283 tags[1] = av_metadata_get(s->metadata, "author" , NULL, 0); | |
284 tags[2] = av_metadata_get(s->metadata, "copyright", NULL, 0); | |
285 tags[3] = av_metadata_get(s->metadata, "comment" , NULL, 0); | |
286 tags[4] = av_metadata_get(s->metadata, "rating" , NULL, 0); | |
4372 | 287 |
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
|
288 duration = asf->duration + PREROLL_TIME * 10000; |
5719 | 289 has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4]; |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
290 metadata_count = s->metadata ? s->metadata->count : 0; |
0 | 291 |
292 bit_rate = 0; | |
293 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
|
294 enc = s->streams[n]->codec; |
0 | 295 |
462
b69898ffc92a
move time_base (pts_num/pts_den) from AVFormatContext -> AVStream
michael
parents:
373
diff
changeset
|
296 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
|
297 |
0 | 298 bit_rate += enc->bit_rate; |
299 } | |
300 | |
301 if (asf->is_streamed) { | |
302 put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */ | |
303 } | |
304 | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
305 put_guid(pb, &ff_asf_header); |
0 | 306 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
|
307 put_le32(pb, 3 + has_title + !!metadata_count + s->nb_streams); /* number of chunks in header */ |
0 | 308 put_byte(pb, 1); /* ??? */ |
309 put_byte(pb, 2); /* ??? */ | |
310 | |
311 /* file header */ | |
312 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
|
313 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
|
314 put_guid(pb, &ff_asf_my_guid); |
0 | 315 put_le64(pb, file_size); |
316 file_time = 0; | |
317 put_le64(pb, unix_to_file_time(file_time)); | |
318 put_le64(pb, asf->nb_packets); /* number of packets */ | |
1345 | 319 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
|
320 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
|
321 put_le64(pb, PREROLL_TIME); /* start time stamp */ |
1895 | 322 put_le32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */ |
5067
499c21a8e0c2
Remove any reference to ASFContext.packet_size and replace it with
rbultje
parents:
5058
diff
changeset
|
323 put_le32(pb, s->packet_size); /* packet size */ |
499c21a8e0c2
Remove any reference to ASFContext.packet_size and replace it with
rbultje
parents:
5058
diff
changeset
|
324 put_le32(pb, s->packet_size); /* packet size */ |
0 | 325 put_le32(pb, bit_rate); /* Nominal data rate in bps */ |
326 end_header(pb, hpos); | |
327 | |
328 /* unknown headers */ | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
329 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
|
330 put_guid(pb, &ff_asf_head2_guid); |
0 | 331 put_le32(pb, 6); |
332 put_le16(pb, 0); | |
333 end_header(pb, hpos); | |
334 | |
335 /* title and other infos */ | |
336 if (has_title) { | |
5720 | 337 int len; |
338 uint8_t *buf; | |
339 ByteIOContext *dyn_buf; | |
340 | |
341 if (url_open_dyn_buf(&dyn_buf) < 0) | |
342 return AVERROR(ENOMEM); | |
343 | |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
344 hpos = put_header(pb, &ff_asf_comment_header); |
5720 | 345 |
346 for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) { | |
5876
2c0f0162a110
Move put_le16_nolen() to asf.c and give it a ff_ prefix. This way, it is easier
rbultje
parents:
5720
diff
changeset
|
347 len = tags[n] ? ff_put_str16_nolen(dyn_buf, tags[n]->value) : 0; |
5720 | 348 put_le16(pb, len); |
349 } | |
350 len = url_close_dyn_buf(dyn_buf, &buf); | |
351 put_buffer(pb, buf, len); | |
352 av_freep(&buf); | |
0 | 353 end_header(pb, hpos); |
354 } | |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
355 if (metadata_count) { |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
356 AVMetadataTag *tag = NULL; |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
357 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
|
358 put_le16(pb, metadata_count); |
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
359 while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) { |
5720 | 360 put_str16(pb, tag->key); |
4373
7eef34a6f1c0
write all available metadata tags into extended_content_header
aurel
parents:
4372
diff
changeset
|
361 put_le16(pb, 0); |
5720 | 362 put_str16(pb, tag->value); |
4373
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) { |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
378 case AVMEDIA_TYPE_AUDIO: |
0 | 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: | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
384 case AVMEDIA_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); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
392 if (enc->codec_type == AVMEDIA_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 | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
406 if (enc->codec_type == AVMEDIA_TYPE_AUDIO) { |
0 | 407 /* WAVEFORMATEX header */ |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4748
diff
changeset
|
408 int wavsize = ff_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 */ | |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4748
diff
changeset
|
440 ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1); |
0 | 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; | |
5713 | 452 const char *desc; |
5720 | 453 int len; |
454 uint8_t *buf; | |
455 ByteIOContext *dyn_buf; | |
0 | 456 |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
457 enc = s->streams[n]->codec; |
0 | 458 p = avcodec_find_encoder(enc->codec_id); |
459 | |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
460 if(enc->codec_type == AVMEDIA_TYPE_AUDIO) |
1863
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
461 put_le16(pb, 2); |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
462 else if(enc->codec_type == AVMEDIA_TYPE_VIDEO) |
1863
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
463 put_le16(pb, 1); |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
464 else |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
465 put_le16(pb, -1); |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
466 |
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
467 if(enc->codec_id == CODEC_ID_WMAV2) |
5713 | 468 desc = "Windows Media Audio V8"; |
1863
97b153836b82
create codec_comment_header which looks more like what M$ creates, sane or not ...
michael
parents:
1862
diff
changeset
|
469 else |
5713 | 470 desc = p ? p->name : enc->codec_name; |
5720 | 471 |
472 if ( url_open_dyn_buf(&dyn_buf) < 0) | |
473 return AVERROR(ENOMEM); | |
474 | |
5876
2c0f0162a110
Move put_le16_nolen() to asf.c and give it a ff_ prefix. This way, it is easier
rbultje
parents:
5720
diff
changeset
|
475 ff_put_str16_nolen(dyn_buf, desc); |
5720 | 476 len = url_close_dyn_buf(dyn_buf, &buf); |
477 put_le16(pb, len / 2); // "number of characters" = length in bytes / 2 | |
478 | |
479 put_buffer(pb, buf, len); | |
480 av_freep(&buf); | |
481 | |
0 | 482 put_le16(pb, 0); /* no parameters */ |
885 | 483 |
484 | |
0 | 485 /* id */ |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
486 if (enc->codec_type == AVMEDIA_TYPE_AUDIO) { |
0 | 487 put_le16(pb, 2); |
196 | 488 put_le16(pb, enc->codec_tag); |
0 | 489 } else { |
490 put_le16(pb, 4); | |
196 | 491 put_le32(pb, enc->codec_tag); |
0 | 492 } |
1685 | 493 if(!enc->codec_tag) |
494 return -1; | |
0 | 495 } |
496 end_header(pb, hpos); | |
497 | |
498 /* patch the header size fields */ | |
499 | |
500 cur_pos = url_ftell(pb); | |
501 header_size = cur_pos - header_offset; | |
502 if (asf->is_streamed) { | |
503 header_size += 8 + 30 + 50; | |
504 | |
505 url_fseek(pb, header_offset - 10 - 30, SEEK_SET); | |
506 put_le16(pb, header_size); | |
507 url_fseek(pb, header_offset - 2 - 30, SEEK_SET); | |
508 put_le16(pb, header_size); | |
509 | |
510 header_size -= 8 + 30 + 50; | |
511 } | |
512 header_size += 24 + 6; | |
513 url_fseek(pb, header_offset - 14, SEEK_SET); | |
514 put_le64(pb, header_size); | |
515 url_fseek(pb, cur_pos, SEEK_SET); | |
516 | |
517 /* movie chunk, followed by packets of packet_size */ | |
518 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
|
519 put_guid(pb, &ff_asf_data_header); |
0 | 520 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
|
521 put_guid(pb, &ff_asf_my_guid); |
0 | 522 put_le64(pb, asf->nb_packets); /* nb packets */ |
523 put_byte(pb, 1); /* ??? */ | |
524 put_byte(pb, 1); /* ??? */ | |
525 return 0; | |
526 } | |
527 | |
528 static int asf_write_header(AVFormatContext *s) | |
529 { | |
530 ASFContext *asf = s->priv_data; | |
531 | |
5067
499c21a8e0c2
Remove any reference to ASFContext.packet_size and replace it with
rbultje
parents:
5058
diff
changeset
|
532 s->packet_size = PACKET_SIZE; |
0 | 533 asf->nb_packets = 0; |
885 | 534 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
535 asf->last_indexed_pts = 0; |
2787
8453787462c1
stupid code (casting of void*) found by checktree.sh
michael
parents:
2771
diff
changeset
|
536 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
|
537 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
|
538 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
|
539 asf->maximum_packet = 0; |
0 | 540 |
2615 | 541 /* the data-chunk-size has to be 50, which is data_size - asf->data_offset |
542 * at the moment this function is done. It is needed to use asf as | |
543 * streamable format. */ | |
544 if (asf_write_header1(s, 0, 50) < 0) { | |
0 | 545 //av_free(asf); |
546 return -1; | |
547 } | |
548 | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
549 put_flush_packet(s->pb); |
0 | 550 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
551 asf->packet_nb_payloads = 0; |
0 | 552 asf->packet_timestamp_start = -1; |
553 asf->packet_timestamp_end = -1; | |
5067
499c21a8e0c2
Remove any reference to ASFContext.packet_size and replace it with
rbultje
parents:
5058
diff
changeset
|
554 init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1, |
0 | 555 NULL, NULL, NULL, NULL); |
556 | |
557 return 0; | |
558 } | |
559 | |
560 static int asf_write_stream_header(AVFormatContext *s) | |
561 { | |
562 ASFContext *asf = s->priv_data; | |
563 | |
564 asf->is_streamed = 1; | |
565 | |
566 return asf_write_header(s); | |
567 } | |
568 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
569 static int put_payload_parsing_info( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
570 AVFormatContext *s, |
885 | 571 unsigned int sendtime, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
572 unsigned int duration, |
885 | 573 int nb_payloads, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
574 int padsize |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
575 ) |
0 | 576 { |
577 ASFContext *asf = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
578 ByteIOContext *pb = s->pb; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
579 int ppi_size, i; |
1766
49b67c70e9c9
remove senseless and wrong direct access to ByteIOContext internals
michael
parents:
1764
diff
changeset
|
580 int64_t start= url_ftell(pb); |
0 | 581 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
582 int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS; |
885 | 583 |
1775 | 584 padsize -= PACKET_HEADER_MIN_SIZE; |
585 if(asf->multi_payloads_present) | |
586 padsize--; | |
587 assert(padsize>=0); | |
588 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
589 put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
590 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
|
591 put_byte(pb, 0x0); |
0 | 592 } |
593 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
594 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
595 iLengthTypeFlags |= ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT; |
0 | 596 |
597 if (padsize > 0) { | |
598 if (padsize < 256) | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
599 iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE; |
0 | 600 else |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
601 iLengthTypeFlags |= ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD; |
0 | 602 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
603 put_byte(pb, iLengthTypeFlags); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
604 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
605 put_byte(pb, ASF_PPI_PROPERTY_FLAGS); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
606 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
607 if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD) |
0 | 608 put_le16(pb, padsize - 2); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
609 if (iLengthTypeFlags & ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE) |
0 | 610 put_byte(pb, padsize - 1); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
611 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
612 put_le32(pb, sendtime); |
0 | 613 put_le16(pb, duration); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
614 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
615 put_byte(pb, nb_payloads | ASF_PAYLOAD_FLAGS); |
0 | 616 |
1766
49b67c70e9c9
remove senseless and wrong direct access to ByteIOContext internals
michael
parents:
1764
diff
changeset
|
617 ppi_size = url_ftell(pb) - start; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
618 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
619 return ppi_size; |
0 | 620 } |
621 | |
622 static void flush_packet(AVFormatContext *s) | |
623 { | |
624 ASFContext *asf = s->priv_data; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
625 int packet_hdr_size, packet_filled_size; |
0 | 626 |
2801
dafc142ae2e2
add assert to detect invalid packet_timestamp_start/end
michael
parents:
2800
diff
changeset
|
627 assert(asf->packet_timestamp_end >= asf->packet_timestamp_start); |
dafc142ae2e2
add assert to detect invalid packet_timestamp_start/end
michael
parents:
2800
diff
changeset
|
628 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
629 if (asf->is_streamed) { |
5067
499c21a8e0c2
Remove any reference to ASFContext.packet_size and replace it with
rbultje
parents:
5058
diff
changeset
|
630 put_chunk(s, 0x4424, s->packet_size, 0); |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
631 } |
0 | 632 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
633 packet_hdr_size = put_payload_parsing_info( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
634 s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
635 asf->packet_timestamp_start, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
636 asf->packet_timestamp_end - asf->packet_timestamp_start, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
637 asf->packet_nb_payloads, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
638 asf->packet_size_left |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
639 ); |
0 | 640 |
1775 | 641 packet_filled_size = PACKET_SIZE - asf->packet_size_left; |
642 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
|
643 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
|
644 |
5067
499c21a8e0c2
Remove any reference to ASFContext.packet_size and replace it with
rbultje
parents:
5058
diff
changeset
|
645 put_buffer(s->pb, asf->packet_buf, s->packet_size - packet_hdr_size); |
0 | 646 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
647 put_flush_packet(s->pb); |
0 | 648 asf->nb_packets++; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
649 asf->packet_nb_payloads = 0; |
0 | 650 asf->packet_timestamp_start = -1; |
651 asf->packet_timestamp_end = -1; | |
5067
499c21a8e0c2
Remove any reference to ASFContext.packet_size and replace it with
rbultje
parents:
5058
diff
changeset
|
652 init_put_byte(&asf->pb, asf->packet_buf, s->packet_size, 1, |
0 | 653 NULL, NULL, NULL, NULL); |
654 } | |
655 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
656 static void put_payload_header( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
657 AVFormatContext *s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
658 ASFStream *stream, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
659 int presentation_time, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
660 int m_obj_size, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
661 int m_obj_offset, |
470 | 662 int payload_len, |
663 int flags | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
664 ) |
0 | 665 { |
666 ASFContext *asf = s->priv_data; | |
667 ByteIOContext *pb = &asf->pb; | |
668 int val; | |
885 | 669 |
0 | 670 val = stream->num; |
5913
11bb10c37225
Replace all occurences of PKT_FLAG_KEY with AV_PKT_FLAG_KEY.
cehoyos
parents:
5910
diff
changeset
|
671 if (flags & AV_PKT_FLAG_KEY) |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
672 val |= ASF_PL_FLAG_KEY_FRAME; |
0 | 673 put_byte(pb, val); |
885 | 674 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
675 put_byte(pb, stream->seq); //Media object number |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
676 put_le32(pb, m_obj_offset); //Offset Into Media Object |
885 | 677 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
678 // Replicated Data shall be at least 8 bytes long. |
885 | 679 // 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
|
680 // Size of the Media Object that the payload belongs to. |
885 | 681 // 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
|
682 // 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
|
683 put_byte(pb, ASF_PAYLOAD_REPLICATED_DATA_LENGTH); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
684 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
685 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
|
686 put_le32(pb, presentation_time);//Replicated Data - Presentation Time |
885 | 687 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
688 if (asf->multi_payloads_present){ |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
689 put_le16(pb, payload_len); //payload length |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
690 } |
0 | 691 } |
692 | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
693 static void put_frame( |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
694 AVFormatContext *s, |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
695 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
|
696 AVStream *avst, |
887 | 697 int timestamp, |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
698 const uint8_t *buf, |
887 | 699 int m_obj_size, |
470 | 700 int flags |
887 | 701 ) |
0 | 702 { |
703 ASFContext *asf = s->priv_data; | |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
704 int m_obj_offset, payload_len, frag_len1; |
0 | 705 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
706 m_obj_offset = 0; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
707 while (m_obj_offset < m_obj_size) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
708 payload_len = m_obj_size - m_obj_offset; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
709 if (asf->packet_timestamp_start == -1) { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
710 asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT); |
885 | 711 |
1775 | 712 asf->packet_size_left = PACKET_SIZE; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
713 if (asf->multi_payloads_present){ |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
714 frag_len1 = MULTI_PAYLOAD_CONSTANT - 1; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
715 } |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
716 else { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
717 frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
718 } |
1764 | 719 asf->packet_timestamp_start = timestamp; |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
720 } |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
721 else { |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
722 // multi payloads |
1775 | 723 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
|
724 |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
725 if(frag_len1 < payload_len && avst->codec->codec_type == AVMEDIA_TYPE_AUDIO){ |
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
|
726 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
|
727 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
|
728 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
729 } |
0 | 730 if (frag_len1 > 0) { |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
731 if (payload_len > frag_len1) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
732 payload_len = frag_len1; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
733 else if (payload_len == (frag_len1 - 1)) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
734 payload_len = frag_len1 - 2; //additional byte need to put padding length |
885 | 735 |
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
|
736 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
|
737 put_buffer(&asf->pb, buf, payload_len); |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
738 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
739 if (asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
740 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
|
741 else |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
742 asf->packet_size_left -= (payload_len + PAYLOAD_HEADER_SIZE_SINGLE_PAYLOAD); |
0 | 743 asf->packet_timestamp_end = timestamp; |
885 | 744 |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
745 asf->packet_nb_payloads++; |
0 | 746 } else { |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
747 payload_len = 0; |
0 | 748 } |
373
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
749 m_obj_offset += payload_len; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
750 buf += payload_len; |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
751 |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
752 if (!asf->multi_payloads_present) |
e47d9c8e2054
asf patch by (Konstantin Andreyev <kandreyev at bcsii dot com>)
michael
parents:
372
diff
changeset
|
753 flush_packet(s); |
1775 | 754 else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + PACKET_HEADER_MIN_SIZE + 1)) |
0 | 755 flush_packet(s); |
756 } | |
757 stream->seq++; | |
758 } | |
759 | |
468 | 760 static int asf_write_packet(AVFormatContext *s, AVPacket *pkt) |
0 | 761 { |
762 ASFContext *asf = s->priv_data; | |
763 ASFStream *stream; | |
65 | 764 int64_t duration; |
0 | 765 AVCodecContext *codec; |
885 | 766 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
|
767 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
|
768 int flags= pkt->flags; |
0 | 769 |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
743
diff
changeset
|
770 codec = s->streams[pkt->stream_index]->codec; |
468 | 771 stream = &asf->streams[pkt->stream_index]; |
0 | 772 |
5910
536e5527c1e0
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
5876
diff
changeset
|
773 if(codec->codec_type == AVMEDIA_TYPE_AUDIO) |
5913
11bb10c37225
Replace all occurences of PKT_FLAG_KEY with AV_PKT_FLAG_KEY.
cehoyos
parents:
5910
diff
changeset
|
774 flags &= ~AV_PKT_FLAG_KEY; |
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
|
775 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
776 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
|
777 assert(pts != AV_NOPTS_VALUE); |
cb8b538021cd
muxing packets with unknown timestamps is not allowed
michael
parents:
1687
diff
changeset
|
778 duration = pts * 10000; |
3236 | 779 asf->duration= FFMAX(asf->duration, duration + pkt->duration * 10000); |
0 | 780 |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
781 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
|
782 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
|
783 |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
784 /* check index */ |
5913
11bb10c37225
Replace all occurences of PKT_FLAG_KEY with AV_PKT_FLAG_KEY.
cehoyos
parents:
5910
diff
changeset
|
785 if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) { |
1556 | 786 start_sec = (int)(duration / INT64_C(10000000)); |
787 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
|
788 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
|
789 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
|
790 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
|
791 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
|
792 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
793 // store |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
794 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
|
795 asf->index_ptr[i].packet_count = (uint16_t)(asf->nb_packets-packet_st); |
1685 | 796 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
|
797 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
798 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
|
799 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
|
800 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
801 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
802 return 0; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
803 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
804 |
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 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
|
807 { |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
808 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
|
809 int i; |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
810 |
4593
0d8b36d98ce2
move static tables from asf.h to non-static tables in asf.c
aurel
parents:
4592
diff
changeset
|
811 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
|
812 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
|
813 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
|
814 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
|
815 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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 } |
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
821 |
0 | 822 return 0; |
823 } | |
824 | |
825 static int asf_write_trailer(AVFormatContext *s) | |
826 { | |
827 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
|
828 int64_t file_size,data_size; |
0 | 829 |
830 /* flush the current packet */ | |
831 if (asf->pb.buf_ptr > asf->pb.buffer) | |
832 flush_packet(s); | |
833 | |
716
55081ada3aad
31_ASF_compatibility_with_WMP_and_add_index.patch by (Calcium | calcium nurs or jp)
michael
parents:
672
diff
changeset
|
834 /* write index */ |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
835 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
|
836 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
|
837 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
|
838 } |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
839 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
|
840 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
841 if (asf->is_streamed || url_is_streamed(s->pb)) { |
0 | 842 put_chunk(s, 0x4524, 0, 0); /* end of stream */ |
843 } else { | |
844 /* rewrite an updated header */ | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
845 file_size = url_ftell(s->pb); |
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
846 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
|
847 asf_write_header1(s, file_size, data_size - asf->data_offset); |
0 | 848 } |
849 | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2615
diff
changeset
|
850 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
|
851 av_free(asf->index_ptr); |
0 | 852 return 0; |
853 } | |
854 | |
4206 | 855 #if CONFIG_ASF_MUXER |
1167 | 856 AVOutputFormat asf_muxer = { |
0 | 857 "asf", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3236
diff
changeset
|
858 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
|
859 "video/x-ms-asf", |
672 | 860 "asf,wmv,wma", |
0 | 861 sizeof(ASFContext), |
4206 | 862 #if CONFIG_LIBMP3LAME |
232 | 863 CODEC_ID_MP3, |
0 | 864 #else |
865 CODEC_ID_MP2, | |
866 #endif | |
867 CODEC_ID_MSMPEG4V3, | |
868 asf_write_header, | |
869 asf_write_packet, | |
870 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
|
871 .flags = AVFMT_GLOBALHEADER, |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4748
diff
changeset
|
872 .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0}, |
4618
5b9eddbee9c4
Add some basic metadata conversion tables for matroska and asf.
aurel
parents:
4593
diff
changeset
|
873 .metadata_conv = ff_asf_metadata_conv, |
0 | 874 }; |
1169 | 875 #endif |
0 | 876 |
4206 | 877 #if CONFIG_ASF_STREAM_MUXER |
1167 | 878 AVOutputFormat asf_stream_muxer = { |
0 | 879 "asf_stream", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3236
diff
changeset
|
880 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
|
881 "video/x-ms-asf", |
672 | 882 "asf,wmv,wma", |
0 | 883 sizeof(ASFContext), |
4206 | 884 #if CONFIG_LIBMP3LAME |
232 | 885 CODEC_ID_MP3, |
0 | 886 #else |
887 CODEC_ID_MP2, | |
888 #endif | |
889 CODEC_ID_MSMPEG4V3, | |
890 asf_write_stream_header, | |
891 asf_write_packet, | |
892 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
|
893 .flags = AVFMT_GLOBALHEADER, |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
4748
diff
changeset
|
894 .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, ff_codec_bmp_tags, ff_codec_wav_tags, 0}, |
4618
5b9eddbee9c4
Add some basic metadata conversion tables for matroska and asf.
aurel
parents:
4593
diff
changeset
|
895 .metadata_conv = ff_asf_metadata_conv, |
0 | 896 }; |
1169 | 897 #endif //CONFIG_ASF_STREAM_MUXER |