* qatar/master:
lavfi: add select filter
oggdec: fix out of bound write in the ogg demuxer
movenc: create an alternate group for each media type
lavd: add libcdio-paranoia input device for audio CD grabbing
rawdec: refactor private option for raw video demuxers
pcmdec: use unique classes for all pcm demuxers.
rawdec: g722 is always 1 channel/16kHz
Conflicts:
Changelog
configure
doc/filters.texi
libavdevice/avdevice.h
libavfilter/avfilter.h
libavfilter/vf_select.c
tests/ref/lavf/mov
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -167,6 +167,7 @@ External library support: |
167 | 167 |
--enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no] |
168 | 168 |
--enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no] |
169 | 169 |
--enable-libopencv enable video filtering via libopencv [no] |
170 |
+ --enable-libcdio enable audio CD grabbing with libcdio |
|
170 | 171 |
--enable-libdc1394 enable IIDC-1394 grabbing using libdc1394 |
171 | 172 |
and libraw1394 [no] |
172 | 173 |
--enable-libdirac enable Dirac support via libdirac [no] |
... | ... |
@@ -992,6 +993,7 @@ CONFIG_LIST=" |
992 | 992 |
h264pred |
993 | 993 |
hardcoded_tables |
994 | 994 |
huffman |
995 |
+ libcdio |
|
995 | 996 |
libcelt |
996 | 997 |
libdc1394 |
997 | 998 |
libdirac |
... | ... |
@@ -1548,6 +1550,7 @@ dv1394_indev_deps="dv1394 dv_demuxer" |
1548 | 1548 |
fbdev_indev_deps="linux_fb_h" |
1549 | 1549 |
jack_indev_deps="jack_jack_h sem_timedwait" |
1550 | 1550 |
lavfi_indev_deps="avfilter" |
1551 |
+libcdio_indev_deps="libcdio" |
|
1551 | 1552 |
libdc1394_indev_deps="libdc1394" |
1552 | 1553 |
openal_indev_deps="openal" |
1553 | 1554 |
oss_indev_deps_any="soundcard_h sys_soundcard_h" |
... | ... |
@@ -2669,6 +2672,7 @@ die_license_disabled() { |
2669 | 2669 |
enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; } |
2670 | 2670 |
} |
2671 | 2671 |
|
2672 |
+die_license_disabled gpl libcdio |
|
2672 | 2673 |
die_license_disabled gpl libx264 |
2673 | 2674 |
die_license_disabled gpl libxavs |
2674 | 2675 |
die_license_disabled gpl libxvid |
... | ... |
@@ -3092,6 +3096,9 @@ enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_fu |
3092 | 3092 |
|
3093 | 3093 |
enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio |
3094 | 3094 |
|
3095 |
+enabled libcdio && |
|
3096 |
+ check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open "-lcdio_paranoia -lcdio_cdda -lcdio" |
|
3097 |
+ |
|
3095 | 3098 |
enabled x11grab && |
3096 | 3099 |
check_header X11/Xlib.h && |
3097 | 3100 |
check_header X11/extensions/XShm.h && |
... | ... |
@@ -3315,6 +3322,7 @@ echo "libvdpau enabled ${vdpau-no}" |
3315 | 3315 |
echo "AVISynth enabled ${avisynth-no}" |
3316 | 3316 |
echo "libcelt enabled ${libcelt-no}" |
3317 | 3317 |
echo "frei0r enabled ${frei0r-no}" |
3318 |
+echo "libcdio support ${libcdio-no}" |
|
3318 | 3319 |
echo "libdc1394 support ${libdc1394-no}" |
3319 | 3320 |
echo "libdirac enabled ${libdirac-no}" |
3320 | 3321 |
echo "libfaac enabled ${libfaac-no}" |
... | ... |
@@ -1680,26 +1680,26 @@ the PTS of the first video frame in the video, NAN if undefined |
1680 | 1680 |
the time of the first video frame in the video, NAN if undefined |
1681 | 1681 |
|
1682 | 1682 |
@item pict_type |
1683 |
-the picture type of the filtered frame, can assume one of the following |
|
1683 |
+the type of the filtered frame, can assume one of the following |
|
1684 | 1684 |
values: |
1685 | 1685 |
@table @option |
1686 |
-@item PICT_TYPE_I |
|
1687 |
-@item PICT_TYPE_P |
|
1688 |
-@item PICT_TYPE_B |
|
1689 |
-@item PICT_TYPE_S |
|
1690 |
-@item PICT_TYPE_SI |
|
1691 |
-@item PICT_TYPE_SP |
|
1692 |
-@item PICT_TYPE_BI |
|
1686 |
+@item I |
|
1687 |
+@item P |
|
1688 |
+@item B |
|
1689 |
+@item S |
|
1690 |
+@item SI |
|
1691 |
+@item SP |
|
1692 |
+@item BI |
|
1693 | 1693 |
@end table |
1694 | 1694 |
|
1695 | 1695 |
@item interlace_type |
1696 | 1696 |
the frame interlace type, can assume one of the following values: |
1697 | 1697 |
@table @option |
1698 |
-@item INTERLACE_TYPE_P |
|
1698 |
+@item PROGRESSIVE |
|
1699 | 1699 |
the frame is progressive (not interlaced) |
1700 |
-@item INTERLACE_TYPE_T |
|
1700 |
+@item TOPFIRST |
|
1701 | 1701 |
the frame is top-field-first |
1702 |
-@item INTERLACE_TYPE_B |
|
1702 |
+@item BOTTOMFIRST |
|
1703 | 1703 |
the frame is bottom-field-first |
1704 | 1704 |
@end table |
1705 | 1705 |
|
... | ... |
@@ -1726,7 +1726,7 @@ select=1 |
1726 | 1726 |
select=0 |
1727 | 1727 |
|
1728 | 1728 |
# select only I-frames |
1729 |
-select='eq(pict_type\,PICT_TYPE_I)' |
|
1729 |
+select='eq(pict_type\,I)' |
|
1730 | 1730 |
|
1731 | 1731 |
# select one frame every 100 |
1732 | 1732 |
select='not(mod(n\,100))' |
... | ... |
@@ -1735,7 +1735,7 @@ select='not(mod(n\,100))' |
1735 | 1735 |
select='gte(t\,10)*lte(t\,20)' |
1736 | 1736 |
|
1737 | 1737 |
# select only I frames contained in the 10-20 time interval |
1738 |
-select='gte(t\,10)*lte(t\,20)*eq(pict_type\,PICT_TYPE_I)' |
|
1738 |
+select='gte(t\,10)*lte(t\,20)*eq(pict_type\,I)' |
|
1739 | 1739 |
|
1740 | 1740 |
# select frames with a minimum distance of 10 seconds |
1741 | 1741 |
select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)' |
... | ... |
@@ -33,6 +33,7 @@ OBJS-$(CONFIG_VFWCAP_INDEV) += vfwcap.o |
33 | 33 |
OBJS-$(CONFIG_X11_GRAB_DEVICE_INDEV) += x11grab.o |
34 | 34 |
|
35 | 35 |
# external libraries |
36 |
+OBJS-$(CONFIG_LIBCDIO_INDEV) += libcdio.o |
|
36 | 37 |
OBJS-$(CONFIG_LIBDC1394_INDEV) += libdc1394.o |
37 | 38 |
|
38 | 39 |
SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H) += alsa-audio.h |
... | ... |
@@ -23,8 +23,8 @@ |
23 | 23 |
#include "libavformat/avformat.h" |
24 | 24 |
|
25 | 25 |
#define LIBAVDEVICE_VERSION_MAJOR 53 |
26 |
-#define LIBAVDEVICE_VERSION_MINOR 3 |
|
27 |
-#define LIBAVDEVICE_VERSION_MICRO 3 |
|
26 |
+#define LIBAVDEVICE_VERSION_MINOR 4 |
|
27 |
+#define LIBAVDEVICE_VERSION_MICRO 0 |
|
28 | 28 |
|
29 | 29 |
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ |
30 | 30 |
LIBAVDEVICE_VERSION_MINOR, \ |
31 | 31 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,186 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2011 Anton Khirnov <anton@khirnov.net> |
|
2 |
+ * |
|
3 |
+ * This file is part of Libav. |
|
4 |
+ * |
|
5 |
+ * Libav 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.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * Libav 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 Libav; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * @file |
|
22 |
+ * libcdio CD grabbing |
|
23 |
+ */ |
|
24 |
+ |
|
25 |
+#include <cdio/cdda.h> |
|
26 |
+#include <cdio/paranoia.h> |
|
27 |
+ |
|
28 |
+#include "libavutil/log.h" |
|
29 |
+#include "libavutil/mem.h" |
|
30 |
+#include "libavutil/opt.h" |
|
31 |
+ |
|
32 |
+#include "libavformat/avformat.h" |
|
33 |
+#include "libavformat/internal.h" |
|
34 |
+ |
|
35 |
+/* cdio returns some malloced strings that need to be free()d */ |
|
36 |
+#undef free |
|
37 |
+ |
|
38 |
+typedef struct CDIOContext { |
|
39 |
+ cdrom_drive_t *drive; |
|
40 |
+ cdrom_paranoia_t *paranoia; |
|
41 |
+ int32_t last_sector; |
|
42 |
+ |
|
43 |
+ /* private options */ |
|
44 |
+ int speed; |
|
45 |
+ int paranoia_mode; |
|
46 |
+} CDIOContext; |
|
47 |
+ |
|
48 |
+static av_cold int read_header(AVFormatContext *ctx, AVFormatParameters *ap) |
|
49 |
+{ |
|
50 |
+ CDIOContext *s = ctx->priv_data; |
|
51 |
+ AVStream *st; |
|
52 |
+ int ret, i; |
|
53 |
+ char *err = NULL; |
|
54 |
+ |
|
55 |
+ if (!(st = av_new_stream(ctx, 0))) |
|
56 |
+ return AVERROR(ENOMEM); |
|
57 |
+ s->drive = cdio_cddap_identify(ctx->filename, CDDA_MESSAGE_LOGIT, &err); |
|
58 |
+ if (!s->drive) { |
|
59 |
+ av_log(ctx, AV_LOG_ERROR, "Could not open drive %s.\n", ctx->filename); |
|
60 |
+ return AVERROR(EINVAL); |
|
61 |
+ } |
|
62 |
+ if (err) { |
|
63 |
+ av_log(ctx, AV_LOG_VERBOSE, "%s\n", err); |
|
64 |
+ free(err); |
|
65 |
+ } |
|
66 |
+ if ((ret = cdio_cddap_open(s->drive)) < 0 || !s->drive->opened) { |
|
67 |
+ av_log(ctx, AV_LOG_ERROR, "Could not open disk in drive %s.\n", ctx->filename); |
|
68 |
+ return AVERROR(EINVAL); |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ cdio_cddap_verbose_set(s->drive, CDDA_MESSAGE_LOGIT, CDDA_MESSAGE_LOGIT); |
|
72 |
+ if (s->speed) |
|
73 |
+ cdio_cddap_speed_set(s->drive, s->speed); |
|
74 |
+ |
|
75 |
+ s->paranoia = cdio_paranoia_init(s->drive); |
|
76 |
+ if (!s->paranoia) { |
|
77 |
+ av_log(ctx, AV_LOG_ERROR, "Could not init paranoia.\n"); |
|
78 |
+ return AVERROR(EINVAL); |
|
79 |
+ } |
|
80 |
+ cdio_paranoia_modeset(s->paranoia, s->paranoia_mode); |
|
81 |
+ |
|
82 |
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
|
83 |
+ if (s->drive->bigendianp) |
|
84 |
+ st->codec->codec_id = CODEC_ID_PCM_S16BE; |
|
85 |
+ else |
|
86 |
+ st->codec->codec_id = CODEC_ID_PCM_S16LE; |
|
87 |
+ st->codec->sample_rate = 44100; |
|
88 |
+ st->codec->channels = 2; |
|
89 |
+ if (s->drive->audio_last_sector != CDIO_INVALID_LSN && |
|
90 |
+ s->drive->audio_first_sector != CDIO_INVALID_LSN) |
|
91 |
+ st->duration = s->drive->audio_last_sector - s->drive->audio_first_sector; |
|
92 |
+ else if (s->drive->tracks) |
|
93 |
+ st->duration = s->drive->disc_toc[s->drive->tracks].dwStartSector; |
|
94 |
+ av_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2*st->codec->channels*st->codec->sample_rate); |
|
95 |
+ |
|
96 |
+ for (i = 0; i < s->drive->tracks; i++) { |
|
97 |
+ char title[16]; |
|
98 |
+ snprintf(title, sizeof(title), "track %02d", s->drive->disc_toc[i].bTrack); |
|
99 |
+ ff_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector, |
|
100 |
+ s->drive->disc_toc[i+1].dwStartSector, title); |
|
101 |
+ } |
|
102 |
+ |
|
103 |
+ s->last_sector = cdio_cddap_disc_lastsector(s->drive); |
|
104 |
+ |
|
105 |
+ return 0; |
|
106 |
+} |
|
107 |
+ |
|
108 |
+static int read_packet(AVFormatContext *ctx, AVPacket *pkt) |
|
109 |
+{ |
|
110 |
+ CDIOContext *s = ctx->priv_data; |
|
111 |
+ int ret; |
|
112 |
+ uint16_t *buf; |
|
113 |
+ char *err = NULL; |
|
114 |
+ |
|
115 |
+ if (ctx->streams[0]->cur_dts > s->last_sector) |
|
116 |
+ return AVERROR_EOF; |
|
117 |
+ |
|
118 |
+ buf = cdio_paranoia_read(s->paranoia, NULL); |
|
119 |
+ if (!buf) |
|
120 |
+ return AVERROR_EOF; |
|
121 |
+ |
|
122 |
+ if (err = cdio_cddap_errors(s->drive)) { |
|
123 |
+ av_log(ctx, AV_LOG_ERROR, "%s\n", err); |
|
124 |
+ free(err); |
|
125 |
+ err = NULL; |
|
126 |
+ } |
|
127 |
+ if (err = cdio_cddap_messages(s->drive)) { |
|
128 |
+ av_log(ctx, AV_LOG_VERBOSE, "%s\n", err); |
|
129 |
+ free(err); |
|
130 |
+ err = NULL; |
|
131 |
+ } |
|
132 |
+ |
|
133 |
+ if ((ret = av_new_packet(pkt, CDIO_CD_FRAMESIZE_RAW)) < 0) |
|
134 |
+ return ret; |
|
135 |
+ memcpy(pkt->data, buf, CDIO_CD_FRAMESIZE_RAW); |
|
136 |
+ return 0; |
|
137 |
+} |
|
138 |
+ |
|
139 |
+static av_cold int read_close(AVFormatContext *ctx) |
|
140 |
+{ |
|
141 |
+ CDIOContext *s = ctx->priv_data; |
|
142 |
+ cdio_paranoia_free(s->paranoia); |
|
143 |
+ cdio_cddap_close(s->drive); |
|
144 |
+ return 0; |
|
145 |
+} |
|
146 |
+ |
|
147 |
+static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, |
|
148 |
+ int flags) |
|
149 |
+{ |
|
150 |
+ CDIOContext *s = ctx->priv_data; |
|
151 |
+ AVStream *st = ctx->streams[0]; |
|
152 |
+ |
|
153 |
+ cdio_paranoia_seek(s->paranoia, timestamp, SEEK_SET); |
|
154 |
+ st->cur_dts = timestamp; |
|
155 |
+ return 0; |
|
156 |
+} |
|
157 |
+ |
|
158 |
+#define OFFSET(x) offsetof(CDIOContext, x) |
|
159 |
+#define DEC AV_OPT_FLAG_DECODING_PARAM |
|
160 |
+static const AVOption options[] = { |
|
161 |
+ { "speed", "Drive reading speed.", OFFSET(speed), FF_OPT_TYPE_INT, { 0 }, 0, INT_MAX, DEC }, |
|
162 |
+ { "paranoia_mode", "Error recovery mode.", OFFSET(paranoia_mode), FF_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, DEC, "paranoia_mode" }, |
|
163 |
+ { "verify", "Verify data integrity in overlap area", 0, FF_OPT_TYPE_CONST, { PARANOIA_MODE_VERIFY }, 0, 0, DEC, "paranoia_mode" }, |
|
164 |
+ { "overlap", "Perform overlapped reads.", 0, FF_OPT_TYPE_CONST, { PARANOIA_MODE_OVERLAP }, 0, 0, DEC, "paranoia_mode" }, |
|
165 |
+ { "neverskip", "Do not skip failed reads.", 0, FF_OPT_TYPE_CONST, { PARANOIA_MODE_NEVERSKIP }, 0, 0, DEC, "paranoia_mode" }, |
|
166 |
+ { NULL }, |
|
167 |
+}; |
|
168 |
+ |
|
169 |
+static const AVClass libcdio_class = { |
|
170 |
+ .class_name = "libcdio indev", |
|
171 |
+ .item_name = av_default_item_name, |
|
172 |
+ .option = options, |
|
173 |
+ .version = LIBAVUTIL_VERSION_INT, |
|
174 |
+}; |
|
175 |
+ |
|
176 |
+AVInputFormat ff_libcdio_demuxer = { |
|
177 |
+ .name = "libcdio", |
|
178 |
+ .read_header = read_header, |
|
179 |
+ .read_packet = read_packet, |
|
180 |
+ .read_close = read_close, |
|
181 |
+ .read_seek = read_seek, |
|
182 |
+ .priv_data_size = sizeof(CDIOContext), |
|
183 |
+ .flags = AVFMT_NOFILE, |
|
184 |
+ .priv_class = &libcdio_class, |
|
185 |
+}; |
... | ... |
@@ -45,18 +45,18 @@ static const char *var_names[] = { |
45 | 45 |
"prev_selected_t", ///< previously selected time |
46 | 46 |
|
47 | 47 |
"pict_type", ///< the type of picture in the movie |
48 |
- "PICT_TYPE_I", |
|
49 |
- "PICT_TYPE_P", |
|
50 |
- "PICT_TYPE_B", |
|
51 |
- "PICT_TYPE_S", |
|
52 |
- "PICT_TYPE_SI", |
|
53 |
- "PICT_TYPE_SP", |
|
54 |
- "PICT_TYPE_BI", |
|
48 |
+ "I", |
|
49 |
+ "P", |
|
50 |
+ "B", |
|
51 |
+ "S", |
|
52 |
+ "SI", |
|
53 |
+ "SP", |
|
54 |
+ "BI", |
|
55 | 55 |
|
56 | 56 |
"interlace_type", ///< the frame interlace type |
57 |
- "INTERLACE_TYPE_P", |
|
58 |
- "INTERLACE_TYPE_T", |
|
59 |
- "INTERLACE_TYPE_B", |
|
57 |
+ "PROGRESSIVE", |
|
58 |
+ "TOPFIRST", |
|
59 |
+ "BOTTOMFIRST", |
|
60 | 60 |
|
61 | 61 |
"n", ///< frame number (starting from zero) |
62 | 62 |
"selected_n", ///< selected frame number (starting from zero) |
... | ... |
@@ -317,19 +317,14 @@ static av_cold void uninit(AVFilterContext *ctx) |
317 | 317 |
{ |
318 | 318 |
SelectContext *select = ctx->priv; |
319 | 319 |
AVFilterBufferRef *picref; |
320 |
- int i; |
|
321 | 320 |
|
322 |
- if (select->expr) |
|
323 |
- av_expr_free(select->expr); |
|
321 |
+ av_expr_free(select->expr); |
|
324 | 322 |
select->expr = NULL; |
325 | 323 |
|
326 |
- if (select->pending_frames) { |
|
327 |
- for (i = 0; i < av_fifo_size(select->pending_frames)/sizeof(picref); i++) { |
|
328 |
- av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL); |
|
329 |
- avfilter_unref_buffer(picref); |
|
330 |
- } |
|
331 |
- av_fifo_free(select->pending_frames); |
|
332 |
- } |
|
324 |
+ while (select->pending_frames && |
|
325 |
+ av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL) == sizeof(picref)) |
|
326 |
+ avfilter_unref_buffer(picref); |
|
327 |
+ av_fifo_free(select->pending_frames); |
|
333 | 328 |
select->pending_frames = NULL; |
334 | 329 |
} |
335 | 330 |
|
... | ... |
@@ -58,6 +58,8 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt) |
58 | 58 |
return ret; |
59 | 59 |
} |
60 | 60 |
|
61 |
+FF_RAWVIDEO_DEMUXER_CLASS(ingenient) |
|
62 |
+ |
|
61 | 63 |
AVInputFormat ff_ingenient_demuxer = { |
62 | 64 |
.name = "ingenient", |
63 | 65 |
.long_name = NULL_IF_CONFIG_SMALL("raw Ingenient MJPEG"), |
... | ... |
@@ -67,5 +69,5 @@ AVInputFormat ff_ingenient_demuxer = { |
67 | 67 |
.flags= AVFMT_GENERIC_INDEX, |
68 | 68 |
.extensions = "cgi", // FIXME |
69 | 69 |
.value = CODEC_ID_MJPEG, |
70 |
- .priv_class = &ff_rawvideo_demuxer_class, |
|
70 |
+ .priv_class = &ingenient_demuxer_class, |
|
71 | 71 |
}; |
... | ... |
@@ -1225,7 +1225,8 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) |
1225 | 1225 |
|
1226 | 1226 |
avio_wb32(pb, 0); /* reserved */ |
1227 | 1227 |
avio_wb32(pb, 0); /* reserved */ |
1228 |
- avio_wb32(pb, 0x0); /* reserved (Layer & Alternate group) */ |
|
1228 |
+ avio_wb16(pb, 0); /* layer */ |
|
1229 |
+ avio_wb16(pb, st->codec->codec_type); /* alternate group) */ |
|
1229 | 1230 |
/* Volume, only for audio */ |
1230 | 1231 |
if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO) |
1231 | 1232 |
avio_wb16(pb, 0x0100); |
... | ... |
@@ -22,6 +22,8 @@ |
22 | 22 |
#include "avformat.h" |
23 | 23 |
#include "rawdec.h" |
24 | 24 |
#include "pcm.h" |
25 |
+#include "libavutil/log.h" |
|
26 |
+#include "libavutil/opt.h" |
|
25 | 27 |
|
26 | 28 |
#define RAW_SAMPLES 1024 |
27 | 29 |
|
... | ... |
@@ -46,7 +48,19 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) |
46 | 46 |
return ret; |
47 | 47 |
} |
48 | 48 |
|
49 |
+static const AVOption pcm_options[] = { |
|
50 |
+ { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, |
|
51 |
+ { "channels", "", offsetof(RawAudioDemuxerContext, channels), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, |
|
52 |
+ { NULL }, |
|
53 |
+}; |
|
54 |
+ |
|
49 | 55 |
#define PCMDEF(name, long_name, ext, codec) \ |
56 |
+static const AVClass name ## _demuxer_class = {\ |
|
57 |
+ .class_name = #name " demuxer",\ |
|
58 |
+ .item_name = av_default_item_name,\ |
|
59 |
+ .option = pcm_options,\ |
|
60 |
+ .version = LIBAVUTIL_VERSION_INT,\ |
|
61 |
+};\ |
|
50 | 62 |
AVInputFormat ff_pcm_ ## name ## _demuxer = {\ |
51 | 63 |
#name,\ |
52 | 64 |
NULL_IF_CONFIG_SMALL(long_name),\ |
... | ... |
@@ -59,7 +73,7 @@ AVInputFormat ff_pcm_ ## name ## _demuxer = {\ |
59 | 59 |
.flags= AVFMT_GENERIC_INDEX,\ |
60 | 60 |
.extensions = ext,\ |
61 | 61 |
.value = codec,\ |
62 |
- .priv_class = &ff_rawaudio_demuxer_class,\ |
|
62 |
+ .priv_class = &name ## _demuxer_class,\ |
|
63 | 63 |
}; |
64 | 64 |
|
65 | 65 |
PCMDEF(f64be, "PCM 64 bit floating-point big-endian format", |
... | ... |
@@ -51,9 +51,12 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
51 | 51 |
|
52 | 52 |
st->codec->channels = 1; |
53 | 53 |
|
54 |
- if (s1->sample_rate) |
|
54 |
+ if (id == CODEC_ID_ADPCM_G722) |
|
55 |
+ st->codec->sample_rate = 16000; |
|
56 |
+ |
|
57 |
+ if (s1 && s1->sample_rate) |
|
55 | 58 |
st->codec->sample_rate = s1->sample_rate; |
56 |
- if (s1->channels) |
|
59 |
+ if (s1 && s1->channels) |
|
57 | 60 |
st->codec->channels = s1->channels; |
58 | 61 |
|
59 | 62 |
st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id); |
... | ... |
@@ -165,48 +168,22 @@ fail: |
165 | 165 |
|
166 | 166 |
/* Note: Do not forget to add new entries to the Makefile as well. */ |
167 | 167 |
|
168 |
-static const AVOption audio_options[] = { |
|
169 |
- { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, |
|
170 |
- { "channels", "", offsetof(RawAudioDemuxerContext, channels), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, |
|
171 |
- { NULL }, |
|
172 |
-}; |
|
173 |
- |
|
174 |
-const AVClass ff_rawaudio_demuxer_class = { |
|
175 |
- .class_name = "rawaudio demuxer", |
|
176 |
- .item_name = av_default_item_name, |
|
177 |
- .option = audio_options, |
|
178 |
- .version = LIBAVUTIL_VERSION_INT, |
|
179 |
-}; |
|
180 |
- |
|
181 | 168 |
#define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x) |
182 | 169 |
#define DEC AV_OPT_FLAG_DECODING_PARAM |
183 |
-static const AVOption video_options[] = { |
|
184 |
- { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, |
|
185 |
- { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC }, |
|
186 |
- { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, |
|
170 |
+const AVOption ff_rawvideo_options[] = { |
|
171 |
+ { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC}, |
|
187 | 172 |
{ NULL }, |
188 | 173 |
}; |
189 |
-#undef OFFSET |
|
190 |
-#undef DEC |
|
191 |
- |
|
192 |
-const AVClass ff_rawvideo_demuxer_class = { |
|
193 |
- .class_name = "rawvideo demuxer", |
|
194 |
- .item_name = av_default_item_name, |
|
195 |
- .option = video_options, |
|
196 |
- .version = LIBAVUTIL_VERSION_INT, |
|
197 |
-}; |
|
198 | 174 |
|
199 | 175 |
#if CONFIG_G722_DEMUXER |
200 | 176 |
AVInputFormat ff_g722_demuxer = { |
201 | 177 |
.name = "g722", |
202 | 178 |
.long_name = NULL_IF_CONFIG_SMALL("raw G.722"), |
203 |
- .priv_data_size = sizeof(RawAudioDemuxerContext), |
|
204 | 179 |
.read_header = ff_raw_read_header, |
205 | 180 |
.read_packet = ff_raw_read_partial_packet, |
206 | 181 |
.flags= AVFMT_GENERIC_INDEX, |
207 | 182 |
.extensions = "g722,722", |
208 | 183 |
.value = CODEC_ID_ADPCM_G722, |
209 |
- .priv_class = &ff_rawaudio_demuxer_class, |
|
210 | 184 |
}; |
211 | 185 |
#endif |
212 | 186 |
|
... | ... |
@@ -24,6 +24,7 @@ |
24 | 24 |
|
25 | 25 |
#include "avformat.h" |
26 | 26 |
#include "libavutil/log.h" |
27 |
+#include "libavutil/opt.h" |
|
27 | 28 |
|
28 | 29 |
typedef struct RawAudioDemuxerContext { |
29 | 30 |
AVClass *class; |
... | ... |
@@ -38,8 +39,7 @@ typedef struct FFRawVideoDemuxerContext { |
38 | 38 |
char *framerate; /**< String describing framerate, set by a private option. */ |
39 | 39 |
} FFRawVideoDemuxerContext; |
40 | 40 |
|
41 |
-extern const AVClass ff_rawaudio_demuxer_class; |
|
42 |
-extern const AVClass ff_rawvideo_demuxer_class; |
|
41 |
+extern const AVOption ff_rawvideo_options[]; |
|
43 | 42 |
|
44 | 43 |
int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap); |
45 | 44 |
|
... | ... |
@@ -49,7 +49,16 @@ int ff_raw_audio_read_header(AVFormatContext *s, AVFormatParameters *ap); |
49 | 49 |
|
50 | 50 |
int ff_raw_video_read_header(AVFormatContext *s, AVFormatParameters *ap); |
51 | 51 |
|
52 |
+#define FF_RAWVIDEO_DEMUXER_CLASS(name)\ |
|
53 |
+static const AVClass name ## _demuxer_class = {\ |
|
54 |
+ .class_name = #name " demuxer",\ |
|
55 |
+ .item_name = av_default_item_name,\ |
|
56 |
+ .option = ff_rawvideo_options,\ |
|
57 |
+ .version = LIBAVUTIL_VERSION_INT,\ |
|
58 |
+}; |
|
59 |
+ |
|
52 | 60 |
#define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)\ |
61 |
+FF_RAWVIDEO_DEMUXER_CLASS(shortname)\ |
|
53 | 62 |
AVInputFormat ff_ ## shortname ## _demuxer = {\ |
54 | 63 |
.name = #shortname,\ |
55 | 64 |
.long_name = NULL_IF_CONFIG_SMALL(longname),\ |
... | ... |
@@ -60,7 +69,7 @@ AVInputFormat ff_ ## shortname ## _demuxer = {\ |
60 | 60 |
.flags = AVFMT_GENERIC_INDEX,\ |
61 | 61 |
.value = id,\ |
62 | 62 |
.priv_data_size = sizeof(FFRawVideoDemuxerContext),\ |
63 |
- .priv_class = &ff_rawvideo_demuxer_class,\ |
|
63 |
+ .priv_class = &shortname ## _demuxer_class,\ |
|
64 | 64 |
}; |
65 | 65 |
|
66 | 66 |
#endif /* AVFORMAT_RAWDEC_H */ |
... | ... |
@@ -44,6 +44,22 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) |
44 | 44 |
return 0; |
45 | 45 |
} |
46 | 46 |
|
47 |
+#define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x) |
|
48 |
+#define DEC AV_OPT_FLAG_DECODING_PARAM |
|
49 |
+static const AVOption rawvideo_options[] = { |
|
50 |
+ { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, |
|
51 |
+ { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC }, |
|
52 |
+ { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, |
|
53 |
+ { NULL }, |
|
54 |
+}; |
|
55 |
+ |
|
56 |
+static const AVClass rawvideo_demuxer_class = { |
|
57 |
+ .class_name = "rawvideo demuxer", |
|
58 |
+ .item_name = av_default_item_name, |
|
59 |
+ .option = rawvideo_options, |
|
60 |
+ .version = LIBAVUTIL_VERSION_INT, |
|
61 |
+}; |
|
62 |
+ |
|
47 | 63 |
AVInputFormat ff_rawvideo_demuxer = { |
48 | 64 |
.name = "rawvideo", |
49 | 65 |
.long_name = NULL_IF_CONFIG_SMALL("raw video format"), |
... | ... |
@@ -53,5 +69,5 @@ AVInputFormat ff_rawvideo_demuxer = { |
53 | 53 |
.flags= AVFMT_GENERIC_INDEX, |
54 | 54 |
.extensions = "yuv,cif,qcif,rgb", |
55 | 55 |
.value = CODEC_ID_RAWVIDEO, |
56 |
- .priv_class = &ff_rawvideo_demuxer_class, |
|
56 |
+ .priv_class = &rawvideo_demuxer_class, |
|
57 | 57 |
}; |
... | ... |
@@ -131,7 +131,7 @@ FATE_TESTS += fate-gsm-ms |
131 | 131 |
fate-gsm-ms: CMD = framecrc -i $(SAMPLES)/gsm/ciao.wav |
132 | 132 |
|
133 | 133 |
FATE_TESTS += fate-g722dec-1 |
134 |
-fate-g722dec-1: CMD = framecrc -ar 16000 -i $(SAMPLES)/g722/conf-adminmenu-162.g722 |
|
134 |
+fate-g722dec-1: CMD = framecrc -i $(SAMPLES)/g722/conf-adminmenu-162.g722 |
|
135 | 135 |
|
136 | 136 |
FATE_TESTS += fate-msmpeg4v1 |
137 | 137 |
fate-msmpeg4v1: CMD = framecrc -flags +bitexact -dct fastint -idct simple -i $(SAMPLES)/msmpeg4v1/mpg4.avi -an |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-c68f649777ab8e7c9a0f1f221451d3ad *./tests/data/acodec/alac.m4a |
|
1 |
+b25bcc7ec3f5c19cdfc01a6bbd32edb8 *./tests/data/acodec/alac.m4a |
|
2 | 2 |
389386 ./tests/data/acodec/alac.m4a |
3 | 3 |
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/alac.acodec.out.wav |
4 | 4 |
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 |
... | ... |
@@ -6,7 +6,7 @@ f443a8eeb1647ec1eeb8370c939e52d4 *./tests/data/acodec/pcm_mulaw.wav |
6 | 6 |
529256 ./tests/data/acodec/pcm_mulaw.wav |
7 | 7 |
1c3eeaa8814ebd4916780dff80ed6dc5 *./tests/data/pcm.acodec.out.wav |
8 | 8 |
stddev: 103.38 PSNR: 56.04 MAXDIFF: 644 bytes: 1058400/ 1058400 |
9 |
-b7936d7170e0efefb379349d81aed360 *./tests/data/acodec/pcm_s8.mov |
|
9 |
+760f85fb9f4e8aba326fb44ae84c9507 *./tests/data/acodec/pcm_s8.mov |
|
10 | 10 |
530837 ./tests/data/acodec/pcm_s8.mov |
11 | 11 |
652edf30f35ad89bf27bcc9d2f9c7b53 *./tests/data/pcm.acodec.out.wav |
12 | 12 |
stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400 |
... | ... |
@@ -14,7 +14,7 @@ stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400 |
14 | 14 |
529244 ./tests/data/acodec/pcm_u8.wav |
15 | 15 |
652edf30f35ad89bf27bcc9d2f9c7b53 *./tests/data/pcm.acodec.out.wav |
16 | 16 |
stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400 |
17 |
-c42b9c04305455250366c84e17c1023f *./tests/data/acodec/pcm_s16be.mov |
|
17 |
+a4e18d1ca9ef5b8132a84d43625ddc47 *./tests/data/acodec/pcm_s16be.mov |
|
18 | 18 |
1060037 ./tests/data/acodec/pcm_s16be.mov |
19 | 19 |
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav |
20 | 20 |
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 |
... | ... |
@@ -30,7 +30,7 @@ c4f51bf32fad2f7af8ea5beedb56168b *./tests/data/acodec/pcm_s16le.mkv |
30 | 30 |
1060638 ./tests/data/acodec/pcm_s16le.mkv |
31 | 31 |
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav |
32 | 32 |
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 |
33 |
-07ffe7ffb78f3648b6524debdde5aec1 *./tests/data/acodec/pcm_s24be.mov |
|
33 |
+971d2d2633e41a0326fe2d04a2d0350f *./tests/data/acodec/pcm_s24be.mov |
|
34 | 34 |
1589237 ./tests/data/acodec/pcm_s24be.mov |
35 | 35 |
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav |
36 | 36 |
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 |
... | ... |
@@ -38,7 +38,7 @@ a85380fb79b0d4fff38e24ac1e34bb94 *./tests/data/acodec/pcm_s24le.wav |
38 | 38 |
1587668 ./tests/data/acodec/pcm_s24le.wav |
39 | 39 |
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav |
40 | 40 |
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 |
41 |
-d7792f0343cd66fda8b50b569e2bcc48 *./tests/data/acodec/pcm_s32be.mov |
|
41 |
+fc4f4e3e195bbde037ed31021d229f12 *./tests/data/acodec/pcm_s32be.mov |
|
42 | 42 |
2118437 ./tests/data/acodec/pcm_s32be.mov |
43 | 43 |
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav |
44 | 44 |
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 |