[FFmpeg-devel] [PATCH 5/9] avcodec/videotoolbox: print descriptive errors on decode failures
wm4
nfxjfg at googlemail.com
Tue Sep 26 15:20:35 EEST 2017
On Mon, 25 Sep 2017 17:36:27 -0700
Aman Gupta <ffmpeg at tmm1.net> wrote:
> From: Aman Gupta <aman at tmm1.net>
>
> ---
> libavcodec/videotoolbox.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> index 1de556f3e8..f56ab1f8c9 100644
> --- a/libavcodec/videotoolbox.c
> +++ b/libavcodec/videotoolbox.c
> @@ -425,7 +425,22 @@ static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame)
> status = videotoolbox_session_decode_frame(avctx);
>
> if (status) {
> - av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
> + const char *error = NULL;
> + switch (status) {
> + case kVTVideoDecoderBadDataErr:
> + error = "bad data";
> + break;
> + case kVTVideoDecoderMalfunctionErr:
> + error = "decoder malfunction";
> + break;
> + case kVTInvalidSessionErr:
> + error = "invalid session";
> + break;
> + default:
> + error = "unknown";
> + break;
> + }
> + av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%s, %d)\n", error, status);
> return AVERROR_UNKNOWN;
> }
>
Is status really an int? If not, it should be casted (the safest way to
deal with "opaque" typedefs).
Bonus points for moving the error status->string switch mapping to a
separate function.
More information about the ffmpeg-devel
mailing list