History

Merge commit '5d3addb937946eca5391e40b5e6308e74ac6f77b'

* commit '5d3addb937946eca5391e40b5e6308e74ac6f77b': Add a quality factor packet side data Conflicts: doc/APIchanges ffmpeg.c libavcodec/avcodec.h libavcodec/mpegvideo_enc.c libavcodec/version.h

Michael Niedermayer committed 11 years ago

Commit e5bae392 parents b1fad7a 5d3addb12 files · +67 −7Browse files

Unified · Split

12 files
  1. doc/APIchanges +3 −0
  2. ffmpeg.c +10 −3
  3. ffmpeg.h +3 −0
  4. libavcodec/avcodec.h +7 −0
  5. libavcodec/dnxhdenc.c +6 −1
  6. libavcodec/libx264.c +8 −1
  7. libavcodec/libxavs.c +6 −0
  8. libavcodec/libxvid.c +6 −0
  9. libavcodec/mpegvideo_enc.c +7 −0
  10. libavcodec/svq1enc.c +6 −0
  11. libavcodec/version.h +2 −2
  12. libavformat/dump.c +3 −0
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2014-08-09 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2015-xx-xx - xxxxxxx - lavc 56.33.0 - avcodec.h
19+ Add AV_PKT_DATA_QUALITY_FACTOR to export the quality value of an AVPacket.
20+
1821 2015-07-16 - xxxxxxxx - lavc 56.49.100
1922 Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS
2023 and FF_CODEC_PROPERTY_CLOSED_CAPTIONS
ffmpeg.c+10−3
@@ -667,6 +667,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) · 666 unmodified lines
667667 }
668668 ost->frame_number++;
669669 }
670+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
671+ uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
672+ NULL);
673+ ost->quality = sd ? *(int *)sd : -1;
674+ }
670675
671676 if (bsfc)
672677 av_packet_split_side_data(pkt);
@@ -1257,7 +1262,8 @@ static void do_video_stats(OutputStream *ost, int frame_size) · 584 unmodified lines
12571262 enc = ost->enc_ctx;
12581263 if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
12591264 frame_number = ost->st->nb_frames;
1260− fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame ? enc->coded_frame->quality / (float)FF_QP2LAMBDA : 0);
1265+ fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
1266+ ost->quality / (float)FF_QP2LAMBDA);
12611267 if (enc->coded_frame && (enc->flags&CODEC_FLAG_PSNR))
12621268 fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
12631269
@@ -1548,8 +1554,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti · 284 unmodified lines
15481554 float q = -1;
15491555 ost = output_streams[i];
15501556 enc = ost->enc_ctx;
1551− if (!ost->stream_copy && enc->coded_frame)
1552− q = enc->coded_frame->quality / (float)FF_QP2LAMBDA;
1557+ if (!ost->stream_copy)
1558+ q = ost->quality / (float) FF_QP2LAMBDA;
1559+
15531560 if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
15541561 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
15551562 av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
ffmpeg.h+3−0
@@ -456,6 +456,9 @@ typedef struct OutputStream { · 455 unmodified lines
456456 // number of frames/samples sent to the encoder
457457 uint64_t frames_encoded;
458458 uint64_t samples_encoded;
459+
460+ /* packet quality factor */
461+ int quality;
459462 } OutputStream;
460463
461464 typedef struct OutputFile {
libavcodec/avcodec.h+7−0
@@ -1054,6 +1054,13 @@ enum AVPacketSideDataType { · 1053 unmodified lines
10541054 */
10551055 AV_PKT_DATA_AUDIO_SERVICE_TYPE,
10561056
1057+ /**
1058+ * This side data contains an integer value representing the quality
1059+ * factor of the compressed frame. Allowed range is between 1 (good)
1060+ * and FF_LAMBDA_MAX (bad).
1061+ */
1062+ AV_PKT_DATA_QUALITY_FACTOR,
1063+
10571064 /**
10581065 * Recommmends skipping the specified number of samples
10591066 * @code
libavcodec/dnxhdenc.c+6−1
@@ -1050,7 +1050,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt, · 1049 unmodified lines
10501050 DNXHDEncContext *ctx = avctx->priv_data;
10511051 int first_field = 1;
10521052 int offset, i, ret;
1053− uint8_t *buf;
1053+ uint8_t *buf, *sd;
10541054
10551055 if ((ret = ff_alloc_packet2(avctx, pkt, ctx->cid_table->frame_size)) < 0)
10561056 return ret;
@@ -1103,6 +1103,11 @@ encode_coding_unit: · 46 unmodified lines
11031103
11041104 avctx->coded_frame->quality = ctx->qscale * FF_QP2LAMBDA;
11051105
1106+ sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
1107+ if (!sd)
1108+ return AVERROR(ENOMEM);
1109+ *(int *)sd = ctx->qscale * FF_QP2LAMBDA;
1110+
11061111 pkt->flags |= AV_PKT_FLAG_KEY;
11071112 *got_packet = 1;
11081113 return 0;
libavcodec/libx264.c+8−1
@@ -302,8 +302,15 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, · 301 unmodified lines
302302 }
303303
304304 pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
305− if (ret)
305+ if (ret) {
306+ uint8_t *sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
307+ sizeof(int));
308+ if (!sd)
309+ return AVERROR(ENOMEM);
310+ *(int *)sd = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
311+
306312 ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
313+ }
307314
308315 *got_packet = ret;
309316 return 0;
libavcodec/libxavs.c+6−0
@@ -117,6 +117,7 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt, · 116 unmodified lines
117117 xavs_nal_t *nal;
118118 int nnal, i, ret;
119119 xavs_picture_t pic_out;
120+ uint8_t *sd;
120121
121122 x4->pic.img.i_csp = XAVS_CSP_I420;
122123 x4->pic.img.i_plane = 3;
@@ -191,6 +192,11 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt, · 68 unmodified lines
191192
192193 avctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
193194
195+ sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
196+ if (!sd)
197+ return AVERROR(ENOMEM);
198+ *(int *)sd = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
199+
194200 x4->out_frame_count++;
195201 *got_packet = ret;
196202 return 0;
libavcodec/libxvid.c+6−0
@@ -771,6 +771,12 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 770 unmodified lines
771771 }
772772
773773 if (xerr > 0) {
774+ uint8_t *sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
775+ sizeof(int));
776+ if (!sd)
777+ return AVERROR(ENOMEM);
778+ *(int *)sd = xvid_enc_stats.quant * FF_QP2LAMBDA;
779+
774780 *got_packet = 1;
775781
776782 avctx->coded_frame->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
libavcodec/mpegvideo_enc.c+7−0
@@ -1731,6 +1731,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, · 1730 unmodified lines
17311731
17321732 /* output? */
17331733 if (s->new_picture.f->data[0]) {
1734+ uint8_t *sd;
17341735 int growing_buffer = context_count == 1 && !pkt->data && !s->data_partitioning;
17351736 int pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - FF_INPUT_BUFFER_PADDING_SIZE
17361737 :
@@ -1781,6 +1782,12 @@ vbv_retry: · 44 unmodified lines
17811782
17821783 frame_end(s);
17831784
1785+ sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
1786+ sizeof(int));
1787+ if (!sd)
1788+ return AVERROR(ENOMEM);
1789+ *(int *)sd = s->current_picture.f->quality;
1790+
17841791 if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
17851792 ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);
17861793
libavcodec/svq1enc.c+6−0
@@ -574,6 +574,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 573 unmodified lines
574574 {
575575 SVQ1EncContext *const s = avctx->priv_data;
576576 int i, ret;
577+ uint8_t *sd;
577578
578579 if ((ret = ff_alloc_packet2(avctx, pkt, s->y_block_width * s->y_block_height *
579580 MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE)) < 0)
@@ -613,6 +614,11 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 33 unmodified lines
613614 avctx->coded_frame->pict_type = s->pict_type;
614615 avctx->coded_frame->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
615616
617+ sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
618+ if (!sd)
619+ return AVERROR(ENOMEM);
620+ *(int *)sd = pict->quality;
621+
616622 svq1_write_header(s, s->pict_type);
617623 for (i = 0; i < 3; i++)
618624 if (svq1_encode_plane(s, i,
libavcodec/version.h+2−2
@@ -29,8 +29,8 @@ · 28 unmodified lines
2929 #include "libavutil/version.h"
3030
3131 #define LIBAVCODEC_VERSION_MAJOR 56
32−#define LIBAVCODEC_VERSION_MINOR 49
33−#define LIBAVCODEC_VERSION_MICRO 101
32+#define LIBAVCODEC_VERSION_MINOR 50
33+#define LIBAVCODEC_VERSION_MICRO 100
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3636 LIBAVCODEC_VERSION_MINOR, \
libavformat/dump.c+3−0
@@ -377,6 +377,9 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent) · 376 unmodified lines
377377 av_log(ctx, AV_LOG_INFO, "audio service type: ");
378378 dump_audioservicetype(ctx, &sd);
379379 break;
380+ case AV_PKT_DATA_QUALITY_FACTOR:
381+ av_log(ctx, AV_LOG_INFO, "quality factor: %d", *(int *)sd.data);
382+ break;
380383 default:
381384 av_log(ctx, AV_LOG_WARNING,
382385 "unknown side data type %d (%d bytes)", sd.type, sd.size);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t