[MPlayer-dev-eng] [PATCH] New version of info fields for MEncoder

Andriy N. Gritsenko andrej at lucky.net
Thu Aug 29 12:24:59 CEST 2002


    Hi, Arpi!

Sometime (on Wednesday, August 28 at 20:40) I've received something...
>> >     Second patch implements some avi info fields into MEncoder. These
>> > fields are: Software (MEncoder, of course :), Name, Artist, Genre,
>> > Subject, Copyright, Source, Comment. It also fixes broken RIFF header
>> > (I wonder why nobody noticed that yet) in generated avi file.
>> This isn't the right way to do it. Do not make so many non-sense variables!
>> (char *info_* and int infotype*)
>agree. and it must be a suboption thing, like -info copyright=...,title=...

    Was redone. Anyway char *info_* couldn't be removed. :)  Since
config_read_option() didn't work with spaces in info fields it was
changed a little. Now it works with option like that:

-info "name=AMV clip:copyright=EVA club"

    With best wishes.
    Andriy.
-------------- next part --------------
diff -udpr MPlayer-20020829.orig/libmpdemux/aviwrite.c MPlayer-20020829/libmpdemux/aviwrite.c
--- MPlayer-20020829.orig/libmpdemux/aviwrite.c	Mon Aug  5 14:26:26 2002
+++ MPlayer-20020829/libmpdemux/aviwrite.c	Thu Aug 29 11:35:43 2002
@@ -146,7 +146,7 @@ void aviwrite_write_header(aviwrite_t *m
       return;
 #endif
   riff[0]=mmioFOURCC('R','I','F','F');
-  riff[1]=muxer->file_end;  // filesize
+  riff[1]=muxer->file_end-2*sizeof(unsigned int);  // filesize
   riff[2]=formtypeAVI; // 'AVI '
   riff[0]=le2me_32(riff[0]);
   riff[1]=le2me_32(riff[1]);
-------------- next part --------------
diff -udpr MPlayer-20020829.orig/cfg-mencoder.h MPlayer-20020829/cfg-mencoder.h
--- MPlayer-20020829.orig/cfg-mencoder.h	Mon Aug  5 16:41:32 2002
+++ MPlayer-20020829/cfg-mencoder.h	Thu Aug 29 12:29:31 2002
@@ -93,6 +93,26 @@ struct config oac_conf[]={
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
+struct config info_conf[]={
+	{"name", &info_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"artist", &info_artist, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"genre", &info_genre, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"subject", &info_subject, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"copyright", &info_copyright, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"srcform", &info_sourceform, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"comment", &info_comment, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"help", "\nAvailable INFO fields:\n"
+	"   name      - title of the subject of the file\n"
+	"   artist    - artist or author of the original subject of the file\n"
+	"   genre     - original work category\n"
+	"   subject   - contents of the file\n"
+	"   copyright - copyright information for the file\n"
+	"   srcform   - original form of the material that was digitized\n"
+	"   comment   - general comments about the file or the subject of the file\n"
+	"\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+	{NULL, NULL, 0, 0, 0, 0, NULL}
+};
+
 static config_t mencoder_opts[]={
 	/* name, pointer, type, flags, min, max */
 	{"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, /* this must be the first!!! */
@@ -129,6 +149,9 @@ static config_t mencoder_opts[]={
 	{"vobsubout", &vobsub_out, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"vobsuboutindex", &vobsub_out_index, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
 	{"vobsuboutid", &vobsub_out_id, CONF_TYPE_STRING, 0, 0, 0, NULL},
+
+	// info header strings
+	{"info", info_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 
 #ifdef HAVE_DIVX4ENCORE
 	{"divx4opts", divx4opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
diff -udpr MPlayer-20020829.orig/cfgparser.c MPlayer-20020829/cfgparser.c
--- MPlayer-20020829.orig/cfgparser.c	Wed Aug 28 19:55:40 2002
+++ MPlayer-20020829/cfgparser.c	Thu Aug 29 13:01:16 2002
@@ -707,7 +707,7 @@ static int config_read_option(m_config_t
 			    /* clear out */
 			    subopt[0] = subparam[0] = 0;
 			    
-			    sscanf_ret = sscanf(token, "%[^=]=%s", subopt, subparam);
+			    sscanf_ret = sscanf(token, "%[^=]=%[^:]", subopt, subparam);
 
 			    mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "token: '%s', i=%d, subopt='%s', subparam='%s' (ret: %d)\n", token, i, subopt, subparam, sscanf_ret);
 			    switch(sscanf_ret)
diff -udpr MPlayer-20020829.orig/libmpdemux/aviwrite.c MPlayer-20020829/libmpdemux/aviwrite.c
--- MPlayer-20020829.orig/libmpdemux/aviwrite.c	Mon Aug  5 14:26:26 2002
+++ MPlayer-20020829/libmpdemux/aviwrite.c	Thu Aug 29 11:35:43 2002
@@ -218,6 +218,21 @@ void aviwrite_write_header(aviwrite_t *m
           le2me_WAVEFORMATEX(muxer->streams[i]->wf);
 }	  
 	  break;
+      }
+  }
+
+  // INFO:
+  hdrsize=0;
+  // calc info size:
+  for(i=0;muxer->info[i].id!=0;i++){
+      register size_t sz=strlen(muxer->info[i].text)+1;
+      hdrsize+=sz+8+sz%2;
+  }
+  // write infos:
+  if (hdrsize!=0){
+      write_avi_list(f,mmioFOURCC('I','N','F','O'),hdrsize);
+      for(i=0;muxer->info[i].id!=0;i++){
+          write_avi_chunk(f,muxer->info[i].id,strlen(muxer->info[i].text)+1,muxer->info[i].text);
       }
   }
 
diff -udpr MPlayer-20020829.orig/libmpdemux/aviwrite.h MPlayer-20020829/libmpdemux/aviwrite.h
--- MPlayer-20020829.orig/libmpdemux/aviwrite.h	Fri Apr 12 13:40:38 2002
+++ MPlayer-20020829/libmpdemux/aviwrite.h	Thu Aug 29 11:32:45 2002
@@ -26,6 +26,11 @@ typedef struct {
 } aviwrite_stream_t;
 
 typedef struct {
+  unsigned int id;
+  char *text;
+} aviwrite_info_t;
+
+typedef struct {
   // encoding:
   MainAVIHeader avih;
   unsigned int movi_start;
@@ -35,6 +40,8 @@ typedef struct {
   AVIINDEXENTRY *idx;
   int idx_pos;
   int idx_size;
+  // info list
+  aviwrite_info_t *info;
   // streams:
   //int num_streams;
   aviwrite_stream_t* def_v;  // default video stream (for general headers)
diff -udpr MPlayer-20020829.orig/mencoder.c MPlayer-20020829/mencoder.c
--- MPlayer-20020829.orig/mencoder.c	Thu Aug 29 00:32:30 2002
+++ MPlayer-20020829/mencoder.c	Thu Aug 29 12:26:38 2002
@@ -164,6 +164,15 @@ static subtitle* subtitles=NULL;
 float sub_last_pts = -303;
 #endif
 
+// infos are empty by default
+char *info_name=NULL;
+char *info_artist=NULL;
+char *info_genre=NULL;
+char *info_subject=NULL;
+char *info_copyright=NULL;
+char *info_sourceform=NULL;
+char *info_comment=NULL;
+
 
 
 //char *out_audio_codec=NULL; // override audio codec
@@ -300,6 +309,8 @@ sh_video_t *sh_video=NULL;
 int file_format=DEMUXER_TYPE_UNKNOWN;
 int i;
 void *vobsub_writer=NULL;
+aviwrite_info_t info[16]; // number of header comands is 7 plus "ISFT" and
+                        // padded 0 so it has 9 elements; let it be more...
 
 uint32_t ptimer_start;
 uint32_t audiorate=0;
@@ -578,6 +589,44 @@ if(!muxer_f) {
 }
 
 muxer=aviwrite_new_muxer();
+
+// ============= INFO ===============
+
+muxer->info=info;
+// always include software info
+info[0].id=mmioFOURCC('I','S','F','T'); // Software:
+info[0].text="MEncoder " VERSION;
+// include any optional strings
+i=1;
+if(info_name!=NULL){
+  info[i].id=mmioFOURCC('I','N','A','M'); // Name:
+  info[i++].text=info_name;
+}
+if(info_artist!=NULL){
+  info[i].id=mmioFOURCC('I','A','R','T'); // Artist:
+  info[i++].text=info_artist;
+}
+if(info_genre!=NULL){
+  info[i].id=mmioFOURCC('I','G','N','R'); // Genre:
+  info[i++].text=info_genre;
+}
+if(info_subject!=NULL){
+  info[i].id=mmioFOURCC('I','S','B','J'); // Subject:
+  info[i++].text=info_subject;
+}
+if(info_copyright!=NULL){
+  info[i].id=mmioFOURCC('I','C','O','P'); // Copyright:
+  info[i++].text=info_copyright;
+}
+if(info_sourceform!=NULL){
+  info[i].id=mmioFOURCC('I','S','R','F'); // Source Form:
+  info[i++].text=info_sourceform;
+}
+if(info_comment!=NULL){
+  info[i].id=mmioFOURCC('I','C','M','T'); // Comment:
+  info[i++].text=info_comment;
+}
+info[i].id=0;
 
 // ============= VIDEO ===============
 


More information about the MPlayer-dev-eng mailing list