diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-21 13:23:29 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-22 19:31:52 +0200 |
commit | c40ecffd31d0e0be531425e48a98c1a8fcaaffa2 (patch) | |
tree | 0ba43d0eca37012a0185646605b2f39d83d93180 /libavcodec/avpacket.c | |
parent | a906e86a8dbd70d1ca858abc498c25e536fa87a9 (diff) | |
download | ffmpeg-c40ecffd31d0e0be531425e48a98c1a8fcaaffa2.tar.gz |
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 <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/avpacket.c')
-rw-r--r-- | libavcodec/avpacket.c | 25 |
1 files changed, 25 insertions, 0 deletions
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<error_count; i++) + AV_WL64(side_data+8 + 8*i , error[i]); + + return 0; +} |