You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

840 lines
20KB

  1. /*
  2. * RAW muxer and demuxer
  3. * Copyright (c) 2001 Fabrice Bellard
  4. * Copyright (c) 2005 Alex Beregszaszi
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "libavutil/crc.h"
  23. #include "libavcodec/ac3_parser.h"
  24. #include "libavcodec/get_bits.h"
  25. #include "libavcodec/bytestream.h"
  26. #include "avformat.h"
  27. #include "raw.h"
  28. #include "id3v2.h"
  29. #include "id3v1.h"
  30. /* simple formats */
  31. #if CONFIG_NULL_MUXER
  32. static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
  33. {
  34. return 0;
  35. }
  36. #endif
  37. #if CONFIG_MUXERS
  38. int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
  39. {
  40. put_buffer(s->pb, pkt->data, pkt->size);
  41. put_flush_packet(s->pb);
  42. return 0;
  43. }
  44. #endif
  45. #if CONFIG_DEMUXERS
  46. /* raw input */
  47. static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
  48. {
  49. AVStream *st;
  50. enum CodecID id;
  51. st = av_new_stream(s, 0);
  52. if (!st)
  53. return AVERROR(ENOMEM);
  54. id = s->iformat->value;
  55. if (id == CODEC_ID_RAWVIDEO) {
  56. st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
  57. } else {
  58. st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
  59. }
  60. st->codec->codec_id = id;
  61. switch(st->codec->codec_type) {
  62. case AVMEDIA_TYPE_AUDIO:
  63. st->codec->sample_rate = ap->sample_rate;
  64. if(ap->channels) st->codec->channels = ap->channels;
  65. else st->codec->channels = 1;
  66. st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
  67. assert(st->codec->bits_per_coded_sample > 0);
  68. st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8;
  69. av_set_pts_info(st, 64, 1, st->codec->sample_rate);
  70. break;
  71. case AVMEDIA_TYPE_VIDEO:
  72. if(ap->time_base.num)
  73. av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
  74. else
  75. av_set_pts_info(st, 64, 1, 25);
  76. st->codec->width = ap->width;
  77. st->codec->height = ap->height;
  78. st->codec->pix_fmt = ap->pix_fmt;
  79. if(st->codec->pix_fmt == PIX_FMT_NONE)
  80. st->codec->pix_fmt= PIX_FMT_YUV420P;
  81. break;
  82. default:
  83. return -1;
  84. }
  85. return 0;
  86. }
  87. #define RAW_PACKET_SIZE 1024
  88. #define RAW_SAMPLES 1024
  89. static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
  90. {
  91. int ret, size, bps;
  92. // AVStream *st = s->streams[0];
  93. size= RAW_SAMPLES*s->streams[0]->codec->block_align;
  94. ret= av_get_packet(s->pb, pkt, size);
  95. pkt->stream_index = 0;
  96. if (ret < 0)
  97. return ret;
  98. bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
  99. assert(bps); // if false there IS a bug elsewhere (NOT in this function)
  100. pkt->dts=
  101. pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
  102. return ret;
  103. }
  104. int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
  105. {
  106. int ret, size;
  107. size = RAW_PACKET_SIZE;
  108. if (av_new_packet(pkt, size) < 0)
  109. return AVERROR(ENOMEM);
  110. pkt->pos= url_ftell(s->pb);
  111. pkt->stream_index = 0;
  112. ret = get_partial_buffer(s->pb, pkt->data, size);
  113. if (ret < 0) {
  114. av_free_packet(pkt);
  115. return ret;
  116. }
  117. pkt->size = ret;
  118. return ret;
  119. }
  120. #endif
  121. #if CONFIG_RAWVIDEO_DEMUXER
  122. static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
  123. {
  124. int packet_size, ret, width, height;
  125. AVStream *st = s->streams[0];
  126. width = st->codec->width;
  127. height = st->codec->height;
  128. packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
  129. if (packet_size < 0)
  130. return -1;
  131. ret= av_get_packet(s->pb, pkt, packet_size);
  132. pkt->pts=
  133. pkt->dts= pkt->pos / packet_size;
  134. pkt->stream_index = 0;
  135. if (ret < 0)
  136. return ret;
  137. return 0;
  138. }
  139. #endif
  140. #if CONFIG_DEMUXERS
  141. int pcm_read_seek(AVFormatContext *s,
  142. int stream_index, int64_t timestamp, int flags)
  143. {
  144. AVStream *st;
  145. int block_align, byte_rate;
  146. int64_t pos, ret;
  147. st = s->streams[0];
  148. block_align = st->codec->block_align ? st->codec->block_align :
  149. (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
  150. byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
  151. block_align * st->codec->sample_rate;
  152. if (block_align <= 0 || byte_rate <= 0)
  153. return -1;
  154. if (timestamp < 0) timestamp = 0;
  155. /* compute the position by aligning it to block_align */
  156. pos = av_rescale_rnd(timestamp * byte_rate,
  157. st->time_base.num,
  158. st->time_base.den * (int64_t)block_align,
  159. (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP);
  160. pos *= block_align;
  161. /* recompute exact position */
  162. st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
  163. if ((ret = url_fseek(s->pb, pos + s->data_offset, SEEK_SET)) < 0)
  164. return ret;
  165. return 0;
  166. }
  167. int ff_raw_audio_read_header(AVFormatContext *s,
  168. AVFormatParameters *ap)
  169. {
  170. AVStream *st = av_new_stream(s, 0);
  171. if (!st)
  172. return AVERROR(ENOMEM);
  173. st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
  174. st->codec->codec_id = s->iformat->value;
  175. st->need_parsing = AVSTREAM_PARSE_FULL;
  176. /* the parameters will be extracted from the compressed bitstream */
  177. return 0;
  178. }
  179. /* MPEG-1/H.263 input */
  180. int ff_raw_video_read_header(AVFormatContext *s,
  181. AVFormatParameters *ap)
  182. {
  183. AVStream *st;
  184. st = av_new_stream(s, 0);
  185. if (!st)
  186. return AVERROR(ENOMEM);
  187. st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
  188. st->codec->codec_id = s->iformat->value;
  189. st->need_parsing = AVSTREAM_PARSE_FULL;
  190. /* for MJPEG, specify frame rate */
  191. /* for MPEG-4 specify it, too (most MPEG-4 streams do not have the fixed_vop_rate set ...)*/
  192. if (ap->time_base.num) {
  193. st->codec->time_base= ap->time_base;
  194. } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
  195. st->codec->codec_id == CODEC_ID_MPEG4 ||
  196. st->codec->codec_id == CODEC_ID_DIRAC ||
  197. st->codec->codec_id == CODEC_ID_DNXHD ||
  198. st->codec->codec_id == CODEC_ID_VC1 ||
  199. st->codec->codec_id == CODEC_ID_H264) {
  200. st->codec->time_base= (AVRational){1,25};
  201. }
  202. av_set_pts_info(st, 64, 1, 1200000);
  203. return 0;
  204. }
  205. #endif
  206. #if CONFIG_DNXHD_DEMUXER
  207. static int dnxhd_probe(AVProbeData *p)
  208. {
  209. static const uint8_t header[] = {0x00,0x00,0x02,0x80,0x01};
  210. int w, h, compression_id;
  211. if (p->buf_size < 0x2c)
  212. return 0;
  213. if (memcmp(p->buf, header, 5))
  214. return 0;
  215. h = AV_RB16(p->buf + 0x18);
  216. w = AV_RB16(p->buf + 0x1a);
  217. if (!w || !h)
  218. return 0;
  219. compression_id = AV_RB32(p->buf + 0x28);
  220. if (compression_id < 1237 || compression_id > 1253)
  221. return 0;
  222. return AVPROBE_SCORE_MAX;
  223. }
  224. #endif
  225. #if CONFIG_AC3_DEMUXER || CONFIG_EAC3_DEMUXER
  226. static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
  227. {
  228. int max_frames, first_frames = 0, frames;
  229. uint8_t *buf, *buf2, *end;
  230. AC3HeaderInfo hdr;
  231. GetBitContext gbc;
  232. enum CodecID codec_id = CODEC_ID_AC3;
  233. max_frames = 0;
  234. buf = p->buf;
  235. end = buf + p->buf_size;
  236. for(; buf < end; buf++) {
  237. buf2 = buf;
  238. for(frames = 0; buf2 < end; frames++) {
  239. init_get_bits(&gbc, buf2, 54);
  240. if(ff_ac3_parse_header(&gbc, &hdr) < 0)
  241. break;
  242. if(buf2 + hdr.frame_size > end ||
  243. av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
  244. break;
  245. if (hdr.bitstream_id > 10)
  246. codec_id = CODEC_ID_EAC3;
  247. buf2 += hdr.frame_size;
  248. }
  249. max_frames = FFMAX(max_frames, frames);
  250. if(buf == p->buf)
  251. first_frames = frames;
  252. }
  253. if(codec_id != expected_codec_id) return 0;
  254. // keep this in sync with mp3 probe, both need to avoid
  255. // issues with MPEG-files!
  256. if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
  257. else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
  258. else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
  259. else if(max_frames>=1) return 1;
  260. else return 0;
  261. }
  262. #endif
  263. #if CONFIG_AC3_DEMUXER
  264. static int ac3_probe(AVProbeData *p)
  265. {
  266. return ac3_eac3_probe(p, CODEC_ID_AC3);
  267. }
  268. #endif
  269. #if CONFIG_EAC3_DEMUXER
  270. static int eac3_probe(AVProbeData *p)
  271. {
  272. return ac3_eac3_probe(p, CODEC_ID_EAC3);
  273. }
  274. #endif
  275. /* Note: Do not forget to add new entries to the Makefile as well. */
  276. #if CONFIG_AC3_DEMUXER
  277. AVInputFormat ac3_demuxer = {
  278. "ac3",
  279. NULL_IF_CONFIG_SMALL("raw AC-3"),
  280. 0,
  281. ac3_probe,
  282. ff_raw_audio_read_header,
  283. ff_raw_read_partial_packet,
  284. .flags= AVFMT_GENERIC_INDEX,
  285. .extensions = "ac3",
  286. .value = CODEC_ID_AC3,
  287. };
  288. #endif
  289. #if CONFIG_AC3_MUXER
  290. AVOutputFormat ac3_muxer = {
  291. "ac3",
  292. NULL_IF_CONFIG_SMALL("raw AC-3"),
  293. "audio/x-ac3",
  294. "ac3",
  295. 0,
  296. CODEC_ID_AC3,
  297. CODEC_ID_NONE,
  298. NULL,
  299. ff_raw_write_packet,
  300. .flags= AVFMT_NOTIMESTAMPS,
  301. };
  302. #endif
  303. #if CONFIG_DIRAC_MUXER
  304. AVOutputFormat dirac_muxer = {
  305. "dirac",
  306. NULL_IF_CONFIG_SMALL("raw Dirac"),
  307. NULL,
  308. "drc",
  309. 0,
  310. CODEC_ID_NONE,
  311. CODEC_ID_DIRAC,
  312. NULL,
  313. ff_raw_write_packet,
  314. .flags= AVFMT_NOTIMESTAMPS,
  315. };
  316. #endif
  317. #if CONFIG_DNXHD_DEMUXER
  318. AVInputFormat dnxhd_demuxer = {
  319. "dnxhd",
  320. NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
  321. 0,
  322. dnxhd_probe,
  323. ff_raw_video_read_header,
  324. ff_raw_read_partial_packet,
  325. .flags= AVFMT_GENERIC_INDEX,
  326. .value = CODEC_ID_DNXHD,
  327. };
  328. #endif
  329. #if CONFIG_DNXHD_MUXER
  330. AVOutputFormat dnxhd_muxer = {
  331. "dnxhd",
  332. NULL_IF_CONFIG_SMALL("raw DNxHD (SMPTE VC-3)"),
  333. NULL,
  334. "dnxhd",
  335. 0,
  336. CODEC_ID_NONE,
  337. CODEC_ID_DNXHD,
  338. NULL,
  339. ff_raw_write_packet,
  340. .flags= AVFMT_NOTIMESTAMPS,
  341. };
  342. #endif
  343. #if CONFIG_DTS_MUXER
  344. AVOutputFormat dts_muxer = {
  345. "dts",
  346. NULL_IF_CONFIG_SMALL("raw DTS"),
  347. "audio/x-dca",
  348. "dts",
  349. 0,
  350. CODEC_ID_DTS,
  351. CODEC_ID_NONE,
  352. NULL,
  353. ff_raw_write_packet,
  354. .flags= AVFMT_NOTIMESTAMPS,
  355. };
  356. #endif
  357. #if CONFIG_EAC3_DEMUXER
  358. AVInputFormat eac3_demuxer = {
  359. "eac3",
  360. NULL_IF_CONFIG_SMALL("raw E-AC-3"),
  361. 0,
  362. eac3_probe,
  363. ff_raw_audio_read_header,
  364. ff_raw_read_partial_packet,
  365. .flags= AVFMT_GENERIC_INDEX,
  366. .extensions = "eac3",
  367. .value = CODEC_ID_EAC3,
  368. };
  369. #endif
  370. #if CONFIG_EAC3_MUXER
  371. AVOutputFormat eac3_muxer = {
  372. "eac3",
  373. NULL_IF_CONFIG_SMALL("raw E-AC-3"),
  374. "audio/x-eac3",
  375. "eac3",
  376. 0,
  377. CODEC_ID_EAC3,
  378. CODEC_ID_NONE,
  379. NULL,
  380. ff_raw_write_packet,
  381. .flags= AVFMT_NOTIMESTAMPS,
  382. };
  383. #endif
  384. #if CONFIG_GSM_DEMUXER
  385. AVInputFormat gsm_demuxer = {
  386. "gsm",
  387. NULL_IF_CONFIG_SMALL("raw GSM"),
  388. 0,
  389. NULL,
  390. ff_raw_audio_read_header,
  391. ff_raw_read_partial_packet,
  392. .flags= AVFMT_GENERIC_INDEX,
  393. .extensions = "gsm",
  394. .value = CODEC_ID_GSM,
  395. };
  396. #endif
  397. #if CONFIG_H261_MUXER
  398. AVOutputFormat h261_muxer = {
  399. "h261",
  400. NULL_IF_CONFIG_SMALL("raw H.261"),
  401. "video/x-h261",
  402. "h261",
  403. 0,
  404. CODEC_ID_NONE,
  405. CODEC_ID_H261,
  406. NULL,
  407. ff_raw_write_packet,
  408. .flags= AVFMT_NOTIMESTAMPS,
  409. };
  410. #endif
  411. #if CONFIG_H263_MUXER
  412. AVOutputFormat h263_muxer = {
  413. "h263",
  414. NULL_IF_CONFIG_SMALL("raw H.263"),
  415. "video/x-h263",
  416. "h263",
  417. 0,
  418. CODEC_ID_NONE,
  419. CODEC_ID_H263,
  420. NULL,
  421. ff_raw_write_packet,
  422. .flags= AVFMT_NOTIMESTAMPS,
  423. };
  424. #endif
  425. #if CONFIG_H264_MUXER
  426. AVOutputFormat h264_muxer = {
  427. "h264",
  428. NULL_IF_CONFIG_SMALL("raw H.264 video format"),
  429. NULL,
  430. "h264",
  431. 0,
  432. CODEC_ID_NONE,
  433. CODEC_ID_H264,
  434. NULL,
  435. ff_raw_write_packet,
  436. .flags= AVFMT_NOTIMESTAMPS,
  437. };
  438. #endif
  439. #if CONFIG_CAVSVIDEO_MUXER
  440. AVOutputFormat cavsvideo_muxer = {
  441. "cavsvideo",
  442. NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
  443. NULL,
  444. "cavs",
  445. 0,
  446. CODEC_ID_NONE,
  447. CODEC_ID_CAVS,
  448. NULL,
  449. ff_raw_write_packet,
  450. .flags= AVFMT_NOTIMESTAMPS,
  451. };
  452. #endif
  453. #if CONFIG_M4V_MUXER
  454. AVOutputFormat m4v_muxer = {
  455. "m4v",
  456. NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
  457. NULL,
  458. "m4v",
  459. 0,
  460. CODEC_ID_NONE,
  461. CODEC_ID_MPEG4,
  462. NULL,
  463. ff_raw_write_packet,
  464. .flags= AVFMT_NOTIMESTAMPS,
  465. };
  466. #endif
  467. #if CONFIG_MJPEG_DEMUXER
  468. AVInputFormat mjpeg_demuxer = {
  469. "mjpeg",
  470. NULL_IF_CONFIG_SMALL("raw MJPEG video"),
  471. 0,
  472. NULL,
  473. ff_raw_video_read_header,
  474. ff_raw_read_partial_packet,
  475. .flags= AVFMT_GENERIC_INDEX,
  476. .extensions = "mjpg,mjpeg",
  477. .value = CODEC_ID_MJPEG,
  478. };
  479. #endif
  480. #if CONFIG_MJPEG_MUXER
  481. AVOutputFormat mjpeg_muxer = {
  482. "mjpeg",
  483. NULL_IF_CONFIG_SMALL("raw MJPEG video"),
  484. "video/x-mjpeg",
  485. "mjpg,mjpeg",
  486. 0,
  487. CODEC_ID_NONE,
  488. CODEC_ID_MJPEG,
  489. NULL,
  490. ff_raw_write_packet,
  491. .flags= AVFMT_NOTIMESTAMPS,
  492. };
  493. #endif
  494. #if CONFIG_MLP_DEMUXER
  495. AVInputFormat mlp_demuxer = {
  496. "mlp",
  497. NULL_IF_CONFIG_SMALL("raw MLP"),
  498. 0,
  499. NULL,
  500. ff_raw_audio_read_header,
  501. ff_raw_read_partial_packet,
  502. .flags= AVFMT_GENERIC_INDEX,
  503. .extensions = "mlp",
  504. .value = CODEC_ID_MLP,
  505. };
  506. #endif
  507. #if CONFIG_MLP_MUXER
  508. AVOutputFormat mlp_muxer = {
  509. "mlp",
  510. NULL_IF_CONFIG_SMALL("raw MLP"),
  511. NULL,
  512. "mlp",
  513. 0,
  514. CODEC_ID_MLP,
  515. CODEC_ID_NONE,
  516. NULL,
  517. ff_raw_write_packet,
  518. .flags= AVFMT_NOTIMESTAMPS,
  519. };
  520. #endif
  521. #if CONFIG_SRT_MUXER
  522. AVOutputFormat srt_muxer = {
  523. .name = "srt",
  524. .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle format"),
  525. .mime_type = "application/x-subrip",
  526. .extensions = "srt",
  527. .write_packet = ff_raw_write_packet,
  528. .flags = AVFMT_NOTIMESTAMPS,
  529. .subtitle_codec = CODEC_ID_SRT,
  530. };
  531. #endif
  532. #if CONFIG_TRUEHD_DEMUXER
  533. AVInputFormat truehd_demuxer = {
  534. "truehd",
  535. NULL_IF_CONFIG_SMALL("raw TrueHD"),
  536. 0,
  537. NULL,
  538. ff_raw_audio_read_header,
  539. ff_raw_read_partial_packet,
  540. .flags= AVFMT_GENERIC_INDEX,
  541. .extensions = "thd",
  542. .value = CODEC_ID_TRUEHD,
  543. };
  544. #endif
  545. #if CONFIG_TRUEHD_MUXER
  546. AVOutputFormat truehd_muxer = {
  547. "truehd",
  548. NULL_IF_CONFIG_SMALL("raw TrueHD"),
  549. NULL,
  550. "thd",
  551. 0,
  552. CODEC_ID_TRUEHD,
  553. CODEC_ID_NONE,
  554. NULL,
  555. ff_raw_write_packet,
  556. .flags= AVFMT_NOTIMESTAMPS,
  557. };
  558. #endif
  559. #if CONFIG_MPEG1VIDEO_MUXER
  560. AVOutputFormat mpeg1video_muxer = {
  561. "mpeg1video",
  562. NULL_IF_CONFIG_SMALL("raw MPEG-1 video"),
  563. "video/x-mpeg",
  564. "mpg,mpeg,m1v",
  565. 0,
  566. CODEC_ID_NONE,
  567. CODEC_ID_MPEG1VIDEO,
  568. NULL,
  569. ff_raw_write_packet,
  570. .flags= AVFMT_NOTIMESTAMPS,
  571. };
  572. #endif
  573. #if CONFIG_MPEG2VIDEO_MUXER
  574. AVOutputFormat mpeg2video_muxer = {
  575. "mpeg2video",
  576. NULL_IF_CONFIG_SMALL("raw MPEG-2 video"),
  577. NULL,
  578. "m2v",
  579. 0,
  580. CODEC_ID_NONE,
  581. CODEC_ID_MPEG2VIDEO,
  582. NULL,
  583. ff_raw_write_packet,
  584. .flags= AVFMT_NOTIMESTAMPS,
  585. };
  586. #endif
  587. #if CONFIG_NULL_MUXER
  588. AVOutputFormat null_muxer = {
  589. "null",
  590. NULL_IF_CONFIG_SMALL("raw null video format"),
  591. NULL,
  592. NULL,
  593. 0,
  594. AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE),
  595. CODEC_ID_RAWVIDEO,
  596. NULL,
  597. null_write_packet,
  598. .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
  599. };
  600. #endif
  601. #if CONFIG_RAWVIDEO_DEMUXER
  602. AVInputFormat rawvideo_demuxer = {
  603. "rawvideo",
  604. NULL_IF_CONFIG_SMALL("raw video format"),
  605. 0,
  606. NULL,
  607. raw_read_header,
  608. rawvideo_read_packet,
  609. .flags= AVFMT_GENERIC_INDEX,
  610. .extensions = "yuv,cif,qcif,rgb",
  611. .value = CODEC_ID_RAWVIDEO,
  612. };
  613. #endif
  614. #if CONFIG_RAWVIDEO_MUXER
  615. AVOutputFormat rawvideo_muxer = {
  616. "rawvideo",
  617. NULL_IF_CONFIG_SMALL("raw video format"),
  618. NULL,
  619. "yuv,rgb",
  620. 0,
  621. CODEC_ID_NONE,
  622. CODEC_ID_RAWVIDEO,
  623. NULL,
  624. ff_raw_write_packet,
  625. .flags= AVFMT_NOTIMESTAMPS,
  626. };
  627. #endif
  628. #if CONFIG_SHORTEN_DEMUXER
  629. AVInputFormat shorten_demuxer = {
  630. "shn",
  631. NULL_IF_CONFIG_SMALL("raw Shorten"),
  632. 0,
  633. NULL,
  634. ff_raw_audio_read_header,
  635. ff_raw_read_partial_packet,
  636. .flags= AVFMT_GENERIC_INDEX,
  637. .extensions = "shn",
  638. .value = CODEC_ID_SHORTEN,
  639. };
  640. #endif
  641. #if CONFIG_VC1_DEMUXER
  642. AVInputFormat vc1_demuxer = {
  643. "vc1",
  644. NULL_IF_CONFIG_SMALL("raw VC-1"),
  645. 0,
  646. NULL /* vc1_probe */,
  647. ff_raw_video_read_header,
  648. ff_raw_read_partial_packet,
  649. .extensions = "vc1",
  650. .value = CODEC_ID_VC1,
  651. };
  652. #endif
  653. /* PCM formats */
  654. #define PCMINPUTDEF(name, long_name, ext, codec) \
  655. AVInputFormat pcm_ ## name ## _demuxer = {\
  656. #name,\
  657. NULL_IF_CONFIG_SMALL(long_name),\
  658. 0,\
  659. NULL,\
  660. raw_read_header,\
  661. raw_read_packet,\
  662. NULL,\
  663. pcm_read_seek,\
  664. .flags= AVFMT_GENERIC_INDEX,\
  665. .extensions = ext,\
  666. .value = codec,\
  667. };
  668. #define PCMOUTPUTDEF(name, long_name, ext, codec) \
  669. AVOutputFormat pcm_ ## name ## _muxer = {\
  670. #name,\
  671. NULL_IF_CONFIG_SMALL(long_name),\
  672. NULL,\
  673. ext,\
  674. 0,\
  675. codec,\
  676. CODEC_ID_NONE,\
  677. NULL,\
  678. ff_raw_write_packet,\
  679. .flags= AVFMT_NOTIMESTAMPS,\
  680. };
  681. #if !CONFIG_MUXERS && CONFIG_DEMUXERS
  682. #define PCMDEF(name, long_name, ext, codec) \
  683. PCMINPUTDEF(name, long_name, ext, codec)
  684. #elif CONFIG_MUXERS && !CONFIG_DEMUXERS
  685. #define PCMDEF(name, long_name, ext, codec) \
  686. PCMOUTPUTDEF(name, long_name, ext, codec)
  687. #elif CONFIG_MUXERS && CONFIG_DEMUXERS
  688. #define PCMDEF(name, long_name, ext, codec) \
  689. PCMINPUTDEF(name, long_name, ext, codec)\
  690. PCMOUTPUTDEF(name, long_name, ext, codec)
  691. #else
  692. #define PCMDEF(name, long_name, ext, codec)
  693. #endif
  694. #if HAVE_BIGENDIAN
  695. #define BE_DEF(s) s
  696. #define LE_DEF(s) NULL
  697. #else
  698. #define BE_DEF(s) NULL
  699. #define LE_DEF(s) s
  700. #endif
  701. PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",
  702. NULL, CODEC_ID_PCM_F64BE)
  703. PCMDEF(f64le, "PCM 64 bit floating-point little-endian format",
  704. NULL, CODEC_ID_PCM_F64LE)
  705. PCMDEF(f32be, "PCM 32 bit floating-point big-endian format",
  706. NULL, CODEC_ID_PCM_F32BE)
  707. PCMDEF(f32le, "PCM 32 bit floating-point little-endian format",
  708. NULL, CODEC_ID_PCM_F32LE)
  709. PCMDEF(s32be, "PCM signed 32 bit big-endian format",
  710. NULL, CODEC_ID_PCM_S32BE)
  711. PCMDEF(s32le, "PCM signed 32 bit little-endian format",
  712. NULL, CODEC_ID_PCM_S32LE)
  713. PCMDEF(s24be, "PCM signed 24 bit big-endian format",
  714. NULL, CODEC_ID_PCM_S24BE)
  715. PCMDEF(s24le, "PCM signed 24 bit little-endian format",
  716. NULL, CODEC_ID_PCM_S24LE)
  717. PCMDEF(s16be, "PCM signed 16 bit big-endian format",
  718. BE_DEF("sw"), CODEC_ID_PCM_S16BE)
  719. PCMDEF(s16le, "PCM signed 16 bit little-endian format",
  720. LE_DEF("sw"), CODEC_ID_PCM_S16LE)
  721. PCMDEF(s8, "PCM signed 8 bit format",
  722. "sb", CODEC_ID_PCM_S8)
  723. PCMDEF(u32be, "PCM unsigned 32 bit big-endian format",
  724. NULL, CODEC_ID_PCM_U32BE)
  725. PCMDEF(u32le, "PCM unsigned 32 bit little-endian format",
  726. NULL, CODEC_ID_PCM_U32LE)
  727. PCMDEF(u24be, "PCM unsigned 24 bit big-endian format",
  728. NULL, CODEC_ID_PCM_U24BE)
  729. PCMDEF(u24le, "PCM unsigned 24 bit little-endian format",
  730. NULL, CODEC_ID_PCM_U24LE)
  731. PCMDEF(u16be, "PCM unsigned 16 bit big-endian format",
  732. BE_DEF("uw"), CODEC_ID_PCM_U16BE)
  733. PCMDEF(u16le, "PCM unsigned 16 bit little-endian format",
  734. LE_DEF("uw"), CODEC_ID_PCM_U16LE)
  735. PCMDEF(u8, "PCM unsigned 8 bit format",
  736. "ub", CODEC_ID_PCM_U8)
  737. PCMDEF(alaw, "PCM A-law format",
  738. "al", CODEC_ID_PCM_ALAW)
  739. PCMDEF(mulaw, "PCM mu-law format",
  740. "ul", CODEC_ID_PCM_MULAW)