OSDN Git Service

ac3enc: scale floating-point coupling channel coefficients in
[coroid/libav_saccubus.git] / avconv.c
index d336cf8..09d4886 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -140,9 +140,6 @@ static unsigned int subtitle_codec_tag = 0;
 static int data_disable = 0;
 static unsigned int data_codec_tag = 0;
 
-static float mux_preload= 0.5;
-static float mux_max_delay= 0.7;
-
 static int file_overwrite = 0;
 static int do_benchmark = 0;
 static int do_hex_dump = 0;
@@ -183,10 +180,6 @@ static unsigned int allocated_audio_out_size, allocated_audio_buf_size;
 
 static short *samples;
 
-static AVBitStreamFilterContext *video_bitstream_filters=NULL;
-static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
-static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
-
 #define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
 
 typedef struct InputStream {
@@ -323,11 +316,15 @@ typedef struct OptionsContext {
 
     int64_t recording_time;
     uint64_t limit_filesize;
+    float mux_preload;
+    float mux_max_delay;
 
     SpecifierOpt *metadata;
     int        nb_metadata;
     SpecifierOpt *max_frames;
     int        nb_max_frames;
+    SpecifierOpt *bitstream_filters;
+    int        nb_bitstream_filters;
 } OptionsContext;
 
 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
@@ -370,6 +367,8 @@ static void reset_options(OptionsContext *o)
 
     memset(o, 0, sizeof(*o));
 
+    o->mux_preload    = 0.5;
+    o->mux_max_delay  = 0.7;
     o->recording_time = INT64_MAX;
     o->limit_filesize = UINT64_MAX;
     o->chapters_input_file = INT_MAX;
@@ -2731,7 +2730,7 @@ static int opt_map(OptionsContext *o, const char *opt, const char *arg)
 static void parse_meta_type(char *arg, char *type, int *index)
 {
     if (*arg) {
-        *type = *(++arg);
+        *type = *arg;
         switch (*arg) {
         case 'g':
             break;
@@ -3064,6 +3063,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
     AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
     int idx      = oc->nb_streams - 1;
     int64_t max_frames = INT64_MAX;
+    char *bsf = NULL, *next;
+    AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
 
     if (!st) {
         av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n");
@@ -3088,6 +3089,23 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
     MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);
     ost->max_frames = max_frames;
 
+    MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
+    while (bsf) {
+        if (next = strchr(bsf, ','))
+            *next++ = 0;
+        if (!(bsfc = av_bitstream_filter_init(bsf))) {
+            av_log(NULL, AV_LOG_ERROR, "Unknown bitstream filter %s\n", bsf);
+            exit_program(1);
+        }
+        if (bsfc_prev)
+            bsfc_prev->next = bsfc;
+        else
+            ost->bitstream_filters = bsfc;
+
+        bsfc_prev = bsfc;
+        bsf       = next;
+    }
+
     ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
     return ost;
 }
@@ -3109,9 +3127,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
 #endif
     }
 
-    ost->bitstream_filters = video_bitstream_filters;
-    video_bitstream_filters= NULL;
-
     video_enc = st->codec;
 
     if(video_codec_tag)
@@ -3212,9 +3227,6 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc)
     ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO);
     st  = ost->st;
 
-    ost->bitstream_filters = audio_bitstream_filters;
-    audio_bitstream_filters= NULL;
-
     audio_enc = st->codec;
     audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
 
@@ -3282,9 +3294,6 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc)
     st  = ost->st;
     subtitle_enc = st->codec;
 
-    ost->bitstream_filters = subtitle_bitstream_filters;
-    subtitle_bitstream_filters= NULL;
-
     subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
 
     if(subtitle_codec_tag)
@@ -3561,8 +3570,8 @@ static void opt_output_file(void *optctx, const char *filename)
         }
     }
 
-    oc->preload= (int)(mux_preload*AV_TIME_BASE);
-    oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
+    oc->preload   = (int)(o->mux_preload   * AV_TIME_BASE);
+    oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE);
     oc->flags |= AVFMT_FLAG_NONBLOCK;
 
     /* copy chapters */
@@ -3927,7 +3936,7 @@ static int opt_target(OptionsContext *o, const char *opt, const char *arg)
            and the first pack from the other stream, respectively, may also have
            been written before.
            So the real data starts at SCR 36000+3*1200. */
-        mux_preload= (36000+3*1200) / 90000.0; //0.44
+        o->mux_preload = (36000+3*1200) / 90000.0; //0.44
     } else if(!strcmp(arg, "svcd")) {
 
         opt_video_codec(o, "c:v", "mpeg2video");
@@ -4008,27 +4017,6 @@ static int opt_vstats(const char *opt, const char *arg)
     return opt_vstats_file(opt, filename);
 }
 
-static int opt_bsf(const char *opt, const char *arg)
-{
-    AVBitStreamFilterContext *bsfc= av_bitstream_filter_init(arg); //FIXME split name and args for filter at '='
-    AVBitStreamFilterContext **bsfp;
-
-    if(!bsfc){
-        fprintf(stderr, "Unknown bitstream filter %s\n", arg);
-        exit_program(1);
-    }
-
-    bsfp= *opt == 'v' ? &video_bitstream_filters :
-          *opt == 'a' ? &audio_bitstream_filters :
-                        &subtitle_bitstream_filters;
-    while(*bsfp)
-        bsfp= &(*bsfp)->next;
-
-    *bsfp= bsfc;
-
-    return 0;
-}
-
 static int opt_video_frames(OptionsContext *o, const char *opt, const char *arg)
 {
     return parse_option(o, "frames:v", arg, options);
@@ -4143,12 +4131,10 @@ static const OptionDef options[] = {
     { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {(void*)&input_sync}, "sync read on input", "" },
 
     /* muxer options */
-    { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_max_delay}, "set the maximum demux-decode delay", "seconds" },
-    { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_preload}, "set the initial demux-decode delay", "seconds" },
+    { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT   | OPT_OFFSET, {.off = OFFSET(mux_max_delay)}, "set the maximum demux-decode delay", "seconds" },
+    { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(mux_preload)},   "set the initial demux-decode delay", "seconds" },
 
-    { "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
-    { "vbsf", HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
-    { "sbsf", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
+    { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(bitstream_filters)}, "A comma-separated list of bitstream filters", "bitstream_filters" },
 
     /* data codec support */
     { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },