From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 68A2345326 for ; Sat, 22 Jul 2023 14:11:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E91F068C5D7; Sat, 22 Jul 2023 17:11:17 +0300 (EEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CA58B68C501 for ; Sat, 22 Jul 2023 17:11:10 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id EC24FC0002 for ; Sat, 22 Jul 2023 14:11:09 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 22 Jul 2023 16:11:03 +0200 Message-Id: <20230722141104.3327415-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230722141104.3327415-1-michael@niedermayer.cc> References: <20230722141104.3327415-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 4/5] avradio/sdrdemux: avoid literal offsets in dump code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Michael Niedermayer --- libavradio/sdrdemux.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index 66130d9662..09d720de23 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -1842,20 +1842,27 @@ process_next_block: sdr->block_center_freq = fifo_element[0].center_frequency; if (sdr->dump_avio) { - uint8_t header[48] = "FFSDR001int16BE"; + uint8_t header[16] = "FFSDR001int16BE"; uint8_t *tmp = (void*)sdr->windowed_block; //We use an unused array as temporary here + int64_t sizepos, endpos; if (sdr->sample_size == 2) memcpy(header + 11, "08", 2); - AV_WB32(header+16, sdr->sdr_sample_rate); - AV_WB32(header+20, sdr->block_size); - AV_WB64(header+24, av_double2int(fifo_element[0].center_frequency)); - AV_WB64(header+32, sdr->pts); - AV_WB32(header+40, sdr->bandwidth); - AV_WB32(header+44, sizeof(header)); - avio_write(sdr->dump_avio, header, sizeof(header)); + avio_wb32(sdr->dump_avio, sdr->sdr_sample_rate); + avio_wb32(sdr->dump_avio, sdr->block_size); + avio_wb64(sdr->dump_avio, av_double2int(fifo_element[0].center_frequency)); + avio_wb64(sdr->dump_avio, sdr->pts); + avio_wb32(sdr->dump_avio, sdr->bandwidth); + sizepos = avio_tell(sdr->dump_avio); + avio_wb32(sdr->dump_avio, 0); + + endpos = avio_tell(sdr->dump_avio); + + avio_seek(sdr->dump_avio, sizepos, SEEK_SET); + avio_wb32(sdr->dump_avio, endpos); + avio_seek(sdr->dump_avio, endpos, SEEK_SET); if (sdr->sample_size == 2) { avio_write(sdr->dump_avio, fifo_element[0].halfblock, sdr->block_size * sdr->sample_size); -- 2.31.1 _______________________________________________ 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".