mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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 Merged-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
commit
e5bae39f46
@ -15,6 +15,9 @@ libavutil: 2014-08-09
|
|||||||
|
|
||||||
API changes, most recent first:
|
API changes, most recent first:
|
||||||
|
|
||||||
|
2015-xx-xx - xxxxxxx - lavc 56.33.0 - avcodec.h
|
||||||
|
Add AV_PKT_DATA_QUALITY_FACTOR to export the quality value of an AVPacket.
|
||||||
|
|
||||||
2015-07-16 - xxxxxxxx - lavc 56.49.100
|
2015-07-16 - xxxxxxxx - lavc 56.49.100
|
||||||
Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS
|
Add av_codec_get_codec_properties(), FF_CODEC_PROPERTY_LOSSLESS
|
||||||
and FF_CODEC_PROPERTY_CLOSED_CAPTIONS
|
and FF_CODEC_PROPERTY_CLOSED_CAPTIONS
|
||||||
|
13
ffmpeg.c
13
ffmpeg.c
@ -667,6 +667,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
|
|||||||
}
|
}
|
||||||
ost->frame_number++;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if (bsfc)
|
if (bsfc)
|
||||||
av_packet_split_side_data(pkt);
|
av_packet_split_side_data(pkt);
|
||||||
@ -1257,7 +1262,8 @@ static void do_video_stats(OutputStream *ost, int frame_size)
|
|||||||
enc = ost->enc_ctx;
|
enc = ost->enc_ctx;
|
||||||
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
|
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
frame_number = ost->st->nb_frames;
|
frame_number = ost->st->nb_frames;
|
||||||
fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame ? enc->coded_frame->quality / (float)FF_QP2LAMBDA : 0);
|
fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
|
||||||
|
ost->quality / (float)FF_QP2LAMBDA);
|
||||||
if (enc->coded_frame && (enc->flags&CODEC_FLAG_PSNR))
|
if (enc->coded_frame && (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)));
|
fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
|
||||||
|
|
||||||
@ -1548,8 +1554,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
|
|||||||
float q = -1;
|
float q = -1;
|
||||||
ost = output_streams[i];
|
ost = output_streams[i];
|
||||||
enc = ost->enc_ctx;
|
enc = ost->enc_ctx;
|
||||||
if (!ost->stream_copy && enc->coded_frame)
|
if (!ost->stream_copy)
|
||||||
q = enc->coded_frame->quality / (float)FF_QP2LAMBDA;
|
q = ost->quality / (float) FF_QP2LAMBDA;
|
||||||
|
|
||||||
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
|
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
|
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
|
||||||
av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
|
av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
|
||||||
|
3
ffmpeg.h
3
ffmpeg.h
@ -456,6 +456,9 @@ typedef struct OutputStream {
|
|||||||
// number of frames/samples sent to the encoder
|
// number of frames/samples sent to the encoder
|
||||||
uint64_t frames_encoded;
|
uint64_t frames_encoded;
|
||||||
uint64_t samples_encoded;
|
uint64_t samples_encoded;
|
||||||
|
|
||||||
|
/* packet quality factor */
|
||||||
|
int quality;
|
||||||
} OutputStream;
|
} OutputStream;
|
||||||
|
|
||||||
typedef struct OutputFile {
|
typedef struct OutputFile {
|
||||||
|
@ -1054,6 +1054,13 @@ enum AVPacketSideDataType {
|
|||||||
*/
|
*/
|
||||||
AV_PKT_DATA_AUDIO_SERVICE_TYPE,
|
AV_PKT_DATA_AUDIO_SERVICE_TYPE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This side data contains an integer value representing the quality
|
||||||
|
* factor of the compressed frame. Allowed range is between 1 (good)
|
||||||
|
* and FF_LAMBDA_MAX (bad).
|
||||||
|
*/
|
||||||
|
AV_PKT_DATA_QUALITY_FACTOR,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recommmends skipping the specified number of samples
|
* Recommmends skipping the specified number of samples
|
||||||
* @code
|
* @code
|
||||||
|
@ -1050,7 +1050,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
DNXHDEncContext *ctx = avctx->priv_data;
|
DNXHDEncContext *ctx = avctx->priv_data;
|
||||||
int first_field = 1;
|
int first_field = 1;
|
||||||
int offset, i, ret;
|
int offset, i, ret;
|
||||||
uint8_t *buf;
|
uint8_t *buf, *sd;
|
||||||
|
|
||||||
if ((ret = ff_alloc_packet2(avctx, pkt, ctx->cid_table->frame_size)) < 0)
|
if ((ret = ff_alloc_packet2(avctx, pkt, ctx->cid_table->frame_size)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -1103,6 +1103,11 @@ encode_coding_unit:
|
|||||||
|
|
||||||
avctx->coded_frame->quality = ctx->qscale * FF_QP2LAMBDA;
|
avctx->coded_frame->quality = ctx->qscale * FF_QP2LAMBDA;
|
||||||
|
|
||||||
|
sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
|
||||||
|
if (!sd)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
*(int *)sd = ctx->qscale * FF_QP2LAMBDA;
|
||||||
|
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -302,8 +302,15 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
|
pkt->flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
uint8_t *sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
|
||||||
|
sizeof(int));
|
||||||
|
if (!sd)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
*(int *)sd = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
||||||
|
|
||||||
ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
ctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
||||||
|
}
|
||||||
|
|
||||||
*got_packet = ret;
|
*got_packet = ret;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -117,6 +117,7 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
xavs_nal_t *nal;
|
xavs_nal_t *nal;
|
||||||
int nnal, i, ret;
|
int nnal, i, ret;
|
||||||
xavs_picture_t pic_out;
|
xavs_picture_t pic_out;
|
||||||
|
uint8_t *sd;
|
||||||
|
|
||||||
x4->pic.img.i_csp = XAVS_CSP_I420;
|
x4->pic.img.i_csp = XAVS_CSP_I420;
|
||||||
x4->pic.img.i_plane = 3;
|
x4->pic.img.i_plane = 3;
|
||||||
@ -191,6 +192,11 @@ static int XAVS_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
avctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
avctx->coded_frame->quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
||||||
|
|
||||||
|
sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
|
||||||
|
if (!sd)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
*(int *)sd = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
|
||||||
|
|
||||||
x4->out_frame_count++;
|
x4->out_frame_count++;
|
||||||
*got_packet = ret;
|
*got_packet = ret;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -771,6 +771,12 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (xerr > 0) {
|
if (xerr > 0) {
|
||||||
|
uint8_t *sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
|
||||||
|
sizeof(int));
|
||||||
|
if (!sd)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
*(int *)sd = xvid_enc_stats.quant * FF_QP2LAMBDA;
|
||||||
|
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
|
|
||||||
avctx->coded_frame->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
|
avctx->coded_frame->quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
|
||||||
|
@ -1731,6 +1731,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
|
|
||||||
/* output? */
|
/* output? */
|
||||||
if (s->new_picture.f->data[0]) {
|
if (s->new_picture.f->data[0]) {
|
||||||
|
uint8_t *sd;
|
||||||
int growing_buffer = context_count == 1 && !pkt->data && !s->data_partitioning;
|
int growing_buffer = context_count == 1 && !pkt->data && !s->data_partitioning;
|
||||||
int pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - FF_INPUT_BUFFER_PADDING_SIZE
|
int pkt_size = growing_buffer ? FFMAX(s->mb_width*s->mb_height*64+10000, avctx->internal->byte_buffer_size) - FF_INPUT_BUFFER_PADDING_SIZE
|
||||||
:
|
:
|
||||||
@ -1781,6 +1782,12 @@ vbv_retry:
|
|||||||
|
|
||||||
frame_end(s);
|
frame_end(s);
|
||||||
|
|
||||||
|
sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
|
||||||
|
sizeof(int));
|
||||||
|
if (!sd)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
*(int *)sd = s->current_picture.f->quality;
|
||||||
|
|
||||||
if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
|
if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
|
||||||
ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);
|
ff_mjpeg_encode_picture_trailer(&s->pb, s->header_bits);
|
||||||
|
|
||||||
|
@ -574,6 +574,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
{
|
{
|
||||||
SVQ1EncContext *const s = avctx->priv_data;
|
SVQ1EncContext *const s = avctx->priv_data;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
uint8_t *sd;
|
||||||
|
|
||||||
if ((ret = ff_alloc_packet2(avctx, pkt, s->y_block_width * s->y_block_height *
|
if ((ret = ff_alloc_packet2(avctx, pkt, s->y_block_width * s->y_block_height *
|
||||||
MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE)) < 0)
|
MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE)) < 0)
|
||||||
@ -613,6 +614,11 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
avctx->coded_frame->pict_type = s->pict_type;
|
avctx->coded_frame->pict_type = s->pict_type;
|
||||||
avctx->coded_frame->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
|
avctx->coded_frame->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
|
||||||
|
|
||||||
|
sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
|
||||||
|
if (!sd)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
*(int *)sd = pict->quality;
|
||||||
|
|
||||||
svq1_write_header(s, s->pict_type);
|
svq1_write_header(s, s->pict_type);
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
if (svq1_encode_plane(s, i,
|
if (svq1_encode_plane(s, i,
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
#include "libavutil/version.h"
|
#include "libavutil/version.h"
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 56
|
#define LIBAVCODEC_VERSION_MAJOR 56
|
||||||
#define LIBAVCODEC_VERSION_MINOR 49
|
#define LIBAVCODEC_VERSION_MINOR 50
|
||||||
#define LIBAVCODEC_VERSION_MICRO 101
|
#define LIBAVCODEC_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
LIBAVCODEC_VERSION_MINOR, \
|
LIBAVCODEC_VERSION_MINOR, \
|
||||||
|
@ -377,6 +377,9 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
|
|||||||
av_log(ctx, AV_LOG_INFO, "audio service type: ");
|
av_log(ctx, AV_LOG_INFO, "audio service type: ");
|
||||||
dump_audioservicetype(ctx, &sd);
|
dump_audioservicetype(ctx, &sd);
|
||||||
break;
|
break;
|
||||||
|
case AV_PKT_DATA_QUALITY_FACTOR:
|
||||||
|
av_log(ctx, AV_LOG_INFO, "quality factor: %d", *(int *)sd.data);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(ctx, AV_LOG_WARNING,
|
av_log(ctx, AV_LOG_WARNING,
|
||||||
"unknown side data type %d (%d bytes)", sd.type, sd.size);
|
"unknown side data type %d (%d bytes)", sd.type, sd.size);
|
||||||
|
Loading…
Reference in New Issue
Block a user