From patchwork Sat Jul 22 14:11:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42898 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be1d:b0:130:ccc6:6c4b with SMTP id ge29csp881194pzb; Sat, 22 Jul 2023 07:11:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7GRaW4QyQh8dYFj8VMw59V1MJ4CPsDO/TwyTVxuilVRzRErA+xdBGVai3tpuBGp+ns/n5 X-Received: by 2002:a17:906:74d6:b0:993:e695:b589 with SMTP id z22-20020a17090674d600b00993e695b589mr4218122ejl.20.1690035078145; Sat, 22 Jul 2023 07:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690035078; cv=none; d=google.com; s=arc-20160816; b=E1pVSTNBi06RQC8jr5m3CR+HUpNhHFfVZrORJ4jJ3LDcrjjpp7mNgxr31Vxt7QlJ68 K8dthJ0QjU3J0Em78SeNTe4BWIGzEBJEEh/pbSq4kyyG7MmGN4D4UoFuVJEtdCu4/dw2 bYxPOE2y3kyxERZgdzgvodNw+R8SOam3FPmrf0OLCAEDatVS/zQbVRHTDjadxKgxd3/N GoOqU2SVw4jD41iQ83vPjQ9IXR/vp/KHjY33BnhM/J07OnH5jVnoKa9qnMb5h2o3AwIk MGw6jT3uUROTSvTN9wBIVNhaVdNImCImss70TUVB8fZO8DdNT3FzGkSeOtOLzQtIsxEy +yPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=GAaeCO/Zl6KKCI51pwx57SnyhIFHX2yY+5+5YoQLeZo=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=aVY0d/c/urbaMsxxul/56C/R2xbs+Jr5qqS3QDxpSBtt0jqnmAvOwLd6CHGTM4hGTQ A9QokfXlXdvuBVPiDIoBUI9y15tjo8jRNLwNURLJrMEwYG6T0xmqOpYxfyH6NMdVG2j+ npNo1WiXdH2KLfM8kJjjuh3VLEpU1Z8h/PJaONQl7nImvrg2LOt2ZqFHmRwjsbRdtz6w cXZ/TfUUo4RlSHVeXYV0KuYVgU5Oey2WrccWajXDMa1kllWP6hLzgaTXVpCRycp3J9V5 2sklbgxr4apq9CV6RfSbL5i1lPJBeNhk/ENPNDOWFpCJ2/aLTz4ynS1yNI3Y5l9rikrB Ny3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s6-20020a1709067b8600b00993470737b9si3692858ejo.748.2023.07.22.07.11.17; Sat, 22 Jul 2023 07:11:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AC1AD68C564; Sat, 22 Jul 2023 17:11:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BEBE68C28B for ; Sat, 22 Jul 2023 17:11:07 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7D9C91BF203 for ; Sat, 22 Jul 2023 14:11:06 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 22 Jul 2023 16:11:00 +0200 Message-Id: <20230722141104.3327415-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/5] avradio/vissualize: support simple skiping of chars 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Q3CqIX+ZsVg/ Signed-off-by: Michael Niedermayer --- libavradio/vissualize.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavradio/vissualize.c b/libavradio/vissualize.c index a3dcf5801b..2d397546dc 100644 --- a/libavradio/vissualize.c +++ b/libavradio/vissualize.c @@ -81,8 +81,11 @@ static void draw_char(uint8_t *frame_buffer, ptrdiff_t stride, char ch, int x0, } } -static void draw_string(uint8_t *frame_buffer, ptrdiff_t stride, char *str, int x0, int y0, int xd, int yd, int r, int g, int b, int w, int h) +static void draw_string(uint8_t *frame_buffer, ptrdiff_t stride, char *str, int x0, int y0, int xd, int yd, int r, int g, int b, int w, int h, int skipx) { + x0 += xd*9*skipx; + y0 += yd*9*skipx; + while(*str) { draw_char(frame_buffer, stride, *str++, x0, y0, xd, yd, r, g, b, w, h); x0 += xd*9; @@ -206,6 +209,7 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, AVPacket *pkt) int color = s->stream ? 64 : 32; int size = s->stream ? 181 : 128; int xd = size, yd = size; + int pos; if (!s->in_station_list) continue; @@ -217,14 +221,14 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, AVPacket *pkt) } av_strlcatf(text, sizeof(text), "%f Mhz %d %d %d", f/1000000, (int)s->score, ff_sdr_histogram_score(s), s->timeout); - draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, color, color, color, w, h); + draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, color, color, color, w, h, 0); if (s->radiotext[0]) { - draw_string(pkt->data, 4*w, s->radiotext, xmid + 8*yd, 320*h2 + 24*yd, xd, yd, color, color, color, w, h); + draw_string(pkt->data, 4*w, s->radiotext, xmid + 8*yd, 320*h2 + 24*yd, xd, yd, color, color, color, w, h, 0); } if (s->title[0] || s->artist[0]) { int len = strlen(s->title) + 1; - draw_string(pkt->data, 4*w, s->title , xmid + 8*yd, 320*h2 + 2*24*yd, xd, yd, color, color*1.5, color, w, h); - draw_string(pkt->data, 4*w, s->artist, xmid + 8*yd + 9*xd*len, 320*h2 + 2*24*yd + 9*yd*len, xd, yd, color, color*2, color, w, h); + draw_string(pkt->data, 4*w, s->title , xmid + 8*yd, 320*h2 + 2*24*yd, xd, yd, color, color*1.5, color, w, h, 0); + draw_string(pkt->data, 4*w, s->artist, xmid + 8*yd, 320*h2 + 2*24*yd, xd, yd, color, color*2, color, w, h, len); } } } From patchwork Sat Jul 22 14:11:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42899 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be1d:b0:130:ccc6:6c4b with SMTP id ge29csp881296pzb; Sat, 22 Jul 2023 07:11:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlHIlts5sFlQFrh+GeSdiZqSfojWEaGDIcaFcaLsPQPFX4YcgbgRNN4xhmIucmtzAY7HSXcX X-Received: by 2002:a17:906:5a5d:b0:99b:5a73:4d06 with SMTP id my29-20020a1709065a5d00b0099b5a734d06mr4222690ejc.20.1690035088083; Sat, 22 Jul 2023 07:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690035088; cv=none; d=google.com; s=arc-20160816; b=EXFdgABU+nhXimlWUobET1igV0INKNQvhAL8xgeNGhAwr9fxJGBytrnf6fhHeGZERU f1ySKq8s9pTouhW1EPkjNCaIC1toDdxEAMnvk8PyfR5AIVG6Y9eWFq/4U4dsQiM8x2j4 X7oA9d95DpWwG27FYEzA4UjKXfalUEDgBJroAF5VenCKW4hMeZ8/mX0/AFFGNlKb/wPV TkNdISQluxhjei/L40cVt4i1Dnp/gJY5IYRnWRXZSRPKWA3QM/2bjpnZWv76UJXptzm6 z5U4r4xwrJxM2m5NUIO3pI9iSo1xBcFZVZRKGht+8daz+fi9KEAcYg85jJIGEZrcHLcU hgWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=VBi51J2RRlm8duIMklwwm0nI7UytYQhGg9gzYsfZEwE=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=HnY7yZ/E/0ChEHPsxhw7PDLj9oCbcqsA8VEeZnqLfLd7j2x9YJXNyu1t3L9CZ5buCf 9MoGENKt6+SUUBaSXMS9yYt5DjdxBMmUIJk/bfVlH0mwVOzvFI4+d787z75hzzOX7wXA hE6k2DWozaGwGoYLvd9BiJWqpylTbqq5uMLkYmp8FRvNjnOXzF1h2vZuhZW6LVcBdToE sDGx1fvOp/QcJ65VpIiZRZqxPD4QbGKkRbBEyig8imjZyqFwTA5MbYioelY0A/jNZG95 Mr96AtPUF6S8wqo5xlFancoIhefEWmxMcmqmNFnH86I416HVe4Nwzn6PR4zapUjAzCcn 2fWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c19-20020a170906695300b0098e2cc0aaaesi3841943ejs.560.2023.07.22.07.11.27; Sat, 22 Jul 2023 07:11:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2FCF568C57F; Sat, 22 Jul 2023 17:11:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33DB568C4C9 for ; Sat, 22 Jul 2023 17:11:08 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 859FA1BF204 for ; Sat, 22 Jul 2023 14:11:07 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 22 Jul 2023 16:11:01 +0200 Message-Id: <20230722141104.3327415-2-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 2/5] avradio/vissualize: change color of the active station 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: KFLg22IrqM1K Signed-off-by: Michael Niedermayer --- libavradio/vissualize.c | 6 ++++-- tests/ref/fate/sdr-am | 2 +- tests/ref/fate/sdr-fm | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libavradio/vissualize.c b/libavradio/vissualize.c index 2d397546dc..15d7f9e95f 100644 --- a/libavradio/vissualize.c +++ b/libavradio/vissualize.c @@ -219,9 +219,11 @@ int ff_sdr_vissualization(SDRContext *sdr, AVStream *st, AVPacket *pkt) } else { snprintf(text, sizeof(text), "%s ", ff_sdr_modulation_descs[s->modulation].shortname); } - av_strlcatf(text, sizeof(text), "%f Mhz %d %d %d", + draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, color, color, color*(s->stream ? 2 : 1), w, h, 0); + pos = strlen(text); + snprintf(text, sizeof(text), "%f Mhz %d %d %d", f/1000000, (int)s->score, ff_sdr_histogram_score(s), s->timeout); - draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, color, color, color, w, h, 0); + draw_string(pkt->data, 4*w, text, xmid + 8*yd, 320*h2, xd, yd, color, color, color, w, h, pos); if (s->radiotext[0]) { draw_string(pkt->data, 4*w, s->radiotext, xmid + 8*yd, 320*h2 + 24*yd, xd, yd, color, color, color, w, h, 0); } diff --git a/tests/ref/fate/sdr-am b/tests/ref/fate/sdr-am index d0fdc48cf5..b8a34ee488 100644 --- a/tests/ref/fate/sdr-am +++ b/tests/ref/fate/sdr-am @@ -52,4 +52,4 @@ 4, 4096, 4096, 1024, 2048, 0xdcd6ff8d 5, 4096, 4096, 1024, 2048, 0xedac0493 6, 4096, 4096, 1024, 2048, 0x970a0066 -0, 3, 3, 1, 320000, 0x73e13a75 +0, 3, 3, 1, 320000, 0x9fb0c309 diff --git a/tests/ref/fate/sdr-fm b/tests/ref/fate/sdr-fm index 0a3aaa48d4..3ae5adc2c0 100644 --- a/tests/ref/fate/sdr-fm +++ b/tests/ref/fate/sdr-fm @@ -19,7 +19,7 @@ 2, 8196, 8196, 4096, 8192, 0xb966fb19 1, 12292, 12292, 4096, 8192, 0x6d8ffe6e 2, 12292, 12292, 4096, 8192, 0x51d1fb50 -0, 3, 3, 1, 320000, 0x1b178638 +0, 3, 3, 1, 320000, 0xf8b7b144 1, 16388, 16388, 4096, 8192, 0x8c000600 2, 16388, 16388, 4096, 8192, 0x335ff20c -0, 4, 4, 1, 320000, 0x49dd90cc +0, 4, 4, 1, 320000, 0xab42bbc7 From patchwork Sat Jul 22 14:11:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42900 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be1d:b0:130:ccc6:6c4b with SMTP id ge29csp881384pzb; Sat, 22 Jul 2023 07:11:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHHpM9TbdOV4eDMD7LjALM4QN3dmQjfFD500xJup+9sa9XvSdPYEi5FrER+IJwQ8rpb0ATq X-Received: by 2002:a17:906:1c9:b0:989:74a:39ff with SMTP id 9-20020a17090601c900b00989074a39ffmr4219261ejj.49.1690035096542; Sat, 22 Jul 2023 07:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690035096; cv=none; d=google.com; s=arc-20160816; b=LzaB5Pk6iR7jeqb/8u+hFhx9rSWB9rLAYq3Yy1PJDaXtsLl/xCQPtAixZTqBRXLUp3 YiPhrjwwyGrOnFIBXuEGNvaeJr0ftHxBsZg111c+yST2cFpMdNJ+PVbqrkKozUwlKYHA x7W8yDZinynZG6CdtSbGHg570eNreMwVis3EtycRP6+MLKU64T2gcaQTXtiH+TiaNCY6 5O14wTa6SnMZXpJ4NdiA2uuCocetIo6NkF+DNmjclp35/hP13S4uIM17NjmIwy8Cdfru DQ8SgVlZOE9+ViJttCsuDINK5tmHDZWXihru6Tr6m+jcmvKMqb4d9dARUtAmYcCcvV+N L8UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=swyym0gPTBSzcmfVlpO0cJzUB59qXFUkXTcbDE88/Ok=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=BWQpXJvcY1DyWBtlT/Z9QjMPGZmlTxJb+0294Be7e4/AIBOEH0VqRrDay0/YRfmI/0 OQbAH4mSqynExJmMHES6nevwRMUYjdmtiIL5ylfEg44VklKGuDjGspIxxOiDim6y89Wc om7jVpNWJAuABQ5HMTTdwgDJq9IN9r6If0vz2HLur12cP0PKw1YzhOUhv9BS3Gqs1jP8 CvYp//duveu8C+Mq8hnfmi3NEMSYVN2bdqz/XH1Pz4tGX/sYNBRIV49wRIPkus8HmicA /1hzat7chvRSQUUuVTJw/ftM7/x+VjCHMzM4+Vz7Tixf8sd/4oIHrotWdXZvelErH4Fz QJSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gu19-20020a170906f29300b009936880c9afsi3526497ejb.377.2023.07.22.07.11.36; Sat, 22 Jul 2023 07:11:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3BBB468C59C; Sat, 22 Jul 2023 17:11:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F2A468C501 for ; Sat, 22 Jul 2023 17:11:09 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BE77720005 for ; Sat, 22 Jul 2023 14:11:08 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 22 Jul 2023 16:11:02 +0200 Message-Id: <20230722141104.3327415-3-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 3/5] avradio/sdr: Remove direct inclusion of pthread.h 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: vnTp+HeSPUif Fate tests pass on mingw32 & 64 with this Signed-off-by: Michael Niedermayer --- libavradio/sdr.h | 1 - libavradio/sdrdemux.c | 1 - 2 files changed, 2 deletions(-) diff --git a/libavradio/sdr.h b/libavradio/sdr.h index c651ba0d99..4349763bd1 100644 --- a/libavradio/sdr.h +++ b/libavradio/sdr.h @@ -22,7 +22,6 @@ #ifndef AVRADIO_SDR_H #define AVRADIO_SDR_H -#include #include #include diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index 8967ff1ea9..66130d9662 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -35,7 +35,6 @@ #include "sdr.h" -#include #include #include #include "libavutil/avassert.h" From patchwork Sat Jul 22 14:11:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42901 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be1d:b0:130:ccc6:6c4b with SMTP id ge29csp881467pzb; Sat, 22 Jul 2023 07:11:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlGWVV0gFm0md0yqR0jOz5VgGoVlHJcRBCtaXBtfdupzioDFLYgsaeT+bmvDsb4Sta4Ve+pm X-Received: by 2002:a17:906:1098:b0:98c:e72c:6b83 with SMTP id u24-20020a170906109800b0098ce72c6b83mr4408734eju.45.1690035104735; Sat, 22 Jul 2023 07:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690035104; cv=none; d=google.com; s=arc-20160816; b=SIvm6KzLrUhnQ6chzL1HaE5aPnwBXPStwmUQAvu0ibwkNW18Rxs2B2iGl7y+9MH/Q+ DBlntWyb9ZIQfwTnOmQH8qBWtOjYKO6r+CxU4e+UZ+wVsk5rPrVug9WkL3YRNzQrixQm MfAItEwu3gdqhm4TfJkHyPmHzPUnoP4L9TDwuDr6DPMBoK0XsUrlchLMqJp/blyKNhl6 0ZFh9K/yC5AL8JylGvvyCK2NsasXa1wx+m8sgl5gagDwX7b6QlEh04qF7rPHNzxcEDyO X/b/e142htYCTkAtFFIB6431sS/r/avADVgGDETFoRRI4/gCfJduKUUUFv4bFyBVqHS3 yqqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=XMa52jKF222FNEHnDO96GGeSPvg2m1a7BMOQANccRqY=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=jwPcDVDzb1myDk0oY390DmqxZbHQ+/pXTKtSXvU9mYrhjDzxERYicPANB3anm3nfZI u87f98aoDXFUepxITdmHLF98CAM8geJ44PCP3/P9Uz+UBHNAvxpY64LQu221Kn0pTh/H cntvaDHDHS/b77CUu2ILtJ0ZPrkHWkF6aFo6AtgGX8x7MfPs+ot//H3nl8m82Slvwev5 U4IOjFbYj9U0JOkdHDziT3c91YtlFKYur2jL6ksust3i728FmLoMJuIPZd2btU2vSNGa +kLsA5uDK4nS7/e3D54lgvUskn7lYWwVVj659IgryltKBpmbwlCA+clYgqXrUgTTcerf o7MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j19-20020a170906411300b00988a6f59292si3649634ejk.600.2023.07.22.07.11.44; Sat, 22 Jul 2023 07:11:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2164768C5E4; Sat, 22 Jul 2023 17:11:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YM+RtPDULAjJ 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); From patchwork Sat Jul 22 14:11:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42902 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be1d:b0:130:ccc6:6c4b with SMTP id ge29csp881558pzb; Sat, 22 Jul 2023 07:11:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPdymOD7u0w+yaUQyQ+6t0SzSprnwbpbmhDXOrzVZEEBM+JbyUMvCfZxxF1aJD9/MtbBSO X-Received: by 2002:a50:ee82:0:b0:521:d770:4743 with SMTP id f2-20020a50ee82000000b00521d7704743mr4164133edr.20.1690035114006; Sat, 22 Jul 2023 07:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690035113; cv=none; d=google.com; s=arc-20160816; b=Dz9sGq1OpMQlkQqOXOZ1EYkAurXx8T+BzaQW2Nkd6jKAr5NZWPV4xBLUyfymCrqO0/ 9RC2cW7DEV6cHbhFxmAm4cBRaJ17a3mwsRVQ74dgi23N/y+aAQlcXVykq6xdrL8vwtQc 2RzwAQwUNKJ3u+A58S1w0BvyntbAfu5zrE6aFaJ2EM0mVuGn5FAhRoHdbHxKfbxWF4F5 YxDQuNT2nXf/pQDx4IyO+j4MPl1JPCsCWs0hHDC9Y3mMgNzsowN2ot0NawjowvwP8HSe 7T2sseRDU6MeLui5uU9lHp4ImY/fPB5VTmfYFountOy/OEnAJHLKCP1FkJJiAaZKiuhY TUgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=96iSvdqRChb6uBQhcA4TssRoRVzQHLpWVP2xLbI4J8U=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=iSsmtBhmWT1Zs5on3/1lJEzQddwGaQVrCuHmvSH0XFK0uQgGQ6u4De7JM7dHKq4/xI SepX8R9vtU8jRjsedcDrO+k5KkfUSOFP4spxBD4BvGrLKvV73fWA+t8DrTaCkH90D7Zr hR1cA1M4iFAu5guaqOIa80MflSRVr+YGJczNHGcAXWV/WYOGGsGuDd6L+48E6Ds077ek ReKLUkACAMw5TEk2rML96vYvw59ztdeE0YhU0+Vv5NCU1iQndY2RpbfvPNbyUbPMAqfK RXUZlHJjEy8rw7jT7PmJ4ScXf5HXMAlQC7ixI2Tw63NtNgfArLlpSnBMHyTx/CNbBEZN wmBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y4-20020a50eb04000000b0052218bc55e8si878060edp.238.2023.07.22.07.11.53; Sat, 22 Jul 2023 07:11:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3AE8F68C624; Sat, 22 Jul 2023 17:11:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFBB668C59C for ; Sat, 22 Jul 2023 17:11:11 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2D24B40004 for ; Sat, 22 Jul 2023 14:11:10 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 22 Jul 2023 16:11:04 +0200 Message-Id: <20230722141104.3327415-5-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 5/5] avradio/sdrdemux: store min/max frequency, driver, label and tuner 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IBjCypwA+aYq Signed-off-by: Michael Niedermayer --- libavradio/sdr.h | 1 + libavradio/sdrdemux.c | 35 ++++++++++++++++++++++++++++++++++- libavradio/sdrinradio.c | 14 ++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/libavradio/sdr.h b/libavradio/sdr.h index 4349763bd1..de0a479d26 100644 --- a/libavradio/sdr.h +++ b/libavradio/sdr.h @@ -138,6 +138,7 @@ typedef struct SDRContext { Mode mode; AVRational fps; char *driver_name; + AVDictionary *driver_dict; char *dump_url; int fileheader_size; AVIOContext *dump_avio; diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index 09d720de23..bb33c69668 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -1723,6 +1723,9 @@ static int sdrfile_initial_setup(AVFormatContext *s) } else return AVERROR_INVALIDDATA; + sdr->min_freq = 0; + sdr->max_freq = 40 * 1000*1000*1000LL; + avio_skip(s->pb, 3); //BE sdr->sdr_sample_rate = avio_rb32(s->pb); avio_rb32(s->pb); //block_size @@ -1731,6 +1734,26 @@ static int sdrfile_initial_setup(AVFormatContext *s) if (version > AV_RB24("000")) { sdr->bandwidth = avio_rb32(s->pb); sdr->fileheader_size = avio_rb32(s->pb); + if (sdr->fileheader_size < 48 || sdr->fileheader_size > 100000) + return AVERROR_INVALIDDATA; + if (version > AV_RB24("001")) { + char *tmp = av_malloc(sdr->fileheader_size); + if (!tmp) + return AVERROR(ENOMEM); + + sdr->min_freq = avio_rb64(s->pb); + sdr->max_freq = avio_rb64(s->pb); + avio_get_str(s->pb, sdr->fileheader_size, tmp, sdr->fileheader_size); + sdr->driver_name = av_strdup(tmp); + + avio_get_str(s->pb, sdr->fileheader_size, tmp, sdr->fileheader_size); + if (*tmp) + av_dict_set(&sdr->driver_dict, "label", tmp, 0); + + avio_get_str(s->pb, sdr->fileheader_size, tmp, sdr->fileheader_size); + if (*tmp) + av_dict_set(&sdr->driver_dict, "tuner", tmp, 0); + } } else { sdr->bandwidth = sdr->sdr_sample_rate; sdr->fileheader_size = 40; @@ -1842,9 +1865,11 @@ process_next_block: sdr->block_center_freq = fifo_element[0].center_frequency; if (sdr->dump_avio) { - uint8_t header[16] = "FFSDR001int16BE"; + uint8_t header[16] = "FFSDR002int16BE"; uint8_t *tmp = (void*)sdr->windowed_block; //We use an unused array as temporary here int64_t sizepos, endpos; + AVDictionaryEntry *e_label = av_dict_get(sdr->driver_dict, "label", NULL, 0); + AVDictionaryEntry *e_tuner = av_dict_get(sdr->driver_dict, "tuner", NULL, 0); if (sdr->sample_size == 2) memcpy(header + 11, "08", 2); @@ -1858,6 +1883,12 @@ process_next_block: sizepos = avio_tell(sdr->dump_avio); avio_wb32(sdr->dump_avio, 0); + avio_wb64(sdr->dump_avio, sdr->min_freq); + avio_wb64(sdr->dump_avio, sdr->max_freq); + avio_put_str(sdr->dump_avio, sdr->driver_name); + avio_put_str(sdr->dump_avio, e_label ? e_label->value : NULL); + avio_put_str(sdr->dump_avio, e_tuner ? e_tuner->value : NULL); + endpos = avio_tell(sdr->dump_avio); avio_seek(sdr->dump_avio, sizepos, SEEK_SET); @@ -2202,6 +2233,8 @@ int ff_sdr_read_close(AVFormatContext *s) avio_close(sdr->dump_avio); + av_dict_free(&sdr->driver_dict); + return 0; } diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c index d12b0b73fe..c24a30d746 100644 --- a/libavradio/sdrinradio.c +++ b/libavradio/sdrinradio.c @@ -161,6 +161,7 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s) SoapySDRDevice *soapy = NULL; SoapySDRStream *soapyRxStream = NULL; const char * soapy_format; + AVDictionaryEntry *e_label, *e_serial; sdr->read_callback = sdrindev_read_callback; sdr->set_frequency_callback = sdrindev_set_frequency_callback; @@ -171,6 +172,7 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s) results = SoapySDRDevice_enumerate(NULL, &length); for (i = 0; i < length; i++) { int usable = 1; + int selected = 0; for (int j = 0; j < results[i].size; j++) { if (!strcmp("driver", results[i].keys[j])) { if (!strcmp("audio", results[i].vals[j])) { @@ -180,7 +182,11 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s) if (!sdr->driver_name) return AVERROR(ENOMEM); } + if(usable) + selected = !strcmp(sdr->driver_name, results[i].vals[j]); } + if (selected) + av_dict_set(&sdr->driver_dict, results[i].keys[j], results[i].vals[j], 0); } if (!usable) continue; @@ -191,6 +197,14 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s) } SoapySDRKwargsList_clear(results, length); + e_serial = av_dict_get(sdr->driver_dict, "serial", NULL, 0); + e_label = av_dict_get(sdr->driver_dict, "label", NULL, 0); + if (e_serial && e_label) { + char *p = strstr(e_label->value, e_serial->value); + if (p) + *p = 0; // we store this in dump url, preserve users privacy + } + av_log(s, AV_LOG_INFO, "Opening %s\n", sdr->driver_name); if (!sdr->driver_name) return AVERROR(EINVAL); //No driver specified and none found