From patchwork Fri Jul 31 10:39:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21401 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C905A44A5EB for ; Fri, 31 Jul 2020 13:40:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B351268B815; Fri, 31 Jul 2020 13:40:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA1A368B808 for ; Fri, 31 Jul 2020 13:40:19 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id a26so5155016ejc.2 for ; Fri, 31 Jul 2020 03:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eBaqGemil/s1nzrmP9/9fUsl/Fr+gxtmIzTRn2i+4hM=; b=qlgyE9EH0cb2qWFHaA4RzAa1wZJJOTUmZ5dS86juEqh11qxdOS5TQ0x//MSdYq9/FF sfNYbwhMbG28zkqJWqrmiNxFFgS136eT2jsx33EFDN9IYOFzs86j9vVdgsE6JOlPkZd3 6T2rDbYSk/aQ5zfp9PwDjs8u4iFNgTonyauSTguzE244C9CyLJCqIFJC+QKFmr4QueJJ d3hQLNf9Kpr4T4GlHuWQpC768m3YcUP5Z9gCzszkXY89sr0bOis/Ms0hDIqK6lwUlnXr 9fmZNU1QPdxnveQdwkvAse3tRvavs7Pso7xyR8/o5SQYmFdDQ7fswCMYBXUhxnt22KLW jWRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eBaqGemil/s1nzrmP9/9fUsl/Fr+gxtmIzTRn2i+4hM=; b=s/zHkk32zH9gNduUwo9mglke2sHkIqPHwdXump8Lcq1nvJo7CjDCMEKlh/yQjf90wU ZYwMkdIzRECZAiswtAoTIIIfTRa9W37OG14k3/N3fzwtQNLdbmEs5fYI4X9AyAPoXHpo e+VUZ6q+/r6P25rdY2VI0h29yg//ziXujp/wcq8eCPK0LgeERrmnhWSQOEb1gUnjMXGk zKLPlLXrBsGfQA2vEkBtenTKaPk3PkQs/3JIfgwXqDMjSMI+N9wDeT+oQvDEWfOjFf/t AVpK9RAJhVIBQVqSENNL8k5UsWDwTjpw99On8maX6CuEtV36ZigzPPIbBu5M2bYRFqLC /dhA== X-Gm-Message-State: AOAM530yjyKh7fw41BFPi8YuSwdceaaKI5/pWXXQtbixbzzBtuf3QvUB fjD6W60r647syRLSdqw07Sw4jB49 X-Google-Smtp-Source: ABdhPJwWHSUyrOe0FijgDV9kNUrdEQmlEJqhAGnnSFkXAlDZeWv/VSDIisel2HIC2RSRB4iXe9aweA== X-Received: by 2002:a17:906:c18d:: with SMTP id g13mr3272359ejz.239.1596192018844; Fri, 31 Jul 2020 03:40:18 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id k18sm8877891ejp.81.2020.07.31.03.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 03:40:18 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Jul 2020 12:39:46 +0200 Message-Id: <20200731103946.2843-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731103946.2843-1-andreas.rheinhardt@gmail.com> References: <20200731103946.2843-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/g723_1enc: Avoid skip_put_bits() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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. Signed-off-by: Andreas Rheinhardt --- The earlier code here was unaffected by any of the bugs of skip_put_bits, because this code uses a little-endian writer and the number of bits written so far was always even, so that skipping a single bit could be done in the buffer itself. libavcodec/g723_1enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index 592840566e..b2ba3c2230 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -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 +