[vlc-commits] dav1d: factorize the code to set the output video format
Steve Lhomme
git at videolan.org
Fri Sep 11 10:59:32 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Sep 9 11:06:52 2020 +0200| [c94c8ebcddb81fec5c95e8315d14f13079f98a9e] | committer: Steve Lhomme
dav1d: factorize the code to set the output video format
And some code cleaning.
No functional changes.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c94c8ebcddb81fec5c95e8315d14f13079f98a9e
---
modules/codec/dav1d.c | 64 +++++++++++++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 28 deletions(-)
diff --git a/modules/codec/dav1d.c b/modules/codec/dav1d.c
index 23b4eb9cda..5d341a367f 100644
--- a/modules/codec/dav1d.c
+++ b/modules/codec/dav1d.c
@@ -125,30 +125,35 @@ static vlc_fourcc_t FindVlcChroma(const Dav1dPicture *img)
return 0;
}
-static int NewPicture(Dav1dPicture *img, void *cookie)
+static void UpdateDecoderOutput(decoder_t *dec, const Dav1dSequenceHeader *seq_hdr)
{
- decoder_t *dec = cookie;
-
video_format_t *v = &dec->fmt_out.video;
- v->i_visible_width = img->p.w;
- v->i_visible_height = img->p.h;
- v->i_width = (img->p.w + 0x7F) & ~0x7F;
- v->i_height = (img->p.h + 0x7F) & ~0x7F;
-
if( !v->i_sar_num || !v->i_sar_den )
{
v->i_sar_num = 1;
v->i_sar_den = 1;
}
- if(dec->fmt_in.video.primaries == COLOR_PRIMARIES_UNDEF && img->seq_hdr)
+ if(dec->fmt_in.video.primaries == COLOR_PRIMARIES_UNDEF && seq_hdr)
{
- v->primaries = iso_23001_8_cp_to_vlc_primaries(img->seq_hdr->pri);
- v->transfer = iso_23001_8_tc_to_vlc_xfer(img->seq_hdr->trc);
- v->space = iso_23001_8_mc_to_vlc_coeffs(img->seq_hdr->mtrx);
- v->color_range = img->seq_hdr->color_range ? COLOR_RANGE_FULL : COLOR_RANGE_LIMITED;
+ v->primaries = iso_23001_8_cp_to_vlc_primaries(seq_hdr->pri);
+ v->transfer = iso_23001_8_tc_to_vlc_xfer(seq_hdr->trc);
+ v->space = iso_23001_8_mc_to_vlc_coeffs(seq_hdr->mtrx);
+ v->color_range = seq_hdr->color_range ? COLOR_RANGE_FULL : COLOR_RANGE_LIMITED;
}
+}
+
+static int NewPicture(Dav1dPicture *img, void *cookie)
+{
+ decoder_t *dec = cookie;
+
+ video_format_t *v = &dec->fmt_out.video;
+
+ v->i_visible_width = img->p.w;
+ v->i_visible_height = img->p.h;
+
+ UpdateDecoderOutput(dec, img->seq_hdr);
const Dav1dMasteringDisplay *md = img->mastering_display;
if( dec->fmt_in.video.mastering.max_luminance == 0 && md )
@@ -180,23 +185,27 @@ static int NewPicture(Dav1dPicture *img, void *cookie)
v->projection_mode = dec->fmt_in.video.projection_mode;
v->multiview_mode = dec->fmt_in.video.multiview_mode;
v->pose = dec->fmt_in.video.pose;
- dec->fmt_out.video.i_chroma = dec->fmt_out.i_codec = FindVlcChroma(img);
+ 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_chroma = dec->fmt_out.i_codec;
if (decoder_UpdateVideoFormat(dec) == 0)
{
- picture_t *pic = decoder_NewPicture(dec);
- if (likely(pic != NULL))
- {
- img->data[0] = pic->p[0].p_pixels;
- img->stride[0] = pic->p[0].i_pitch;
- img->data[1] = pic->p[1].p_pixels;
- img->data[2] = pic->p[2].p_pixels;
- assert(pic->p[1].i_pitch == pic->p[2].i_pitch);
- img->stride[1] = pic->p[1].i_pitch;
- img->allocator_data = pic;
-
- return 0;
- }
+ picture_t *pic;
+ pic = decoder_NewPicture(dec);
+ if (unlikely(pic == NULL))
+ return -1;
+
+ img->data[0] = pic->p[0].p_pixels;
+ img->stride[0] = pic->p[0].i_pitch;
+ img->data[1] = pic->p[1].p_pixels;
+ img->data[2] = pic->p[2].p_pixels;
+ assert(pic->p[1].i_pitch == pic->p[2].i_pitch);
+ img->stride[1] = pic->p[1].i_pitch;
+
+ img->allocator_data = pic;
+ return 0;
}
return -1;
}
@@ -481,4 +490,3 @@ static void CloseDecoder(vlc_object_t *p_this)
dav1d_close(&p_sys->c);
}
-
More information about the vlc-commits
mailing list