[vlc-commits] [Git][videolan/vlc][master] 5 commits: packetizer: av1: keep the reduced_still_picture_header
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Tue Apr 18 17:06:24 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
507808e3 by Steve Lhomme at 2023-04-18T16:44:10+00:00
packetizer: av1: keep the reduced_still_picture_header
It's used to compare sequence headers.
- - - - -
7e9333f0 by Steve Lhomme at 2023-04-18T16:44:10+00:00
dav1d: always use buffers with the max resolution
When the super resolution of AV1 is used, some frames may be encoded smaller
than the max resolution, but they are actually decoded at the max resolution
by dav1d. So we need to provide a buffer large enough.
Ref. #28002
- - - - -
d59fdf9c by Steve Lhomme at 2023-04-18T16:44:10+00:00
packetizer: av1: allow reading the super resolution from the sequence header
- - - - -
213ba82e by Steve Lhomme at 2023-04-18T16:44:10+00:00
dav1d: buffer more pictures when super resolution is used
When decoding AV1 bitstreams using super resolution, we end up deadlocking
in the decoder pool because we don't have engouh pictures.
We need to add more pictures to the pool so that the decoder works properly.
It seems to need only one extra when using a single thread and 2 when using
more that one thread.
Ref. #28002
- - - - -
47486d99 by Steve Lhomme at 2023-04-18T16:44:10+00:00
dav1d: update the extra picture buffers needed on each picture
If the AV1 extra data in the container don't match the bitstream (invalid file)
we end up missing some pictures when using extra resolution.
This can be triggered by this bug in Handbrake with SVT-AV1:
https://github.com/HandBrake/HandBrake/issues/5081
Ref. #28002
- - - - -
3 changed files:
- modules/codec/dav1d.c
- modules/packetizer/av1_obu.c
- modules/packetizer/av1_obu.h
Changes:
=====================================
modules/codec/dav1d.c
=====================================
@@ -160,11 +160,12 @@ static void UpdateDecoderOutput(decoder_t *dec, const Dav1dSequenceHeader *seq_h
static int NewPicture(Dav1dPicture *img, void *cookie)
{
decoder_t *dec = cookie;
+ decoder_sys_t *p_sys = dec->p_sys;
video_format_t *v = &dec->fmt_out.video;
- v->i_visible_width = img->p.w;
- v->i_visible_height = img->p.h;
+ v->i_visible_width = img->seq_hdr->max_width;
+ v->i_visible_height = img->seq_hdr->max_height;
UpdateDecoderOutput(dec, img->seq_hdr);
@@ -199,10 +200,15 @@ static int NewPicture(Dav1dPicture *img, void *cookie)
v->multiview_mode = dec->fmt_in->video.multiview_mode;
v->pose = dec->fmt_in->video.pose;
dec->fmt_out.i_codec = FindVlcChroma(img);
- v->i_width = (img->p.w + 0x7F) & ~0x7F;
- v->i_height = (img->p.h + 0x7F) & ~0x7F;
+ v->i_width = (img->seq_hdr->max_width + 0x7F) & ~0x7F;
+ v->i_height = (img->seq_hdr->max_height + 0x7F) & ~0x7F;
v->i_chroma = dec->fmt_out.i_codec;
+ dec->i_extra_picture_buffers = p_sys->s.max_frame_delay;
+ if (img->seq_hdr->super_res)
+ // dav1d seems to buffer more pictures when using super resolution
+ dec->i_extra_picture_buffers += p_sys->s.max_frame_delay > 1 ? 2 : 1;
+
if (decoder_UpdateVideoFormat(dec) == 0)
{
picture_t *pic;
@@ -481,6 +487,7 @@ static int OpenDecoder(vlc_object_t *p_this)
dec->fmt_out.video.i_frame_rate = dec->fmt_in->video.i_frame_rate;
dec->fmt_out.video.i_frame_rate_base = dec->fmt_in->video.i_frame_rate_base;
+ bool super_res = false;
if (!sequence_hdr)
{
dec->fmt_out.i_codec = VLC_CODEC_I420;
@@ -497,6 +504,7 @@ static int OpenDecoder(vlc_object_t *p_this)
if (dec->fmt_out.video.transfer == TRANSFER_FUNC_UNDEF)
AV1_get_colorimetry(sequence_hdr, &dec->fmt_out.video.primaries, &dec->fmt_out.video.transfer,
&dec->fmt_out.video.space, &dec->fmt_out.video.color_range);
+ super_res = AV1_get_super_res(sequence_hdr);
}
dec->fmt_out.video.i_visible_width = dec->fmt_out.video.i_width;
dec->fmt_out.video.i_visible_height = dec->fmt_out.video.i_height;
@@ -512,6 +520,9 @@ static int OpenDecoder(vlc_object_t *p_this)
dav1d_version(), p_sys->s.n_threads);
dec->i_extra_picture_buffers = p_sys->s.max_frame_delay;
+ if (super_res)
+ // dav1d seems to buffer more pictures when using super resolution
+ dec->i_extra_picture_buffers += p_sys->s.max_frame_delay > 1 ? 2 : 1;
#else
msg_Dbg(p_this, "Using dav1d version %s with %d/%d frame/tile threads",
dav1d_version(), p_sys->s.n_frame_threads, p_sys->s.n_tile_threads);
=====================================
modules/packetizer/av1_obu.c
=====================================
@@ -328,8 +328,8 @@ av1_OBU_sequence_header_t *
p_seq->seq_profile = bs_read(&bs, 3);
p_seq->still_picture = bs_read1(&bs);
- const obu_u1_t reduced_still_picture_header = bs_read1(&bs);
- if(reduced_still_picture_header)
+ p_seq->reduced_still_picture_header = bs_read1(&bs);
+ if(p_seq->reduced_still_picture_header)
{
p_seq->operating_points[0].seq_level_idx = bs_read(&bs, 5);
}
@@ -373,7 +373,7 @@ av1_OBU_sequence_header_t *
const obu_u4_t frame_height_bits_minus_1 = bs_read(&bs, 4);
p_seq->max_frame_width_minus_1 = bs_read(&bs, 1 + frame_width_bits_minus_1);
p_seq->max_frame_height_minus_1 = bs_read(&bs, 1 + frame_height_bits_minus_1);
- if(!reduced_still_picture_header)
+ if(!p_seq->reduced_still_picture_header)
{
p_seq->frame_id_numbers_present_flag = bs_read1(&bs);
if(p_seq->frame_id_numbers_present_flag)
@@ -385,7 +385,7 @@ av1_OBU_sequence_header_t *
p_seq->use_128x128_superblock = bs_read1(&bs);
p_seq->enable_filter_intra = bs_read1(&bs);
p_seq->enable_intra_edge_filter = bs_read1(&bs);
- if(!reduced_still_picture_header)
+ if(!p_seq->reduced_still_picture_header)
{
p_seq->enable_interintra_compound = bs_read1(&bs);
p_seq->enable_masked_compound = bs_read1(&bs);
@@ -554,6 +554,11 @@ bool AV1_get_frame_rate(const av1_OBU_sequence_header_t *p_seq,
return true;
}
+bool AV1_get_super_res(const av1_OBU_sequence_header_t *p_seq)
+{
+ return p_seq->enable_superres;
+}
+
bool AV1_get_colorimetry(const av1_OBU_sequence_header_t *p_seq,
video_color_primaries_t *p_primaries,
video_transfer_func_t *p_transfer,
=====================================
modules/packetizer/av1_obu.h
=====================================
@@ -167,6 +167,7 @@ bool AV1_get_colorimetry( const av1_OBU_sequence_header_t *,
video_color_primaries_t *, video_transfer_func_t *,
video_color_space_t *, video_color_range_t *);
bool AV1_get_frame_rate(const av1_OBU_sequence_header_t *, unsigned *, unsigned *);
+bool AV1_get_super_res(const av1_OBU_sequence_header_t *);
vlc_fourcc_t AV1_get_chroma(const av1_OBU_sequence_header_t *);
bool AV1_sequence_header_equal(const av1_OBU_sequence_header_t *,const av1_OBU_sequence_header_t *);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/77ddfcd3e25a99364d3e310822cc5fa2d06ba3e8...47486d9992c3c58a929ec535b2da59ecc325a367
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/77ddfcd3e25a99364d3e310822cc5fa2d06ba3e8...47486d9992c3c58a929ec535b2da59ecc325a367
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