mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Refactor common code into src/common.h.
This commit is contained in:
parent
6cd40d4776
commit
5c66353175
@ -1,3 +1,8 @@
|
||||
2012-01-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/aiff.c src/wav.c src/common.h
|
||||
Refactor common code into src/common.h.
|
||||
|
||||
2012-01-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* programs/sndfile-cmp.c
|
||||
|
19
src/aiff.c
19
src/aiff.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2005 David Viens <davidv@plogue.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
@ -1750,20 +1750,9 @@ aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword)
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static int
|
||||
aiff_id_to_marker (const SF_CHUNK_INFO * chunk_info)
|
||||
{ const unsigned char * cptr ;
|
||||
|
||||
if (chunk_info->id_size != 4)
|
||||
return 0 ;
|
||||
|
||||
cptr = (const unsigned char *) chunk_info->id ;
|
||||
return (cptr [3] << 24) + (cptr [2] << 16) + (cptr [1] << 8) + cptr [0] ;
|
||||
} /* aiff_id_to_marker */
|
||||
|
||||
static int
|
||||
aiff_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info)
|
||||
{ int marker = aiff_id_to_marker (chunk_info) ;
|
||||
{ int marker = fourcc_to_marker (chunk_info) ;
|
||||
|
||||
return psf_save_write_chunk (&psf->wchunks, marker, chunk_info) ;
|
||||
} /* aiff_set_chunk */
|
||||
@ -1771,7 +1760,7 @@ aiff_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info)
|
||||
|
||||
static int
|
||||
aiff_get_chunk_size (SF_PRIVATE *psf, SF_CHUNK_INFO * chunk_info)
|
||||
{ int indx, marker = aiff_id_to_marker (chunk_info) ;
|
||||
{ int indx, marker = fourcc_to_marker (chunk_info) ;
|
||||
|
||||
if ((indx = psf_find_read_chunk (&psf->rchunks, marker)) < 0)
|
||||
return SFE_UNKNOWN_CHUNK ;
|
||||
@ -1783,7 +1772,7 @@ aiff_get_chunk_size (SF_PRIVATE *psf, SF_CHUNK_INFO * chunk_info)
|
||||
|
||||
static int
|
||||
aiff_get_chunk_data (SF_PRIVATE *psf, SF_CHUNK_INFO * chunk_info)
|
||||
{ int indx, marker = aiff_id_to_marker (chunk_info) ;
|
||||
{ int indx, marker = fourcc_to_marker (chunk_info) ;
|
||||
sf_count_t pos ;
|
||||
|
||||
if ((indx = psf_find_read_chunk (&psf->rchunks, marker)) < 0)
|
||||
|
13
src/common.h
13
src/common.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -866,6 +866,17 @@ int psf_save_write_chunk (WRITE_CHUNKS * pchk, int64_t marker, const SF_CHUNK_I
|
||||
int psf_find_read_chunk (READ_CHUNKS * pchk, int64_t marker) ;
|
||||
int psf_find_write_chunk (WRITE_CHUNKS * pchk, int64_t marker) ;
|
||||
|
||||
static inline int
|
||||
fourcc_to_marker (const SF_CHUNK_INFO * chunk_info)
|
||||
{ const unsigned char * cptr ;
|
||||
|
||||
if (chunk_info->id_size != 4)
|
||||
return 0 ;
|
||||
|
||||
cptr = (const unsigned char *) chunk_info->id ;
|
||||
return (cptr [3] << 24) + (cptr [2] << 16) + (cptr [1] << 8) + cptr [0] ;
|
||||
} /* fourcc_to_marker */
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
** Functions that work like OpenBSD's strlcpy/strlcat to replace strncpy/strncat.
|
||||
**
|
||||
|
19
src/wav.c
19
src/wav.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 2004-2005 David Viens <davidv@plogue.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
@ -1829,20 +1829,9 @@ exif_subchunk_parse (SF_PRIVATE *psf, unsigned int length)
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static int
|
||||
wav_id_to_marker (const SF_CHUNK_INFO * chunk_info)
|
||||
{ const unsigned char * cptr ;
|
||||
|
||||
if (chunk_info->id_size != 4)
|
||||
return 0 ;
|
||||
|
||||
cptr = (const unsigned char *) chunk_info->id ;
|
||||
return (cptr [3] << 24) + (cptr [2] << 16) + (cptr [1] << 8) + cptr [0] ;
|
||||
} /* wav_id_to_marker */
|
||||
|
||||
static int
|
||||
wav_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info)
|
||||
{ int marker = wav_id_to_marker (chunk_info) ;
|
||||
{ int marker = fourcc_to_marker (chunk_info) ;
|
||||
|
||||
return psf_save_write_chunk (&psf->wchunks, marker, chunk_info) ;
|
||||
} /* wav_set_chunk */
|
||||
@ -1850,7 +1839,7 @@ wav_set_chunk (SF_PRIVATE *psf, const SF_CHUNK_INFO * chunk_info)
|
||||
|
||||
static int
|
||||
wav_get_chunk_size (SF_PRIVATE *psf, SF_CHUNK_INFO * chunk_info)
|
||||
{ int indx, marker = wav_id_to_marker (chunk_info) ;
|
||||
{ int indx, marker = fourcc_to_marker (chunk_info) ;
|
||||
|
||||
if ((indx = psf_find_read_chunk (&psf->rchunks, marker)) < 0)
|
||||
return SFE_UNKNOWN_CHUNK ;
|
||||
@ -1862,7 +1851,7 @@ wav_get_chunk_size (SF_PRIVATE *psf, SF_CHUNK_INFO * chunk_info)
|
||||
|
||||
static int
|
||||
wav_get_chunk_data (SF_PRIVATE *psf, SF_CHUNK_INFO * chunk_info)
|
||||
{ int indx, marker = wav_id_to_marker (chunk_info) ;
|
||||
{ int indx, marker = fourcc_to_marker (chunk_info) ;
|
||||
sf_count_t pos ;
|
||||
|
||||
if ((indx = psf_find_read_chunk (&psf->rchunks, marker)) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user