On Mon, 18 Nov 2013 20:01:06 +0200, Rémi Denis-Courmont <[email protected]> wrote: > Le lundi 18 novembre 2013, 18:56:57 Anton Khirnov a écrit : > > On Mon, 18 Nov 2013 19:45 +0200, Rémi Denis-Courmont <[email protected]> > wrote: > > > Le vendredi 8 novembre 2013, 23:42:11 Anton Khirnov a écrit : > > > > --- > > > > > > > > avconv.c | 79 > > > > > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ avconv.h > > > > | > > > > 15 +++++++++++ > > > > > > > > avconv_filter.c | 3 ++- > > > > avconv_opt.c | 18 ++++++++++++- > > > > doc/avconv.texi | 20 ++++++++++++++ > > > > 5 files changed, 133 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/avconv.c b/avconv.c > > > > index 8d8c802..33a9a73 100644 > > > > --- a/avconv.c > > > > +++ b/avconv.c > > > > @@ -1165,6 +1165,13 @@ static int decode_video(InputStream *ist, > > > > AVPacket > > > > *pkt, int *got_output) return ret; > > > > > > > > } > > > > > > > > + if (ist->hwaccel_retrieve_data) { > > > > + err = ist->hwaccel_retrieve_data(ist->st->codec, > > > > decoded_frame); > > > > + if (err < 0) > > > > + goto fail; > > > > + ist->hwaccel_pix_fmt = decoded_frame->format; > > > > + } > > > > + > > > > > > > > decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, > > > > > > > > decoded_frame->pkt_pts, decoded_frame->pkt_dts); pkt->size = 0; > > > > @@ -1212,6 +1219,7 @@ static int decode_video(InputStream *ist, AVPacket > > > > *pkt, int *got_output) break; > > > > > > > > } > > > > > > > > +fail: > > > > av_frame_unref(ist->filter_frame); > > > > av_frame_unref(decoded_frame); > > > > return err < 0 ? err : ret; > > > > > > > > @@ -1359,6 +1367,70 @@ static void print_sdp(void) > > > > > > > > av_freep(&avc); > > > > > > > > } > > > > > > > > +typedef struct HWAccel { > > > > + const char *name; > > > > + int (*init)(AVCodecContext *s); > > > > + enum HWAccelID id; > > > > + enum AVPixelFormat pix_fmt; > > > > +} HWAccel; > > > > + > > > > +static const HWAccel hwaccels[] = { > > > > + { 0 }, > > > > +}; > > > > + > > > > +static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt) > > > > +{ > > > > + int i; > > > > + for (i = 0; hwaccels[i].name; i++) > > > > + if (hwaccels[i].pix_fmt == pix_fmt) > > > > + return &hwaccels[i]; > > > > + return NULL; > > > > +} > > > > + > > > > +static enum AVPixelFormat get_format(AVCodecContext *s, const enum > > > > AVPixelFormat *pix_fmts) > > > > +{ > > > > + InputStream *ist = s->opaque; > > > > + const enum AVPixelFormat *p; > > > > + int ret; > > > > + > > > > + for (p = pix_fmts; *p != -1; p++) { > > > > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p); > > > > + const HWAccel *hwaccel = get_hwaccel(*p); > > > > > > Should this not be after the following if() ? > > > > Yes, I suppose it should. Moved locally. > > > > > > + > > > > + if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) > > > > + break; > > > > + else if (!hwaccel || > > > > + (ist->active_hwaccel_id && ist->active_hwaccel_id != > > > > hwaccel->id) || > > > > > > I don't really follow why you need to keep track of and cross-check the > > > current hardware acceleration identifier. > > > > To make sure a different hwaccel does not get selected on a reinit. It > > probably cannot happen with any current decoder, but is conceivable in > > theory. > > And it would be a problem because...?
Because my code doesn't handle it. And when I tried to, it turned out that it's a lot of overhead (reference counting all the hwaccel contexts, especially if I don't want to create more Devices than needed) for almost no gain, since I don't really see what is there to gain from switching between multiple hwaccels on one stream. Perhaps it could be useful for testing, in that case feel free to send patches. -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
