The WAVE demuxer returns packets with many blocks per frame, which needs to be
parsed into single blocks. This has a side-effect of fixing the timestamps.
... | ... |
@@ -2,6 +2,11 @@ Entries are sorted chronologically from oldest to youngest within each release, |
2 | 2 |
releases are sorted from youngest to oldest. |
3 | 3 |
|
4 | 4 |
|
5 |
+version <next>: |
|
6 |
+ |
|
7 |
+- GSM audio parser |
|
8 |
+ |
|
9 |
+ |
|
5 | 10 |
version 0.8_beta2: |
6 | 11 |
|
7 | 12 |
- Automatic thread count based on detection number of (available) CPU cores |
... | ... |
@@ -608,6 +608,7 @@ OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o |
608 | 608 |
OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o |
609 | 609 |
OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o |
610 | 610 |
OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o |
611 |
+OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o |
|
611 | 612 |
OBJS-$(CONFIG_H261_PARSER) += h261_parser.o |
612 | 613 |
OBJS-$(CONFIG_H263_PARSER) += h263_parser.o |
613 | 614 |
OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264.o \ |
... | ... |
@@ -399,6 +399,7 @@ void avcodec_register_all(void) |
399 | 399 |
REGISTER_PARSER (DVBSUB, dvbsub); |
400 | 400 |
REGISTER_PARSER (DVDSUB, dvdsub); |
401 | 401 |
REGISTER_PARSER (FLAC, flac); |
402 |
+ REGISTER_PARSER (GSM, gsm); |
|
402 | 403 |
REGISTER_PARSER (H261, h261); |
403 | 404 |
REGISTER_PARSER (H263, h263); |
404 | 405 |
REGISTER_PARSER (H264, h264); |
405 | 406 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,31 @@ |
0 |
+/* |
|
1 |
+ * GSM common header |
|
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 |
+#ifndef AVCODEC_GSM_H |
|
21 |
+#define AVCODEC_GSM_H |
|
22 |
+ |
|
23 |
+/* bytes per block */ |
|
24 |
+#define GSM_BLOCK_SIZE 33 |
|
25 |
+#define GSM_MS_BLOCK_SIZE 65 |
|
26 |
+ |
|
27 |
+/* samples per block */ |
|
28 |
+#define GSM_FRAME_SIZE 160 |
|
29 |
+ |
|
30 |
+#endif /* AVCODEC_GSM_H */ |
0 | 31 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,79 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2012 Justin Ruggles |
|
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 |
+ * GSM audio parser |
|
23 |
+ * |
|
24 |
+ * Splits packets into individual blocks. |
|
25 |
+ */ |
|
26 |
+ |
|
27 |
+#include "parser.h" |
|
28 |
+#include "gsm.h" |
|
29 |
+ |
|
30 |
+typedef struct GSMParseContext { |
|
31 |
+ ParseContext pc; |
|
32 |
+ int block_size; |
|
33 |
+ int remaining; |
|
34 |
+} GSMParseContext; |
|
35 |
+ |
|
36 |
+static int gsm_parse(AVCodecParserContext *s1, AVCodecContext *avctx, |
|
37 |
+ const uint8_t **poutbuf, int *poutbuf_size, |
|
38 |
+ const uint8_t *buf, int buf_size) |
|
39 |
+{ |
|
40 |
+ GSMParseContext *s = s1->priv_data; |
|
41 |
+ ParseContext *pc = &s->pc; |
|
42 |
+ int next; |
|
43 |
+ |
|
44 |
+ if (!s->block_size) { |
|
45 |
+ switch (avctx->codec_id) { |
|
46 |
+ case CODEC_ID_GSM: s->block_size = GSM_BLOCK_SIZE; break; |
|
47 |
+ case CODEC_ID_GSM_MS: s->block_size = GSM_MS_BLOCK_SIZE; break; |
|
48 |
+ default: |
|
49 |
+ return AVERROR(EINVAL); |
|
50 |
+ } |
|
51 |
+ } |
|
52 |
+ |
|
53 |
+ if (!s->remaining) |
|
54 |
+ s->remaining = s->block_size; |
|
55 |
+ if (s->remaining <= buf_size) { |
|
56 |
+ next = s->remaining; |
|
57 |
+ s->remaining = 0; |
|
58 |
+ } else { |
|
59 |
+ next = END_NOT_FOUND; |
|
60 |
+ s->remaining -= buf_size; |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ if (ff_combine_frame(pc, next, &buf, &buf_size) < 0 || !buf_size) { |
|
64 |
+ *poutbuf = NULL; |
|
65 |
+ *poutbuf_size = 0; |
|
66 |
+ return buf_size; |
|
67 |
+ } |
|
68 |
+ *poutbuf = buf; |
|
69 |
+ *poutbuf_size = buf_size; |
|
70 |
+ return next; |
|
71 |
+} |
|
72 |
+ |
|
73 |
+AVCodecParser ff_gsm_parser = { |
|
74 |
+ .codec_ids = { CODEC_ID_GSM, CODEC_ID_GSM_MS }, |
|
75 |
+ .priv_data_size = sizeof(GSMParseContext), |
|
76 |
+ .parser_parse = gsm_parse, |
|
77 |
+ .parser_close = ff_parse_close, |
|
78 |
+}; |
... | ... |
@@ -25,11 +25,6 @@ |
25 | 25 |
#include <stdint.h> |
26 | 26 |
#include "avcodec.h" |
27 | 27 |
|
28 |
-// input and output sizes in byte |
|
29 |
-#define GSM_BLOCK_SIZE 33 |
|
30 |
-#define GSM_MS_BLOCK_SIZE 65 |
|
31 |
-#define GSM_FRAME_SIZE 160 |
|
32 |
- |
|
33 | 28 |
typedef struct { |
34 | 29 |
AVFrame frame; |
35 | 30 |
// Contains first 120 elements from the previous frame |
... | ... |
@@ -27,13 +27,10 @@ |
27 | 27 |
|
28 | 28 |
// The idiosyncrasies of GSM-in-WAV are explained at http://kbs.cs.tu-berlin.de/~jutta/toast.html |
29 | 29 |
|
30 |
-#include "avcodec.h" |
|
31 | 30 |
#include <gsm/gsm.h> |
32 | 31 |
|
33 |
-// gsm.h misses some essential constants |
|
34 |
-#define GSM_BLOCK_SIZE 33 |
|
35 |
-#define GSM_MS_BLOCK_SIZE 65 |
|
36 |
-#define GSM_FRAME_SIZE 160 |
|
32 |
+#include "avcodec.h" |
|
33 |
+#include "gsm.h" |
|
37 | 34 |
|
38 | 35 |
static av_cold int libgsm_encode_init(AVCodecContext *avctx) { |
39 | 36 |
if (avctx->channels > 1) { |
... | ... |
@@ -21,8 +21,8 @@ |
21 | 21 |
#define AVCODEC_VERSION_H |
22 | 22 |
|
23 | 23 |
#define LIBAVCODEC_VERSION_MAJOR 53 |
24 |
-#define LIBAVCODEC_VERSION_MINOR 32 |
|
25 |
-#define LIBAVCODEC_VERSION_MICRO 2 |
|
24 |
+#define LIBAVCODEC_VERSION_MINOR 33 |
|
25 |
+#define LIBAVCODEC_VERSION_MICRO 0 |
|
26 | 26 |
|
27 | 27 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
28 | 28 |
LIBAVCODEC_VERSION_MINOR, \ |