metadata.c
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:3k
源码类别:

Windows CE

开发平台:

C/C++

  1. ////////////////////////////////////////////////////////////////////////////
  2. //                           **** WAVPACK ****                            //
  3. //                  Hybrid Lossless Wavefile Compressor                   //
  4. //              Copyright (c) 1998 - 2003 Conifer Software.               //
  5. //                          All Rights Reserved.                          //
  6. //      Distributed under the BSD Software License (see license.txt)      //
  7. ////////////////////////////////////////////////////////////////////////////
  8. // metadata.c
  9. // This module handles the metadata structure introduced in WavPack 4.0
  10. #include "wavpack.h"
  11. int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd)
  12. {
  13.     uchar tchar;
  14.     if (!wpc->infile (&wpmd->id, 1, wpc->privdata) || !wpc->infile (&tchar, 1, wpc->privdata))
  15. return FALSE;
  16.     wpmd->byte_length = tchar << 1;
  17.     if (wpmd->id & ID_LARGE) {
  18. wpmd->id &= ~ID_LARGE;
  19. if (!wpc->infile (&tchar, 1, wpc->privdata))
  20.     return FALSE;
  21. wpmd->byte_length += (long) tchar << 9; 
  22. if (!wpc->infile (&tchar, 1, wpc->privdata))
  23.     return FALSE;
  24. wpmd->byte_length += (long) tchar << 17;
  25.     }
  26.     if (wpmd->id & ID_ODD_SIZE) {
  27. wpmd->id &= ~ID_ODD_SIZE;
  28. wpmd->byte_length--;
  29.     }
  30.     if (wpmd->byte_length && wpmd->byte_length <= sizeof (wpc->read_buffer)) {
  31. ulong bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1);
  32. if (wpc->infile (wpc->read_buffer, bytes_to_read, wpc->privdata) != (long) bytes_to_read) {
  33.     wpmd->data = NULL;
  34.     return FALSE;
  35. }
  36. wpmd->data = wpc->read_buffer;
  37.     }
  38.     else
  39. wpmd->data = NULL;
  40.     return TRUE;
  41. }
  42. int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
  43. {
  44.     WavpackStream *wps = &wpc->stream;
  45.     switch (wpmd->id) {
  46. case ID_DUMMY:
  47.     return TRUE;
  48. case ID_DECORR_TERMS:
  49.     return read_decorr_terms (wps, wpmd);
  50. case ID_DECORR_WEIGHTS:
  51.     return read_decorr_weights (wps, wpmd);
  52. case ID_DECORR_SAMPLES:
  53.     return read_decorr_samples (wps, wpmd);
  54. case ID_ENTROPY_VARS:
  55.     return read_entropy_vars (wps, wpmd);
  56. case ID_HYBRID_PROFILE:
  57.     return read_hybrid_profile (wps, wpmd);
  58. case ID_FLOAT_INFO:
  59.     return read_float_info (wps, wpmd);
  60. case ID_INT32_INFO:
  61.     return read_int32_info (wps, wpmd);
  62. case ID_CHANNEL_INFO:
  63.     return read_channel_info (wpc, wpmd);
  64. case ID_CONFIG_BLOCK:
  65.     return read_config_info (wpc, wpmd);
  66. case ID_WV_BITSTREAM:
  67.     return init_wv_bitstream (wpc, wpmd);
  68. case ID_SHAPING_WEIGHTS:
  69. case ID_WVC_BITSTREAM:
  70. case ID_WVX_BITSTREAM:
  71.     return TRUE;
  72. default:
  73.     return (wpmd->id & ID_OPTIONAL_DATA) ? TRUE : FALSE;
  74.     }
  75. }