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.

64 lines
1.8KB

  1. /*
  2. * D-Cinema audio decoder.
  3. * Copyright (c) 2005 Reimar Döffinger.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include "avformat.h"
  20. static int daud_header(AVFormatContext *s, AVFormatParameters *ap) {
  21. AVStream *st = av_new_stream(s, 0);
  22. st->codec->codec_type = CODEC_TYPE_AUDIO;
  23. st->codec->codec_id = CODEC_ID_PCM_S24DAUD;
  24. st->codec->codec_tag = MKTAG('d', 'a', 'u', 'd');
  25. st->codec->channels = 6;
  26. st->codec->sample_rate = 96000;
  27. st->codec->bit_rate = 3 * 6 * 96000 * 8;
  28. st->codec->block_align = 3 * 6;
  29. st->codec->bits_per_sample = 24;
  30. return 0;
  31. }
  32. static int daud_packet(AVFormatContext *s, AVPacket *pkt) {
  33. ByteIOContext *pb = &s->pb;
  34. int ret, size;
  35. if (url_feof(pb))
  36. return AVERROR_IO;
  37. size = get_be16(pb);
  38. get_be16(pb); // unknown
  39. ret = av_get_packet(pb, pkt, size);
  40. pkt->stream_index = 0;
  41. return ret;
  42. }
  43. static AVInputFormat daud_iformat = {
  44. "daud",
  45. "D-Cinema audio format",
  46. 0,
  47. NULL,
  48. daud_header,
  49. daud_packet,
  50. NULL,
  51. NULL,
  52. .extensions = "302",
  53. };
  54. int daud_init(void)
  55. {
  56. av_register_input_format(&daud_iformat);
  57. return 0;
  58. }