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 1/2] lavc/tak: make ff_tak_parse_streaminfo static
@ 2023-05-04 18:49 Anton Khirnov
  2023-05-04 18:49 ` [FFmpeg-devel] [PATCH 2/2] lavc/tak: do not store invalid values in stream info Anton Khirnov
  2023-05-04 19:01 ` [FFmpeg-devel] [PATCH 1/2] lavc/tak: make ff_tak_parse_streaminfo static Paul B Mahol
  0 siblings, 2 replies; 4+ messages in thread
From: Anton Khirnov @ 2023-05-04 18:49 UTC (permalink / raw)
  To: ffmpeg-devel

It is not used outside of tak.c
---
 libavcodec/tak.c | 6 +++---
 libavcodec/tak.h | 2 --
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/tak.c b/libavcodec/tak.c
index f26574c968..d1604dc9d2 100644
--- a/libavcodec/tak.c
+++ b/libavcodec/tak.c
@@ -92,7 +92,7 @@ int ff_tak_check_crc(const uint8_t *buf, unsigned int buf_size)
     return 0;
 }
 
-void ff_tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb)
+static void tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb)
 {
     uint64_t channel_mask = 0;
     int frame_type, i;
@@ -135,7 +135,7 @@ int avpriv_tak_parse_streaminfo(TAKStreamInfo *s, const uint8_t *buf, int size)
     if (ret < 0)
         return AVERROR_INVALIDDATA;
 
-    ff_tak_parse_streaminfo(s, &gb);
+    tak_parse_streaminfo(s, &gb);
 
     return 0;
 }
@@ -159,7 +159,7 @@ int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
     }
 
     if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) {
-        ff_tak_parse_streaminfo(ti, gb);
+        tak_parse_streaminfo(ti, gb);
 
         if (get_bits(gb, 6))
             skip_bits(gb, 25);
diff --git a/libavcodec/tak.h b/libavcodec/tak.h
index 6069118971..5e43598de8 100644
--- a/libavcodec/tak.h
+++ b/libavcodec/tak.h
@@ -149,8 +149,6 @@ int ff_tak_check_crc(const uint8_t *buf, unsigned int buf_size);
  */
 int avpriv_tak_parse_streaminfo(TAKStreamInfo *s, const uint8_t *buf, int size);
 
-void ff_tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb);
-
 /**
  * Validate and decode a frame header.
  * @param      avctx             AVCodecContext to use as av_log() context
-- 
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

* [FFmpeg-devel] [PATCH 2/2] lavc/tak: do not store invalid values in stream info
  2023-05-04 18:49 [FFmpeg-devel] [PATCH 1/2] lavc/tak: make ff_tak_parse_streaminfo static Anton Khirnov
@ 2023-05-04 18:49 ` Anton Khirnov
  2023-05-04 19:00   ` Paul B Mahol
  2023-05-04 19:01 ` [FFmpeg-devel] [PATCH 1/2] lavc/tak: make ff_tak_parse_streaminfo static Paul B Mahol
  1 sibling, 1 reply; 4+ messages in thread
From: Anton Khirnov @ 2023-05-04 18:49 UTC (permalink / raw)
  To: ffmpeg-devel

When tak_get_nb_samples() fails, it will currently write
AVERROR_INVALIDDATA as TAKStreamInfo.frame_samples. The parser will then
use this negative value as a frame duration, which leads to various
breakage.

Avoid this by returning the error code from tak_parse_streaminfo()
directly and never store negative values in the parsed header.
---
 libavcodec/tak.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/libavcodec/tak.c b/libavcodec/tak.c
index d1604dc9d2..628609b71b 100644
--- a/libavcodec/tak.c
+++ b/libavcodec/tak.c
@@ -92,10 +92,10 @@ int ff_tak_check_crc(const uint8_t *buf, unsigned int buf_size)
     return 0;
 }
 
-static void tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb)
+static int tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb)
 {
     uint64_t channel_mask = 0;
-    int frame_type, i;
+    int frame_type, i, ret;
 
     s->codec = get_bits(gb, TAK_ENCODER_CODEC_BITS);
     skip_bits(gb, TAK_ENCODER_PROFILE_BITS);
@@ -124,7 +124,13 @@ static void tak_parse_streaminfo(TAKStreamInfo *s, GetBitContext *gb)
     }
 
     s->ch_layout     = channel_mask;
-    s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);
+
+    ret = tak_get_nb_samples(s->sample_rate, frame_type);
+    if (ret < 0)
+        return ret;
+    s->frame_samples = ret;
+
+    return 0;
 }
 
 int avpriv_tak_parse_streaminfo(TAKStreamInfo *s, const uint8_t *buf, int size)
@@ -135,9 +141,7 @@ int avpriv_tak_parse_streaminfo(TAKStreamInfo *s, const uint8_t *buf, int size)
     if (ret < 0)
         return AVERROR_INVALIDDATA;
 
-    tak_parse_streaminfo(s, &gb);
-
-    return 0;
+    return tak_parse_streaminfo(s, &gb);
 }
 
 int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
@@ -159,7 +163,9 @@ int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
     }
 
     if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) {
-        tak_parse_streaminfo(ti, gb);
+        int ret = tak_parse_streaminfo(ti, gb);
+        if (ret < 0)
+            return ret;
 
         if (get_bits(gb, 6))
             skip_bits(gb, 25);
-- 
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 2/2] lavc/tak: do not store invalid values in stream info
  2023-05-04 18:49 ` [FFmpeg-devel] [PATCH 2/2] lavc/tak: do not store invalid values in stream info Anton Khirnov
@ 2023-05-04 19:00   ` Paul B Mahol
  0 siblings, 0 replies; 4+ messages in thread
From: Paul B Mahol @ 2023-05-04 19:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

approved
_______________________________________________
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 1/2] lavc/tak: make ff_tak_parse_streaminfo static
  2023-05-04 18:49 [FFmpeg-devel] [PATCH 1/2] lavc/tak: make ff_tak_parse_streaminfo static Anton Khirnov
  2023-05-04 18:49 ` [FFmpeg-devel] [PATCH 2/2] lavc/tak: do not store invalid values in stream info Anton Khirnov
@ 2023-05-04 19:01 ` Paul B Mahol
  1 sibling, 0 replies; 4+ messages in thread
From: Paul B Mahol @ 2023-05-04 19:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

approved
_______________________________________________
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:[~2023-05-04 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 18:49 [FFmpeg-devel] [PATCH 1/2] lavc/tak: make ff_tak_parse_streaminfo static Anton Khirnov
2023-05-04 18:49 ` [FFmpeg-devel] [PATCH 2/2] lavc/tak: do not store invalid values in stream info Anton Khirnov
2023-05-04 19:00   ` Paul B Mahol
2023-05-04 19:01 ` [FFmpeg-devel] [PATCH 1/2] lavc/tak: make ff_tak_parse_streaminfo static Paul B Mahol

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