Browse code

Factorize: opt_{audio,video,subtitle}_tag() -> opt_codec_tag().

Originally committed as revision 25596 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini authored on 2010/10/28 22:20:26
Showing 1 changed files
... ...
@@ -2819,24 +2819,6 @@ static void opt_audio_codec(const char *arg)
2819 2819
     opt_codec(&audio_stream_copy, &audio_codec_name, AVMEDIA_TYPE_AUDIO, arg);
2820 2820
 }
2821 2821
 
2822
-static void opt_audio_tag(const char *arg)
2823
-{
2824
-    char *tail;
2825
-    audio_codec_tag= strtol(arg, &tail, 0);
2826
-
2827
-    if(!tail || *tail)
2828
-        audio_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
2829
-}
2830
-
2831
-static void opt_video_tag(const char *arg)
2832
-{
2833
-    char *tail;
2834
-    video_codec_tag= strtol(arg, &tail, 0);
2835
-
2836
-    if(!tail || *tail)
2837
-        video_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
2838
-}
2839
-
2840 2822
 static void opt_video_codec(const char *arg)
2841 2823
 {
2842 2824
     opt_codec(&video_stream_copy, &video_codec_name, AVMEDIA_TYPE_VIDEO, arg);
... ...
@@ -2847,13 +2829,18 @@ static void opt_subtitle_codec(const char *arg)
2847 2847
     opt_codec(&subtitle_stream_copy, &subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, arg);
2848 2848
 }
2849 2849
 
2850
-static void opt_subtitle_tag(const char *arg)
2850
+static void opt_codec_tag(const char *opt, const char *arg)
2851 2851
 {
2852 2852
     char *tail;
2853
-    subtitle_codec_tag= strtol(arg, &tail, 0);
2853
+    uint32_t *codec_tag;
2854
+
2855
+    codec_tag = !strcmp(opt, "atag") ? &audio_codec_tag :
2856
+                !strcmp(opt, "vtag") ? &video_codec_tag :
2857
+                !strcmp(opt, "stag") ? &subtitle_codec_tag : NULL;
2854 2858
 
2855
-    if(!tail || *tail)
2856
-        subtitle_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
2859
+    *codec_tag = strtol(arg, &tail, 0);
2860
+    if (!tail || *tail)
2861
+        *codec_tag = arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
2857 2862
 }
2858 2863
 
2859 2864
 static void opt_map(const char *arg)
... ...
@@ -4124,7 +4111,7 @@ static const OptionDef options[] = {
4124 4124
     { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix}, "specify inter matrix coeffs", "matrix" },
4125 4125
     { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "top=1/bottom=0/auto=-1 field first", "" },
4126 4126
     { "dc", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_dc_precision}, "intra_dc_precision", "precision" },
4127
-    { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force video tag/fourcc", "fourcc/tag" },
4127
+    { "vtag", OPT_FUNC2 | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_codec_tag}, "force video tag/fourcc", "fourcc/tag" },
4128 4128
     { "newvideo", OPT_VIDEO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new video stream to the current output stream" },
4129 4129
     { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" },
4130 4130
     { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
... ...
@@ -4140,7 +4127,7 @@ static const OptionDef options[] = {
4140 4140
     { "ac", HAS_ARG | OPT_FUNC2 | OPT_AUDIO, {(void*)opt_audio_channels}, "set number of audio channels", "channels" },
4141 4141
     { "an", OPT_BOOL | OPT_AUDIO, {(void*)&audio_disable}, "disable audio" },
4142 4142
     { "acodec", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_codec}, "force audio codec ('copy' to copy stream)", "codec" },
4143
-    { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_audio_tag}, "force audio tag/fourcc", "fourcc/tag" },
4143
+    { "atag", OPT_FUNC2 | HAS_ARG | OPT_EXPERT | OPT_AUDIO, {(void*)opt_codec_tag}, "force audio tag/fourcc", "fourcc/tag" },
4144 4144
     { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audio volume (256=normal)" , "volume" }, //
4145 4145
     { "newaudio", OPT_AUDIO | OPT_FUNC2, {(void*)opt_new_stream}, "add a new audio stream to the current output stream" },
4146 4146
     { "alang", HAS_ARG | OPT_STRING | OPT_AUDIO, {(void *)&audio_language}, "set the ISO 639 language code (3 letters) of the current audio stream" , "code" },
... ...
@@ -4151,7 +4138,7 @@ static const OptionDef options[] = {
4151 4151
     { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" },
4152 4152
     { "newsubtitle", OPT_SUBTITLE | OPT_FUNC2, {(void*)opt_new_stream}, "add a new subtitle stream to the current output stream" },
4153 4153
     { "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language}, "set the ISO 639 language code (3 letters) of the current subtitle stream" , "code" },
4154
-    { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_subtitle_tag}, "force subtitle tag/fourcc", "fourcc/tag" },
4154
+    { "stag", OPT_FUNC2 | HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_codec_tag}, "force subtitle tag/fourcc", "fourcc/tag" },
4155 4155
 
4156 4156
     /* grab options */
4157 4157
     { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "set video grab channel (DV1394 only)", "channel" },