Lines Matching defs:psf

85 typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ;
87 static int vorbis_read_header (SF_PRIVATE *psf) ;
88 static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ;
89 static int vorbis_close (SF_PRIVATE *psf) ;
90 static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ;
91 static int vorbis_byterate (SF_PRIVATE *psf) ;
92 static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ;
93 static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ;
94 static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ;
95 static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ;
96 static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
97 static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
98 static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
99 static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
100 static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
101 static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
102 static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
103 static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
104 static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ;
105 static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ;
149 vorbis_read_header (SF_PRIVATE *psf)
150 { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
151 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
169 { psf_log_printf (psf, "Vorbis: First packet does not have a beginning-of-stream bit.\n") ;
174 { psf_log_printf (psf, "Vorbis: First page contains extraneous packets!\n") ;
180 psf_log_printf (psf, "Found Vorbis in stream header, but vorbis_synthesis_headerin failed.\n") ;
201 { nn = ogg_stream_next_page (psf, odata) ;
203 { psf_log_printf (psf, "End of file before finding all Vorbis headers!\n") ;
207 { psf_log_printf (psf, "Error reading file while finding Vorbis headers!\n") ;
208 return psf->error ;
215 psf_log_printf (psf, "Corrupt secondary header. Exiting.\n") ;
228 psf_log_printf (psf, "Vorbis: stream has extraneous header packets.\n") ;
230 psf_log_printf (psf, "Bitstream is %d channel, %D Hz\n", vdata->vinfo.channels, vdata->vinfo.rate) ;
231 psf_log_printf (psf, "Encoded by : %s\n", vdata->vcomment.vendor) ;
234 psf->dataoffset = ogg_sync_ftell (psf) ;
243 ogg_stream_unpack_page (psf, odata) ;
244 vorbis_calculate_granulepos (psf, &vdata->pcm_start) ;
251 psf->datalength = psf->filelength ;
252 if (!psf->is_pipe)
253 { saved_offset = ogg_sync_ftell (psf) ;
254 last_page = ogg_sync_last_page_before (psf, odata, &vdata->pcm_end, psf->filelength, odata->ostream.serialno) ;
257 psf_log_printf (psf, "Ogg: Last page lacks an end-of-stream bit.\n") ;
258 psf->datalength = last_page + odata->opage.header_len + odata->opage.body_len - psf->dataoffset ;
259 if (psf->datalength + psf->dataoffset < psf->filelength)
260 psf_log_printf (psf, "Ogg: Junk after the last page.\n") ;
264 ogg_sync_fseek (psf, saved_offset, SEEK_SET) ;
267 psf_log_printf (psf, "PCM offset : %D\n", vdata->pcm_start) ;
269 psf_log_printf (psf, "PCM end : %D\n", vdata->pcm_end) ;
271 psf_log_printf (psf, "PCM end : unknown\n") ;
282 { psf_log_printf (psf, "Metadata :\n") ;
286 psf_store_string (psf, vorbis_metatypes [i].id, dd) ;
287 psf_log_printf (psf, " %-10s : %s\n", vorbis_metatypes [i].name, dd) ;
289 psf_log_printf (psf, "End\n") ;
291 psf->sf.samplerate = vdata->vinfo.rate ;
292 psf->sf.channels = vdata->vinfo.channels ;
293 psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
294 psf->sf.frames = (vdata->pcm_end != (uint64_t) -1) ? vdata->pcm_end - vdata->pcm_start : SF_COUNT_MAX ;
310 vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
312 OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
313 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
319 ret = vorbis_encode_init_vbr (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, vdata->quality) ;
322 ret = vorbis_encode_init (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) ; /* average bitrate mode */
323 ret = ( vorbis_encode_setup_managed (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1)
340 if (psf->strings.data [k].type == 0)
343 switch (psf->strings.data [k].type)
358 vorbis_comment_add_tag (&vdata->vcomment, name, psf->strings.storage + psf->strings.data [k].offset) ;
394 { ogg_write_page (psf, &odata->opage) ;
402 vorbis_close (SF_PRIVATE *psf)
403 { OGG_PRIVATE* odata = psf->container_data ;
404 VORBIS_PRIVATE *vdata = psf->codec_data ;
412 if (psf->file.mode == SFM_WRITE)
414 if (psf->write_current <= 0)
415 vorbis_write_header (psf, 0) ;
433 ogg_write_page (psf, &odata->opage) ;
456 ogg_vorbis_open (SF_PRIVATE *psf)
457 { OGG_PRIVATE* odata = psf->container_data ;
462 { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ;
467 psf->codec_data = vdata ;
469 if (psf->file.mode == SFM_RDWR)
472 psf_log_printf (psf, "Vorbis library version : %s\n", vorbis_version_string ()) ;
474 if (psf->file.mode == SFM_READ)
475 { if ((error = vorbis_read_header (psf)))
478 psf->read_short = vorbis_read_s ;
479 psf->read_int = vorbis_read_i ;
480 psf->read_float = vorbis_read_f ;
481 psf->read_double = vorbis_read_d ;
484 psf->codec_close = vorbis_close ;
485 if (psf->file.mode == SFM_WRITE)
490 psf->write_header = vorbis_write_header ;
491 psf->write_short = vorbis_write_s ;
492 psf->write_int = vorbis_write_i ;
493 psf->write_float = vorbis_write_f ;
494 psf->write_double = vorbis_write_d ;
496 psf->sf.frames = 0 ;
497 psf->datalength = 0 ;
498 psf->filelength = 0 ;
499 psf->dataoffset = 0 ;
500 psf->strings.flags = SF_STR_ALLOW_START ;
503 psf->seek = vorbis_seek ;
504 psf->command = vorbis_command ;
505 psf->byterate = vorbis_byterate ;
506 psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;
507 psf->sf.sections = 1 ;
513 vorbis_command (SF_PRIVATE *psf, int command, void * data, int datasize)
514 { OGG_PRIVATE* odata = psf->container_data ;
515 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
522 if (psf->have_written)
530 psf_log_printf (psf, "%s : Setting SFC_SET_VBR_ENCODING_QUALITY to %f.\n", __func__, vdata->quality) ;
548 vorbis_rnull (SF_PRIVATE *UNUSED (psf), int samples, void *UNUSED (vptr), int UNUSED (off) , int channels, float **UNUSED (pcm))
554 vorbis_rshort (SF_PRIVATE *psf, int samples, void *vptr, int off, int channels, float **pcm)
558 if (psf->float_int_mult)
560 float inverse = 1.0 / psf->float_max ;
575 vorbis_rint (SF_PRIVATE *psf, int samples, void *vptr, int off, int channels, float **pcm)
580 if (psf->float_int_mult)
582 float inverse = 1.0 / psf->float_max ;
597 vorbis_rfloat (SF_PRIVATE *UNUSED (psf), int samples, void *vptr, int off, int channels, float **pcm)
608 vorbis_rdouble (SF_PRIVATE *UNUSED (psf), int samples, void *vptr, int off, int channels, float **pcm)
620 vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn)
621 { VORBIS_PRIVATE *vdata = psf->codec_data ;
622 OGG_PRIVATE *odata = psf->container_data ;
626 len = lens / psf->sf.channels ;
637 i += transfn (psf, samples, ptr, i, psf->sf.channels, pcm) ;
649 nn = ogg_stream_unpack_page (psf, odata) ;
655 vorbis_calculate_granulepos (psf, &vdata->gp) ;
669 vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t lens)
670 { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rshort) ;
674 vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t lens)
675 { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rint) ;
679 vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t lens)
680 { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rfloat) ;
684 vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens)
685 { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rdouble) ;
692 vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames)
717 ogg_write_page (psf, &odata->opage) ;
732 vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens)
735 OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
736 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
737 int in_frames = lens / psf->sf.channels ;
740 for (m = 0 ; m < psf->sf.channels ; m++)
743 vorbis_write_samples (psf, odata, vdata, in_frames) ;
749 vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens)
751 OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
752 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
753 int in_frames = lens / psf->sf.channels ;
756 for (m = 0 ; m < psf->sf.channels ; m++)
759 vorbis_write_samples (psf, odata, vdata, in_frames) ;
765 vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens)
767 OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
768 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
769 int in_frames = lens / psf->sf.channels ;
772 for (m = 0 ; m < psf->sf.channels ; m++)
775 vorbis_write_samples (psf, odata, vdata, in_frames) ;
781 vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens)
783 OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
784 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
785 int in_frames = lens / psf->sf.channels ;
788 for (m = 0 ; m < psf->sf.channels ; m++)
791 vorbis_write_samples (psf, odata, vdata, in_frames) ;
797 vorbis_skip (SF_PRIVATE *psf, uint64_t target)
798 { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
799 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
823 nn = ogg_stream_unpack_page (psf, odata) ;
831 vorbis_calculate_granulepos (psf, &vdata->gp) ;
864 vorbis_read_sample (psf, (void *) NULL, (target - vdata->gp) * psf->sf.channels, vorbis_rnull) ;
870 vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp)
871 { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
872 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
883 target_gp - vdata->gp < ((unsigned) (VORBIS_SEEK_THRESHOLD) * psf->sf.samplerate))
901 ret = ogg_stream_seek_page_search (psf, odata, search_target_gp, vdata->pcm_start,
902 vdata->pcm_end, &best_gp, psf->dataoffset, vdata->last_page, vdata->vinfo.rate) ;
906 ret = ogg_stream_unpack_page (psf, odata) ;
910 ret = vorbis_calculate_granulepos (psf, &vdata->gp) ;
917 vorbis_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
918 { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
919 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
927 { psf->error = SFE_BAD_SEEK ;
931 if (psf->file.mode == SFM_READ)
934 ret = vorbis_seek_trysearch (psf, target_gp) ;
938 psf_log_printf (psf, "Vorbis: Seek search failed. Reading through stream from start.\n") ;
942 ogg_sync_fseek (psf, psf->dataoffset, SEEK_SET) ;
947 vorbis_skip (psf, target_gp) ;
952 psf->error = SFE_BAD_SEEK ;
957 vorbis_byterate (SF_PRIVATE *psf)
959 if (psf->file.mode == SFM_READ)
960 return (psf->datalength * psf->sf.samplerate) / psf->sf.frames ;
966 vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out)
967 { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ;
968 VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ;
1007 { psf_log_printf (psf, "Vorbis: Ogg page has no granule position, cannot calculate sample position!\n") ;
1008 psf->error = SFE_MALFORMED_FILE ;
1032 psf_log_printf (psf, "Vorbis: Cannot calculate ambiguous last page duration. Sample count may be wrong.\n") ;
1036 { psf_log_printf (psf, "Vorbis: Granule position is nonsensical! (Missing end-of-stream marker?)\n") ;
1037 psf->error = SFE_MALFORMED_FILE ;
1051 ogg_vorbis_open (SF_PRIVATE *psf)
1053 psf_log_printf (psf, "This version of libsndfile was compiled without Ogg/Vorbis support.\n") ;