diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 7094722c8d..ee4294bd9a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -943,6 +943,7 @@ OBJS-$(CONFIG_PNG_PARSER) += png_parser.o OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o +OBJS-$(CONFIG_SIPR_PARSER) += sipr_parser.o OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \ simple_idct.o wmv2data.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 22a93f305c..703c552f5f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -702,6 +702,7 @@ void avcodec_register_all(void) REGISTER_PARSER(PNM, pnm); REGISTER_PARSER(RV30, rv30); REGISTER_PARSER(RV40, rv40); + REGISTER_PARSER(SIPR, sipr); REGISTER_PARSER(TAK, tak); REGISTER_PARSER(VC1, vc1); REGISTER_PARSER(VORBIS, vorbis); diff --git a/libavcodec/sipr_parser.c b/libavcodec/sipr_parser.c new file mode 100644 index 0000000000..fba25e1028 --- /dev/null +++ b/libavcodec/sipr_parser.c @@ -0,0 +1,74 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg 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, + * 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 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Sipr audio parser + */ + +#include "parser.h" + +typedef struct SiprParserContext{ + ParseContext pc; +} SiprParserContext; + +static int sipr_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size) +{ + int next; + + switch (avctx->block_align) { + case 20: + case 19: + case 29: + case 37: next = avctx->block_align; break; + default: + if (avctx->bit_rate > 12200) next = 20; + else if (avctx->bit_rate > 7500 ) next = 19; + else if (avctx->bit_rate > 5750 ) next = 29; + else next = 37; + } + + return FFMIN(next, buf_size); +} + +static int sipr_parse(AVCodecParserContext *s1, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + SiprParserContext *s = s1->priv_data; + ParseContext *pc = &s->pc; + int next; + + next = sipr_split(avctx, buf, buf_size); + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } + + *poutbuf = buf; + *poutbuf_size = buf_size; + return next; +} + +AVCodecParser ff_sipr_parser = { + .codec_ids = { AV_CODEC_ID_SIPR }, + .priv_data_size = sizeof(SiprParserContext), + .parser_parse = sipr_parse, + .parser_close = ff_parse_close, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index 2a0df198ea..b0dd46d6fb 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 72 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 73 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavformat/aadec.c b/libavformat/aadec.c index cf5f3d107a..0f4ec2019d 100644 --- a/libavformat/aadec.c +++ b/libavformat/aadec.c @@ -184,11 +184,13 @@ static int aa_read_header(AVFormatContext *s) st->codecpar->block_align = 19; st->codecpar->channels = 1; st->codecpar->sample_rate = 8500; + st->need_parsing = AVSTREAM_PARSE_FULL_RAW; } else if (!strcmp(codec_name, "acelp16")) { st->codecpar->codec_id = AV_CODEC_ID_SIPR; st->codecpar->block_align = 20; st->codecpar->channels = 1; st->codecpar->sample_rate = 16000; + st->need_parsing = AVSTREAM_PARSE_FULL_RAW; } /* determine, and jump to audio start offset */ diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 4d565291af..c803588939 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -236,6 +236,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, return -1; } st->codecpar->block_align = ff_sipr_subpk_size[flavor]; + st->need_parsing = AVSTREAM_PARSE_FULL_RAW; } else { if(sub_packet_size <= 0){ av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");