From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D0C9540963 for ; Tue, 1 Feb 2022 21:21:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CDFB568B00F; Tue, 1 Feb 2022 23:21:16 +0200 (EET) Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0D2268AF71 for ; Tue, 1 Feb 2022 23:21:09 +0200 (EET) Received: by mail-qk1-f169.google.com with SMTP id o10so16427211qkg.0 for ; Tue, 01 Feb 2022 13:21:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HYYGPGAIvrNnww5f39ybFiTJm6f8Gl1N+q59NK1yVao=; b=Ce+MmGexvnJawMcVMv9dZ6CSsaXrTHfTFI+0eaNQETr/7stdGjIWvaHBa1UZV8jTUJ gQmvbaGle5Lvi6uC5Zz7lD14aWYt8jehAiR0I6NqJFFqm6FFILN80hGuJZ10tNcPWfFq lzYdrYim4Yk2flBbXQnHL4KSEW0+faV44IRXjZAWhAfInR5cVY0BjmSkuCi9R6QpFl+W /k6G4Fm/sOjTYr45uQN30BFri5W39DQTFRlnf481k4z8cWfqNjCzbWJw/Bo1b/L9wSB9 urZEWPiESAbRoeAHZKlQhoqZI7UblFI5oHrsm7VO+GR9+gxPT1tQ2lyrplR/Zq0lr6Gg giyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HYYGPGAIvrNnww5f39ybFiTJm6f8Gl1N+q59NK1yVao=; b=iqTBHa6oze23kXTErFqctW70F7RSgtRR85EqDuU31BlxIlemnS7EadFVizaiJ7CdZA id7TXUqMVPgJ9j9jHpPnV146w3ONmTV+0yQgkJijdTnrYV0cIsydr3CCHNroZZB8KYt5 fd8R+tLc8ipYx88sH6RQzr4hRDhPwrUE4e6DKP/Z6Uf+3SzK07IjKOJtp3GOIxO6wpMa h/mj6tfWu4FFe/OTuGnsWRSmWGrFWbJV4uMmG7TEdEZ4kHnJlSQxQZXN0jd7ESdbF+7j JHn6CnBIrpC31IXC83/7+JIkRQ8CQqPg2Wefa0upBZNBCXPBra1AomXrwUJPYWAQ6A6B VkiQ== X-Gm-Message-State: AOAM531IXnqgnquytiLNY+aeb6O6tlVKDev7fQhwx07op2s6Iix07xu0 8KB3PGxiERnOIlyluXHABZ/eEog6A4/AQA== X-Google-Smtp-Source: ABdhPJyZXU2kUczdCzl3m4v4TeEfqRuVUAdweJ7Q2JShxkTjl/+IrvevQVTEa9I2kyE2JJLKy5KUSA== X-Received: by 2002:a05:620a:2687:: with SMTP id c7mr15611743qkp.341.1643750468274; Tue, 01 Feb 2022 13:21:08 -0800 (PST) Received: from localhost.localdomain ([151.200.235.219]) by smtp.gmail.com with ESMTPSA id ay18sm2928225qkb.8.2022.02.01.13.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 13:21:07 -0800 (PST) From: Scott Theisen To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 16:20:51 -0500 Message-Id: <20220201212056.29712-4-scott.the.elm@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220201212056.29712-1-scott.the.elm@gmail.com> References: <20220201212056.29712-1-scott.the.elm@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] avpriv_find_start_code(): make the state parameter output only X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Scott Theisen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- libavcodec/cbs_mpeg2.c | 8 -------- libavcodec/mpeg12dec.c | 5 ++--- libavcodec/mpeg4_unpack_bframes_bsf.c | 1 - libavcodec/mpegvideo_parser.c | 3 +-- libavcodec/utils.c | 1 + libavformat/rtpenc_mpv.c | 3 +-- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 26400f279f..03ea49cbca 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -160,14 +160,6 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, for (i = 0;; i++) { unit_type = start_code & 0xff; - if (start == frag->data + frag->data_size) { - // The last four bytes form a start code which constitutes - // a unit of its own. In this situation avpriv_find_start_code - // won't modify start_code at all so modify start_code so that - // the next unit will be treated as the last unit. - start_code = 0; - } - end = avpriv_find_start_code(start--, frag->data + frag->data_size, &start_code); diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 4a7bd6d466..1110fcb319 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1770,7 +1770,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, if (avctx->hwaccel && avctx->hwaccel->decode_slice) { const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ - int start_code = -1; + uint32_t start_code; buf_end = avpriv_find_start_code(buf_start + 2, *buf + buf_size, &start_code); if (buf_end < *buf + buf_size) buf_end -= 4; @@ -2020,7 +2020,6 @@ static int slice_decode_thread(AVCodecContext *c, void *arg) if (s->mb_y == s->end_mb_y) return 0; - start_code = -1; buf = avpriv_find_start_code(buf, s->gb.buffer_end, &start_code); if (start_code < SLICE_MIN_START_CODE || start_code > SLICE_MAX_START_CODE) return AVERROR_INVALIDDATA; @@ -2475,7 +2474,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, for (;;) { /* find next start code */ - uint32_t start_code = -1; + uint32_t start_code; buf_ptr = avpriv_find_start_code(buf_ptr, buf_end, &start_code); if (start_code > 0x1ff) { if (!skip_frame) { diff --git a/libavcodec/mpeg4_unpack_bframes_bsf.c b/libavcodec/mpeg4_unpack_bframes_bsf.c index 6f8595713d..8b3fda0b03 100644 --- a/libavcodec/mpeg4_unpack_bframes_bsf.c +++ b/libavcodec/mpeg4_unpack_bframes_bsf.c @@ -36,7 +36,6 @@ static void scan_buffer(const uint8_t *buf, int buf_size, const uint8_t *end = buf + buf_size, *pos = buf; while (pos < end) { - startcode = -1; pos = avpriv_find_start_code(pos, end, &startcode); if (startcode == USER_DATA_STARTCODE && pos_p) { diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index c5dc867d24..c991a82405 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -105,7 +105,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, { struct MpvParseContext *pc = s->priv_data; const uint8_t *buf_end = buf + buf_size; - uint32_t start_code; int frame_rate_index, ext_type, bytes_left; int frame_rate_ext_n, frame_rate_ext_d; int top_field_first, repeat_first_field, progressive_frame; @@ -120,7 +119,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, s->repeat_pict = 0; while (buf < buf_end) { - start_code= -1; + uint32_t start_code; buf= avpriv_find_start_code(buf, buf_end, &start_code); bytes_left = buf_end - buf; switch(start_code) { diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 882f90be79..cf88e0a759 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -950,6 +950,7 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, if (p >= end) return end; + *state = ~0; for (i = 0; i < 3; i++) { uint32_t tmp = *state << 8; *state = tmp + *(p++); diff --git a/libavformat/rtpenc_mpv.c b/libavformat/rtpenc_mpv.c index 4b45f51772..bb63c9bdc6 100644 --- a/libavformat/rtpenc_mpv.c +++ b/libavformat/rtpenc_mpv.c @@ -51,11 +51,10 @@ void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size) end_of_slice = 1; } else { const uint8_t *r, *r1; - int start_code; r1 = buf1; while (1) { - start_code = -1; + uint32_t start_code; r = avpriv_find_start_code(r1, end, &start_code); if((start_code & 0xFFFFFF00) == 0x100) { /* New start code found */ -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".