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
943OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o943OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
944OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o944OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o
945OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o945OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o
946OBJS-$(CONFIG_SIPR_PARSER) += sipr_parser.o
946OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o947OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o
947OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \948OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \
948 simple_idct.o wmv2data.o949 simple_idct.o wmv2data.o
libavcodec/allcodecs.c+1−0
@@ -702,6 +702,7 @@ void avcodec_register_all(void) · 701 unmodified lines
702 REGISTER_PARSER(PNM, pnm);702 REGISTER_PARSER(PNM, pnm);
703 REGISTER_PARSER(RV30, rv30);703 REGISTER_PARSER(RV30, rv30);
704 REGISTER_PARSER(RV40, rv40);704 REGISTER_PARSER(RV40, rv40);
705 REGISTER_PARSER(SIPR, sipr);
705 REGISTER_PARSER(TAK, tak);706 REGISTER_PARSER(TAK, tak);
706 REGISTER_PARSER(VC1, vc1);707 REGISTER_PARSER(VC1, vc1);
707 REGISTER_PARSER(VORBIS, vorbis);708 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
26typedef struct SiprParserContext{
27 ParseContext pc;
28} SiprParserContext;
29
30static 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
49static 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
69AVCodecParser 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
28#include "libavutil/version.h"28#include "libavutil/version.h"
29 29
30#define LIBAVCODEC_VERSION_MAJOR 5730#define LIBAVCODEC_VERSION_MAJOR 57
31#define LIBAVCODEC_VERSION_MINOR 7231#define LIBAVCODEC_VERSION_MINOR 73
32#define LIBAVCODEC_VERSION_MICRO 10132#define LIBAVCODEC_VERSION_MICRO 100
33 33
34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
35 LIBAVCODEC_VERSION_MINOR, \35 LIBAVCODEC_VERSION_MINOR, \
libavformat/aadec.c+2−0
@@ -184,11 +184,13 @@ static int aa_read_header(AVFormatContext *s) · 183 unmodified lines
184 st->codecpar->block_align = 19;184 st->codecpar->block_align = 19;
185 st->codecpar->channels = 1;185 st->codecpar->channels = 1;
186 st->codecpar->sample_rate = 8500;186 st->codecpar->sample_rate = 8500;
187 st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
187 } else if (!strcmp(codec_name, "acelp16")) {188 } else if (!strcmp(codec_name, "acelp16")) {
188 st->codecpar->codec_id = AV_CODEC_ID_SIPR;189 st->codecpar->codec_id = AV_CODEC_ID_SIPR;
189 st->codecpar->block_align = 20;190 st->codecpar->block_align = 20;
190 st->codecpar->channels = 1;191 st->codecpar->channels = 1;
191 st->codecpar->sample_rate = 16000;192 st->codecpar->sample_rate = 16000;
193 st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
192 }194 }
193 195
194 /* determine, and jump to audio start offset */196 /* 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
236 return -1;236 return -1;
237 }237 }
238 st->codecpar->block_align = ff_sipr_subpk_size[flavor];238 st->codecpar->block_align = ff_sipr_subpk_size[flavor];
239 st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
239 } else {240 } else {
240 if(sub_packet_size <= 0){241 if(sub_packet_size <= 0){
241 av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");242 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