Put layout back in Dav1dSequenceHeader

This partially reverts commit b6bb8536.

Relegating the work of deriving this value to the library user from
ss_hor, ss_ver and monochrome in functions that don't return a
Dav1dPictureParameters is not a good idea.
Signed-off-by: James Almer's avatarJames Almer <jamrial@gmail.com>
parent 513dfa99
......@@ -173,6 +173,7 @@ typedef struct Dav1dSequenceHeader {
* a normative requirement.
*/
int max_width, max_height;
enum Dav1dPixelLayout layout; ///< format of the picture
enum Dav1dColorPrimaries pri; ///< color primaries (av1)
enum Dav1dTransferCharacteristics trc; ///< transfer characteristics (av1)
enum Dav1dMatrixCoefficients mtrx; ///< matrix coefficients (av1)
......
......@@ -3003,10 +3003,6 @@ int dav1d_submit_frame(Dav1dContext *const c) {
f->dsp = &c->dsp[f->seq_hdr->hbd];
const int bpc = 8 + 2 * f->seq_hdr->hbd;
const enum Dav1dPixelLayout layout =
f->seq_hdr->monochrome ? DAV1D_PIXEL_LAYOUT_I400 :
!f->seq_hdr->ss_hor ? DAV1D_PIXEL_LAYOUT_I444 :
f->seq_hdr->ss_ver ? DAV1D_PIXEL_LAYOUT_I420 : DAV1D_PIXEL_LAYOUT_I422;
if (!f->dsp->ipred.intra_pred[DC_PRED]) {
Dav1dDSPContext *const dsp = &c->dsp[f->seq_hdr->hbd];
......@@ -3069,7 +3065,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
f->frame_hdr->height * 2 < c->refs[refidx].p.p.p.h ||
f->frame_hdr->width[0] > c->refs[refidx].p.p.p.w * 16 ||
f->frame_hdr->height > c->refs[refidx].p.p.p.h * 16 ||
layout != c->refs[refidx].p.p.p.layout ||
f->seq_hdr->layout != c->refs[refidx].p.p.p.layout ||
bpc != c->refs[refidx].p.p.p.bpc)
{
for (int j = 0; j < i; j++)
......@@ -3118,7 +3114,8 @@ int dav1d_submit_frame(Dav1dContext *const c) {
// allocate frame
res = dav1d_thread_picture_alloc(&f->sr_cur, f->frame_hdr->width[1],
f->frame_hdr->height, layout, bpc,
f->frame_hdr->height,
f->seq_hdr->layout, bpc,
c->n_fc > 1 ? &f->frame_thread.td : NULL,
f->frame_hdr->show_frame, &c->allocator);
if (res < 0) goto error;
......
......@@ -216,6 +216,7 @@ static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb,
}
if (hdr->monochrome) {
hdr->color_range = dav1d_get_bits(gb, 1);
hdr->layout = DAV1D_PIXEL_LAYOUT_I400;
hdr->ss_hor = hdr->ss_ver = 0;
hdr->chr = DAV1D_CHR_UNKNOWN;
hdr->separate_uv_delta_q = 0;
......@@ -223,6 +224,7 @@ static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb,
hdr->trc == DAV1D_TRC_SRGB &&
hdr->mtrx == DAV1D_MC_IDENTITY)
{
hdr->layout = DAV1D_PIXEL_LAYOUT_I444;
hdr->ss_hor = hdr->ss_ver = 1;
hdr->color_range = 1;
if (hdr->profile != 1 && !(hdr->profile == 2 && hdr->hbd == 2))
......@@ -230,8 +232,12 @@ static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb,
} else {
hdr->color_range = dav1d_get_bits(gb, 1);
switch (hdr->profile) {
case 0: hdr->ss_hor = hdr->ss_ver = 1; break;
case 1: hdr->ss_hor = hdr->ss_ver = 0; break;
case 0: hdr->layout = DAV1D_PIXEL_LAYOUT_I420;
hdr->ss_hor = hdr->ss_ver = 1;
break;
case 1: hdr->layout = DAV1D_PIXEL_LAYOUT_I444;
hdr->ss_hor = hdr->ss_ver = 0;
break;
case 2:
if (hdr->hbd == 2) {
hdr->ss_hor = dav1d_get_bits(gb, 1);
......@@ -240,6 +246,10 @@ static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb,
hdr->ss_hor = 1;
hdr->ss_ver = 0;
}
hdr->layout = hdr->ss_hor ?
hdr->ss_ver ? DAV1D_PIXEL_LAYOUT_I420 :
DAV1D_PIXEL_LAYOUT_I422 :
DAV1D_PIXEL_LAYOUT_I444;
break;
}
hdr->chr = hdr->ss_hor == 1 && hdr->ss_ver == 1 ?
......
Markdown is supported
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