Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Scott Theisen <scott.the.elm@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Scott Theisen <scott.the.elm@gmail.com>
Subject: [FFmpeg-devel] [PATCH 3/8] avpriv_find_start_code(): make the state parameter output only
Date: Tue,  1 Feb 2022 16:20:51 -0500
Message-ID: <20220201212056.29712-4-scott.the.elm@gmail.com> (raw)
In-Reply-To: <20220201212056.29712-1-scott.the.elm@gmail.com>

---
 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".

  parent reply	other threads:[~2022-02-01 21:21 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 21:20 [FFmpeg-devel] [PATCH 0/8] rewrite avpriv_find_start_code() for clarity Scott Theisen
2022-02-01 21:20 ` [FFmpeg-devel] [PATCH 1/8] avpriv_find_start_code(): readability enhancement part 1 Scott Theisen
2022-02-01 21:20 ` [FFmpeg-devel] [PATCH 2/8] avpriv_find_start_code(): rewrite while loop and add comments for clarity Scott Theisen
2022-02-01 21:20 ` Scott Theisen [this message]
2022-02-02  0:15   ` [FFmpeg-devel] [PATCH 3/8] avpriv_find_start_code(): make the state parameter output only Andreas Rheinhardt
2022-02-02  3:25     ` Scott Theisen
2022-02-02  3:29       ` Andreas Rheinhardt
2022-02-01 21:20 ` [FFmpeg-devel] [PATCH 4/8] avpriv_find_start_code(): add doxygen comment and rename a parameter Scott Theisen
2022-02-01 21:20 ` [FFmpeg-devel] [PATCH 5/8] avpriv_find_start_code(): replace unnecessary for loop Scott Theisen
2022-02-01 21:20 ` [FFmpeg-devel] [PATCH 6/8] avcodec/internal.h: create avpriv_start_code_is_valid() Scott Theisen
2022-02-01 21:20 ` [FFmpeg-devel] [PATCH 7/8] cbs_mpeg2.c: use a while loop with a loop condition instead of an infinite loop Scott Theisen
2022-02-01 21:20 ` [FFmpeg-devel] [PATCH 8/8] avpriv_find_start_code(): reduce the number of iterations Scott Theisen
2022-02-03 18:44 ` [FFmpeg-devel] [PATCH v2 0/13] rewrite avpriv_find_start_code() for clarity Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 01/13] avcodec/internal.h: create avpriv_start_code_is_valid() Scott Theisen
2022-02-05  5:42     ` Andreas Rheinhardt
2022-02-05  5:57       ` Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 02/13] avpriv_find_start_code(): readability enhancement part 1 Scott Theisen
2022-02-05  6:26     ` Andreas Rheinhardt
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 03/13] avpriv_find_start_code(): rewrite while loop and add comments for clarity Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 04/13] avpriv_find_start_code(): rewrite for loop " Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 05/13] avpriv_find_start_code(): add doxygen comment and rename a parameter Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 06/13] avpriv_find_start_code(): correct type of start_code parameter Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 07/13] avpriv_find_start_code(): constify pointer parameters Scott Theisen
2022-02-05  5:49     ` Andreas Rheinhardt
2022-02-05  6:08       ` Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 08/13] avpriv_find_start_code(): add parameter for ignoring history Scott Theisen
2022-02-05  6:10     ` Andreas Rheinhardt
2022-02-05  9:00       ` Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 09/13] avpriv_find_start_code(): fix indent from previous commit Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 10/13] cbs_mpeg2.c: use a while loop with a loop condition instead of an infinite loop Scott Theisen
2022-02-05  1:48     ` Andreas Rheinhardt
2022-02-05  3:47       ` Scott Theisen
2022-02-05  4:06         ` Andreas Rheinhardt
2022-02-05  4:09           ` Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 11/13] cbs_mpeg2.c: improve readability of start code search (part 1) Scott Theisen
2022-02-05  2:16     ` Andreas Rheinhardt
2022-02-05  3:53       ` Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 12/13] cbs_mpeg2.c: improve readability of start code search (part 2) Scott Theisen
2022-02-05  2:24     ` Andreas Rheinhardt
2022-02-05  3:59       ` Scott Theisen
2022-02-03 18:44   ` [FFmpeg-devel] [PATCH v2 13/13] cbs_mpeg2.c: improve readability of start code search (part 3) Scott Theisen
2022-02-05  3:54     ` Andreas Rheinhardt
2022-02-05  4:26       ` Scott Theisen
2022-02-09  3:28 ` [FFmpeg-devel] [PATCH v3 0/8] rewrite avpriv_find_start_code() for clarity Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 1/8] avcodec/startcode.h: create start_code_is_valid() Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 2/8] avpriv_find_start_code(): readability enhancement part 1 Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 3/8] avpriv_find_start_code(): rewrite while loop Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 4/8] avpriv_find_start_code(): rewrite for loop for clarity Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 5/8] avpriv_find_start_code(): add doxygen comment and rename a parameter Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 6/8] avpriv_find_start_code(): correct type of start_code parameter Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 7/8] avpriv_find_start_code(): constify pointer parameters Scott Theisen
2022-02-09  3:28   ` [FFmpeg-devel] [PATCH v3 8/8] avpriv_find_start_code(): make start_code output only Scott Theisen
2022-03-07 18:44   ` [FFmpeg-devel] [PATCH v3 0/8] rewrite avpriv_find_start_code() for clarity Scott Theisen
2022-09-16 18:19 ` [FFmpeg-devel] [PATCH v4 " Scott Theisen
2022-09-16 18:19   ` [FFmpeg-devel] [PATCH v4 1/8] avcodec/startcode.h: create start_code_is_valid() Scott Theisen
2022-09-16 18:19   ` [FFmpeg-devel] [PATCH v4 2/8] avpriv_find_start_code(): readability enhancement part 1 Scott Theisen
2022-09-16 18:19   ` [FFmpeg-devel] [PATCH v4 3/8] avpriv_find_start_code(): rewrite while loop Scott Theisen
2022-09-16 18:19   ` [FFmpeg-devel] [PATCH v4 4/8] avpriv_find_start_code(): rewrite for loop for clarity Scott Theisen
2022-09-16 18:19   ` [FFmpeg-devel] [PATCH v4 5/8] avpriv_find_start_code(): add doxygen comment and rename a parameter Scott Theisen
2022-09-16 18:20   ` [FFmpeg-devel] [PATCH v4 6/8] avpriv_find_start_code(): correct type of start_code parameter Scott Theisen
2022-09-16 18:20   ` [FFmpeg-devel] [PATCH v4 7/8] avpriv_find_start_code(): constify pointer parameters Scott Theisen
2022-09-16 18:20   ` [FFmpeg-devel] [PATCH v4 8/8] avpriv_find_start_code(): make start_code output only Scott Theisen
2022-09-16 18:26   ` [FFmpeg-devel] [PATCH v4 0/8] rewrite avpriv_find_start_code() for clarity Scott Theisen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220201212056.29712-4-scott.the.elm@gmail.com \
    --to=scott.the.elm@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git