History

avcodec: add SIPR parser

Fixes #2056.

Paul B Mahol committed 9 years ago

Commit 40cf9431 parent 8fb48656 files · +81 −2Browse files

Unified · Split

6 files
  1. libavcodec/Makefile +1 −0
  2. libavcodec/allcodecs.c +1 −0
  3. libavcodec/sipr_parser.c +74 −0
  4. libavcodec/version.h +2 −2
  5. libavformat/aadec.c +2 −0
  6. libavformat/rmdec.c +1 −0
libavcodec/Makefile+1−0
@@ -943,6 +943,7 @@ OBJS-$(CONFIG_PNG_PARSER) += png_parser.o · 942 unmodified lines
943943 OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
944944 OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o
945945 OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o
946+OBJS-$(CONFIG_SIPR_PARSER) += sipr_parser.o
946947 OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o
947948 OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \
948949 simple_idct.o wmv2data.o
libavcodec/allcodecs.c+1−0
@@ -702,6 +702,7 @@ void avcodec_register_all(void) · 701 unmodified lines
702702 REGISTER_PARSER(PNM, pnm);
703703 REGISTER_PARSER(RV30, rv30);
704704 REGISTER_PARSER(RV40, rv40);
705+ REGISTER_PARSER(SIPR, sipr);
705706 REGISTER_PARSER(TAK, tak);
706707 REGISTER_PARSER(VC1, vc1);
707708 REGISTER_PARSER(VORBIS, vorbis);
libavcodec/sipr_parser.c+74−0
@@ -0,0 +1,74 @@
1+/*
2+ * This file is part of FFmpeg.
3+ *
4+ * FFmpeg is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * FFmpeg is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with FFmpeg; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+/**
20+ * @file
21+ * Sipr audio parser
22+ */
23+
24+#include "parser.h"
25+
26+typedef struct SiprParserContext{
27+ ParseContext pc;
28+} SiprParserContext;
29+
30+static int sipr_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
31+{
32+ int next;
33+
34+ switch (avctx->block_align) {
35+ case 20:
36+ case 19:
37+ case 29:
38+ case 37: next = avctx->block_align; break;
39+ default:
40+ if (avctx->bit_rate > 12200) next = 20;
41+ else if (avctx->bit_rate > 7500 ) next = 19;
42+ else if (avctx->bit_rate > 5750 ) next = 29;
43+ else next = 37;
44+ }
45+
46+ return FFMIN(next, buf_size);
47+}
48+
49+static int sipr_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
50+ const uint8_t **poutbuf, int *poutbuf_size,
51+ const uint8_t *buf, int buf_size)
52+{
53+ SiprParserContext *s = s1->priv_data;
54+ ParseContext *pc = &s->pc;
55+ int next;
56+
57+ next = sipr_split(avctx, buf, buf_size);
58+ if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
59+ *poutbuf = NULL;
60+ *poutbuf_size = 0;
61+ return buf_size;
62+ }
63+
64+ *poutbuf = buf;
65+ *poutbuf_size = buf_size;
66+ return next;
67+}
68+
69+AVCodecParser ff_sipr_parser = {
70+ .codec_ids = { AV_CODEC_ID_SIPR },
71+ .priv_data_size = sizeof(SiprParserContext),
72+ .parser_parse = sipr_parse,
73+ .parser_close = ff_parse_close,
74+};
libavcodec/version.h+2−2
@@ -28,8 +28,8 @@ · 27 unmodified lines
2828 #include "libavutil/version.h"
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 57
31−#define LIBAVCODEC_VERSION_MINOR 72
32−#define LIBAVCODEC_VERSION_MICRO 101
31+#define LIBAVCODEC_VERSION_MINOR 73
32+#define LIBAVCODEC_VERSION_MICRO 100
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3535 LIBAVCODEC_VERSION_MINOR, \
libavformat/aadec.c+2−0
@@ -184,11 +184,13 @@ static int aa_read_header(AVFormatContext *s) · 183 unmodified lines
184184 st->codecpar->block_align = 19;
185185 st->codecpar->channels = 1;
186186 st->codecpar->sample_rate = 8500;
187+ st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
187188 } else if (!strcmp(codec_name, "acelp16")) {
188189 st->codecpar->codec_id = AV_CODEC_ID_SIPR;
189190 st->codecpar->block_align = 20;
190191 st->codecpar->channels = 1;
191192 st->codecpar->sample_rate = 16000;
193+ st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
192194 }
193195
194196 /* determine, and jump to audio start offset */
libavformat/rmdec.c+1−0
@@ -236,6 +236,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, · 235 unmodified lines
236236 return -1;
237237 }
238238 st->codecpar->block_align = ff_sipr_subpk_size[flavor];
239+ st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
239240 } else {
240241 if(sub_packet_size <= 0){
241242 av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t