]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/g723_1enc: Avoid skip_put_bits()
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 31 Jul 2020 08:45:48 +0000 (10:45 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 1 Aug 2020 17:08:11 +0000 (19:08 +0200)
If a bit is reserved, it matters very much what value it has, because
otherwise a decoder conforming to a future version of the standard might
interpret the output file in an unintended manner. This implies that
one must not use skip_put_bits() for it (which does not give any
guarantees wrt what ends up in the output (in case of a little-endian
bitstream writer (as here) it writes a 0 bit)); given that the reference
encoder as well as the earlier code write a zero bit at this place, the
new code does, too.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/g723_1enc.c

index 592840566e92c350828eb1c805b2e57fd787c5c8..b2ba3c2230fbe1e7c2ea8fea032f9f5e900a7392 100644 (file)
@@ -1030,7 +1030,7 @@ static int pack_bitstream(G723_1_ChannelContext *p, AVPacket *avpkt)
     put_bits(&pb, 1, p->subframe[3].grid_index);
 
     if (p->cur_rate == RATE_6300) {
-        skip_put_bits(&pb, 1); /* reserved bit */
+        put_bits(&pb, 1, 0); /* reserved bit */
 
         /* Write 13 bit combined position index */
         temp = (p->subframe[0].pulse_pos >> 16) * 810 +