Skip to content

Commit

Permalink
Use the frame delay calculated by dav1id
Browse files Browse the repository at this point in the history
  • Loading branch information
Asd-g committed Mar 7, 2024
1 parent 927d5a8 commit 0747f84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 3 additions & 4 deletions common/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ int open_decoder
* For instance, when stream is encoded as AC-3,
* AVCodecContext.codec_id might have been set to AV_CODEC_ID_EAC3
* while AVCodec.id is set to AV_CODEC_ID_AC3. */
if( !strcmp( codec->name, "libdav1d" )
&& (ret = av_opt_set_int( c->priv_data, "framethreads", 1, 0 )) < 0 )
goto fail;
else if( !strcmp( codec->name, "vp9" )
if( !strcmp( codec->name, "vp9" )
&& thread_count != 1
&& av_cpu_count() > 1 )
c->thread_count = 2;
Expand Down Expand Up @@ -174,6 +171,8 @@ int open_decoder
if( is_qsv_decoder( c->codec ) )
if( (ret = do_qsv_decoder_workaround( c )) < 0 )
goto fail;
if (!strcmp(codec->name, "libdav1d"))
c->thread_count = c->delay;
*ctx = c;
return ret;
fail:
Expand Down
5 changes: 4 additions & 1 deletion common/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ static inline uint32_t get_decoder_delay
AVCodecContext *ctx
)
{
return ctx->has_b_frames + ((ctx->active_thread_type & FF_THREAD_FRAME) ? ctx->thread_count - 1 : 0);
if (!strcmp(ctx->codec->name, "libdav1d"))
return ctx->delay;
else
return ctx->has_b_frames + ((ctx->active_thread_type & FF_THREAD_FRAME) ? ctx->thread_count - 1 : 0);
}

const AVCodec *find_decoder
Expand Down

0 comments on commit 0747f84

Please sign in to comment.