Commit d50ab820 authored by Ivan Uskov's avatar Ivan Uskov Committed by Michael Niedermayer

libavcodec/qsvdec_h264.c: refactoring: functionality of qsv_process_data() has...

libavcodec/qsvdec_h264.c: refactoring: functionality of qsv_process_data() has been moved into qsvdec.c
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent fd7eadd2
......@@ -92,7 +92,10 @@ int ff_qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt)
ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, &param);
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;
}
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment