[FFmpeg-devel] [PATCH] avcodec/s302m: Check for non PCM Streams and provide a informative error message instead of noise
Michael Niedermayer
michaelni at gmx.at
Thu Jun 4 16:57:43 CEST 2015
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavcodec/s302m.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
index 7639a0f..cb10914 100644
--- a/libavcodec/s302m.c
+++ b/libavcodec/s302m.c
@@ -95,6 +95,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int block_size, ret;
+ int i, data_type;
int frame_size = s302m_parse_frame_header(avctx, buf, buf_size);
if (frame_size < 0)
@@ -123,6 +124,16 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
(ff_reverse[buf[3] & 0x0f] << 4);
buf += 7;
}
+ o = (uint32_t *)frame->data[0];
+ if (avctx->channels == 2)
+ for (i=0; i<frame->nb_samples * 2 - 6; i+=2) {
+ if (o[i] || o[i+1] || o[i+2] || o[i+3])
+ break;
+ if (o[i+4] == 0x96F87200U && o[i+5] == 0xA54E1F00) {
+ data_type = (o[i+6] >> 16) & 0x1F;
+ goto non_pcm;
+ }
+ }
} else if (avctx->bits_per_raw_sample == 20) {
uint32_t *o = (uint32_t *)frame->data[0];
for (; buf_size > 5; buf_size -= 6) {
@@ -134,6 +145,16 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
(ff_reverse[buf[3]] << 12);
buf += 6;
}
+ o = (uint32_t *)frame->data[0];
+ if (avctx->channels == 2)
+ for (i=0; i<frame->nb_samples * 2 - 6; i+=2) {
+ if (o[i] || o[i+1] || o[i+2] || o[i+3])
+ break;
+ if (o[i+4] == 0x6F872000U && o[i+5] == 0x54E1F000) {
+ data_type = (o[i+6] >> 16) & 0x1F;
+ goto non_pcm;
+ }
+ }
} else {
uint16_t *o = (uint16_t *)frame->data[0];
for (; buf_size > 4; buf_size -= 5) {
@@ -144,11 +165,24 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,
(ff_reverse[buf[2]] >> 4);
buf += 5;
}
+ o = (uint16_t *)frame->data[0];
+ if (avctx->channels == 2)
+ for (i=0; i<frame->nb_samples * 2 - 6; i+=2) {
+ if (o[i] || o[i+1] || o[i+2] || o[i+3])
+ break;
+ if (o[i+4] == 0xF872U && o[i+5] == 0x4E1F) {
+ data_type = (o[i+6] & 0x1F);
+ goto non_pcm;
+ }
+ }
}
*got_frame_ptr = 1;
return avpkt->size;
+non_pcm:
+ av_log(avctx, AV_LOG_ERROR, "S302 non PCM mode with data type %d not supported\n", data_type);
+ return AVERROR_PATCHWELCOME;
}
AVCodec ff_s302m_decoder = {
--
1.7.9.5
More information about the ffmpeg-devel
mailing list