diff options
author | Tom Butterworth <bangnoise@gmail.com> | 2015-07-16 13:23:21 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-16 16:04:06 +0200 |
commit | 6074956fa1d2617ac602e49931b06df0a751370e (patch) | |
tree | 930da3947df79624fcbe388ca43cd6da969b2eda /libavcodec | |
parent | 012ba786e6a72c286785530d06c8c780a2c68dd2 (diff) | |
download | ffmpeg-6074956fa1d2617ac602e49931b06df0a751370e.tar.gz |
avcodec/hap: move some per-stream setup into decoder init rather than per-frame
This change will reject frames with a texture type which doesn't match the stream description.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/hapdec.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c index e6b7d61b92..5986a3f208 100644 --- a/libavcodec/hapdec.c +++ b/libavcodec/hapdec.c @@ -78,20 +78,19 @@ static int setup_texture(AVCodecContext *avctx, size_t length) const char *compressorstr; int ret; + if ((avctx->codec_tag == MKTAG('H','a','p','1') && (ctx->section_type & 0x0F) != HAP_FMT_RGBDXT1) + || (avctx->codec_tag == MKTAG('H','a','p','5') && (ctx->section_type & 0x0F) != HAP_FMT_RGBADXT5) + || (avctx->codec_tag == MKTAG('H','a','p','Y') && (ctx->section_type & 0x0F) != HAP_FMT_YCOCGDXT5)) + return AVERROR_INVALIDDATA; + switch (ctx->section_type & 0x0F) { case HAP_FMT_RGBDXT1: - ctx->tex_rat = 8; - ctx->tex_fun = ctx->dxtc.dxt1_block; texture_name = "DXT1"; break; case HAP_FMT_RGBADXT5: - ctx->tex_rat = 16; - ctx->tex_fun = ctx->dxtc.dxt5_block; texture_name = "DXT5"; break; case HAP_FMT_YCOCGDXT5: - ctx->tex_rat = 16; - ctx->tex_fun = ctx->dxtc.dxt5ys_block; texture_name = "DXT5-YCoCg-scaled"; break; default: @@ -211,6 +210,22 @@ static av_cold int hap_init(AVCodecContext *avctx) ff_texturedsp_init(&ctx->dxtc); + switch (avctx->codec_tag) { + case MKTAG('H','a','p','1'): + ctx->tex_rat = 8; + ctx->tex_fun = ctx->dxtc.dxt1_block; + break; + case MKTAG('H','a','p','5'): + ctx->tex_rat = 16; + ctx->tex_fun = ctx->dxtc.dxt5_block; + break; + case MKTAG('H','a','p','Y'): + ctx->tex_rat = 16; + ctx->tex_fun = ctx->dxtc.dxt5ys_block; + break; + default: + return AVERROR_DECODER_NOT_FOUND; + } return 0; } |