return ret;
if (frame->buf[0]) {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
- 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);
- return AVERROR(ENOMEM);
- }
+ 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);
+ }
- for (int i = 0; i < desc->nb_components; i++) {
- int shift = i ? desc->log2_chroma_h : 0;
- int bytes = desc->comp[0].depth == 8 ? 1 : 2;
- rav1e_frame_fill_plane(rframe, i, frame->data[i],
- (frame->height >> shift) * frame->linesize[i],
- frame->linesize[i], bytes);
- }
- av_frame_unref(frame);
+ for (int i = 0; i < desc->nb_components; i++) {
+ int shift = i ? desc->log2_chroma_h : 0;
+ int bytes = desc->comp[0].depth == 8 ? 1 : 2;
+ rav1e_frame_fill_plane(rframe, i, frame->data[i],
+ (frame->height >> shift) * frame->linesize[i],
+ frame->linesize[i], bytes);
+ }
+ av_frame_unref(frame);
+ rav1e_frame_set_opaque(rframe, pts, av_free);
}
}
if (ret == RA_ENCODER_STATUS_ENOUGH_DATA) {
ctx->rframe = rframe; /* Queue is full. Store the RaFrame to retry next call */
} else {
- rav1e_frame_unref(rframe); /* No need to unref if flushing. */
+ rav1e_frame_unref(rframe); /* No need to unref if flushing. */
ctx->rframe = NULL;
}
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);
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) {
.version = LIBAVUTIL_VERSION_INT,
};
-AVCodec ff_librav1e_encoder = {
+const AVCodec ff_librav1e_encoder = {
.name = "librav1e",
.long_name = NULL_IF_CONFIG_SMALL("librav1e AV1"),
.type = AVMEDIA_TYPE_VIDEO,
.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",
};