Commit 951b0c98 authored by Janne Grunau's avatar Janne Grunau

scalable: output only frames of the highest selected spatial layer

Fixes #188.
parent 3a4445bd
......@@ -144,6 +144,7 @@ typedef struct Dav1dPictureParameters {
int fullrange;
Dav1dFilmGrainData film_grain; ///< film grain parameters
int spatial_id; ///< spatial id of the frame for scalable AV1
} Dav1dPictureParameters;
typedef struct Dav1dPicture {
......
......@@ -3111,6 +3111,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
f->sr_cur.p.p.chr = f->seq_hdr.chr;
f->sr_cur.p.p.fullrange = f->seq_hdr.color_range;
f->sr_cur.p.m = f->tile[0].data.m;
f->sr_cur.p.p.spatial_id = f->frame_hdr.spatial_id;
if (f->frame_hdr.super_res.enabled) {
res = dav1d_picture_alloc_copy(&f->cur, f->frame_hdr.width[0], &f->sr_cur.p);
......
......@@ -487,6 +487,7 @@ typedef struct Av1FrameHeader {
int present, update;
Dav1dFilmGrainData data;
} film_grain;
int temporal_id, spatial_id;
} Av1FrameHeader;
#define QINDEX_RANGE 256
......
......@@ -186,6 +186,15 @@ static int output_image(Dav1dContext *const c, Dav1dPicture *const out,
int has_grain = fgdata->num_y_points || fgdata->num_uv_points[0] ||
fgdata->num_uv_points[1];
// skip lower spatial layers
if (c->operating_point_idc && !c->all_layers) {
const int max_spatial_id = ulog2(c->operating_point_idc >> 8);
if (max_spatial_id > in->p.spatial_id) {
dav1d_picture_unref(in);
return 0;
}
}
// If there is nothing to be done, skip the allocation/copy
if (!c->apply_grain || !has_grain) {
dav1d_picture_move_ref(out, in);
......
......@@ -1150,7 +1150,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
const int has_length_field = dav1d_get_bits(&gb, 1);
dav1d_get_bits(&gb, 1); // reserved
int temporal_id, spatial_id;
int temporal_id = 0, spatial_id = 0;
if (has_extension) {
temporal_id = dav1d_get_bits(&gb, 3);
spatial_id = dav1d_get_bits(&gb, 2);
......@@ -1234,6 +1234,8 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
case OBU_FRAME_HDR:
c->have_frame_hdr = 0;
if (!c->have_seq_hdr) goto error;
c->frame_hdr.temporal_id = temporal_id;
c->frame_hdr.spatial_id = spatial_id;
if ((res = parse_frame_hdr(c, &gb)) < 0)
return res;
for (int n = 0; n < c->n_tile_data; n++)
......
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