[FFmpeg-devel] [PATCH 2/4] libavcodec/qsvdec_h264.c: refactoring: functional of qsv_process_data() has been moved into qsvdec.c
Michael Niedermayer
michael at niedermayer.cc
Thu Jul 23 03:18:13 CEST 2015
On Tue, Jul 21, 2015 at 04:05:18PM +0300, Ivan Uskov wrote:
> Hello All,
>
> The qsv_process_data() doing nothing h.264-specific, so it has been
> moved into qsvdec.c with new name ff_qsv_prepare().
> Please review.
>
>
> --
> Best regards,
> Ivan mailto:ivan.uskov at nablet.com
> qsvdec.c | 19 +++++++++++++++++++
> qsvdec.h | 2 ++
> qsvdec_h264.c | 20 +-------------------
> 3 files changed, 22 insertions(+), 19 deletions(-)
> 5cf0f0974edba5b9fe0a21c69da333eff7062b3b 0002-libavcodec-qsvdec_h264.c-refactoring-functional-of-q.patch
> From 4542ac05ed5dbce40d9adcb3feb320a76b62a1c2 Mon Sep 17 00:00:00 2001
> From: Ivan Uskov <ivan.uskov at nablet.com>
> Date: Mon, 20 Jul 2015 12:42:16 -0400
> Subject: [PATCH 2/4] libavcodec/qsvdec_h264.c: refactoring: functional of
> qsv_process_data() has been moved into qsvdec.c
>
> ---
> libavcodec/qsvdec.c | 19 +++++++++++++++++++
> libavcodec/qsvdec.h | 2 ++
> libavcodec/qsvdec_h264.c | 20 +-------------------
> 3 files changed, 22 insertions(+), 19 deletions(-)
>
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 8b06611..3be1c75 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -123,6 +123,7 @@ int ff_qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt)
> if (!q->async_fifo)
> return AVERROR(ENOMEM);
>
> + q->ready = 1;
>
> return 0;
> }
> @@ -218,6 +219,17 @@ static QSVFrame *find_frame(QSVContext *q, mfxFrameSurface1 *surf)
> }
> return NULL;
> }
> +static int ff_qsv_prepare(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt)
> +{
> + int ret;
> +
> + ret = ff_qsv_decode_init(avctx, q, avpkt);
> + /* consume packet without a header */
> + if (AVERROR(EAGAIN)==ret)
> + return avpkt->size;
> +
> + return ret;
> +}
>
> int ff_qsv_decode(AVCodecContext *avctx, QSVContext *q,
> AVFrame *frame, int *got_frame,
> @@ -230,6 +242,11 @@ int ff_qsv_decode(AVCodecContext *avctx, QSVContext *q,
> mfxBitstream bs = { { { 0 } } };
> int ret;
>
> + if (!q->ready) {
> + ret = ff_qsv_prepare(avctx, q, avpkt);
> + if (ret)
> + return ret;
> + }
> if (avpkt->size) {
> bs.Data = avpkt->data;
> bs.DataLength = avpkt->size;
> @@ -325,5 +342,7 @@ int ff_qsv_decode_close(QSVContext *q)
>
> ff_qsv_close_internal_session(&q->internal_qs);
>
> + q->ready = 0;
> +
> return 0;
> }
> diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
> index 4d3c505..24c565c 100644
> --- a/libavcodec/qsvdec.h
> +++ b/libavcodec/qsvdec.h
> @@ -50,6 +50,8 @@ typedef struct QSVContext {
>
> AVFifoBuffer *async_fifo;
>
> + int ready;
I think this should be documented, its not immedeatly clear from
just the name "ready" what exactly it refers to
maybe a more verbose variable name would make it also more immedeatly
obvious what it means
maybe something like
"int prepared" and ff_qsv_prepare() but maybe that is not the
best suggestion i dont know
also ff_qsv_prepare() should be documented what it exactly does/means
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150723/d9bf5d51/attachment.sig>
More information about the ffmpeg-devel
mailing list