diff mbox series

[FFmpeg-devel,25/46] avcodec/jpeglsenc: Remove redundant implicit checks

Message ID HE1PR0301MB21541B696C1C99E73264B0838F5F9@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 83cb9be1d2f6037d11c921835d8300ae8acf44f8
Headers show
Series [FFmpeg-devel,01/46] avcodec/a64multienc: Avoid intermediate buffer | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 29, 2021, 11:56 p.m. UTC
Now that the proper buffer size is calculated (and checked) before
allocating the buffer, it is known that the buffer always suffices.
So use the unchecked PutBit-API; and also use an unchecked bitstream
reader as we check ourselves.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/jpeglsenc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index a7bcd78275..c80d7373cf 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -25,6 +25,7 @@ 
  * JPEG-LS encoder.
  */
 
+#define UNCHECKED_BITSTREAM_READER 1
 #include "avcodec.h"
 #include "bytestream.h"
 #include "encode.h"
@@ -53,12 +54,6 @@  static inline void put_marker_byteu(PutByteContext *pb, enum JpegMarker code)
     bytestream2_put_byteu(pb, code);
 }
 
-static inline void put_marker_byte(PutByteContext *pb, enum JpegMarker code)
-{
-    bytestream2_put_byte(pb, 0xff);
-    bytestream2_put_byte(pb, code);
-}
-
 /**
  * Encode error from regular symbol
  */
@@ -408,15 +403,15 @@  static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
     while (get_bits_count(&gb) < size_in_bits) {
         int v;
         v = get_bits(&gb, 8);
-        bytestream2_put_byte(&pb, v);
+        bytestream2_put_byteu(&pb, v);
         if (v == 0xFF) {
             v = get_bits(&gb, 7);
-            bytestream2_put_byte(&pb, v);
+            bytestream2_put_byteu(&pb, v);
         }
     }
 
     /* End of image */
-    put_marker_byte(&pb, EOI);
+    put_marker_byteu(&pb, EOI);
 
     emms_c();