2014-01-24 10:37:15 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* This file is part of Kvazaar HEVC encoder.
|
2014-02-21 13:00:20 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 Tampere University of Technology and others (see
|
2014-01-24 10:37:15 +00:00
|
|
|
* COPYING file).
|
|
|
|
*
|
|
|
|
* Kvazaar is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* \file
|
2012-05-30 12:10:23 +00:00
|
|
|
*/
|
|
|
|
|
2013-09-18 09:16:03 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-05-30 12:10:23 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2014-02-03 20:58:23 +00:00
|
|
|
#include "extras/getopt.h"
|
2012-05-30 12:10:23 +00:00
|
|
|
|
2013-09-19 08:28:58 +00:00
|
|
|
/**
|
|
|
|
* \brief Allocate memory for config object
|
|
|
|
* \return pointer to allocated memory
|
|
|
|
*/
|
2014-02-21 12:51:39 +00:00
|
|
|
config *config_alloc(void)
|
2012-05-30 12:10:23 +00:00
|
|
|
{
|
2013-09-19 08:28:58 +00:00
|
|
|
config *cfg = (config *)malloc(sizeof(config));
|
2014-01-31 15:30:27 +00:00
|
|
|
if (!cfg) {
|
|
|
|
fprintf(stderr, "Failed to allocate a config object!\n");
|
|
|
|
return cfg;
|
|
|
|
}
|
|
|
|
|
2012-05-30 12:10:23 +00:00
|
|
|
memset(cfg, 0, sizeof(config));
|
|
|
|
return cfg;
|
|
|
|
}
|
|
|
|
|
2013-09-19 08:28:58 +00:00
|
|
|
/**
|
|
|
|
* \brief Initialize config structure
|
|
|
|
* \param cfg config object
|
|
|
|
* \return 1 on success, 0 on failure
|
|
|
|
*/
|
|
|
|
int config_init(config *cfg)
|
2014-02-21 13:00:20 +00:00
|
|
|
{
|
2014-02-06 19:45:37 +00:00
|
|
|
cfg->input = NULL;
|
|
|
|
cfg->output = NULL;
|
|
|
|
cfg->debug = NULL;
|
|
|
|
cfg->frames = 0;
|
2014-03-10 13:53:23 +00:00
|
|
|
cfg->width = 0;
|
|
|
|
cfg->height = 0;
|
2014-02-06 19:45:37 +00:00
|
|
|
cfg->qp = 32;
|
|
|
|
cfg->intra_period = 0;
|
|
|
|
cfg->deblock_enable = 1;
|
|
|
|
cfg->deblock_beta = 0;
|
|
|
|
cfg->deblock_tc = 0;
|
|
|
|
cfg->sao_enable = 1;
|
2014-03-05 14:56:00 +00:00
|
|
|
cfg->rdoq_enable = 1;
|
2014-04-07 11:36:01 +00:00
|
|
|
cfg->rdo = 1;
|
2014-04-02 11:41:40 +00:00
|
|
|
cfg->trskip_enable = 1;
|
2014-02-06 19:45:37 +00:00
|
|
|
cfg->vui.sar_width = 0;
|
|
|
|
cfg->vui.sar_height = 0;
|
|
|
|
cfg->vui.overscan = 0; /* undef */
|
|
|
|
cfg->vui.videoformat = 5; /* undef */
|
|
|
|
cfg->vui.fullrange = 0; /* limited range */
|
|
|
|
cfg->vui.colorprim = 2; /* undef */
|
|
|
|
cfg->vui.transfer = 2; /* undef */
|
|
|
|
cfg->vui.colormatrix = 2; /* undef */
|
|
|
|
cfg->vui.chroma_loc = 0; /* left center */
|
2014-02-06 22:35:15 +00:00
|
|
|
cfg->aud_enable = 0;
|
config: Add --cqmfile to use custom quantization matrices from a file.
The coefficients in a matrix are stored in up-right diagonal order.
The following indicates the default matrices specified in the spec.
INTRA4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA8X8_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER8X8_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER16X16_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA32X32_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER32X32_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA_DC
16
INTRA16X16_CHROMAU_DC
16
INTRA16X16_CHROMAV_DC
16
INTER16X16_LUMA_DC
16
INTER16X16_CHROMAU_DC
16
INTER16X16_CHROMAV_DC
16
INTRA32X32_LUMA_DC
16
INTER32X32_LUMA_DC
16
2014-02-11 10:55:21 +00:00
|
|
|
cfg->cqmfile = NULL;
|
2014-02-19 13:09:17 +00:00
|
|
|
cfg->ref_frames = DEFAULT_REF_PIC_COUNT;
|
2014-03-10 12:58:57 +00:00
|
|
|
cfg->seek = 0;
|
2012-05-30 12:10:23 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-09-19 08:28:58 +00:00
|
|
|
/**
|
|
|
|
* \brief Free memory allocated to the config
|
|
|
|
* \param cfg config object
|
|
|
|
* \return 1 on success, 0 on failure
|
|
|
|
*/
|
|
|
|
int config_destroy(config *cfg)
|
2012-05-30 12:10:23 +00:00
|
|
|
{
|
2013-09-18 11:50:43 +00:00
|
|
|
FREE_POINTER(cfg->input);
|
|
|
|
FREE_POINTER(cfg->output);
|
config: Add --cqmfile to use custom quantization matrices from a file.
The coefficients in a matrix are stored in up-right diagonal order.
The following indicates the default matrices specified in the spec.
INTRA4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA8X8_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER8X8_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER16X16_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA32X32_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER32X32_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA_DC
16
INTRA16X16_CHROMAU_DC
16
INTRA16X16_CHROMAV_DC
16
INTER16X16_LUMA_DC
16
INTER16X16_CHROMAU_DC
16
INTER16X16_CHROMAV_DC
16
INTRA32X32_LUMA_DC
16
INTER32X32_LUMA_DC
16
2014-02-11 10:55:21 +00:00
|
|
|
FREE_POINTER(cfg->cqmfile);
|
2012-05-30 12:10:23 +00:00
|
|
|
free(cfg);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-01-31 15:24:04 +00:00
|
|
|
/**
|
|
|
|
* \brief Allocates memory space for a string, and copies it
|
|
|
|
* \param char * string to copy
|
|
|
|
* \return a pointer to the copied string on success, null on failure
|
|
|
|
*/
|
2014-02-21 12:52:49 +00:00
|
|
|
static char *copy_string(const char *string)
|
2014-01-31 15:24:04 +00:00
|
|
|
{
|
|
|
|
// Allocate +1 for \0
|
|
|
|
char *allocated_string = (char *)malloc(strlen(string) + 1);
|
|
|
|
if (!allocated_string) {
|
|
|
|
fprintf(stderr, "Failed to allocate a string!\n");
|
|
|
|
return allocated_string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the string to the new buffer
|
|
|
|
memcpy(allocated_string, string, strlen(string) + 1);
|
|
|
|
|
|
|
|
return allocated_string;
|
|
|
|
}
|
|
|
|
|
2014-02-03 22:16:42 +00:00
|
|
|
static int atobool(const char *str)
|
|
|
|
{
|
|
|
|
if (!strcmp(str, "1") ||
|
|
|
|
!strcmp(str, "true") ||
|
|
|
|
!strcmp(str, "yes"))
|
|
|
|
return 1;
|
|
|
|
if (!strcmp(str, "0") ||
|
|
|
|
!strcmp(str, "false") ||
|
|
|
|
!strcmp(str, "no"))
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-06 19:45:37 +00:00
|
|
|
static int parse_enum(const char *arg, const char * const *names, int8_t *dst)
|
|
|
|
{
|
2014-02-21 13:15:59 +00:00
|
|
|
int8_t i;
|
|
|
|
for (i = 0; names[i]; i++) {
|
2014-02-06 19:45:37 +00:00
|
|
|
if (!strcmp(arg, names[i])) {
|
|
|
|
*dst = i;
|
|
|
|
return 1;
|
|
|
|
}
|
2014-02-21 13:15:59 +00:00
|
|
|
}
|
2014-02-06 19:45:37 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-03 20:58:23 +00:00
|
|
|
static int config_parse(config *cfg, const char *name, const char *value)
|
|
|
|
{
|
2014-02-06 19:45:37 +00:00
|
|
|
static const char * const overscan_names[] = { "undef", "show", "crop", NULL };
|
|
|
|
static const char * const videoformat_names[] = { "component", "pal", "ntsc", "secam", "mac", "undef", NULL };
|
2014-02-08 02:29:50 +00:00
|
|
|
static const char * const range_names[] = { "tv", "pc", NULL };
|
2014-02-06 19:45:37 +00:00
|
|
|
static const char * const colorprim_names[] = { "", "bt709", "undef", "", "bt470m", "bt470bg", "smpte170m",
|
|
|
|
"smpte240m", "film", "bt2020", NULL };
|
|
|
|
static const char * const transfer_names[] = { "", "bt709", "undef", "", "bt470m", "bt470bg", "smpte170m",
|
|
|
|
"smpte240m", "linear", "log100", "log316", "iec61966-2-4",
|
|
|
|
"bt1361e", "iec61966-2-1", "bt2020-10", "bt2020-12", NULL };
|
|
|
|
static const char * const colormatrix_names[] = { "GBR", "bt709", "undef", "", "fcc", "bt470bg", "smpte170m",
|
|
|
|
"smpte240m", "YCgCo", "bt2020nc", "bt2020c", NULL };
|
|
|
|
|
|
|
|
int error = 0;
|
2014-02-03 22:16:42 +00:00
|
|
|
|
2014-02-03 20:58:23 +00:00
|
|
|
if (!name)
|
|
|
|
return 0;
|
2014-02-03 22:16:42 +00:00
|
|
|
if (!value)
|
|
|
|
value = "true";
|
|
|
|
|
2014-04-04 08:39:25 +00:00
|
|
|
// Treat "--no-param" as --param 0
|
|
|
|
if ((!strncmp(name, "no-", 3))) {
|
|
|
|
name += 3;
|
2014-02-03 22:16:42 +00:00
|
|
|
value = atobool(value) ? "false" : "true";
|
|
|
|
}
|
2014-02-03 20:58:23 +00:00
|
|
|
|
2014-04-04 09:20:17 +00:00
|
|
|
#define OPT(STR) (!strcmp(name, STR))
|
|
|
|
if OPT("input")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->input = copy_string(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("output")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->output = copy_string(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("debug")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->debug = copy_string(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("width")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->width = atoi(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("height")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->height = atoi(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("input-res") {
|
2014-03-10 13:53:23 +00:00
|
|
|
if (2 != sscanf(value, "%dx%d", &cfg->width, &cfg->height)) {
|
|
|
|
cfg->width = cfg->height = 0;
|
|
|
|
}
|
|
|
|
}
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("frames")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->frames = atoi(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("qp")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->qp = atoi(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("period")
|
2014-02-03 20:58:23 +00:00
|
|
|
cfg->intra_period = atoi(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("ref") {
|
2014-02-18 15:45:54 +00:00
|
|
|
cfg->ref_frames = atoi(value);
|
2014-02-20 09:02:51 +00:00
|
|
|
if (cfg->ref_frames < 1 || cfg->ref_frames >= MAX_REF_PIC_COUNT) {
|
|
|
|
fprintf(stderr, "--ref out of range [1..15], set to 3\n");
|
2014-02-19 13:09:17 +00:00
|
|
|
cfg->ref_frames = 3;
|
2014-02-18 15:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("deblock") {
|
2014-02-03 22:31:24 +00:00
|
|
|
int beta, tc;
|
|
|
|
if (2 == sscanf(value, "%d:%d", &beta, &tc)) {
|
|
|
|
cfg->deblock_enable = 1;
|
|
|
|
cfg->deblock_beta = beta;
|
|
|
|
cfg->deblock_tc = tc;
|
|
|
|
} else if (sscanf(value, "%d", &beta)) {
|
|
|
|
cfg->deblock_enable = 1;
|
|
|
|
cfg->deblock_beta = beta;
|
|
|
|
cfg->deblock_tc = cfg->deblock_beta;
|
|
|
|
} else
|
|
|
|
cfg->deblock_enable = atobool(value);
|
2014-02-06 12:32:30 +00:00
|
|
|
|
|
|
|
if (cfg->deblock_beta < -6 || cfg->deblock_beta > 6) {
|
|
|
|
fprintf(stderr, "--deblock beta parameter out of range [-6..6], set to 0\n");
|
|
|
|
cfg->deblock_beta = 0;
|
|
|
|
}
|
|
|
|
if (cfg->deblock_tc < -6 || cfg->deblock_tc > 6) {
|
|
|
|
fprintf(stderr, "--deblock tc parameter out of range [-6..6], set to 0\n");
|
|
|
|
cfg->deblock_tc = 0;
|
|
|
|
}
|
2014-02-03 22:31:24 +00:00
|
|
|
}
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("sao")
|
2014-02-03 22:55:51 +00:00
|
|
|
cfg->sao_enable = atobool(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("rdoq")
|
2014-03-05 14:56:00 +00:00
|
|
|
cfg->rdoq_enable = atobool(value);
|
2014-04-07 11:36:01 +00:00
|
|
|
else if OPT("rd") {
|
|
|
|
int rdo = 0;
|
|
|
|
if (sscanf(value, "%d", &rdo)) {
|
|
|
|
if(rdo < 0 || rdo > 2) {
|
|
|
|
fprintf(stderr, "--rd parameter out of range [0..2], set to 1\n");
|
|
|
|
rdo = 1;
|
|
|
|
}
|
|
|
|
cfg->rdo = rdo;
|
|
|
|
}
|
|
|
|
}
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("transform-skip")
|
2014-04-02 11:41:40 +00:00
|
|
|
cfg->trskip_enable = atobool(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("sar") {
|
2014-02-06 19:45:37 +00:00
|
|
|
int sar_width, sar_height;
|
|
|
|
if (2 == sscanf(value, "%d:%d", &sar_width, &sar_height)) {
|
|
|
|
cfg->vui.sar_width = sar_width;
|
|
|
|
cfg->vui.sar_height = sar_height;
|
|
|
|
} else
|
|
|
|
error = 1;
|
|
|
|
}
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("overscan")
|
2014-02-06 19:45:37 +00:00
|
|
|
error = !parse_enum(value, overscan_names, &cfg->vui.overscan);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("videoformat")
|
2014-02-06 19:45:37 +00:00
|
|
|
error = !parse_enum(value, videoformat_names, &cfg->vui.videoformat);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("range")
|
2014-02-08 02:29:50 +00:00
|
|
|
error = !parse_enum(value, range_names, &cfg->vui.fullrange);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("colorprim")
|
2014-02-06 19:45:37 +00:00
|
|
|
error = !parse_enum(value, colorprim_names, &cfg->vui.colorprim);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("transfer")
|
2014-02-06 19:45:37 +00:00
|
|
|
error = !parse_enum(value, transfer_names, &cfg->vui.transfer);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("colormatrix")
|
2014-02-06 19:45:37 +00:00
|
|
|
error = !parse_enum(value, colormatrix_names, &cfg->vui.colormatrix);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("chromaloc") {
|
2014-02-06 19:45:37 +00:00
|
|
|
cfg->vui.chroma_loc = atoi(value);
|
|
|
|
if (cfg->vui.chroma_loc < 0 || cfg->vui.chroma_loc > 5) {
|
|
|
|
fprintf(stderr, "--chromaloc parameter out of range [0..5], set to 0\n");
|
|
|
|
cfg->vui.chroma_loc = 0;
|
|
|
|
}
|
|
|
|
}
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("aud")
|
2014-02-06 22:35:15 +00:00
|
|
|
cfg->aud_enable = atobool(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("cqmfile")
|
config: Add --cqmfile to use custom quantization matrices from a file.
The coefficients in a matrix are stored in up-right diagonal order.
The following indicates the default matrices specified in the spec.
INTRA4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA8X8_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER8X8_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER16X16_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA32X32_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER32X32_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA_DC
16
INTRA16X16_CHROMAU_DC
16
INTRA16X16_CHROMAV_DC
16
INTER16X16_LUMA_DC
16
INTER16X16_CHROMAU_DC
16
INTER16X16_CHROMAV_DC
16
INTRA32X32_LUMA_DC
16
INTER32X32_LUMA_DC
16
2014-02-11 10:55:21 +00:00
|
|
|
cfg->cqmfile = copy_string(value);
|
2014-04-04 09:20:17 +00:00
|
|
|
else if OPT("seek")
|
2014-03-10 12:58:57 +00:00
|
|
|
cfg->seek = atoi(value);
|
2014-02-03 20:58:23 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
#undef OPT
|
|
|
|
|
2014-02-06 19:45:37 +00:00
|
|
|
return error ? 0 : 1;
|
2014-02-03 20:58:23 +00:00
|
|
|
}
|
|
|
|
|
2013-09-19 08:28:58 +00:00
|
|
|
/**
|
|
|
|
* \brief Read configuration options from argv to the config struct
|
|
|
|
* \param cfg config object
|
|
|
|
* \param argc argument count
|
|
|
|
* \param argv argument list
|
|
|
|
* \return 1 on success, 0 on failure
|
|
|
|
*/
|
|
|
|
int config_read(config *cfg,int argc, char *argv[])
|
2012-05-30 12:10:23 +00:00
|
|
|
{
|
2014-02-18 15:45:54 +00:00
|
|
|
static char short_options[] = "i:o:d:w:h:n:q:p:r:";
|
2014-02-03 20:58:23 +00:00
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
|
|
|
{ "input", required_argument, NULL, 'i' },
|
|
|
|
{ "output", required_argument, NULL, 'o' },
|
|
|
|
{ "debug", required_argument, NULL, 'd' },
|
|
|
|
{ "width", required_argument, NULL, 'w' },
|
2014-03-10 13:53:23 +00:00
|
|
|
{ "height", required_argument, NULL, 'h' }, // deprecated
|
|
|
|
{ "frames", required_argument, NULL, 'n' }, // deprecated
|
2014-02-03 20:58:23 +00:00
|
|
|
{ "qp", required_argument, NULL, 'q' },
|
|
|
|
{ "period", required_argument, NULL, 'p' },
|
2014-02-18 15:45:54 +00:00
|
|
|
{ "ref", required_argument, NULL, 'r' },
|
2014-03-10 13:53:23 +00:00
|
|
|
{ "input-res", required_argument, NULL, 0 },
|
2014-02-03 22:16:42 +00:00
|
|
|
{ "no-deblock", no_argument, NULL, 0 },
|
2014-02-03 22:31:24 +00:00
|
|
|
{ "deblock", required_argument, NULL, 0 },
|
2014-02-03 22:55:51 +00:00
|
|
|
{ "no-sao", no_argument, NULL, 0 },
|
2014-03-05 14:56:00 +00:00
|
|
|
{ "no-rdoq", no_argument, NULL, 0 },
|
2014-04-07 11:36:01 +00:00
|
|
|
{ "rd", required_argument, NULL, 0 },
|
2014-04-02 11:41:40 +00:00
|
|
|
{ "no-transform-skip", no_argument, NULL, 0 },
|
2014-02-06 19:45:37 +00:00
|
|
|
{ "sar", required_argument, NULL, 0 },
|
|
|
|
{ "overscan", required_argument, NULL, 0 },
|
|
|
|
{ "videoformat", required_argument, NULL, 0 },
|
|
|
|
{ "range", required_argument, NULL, 0 },
|
|
|
|
{ "colorprim", required_argument, NULL, 0 },
|
|
|
|
{ "transfer", required_argument, NULL, 0 },
|
|
|
|
{ "colormatrix", required_argument, NULL, 0 },
|
|
|
|
{ "chromaloc", required_argument, NULL, 0 },
|
2014-02-06 22:35:15 +00:00
|
|
|
{ "aud", no_argument, NULL, 0 },
|
config: Add --cqmfile to use custom quantization matrices from a file.
The coefficients in a matrix are stored in up-right diagonal order.
The following indicates the default matrices specified in the spec.
INTRA4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_LUMA
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAU
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTER4X4_CHROMAV
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16,
16, 16, 16, 16
INTRA8X8_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA8X8_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER8X8_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER8X8_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAU
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTRA16X16_CHROMAV
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER16X16_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAU
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTER16X16_CHROMAV
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA32X32_LUMA
16, 16, 16, 16, 17, 18, 21, 24,
16, 16, 16, 16, 17, 19, 22, 25,
16, 16, 17, 18, 20, 22, 25, 29,
16, 16, 18, 21, 24, 27, 31, 36,
17, 17, 20, 24, 30, 35, 41, 47,
18, 19, 22, 27, 35, 44, 54, 65,
21, 22, 25, 31, 41, 54, 70, 88,
24, 25, 29, 36, 47, 65, 88, 115
INTER32X32_LUMA
16, 16, 16, 16, 17, 18, 20, 24,
16, 16, 16, 17, 18, 20, 24, 25,
16, 16, 17, 18, 20, 24, 25, 28,
16, 17, 18, 20, 24, 25, 28, 33,
17, 18, 20, 24, 25, 28, 33, 41,
18, 20, 24, 25, 28, 33, 41, 54,
20, 24, 25, 28, 33, 41, 54, 71,
24, 25, 28, 33, 41, 54, 71, 91
INTRA16X16_LUMA_DC
16
INTRA16X16_CHROMAU_DC
16
INTRA16X16_CHROMAV_DC
16
INTER16X16_LUMA_DC
16
INTER16X16_CHROMAU_DC
16
INTER16X16_CHROMAV_DC
16
INTRA32X32_LUMA_DC
16
INTER32X32_LUMA_DC
16
2014-02-11 10:55:21 +00:00
|
|
|
{ "cqmfile", required_argument, NULL, 0 },
|
2014-03-10 12:58:57 +00:00
|
|
|
{ "seek", required_argument, NULL, 0 },
|
2014-02-03 20:58:23 +00:00
|
|
|
{0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Parse command line options
|
|
|
|
for (optind = 0;;) {
|
|
|
|
int long_options_index = -1;
|
|
|
|
|
|
|
|
int c = getopt_long(argc, argv, short_options, long_options, &long_options_index);
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (long_options_index < 0) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; long_options[i].name; i++)
|
|
|
|
if (long_options[i].val == c) {
|
|
|
|
long_options_index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (long_options_index < 0) {
|
|
|
|
// getopt_long already printed an error message
|
|
|
|
return 0;
|
2012-05-30 12:10:23 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-03 20:58:23 +00:00
|
|
|
|
|
|
|
if (!config_parse(cfg, long_options[long_options_index].name, optarg)) {
|
|
|
|
const char *name = long_options_index > 0 ? long_options[long_options_index].name : argv[optind-2];
|
|
|
|
fprintf(stderr, "invalid argument: %s = %s\r\n", name, optarg );
|
|
|
|
return 0;
|
|
|
|
}
|
2012-05-30 12:10:23 +00:00
|
|
|
}
|
2014-02-21 13:00:20 +00:00
|
|
|
|
2013-09-19 08:28:58 +00:00
|
|
|
// Check that the required files were defined
|
2014-02-21 13:00:20 +00:00
|
|
|
if(cfg->input == NULL || cfg->output == NULL) return 0;
|
|
|
|
|
2012-05-30 12:10:23 +00:00
|
|
|
return 1;
|
2014-02-03 14:32:54 +00:00
|
|
|
}
|
2014-03-10 13:53:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief A function that does additional checks after config_init.
|
|
|
|
*
|
|
|
|
* Add checks that don't make sense to have in config_init here.
|
|
|
|
* This should be called when cfg is in it's final state.
|
|
|
|
*
|
|
|
|
* \return 0 if config fails, otherwise 1.
|
|
|
|
*/
|
|
|
|
int config_validate(config *cfg)
|
|
|
|
{
|
|
|
|
if (cfg->width == 0 || cfg->height == 0) {
|
|
|
|
fprintf(stderr, "Input error: one of the dimensions is 0: dims=%dx%d", cfg->width, cfg->height);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|