[vlc-commits] [Git][videolan/vlc][master] codec: rav1e: use opaque pointer for storing pts
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Sat Jan 21 13:04:15 UTC 2023
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
bd2be7d8 by Tristan Matthews at 2023-01-21T12:37:03+00:00
codec: rav1e: use opaque pointer for storing pts
- - - - -
1 changed file:
- modules/codec/rav1e.c
Changes:
=====================================
modules/codec/rav1e.c
=====================================
@@ -32,11 +32,14 @@
#define SOUT_CFG_PREFIX "sout-rav1e-"
+struct frame_priv_s
+{
+ vlc_tick_t pts;
+};
+
typedef struct
{
struct RaContext *ra_context;
- date_t date;
- bool date_set;
} encoder_sys_t;
static block_t *Encode(encoder_t *enc, picture_t *p_pict)
@@ -46,13 +49,14 @@ static block_t *Encode(encoder_t *enc, picture_t *p_pict)
block_t *p_out = NULL;
RaFrame *frame;
+ struct frame_priv_s *frame_priv = NULL;
if (p_pict != NULL)
{
- if (!sys->date_set && p_pict->date != VLC_TICK_INVALID)
- {
- date_Set(&sys->date, p_pict->date);
- sys->date_set = true;
- }
+ frame_priv = malloc(sizeof(*frame_priv));
+ if (!frame_priv)
+ goto error;
+
+ frame_priv->pts = p_pict->date;
frame = rav1e_frame_new(ctx);
if (frame == NULL) {
@@ -60,12 +64,14 @@ static block_t *Encode(encoder_t *enc, picture_t *p_pict)
goto error;
}
- for (int idx = 0; idx < p_pict->i_planes; idx++)
+ for (int idx = 0; idx < p_pict->i_planes; idx++) {
rav1e_frame_fill_plane(frame, idx,
p_pict->p[idx].p_pixels,
p_pict->p[idx].i_pitch * p_pict->p[idx].i_visible_lines,
p_pict->p[idx].i_pitch,
p_pict->p[idx].i_pixel_pitch);
+ }
+ rav1e_frame_set_opaque(frame, frame_priv, free);
}
else
frame = NULL; /* Drain with a NULL frame */
@@ -98,7 +104,11 @@ static block_t *Encode(encoder_t *enc, picture_t *p_pict)
}
memcpy(p_block->p_buffer, pkt->data, pkt->len);
- p_block->i_dts = p_block->i_pts = date_Get(&sys->date);
+ /* Reordered frames are always muxed together in the same packet with the
+ next visible frame, and visible frames always come out in order. Therefore
+ dts and pts will always be equal for any given packet. */
+ p_block->i_dts = p_block->i_pts = ((struct frame_priv_s *) pkt->opaque)->pts;
+ free(pkt->opaque);
if (pkt->frame_type == RA_FRAME_TYPE_KEY)
p_block->i_flags |= BLOCK_FLAG_TYPE_I;
@@ -123,6 +133,7 @@ static block_t *Encode(encoder_t *enc, picture_t *p_pict)
return p_out;
error:
+ free(frame_priv);
free(p_out);
return NULL;
}
@@ -265,10 +276,6 @@ static int OpenEncoder(vlc_object_t *this)
}
rav1e_config_unref(ra_config);
- date_Init(&sys->date, enc->fmt_out.video.i_frame_rate,
- enc->fmt_out.video.i_frame_rate_base);
- sys->date_set = false;
-
static const struct vlc_encoder_operations ops =
{
.close = CloseEncoder,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/bd2be7d8294c2eef92eb6b3cf1a026509fb45e4b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/bd2be7d8294c2eef92eb6b3cf1a026509fb45e4b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list