adxenc: check output buffer size before writing
[libav.git] / libavformat / rawenc.c
CommitLineData
115329f1 1/*
4ca31edc 2 * RAW muxers
406792e7 3 * Copyright (c) 2001 Fabrice Bellard
84c63c01 4 * Copyright (c) 2005 Alex Beregszaszi
de6d9b64 5 *
2912e87a 6 * This file is part of Libav.
b78e7197 7 *
2912e87a 8 * Libav is free software; you can redistribute it and/or
19720f15
FB
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
b78e7197 11 * version 2.1 of the License, or (at your option) any later version.
de6d9b64 12 *
2912e87a 13 * Libav is distributed in the hope that it will be useful,
de6d9b64 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19720f15
FB
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
de6d9b64 17 *
19720f15 18 * You should have received a copy of the GNU Lesser General Public
2912e87a 19 * License along with Libav; if not, write to the Free Software
5509bffa 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
de6d9b64 21 */
245976da 22
de6d9b64 23#include "avformat.h"
4ca31edc 24#include "rawenc.h"
de6d9b64 25
54a73bb5 26int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
de6d9b64 27{
77eb5504 28 avio_write(s->pb, pkt->data, pkt->size);
b7f2fdde 29 avio_flush(s->pb);
de6d9b64
FB
30 return 0;
31}
de6d9b64 32
900eb63d
DB
33/* Note: Do not forget to add new entries to the Makefile as well. */
34
b250f9c6 35#if CONFIG_AC3_MUXER
c6610a21 36AVOutputFormat ff_ac3_muxer = {
dfc2c4d9
AK
37 .name = "ac3",
38 .long_name = NULL_IF_CONFIG_SMALL("raw AC-3"),
39 .mime_type = "audio/x-ac3",
40 .extensions = "ac3",
41 .audio_codec = CODEC_ID_AC3,
42 .video_codec = CODEC_ID_NONE,
43 .write_packet = ff_raw_write_packet,
494bbf58 44 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 45};
7402ee23 46#endif
17ac9f1c 47
b250f9c6 48#if CONFIG_DIRAC_MUXER
c6610a21 49AVOutputFormat ff_dirac_muxer = {
dfc2c4d9
AK
50 .name = "dirac",
51 .long_name = NULL_IF_CONFIG_SMALL("raw Dirac"),
52 .extensions = "drc",
53 .audio_codec = CODEC_ID_NONE,
54 .video_codec = CODEC_ID_DIRAC,
55 .write_packet = ff_raw_write_packet,
17ac9f1c
LB
56 .flags= AVFMT_NOTIMESTAMPS,
57};
58#endif
59
b250f9c6 60#if CONFIG_DNXHD_MUXER
c6610a21 61AVOutputFormat ff_dnxhd_muxer = {
dfc2c4d9
AK
62 .name = "dnxhd",
63 .long_name = NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
64 .extensions = "dnxhd",
65 .audio_codec = CODEC_ID_NONE,
66 .video_codec = CODEC_ID_DNXHD,
67 .write_packet = ff_raw_write_packet,
bd09e8a7
BC
68 .flags= AVFMT_NOTIMESTAMPS,
69};
70#endif
71
b250f9c6 72#if CONFIG_DTS_MUXER
c6610a21 73AVOutputFormat ff_dts_muxer = {
dfc2c4d9
AK
74 .name = "dts",
75 .long_name = NULL_IF_CONFIG_SMALL("raw DTS"),
76 .mime_type = "audio/x-dca",
77 .extensions = "dts",
78 .audio_codec = CODEC_ID_DTS,
79 .video_codec = CODEC_ID_NONE,
80 .write_packet = ff_raw_write_packet,
76d32428
DB
81 .flags= AVFMT_NOTIMESTAMPS,
82};
83#endif
84
b250f9c6 85#if CONFIG_EAC3_MUXER
c6610a21 86AVOutputFormat ff_eac3_muxer = {
dfc2c4d9
AK
87 .name = "eac3",
88 .long_name = NULL_IF_CONFIG_SMALL("raw E-AC-3"),
89 .mime_type = "audio/x-eac3",
90 .extensions = "eac3",
91 .audio_codec = CODEC_ID_EAC3,
92 .video_codec = CODEC_ID_NONE,
93 .write_packet = ff_raw_write_packet,
2988c93d
JR
94 .flags= AVFMT_NOTIMESTAMPS,
95};
96#endif
97
9013560f 98#if CONFIG_G722_MUXER
c6610a21 99AVOutputFormat ff_g722_muxer = {
dfc2c4d9
AK
100 .name = "g722",
101 .long_name = NULL_IF_CONFIG_SMALL("raw G.722"),
102 .mime_type = "audio/G722",
103 .extensions = "g722",
104 .audio_codec = CODEC_ID_ADPCM_G722,
105 .video_codec = CODEC_ID_NONE,
106 .write_packet = ff_raw_write_packet,
9013560f
MS
107 .flags= AVFMT_NOTIMESTAMPS,
108};
109#endif
110
b250f9c6 111#if CONFIG_H261_MUXER
c6610a21 112AVOutputFormat ff_h261_muxer = {
dfc2c4d9
AK
113 .name = "h261",
114 .long_name = NULL_IF_CONFIG_SMALL("raw H.261"),
115 .mime_type = "video/x-h261",
116 .extensions = "h261",
117 .audio_codec = CODEC_ID_NONE,
118 .video_codec = CODEC_ID_H261,
119 .write_packet = ff_raw_write_packet,
494bbf58 120 .flags= AVFMT_NOTIMESTAMPS,
1c3990db 121};
082f7acf 122#endif
1c3990db 123
b250f9c6 124#if CONFIG_H263_MUXER
c6610a21 125AVOutputFormat ff_h263_muxer = {
dfc2c4d9
AK
126 .name = "h263",
127 .long_name = NULL_IF_CONFIG_SMALL("raw H.263"),
128 .mime_type = "video/x-h263",
129 .extensions = "h263",
130 .audio_codec = CODEC_ID_NONE,
131 .video_codec = CODEC_ID_H263,
132 .write_packet = ff_raw_write_packet,
494bbf58 133 .flags= AVFMT_NOTIMESTAMPS,
c9a65ca8 134};
082f7acf 135#endif
c9a65ca8 136
b250f9c6 137#if CONFIG_H264_MUXER
c6610a21 138AVOutputFormat ff_h264_muxer = {
dfc2c4d9
AK
139 .name = "h264",
140 .long_name = NULL_IF_CONFIG_SMALL("raw H.264 video format"),
141 .extensions = "h264",
142 .audio_codec = CODEC_ID_NONE,
143 .video_codec = CODEC_ID_H264,
144 .write_packet = ff_raw_write_packet,
76d32428
DB
145 .flags= AVFMT_NOTIMESTAMPS,
146};
082f7acf 147#endif
76d32428 148
de295976 149#if CONFIG_CAVSVIDEO_MUXER
c6610a21 150AVOutputFormat ff_cavsvideo_muxer = {
dfc2c4d9
AK
151 .name = "cavsvideo",
152 .long_name = NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
153 .extensions = "cavs",
154 .audio_codec = CODEC_ID_NONE,
155 .video_codec = CODEC_ID_CAVS,
156 .write_packet = ff_raw_write_packet,
de295976 157 .flags= AVFMT_NOTIMESTAMPS,
de295976
SG
158};
159#endif
160
b250f9c6 161#if CONFIG_M4V_MUXER
c6610a21 162AVOutputFormat ff_m4v_muxer = {
dfc2c4d9
AK
163 .name = "m4v",
164 .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
165 .extensions = "m4v",
166 .audio_codec = CODEC_ID_NONE,
167 .video_codec = CODEC_ID_MPEG4,
168 .write_packet = ff_raw_write_packet,
494bbf58 169 .flags= AVFMT_NOTIMESTAMPS,
89b3d7c9 170};
082f7acf 171#endif
89b3d7c9 172
b250f9c6 173#if CONFIG_MJPEG_MUXER
c6610a21 174AVOutputFormat ff_mjpeg_muxer = {
dfc2c4d9
AK
175 .name = "mjpeg",
176 .long_name = NULL_IF_CONFIG_SMALL("raw MJPEG video"),
177 .mime_type = "video/x-mjpeg",
178 .extensions = "mjpg,mjpeg",
179 .audio_codec = CODEC_ID_NONE,
180 .video_codec = CODEC_ID_MJPEG,
181 .write_packet = ff_raw_write_packet,
494bbf58 182 .flags= AVFMT_NOTIMESTAMPS,
0da71265 183};
082f7acf 184#endif
0da71265 185
0e1ccdeb 186#if CONFIG_MLP_MUXER
c6610a21 187AVOutputFormat ff_mlp_muxer = {
dfc2c4d9
AK
188 .name = "mlp",
189 .long_name = NULL_IF_CONFIG_SMALL("raw MLP"),
190 .extensions = "mlp",
191 .audio_codec = CODEC_ID_MLP,
192 .video_codec = CODEC_ID_NONE,
193 .write_packet = ff_raw_write_packet,
9145021d
RP
194 .flags= AVFMT_NOTIMESTAMPS,
195};
196#endif
197
ba2c508d 198#if CONFIG_SRT_MUXER
c6610a21 199AVOutputFormat ff_srt_muxer = {
ba2c508d
AJ
200 .name = "srt",
201 .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle format"),
202 .mime_type = "application/x-subrip",
203 .extensions = "srt",
54a73bb5 204 .write_packet = ff_raw_write_packet,
ba2c508d
AJ
205 .flags = AVFMT_NOTIMESTAMPS,
206 .subtitle_codec = CODEC_ID_SRT,
207};
208#endif
209
23d9cc45 210#if CONFIG_TRUEHD_MUXER
c6610a21 211AVOutputFormat ff_truehd_muxer = {
dfc2c4d9
AK
212 .name = "truehd",
213 .long_name = NULL_IF_CONFIG_SMALL("raw TrueHD"),
214 .extensions = "thd",
215 .audio_codec = CODEC_ID_TRUEHD,
216 .video_codec = CODEC_ID_NONE,
217 .write_packet = ff_raw_write_packet,
23d9cc45
RP
218 .flags= AVFMT_NOTIMESTAMPS,
219};
220#endif
221
b250f9c6 222#if CONFIG_MPEG1VIDEO_MUXER
c6610a21 223AVOutputFormat ff_mpeg1video_muxer = {
dfc2c4d9
AK
224 .name = "mpeg1video",
225 .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
226 .mime_type = "video/x-mpeg",
227 .extensions = "mpg,mpeg,m1v",
228 .audio_codec = CODEC_ID_NONE,
229 .video_codec = CODEC_ID_MPEG1VIDEO,
230 .write_packet = ff_raw_write_packet,
494bbf58 231 .flags= AVFMT_NOTIMESTAMPS,
de6d9b64 232};
082f7acf 233#endif
de6d9b64 234
b250f9c6 235#if CONFIG_MPEG2VIDEO_MUXER
c6610a21 236AVOutputFormat ff_mpeg2video_muxer = {
dfc2c4d9
AK
237 .name = "mpeg2video",
238 .long_name = NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
239 .extensions = "m2v",
240 .audio_codec = CODEC_ID_NONE,
241 .video_codec = CODEC_ID_MPEG2VIDEO,
242 .write_packet = ff_raw_write_packet,
494bbf58 243 .flags= AVFMT_NOTIMESTAMPS,
6ec864da 244};
082f7acf 245#endif
6ec864da 246
b250f9c6 247#if CONFIG_RAWVIDEO_MUXER
c6610a21 248AVOutputFormat ff_rawvideo_muxer = {
dfc2c4d9
AK
249 .name = "rawvideo",
250 .long_name = NULL_IF_CONFIG_SMALL("raw video format"),
251 .extensions = "yuv,rgb",
252 .audio_codec = CODEC_ID_NONE,
253 .video_codec = CODEC_ID_RAWVIDEO,
254 .write_packet = ff_raw_write_packet,
494bbf58 255 .flags= AVFMT_NOTIMESTAMPS,
5ed8fafc 256};
082f7acf 257#endif