On Sun, 27 Sep 2015 02:41:43 +0200 Vittorio Giovara <[email protected]> wrote:
> This field was used in combination with coded_frame to compute some > sort of PSNR value. Regardless of its use, this property is tied to the > encoding processing, while AVFrame is a structure suited for decoded > data only. > > The only use of this field (besides the deprecated coded_frame) is > in mpegvideoenc: since it might be used in bframes estimation, add an > additional field to Picture, which is a private structure anyway. > > Signed-off-by: Vittorio Giovara <[email protected]> > --- > Improved names for the new variable are welcome. > Vittorio > > libavcodec/mpegpicture.c | 2 ++ > libavcodec/mpegpicture.h | 2 ++ > libavcodec/mpegvideo_enc.c | 24 +++++++++++++++--------- > libavutil/frame.c | 4 ++++ > libavutil/frame.h | 5 ++++- > libavutil/version.h | 3 +++ > 6 files changed, 30 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c > index 9df1415..88d26ec 100644 > --- a/libavcodec/mpegpicture.c > +++ b/libavcodec/mpegpicture.c > @@ -358,6 +358,8 @@ int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture > *dst, Picture *src) > dst->reference = src->reference; > dst->shared = src->shared; > > + memcpy(dst->error, src->error, sizeof(dst->error)); > + > return 0; > fail: > ff_mpeg_unref_picture(avctx, dst); > diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h > index 0588f02..43bacba 100644 > --- a/libavcodec/mpegpicture.h > +++ b/libavcodec/mpegpicture.h > @@ -83,6 +83,8 @@ typedef struct Picture { > > int reference; > int shared; > + > + uint64_t error[4]; > } Picture; > > /** > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c > index b9a43a8..106c943 100644 > --- a/libavcodec/mpegvideo_enc.c > +++ b/libavcodec/mpegvideo_enc.c > @@ -1482,6 +1482,12 @@ FF_DISABLE_DEPRECATION_WARNINGS > av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f); > FF_ENABLE_DEPRECATION_WARNINGS > #endif > +#if FF_API_ERROR_FRAME > +FF_DISABLE_DEPRECATION_WARNINGS > + memcpy(s->current_picture.f->error, s->current_picture.error, > + sizeof(s->current_picture.f->error)); > +FF_ENABLE_DEPRECATION_WARNINGS > +#endif > } > > static void update_noise_reduction(MpegEncContext *s) > @@ -1688,8 +1694,8 @@ vbv_retry: > ff_write_pass1_stats(s); > > for (i = 0; i < 4; i++) { > - s->current_picture_ptr->f->error[i] = > s->current_picture.f->error[i]; > - avctx->error[i] += s->current_picture_ptr->f->error[i]; > + s->current_picture_ptr->error[i] = s->current_picture.error[i]; > + avctx->error[i] += s->current_picture_ptr->error[i]; > } > > if (s->avctx->flags & AV_CODEC_FLAG_PASS1) > @@ -2595,7 +2601,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ > /* note: quant matrix value (8) is implied here */ > s->last_dc[i] = 128 << s->intra_dc_precision; > > - s->current_picture.f->error[i] = 0; > + s->current_picture.error[i] = 0; > } > s->mb_skip_run = 0; > memset(s->last_mv, 0, sizeof(s->last_mv)); > @@ -3153,13 +3159,13 @@ static int encode_thread(AVCodecContext *c, void > *arg){ > if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16; > if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16; > > - s->current_picture.f->error[0] += sse( > + s->current_picture.error[0] += sse( > s, s->new_picture.f->data[0] + s->mb_x*16 + > s->mb_y*s->linesize*16, > s->dest[0], w, h, s->linesize); > - s->current_picture.f->error[1] += sse( > + s->current_picture.error[1] += sse( > s, s->new_picture.f->data[1] + s->mb_x*8 + > s->mb_y*s->uvlinesize*chr_h, > s->dest[1], w>>1, h>>s->chroma_y_shift, s->uvlinesize); > - s->current_picture.f->error[2] += sse( > + s->current_picture.error[2] += sse( > s, s->new_picture.f->data[2] + s->mb_x*8 + > s->mb_y*s->uvlinesize*chr_h, > s->dest[2], w>>1, h>>s->chroma_y_shift, s->uvlinesize); > } > @@ -3212,9 +3218,9 @@ static void merge_context_after_encode(MpegEncContext > *dst, MpegEncContext *src) > MERGE(misc_bits); > MERGE(er.error_count); > MERGE(padding_bug_score); > - MERGE(current_picture.f->error[0]); > - MERGE(current_picture.f->error[1]); > - MERGE(current_picture.f->error[2]); > + MERGE(current_picture.error[0]); > + MERGE(current_picture.error[1]); > + MERGE(current_picture.error[2]); > > if(dst->avctx->noise_reduction){ > for(i=0; i<64; i++){ > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 32ec470..e4f6ab3 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -400,7 +400,11 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src) > dst->color_range = src->color_range; > dst->chroma_location = src->chroma_location; > > +#if FF_API_ERROR_FRAME > +FF_DISABLE_DEPRECATION_WARNINGS > memcpy(dst->error, src->error, sizeof(dst->error)); > +FF_ENABLE_DEPRECATION_WARNINGS > +#endif > > for (i = 0; i < src->nb_side_data; i++) { > const AVFrameSideData *sd_src = src->side_data[i]; > diff --git a/libavutil/frame.h b/libavutil/frame.h > index d231ff3..c723cb0 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -240,10 +240,13 @@ typedef struct AVFrame { > */ > void *opaque; > > +#if FF_API_ERROR_FRAME > /** > - * error > + * @deprecated unused > */ > + attribute_deprecated > uint64_t error[AV_NUM_DATA_POINTERS]; > +#endif > > /** > * When decoding, this signals how much the picture must be delayed. > diff --git a/libavutil/version.h b/libavutil/version.h > index 3c12d71..20059c4 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -96,6 +96,9 @@ > #ifndef FF_API_PLUS1_MINUS1 > #define FF_API_PLUS1_MINUS1 (LIBAVUTIL_VERSION_MAJOR < 56) > #endif > +#ifndef FF_API_ERROR_FRAME > +#define FF_API_ERROR_FRAME (LIBAVUTIL_VERSION_MAJOR < 56) > +#endif > > > /** +1 AVFrame is still way too bloated. If someone really wants it, it could be turned into side data. _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
