From c40ecffd31d0e0be531425e48a98c1a8fcaaffa2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 21 Jul 2015 13:23:29 +0200 Subject: Replace AV_PKT_DATA_QUALITY_FACTOR by AV_PKT_DATA_QUALITY_STATS The stats are a superset of the quality factor, also allowing the picture type and encoder "PSNR" stats to be exported This also replaces the native by fixed little endian order for the affected side data AV_PKT_DATA_QUALITY_FACTOR is left as a synonym of AV_PKT_DATA_QUALITY_STATS Signed-off-by: Michael Niedermayer --- libavcodec/avpacket.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libavcodec/avpacket.c') diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index aae67c5a00..6ba9c0bc5e 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -602,3 +602,28 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb) if (pkt->convergence_duration > 0) pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb); } + +int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) +{ + uint8_t *side_data; + int side_data_size; + int i; + + side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size); + if (!side_data) { + side_data_size = 4+4+8*error_count; + side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, + side_data_size); + } + + if (!side_data || side_data_size < 4+4+8*error_count) + return AVERROR(ENOMEM); + + AV_WL32(side_data , quality ); + side_data[4] = pict_type; + side_data[5] = error_count; + for (i = 0; i