shithub: opus-tools

Download patch

ref: e8aee6d13da187ec4d016a7b5214db1c86bdb064
parent: ef79f7a337d7081ac2f6fc3d25db19dd27635b20
author: Gregory Maxwell <greg@xiph.org>
date: Fri Jan 24 11:17:34 EST 2014

Make discard-comments discard album art, also add a discard-pictures.

Discarding the art is a special case because its often huge relative to the
 opus files.

Thanks for bitingsock on IRC for the report.

--- a/man/opusenc.1
+++ b/man/opusenc.1
@@ -73,6 +73,8 @@
 ] [
 .B --discard-comments
 ] [
+.B --discard-pictures
+] [
 .B --raw
 ] [
 .B --raw-bits
@@ -298,6 +300,8 @@
 efficient. Defaults to 512.
 .IP "--discard-comments"
 Don't propagate metadata tags from the input file.
+.IP "--discard-pictures"
+Don't propagate pictures or art from the input file.
 
 .IP "--raw"
 Raw (headerless) PCM input
--- a/src/flac.c
+++ b/src/flac.c
@@ -197,6 +197,7 @@
         size_t buf_sz;
         size_t b64_sz;
         size_t offs;
+        if(!inopt->copy_pictures)break;
         mime_type_length=strlen(metadata->data.picture.mime_type);
         description_length=strlen((char *)metadata->data.picture.description);
         buf_sz=32+mime_type_length+description_length
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -221,6 +221,7 @@
   printf("                      imported, or the URL if the MIME-TYPE is -->.\n");
   printf(" --padding n        Extra bytes to reserve for metadata (default: 512)\n");
   printf(" --discard-comments Don't keep metadata when transcoding\n");
+  printf(" --discard-pictures Don't keep pictures when transcoding\n");
   printf("\nInput options:\n");
   printf(" --raw              Raw input\n");
   printf(" --raw-bits n       Set bits/sample for raw input (default: 16)\n");
@@ -285,6 +286,7 @@
     {"picture", required_argument, NULL, 0},
     {"padding", required_argument, NULL, 0},
     {"discard-comments", no_argument, NULL, 0},
+    {"discard-pictures", no_argument, NULL, 0},
     {0, 0, 0, 0}
   };
   int i, ret;
@@ -377,6 +379,7 @@
   inopt.rawmode=0;
   inopt.ignorelength=0;
   inopt.copy_comments=1;
+  inopt.copy_pictures=1;
 
   start_time = time(NULL);
   srand(((getpid()&65535)<<15)^start_time);
@@ -567,6 +570,9 @@
           comment_padding=atoi(optarg);
         } else if(strcmp(long_options[option_index].name,"discard-comments")==0){
           inopt.copy_comments=0;
+          inopt.copy_pictures=0;
+        } else if(strcmp(long_options[option_index].name,"discard-pictures")==0){
+          inopt.copy_pictures=0;
         }
         /*Commands whos arguments would leak file paths or just end up as metadata
            should have save_cmd=0; to prevent them from being saved in the
--- a/src/opusenc.h
+++ b/src/opusenc.h
@@ -38,6 +38,7 @@
     char *comments;
     int comments_length;
     int copy_comments;
+    int copy_pictures;
 } oe_enc_opt;
 
 void setup_scaler(oe_enc_opt *opt, float scale);