mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-27 03:50:29 +00:00
Move wavex_ambisonic field from SF_PRIVATE struct to WAV_PRIVATE struct.
This commit is contained in:
parent
278b206a88
commit
51a552bc14
@ -22,6 +22,9 @@
|
||||
* src/common.h src/sndfile.c
|
||||
Add unique_id field to SF_PRIVATE struct.
|
||||
|
||||
* src/common.h src/sndfile.c src/wav.c src/wav_w64.[ch]
|
||||
Move wavex_ambisonic field from SF_PRIVATE struct to WAV_PRIVATE struct.
|
||||
|
||||
2008-08-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* configure.ac
|
||||
|
@ -350,9 +350,6 @@ typedef struct sf_private_tag
|
||||
|
||||
int ieee_replace ;
|
||||
|
||||
/* For ambisonic commands */
|
||||
int wavex_ambisonic ;
|
||||
|
||||
/* A set of file specific function pointers */
|
||||
sf_count_t (*read_short) (struct sf_private_tag*, short *ptr, sf_count_t len) ;
|
||||
sf_count_t (*read_int) (struct sf_private_tag*, int *ptr, sf_count_t len) ;
|
||||
|
@ -2463,11 +2463,6 @@ psf_open_file (SF_PRIVATE *psf, int mode, SF_INFO *sfinfo)
|
||||
/* An attempt at a per SF_PRIVATE unique id. */
|
||||
psf->unique_id = psf_rand_int32 () ;
|
||||
|
||||
/*
|
||||
** File formats that support ambisonic should override this default
|
||||
** and set it to SF_AMBISONIC_NONE.
|
||||
*/
|
||||
psf->wavex_ambisonic = 0 ;
|
||||
psf->sf.sections = 1 ;
|
||||
|
||||
psf->is_pipe = psf_is_pipe (psf) ;
|
||||
|
30
src/wav.c
30
src/wav.c
@ -184,7 +184,7 @@ wav_open (SF_PRIVATE *psf)
|
||||
return SFE_MALLOC_FAILED ;
|
||||
psf->container_data = wpriv ;
|
||||
|
||||
psf->wavex_ambisonic = SF_AMBISONIC_NONE ;
|
||||
wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
|
||||
psf->str_flags = SF_STR_ALLOW_START | SF_STR_ALLOW_END ;
|
||||
|
||||
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
|
||||
@ -198,7 +198,7 @@ wav_open (SF_PRIVATE *psf)
|
||||
{ if (psf->is_pipe)
|
||||
return SFE_NO_PIPE_WRITE ;
|
||||
|
||||
psf->wavex_ambisonic = SF_AMBISONIC_NONE ;
|
||||
wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
|
||||
|
||||
format = psf->sf.format & SF_FORMAT_TYPEMASK ;
|
||||
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX)
|
||||
@ -969,9 +969,13 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
|
||||
static int
|
||||
wavex_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
{ sf_count_t current ;
|
||||
{ WAV_PRIVATE *wpriv ;
|
||||
sf_count_t current ;
|
||||
int fmt_size, k, subformat, add_fact_chunk = SF_FALSE, has_data = SF_FALSE ;
|
||||
|
||||
if ((wpriv = psf->container_data) == NULL)
|
||||
return SFE_INTERNAL ;
|
||||
|
||||
current = psf_ftell (psf) ;
|
||||
|
||||
if (current > psf->dataoffset)
|
||||
@ -1048,7 +1052,7 @@ wavex_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
/* For an Ambisonic file set the channel mask to zero.
|
||||
** Otherwise use a default based on the channel count.
|
||||
*/
|
||||
if (psf->wavex_ambisonic != SF_AMBISONIC_NONE)
|
||||
if (wpriv->wavex_ambisonic != SF_AMBISONIC_NONE)
|
||||
psf_binheader_writef (psf, "4", 0) ;
|
||||
else
|
||||
{ /*
|
||||
@ -1096,13 +1100,13 @@ wavex_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
case SF_FORMAT_PCM_16 :
|
||||
case SF_FORMAT_PCM_24 :
|
||||
case SF_FORMAT_PCM_32 :
|
||||
wavex_write_guid (psf, psf->wavex_ambisonic == SF_AMBISONIC_NONE ?
|
||||
wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
|
||||
&MSGUID_SUBTYPE_PCM : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM) ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_FLOAT :
|
||||
case SF_FORMAT_DOUBLE :
|
||||
wavex_write_guid (psf, psf->wavex_ambisonic == SF_AMBISONIC_NONE ?
|
||||
wavex_write_guid (psf, wpriv->wavex_ambisonic == SF_AMBISONIC_NONE ?
|
||||
&MSGUID_SUBTYPE_IEEE_FLOAT : &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT) ;
|
||||
add_fact_chunk = SF_TRUE ;
|
||||
break ;
|
||||
@ -1249,21 +1253,25 @@ wav_close (SF_PRIVATE *psf)
|
||||
|
||||
static int
|
||||
wav_command (SF_PRIVATE *psf, int command, void * UNUSED (data), int datasize)
|
||||
{
|
||||
{ WAV_PRIVATE *wpriv ;
|
||||
|
||||
if ((wpriv = psf->container_data) == NULL)
|
||||
return SFE_INTERNAL ;
|
||||
|
||||
switch (command)
|
||||
{ case SFC_WAVEX_SET_AMBISONIC :
|
||||
if ((psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAVEX)
|
||||
{ if (datasize == SF_AMBISONIC_NONE)
|
||||
psf->wavex_ambisonic = SF_AMBISONIC_NONE ;
|
||||
wpriv->wavex_ambisonic = SF_AMBISONIC_NONE ;
|
||||
else if (datasize == SF_AMBISONIC_B_FORMAT)
|
||||
psf->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
|
||||
wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
|
||||
else
|
||||
return 0 ;
|
||||
} ;
|
||||
return psf->wavex_ambisonic ;
|
||||
return wpriv->wavex_ambisonic ;
|
||||
|
||||
case SFC_WAVEX_GET_AMBISONIC :
|
||||
return psf->wavex_ambisonic ;
|
||||
return wpriv->wavex_ambisonic ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
|
@ -313,12 +313,12 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize)
|
||||
else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_PCM))
|
||||
{ psf->sf.format = SF_FORMAT_WAVEX | u_bitwidth_to_subformat (psf->bytewidth * 8) ;
|
||||
psf_log_printf (psf, " format : pcm (Ambisonic B)\n") ;
|
||||
psf->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
|
||||
wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
|
||||
}
|
||||
else if (wavex_guid_equal (&wav_fmt->ext.esf, &MSGUID_SUBTYPE_AMBISONIC_B_FORMAT_IEEE_FLOAT))
|
||||
{ psf->sf.format = SF_FORMAT_WAVEX | ((psf->bytewidth == 8) ? SF_FORMAT_DOUBLE : SF_FORMAT_FLOAT) ;
|
||||
psf_log_printf (psf, " format : IEEE float (Ambisonic B)\n") ;
|
||||
psf->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
|
||||
wpriv->wavex_ambisonic = SF_AMBISONIC_B_FORMAT ;
|
||||
}
|
||||
else
|
||||
return SFE_UNIMPLEMENTED ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 1999-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
** Copyright (C) 1999-2008 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
|
||||
@ -257,7 +257,10 @@ typedef struct
|
||||
} FACT_CHUNK ;
|
||||
|
||||
typedef struct
|
||||
{ /* Set to true when 'fmt ' chunk is ambiguous.*/
|
||||
{ /* For ambisonic commands */
|
||||
int wavex_ambisonic ;
|
||||
|
||||
/* Set to true when 'fmt ' chunk is ambiguous.*/
|
||||
int fmt_is_broken ;
|
||||
WAV_FMT wav_fmt ;
|
||||
} WAV_PRIVATE ;
|
||||
|
Loading…
Reference in New Issue
Block a user