[vorbis-dev] Some new code for Ogg Drop

Lars Brubaker LarsBB at reflexive.net
Tue Dec 26 14:11:59 PST 2000



Some new code for Ogg Drop

> Lars Brubaker wrote:
> >
> > Is there any particular person in charge of ogg drop.
> >
> > It would be nice if when compressing 1 channel audio it would
> 1/2 the sample
> > rate that is requested.
> >
> > It would also be great if one could set the output sample rate.
> >
> > Bit Rate >
> >         ...
> > Sample Rate >
> >         Same As Source (default)
> >         44050
> >         22025
> >         (I don't know what other rates vorbis supports)
> > Num Channels >
> >         Same As Source (default)
> >         2
> >         1
> >
> > I would love to write these things but I don't want to spend
> the time if it
> > won't be of help to the maintainer of this utility.
> >
> > Lars.
> >
>
> I would like this too, particullarly the automatic half-rating on mono.
>
> --
> Beni Cherniavsky <cben at crosswinds.net>
>                  (also scben at t2,cben at tx in Technion)

Here is the first pass of some changes to ogg drop.  This does the halving
of the bit rate when the input is mono and it also prevents adding a file
that is already in the list to the list of files to be decompressed.

Lars Brubaker.

cvs diff encthread.c (in directory C:\Code\Vorbis\win32-tools\oggdrop\)
Index: encthread.c
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/encthread.c,v
retrieving revision 1.2
diff -r1.2 encthread.c
0a1
>
//**************************************************************************
*******************************************
5a7
>
//**************************************************************************
*******************************************
11a14
>
//**************************************************************************
*******************************************
29a33
>
//**************************************************************************
*******************************************
31a36
>
//**************************************************************************
*******************************************
34c39
< 	int thread_id;

---
> 	unsigned long thread_id;
48a54,57
>
//**************************************************************************
*******************************************
> static char* pCurrentDecopressingFileName = NULL;
>
>
//**************************************************************************
*******************************************
52a62,67
> 	enclist_t *pNext;
>
> 	if(file == NULL)
> 	{
> 		return;
> 	}
54c69,88
< 	if (file == NULL) return;
---
> 	// let's see if the file is already being decompressed.  If it
> 	// is let's not put it in the list again.
> 	if(pCurrentDecopressingFileName && strcmp(pCurrentDecopressingFileName,
file) == 0)
> 	{
> 		// we are adding a file that is in the list (and is the one being
decompressed).
> 		return;
> 	}
>
> 	pNext = head;
> 	while(pNext)
> 	{
> 		if(strcmp(pNext->filename, file) == 0)
> 		{
> 			// don't add the file it's already in the list.
> 			return;
> 		}
>
> 		// move on to the next file in the list.
> 		pNext = pNext->next;
> 	}
82a117
>
//**************************************************************************
*******************************************
107a143
>
//**************************************************************************
*******************************************
112a149
>
//**************************************************************************
*******************************************
117a155
>
//**************************************************************************
*******************************************
122a161
>
//**************************************************************************
*******************************************
127a167
>
//**************************************************************************
*******************************************
132a173
>
//**************************************************************************
*******************************************
135d175
< 	char *in_file;
145,146c185,188
< 	while (!encoding_done) {
< 		while (in_file = _getfile()) {
---
> 	while (!encoding_done)
> 	{
> 		while(pCurrentDecopressingFileName = _getfile())
> 		{
165c207
< 			in = fopen(in_file, "rb");
---
> 			in = fopen(pCurrentDecopressingFileName, "rb");
167c209,210
< 			if (in == NULL) {
---
> 			if (in == NULL)
> 			{
173c216,217
< 			if (out == NULL) {
---
> 			if (out == NULL)
> 			{
177,179c221,223
< 				start = in_file;
< 				end = rindex(in_file, '.');
< 				end = end?end:(start + strlen(in_file)+1);
---
> 				start = pCurrentDecopressingFileName;
> 				end = rindex(pCurrentDecopressingFileName, '.');
> 				end = end?end:(start + strlen(pCurrentDecopressingFileName)+1);
198c242
< 				_snprintf(buf, 1024, "Format not supported!  Skipping file %s...",
in_file);
---
> 				_snprintf(buf, 1024, "Format not supported!  Skipping file %s...",
pCurrentDecopressingFileName);
216c260,269
< 			enc_opts.bitrate = opt.kbps; /* defaulted at the start, so this is ok
*/
---
> 			if(enc_opts.channels > 1)
> 			{
> 				/* defaulted at the start, so this is ok */
> 				enc_opts.bitrate = opt.kbps;
> 			}
> 			else
> 			{
> 				// it's only one chanel 1/2 the output bit rate
> 				enc_opts.bitrate = opt.kbps/2;
> 			}
219a273
> 			{
220a275
> 			}
229a285
> 			pCurrentDecopressingFileName = NULL;
247a304,305
>
>
//**************************************************************************
*******************************************

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Vorbis-dev mailing list