From patchwork Fri Apr 10 19:02:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stebbins X-Patchwork-Id: 18822 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id F39A944A36F for ; Fri, 10 Apr 2020 22:05:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC38968B5F1; Fri, 10 Apr 2020 22:05:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.jetheaddev.com (mail.jetheaddev.com [70.164.99.34]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9283968B5C9 for ; Fri, 10 Apr 2020 22:05:24 +0300 (EEST) Received: from creator.alpe-d-promontory.fun (192.168.13.165) by cas.jetheaddev.com (192.168.13.27) with Microsoft SMTP Server (TLS) id 14.3.351.0; Fri, 10 Apr 2020 12:05:23 -0700 From: John Stebbins To: Date: Fri, 10 Apr 2020 13:02:23 -0600 Message-ID: <20200410190223.134413-8-jstebbins@jetheaddev.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200410190223.134413-1-jstebbins@jetheaddev.com> References: <20200410190223.134413-1-jstebbins@jetheaddev.com> MIME-Version: 1.0 X-Originating-IP: [192.168.13.165] Subject: [FFmpeg-devel] [PATCH 7/7] lavc/xsubenc: return meaningfull error codes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/xsubenc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index b3da909679..4d58e0f3b5 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -63,7 +63,7 @@ static int xsub_encode_rle(PutBitContext *pb, const uint8_t *bitmap, while (x0 < w) { // Make sure we have enough room for at least one run and padding if (pb->size_in_bits - put_bits_count(pb) < 7*8) - return -1; + return AVERROR_BUFFER_TOO_SMALL; x1 = x0; color = bitmap[x1++] & 3; @@ -124,7 +124,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, if (bufsize < 27 + 7*2 + 4*3) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for XSUB header.\n"); - return -1; + return AVERROR_BUFFER_TOO_SMALL; } // TODO: support multiple rects @@ -147,7 +147,7 @@ FF_ENABLE_DEPRECATION_WARNINGS // TODO: render text-based subtitles into bitmaps if (!h->rects[0]->data[0] || !h->rects[0]->data[1]) { av_log(avctx, AV_LOG_WARNING, "No subtitle bitmap available.\n"); - return -1; + return AVERROR(EINVAL); } // TODO: color reduction, similar to dvdsub encoder @@ -160,7 +160,7 @@ FF_ENABLE_DEPRECATION_WARNINGS if (make_tc(startTime, start_tc) || make_tc(endTime, end_tc)) { av_log(avctx, AV_LOG_WARNING, "Time code >= 100 hours.\n"); - return -1; + return AVERROR(EINVAL); } snprintf(buf, 28, @@ -195,13 +195,13 @@ FF_ENABLE_DEPRECATION_WARNINGS if (xsub_encode_rle(&pb, h->rects[0]->data[0], h->rects[0]->linesize[0] * 2, h->rects[0]->w, (h->rects[0]->h + 1) >> 1)) - return -1; + return AVERROR_BUFFER_TOO_SMALL; bytestream_put_le16(&rlelenptr, put_bits_count(&pb) >> 3); // Length of first field if (xsub_encode_rle(&pb, h->rects[0]->data[0] + h->rects[0]->linesize[0], h->rects[0]->linesize[0] * 2, h->rects[0]->w, h->rects[0]->h >> 1)) - return -1; + return AVERROR_BUFFER_TOO_SMALL; // Enforce total height to be a multiple of 2 if (h->rects[0]->h & 1) {