Fixes #2056.
Unified · Split
| @@ -943,6 +943,7 @@ OBJS-$(CONFIG_PNG_PARSER) += png_parser.o · 942 unmodified lines | ||
| 943 | 943 | OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o |
| 944 | 944 | OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o |
| 945 | 945 | OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o |
| 946 | +OBJS-$(CONFIG_SIPR_PARSER) += sipr_parser.o | |
| 946 | 947 | OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o |
| 947 | 948 | OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \ |
| 948 | 949 | simple_idct.o wmv2data.o |
| @@ -702,6 +702,7 @@ void avcodec_register_all(void) · 701 unmodified lines | ||
| 702 | 702 | REGISTER_PARSER(PNM, pnm); |
| 703 | 703 | REGISTER_PARSER(RV30, rv30); |
| 704 | 704 | REGISTER_PARSER(RV40, rv40); |
| 705 | + REGISTER_PARSER(SIPR, sipr); | |
| 705 | 706 | REGISTER_PARSER(TAK, tak); |
| 706 | 707 | REGISTER_PARSER(VC1, vc1); |
| 707 | 708 | REGISTER_PARSER(VORBIS, vorbis); |
| @@ -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 | +}; | |
| @@ -28,8 +28,8 @@ · 27 unmodified lines | ||
| 28 | 28 | #include "libavutil/version.h" |
| 29 | 29 | |
| 30 | 30 | #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 | |
| 33 | 33 | |
| 34 | 34 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 35 | 35 | LIBAVCODEC_VERSION_MINOR, \ |
| @@ -184,11 +184,13 @@ static int aa_read_header(AVFormatContext *s) · 183 unmodified lines | ||
| 184 | 184 | st->codecpar->block_align = 19; |
| 185 | 185 | st->codecpar->channels = 1; |
| 186 | 186 | st->codecpar->sample_rate = 8500; |
| 187 | + st->need_parsing = AVSTREAM_PARSE_FULL_RAW; | |
| 187 | 188 | } else if (!strcmp(codec_name, "acelp16")) { |
| 188 | 189 | st->codecpar->codec_id = AV_CODEC_ID_SIPR; |
| 189 | 190 | st->codecpar->block_align = 20; |
| 190 | 191 | st->codecpar->channels = 1; |
| 191 | 192 | st->codecpar->sample_rate = 16000; |
| 193 | + st->need_parsing = AVSTREAM_PARSE_FULL_RAW; | |
| 192 | 194 | } |
| 193 | 195 | |
| 194 | 196 | /* determine, and jump to audio start offset */ |
| @@ -236,6 +236,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, · 235 unmodified lines | ||
| 236 | 236 | return -1; |
| 237 | 237 | } |
| 238 | 238 | st->codecpar->block_align = ff_sipr_subpk_size[flavor]; |
| 239 | + st->need_parsing = AVSTREAM_PARSE_FULL_RAW; | |
| 239 | 240 | } else { |
| 240 | 241 | if(sub_packet_size <= 0){ |
| 241 | 242 | av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n"); |