diff options
author | Ivan Uskov <ivan.uskov@nablet.com> | 2015-07-23 05:14:41 -0400 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-23 17:10:39 +0200 |
commit | d50ab820dacf0d070805889ff69ec1f03401d835 (patch) | |
tree | 25c9a540119e666610f870314509430a4ea1f660 /libavcodec | |
parent | fd7eadd25c77307ef8398b5f0307b18050ee070a (diff) | |
download | ffmpeg-d50ab820dacf0d070805889ff69ec1f03401d835.tar.gz |
libavcodec/qsvdec_h264.c: refactoring: functionality of qsv_process_data() has been moved into qsvdec.c
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/qsvdec.c | 13 | ||||
-rw-r--r-- | libavcodec/qsvdec.h | 4 | ||||
-rw-r--r-- | libavcodec/qsvdec_h264.c | 20 |
3 files changed, 17 insertions, 20 deletions
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 8b06611f1d..4e7a0ac271 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -92,7 +92,10 @@ int ff_qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt) ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, ¶m); if (MFX_ERR_MORE_DATA==ret) { - return AVERROR(EAGAIN); + /* this code means that header not found so we return packet size to skip + a current packet + */ + return avpkt->size; } else if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Decode header error %d\n", ret); return ff_qsv_error(ret); @@ -123,6 +126,7 @@ int ff_qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt) if (!q->async_fifo) return AVERROR(ENOMEM); + q->engine_ready = 1; return 0; } @@ -230,6 +234,11 @@ int ff_qsv_decode(AVCodecContext *avctx, QSVContext *q, mfxBitstream bs = { { { 0 } } }; int ret; + if (!q->engine_ready) { + ret = ff_qsv_decode_init(avctx, q, avpkt); + if (ret) + return ret; + } if (avpkt->size) { bs.Data = avpkt->data; bs.DataLength = avpkt->size; @@ -325,5 +334,7 @@ int ff_qsv_decode_close(QSVContext *q) ff_qsv_close_internal_session(&q->internal_qs); + q->engine_ready = 0; + return 0; } diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index 4d3c50563d..a4971ad9d0 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -50,6 +50,10 @@ typedef struct QSVContext { AVFifoBuffer *async_fifo; + // this flag indicates that header parsed, + // decoder instance created and ready to general decoding + int engine_ready; + // options set by the caller int async_depth; int iopattern; diff --git a/libavcodec/qsvdec_h264.c b/libavcodec/qsvdec_h264.c index 8b3f916189..314eb6cd5d 100644 --- a/libavcodec/qsvdec_h264.c +++ b/libavcodec/qsvdec_h264.c @@ -101,24 +101,6 @@ fail: return ret; } -static int qsv_process_data(AVCodecContext *avctx, AVFrame *frame, - int *got_frame, AVPacket *pkt) -{ - QSVH264Context *s = avctx->priv_data; - int ret; - - if (!s->qsv.session || AV_PIX_FMT_NONE==avctx->pix_fmt) { - ret = ff_qsv_decode_init(avctx, &s->qsv, pkt); - /* consume packet without a header */ - if (AVERROR(EAGAIN)==ret) - return pkt->size; - if (ret < 0) - return ret; - } - - return ff_qsv_decode(avctx, &s->qsv, frame, got_frame, pkt); -} - static int qsv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { @@ -171,7 +153,7 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data, s->pkt_filtered.size = size; } - ret = qsv_process_data(avctx, frame, got_frame, &s->pkt_filtered); + ret = ff_qsv_decode(avctx, &s->qsv, frame, got_frame, &s->pkt_filtered); if (ret < 0) return ret; |