Commit 716ecf5a authored by Stefan Westerfeld's avatar Stefan Westerfeld

avfilter/asubprocess: verify extended wav format guid if available

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 17633ac6
......@@ -53,7 +53,7 @@ enum {
STATE_SKIP_CHUNK,
STATE_IN_DATA_CHUNK,
STATE_IN_FMT_CHUNK,
STATE_ERROR
STATE_EXT_FMT
};
typedef struct ASubProcessContext {
......@@ -287,7 +287,7 @@ static int process_input(AVFilterContext *ctx)
sample_rate = AV_RL32(data + 4);
s->out_bit_depth = AV_RL16(data + 14);
if (format != 1 && format != 0xFFFE) { // TODO: check extensible wav format: should be PCM
if (format != 1 && format != 0xFFFE) {
av_log(ctx, AV_LOG_ERROR,
"Unsupported wav format (%d) from subprocess (expected PCM).\n", format);
return AVERROR_INVALIDDATA;
......@@ -309,6 +309,23 @@ static int process_input(AVFilterContext *ctx)
return AVERROR_INVALIDDATA;
}
s->chunk_size -= 16;
if (format = 0xFFFE)
s->state = STATE_EXT_FMT;
else
s->state = STATE_SKIP_CHUNK;
}
else if (s->state == STATE_EXT_FMT && can_read >= 24) {
unsigned char data[24];
static const unsigned char pcm_fmt_guid[16] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
};
sp_read(s->sp, data, 24);
if (memcmp (data + 8, pcm_fmt, 16)) {
av_log(ctx, AV_LOG_ERROR, "Unsupported extended wav format from subprocess (expected PCM).\n");
return AVERROR_INVALIDDATA;
}
s->chunk_size -= 24;
s->state = STATE_SKIP_CHUNK;
}
else if (s->state == STATE_SKIP_CHUNK && can_read > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment