avcodec/libaomenc: export the Sequence Header OBU as extradata
Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
97c9a50844
commit
04e8b8b053
8
configure
vendored
8
configure
vendored
@ -4664,7 +4664,13 @@ enabled cuvid && require cuvid cuviddec.h cuvidCreateDecoder -lnvcuv
|
|||||||
enabled frei0r && require_headers frei0r.h
|
enabled frei0r && require_headers frei0r.h
|
||||||
enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init &&
|
enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init &&
|
||||||
check_lib gmp gmp.h mpz_export -lgmp
|
check_lib gmp gmp.h mpz_export -lgmp
|
||||||
enabled libaom && require_pkg_config libaom "aom >= 0.1.0" aom/aom_codec.h aom_codec_version
|
enabled libaom && {
|
||||||
|
enabled libaom_av1_decoder && require_pkg_config libaom_av1_decoder "aom >= 1.0.0" "aom/aom_decoder.h aom/aomdx.h" aom_codec_av1_dx
|
||||||
|
enabled libaom_av1_encoder && {
|
||||||
|
require_pkg_config libaom_av1_encoder "aom >= 1.0.0" "aom/aom_encoder.h aom/aomcx.h" aom_codec_av1_cx &&
|
||||||
|
require_cpp_condition libaom_av1_encoder aom/aom_encoder.h "defined AOM_FRAME_IS_INTRAONLY";
|
||||||
|
}
|
||||||
|
}
|
||||||
enabled libbs2b && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open
|
enabled libbs2b && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open
|
||||||
enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
|
enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
|
||||||
enabled libdcadec && require libdcadec libdcadec/dca_context.h dcadec_context_create -ldcadec
|
enabled libdcadec && require libdcadec libdcadec/dca_context.h dcadec_context_create -ldcadec
|
||||||
|
@ -68,6 +68,8 @@ static const char *const ctlidstr[] = {
|
|||||||
[AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
|
[AOME_SET_CQ_LEVEL] = "AOME_SET_CQ_LEVEL",
|
||||||
[AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
|
[AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
|
||||||
[AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
|
[AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
|
||||||
|
[AV1E_SET_CHROMA_SUBSAMPLING_X] = "AV1E_SET_CHROMA_SUBSAMPLING_X",
|
||||||
|
[AV1E_SET_CHROMA_SUBSAMPLING_Y] = "AV1E_SET_CHROMA_SUBSAMPLING_Y",
|
||||||
};
|
};
|
||||||
|
|
||||||
static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
|
static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
|
||||||
@ -197,7 +199,7 @@ static av_cold int aom_init(AVCodecContext *avctx)
|
|||||||
AOMContext *ctx = avctx->priv_data;
|
AOMContext *ctx = avctx->priv_data;
|
||||||
struct aom_codec_enc_cfg enccfg = { 0 };
|
struct aom_codec_enc_cfg enccfg = { 0 };
|
||||||
AVCPBProperties *cpb_props;
|
AVCPBProperties *cpb_props;
|
||||||
int res;
|
int res, h_shift, v_shift;
|
||||||
const struct aom_codec_iface *iface = &aom_codec_av1_cx_algo;
|
const struct aom_codec_iface *iface = &aom_codec_av1_cx_algo;
|
||||||
|
|
||||||
av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
|
av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
|
||||||
@ -332,6 +334,13 @@ static av_cold int aom_init(AVCodecContext *avctx)
|
|||||||
codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
|
codecctl_int(avctx, AOME_SET_STATIC_THRESHOLD, ctx->static_thresh);
|
||||||
codecctl_int(avctx, AOME_SET_CQ_LEVEL, ctx->crf);
|
codecctl_int(avctx, AOME_SET_CQ_LEVEL, ctx->crf);
|
||||||
|
|
||||||
|
res = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &h_shift, &v_shift);
|
||||||
|
if (res < 0)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
codecctl_int(avctx, AV1E_SET_CHROMA_SUBSAMPLING_X, h_shift);
|
||||||
|
codecctl_int(avctx, AV1E_SET_CHROMA_SUBSAMPLING_Y, v_shift);
|
||||||
|
|
||||||
// provide dummy value to initialize wrapper, values will be updated each _encode()
|
// provide dummy value to initialize wrapper, values will be updated each _encode()
|
||||||
aom_img_wrap(&ctx->rawimg, ff_aom_pixfmt_to_imgfmt(avctx->pix_fmt),
|
aom_img_wrap(&ctx->rawimg, ff_aom_pixfmt_to_imgfmt(avctx->pix_fmt),
|
||||||
avctx->width, avctx->height, 1, (unsigned char *)1);
|
avctx->width, avctx->height, 1, (unsigned char *)1);
|
||||||
@ -340,6 +349,29 @@ static av_cold int aom_init(AVCodecContext *avctx)
|
|||||||
if (!cpb_props)
|
if (!cpb_props)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
|
||||||
|
aom_fixed_buf_t *seq = aom_codec_get_global_headers(&ctx->encoder);
|
||||||
|
if (!seq)
|
||||||
|
return AVERROR_UNKNOWN;
|
||||||
|
|
||||||
|
avctx->extradata = av_malloc(seq->sz + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
if (!avctx->extradata) {
|
||||||
|
free(seq->buf);
|
||||||
|
free(seq);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
avctx->extradata_size = seq->sz;
|
||||||
|
memcpy(avctx->extradata, seq->buf, seq->sz);
|
||||||
|
memset(avctx->extradata + seq->sz, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
|
/* Doxy says: "The caller owns the memory associated with this buffer.
|
||||||
|
* Memory is allocated using malloc(), and should be freed
|
||||||
|
* via call to free()"
|
||||||
|
*/
|
||||||
|
free(seq->buf);
|
||||||
|
free(seq);
|
||||||
|
}
|
||||||
|
|
||||||
if (enccfg.rc_end_usage == AOM_CBR ||
|
if (enccfg.rc_end_usage == AOM_CBR ||
|
||||||
enccfg.g_pass != AOM_RC_ONE_PASS) {
|
enccfg.g_pass != AOM_RC_ONE_PASS) {
|
||||||
cpb_props->max_bitrate = avctx->rc_max_rate;
|
cpb_props->max_bitrate = avctx->rc_max_rate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user