aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-03-22 17:45:34 +0100
committerAnton Khirnov <anton@khirnov.net>2024-03-28 08:40:01 +0100
commit0edbd00ccf82a2cfc0c4d4a01fa7c62c8e027968 (patch)
tree1177f8a1eff9ba8cd78cc766ff45d5a4baf90f28
parent372c78dd42f2b1ca743473b9c32fad71c65919e0 (diff)
downloadffmpeg-0edbd00ccf82a2cfc0c4d4a01fa7c62c8e027968.tar.gz
fftools/ffmpeg_{demux,dec}: pass -bitexact through DecoderFlags
Avoids abusing AV_DICT_MULTIKEY and relying on undocumented AVDictionary ordering behaviour.
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_dec.c2
-rw-r--r--fftools/ffmpeg_demux.c11
3 files changed, 9 insertions, 6 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6394cca1e7..bf6e0c9084 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -304,6 +304,8 @@ enum DecoderFlags {
DECODER_FLAG_TOP_FIELD_FIRST = (1 << 3),
#endif
DECODER_FLAG_SEND_END_TS = (1 << 4),
+ // force bitexact decoding
+ DECODER_FLAG_BITEXACT = (1 << 5),
};
typedef struct DecoderOpts {
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index ad02a64b60..b8bfae469f 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -1211,6 +1211,8 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts,
return ret;
dp->dec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE;
+ if (o->flags & DECODER_FLAG_BITEXACT)
+ dp->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
if ((ret = avcodec_open2(dp->dec_ctx, codec, NULL)) < 0) {
av_log(dp, AV_LOG_ERROR, "Error while opening decoder: %s\n",
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 73b0eb0da1..af4b4cfd1e 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -908,11 +908,11 @@ static int ist_use(InputStream *ist, int decoding_needed)
if (decoding_needed && ds->sch_idx_dec < 0) {
int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
- ds->dec_opts.flags = (!!ist->fix_sub_duration * DECODER_FLAG_FIX_SUB_DURATION) |
- (!!(d->f.ctx->iformat->flags & AVFMT_NOTIMESTAMPS) * DECODER_FLAG_TS_UNRELIABLE) |
- (!!(d->loop && is_audio) * DECODER_FLAG_SEND_END_TS)
+ ds->dec_opts.flags |= (!!ist->fix_sub_duration * DECODER_FLAG_FIX_SUB_DURATION) |
+ (!!(d->f.ctx->iformat->flags & AVFMT_NOTIMESTAMPS) * DECODER_FLAG_TS_UNRELIABLE) |
+ (!!(d->loop && is_audio) * DECODER_FLAG_SEND_END_TS)
#if FFMPEG_OPT_TOP
- | ((ist->top_field_first >= 0) * DECODER_FLAG_TOP_FIELD_FIRST)
+ | ((ist->top_field_first >= 0) * DECODER_FLAG_TOP_FIELD_FIRST)
#endif
;
@@ -1357,8 +1357,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
ist->user_set_discard = ist->st->discard;
}
- if (o->bitexact)
- av_dict_set(&ds->decoder_opts, "flags", "+bitexact", AV_DICT_MULTIKEY);
+ ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact;
/* Attached pics are sparse, therefore we would not want to delay their decoding
* till EOF. */