[xiph-cvs] cvs commit: vorbis-tools/oggenc/man oggenc.1

Michael Smith msmith at xiph.org
Fri Sep 28 02:51:37 PDT 2001



msmith      01/09/28 02:51:37

  Modified:    oggenc   encode.h oggenc.c
               oggenc/man oggenc.1
  Log:
  direct support for 'genre' tag based on patch from ogg at edwinm.ik.nu
  (Edwin Mons).

Revision  Changes    Path
1.12      +2 -0      vorbis-tools/oggenc/encode.h

Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- encode.h	2001/09/15 15:10:34	1.11
+++ encode.h	2001/09/28 09:51:36	1.12
@@ -47,6 +47,8 @@
         int track_count;
         char **dates;
         int date_count;
+	char **genre;
+	int genre_count;
 
         int quiet;
 

1.30      +40 -13    vorbis-tools/oggenc/oggenc.c

Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- oggenc.c	2001/09/15 15:10:34	1.29
+++ oggenc.c	2001/09/28 09:51:36	1.30
@@ -33,6 +33,7 @@
         {"artist",1,0,'a'},
         {"album",1,0,'l'},
         {"title",1,0,'t'},
+    {"genre",1,0,'G'},
         {"names",1,0,'n'},
     {"name-remove",1,0,'X'},
     {"name-replace",1,0,'P'},
@@ -55,17 +56,18 @@
         
 static char *generate_name_string(char *format, char *remove_list, 
         char *replace_list, char *artist, char *title, char *album, 
-        char *track, char *date);
+        char *track, char *date, char *genre);
 static void parse_options(int argc, char **argv, oe_options *opt);
 static void build_comments(vorbis_comment *vc, oe_options *opt, int filenum, 
-		char **artist,char **album, char **title, char **tracknum, char **date);
+		char **artist,char **album, char **title, char **tracknum, char **date,
+        char **genre);
 static void usage(void);
 
 int main(int argc, char **argv)
 {
         /* Default values */
         oe_options opt = {"ISO-8859-1", NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 
-		0, NULL, 0, 0, 0,16,44100,2, NULL,DEFAULT_NAMEFMT_REMOVE, 
+		0, NULL, 0, NULL, 0, 0, 0,16,44100,2, NULL,DEFAULT_NAMEFMT_REMOVE, 
         DEFAULT_NAMEFMT_REPLACE, NULL, -1,128,-1, -1.0f,0};
         int i;
 
@@ -120,7 +122,8 @@
                 FILE *in, *out = NULL;
                 int foundformat = 0;
                 int closeout = 0, closein = 0;
-		char *artist=NULL, *album=NULL, *title=NULL, *track=NULL, *date=NULL;
+		char *artist=NULL, *album=NULL, *title=NULL, *track=NULL;
+        char *date=NULL, *genre=NULL;
                 input_format *format;
 
                 /* Set various encoding defaults */
@@ -132,7 +135,8 @@
                 enc_opts.error = encode_error;
                 
                 /* OK, let's build the vorbis_comments structure */
-		build_comments(&vc, &opt, i, &artist, &album, &title, &track, &date);
+		build_comments(&vc, &opt, i, &artist, &album, &title, &track, 
+                &date, &genre);
 
                 if(!strcmp(infiles[i], "-"))
                 {
@@ -208,7 +212,8 @@
                         else if(opt.namefmt)
                         {
                                 out_fn = generate_name_string(opt.namefmt, opt.namefmt_remove, 
-                        opt.namefmt_replace, artist, title, album, track,date);
+                        opt.namefmt_replace, artist, title, album, track,date,
+                        genre);
                         }
                         else if(opt.title)
                         {
@@ -337,6 +342,7 @@
                 " -t, --title          Title for this track\n"
                 " -l, --album          Name of album\n"
                 " -a, --artist         Name of artist\n"
+        " -g, --genre          Genre of track\n"
                 "                      If multiple input files are given, then multiple\n"
                 "                      instances of the previous five arguments will be used,\n"
                 "                      in the order they are given. If fewer titles are\n"
@@ -400,7 +406,7 @@
 
 static char *generate_name_string(char *format, char *remove_list,
         char *replace_list, char *artist, char *title, char *album, 
-        char *track, char *date)
+        char *track, char *date, char *genre)
 {
         char *buffer;
         char next;
@@ -432,6 +438,11 @@
                                         used += strncpy_filtered(buffer+used, string, buflen-used,
                             remove_list, replace_list);
                                         break;
+                case 'g':
+                    string = genre?genre:"(none)";
+                    used += strncpy_filtered(buffer+used, string, buflen-used,
+                            remove_list, replace_list);
+                    break;
                                 case 't':
                                         string = title?title:"(none)";
                                         used += strncpy_filtered(buffer+used, string, buflen-used,
@@ -464,7 +475,7 @@
         int ret;
         int option_index = 1;
 
-	while((ret = getopt_long(argc, argv, "a:b:B:c:C:d:e:hl:m:M:n:N:o:P:q:QrR:s:t:vX:", 
+	while((ret = getopt_long(argc, argv, "a:b:B:c:C:d:e:G:hl:m:M:n:N:o:P:q:QrR:s:t:vX:", 
                                         long_options, &option_index)) != -1)
         {
                 switch(ret)
@@ -488,6 +499,14 @@
                         case 'e':
                                 opt->encoding = strdup(optarg);
                                 break;
+            case 'G':
+                opt->genre = realloc(opt->genre, (++opt->genre_count)*sizeof(char *));
+                opt->genre[opt->genre_count - 1] = strdup(optarg);
+                break;
+			case 'h':
+				usage();
+				exit(0);
+				break;
                         case 'l':
                                 opt->album = realloc(opt->album, (++opt->album_count)*sizeof(char *));
                                 opt->album[opt->album_count - 1] = strdup(optarg);
@@ -558,10 +577,6 @@
                                 }
                                 opt->outfile = strdup(optarg);
                                 break;
-			case 'h':
-				usage();
-				exit(0);
-				break;
                         case 'Q':
                                 opt->quiet = 1;
                                 break;
@@ -642,7 +657,8 @@
 }
 
 static void build_comments(vorbis_comment *vc, oe_options *opt, int filenum, 
-		char **artist, char **album, char **title, char **tracknum, char **date)
+		char **artist, char **album, char **title, char **tracknum, 
+        char **date, char **genre)
 {
         int i;
 
@@ -676,6 +692,17 @@
                 *artist = opt->artist[i];
                 add_tag(vc, opt, "artist", opt->artist[i]);
         }
+
+    if(opt->genre_count)
+    {
+        if(filenum >= opt->genre_count)
+            i = opt->genre_count-1;
+        else
+            i = filenum;
+
+        *genre = opt->genre[i];
+        add_tag(vc, opt, "genre", opt->genre[i]);
+    }
 
         if(opt->date_count)
         {

1.9       +9 -1      vorbis-tools/oggenc/man/oggenc.1

Index: oggenc.1
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/man/oggenc.1,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- oggenc.1	2001/08/13 10:55:53	1.8
+++ oggenc.1	2001/09/28 09:51:37	1.9
@@ -51,6 +51,10 @@
 .B -l
 .I album
 ]
+[
+.B -G
+.I genre
+]
 .I input_files \fR...
 
 .SH DESCRIPTION
@@ -101,7 +105,7 @@
 .I output_file (only valid if a single input file is specified)
 
 .IP "-n pattern, --names=pattern"
-Produce filenames as this string, with %a, %t, %l replaced by artist,
+Produce filenames as this string, with %a, %t, %l, %G replaced by artist,
 title, album respectively (see below for specifying these). Also, %%
 gives a literal %.
 
@@ -114,6 +118,10 @@
 .IP "-a artist, --artist artist"
 Set the artist comment field in the comments to
 .I artist.
+
+.IP "-G genre, --genre genre"
+Set the genre comment field in the comments to
+.I genre.
 
 .IP "-d date, --date date"
 Sets the date comment field to the given value. This should be the date of recording.

--- >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 'cvs-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 commits mailing list