1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

Merge commit '11c9bd633f635f07a762be1ecd672de55daf4edc'

* commit '11c9bd633f635f07a762be1ecd672de55daf4edc':
  libopenh264enc: export CPB props side data

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
Hendrik Leppkes 2015-12-17 13:31:21 +01:00
commit f49264a1c5
3 changed files with 40 additions and 0 deletions

View File

@ -323,6 +323,11 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
*/
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame);
/**
* Add a CPB properties side data to an encoding context.
*/
AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx);
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type);
#endif /* AVCODEC_INTERNAL_H */

View File

@ -108,6 +108,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
int err = AVERROR_UNKNOWN;
int log_level;
WelsTraceCallback callback_function;
AVCPBProperties *props;
// Mingw GCC < 4.7 on x86_32 uses an incorrect/buggy ABI for the WelsGetCodecVersion
// function (for functions returning larger structs), thus skip the check in those
@ -223,6 +224,14 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
memcpy(avctx->extradata, fbi.sLayerInfo[0].pBsBuf, size);
}
props = ff_add_cpb_side_data(avctx);
if (!props) {
err = AVERROR(ENOMEM);
goto fail;
}
props->max_bitrate = param.iMaxBitrate;
props->avg_bitrate = param.iTargetBitrate;
return 0;
fail:

View File

@ -3502,3 +3502,29 @@ AVCPBProperties *av_cpb_properties_alloc(size_t *size)
return props;
}
AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx)
{
AVPacketSideData *tmp;
AVCPBProperties *props;
size_t size;
props = av_cpb_properties_alloc(&size);
if (!props)
return NULL;
tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp));
if (!tmp) {
av_freep(&props);
return NULL;
}
avctx->coded_side_data = tmp;
avctx->nb_coded_side_data++;
avctx->coded_side_data[avctx->nb_coded_side_data - 1].type = AV_PKT_DATA_CPB_PROPERTIES;
avctx->coded_side_data[avctx->nb_coded_side_data - 1].data = (uint8_t*)props;
avctx->coded_side_data[avctx->nb_coded_side_data - 1].size = size;
return props;
}