[FFmpeg-devel] [PATCH 6/8] Factorize opt_{audio, video, subtitle}_tag() functions, make all of them use the new function get_codec_tag_from_string().

Stefano Sabatini stefano.sabatini-lala
Wed Jun 2 15:30:30 CEST 2010


---
 ffmpeg.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index bf57883..ca52b00 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2952,22 +2952,24 @@ static void opt_audio_codec(const char *arg)
     opt_codec(&audio_stream_copy, &audio_codec_name, AVMEDIA_TYPE_AUDIO, arg);
 }
 
-static void opt_audio_tag(const char *arg)
+static unsigned int get_codec_tag_from_string(const char *tag)
 {
     char *tail;
-    audio_codec_tag= strtol(arg, &tail, 0);
+    unsigned int codec_tag = strtol(tag, &tail, 0);
 
     if(!tail || *tail)
-        audio_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
+        codec_tag = tag[0] + (tag[1]<<8) + (tag[2]<<16) + (tag[3]<<24);
+    return codec_tag;
 }
 
-static void opt_video_tag(const char *arg)
+static void opt_audio_tag(const char *arg)
 {
-    char *tail;
-    video_codec_tag= strtol(arg, &tail, 0);
+    audio_codec_tag = get_codec_tag_from_string(arg);
+}
 
-    if(!tail || *tail)
-        video_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
+static void opt_video_tag(const char *arg)
+{
+    video_codec_tag = get_codec_tag_from_string(arg);
 }
 
 static void opt_video_codec(const char *arg)
@@ -2982,11 +2984,7 @@ static void opt_subtitle_codec(const char *arg)
 
 static void opt_subtitle_tag(const char *arg)
 {
-    char *tail;
-    subtitle_codec_tag= strtol(arg, &tail, 0);
-
-    if(!tail || *tail)
-        subtitle_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
+    subtitle_codec_tag = get_codec_tag_from_string(arg);
 }
 
 static void opt_map(const char *arg)
-- 
1.7.1




More information about the ffmpeg-devel mailing list