Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/aacdec: strictly conform to K&R style
@ 2024-05-18 13:50 Marcus B Spencer
  2024-05-18 14:16 ` Marton Balint
  0 siblings, 1 reply; 4+ messages in thread
From: Marcus B Spencer @ 2024-05-18 13:50 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marcus B Spencer

In the K&R style, a single-statement block does not have braces.
Edit the code to conform to this rule.

It is FFmpeg's code formatting convention to use K&R style.

Signed-off-by: Marcus B Spencer <marcus@marcusspencer.xyz>
---
 libavformat/aacdec.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index e267886e1a..3901a1dba8 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -49,13 +49,12 @@ static int adts_aac_probe(const AVProbeData *p)
         for (frames = 0; buf2 < end; frames++) {
             uint32_t header = AV_RB16(buf2);
             if ((header & 0xFFF6) != 0xFFF0) {
-                if (buf != buf0) {
+                if (buf != buf0)
                     // Found something that isn't an ADTS header, starting
                     // from a position other than the start of the buffer.
                     // Discard the count we've accumulated so far since it
                     // probably was a false positive.
                     frames = 0;
-                }
                 break;
             }
             fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
@@ -143,9 +142,8 @@ static int handle_id3(AVFormatContext *s, AVPacket *pkt)
     int ret;
 
     ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - pkt->size);
-    if (ret < 0) {
+    if (ret < 0)
         return ret;
-    }
 
     ffio_init_read_context(&pb, pkt->data, pkt->size);
     ff_id3v2_read_dict(&pb.pub, &metadata, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
@@ -175,9 +173,8 @@ retry:
     if (ret < 0)
         return ret;
 
-    if (ret < ADTS_HEADER_SIZE) {
+    if (ret < ADTS_HEADER_SIZE)
         return AVERROR(EIO);
-    }
 
     if ((AV_RB16(pkt->data) >> 4) != 0xfff) {
         // Parse all the ID3 headers between frames
@@ -185,9 +182,8 @@ retry:
 
         av_assert2(append > 0);
         ret = av_append_packet(s->pb, pkt, append);
-        if (ret != append) {
+        if (ret != append)
             return AVERROR(EIO);
-        }
         if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
             av_packet_unref(pkt);
             ret = adts_aac_resync(s);
@@ -200,9 +196,8 @@ retry:
     }
 
     fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;
-    if (fsize < ADTS_HEADER_SIZE) {
+    if (fsize < ADTS_HEADER_SIZE)
         return AVERROR_INVALIDDATA;
-    }
 
     ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
 
-- 
2.39.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/aacdec: strictly conform to K&R style
  2024-05-18 13:50 [FFmpeg-devel] [PATCH] avformat/aacdec: strictly conform to K&R style Marcus B Spencer
@ 2024-05-18 14:16 ` Marton Balint
  2024-05-18 15:35   ` Marcus B Spencer
  0 siblings, 1 reply; 4+ messages in thread
From: Marton Balint @ 2024-05-18 14:16 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



On Sat, 18 May 2024, Marcus B Spencer wrote:

> In the K&R style, a single-statement block does not have braces.
> Edit the code to conform to this rule.
>
> It is FFmpeg's code formatting convention to use K&R style.
>
> Signed-off-by: Marcus B Spencer <marcus@marcusspencer.xyz>
> ---
> libavformat/aacdec.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index e267886e1a..3901a1dba8 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -49,13 +49,12 @@ static int adts_aac_probe(const AVProbeData *p)
>         for (frames = 0; buf2 < end; frames++) {
>             uint32_t header = AV_RB16(buf2);
>             if ((header & 0xFFF6) != 0xFFF0) {
> -                if (buf != buf0) {
> +                if (buf != buf0)
>                     // Found something that isn't an ADTS header, starting
>                     // from a position other than the start of the buffer.
>                     // Discard the count we've accumulated so far since it
>                     // probably was a false positive.
>                     frames = 0;
> -                }

This should keep the braces, because this is in fact multiline. The rest 
looks good.

Regards,
Marton

>                 break;
>             }
>             fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
> @@ -143,9 +142,8 @@ static int handle_id3(AVFormatContext *s, AVPacket *pkt)
>     int ret;
>
>     ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - pkt->size);
> -    if (ret < 0) {
> +    if (ret < 0)
>         return ret;
> -    }
>
>     ffio_init_read_context(&pb, pkt->data, pkt->size);
>     ff_id3v2_read_dict(&pb.pub, &metadata, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
> @@ -175,9 +173,8 @@ retry:
>     if (ret < 0)
>         return ret;
>
> -    if (ret < ADTS_HEADER_SIZE) {
> +    if (ret < ADTS_HEADER_SIZE)
>         return AVERROR(EIO);
> -    }
>
>     if ((AV_RB16(pkt->data) >> 4) != 0xfff) {
>         // Parse all the ID3 headers between frames
> @@ -185,9 +182,8 @@ retry:
>
>         av_assert2(append > 0);
>         ret = av_append_packet(s->pb, pkt, append);
> -        if (ret != append) {
> +        if (ret != append)
>             return AVERROR(EIO);
> -        }
>         if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
>             av_packet_unref(pkt);
>             ret = adts_aac_resync(s);
> @@ -200,9 +196,8 @@ retry:
>     }
>
>     fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;
> -    if (fsize < ADTS_HEADER_SIZE) {
> +    if (fsize < ADTS_HEADER_SIZE)
>         return AVERROR_INVALIDDATA;
> -    }
>
>     ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
>
> -- 
> 2.39.2
>
> _______________________________________________
> 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".
>
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH] avformat/aacdec: strictly conform to K&R style
  2024-05-18 14:16 ` Marton Balint
@ 2024-05-18 15:35   ` Marcus B Spencer
  2024-05-18 23:27     ` Lynne via ffmpeg-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Marcus B Spencer @ 2024-05-18 15:35 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marcus B Spencer

In the K&R style, a single-statement block does not have braces.
Edit the code to conform to this rule.

It is FFmpeg's code formatting convention to use K&R style.

Signed-off-by: Marcus B Spencer <marcus@marcusspencer.xyz>
---
 libavformat/aacdec.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index e267886e1a..d5324df4d5 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -143,9 +143,8 @@ static int handle_id3(AVFormatContext *s, AVPacket *pkt)
     int ret;
 
     ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - pkt->size);
-    if (ret < 0) {
+    if (ret < 0)
         return ret;
-    }
 
     ffio_init_read_context(&pb, pkt->data, pkt->size);
     ff_id3v2_read_dict(&pb.pub, &metadata, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
@@ -175,9 +174,8 @@ retry:
     if (ret < 0)
         return ret;
 
-    if (ret < ADTS_HEADER_SIZE) {
+    if (ret < ADTS_HEADER_SIZE)
         return AVERROR(EIO);
-    }
 
     if ((AV_RB16(pkt->data) >> 4) != 0xfff) {
         // Parse all the ID3 headers between frames
@@ -185,9 +183,8 @@ retry:
 
         av_assert2(append > 0);
         ret = av_append_packet(s->pb, pkt, append);
-        if (ret != append) {
+        if (ret != append)
             return AVERROR(EIO);
-        }
         if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
             av_packet_unref(pkt);
             ret = adts_aac_resync(s);
@@ -200,9 +197,8 @@ retry:
     }
 
     fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;
-    if (fsize < ADTS_HEADER_SIZE) {
+    if (fsize < ADTS_HEADER_SIZE)
         return AVERROR_INVALIDDATA;
-    }
 
     ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
 
-- 
2.39.2

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat/aacdec: strictly conform to K&R style
  2024-05-18 15:35   ` Marcus B Spencer
@ 2024-05-18 23:27     ` Lynne via ffmpeg-devel
  0 siblings, 0 replies; 4+ messages in thread
From: Lynne via ffmpeg-devel @ 2024-05-18 23:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne


[-- Attachment #1.1.1.1: Type: text/plain, Size: 2020 bytes --]

On 18/05/2024 17:35, Marcus B Spencer wrote:
> In the K&R style, a single-statement block does not have braces.
> Edit the code to conform to this rule.
> 
> It is FFmpeg's code formatting convention to use K&R style.
> 
> Signed-off-by: Marcus B Spencer <marcus@marcusspencer.xyz>
> ---
>   libavformat/aacdec.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index e267886e1a..d5324df4d5 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -143,9 +143,8 @@ static int handle_id3(AVFormatContext *s, AVPacket *pkt)
>       int ret;
>   
>       ret = av_append_packet(s->pb, pkt, ff_id3v2_tag_len(pkt->data) - pkt->size);
> -    if (ret < 0) {
> +    if (ret < 0)
>           return ret;
> -    }
>   
>       ffio_init_read_context(&pb, pkt->data, pkt->size);
>       ff_id3v2_read_dict(&pb.pub, &metadata, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
> @@ -175,9 +174,8 @@ retry:
>       if (ret < 0)
>           return ret;
>   
> -    if (ret < ADTS_HEADER_SIZE) {
> +    if (ret < ADTS_HEADER_SIZE)
>           return AVERROR(EIO);
> -    }
>   
>       if ((AV_RB16(pkt->data) >> 4) != 0xfff) {
>           // Parse all the ID3 headers between frames
> @@ -185,9 +183,8 @@ retry:
>   
>           av_assert2(append > 0);
>           ret = av_append_packet(s->pb, pkt, append);
> -        if (ret != append) {
> +        if (ret != append)
>               return AVERROR(EIO);
> -        }
>           if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
>               av_packet_unref(pkt);
>               ret = adts_aac_resync(s);
> @@ -200,9 +197,8 @@ retry:
>       }
>   
>       fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;
> -    if (fsize < ADTS_HEADER_SIZE) {
> +    if (fsize < ADTS_HEADER_SIZE)
>           return AVERROR_INVALIDDATA;
> -    }
>   
>       ret = av_append_packet(s->pb, pkt, fsize - pkt->size);
>   

Pushed, thanks.

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 637 bytes --]

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-18 23:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-18 13:50 [FFmpeg-devel] [PATCH] avformat/aacdec: strictly conform to K&R style Marcus B Spencer
2024-05-18 14:16 ` Marton Balint
2024-05-18 15:35   ` Marcus B Spencer
2024-05-18 23:27     ` Lynne via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git