[FFmpeg-cvslog] ffmpeg: add -bitexact flag to simplify enabling bitexact mode in (de)muxer and (de/en)coder

Michael Niedermayer git at videolan.org
Mon Oct 23 13:42:04 EEST 2017


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Oct 22 01:41:57 2017 +0200| [2c9fa4162b346a394188a2e5a3442076155f2e34] | committer: Michael Niedermayer

ffmpeg: add -bitexact flag to simplify enabling bitexact mode in (de)muxer and (de/en)coder

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c9fa4162b346a394188a2e5a3442076155f2e34
---

 doc/ffmpeg.texi      |  2 ++
 fftools/ffmpeg.h     |  1 +
 fftools/ffmpeg_opt.c | 16 ++++++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index cdb3bc68ae..7db80ebf6a 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1250,6 +1250,8 @@ or as a floating point number (e.g. 0.04166, 2.0833e-5)
 
 Default value is 0.
 
+ at item -bitexact (@emph{input/output})
+Enable bitexact mode for (de)muxer and (de/en)coder
 @item -shortest (@emph{output})
 Finish encoding when the shortest input stream ends.
 @item -dts_delta_threshold
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 0db481d747..50fc8d5767 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -160,6 +160,7 @@ typedef struct OptionsContext {
     float mux_preload;
     float mux_max_delay;
     int shortest;
+    int bitexact;
 
     int video_disable;
     int audio_disable;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 2fa5d6d286..d441d29390 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -782,6 +782,9 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
             exit_program(1);
         }
 
+        if (o->bitexact)
+            ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
+
         switch (par->codec_type) {
         case AVMEDIA_TYPE_VIDEO:
             if(!ist->dec)
@@ -1045,6 +1048,8 @@ static int open_input_file(OptionsContext *o, const char *filename)
         av_format_set_data_codec(ic, find_codec_or_die(data_codec_name, AVMEDIA_TYPE_DATA, 0));
 
     ic->flags |= AVFMT_FLAG_NONBLOCK;
+    if (o->bitexact)
+        ic->flags |= AVFMT_FLAG_BITEXACT;
     ic->interrupt_callback = int_cb;
 
     if (!av_dict_get(o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
@@ -1366,6 +1371,10 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
         ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);
     }
 
+
+    if (o->bitexact)
+        ost->enc_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
+
     MATCH_PER_STREAM_OPT(time_bases, str, time_base, oc, st);
     if (time_base) {
         AVRational q;
@@ -2144,6 +2153,10 @@ static int open_output_file(OptionsContext *o, const char *filename)
         const AVOption *o = av_opt_find(oc, "fflags", NULL, 0, 0);
         av_opt_eval_flags(oc, o, e->value, &format_flags);
     }
+    if (o->bitexact) {
+        format_flags |= AVFMT_FLAG_BITEXACT;
+        oc->flags    |= AVFMT_FLAG_BITEXACT;
+    }
 
     /* create streams for all unlabeled output pads */
     for (i = 0; i < nb_filtergraphs; i++) {
@@ -3467,6 +3480,9 @@ const OptionDef options[] = {
     { "shortest",       OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
                         OPT_OUTPUT,                                  { .off = OFFSET(shortest) },
         "finish encoding within shortest input" },
+    { "bitexact",       OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
+                        OPT_OUTPUT | OPT_INPUT,                      { .off = OFFSET(bitexact) },
+        "bitexact mode" },
     { "apad",           OPT_STRING | HAS_ARG | OPT_SPEC |
                         OPT_OUTPUT,                                  { .off = OFFSET(apad) },
         "audio pad", "" },



More information about the ffmpeg-cvslog mailing list