Mercurial > libavformat.hg
annotate matroskaenc.c @ 2430:da0227bd105a libavformat
put_ebml_float()
author | conrad |
---|---|
date | Wed, 05 Sep 2007 00:22:47 +0000 |
parents | 326e6fcf9f85 |
children | 435ebfec86cf |
rev | line source |
---|---|
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
1 /* |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
2 * Matroska file muxer |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
3 * Copyright (c) 2007 David Conrad |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
4 * |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
6 * |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
11 * |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
16 * |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
20 */ |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
21 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
22 #include "avformat.h" |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
23 #include "riff.h" |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
24 #include "matroska.h" |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
25 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
26 typedef struct MatroskaMuxContext { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
27 offset_t segment; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
28 } MatroskaMuxContext; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
29 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
30 static void put_ebml_id(ByteIOContext *pb, unsigned int id) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
31 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
32 if (id >= 0x3fffff) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
33 put_byte(pb, id >> 24); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
34 if (id >= 0x7fff) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
35 put_byte(pb, id >> 16); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
36 if (id >= 0xff) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
37 put_byte(pb, id >> 8); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
38 put_byte(pb, id); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
39 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
40 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
41 // XXX: test this thoroughly and get rid of minbytes hack (currently needed to |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
42 // use up all of the space reserved in start_ebml_master) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
43 static void put_ebml_size(ByteIOContext *pb, uint64_t size, int minbytes) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
44 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
45 int bytes = minbytes; |
2426 | 46 while (size >> (bytes*7 + 7)) bytes++; |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
47 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
48 // sizes larger than this are currently undefined in EBML |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
49 // XXX: error condition? |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
50 if (size > (1ULL<<56)-1) return; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
51 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
52 put_byte(pb, (0x80 >> bytes) | (size >> bytes*8)); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
53 for (bytes -= 1; bytes >= 0; bytes--) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
54 put_byte(pb, size >> bytes*8); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
55 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
56 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
57 static void put_ebml_uint(ByteIOContext *pb, unsigned int elementid, uint64_t val) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
58 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
59 int bytes = 1; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
60 while (val >> bytes*8) bytes++; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
61 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
62 put_ebml_id(pb, elementid); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
63 put_ebml_size(pb, bytes, 0); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
64 for (bytes -= 1; bytes >= 0; bytes--) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
65 put_byte(pb, val >> bytes*8); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
66 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
67 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
68 //static void put_ebml_sint(ByteIOContext *pb, unsigned int elementid, int64_t val) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
69 |
2430 | 70 static void put_ebml_float(ByteIOContext *pb, unsigned int elementid, double val) |
71 { | |
72 // XXX: single-precision floats? | |
73 put_ebml_id(pb, elementid); | |
74 put_ebml_size(pb, 8, 0); | |
75 put_be64(pb, av_dbl2int(val)); | |
76 } | |
77 | |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
78 static void put_ebml_binary(ByteIOContext *pb, unsigned int elementid, |
2429 | 79 const uint8_t *buf, int size) |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
80 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
81 put_ebml_id(pb, elementid); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
82 put_ebml_size(pb, size, 0); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
83 put_buffer(pb, buf, size); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
84 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
85 |
2429 | 86 static void put_ebml_string(ByteIOContext *pb, unsigned int elementid, const char *str) |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
87 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
88 put_ebml_binary(pb, elementid, str, strlen(str)); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
89 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
90 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
91 static offset_t start_ebml_master(ByteIOContext *pb, unsigned int elementid) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
92 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
93 put_ebml_id(pb, elementid); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
94 // XXX: this always reserves the maximum needed space to store any size value |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
95 // we should be smarter (additional parameter for expected size?) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
96 put_ebml_size(pb, (1ULL<<56)-1, 0); // largest unknown size |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
97 return url_ftell(pb); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
98 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
99 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
100 static void end_ebml_master(ByteIOContext *pb, offset_t start) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
101 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
102 offset_t pos = url_ftell(pb); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
103 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
104 url_fseek(pb, start - 8, SEEK_SET); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
105 put_ebml_size(pb, pos - start, 7); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
106 url_fseek(pb, pos, SEEK_SET); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
107 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
108 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
109 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
110 static int mkv_write_header(AVFormatContext *s) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
111 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
112 MatroskaMuxContext *mkv = s->priv_data; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
113 ByteIOContext *pb = &s->pb; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
114 offset_t ebml_header, segment_info, tracks; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
115 int i; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
116 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
117 ebml_header = start_ebml_master(pb, EBML_ID_HEADER); |
2427 | 118 put_ebml_uint (pb, EBML_ID_EBMLVERSION , 1); |
119 put_ebml_uint (pb, EBML_ID_EBMLREADVERSION , 1); | |
120 put_ebml_uint (pb, EBML_ID_EBMLMAXIDLENGTH , 4); | |
121 put_ebml_uint (pb, EBML_ID_EBMLMAXSIZELENGTH , 8); | |
122 put_ebml_string (pb, EBML_ID_DOCTYPE , "matroska"); | |
123 put_ebml_uint (pb, EBML_ID_DOCTYPEVERSION , 1); | |
124 put_ebml_uint (pb, EBML_ID_DOCTYPEREADVERSION , 1); | |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
125 end_ebml_master(pb, ebml_header); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
126 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
127 mkv->segment = start_ebml_master(pb, MATROSKA_ID_SEGMENT); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
128 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
129 segment_info = start_ebml_master(pb, MATROSKA_ID_INFO); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
130 put_ebml_uint(pb, MATROSKA_ID_TIMECODESCALE, 1000000); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
131 if (strlen(s->title)) |
2428
54f89ce33554
Get rid of put_ebml_utf8(); the error checking that would have distinguished it from put_ebml_string() belongs elsewhere in lavf.
conrad
parents:
2427
diff
changeset
|
132 put_ebml_string(pb, MATROSKA_ID_TITLE, s->title); |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
133 if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) { |
2428
54f89ce33554
Get rid of put_ebml_utf8(); the error checking that would have distinguished it from put_ebml_string() belongs elsewhere in lavf.
conrad
parents:
2427
diff
changeset
|
134 put_ebml_string(pb, MATROSKA_ID_MUXINGAPP, LIBAVFORMAT_IDENT); |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
135 // XXX: both are required; something better for writing app? |
2428
54f89ce33554
Get rid of put_ebml_utf8(); the error checking that would have distinguished it from put_ebml_string() belongs elsewhere in lavf.
conrad
parents:
2427
diff
changeset
|
136 put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT); |
2425
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
137 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
138 // XXX: segment UID and duration |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
139 end_ebml_master(pb, segment_info); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
140 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
141 tracks = start_ebml_master(pb, MATROSKA_ID_TRACKS); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
142 for (i = 0; i < s->nb_streams; i++) { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
143 AVStream *st = s->streams[i]; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
144 offset_t track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
145 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
146 end_ebml_master(pb, track); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
147 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
148 end_ebml_master(pb, tracks); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
149 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
150 put_be64(pb, 0xdeadbeef); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
151 return 0; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
152 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
153 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
154 static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
155 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
156 ByteIOContext *pb = &s->pb; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
157 put_buffer(pb, pkt->data, pkt->size); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
158 return 0; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
159 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
160 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
161 static int mkv_write_trailer(AVFormatContext *s) |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
162 { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
163 MatroskaMuxContext *mkv = s->priv_data; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
164 ByteIOContext *pb = &s->pb; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
165 end_ebml_master(pb, mkv->segment); |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
166 return 0; |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
167 } |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
168 |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
169 AVOutputFormat matroska_muxer = { |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
170 "matroska", |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
171 "Matroska File Format", |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
172 "video/x-matroska", |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
173 "mkv", |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
174 sizeof(MatroskaMuxContext), |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
175 CODEC_ID_MP2, |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
176 CODEC_ID_MPEG4, |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
177 mkv_write_header, |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
178 mkv_write_packet, |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
179 mkv_write_trailer, |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
180 .codec_tag = (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, 0}, |
8c51e92edd7d
Beginning of mkv muxer, only EBML head is written correctly
conrad
parents:
diff
changeset
|
181 }; |