Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
95414eb2
Commit
95414eb2
authored
Jun 25, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qsv: print more complete error messages
Include the libmfx error code and its description
parent
d9ec3c60
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
72 deletions
+97
-72
qsv.c
libavcodec/qsv.c
+78
-55
qsv_internal.h
libavcodec/qsv_internal.h
+4
-1
qsvdec.c
libavcodec/qsvdec.c
+5
-6
qsvenc.c
libavcodec/qsvenc.c
+10
-10
No files found.
libavcodec/qsv.c
View file @
95414eb2
...
@@ -54,39 +54,67 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
...
@@ -54,39 +54,67 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
return
AVERROR
(
ENOSYS
);
return
AVERROR
(
ENOSYS
);
}
}
int
ff_qsv_error
(
int
mfx_err
)
static
const
struct
{
mfxStatus
mfxerr
;
int
averr
;
const
char
*
desc
;
}
qsv_errors
[]
=
{
{
MFX_ERR_NONE
,
0
,
"success"
},
{
MFX_ERR_UNKNOWN
,
AVERROR_UNKNOWN
,
"unknown error"
},
{
MFX_ERR_NULL_PTR
,
AVERROR
(
EINVAL
),
"NULL pointer"
},
{
MFX_ERR_UNSUPPORTED
,
AVERROR
(
ENOSYS
),
"unsupported"
},
{
MFX_ERR_MEMORY_ALLOC
,
AVERROR
(
ENOMEM
),
"failed to allocate memory"
},
{
MFX_ERR_NOT_ENOUGH_BUFFER
,
AVERROR
(
ENOMEM
),
"insufficient input/output buffer"
},
{
MFX_ERR_INVALID_HANDLE
,
AVERROR
(
EINVAL
),
"invalid handle"
},
{
MFX_ERR_LOCK_MEMORY
,
AVERROR
(
EIO
),
"failed to lock the memory block"
},
{
MFX_ERR_NOT_INITIALIZED
,
AVERROR_BUG
,
"not initialized"
},
{
MFX_ERR_NOT_FOUND
,
AVERROR
(
ENOSYS
),
"specified object was not found"
},
{
MFX_ERR_MORE_DATA
,
AVERROR
(
EAGAIN
),
"expect more data at input"
},
{
MFX_ERR_MORE_SURFACE
,
AVERROR
(
EAGAIN
),
"expect more surface at output"
},
{
MFX_ERR_ABORTED
,
AVERROR_UNKNOWN
,
"operation aborted"
},
{
MFX_ERR_DEVICE_LOST
,
AVERROR
(
EIO
),
"device lost"
},
{
MFX_ERR_INCOMPATIBLE_VIDEO_PARAM
,
AVERROR
(
EINVAL
),
"incompatible video parameters"
},
{
MFX_ERR_INVALID_VIDEO_PARAM
,
AVERROR
(
EINVAL
),
"invalid video parameters"
},
{
MFX_ERR_UNDEFINED_BEHAVIOR
,
AVERROR_BUG
,
"undefined behavior"
},
{
MFX_ERR_DEVICE_FAILED
,
AVERROR
(
EIO
),
"device failed"
},
{
MFX_ERR_MORE_BITSTREAM
,
AVERROR
(
EAGAIN
),
"expect more bitstream at output"
},
{
MFX_ERR_INCOMPATIBLE_AUDIO_PARAM
,
AVERROR
(
EINVAL
),
"incompatible audio parameters"
},
{
MFX_ERR_INVALID_AUDIO_PARAM
,
AVERROR
(
EINVAL
),
"invalid audio parameters"
},
{
MFX_WRN_IN_EXECUTION
,
0
,
"operation in execution"
},
{
MFX_WRN_DEVICE_BUSY
,
0
,
"device busy"
},
{
MFX_WRN_VIDEO_PARAM_CHANGED
,
0
,
"video parameters changed"
},
{
MFX_WRN_PARTIAL_ACCELERATION
,
0
,
"partial acceleration"
},
{
MFX_WRN_INCOMPATIBLE_VIDEO_PARAM
,
0
,
"incompatible video parameters"
},
{
MFX_WRN_VALUE_NOT_CHANGED
,
0
,
"value is saturated"
},
{
MFX_WRN_OUT_OF_RANGE
,
0
,
"value out of range"
},
{
MFX_WRN_FILTER_SKIPPED
,
0
,
"filter skipped"
},
{
MFX_WRN_INCOMPATIBLE_AUDIO_PARAM
,
0
,
"incompatible audio parameters"
},
};
int
ff_qsv_map_error
(
mfxStatus
mfx_err
,
const
char
**
desc
)
{
{
switch
(
mfx_err
)
{
int
i
;
case
MFX_ERR_NONE
:
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
qsv_errors
);
i
++
)
{
return
0
;
if
(
qsv_errors
[
i
].
mfxerr
==
mfx_err
)
{
case
MFX_ERR_MEMORY_ALLOC
:
if
(
desc
)
case
MFX_ERR_NOT_ENOUGH_BUFFER
:
*
desc
=
qsv_errors
[
i
].
desc
;
return
AVERROR
(
ENOMEM
);
return
qsv_errors
[
i
].
averr
;
case
MFX_ERR_INVALID_HANDLE
:
}
return
AVERROR
(
EINVAL
);
case
MFX_ERR_DEVICE_FAILED
:
case
MFX_ERR_DEVICE_LOST
:
case
MFX_ERR_LOCK_MEMORY
:
return
AVERROR
(
EIO
);
case
MFX_ERR_NULL_PTR
:
case
MFX_ERR_UNDEFINED_BEHAVIOR
:
case
MFX_ERR_NOT_INITIALIZED
:
return
AVERROR_BUG
;
case
MFX_ERR_UNSUPPORTED
:
case
MFX_ERR_NOT_FOUND
:
return
AVERROR
(
ENOSYS
);
case
MFX_ERR_MORE_DATA
:
case
MFX_ERR_MORE_SURFACE
:
case
MFX_ERR_MORE_BITSTREAM
:
return
AVERROR
(
EAGAIN
);
case
MFX_ERR_INCOMPATIBLE_VIDEO_PARAM
:
case
MFX_ERR_INVALID_VIDEO_PARAM
:
return
AVERROR
(
EINVAL
);
case
MFX_ERR_ABORTED
:
case
MFX_ERR_UNKNOWN
:
default:
return
AVERROR_UNKNOWN
;
}
}
if
(
desc
)
*
desc
=
"unknown error"
;
return
AVERROR_UNKNOWN
;
}
int
ff_qsv_print_error
(
void
*
log_ctx
,
mfxStatus
err
,
const
char
*
error_string
)
{
const
char
*
desc
;
int
ret
;
ret
=
ff_qsv_map_error
(
err
,
&
desc
);
av_log
(
log_ctx
,
AV_LOG_ERROR
,
"%s: %s (%d)
\n
"
,
error_string
,
desc
,
err
);
return
ret
;
}
}
int
ff_qsv_map_pixfmt
(
enum
AVPixelFormat
format
,
uint32_t
*
fourcc
)
int
ff_qsv_map_pixfmt
(
enum
AVPixelFormat
format
,
uint32_t
*
fourcc
)
...
@@ -138,9 +166,10 @@ static int qsv_load_plugins(mfxSession session, const char *load_plugins,
...
@@ -138,9 +166,10 @@ static int qsv_load_plugins(mfxSession session, const char *load_plugins,
ret
=
MFXVideoUSER_Load
(
session
,
&
uid
,
1
);
ret
=
MFXVideoUSER_Load
(
session
,
&
uid
,
1
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
av_log
(
logctx
,
AV_LOG_ERROR
,
"Could not load the requested plugin: %s
\n
"
,
char
errorbuf
[
128
];
plugin
);
snprintf
(
errorbuf
,
sizeof
(
errorbuf
),
err
=
ff_qsv_error
(
ret
);
"Could not load the requested plugin '%s'"
,
plugin
);
err
=
ff_qsv_print_error
(
logctx
,
ret
,
errorbuf
);
goto
load_plugin_fail
;
goto
load_plugin_fail
;
}
}
...
@@ -166,10 +195,9 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
...
@@ -166,10 +195,9 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
int
ret
;
int
ret
;
ret
=
MFXInit
(
impl
,
&
ver
,
session
);
ret
=
MFXInit
(
impl
,
&
ver
,
session
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error initializing an internal MFX session
\n
"
);
return
ff_qsv_print_error
(
avctx
,
ret
,
return
ff_qsv_error
(
ret
);
"Error initializing an internal MFX session"
);
}
ret
=
qsv_load_plugins
(
*
session
,
load_plugins
,
avctx
);
ret
=
qsv_load_plugins
(
*
session
,
load_plugins
,
avctx
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -282,10 +310,9 @@ int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession,
...
@@ -282,10 +310,9 @@ int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession,
err
=
MFXQueryIMPL
(
parent_session
,
&
impl
);
err
=
MFXQueryIMPL
(
parent_session
,
&
impl
);
if
(
err
==
MFX_ERR_NONE
)
if
(
err
==
MFX_ERR_NONE
)
err
=
MFXQueryVersion
(
parent_session
,
&
ver
);
err
=
MFXQueryVersion
(
parent_session
,
&
ver
);
if
(
err
!=
MFX_ERR_NONE
)
{
if
(
err
!=
MFX_ERR_NONE
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error querying the session attributes
\n
"
);
return
ff_qsv_print_error
(
avctx
,
err
,
return
ff_qsv_error
(
err
);
"Error querying the session attributes"
);
}
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
handle_types
);
i
++
)
{
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
handle_types
);
i
++
)
{
err
=
MFXVideoCORE_GetHandle
(
parent_session
,
handle_types
[
i
],
&
handle
);
err
=
MFXVideoCORE_GetHandle
(
parent_session
,
handle_types
[
i
],
&
handle
);
...
@@ -301,18 +328,15 @@ int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession,
...
@@ -301,18 +328,15 @@ int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession,
}
}
err
=
MFXInit
(
impl
,
&
ver
,
&
session
);
err
=
MFXInit
(
impl
,
&
ver
,
&
session
);
if
(
err
!=
MFX_ERR_NONE
)
{
if
(
err
!=
MFX_ERR_NONE
)
av_log
(
avctx
,
AV_LOG_ERROR
,
return
ff_qsv_print_error
(
avctx
,
err
,
"Error initializing a child MFX session: %d
\n
"
,
err
);
"Error initializing a child MFX session"
);
return
ff_qsv_error
(
err
);
}
if
(
handle
)
{
if
(
handle
)
{
err
=
MFXVideoCORE_SetHandle
(
session
,
handle_type
,
handle
);
err
=
MFXVideoCORE_SetHandle
(
session
,
handle_type
,
handle
);
if
(
err
!=
MFX_ERR_NONE
)
{
if
(
err
!=
MFX_ERR_NONE
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error setting a HW handle: %d
\n
"
,
err
);
return
ff_qsv_print_error
(
avctx
,
err
,
return
ff_qsv_error
(
err
);
"Error setting a HW handle"
);
}
}
}
ret
=
qsv_load_plugins
(
session
,
load_plugins
,
avctx
);
ret
=
qsv_load_plugins
(
session
,
load_plugins
,
avctx
);
...
@@ -334,10 +358,9 @@ int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession,
...
@@ -334,10 +358,9 @@ int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession,
qsv_frames_ctx
->
mids
[
i
]
=
frames_hwctx
->
surfaces
[
i
].
Data
.
MemId
;
qsv_frames_ctx
->
mids
[
i
]
=
frames_hwctx
->
surfaces
[
i
].
Data
.
MemId
;
err
=
MFXVideoCORE_SetFrameAllocator
(
session
,
&
frame_allocator
);
err
=
MFXVideoCORE_SetFrameAllocator
(
session
,
&
frame_allocator
);
if
(
err
!=
MFX_ERR_NONE
)
{
if
(
err
!=
MFX_ERR_NONE
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error setting a frame allocator: %d
\n
"
,
err
);
return
ff_qsv_print_error
(
avctx
,
err
,
return
ff_qsv_error
(
err
);
"Error setting a frame allocator"
);
}
}
}
*
psession
=
session
;
*
psession
=
session
;
...
...
libavcodec/qsv_internal.h
View file @
95414eb2
...
@@ -57,7 +57,10 @@ typedef struct QSVFramesContext {
...
@@ -57,7 +57,10 @@ typedef struct QSVFramesContext {
/**
/**
* Convert a libmfx error code into a libav error code.
* Convert a libmfx error code into a libav error code.
*/
*/
int
ff_qsv_error
(
int
mfx_err
);
int
ff_qsv_map_error
(
mfxStatus
mfx_err
,
const
char
**
desc
);
int
ff_qsv_print_error
(
void
*
log_ctx
,
mfxStatus
err
,
const
char
*
error_string
);
int
ff_qsv_codec_id_to_mfx
(
enum
AVCodecID
codec_id
);
int
ff_qsv_codec_id_to_mfx
(
enum
AVCodecID
codec_id
);
...
...
libavcodec/qsvdec.c
View file @
95414eb2
...
@@ -161,10 +161,9 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
...
@@ -161,10 +161,9 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
param
.
NumExtParam
=
q
->
nb_ext_buffers
;
param
.
NumExtParam
=
q
->
nb_ext_buffers
;
ret
=
MFXVideoDECODE_Init
(
q
->
session
,
&
param
);
ret
=
MFXVideoDECODE_Init
(
q
->
session
,
&
param
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error initializing the MFX video decoder
\n
"
);
return
ff_qsv_print_error
(
avctx
,
ret
,
return
ff_qsv_error
(
ret
);
"Error initializing the MFX video decoder"
);
}
q
->
frame_info
=
param
.
mfx
.
FrameInfo
;
q
->
frame_info
=
param
.
mfx
.
FrameInfo
;
...
@@ -298,9 +297,9 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
...
@@ -298,9 +297,9 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
ret
!=
MFX_ERR_MORE_DATA
&&
ret
!=
MFX_ERR_MORE_DATA
&&
ret
!=
MFX_WRN_VIDEO_PARAM_CHANGED
&&
ret
!=
MFX_WRN_VIDEO_PARAM_CHANGED
&&
ret
!=
MFX_ERR_MORE_SURFACE
)
{
ret
!=
MFX_ERR_MORE_SURFACE
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error during QSV decoding.
\n
"
);
av_freep
(
&
sync
);
av_freep
(
&
sync
);
return
ff_qsv_error
(
ret
);
return
ff_qsv_print_error
(
avctx
,
ret
,
"Error during QSV decoding."
);
}
}
/* make sure we do not enter an infinite loop if the SDK
/* make sure we do not enter an infinite loop if the SDK
...
...
libavcodec/qsvenc.c
View file @
95414eb2
...
@@ -601,7 +601,8 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q)
...
@@ -601,7 +601,8 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q)
ret
=
MFXVideoENCODE_GetVideoParam
(
q
->
session
,
&
q
->
param
);
ret
=
MFXVideoENCODE_GetVideoParam
(
q
->
session
,
&
q
->
param
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ff_qsv_error
(
ret
);
return
ff_qsv_print_error
(
avctx
,
ret
,
"Error calling GetVideoParam"
);
q
->
packet_size
=
q
->
param
.
mfx
.
BufferSizeInKB
*
1000
;
q
->
packet_size
=
q
->
param
.
mfx
.
BufferSizeInKB
*
1000
;
...
@@ -750,10 +751,9 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
...
@@ -750,10 +751,9 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
return
ret
;
return
ret
;
ret
=
MFXVideoENCODE_QueryIOSurf
(
q
->
session
,
&
q
->
param
,
&
q
->
req
);
ret
=
MFXVideoENCODE_QueryIOSurf
(
q
->
session
,
&
q
->
param
,
&
q
->
req
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error querying the encoding parameters
\n
"
);
return
ff_qsv_print_error
(
avctx
,
ret
,
return
ff_qsv_error
(
ret
);
"Error querying the encoding parameters"
);
}
if
(
opaque_alloc
)
{
if
(
opaque_alloc
)
{
ret
=
qsv_init_opaque_alloc
(
avctx
,
q
);
ret
=
qsv_init_opaque_alloc
(
avctx
,
q
);
...
@@ -791,10 +791,9 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
...
@@ -791,10 +791,9 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
}
}
ret
=
MFXVideoENCODE_Init
(
q
->
session
,
&
q
->
param
);
ret
=
MFXVideoENCODE_Init
(
q
->
session
,
&
q
->
param
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Error initializing the encoder
\n
"
);
return
ff_qsv_print_error
(
avctx
,
ret
,
return
ff_qsv_error
(
ret
);
"Error initializing the encoder"
);
}
ret
=
qsv_retrieve_enc_params
(
avctx
,
q
);
ret
=
qsv_retrieve_enc_params
(
avctx
,
q
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -979,7 +978,8 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
...
@@ -979,7 +978,8 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q,
av_packet_unref
(
&
new_pkt
);
av_packet_unref
(
&
new_pkt
);
av_freep
(
&
bs
);
av_freep
(
&
bs
);
av_freep
(
&
sync
);
av_freep
(
&
sync
);
return
(
ret
==
MFX_ERR_MORE_DATA
)
?
0
:
ff_qsv_error
(
ret
);
return
(
ret
==
MFX_ERR_MORE_DATA
)
?
0
:
ff_qsv_print_error
(
avctx
,
ret
,
"Error during encoding"
);
}
}
if
(
ret
==
MFX_WRN_INCOMPATIBLE_VIDEO_PARAM
&&
frame
->
interlaced_frame
)
if
(
ret
==
MFX_WRN_INCOMPATIBLE_VIDEO_PARAM
&&
frame
->
interlaced_frame
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment