From f37dcd5879d4308151b3d09eaa902f53f49faef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Wed, 14 Feb 2018 15:08:40 +0200 Subject: [PATCH] Move GOP definition to a separate file Moves definition of the 8-GOP from cfg.c to gop.h. --- src/cfg.c | 35 ++-------------- src/gop.h | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 32 deletions(-) create mode 100644 src/gop.h diff --git a/src/cfg.c b/src/cfg.c index d044a124..0bf1d9e4 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -19,6 +19,7 @@ ****************************************************************************/ #include "cfg.h" +#include "gop.h" #include #include @@ -938,39 +939,9 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) cfg->gop_lp_definition.t = gop.t; } else if (atoi(value) == 8) { cfg->gop_lowdelay = 0; - // GOP - cfg->gop_len = 8; - cfg->gop[0].poc_offset = 8; cfg->gop[0].qp_offset = 1; cfg->gop[0].layer = 1; cfg->gop[0].qp_factor = 0.442; cfg->gop[0].is_ref = 1; - cfg->gop[0].ref_pos_count = 0; - cfg->gop[0].ref_neg_count = 3; cfg->gop[0].ref_neg[0] = 8; cfg->gop[0].ref_neg[1] = 12; cfg->gop[0].ref_neg[2] = 16; + cfg->gop_len = sizeof(kvz_gop_ra8) / sizeof(kvz_gop_ra8[0]); + memcpy(cfg->gop, kvz_gop_ra8, sizeof(kvz_gop_ra8)); - cfg->gop[1].poc_offset = 4; cfg->gop[1].qp_offset = 2; cfg->gop[1].layer = 2; cfg->gop[1].qp_factor = 0.3536; cfg->gop[1].is_ref = 1; - cfg->gop[1].ref_neg_count = 2; cfg->gop[1].ref_neg[0] = 4; cfg->gop[1].ref_neg[1] = 8; - cfg->gop[1].ref_pos_count = 1; cfg->gop[1].ref_pos[0] = 4; - - cfg->gop[2].poc_offset = 2; cfg->gop[2].qp_offset = 3; cfg->gop[2].layer = 3; cfg->gop[2].qp_factor = 0.3536; cfg->gop[2].is_ref = 1; - cfg->gop[2].ref_neg_count = 2; cfg->gop[2].ref_neg[0] = 2; cfg->gop[2].ref_neg[1] = 6; - cfg->gop[2].ref_pos_count = 2; cfg->gop[2].ref_pos[0] = 2; cfg->gop[2].ref_pos[1] = 6; - - cfg->gop[3].poc_offset = 1; cfg->gop[3].qp_offset = 4; cfg->gop[3].layer = 4; cfg->gop[3].qp_factor = 0.68; cfg->gop[3].is_ref = 0; - cfg->gop[3].ref_neg_count = 1; cfg->gop[3].ref_neg[0] = 1; - cfg->gop[3].ref_pos_count = 3; cfg->gop[3].ref_pos[0] = 1; cfg->gop[3].ref_pos[1] = 3; cfg->gop[3].ref_pos[2] = 7; - - cfg->gop[4].poc_offset = 3; cfg->gop[4].qp_offset = 4; cfg->gop[4].layer = 4; cfg->gop[4].qp_factor = 0.68; cfg->gop[4].is_ref = 0; - cfg->gop[4].ref_neg_count = 2; cfg->gop[4].ref_neg[0] = 1; cfg->gop[4].ref_neg[1] = 3; - cfg->gop[4].ref_pos_count = 2; cfg->gop[4].ref_pos[0] = 1; cfg->gop[4].ref_pos[1] = 5; - - cfg->gop[5].poc_offset = 6; cfg->gop[5].qp_offset = 3; cfg->gop[5].layer = 3; cfg->gop[5].qp_factor = 0.3536; cfg->gop[5].is_ref = 1; - cfg->gop[5].ref_neg_count = 2; cfg->gop[5].ref_neg[0] = 2; cfg->gop[5].ref_neg[1] = 6; - cfg->gop[5].ref_pos_count = 1; cfg->gop[5].ref_pos[0] = 2; - - cfg->gop[6].poc_offset = 5; cfg->gop[6].qp_offset = 4; cfg->gop[6].layer = 4; cfg->gop[6].qp_factor = 0.68; cfg->gop[6].is_ref = 0; - cfg->gop[6].ref_neg_count = 2; cfg->gop[6].ref_neg[0] = 1; cfg->gop[6].ref_neg[1] = 5; - cfg->gop[6].ref_pos_count = 2; cfg->gop[6].ref_pos[0] = 1; cfg->gop[6].ref_pos[1] = 3; - - cfg->gop[7].poc_offset = 7; cfg->gop[7].qp_offset = 4; cfg->gop[7].layer = 4; cfg->gop[7].qp_factor = 0.68; cfg->gop[7].is_ref = 0; - cfg->gop[7].ref_neg_count = 3; cfg->gop[7].ref_neg[0] = 1; cfg->gop[7].ref_neg[1] = 3; cfg->gop[7].ref_neg[2] = 7; - cfg->gop[7].ref_pos_count = 1; cfg->gop[7].ref_pos[0] = 1; } else if (atoi(value) == 0) { //Disable gop cfg->gop_len = 0; diff --git a/src/gop.h b/src/gop.h new file mode 100644 index 00000000..97cc4379 --- /dev/null +++ b/src/gop.h @@ -0,0 +1,117 @@ +#ifndef GOP_H_ +#define GOP_H_ +/***************************************************************************** +* This file is part of Kvazaar HEVC encoder. +* +* Copyright (C) 2018 Tampere University of Technology and others (see +* COPYING file). +* +* Kvazaar is free software: you can redistribute it and/or modify it under +* the terms of the GNU Lesser General Public License as published by the +* Free Software Foundation; either version 2.1 of the License, or (at your +* option) any later version. +* +* Kvazaar is distributed in the hope that it will be useful, but WITHOUT ANY +* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along +* with Kvazaar. If not, see . +****************************************************************************/ + +#include + + +static const kvz_gop_config kvz_gop_ra8[8] = { + { + .poc_offset = 8, + .layer = 1, + .qp_offset = 1, + .qp_factor = 0.442, + .is_ref = 1, + .ref_neg_count = 3, + .ref_neg = { 8, 12, 16 }, + .ref_pos_count = 0, + .ref_pos = { 0 }, + }, + { + .poc_offset = 4, + .layer = 2, + .qp_offset = 2, + .qp_factor = 0.3536, + .is_ref = 1, + .ref_neg_count = 2, + .ref_neg = { 4, 8 }, + .ref_pos_count = 1, + .ref_pos = { 4 }, + }, + { + .poc_offset = 2, + .layer = 3, + .qp_offset = 3, + .qp_factor = 0.3536, + .is_ref = 1, + .ref_neg_count = 2, + .ref_neg = { 2, 6 }, + .ref_pos_count = 2, + .ref_pos = { 2, 6 }, + }, + { + .poc_offset = 1, + .layer = 4, + .qp_offset = 4, + .qp_factor = 0.68, + .is_ref = 0, + .ref_neg_count = 1, + .ref_neg = { 1 }, + .ref_pos_count = 3, + .ref_pos = { 1, 3, 7 }, + }, + { + .poc_offset = 3, + .layer = 4, + .qp_offset = 4, + .qp_factor = 0.68, + .is_ref = 0, + .ref_neg_count = 2, + .ref_neg = { 1, 3 }, + .ref_pos_count = 2, + .ref_pos = { 1, 5 }, + }, + { + .poc_offset = 6, + .layer = 3, + .qp_offset = 3, + .qp_factor = 0.3536, + .is_ref = 1, + .ref_neg_count = 2, + .ref_neg = { 2, 6 }, + .ref_pos_count = 1, + .ref_pos = { 2 }, + }, + { + .poc_offset = 5, + .layer = 4, + .qp_offset = 4, + .qp_factor = 0.68, + .is_ref = 0, + .ref_neg_count = 2, + .ref_neg = { 1, 5 }, + .ref_pos_count = 2, + .ref_pos = { 1, 3 }, + }, + { + .poc_offset = 7, + .layer = 4, + .qp_offset = 4, + .qp_factor = 0.68, + .is_ref = 0, + .ref_neg_count = 3, + .ref_neg = { 1, 3, 7 }, + .ref_pos_count = 1, + .ref_pos = { 1 }, + }, +}; + +#endif // GOP_H_