On 2011-12-16 16:04:34 +0100, Kostya Shishkov wrote:
> On Fri, Dec 16, 2011 at 03:52:43PM +0100, Janne Grunau wrote:
> > updated patch
> > ---8<---
> > Statistics for bourne.rmvb -an -f null on quadcore AMD Phenom
> > 
> > 1 thread:  37.12s user 0.03s system  99% cpu 37.174 total
> > 2 threads: 47.63s user 0.24s system 185% cpu 25.807 total
> > 4 threads: 41.21s user 0.30s system 327% cpu 12.674 total
> > ---
> >  libavcodec/rv30.c |    4 ++-
> >  libavcodec/rv34.c |   91 
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  libavcodec/rv34.h |    2 +
> >  libavcodec/rv40.c |    4 ++-
> >  4 files changed, 99 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
> > index 1a126be..429ef9f 100644
> > --- a/libavcodec/rv34.c
> > +++ b/libavcodec/rv34.c
> > @@ -1356,6 +1378,71 @@ av_cold int ff_rv34_decode_init(AVCodecContext 
> > *avctx)
> >      return 0;
> >  }
> >  
> > +int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
> > +{
> > +    RV34DecContext *r = avctx->priv_data;
> > +
> > +    r->s.avctx = avctx;
> > +
> > +    if (avctx->internal->is_copy) {
> > +        r->cbp_chroma       = av_malloc(r->s.mb_stride * r->s.mb_height *
> > +                                        sizeof(*r->cbp_chroma));
> > +        r->cbp_luma         = av_malloc(r->s.mb_stride * r->s.mb_height *
> > +                                        sizeof(*r->cbp_luma));
> > +        r->deblock_coefs    = av_malloc(r->s.mb_stride * r->s.mb_height *
> > +                                        sizeof(*r->deblock_coefs));
> > +        r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 *
> > +                                        sizeof(*r->intra_types_hist));
> > +        r->mb_type          = av_malloc(r->s.mb_stride * r->s.mb_height *
> > +                                        sizeof(*r->mb_type));
> > +
> > +        if (!(r->cbp_chroma       && r->cbp_luma && r->deblock_coefs &&
> > +              r->intra_types_hist && r->mb_type)) {
> > +            av_freep(&r->cbp_chroma);
> > +            av_freep(&r->cbp_luma);
> > +            av_freep(&r->deblock_coefs);
> > +            av_freep(&r->intra_types_hist);
> > +            av_freep(&r->mb_type);
> > +            r->intra_types = NULL;
> > +            return AVERROR(ENOMEM);
> > +        }
> 
> IIRC those fields initially have value from original context instance.
> Do they need to be zeroed beforehands?

no, av_malloc() overwrites them anyway. after that it's either a valid
pointer or NULL.

> The patch itself looks good and sane to me. 

except that most lure a bug somewhere since I get occasionally non
bit-exact P or B frames with 4 threads.


Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to