ref: 041f653545a5c6b677c1f099e9f98634c2cb1601
parent: 513dfa990804496780a7fa9ee0707b84e1976c13
author: James Almer <jamrial@gmail.com>
date: Sun Nov 25 14:14:42 EST 2018
Put layout back in Dav1dSequenceHeader This partially reverts commit b6bb8536ad299d52a5ff49a4f0317b923ce6b8bb. 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 <jamrial@gmail.com>
--- a/include/dav1d/headers.h
+++ b/include/dav1d/headers.h
@@ -173,6 +173,7 @@
* 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)
--- a/src/decode.c
+++ b/src/decode.c
@@ -3003,10 +3003,6 @@
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 @@
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 @@
// 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;
--- a/src/obu.c
+++ b/src/obu.c
@@ -216,6 +216,7 @@
}
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 @@
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 @@
} 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 @@
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 ?