mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-27 01:42:20 +00:00
avcodec: add SIPR parser
Fixes #2056. Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
8fb4865901
commit
40cf943714
@ -943,6 +943,7 @@ OBJS-$(CONFIG_PNG_PARSER) += png_parser.o
|
|||||||
OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
|
OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
|
||||||
OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o
|
OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o
|
||||||
OBJS-$(CONFIG_RV40_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_TAK_PARSER) += tak_parser.o tak.o
|
||||||
OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \
|
OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \
|
||||||
simple_idct.o wmv2data.o
|
simple_idct.o wmv2data.o
|
||||||
|
@ -702,6 +702,7 @@ void avcodec_register_all(void)
|
|||||||
REGISTER_PARSER(PNM, pnm);
|
REGISTER_PARSER(PNM, pnm);
|
||||||
REGISTER_PARSER(RV30, rv30);
|
REGISTER_PARSER(RV30, rv30);
|
||||||
REGISTER_PARSER(RV40, rv40);
|
REGISTER_PARSER(RV40, rv40);
|
||||||
|
REGISTER_PARSER(SIPR, sipr);
|
||||||
REGISTER_PARSER(TAK, tak);
|
REGISTER_PARSER(TAK, tak);
|
||||||
REGISTER_PARSER(VC1, vc1);
|
REGISTER_PARSER(VC1, vc1);
|
||||||
REGISTER_PARSER(VORBIS, vorbis);
|
REGISTER_PARSER(VORBIS, vorbis);
|
||||||
|
74
libavcodec/sipr_parser.c
Normal file
74
libavcodec/sipr_parser.c
Normal file
@ -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,
|
||||||
|
};
|
@ -28,8 +28,8 @@
|
|||||||
#include "libavutil/version.h"
|
#include "libavutil/version.h"
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 57
|
#define LIBAVCODEC_VERSION_MAJOR 57
|
||||||
#define LIBAVCODEC_VERSION_MINOR 72
|
#define LIBAVCODEC_VERSION_MINOR 73
|
||||||
#define LIBAVCODEC_VERSION_MICRO 101
|
#define LIBAVCODEC_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
LIBAVCODEC_VERSION_MINOR, \
|
LIBAVCODEC_VERSION_MINOR, \
|
||||||
|
@ -184,11 +184,13 @@ static int aa_read_header(AVFormatContext *s)
|
|||||||
st->codecpar->block_align = 19;
|
st->codecpar->block_align = 19;
|
||||||
st->codecpar->channels = 1;
|
st->codecpar->channels = 1;
|
||||||
st->codecpar->sample_rate = 8500;
|
st->codecpar->sample_rate = 8500;
|
||||||
|
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
|
||||||
} else if (!strcmp(codec_name, "acelp16")) {
|
} else if (!strcmp(codec_name, "acelp16")) {
|
||||||
st->codecpar->codec_id = AV_CODEC_ID_SIPR;
|
st->codecpar->codec_id = AV_CODEC_ID_SIPR;
|
||||||
st->codecpar->block_align = 20;
|
st->codecpar->block_align = 20;
|
||||||
st->codecpar->channels = 1;
|
st->codecpar->channels = 1;
|
||||||
st->codecpar->sample_rate = 16000;
|
st->codecpar->sample_rate = 16000;
|
||||||
|
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine, and jump to audio start offset */
|
/* determine, and jump to audio start offset */
|
||||||
|
@ -236,6 +236,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
st->codecpar->block_align = ff_sipr_subpk_size[flavor];
|
st->codecpar->block_align = ff_sipr_subpk_size[flavor];
|
||||||
|
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
|
||||||
} else {
|
} else {
|
||||||
if(sub_packet_size <= 0){
|
if(sub_packet_size <= 0){
|
||||||
av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
|
av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user