On 2013-03-24 12:37:28 +0100, Anton Khirnov wrote:
> 
> On Mon, 18 Mar 2013 15:42:24 +0100, Janne Grunau <[email protected]> 
> wrote:
> > mpeg12 part removed since the decoders don't have the frame-threads
> > capability although they are prepared for frame threading. I think it
> > was left out since slice threading is preferred but our threading init
> > code chooses frame threading for h264's benefit since the decoder
> > supports slice threading not on all bitstreams.
> > 
> > Janne
> > ---8<---
> > 
> > Allows use of AVHWAccel based decoders with frame based multithreading.
> > The decoders will be forced into an non-concurrent mode by delaying
> > ff_thread_finish_setup() calls after decoding of the current frame
> > is finished.
> > 
> > This wastes memory by unnecessarily using multiple threads and thus
> > copies of the decoder context but allows seamless switching between
> > hardware accelerated and frame threaded software decoding when the
> > hardware decoder does not support the stream.
> > ---
> >  libavcodec/h263dec.c | 6 +++++-
> >  libavcodec/h264.c    | 9 +++++----
> >  libavcodec/pthread.c | 3 +++
> >  libavcodec/version.h | 2 +-
> >  4 files changed, 14 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
> > index 28fb2db..e8edad7 100644
> > --- a/libavcodec/h263dec.c
> > +++ b/libavcodec/h263dec.c
> > @@ -627,7 +627,8 @@ retry:
> >      if(ff_MPV_frame_start(s, avctx) < 0)
> >          return -1;
> >  
> > -    if (!s->divx_packed) ff_thread_finish_setup(avctx);
> > +    if (!s->divx_packed && !avctx->hwaccel)
> > +        ff_thread_finish_setup(avctx);
> >  
> >      if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & 
> > CODEC_CAP_HWACCEL_VDPAU)) {
> >          ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - 
> > s->gb.buffer);
> > @@ -720,6 +721,9 @@ intrax8_decoded:
> >  
> >      ff_MPV_frame_end(s);
> >  
> > +    if (!s->divx_packed && avctx->hwaccel)
> > +        ff_thread_finish_setup(avctx);
> > +
> >      assert(s->current_picture.f.pict_type == 
> > s->current_picture_ptr->f.pict_type);
> >      assert(s->current_picture.f.pict_type == s->pict_type);
> >      if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
> > diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> > index 9b196c7..db30e3c 100644
> > --- a/libavcodec/h264.c
> > +++ b/libavcodec/h264.c
> > @@ -4453,7 +4453,8 @@ again:
> >                      (h->sei_recovery_frame_cnt >= 0);
> >  
> >                  if (h->current_slice == 1) {
> > -                    if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS))
> > +                    if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) &&
> > +                        !h->avctx->hwaccel)
> >                          decode_postinit(h, nal_index >= nals_needed);
> >  
> >                      if (h->avctx->hwaccel &&
> > @@ -4665,11 +4666,11 @@ out:
> >  
> >      if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) ||
> >          (h->mb_y >= h->mb_height && h->mb_height)) {
> > -        if (avctx->flags2 & CODEC_FLAG2_CHUNKS)
> > -            decode_postinit(h, 1);
> > -
> >          field_end(h, 0);
> >  
> > +        if (avctx->flags2 & CODEC_FLAG2_CHUNKS || h->avctx->hwaccel)
> > +            decode_postinit(h, 1);
> > +
> 
> Looks ok, if you have verified that nothing bad can come from switching those
> two calls.

only practically. looking at both functions it might be safer to just
omit the ff_thread_finish_setup() call. I'll update the patch.

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

Reply via email to