summaryrefslogtreecommitdiff
path: root/avconv.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-07-15 18:41:21 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-07-20 15:06:47 +0100
commit5d3addb937946eca5391e40b5e6308e74ac6f77b (patch)
treee758d6b07dd07480a3b32901ccedc421d45b33c0 /avconv.c
parentd6604b29ef544793479d7fb4e05ef6622bb3e534 (diff)
Add a quality factor packet side data
This is necessary to preserve the quality information currently exported with coded_frame. Add the new side data to every encoder that needs it, and use it in avconv. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/avconv.c b/avconv.c
index 291c4d4ce3..f083d6fb7c 100644
--- a/avconv.c
+++ b/avconv.c
@@ -274,6 +274,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
}
ost->frame_number++;
}
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
+ NULL);
+ ost->quality = sd ? *(int *)sd : -1;
+ }
while (bsfc) {
AVPacket new_pkt = *pkt;
@@ -561,7 +566,8 @@ static void do_video_stats(OutputStream *ost, int frame_size)
enc = ost->enc_ctx;
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
frame_number = ost->frame_number;
- fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame->quality / (float)FF_QP2LAMBDA);
+ fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
+ ost->quality / (float)FF_QP2LAMBDA);
if (enc->flags&CODEC_FLAG_PSNR)
fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
@@ -846,8 +852,9 @@ static void print_report(int is_last_report, int64_t timer_start)
float q = -1;
ost = output_streams[i];
enc = ost->enc_ctx;
- if (!ost->stream_copy && enc->coded_frame)
- q = enc->coded_frame->quality / (float)FF_QP2LAMBDA;
+ if (!ost->stream_copy)
+ q = ost->quality / (float) FF_QP2LAMBDA;
+
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
}