Commit 331d88d3 authored by James Almer's avatar James Almer

api: add a frame type field to Dav1dPictureParameters

parent 3d7920e6
......@@ -40,6 +40,13 @@ enum Dav1dPixelLayout {
DAV1D_PIXEL_LAYOUT_I444, ///< 4:4:4 planar
};
enum Dav1dFrameType {
DAV1D_FRAME_TYPE_KEY = 0, ///< Key Intra frame
DAV1D_FRAME_TYPE_INTER = 1, ///< Inter frame
DAV1D_FRAME_TYPE_INTRA = 2, ///< Non key Intra frame
DAV1D_FRAME_TYPE_SWITCH = 3, ///< Switch Inter frame
};
enum Dav1dColorPrimaries {
DAV1D_COLOR_PRI_BT709 = 1,
DAV1D_COLOR_PRI_UNKNOWN = 2,
......@@ -103,6 +110,7 @@ typedef struct Dav1dPictureParameters {
int w; ///< width (in pixels)
int h; ///< height (in pixels)
enum Dav1dPixelLayout layout; ///< format of the picture
enum Dav1dFrameType type; ///< type of the picture
int bpc; ///< bits per pixel component (8 or 10)
enum Dav1dColorPrimaries pri; ///< color primaries (av1)
......
......@@ -2779,6 +2779,7 @@ int submit_frame(Dav1dContext *const c) {
}
f->cur.p.poc = f->frame_hdr.frame_offset;
f->cur.p.p.type = f->frame_hdr.frame_type;
f->cur.p.p.pri = f->seq_hdr.pri;
f->cur.p.p.trc = f->seq_hdr.trc;
f->cur.p.p.mtrx = f->seq_hdr.mtrx;
......
......@@ -40,13 +40,6 @@ enum ObuType {
OBU_PADDING = 15,
};
enum FrameType {
KEY_FRAME = 0,
INTER_FRAME = 1,
INTRAONLY_FRAME = 2,
S_FRAME = 3,
} FRAME_TYPE;
enum TxfmSize {
TX_4X4,
TX_8X8,
......@@ -421,7 +414,7 @@ typedef struct Av1FrameHeader {
int show_existing_frame;
int existing_frame_idx;
int frame_id;
enum FrameType frame_type;
enum Dav1dFrameType frame_type;
int show_frame;
int showable_frame;
int error_resilient_mode;
......
......@@ -340,13 +340,13 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
goto end;
}
hdr->frame_type = seqhdr->reduced_still_picture_header ? KEY_FRAME : get_bits(gb, 2);
hdr->frame_type = seqhdr->reduced_still_picture_header ? DAV1D_FRAME_TYPE_KEY : get_bits(gb, 2);
hdr->show_frame = seqhdr->reduced_still_picture_header || get_bits(gb, 1);
if (!hdr->show_frame)
hdr->showable_frame = get_bits(gb, 1);
hdr->error_resilient_mode =
(hdr->frame_type == KEY_FRAME && hdr->show_frame) ||
hdr->frame_type == S_FRAME ||
(hdr->frame_type == DAV1D_FRAME_TYPE_KEY && hdr->show_frame) ||
hdr->frame_type == DAV1D_FRAME_TYPE_SWITCH ||
seqhdr->reduced_still_picture_header || get_bits(gb, 1);
#if DEBUG_FRAME_HDR
printf("HDR: post-frametype_bits: off=%ld\n",
......@@ -363,7 +363,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
hdr->frame_id = get_bits(gb, seqhdr->frame_id_n_bits);
hdr->frame_size_override = seqhdr->reduced_still_picture_header ? 0 :
hdr->frame_type == S_FRAME ? 1 : get_bits(gb, 1);
hdr->frame_type == DAV1D_FRAME_TYPE_SWITCH ? 1 : get_bits(gb, 1);
#if DEBUG_FRAME_HDR
printf("HDR: post-frame_size_override_flag: off=%ld\n",
(gb->ptr - init_ptr) * 8 - gb->bits_left);
......@@ -373,7 +373,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
hdr->primary_ref_frame = !hdr->error_resilient_mode && hdr->frame_type & 1 ?
get_bits(gb, 3) : PRIMARY_REF_NONE;
if (hdr->frame_type == KEY_FRAME) {
if (hdr->frame_type == DAV1D_FRAME_TYPE_KEY) {
hdr->refresh_frame_flags = hdr->show_frame ? 0xff : get_bits(gb, 8);
if ((res = read_frame_size(c, gb, 0)) < 0) goto error;
hdr->allow_intrabc = hdr->allow_screen_content_tools &&
......@@ -384,14 +384,14 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
for (int i = 0; i < 8; i++)
get_bits(gb, seqhdr->order_hint_n_bits);
if (hdr->frame_type == INTRAONLY_FRAME) {
if (hdr->frame_type == DAV1D_FRAME_TYPE_INTRA) {
hdr->refresh_frame_flags = get_bits(gb, 8);
if ((res = read_frame_size(c, gb, 0)) < 0) goto error;
hdr->allow_intrabc = hdr->allow_screen_content_tools &&
/* FIXME: no superres scaling && */ get_bits(gb, 1);
} else {
hdr->allow_intrabc = 0;
hdr->refresh_frame_flags = hdr->frame_type == S_FRAME ? 0xff :
hdr->refresh_frame_flags = hdr->frame_type == DAV1D_FRAME_TYPE_SWITCH ? 0xff :
get_bits(gb, 8);
hdr->frame_ref_short_signaling =
seqhdr->order_hint && get_bits(gb, 1);
......@@ -867,7 +867,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
get_bits(gb, 1);
if (hdr->film_grain.present) {
hdr->film_grain.seed = get_bits(gb, 16);
hdr->film_grain.update = hdr->frame_type != INTER_FRAME || get_bits(gb, 1);
hdr->film_grain.update = hdr->frame_type != DAV1D_FRAME_TYPE_INTER || get_bits(gb, 1);
if (!hdr->film_grain.update) {
const int refidx = get_bits(gb, 3);
int i;
......
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