diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-05-09 02:15:01 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-05-19 11:39:45 +0200 |
commit | eee88ba0dc67b5beaa31199d5bf1e7fc324e0652 (patch) | |
tree | 5fcf38676fcc1da5b201560f51fc183ec9fcb406 /libavcodec/pthread_frame.c | |
parent | 41fc62f2e87c8427bdb87b6d90da0935e67e7576 (diff) | |
download | ffmpeg-eee88ba0dc67b5beaa31199d5bf1e7fc324e0652.tar.gz |
avcodec/decode: Set KEY flag+pict_type generically for intra-only codecs
This commit is the analog of 3f11eac75741888c7b2b6f93c458766f2613bab5
for decoding: It sets the AV_FRAME_FLAG_KEY and (for video decoders)
also pict_type to AV_PICTURE_TYPE_I. It furthermore stops setting
audio frames as always being key frames -- it is wrong for e.g.
TrueHD/MLP. The latter also affects TAK and DFPWM.
The change already improves output for several decoders where
it has been forgotten to set e.g. pict_type like speedhq, wnv1
or tiff. The latter is the reason for the change to the exif-image-tiff
FATE test reference file.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/pthread_frame.c')
-rw-r--r-- | libavcodec/pthread_frame.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 67f09c1f48..982e4a64c5 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -22,13 +22,11 @@ * @see doc/multithreading.txt */ -#include "config.h" - #include <stdatomic.h> -#include <stdint.h> #include "avcodec.h" #include "avcodec_internal.h" +#include "codec_desc.h" #include "codec_internal.h" #include "decode.h" #include "hwaccel_internal.h" @@ -108,6 +106,10 @@ typedef struct PerThreadContext { int hwaccel_threadsafe; atomic_int debug_threads; ///< Set if the FF_DEBUG_THREADS option is set. + + /// The following two fields have the same semantics as the DecodeContext field + int intra_only_flag; + enum AVPictureType initial_pict_type; } PerThreadContext; /** @@ -220,6 +222,8 @@ static attribute_align_arg void *frame_worker_thread(void *arg) av_frame_unref(p->frame); p->got_frame = 0; + p->frame->pict_type = p->initial_pict_type; + p->frame->flags |= p->intra_only_flag; p->result = codec->cb.decode(avctx, p->frame, &p->got_frame, p->avpkt); if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) @@ -763,6 +767,13 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, AVCodecContext *copy; int err; + p->initial_pict_type = AV_PICTURE_TYPE_NONE; + if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY) { + p->intra_only_flag = AV_FRAME_FLAG_KEY; + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) + p->initial_pict_type = AV_PICTURE_TYPE_I; + } + atomic_init(&p->state, STATE_INPUT_READY); copy = av_memdup(avctx, sizeof(*avctx)); |