[Mplayer-cvslog] CVS: main/libmpcodecs ad_flac.c,1.2,1.3

Dmitry Baryshkov CVS lumag at mplayerhq.hu
Mon Dec 29 19:10:51 CET 2003


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/tmp/cvs-serv463/libmpcodecs

Modified Files:
	ad_flac.c 
Log Message:
Sync to original FLAC.
Main reason from their CVS log: add support for synthesis to big-endian in plugins.



Index: ad_flac.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_flac.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ad_flac.c	16 Nov 2003 10:41:25 -0000	1.2
+++ ad_flac.c	29 Dec 2003 18:10:49 -0000	1.3
@@ -108,32 +108,19 @@
 FLAC__StreamDecoderWriteStatus flac_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
 {
 	FLAC__byte *buf = ((flac_struct_t*)(client_data))->buf;
-	int channel, sample;
 	int bps = ((flac_struct_t*)(client_data))->sh->samplesize;
+	int lowendian = (((flac_struct_t*)(client_data))->sh->sample_format == AFMT_S16_LE);
+	int unsigned_data = (((flac_struct_t*)(client_data))->sh->sample_format == AFMT_U8);
 	mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "\nWrite callback (%d bytes)!!!!\n", bps*frame->header.blocksize*frame->header.channels);
 	if (buf == NULL)
 	{
 		/* This is used in control for skipping 1 audio frame */
 		return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 	}
-#if 0
-	for (sample = 0; sample < frame->header.blocksize; sample ++)
-		for (channel = 0; channel < frame->header.channels; channel ++)
-			switch (bps)
-			{
-				case 3:
-					buf[bps*(sample*frame->header.channels+channel)+2] = (FLAC__byte)(buffer[channel][sample]>>16);
-				case 2:
-					buf[bps*(sample*frame->header.channels+channel)+1] = (FLAC__byte)(buffer[channel][sample]>>8);
-					buf[bps*(sample*frame->header.channels+channel)+0] = (FLAC__byte)(buffer[channel][sample]);
-					break;
-				case 1:
-					buf[bps*(sample*frame->header.channels+channel)] = buffer[channel][sample]^0x80;
-					break;
-			}
-#else
-	FLAC__plugin_common__apply_gain(
+	FLAC__replaygain_synthesis__apply_gain(
 				buf,
+				lowendian,
+				unsigned_data,
 				buffer,
 				frame->header.blocksize,
 				frame->header.channels,
@@ -144,7 +131,6 @@
 				dither,
 				&(((flac_struct_t*)(client_data))->dither_context)
 		);
-#endif
 	((flac_struct_t*)(client_data))->written += bps*frame->header.blocksize*frame->header.channels;
 	return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 }
@@ -238,7 +224,12 @@
 			((flac_struct_t*)client_data)->bits_per_sample = metadata->data.stream_info.bits_per_sample;
 			sh->samplesize = (metadata->data.stream_info.bits_per_sample<=8)?1:2;
 			/* FIXME: need to support dithering to samplesize 4 */
-			sh->sample_format=(sh->samplesize==1)?AFMT_U8:AFMT_S16_LE; // sample format, see libao2/afmt.h
+			sh->sample_format=(sh->samplesize==1)?AFMT_U8:
+#ifdef WORDS_BIGENDIAN
+				AFMT_S16_BE;
+#else
+				AFMT_S16_LE;
+#endif
 			sh->o_bps = sh->samplesize * metadata->data.stream_info.channels * metadata->data.stream_info.sample_rate;
 			sh->i_bps = metadata->data.stream_info.bits_per_sample * metadata->data.stream_info.channels * metadata->data.stream_info.sample_rate / 8 / 2;
 			// input data rate (compressed bytes per second)
@@ -460,7 +451,7 @@
 
 	FLAC__stream_decoder_process_until_end_of_metadata(context->flac_dec);
 
-	FLAC__plugin_common__init_dither_context(&(context->dither_context), sh_audio->samplesize * 8, noise_shaping);
+	FLAC__replaygain_synthesis__init_dither_context(&(context->dither_context), sh_audio->samplesize * 8, noise_shaping);
 	
 	return 1; // return values: 1=OK 0=ERROR
 }




More information about the MPlayer-cvslog mailing list