Commit f766f3c8 authored by John Koleszar's avatar John Koleszar
Browse files

dixie: simple validation of the frame header

Change-Id: Iae8c2d421eb686d652807d44d8053eaec8f72897
parent 5c263fa3
No related merge requests found
Showing with 67 additions and 2 deletions
...@@ -11,6 +11,35 @@ ...@@ -11,6 +11,35 @@
#include "bit_ops.h" #include "bit_ops.h"
#include "dixie.h" #include "dixie.h"
void
decode_frame(struct vp8_decoder_ctx *ctx,
const unsigned char *data,
unsigned int sz)
{
vpx_codec_err_t res;
if ((res = vp8_parse_frame_header(data, sz, &ctx->frame_hdr)))
vpx_internal_error(&ctx->error, res, "Failed to parse frame header");
if (ctx->frame_hdr.is_experimental)
vpx_internal_error(&ctx->error, VPX_CODEC_UNSUP_BITSTREAM,
"Experimental bitstreams not supported.");
if (ctx->frame_hdr.version != 0)
vpx_internal_error(&ctx->error, VPX_CODEC_UNSUP_BITSTREAM,
"Unsupported version %d", ctx->frame_hdr.version);
if (ctx->frame_hdr.is_keyframe)
if (ctx->frame_hdr.kf.scale_w || ctx->frame_hdr.kf.scale_h)
vpx_internal_error(&ctx->error, VPX_CODEC_UNSUP_BITSTREAM,
"Spatial resampling not supported.");
}
vpx_codec_err_t vpx_codec_err_t
vp8_parse_frame_header(const unsigned char *data, vp8_parse_frame_header(const unsigned char *data,
unsigned int sz, unsigned int sz,
...@@ -52,3 +81,20 @@ vp8_parse_frame_header(const unsigned char *data, ...@@ -52,3 +81,20 @@ vp8_parse_frame_header(const unsigned char *data,
return VPX_CODEC_OK; return VPX_CODEC_OK;
} }
vpx_codec_err_t
vp8_dixie_decode_frame(struct vp8_decoder_ctx *ctx,
const unsigned char *data,
unsigned int sz)
{
volatile struct vp8_decoder_ctx *ctx_ = ctx;
ctx->error.error_code = VPX_CODEC_OK;
ctx->error.has_detail = 0;
if (!setjmp(ctx->error.jmp))
decode_frame(ctx, data, sz);
return ctx_->error.error_code;
}
...@@ -27,9 +27,25 @@ struct vp8_frame_hdr ...@@ -27,9 +27,25 @@ struct vp8_frame_hdr
} kf; } kf;
}; };
struct vp8_decoder_ctx
{
struct vpx_internal_error_info error;
struct vp8_frame_hdr frame_hdr;
};
vpx_codec_err_t vpx_codec_err_t
vp8_parse_frame_header(const unsigned char *data, vp8_parse_frame_header(const unsigned char *data,
unsigned int sz, unsigned int sz,
struct vp8_frame_hdr *hdr); struct vp8_frame_hdr *hdr);
vpx_codec_err_t
vp8_dixie_decode_frame(struct vp8_decoder_ctx *ctx,
const unsigned char *data,
unsigned int sz);
#endif #endif
...@@ -25,6 +25,7 @@ struct vpx_codec_alg_priv ...@@ -25,6 +25,7 @@ struct vpx_codec_alg_priv
vpx_codec_priv_t base; vpx_codec_priv_t base;
vpx_codec_dec_cfg_t cfg; vpx_codec_dec_cfg_t cfg;
vp8_stream_info_t si; vp8_stream_info_t si;
struct vp8_decoder_ctx decoder_ctx;
vpx_image_t img; vpx_image_t img;
int img_setup; int img_setup;
int img_avail; int img_avail;
...@@ -142,9 +143,11 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, ...@@ -142,9 +143,11 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
{ {
vpx_codec_err_t res = VPX_CODEC_OK; vpx_codec_err_t res = VPX_CODEC_OK;
ctx->img_avail = 0; res = vp8_dixie_decode_frame(&ctx->decoder_ctx, data, data_sz);
if(res)
update_error_state(ctx, &ctx->decoder_ctx.error);
ctx->img_avail = 0;
return res; return res;
} }
......
Supports Markdown
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