[FFmpeg-devel] [PATCH 5/7] avcodec/cbs_h2645: Remove dead code to delete trailing zeroes

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Dec 10 00:26:02 EET 2019


Trailing zeroes are already discarded when splitting a fragment, which
makes the code to remove them when decomposing slices dead code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
This of course presupposes that the fragment has been split via
cbs_h2645_split_fragment(). And the current code is buggy even when one
does not make this assumption: The trailing zeroes should be discarded
before one reads the header. And then the GetBitContext needs to
reinitialized (otherwise, some of those trailing zeroes might be
considered valid data when reading the header).

 libavcodec/cbs_h2645.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 7c92ae4871..be82a8cd5f 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -857,13 +857,6 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx,
 
             pos = get_bits_count(&gbc);
             len = unit->data_size;
-            if (!unit->data[len - 1]) {
-                int z;
-                for (z = 0; z < len && !unit->data[len - z - 1]; z++);
-                av_log(ctx->log_ctx, AV_LOG_DEBUG, "Deleted %d trailing zeroes "
-                       "from slice data.\n", z);
-                len -= z;
-            }
 
             slice->data_size = len - pos / 8;
             slice->data_ref  = av_buffer_ref(unit->data_ref);
@@ -1039,13 +1032,6 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx,
 
             pos = get_bits_count(&gbc);
             len = unit->data_size;
-            if (!unit->data[len - 1]) {
-                int z;
-                for (z = 0; z < len && !unit->data[len - z - 1]; z++);
-                av_log(ctx->log_ctx, AV_LOG_DEBUG, "Deleted %d trailing zeroes "
-                       "from slice data.\n", z);
-                len -= z;
-            }
 
             slice->data_size = len - pos / 8;
             slice->data_ref  = av_buffer_ref(unit->data_ref);
-- 
2.20.1



More information about the ffmpeg-devel mailing list