oanastratulat

Untitled

Dec 29th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. ---
  2. libavcodec/adxdec.c | 35 ++++++++++++++++++++++++++---------
  3. 1 files changed, 26 insertions(+), 9 deletions(-)
  4.  
  5. diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
  6. index e910413..ea11db7 100644
  7. --- a/libavcodec/adxdec.c
  8. +++ b/libavcodec/adxdec.c
  9. @@ -38,16 +38,16 @@ static av_cold int adx_decode_init(AVCodecContext *avctx)
  10. ADXContext *c = avctx->priv_data;
  11. int ret, header_size;
  12.  
  13. - if (avctx->extradata_size < 24)
  14. - return AVERROR_INVALIDDATA;
  15. -
  16. - if ((ret = avpriv_adx_decode_header(avctx, avctx->extradata,
  17. - avctx->extradata_size, &header_size,
  18. - c->coeff)) < 0) {
  19. - av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");
  20. - return AVERROR_INVALIDDATA;
  21. + if (avctx->extradata_size >= 24) {
  22. + if ((ret = avpriv_adx_decode_header(avctx, avctx->extradata,
  23. + avctx->extradata_size, &header_size,
  24. + c->coeff)) < 0) {
  25. + av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");
  26. + return AVERROR_INVALIDDATA;
  27. + }
  28. + c->channels = avctx->channels;
  29. + c->header_parsed = 1;
  30. }
  31. - c->channels = avctx->channels;
  32.  
  33. avctx->sample_fmt = AV_SAMPLE_FMT_S16;
  34.  
  35. @@ -107,6 +107,23 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data,
  36. return buf_size;
  37. }
  38.  
  39. + if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) {
  40. + int header_size;
  41. + if ((ret = avpriv_adx_decode_header(avctx, buf, buf_size, &header_size,
  42. + c->coeff)) < 0) {
  43. + av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");
  44. + return AVERROR_INVALIDDATA;
  45. + }
  46. + c->channels = avctx->channels;
  47. + c->header_parsed = 1;
  48. + if (buf_size < header_size)
  49. + return AVERROR_INVALIDDATA;
  50. + buf += header_size;
  51. + buf_size -= header_size;
  52. + }
  53. + if (!c->header_parsed)
  54. + return AVERROR_INVALIDDATA;
  55. +
  56. /* calculate number of blocks in the packet */
  57. num_blocks = buf_size / (BLOCK_SIZE * c->channels);
  58.  
  59. --
Advertisement
Add Comment
Please, Sign In to add comment