]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/pcmdec.c
audioconvert: add some additional channel and channel layout macros
[ffmpeg] / libavformat / pcmdec.c
index b657fb680b625329698fba4abc1a9e8254bf9350..b61fb33764eb20441859f42a4f639efca05ae255 100644 (file)
@@ -2,26 +2,28 @@
  * RAW PCM demuxers
  * Copyright (c) 2002 Fabrice Bellard
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "avformat.h"
-#include "raw.h"
+#include "rawdec.h"
 #include "pcm.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
 
 #define RAW_SAMPLES     1024
 
@@ -46,19 +48,30 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
-#define PCMDEF(name, long_name, ext, codec) \
-AVInputFormat pcm_ ## name ## _demuxer = {\
-    #name,\
-    NULL_IF_CONFIG_SMALL(long_name),\
-    0,\
-    NULL,\
-    ff_raw_read_header,\
-    raw_read_packet,\
-    NULL,\
-    pcm_read_seek,\
-    .flags= AVFMT_GENERIC_INDEX,\
-    .extensions = ext,\
-    .value = codec,\
+static const AVOption pcm_options[] = {
+    { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { "channels",    "", offsetof(RawAudioDemuxerContext, channels),    AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { NULL },
+};
+
+#define PCMDEF(name_, long_name_, ext, codec)               \
+static const AVClass name_ ## _demuxer_class = {            \
+    .class_name = #name_ " demuxer",                        \
+    .item_name  = av_default_item_name,                     \
+    .option     = pcm_options,                              \
+    .version    = LIBAVUTIL_VERSION_INT,                    \
+};                                                          \
+AVInputFormat ff_pcm_ ## name_ ## _demuxer = {              \
+    .name           = #name_,                               \
+    .long_name      = NULL_IF_CONFIG_SMALL(long_name_),     \
+    .priv_data_size = sizeof(RawAudioDemuxerContext),       \
+    .read_header    = ff_raw_read_header,                   \
+    .read_packet    = raw_read_packet,                      \
+    .read_seek      = pcm_read_seek,                        \
+    .flags          = AVFMT_GENERIC_INDEX,                  \
+    .extensions     = ext,                                  \
+    .value          = codec,                                \
+    .priv_class     = &name_ ## _demuxer_class,             \
 };
 
 PCMDEF(f64be, "PCM 64 bit floating-point big-endian format",