1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * WavPack shared functions 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * This file is part of FFmpeg. 5cabdff1aSopenharmony_ci * 6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 7cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 8cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 9cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 10cabdff1aSopenharmony_ci * 11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14cabdff1aSopenharmony_ci * Lesser General Public License for more details. 15cabdff1aSopenharmony_ci * 16cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 17cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 18cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19cabdff1aSopenharmony_ci */ 20cabdff1aSopenharmony_ci 21cabdff1aSopenharmony_ci#include <stdint.h> 22cabdff1aSopenharmony_ci#include <string.h> 23cabdff1aSopenharmony_ci 24cabdff1aSopenharmony_ci#include "libavutil/error.h" 25cabdff1aSopenharmony_ci#include "libavutil/intreadwrite.h" 26cabdff1aSopenharmony_ci#include "libavutil/macros.h" 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_ci#include "wv.h" 29cabdff1aSopenharmony_ci 30cabdff1aSopenharmony_ciint ff_wv_parse_header(WvHeader *wv, const uint8_t *data) 31cabdff1aSopenharmony_ci{ 32cabdff1aSopenharmony_ci memset(wv, 0, sizeof(*wv)); 33cabdff1aSopenharmony_ci 34cabdff1aSopenharmony_ci if (AV_RL32(data) != MKTAG('w', 'v', 'p', 'k')) 35cabdff1aSopenharmony_ci return AVERROR_INVALIDDATA; 36cabdff1aSopenharmony_ci 37cabdff1aSopenharmony_ci wv->blocksize = AV_RL32(data + 4); 38cabdff1aSopenharmony_ci if (wv->blocksize < 24 || wv->blocksize > WV_BLOCK_LIMIT) 39cabdff1aSopenharmony_ci return AVERROR_INVALIDDATA; 40cabdff1aSopenharmony_ci wv->blocksize -= 24; 41cabdff1aSopenharmony_ci 42cabdff1aSopenharmony_ci wv->version = AV_RL16(data + 8); 43cabdff1aSopenharmony_ci wv->total_samples = AV_RL32(data + 12); 44cabdff1aSopenharmony_ci wv->block_idx = AV_RL32(data + 16); 45cabdff1aSopenharmony_ci wv->samples = AV_RL32(data + 20); 46cabdff1aSopenharmony_ci wv->flags = AV_RL32(data + 24); 47cabdff1aSopenharmony_ci wv->crc = AV_RL32(data + 28); 48cabdff1aSopenharmony_ci 49cabdff1aSopenharmony_ci wv->initial = !!(wv->flags & WV_FLAG_INITIAL_BLOCK); 50cabdff1aSopenharmony_ci wv->final = !!(wv->flags & WV_FLAG_FINAL_BLOCK); 51cabdff1aSopenharmony_ci 52cabdff1aSopenharmony_ci return 0; 53cabdff1aSopenharmony_ci} 54