X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flibrav1e.c;h=37c3007d812fcf8287dc731992e36e2832eeac5e;hb=930391e5988abe126d29c5e9b09fab459e0b8936;hp=46071bcdacf1d96bafa00ee7b3f2b71e5308e474;hpb=b085a72c54ced391d4e1cd00d2a2959b5a5704e6;p=ffmpeg diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 46071bcdacf..37c3007d812 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -445,10 +445,18 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) if (frame->buf[0]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); + int64_t *pts = av_malloc(sizeof(int64_t)); + if (!pts) { + av_log(avctx, AV_LOG_ERROR, "Could not allocate PTS buffer.\n"); + return AVERROR(ENOMEM); + } + *pts = frame->pts; + rframe = rav1e_frame_new(ctx->ctx); if (!rframe) { av_log(avctx, AV_LOG_ERROR, "Could not allocate new rav1e frame.\n"); av_frame_unref(frame); + av_freep(&pts); return AVERROR(ENOMEM); } @@ -460,6 +468,7 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) frame->linesize[i], bytes); } av_frame_unref(frame); + rav1e_frame_set_opaque(rframe, pts, av_free); } } @@ -523,7 +532,7 @@ retry: return AVERROR_UNKNOWN; } - ret = av_new_packet(pkt, rpkt->len); + ret = ff_get_encode_buffer(avctx, pkt, rpkt->len, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not allocate packet.\n"); rav1e_packet_unref(rpkt); @@ -535,7 +544,8 @@ retry: if (rpkt->frame_type == RA_FRAME_TYPE_KEY) pkt->flags |= AV_PKT_FLAG_KEY; - pkt->pts = pkt->dts = rpkt->input_frameno * avctx->ticks_per_frame; + pkt->pts = pkt->dts = *((int64_t *) rpkt->opaque); + av_free(rpkt->opaque); rav1e_packet_unref(rpkt); if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) { @@ -614,7 +624,8 @@ AVCodec ff_librav1e_encoder = { .priv_class = &class, .defaults = librav1e_defaults, .pix_fmts = librav1e_pix_fmts, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | + AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .wrapper_name = "librav1e", };