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