Commit c94c8ebc authored by Steve Lhomme's avatar Steve Lhomme
Browse files

dav1d: factorize the code to set the output video format

And some code cleaning.

No functional changes.
parent 3c64e71e
......@@ -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);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment