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/7] avformat/apvenc: Only allow APV
@ 2025-04-27 18:42 Andreas Rheinhardt
  2025-04-27 19:41 ` Mark Thompson
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-04-27 18:42 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 29 bytes --]

Patches attached.

- Andreas

[-- Attachment #2: 0001-avformat-apvenc-Only-allow-APV.patch --]
[-- Type: text/x-patch, Size: 904 bytes --]

From c0dbda4a3a63a451618e4578c779cd999d365819 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:11:50 +0200
Subject: [PATCH 1/7] avformat/apvenc: Only allow APV

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/apvenc.c b/libavformat/apvenc.c
index 9c4d33fdae..c7827cd5b5 100644
--- a/libavformat/apvenc.c
+++ b/libavformat/apvenc.c
@@ -35,6 +35,6 @@ const FFOutputFormat ff_apv_muxer = {
     .p.audio_codec    = AV_CODEC_ID_NONE,
     .p.video_codec    = AV_CODEC_ID_APV,
     .p.subtitle_codec = AV_CODEC_ID_NONE,
-    .flags_internal   = FF_OFMT_FLAG_MAX_ONE_OF_EACH,
+    .flags_internal   = FF_OFMT_FLAG_MAX_ONE_OF_EACH | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS,
     .write_packet     = apv_write_packet,
 };
-- 
2.45.2


[-- Attachment #3: 0002-avformat-apvenc-Remove-unused-header.patch --]
[-- Type: text/x-patch, Size: 699 bytes --]

From c7eca20695decf6ed5a2d48fdc51bb3e4dc154f9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:12:19 +0200
Subject: [PATCH 2/7] avformat/apvenc: Remove unused header

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvenc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavformat/apvenc.c b/libavformat/apvenc.c
index c7827cd5b5..823cc0e601 100644
--- a/libavformat/apvenc.c
+++ b/libavformat/apvenc.c
@@ -16,8 +16,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/apv.h"
-
 #include "avformat.h"
 #include "mux.h"
 
-- 
2.45.2


[-- Attachment #4: 0003-avformat-apvdec-Use-ffio_read_size.patch --]
[-- Type: text/x-patch, Size: 896 bytes --]

From 8fd6d853835e053a9617a28b7024ec9ce3abfddc Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:14:35 +0200
Subject: [PATCH 3/7] avformat/apvdec: Use ffio_read_size()

Fixes potential use of uninitialized data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index e1ac34b003..9f94a901ec 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -164,7 +164,7 @@ static int apv_read_header(AVFormatContext *s)
     err = ffio_ensure_seekback(s->pb, sizeof(buffer));
     if (err < 0)
         return err;
-    size = avio_read(s->pb, buffer, sizeof(buffer));
+    size = ffio_read_size(s->pb, buffer, sizeof(buffer));
     if (size < 0)
         return size;
 
-- 
2.45.2


[-- Attachment #5: 0004-avformat-apvdec-Remove-inappropriate-flags.patch --]
[-- Type: text/x-patch, Size: 1232 bytes --]

From 8132d6218d5945dc2267627b36deb3a191552ed9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:20:02 +0200
Subject: [PATCH 4/7] avformat/apvdec: Remove inappropriate flags

The init-cleanup flag makes no sense for a demuxer without
a read_close() function; and the generic index is wrong, as
the packet positions are off by four (they point to the actual
packet data, not to the access unit size field).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/apvdec.c b/libavformat/apvdec.c
index 9f94a901ec..85e875a0d4 100644
--- a/libavformat/apvdec.c
+++ b/libavformat/apvdec.c
@@ -240,8 +240,7 @@ const FFInputFormat ff_apv_demuxer = {
     .p.name         = "apv",
     .p.long_name    = NULL_IF_CONFIG_SMALL("APV raw bitstream"),
     .p.extensions   = "apv",
-    .p.flags        = AVFMT_GENERIC_INDEX | AVFMT_NOTIMESTAMPS,
-    .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
+    .p.flags        = AVFMT_NOTIMESTAMPS,
     .read_probe     = apv_probe,
     .read_header    = apv_read_header,
     .read_packet    = apv_read_packet,
-- 
2.45.2


[-- Attachment #6: 0005-avformat-apvenc-Add-AVFMT_NOTIMESTAMPS-flag.patch --]
[-- Type: text/x-patch, Size: 914 bytes --]

From a0b0e7796c85d4b77d5ead8cf8baccb4c75e1523 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:23:23 +0200
Subject: [PATCH 5/7] avformat/apvenc: Add AVFMT_NOTIMESTAMPS flag

This is a raw format.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/apvenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/apvenc.c b/libavformat/apvenc.c
index 823cc0e601..1e58ca8903 100644
--- a/libavformat/apvenc.c
+++ b/libavformat/apvenc.c
@@ -33,6 +33,7 @@ const FFOutputFormat ff_apv_muxer = {
     .p.audio_codec    = AV_CODEC_ID_NONE,
     .p.video_codec    = AV_CODEC_ID_APV,
     .p.subtitle_codec = AV_CODEC_ID_NONE,
+    .p.flags          = AVFMT_NOTIMESTAMPS,
     .flags_internal   = FF_OFMT_FLAG_MAX_ONE_OF_EACH | FF_OFMT_FLAG_ONLY_DEFAULT_CODECS,
     .write_packet     = apv_write_packet,
 };
-- 
2.45.2


[-- Attachment #7: 0006-avcodec-apv_decode-Fix-shadowing.patch --]
[-- Type: text/x-patch, Size: 1433 bytes --]

From d65d8f934d8b66509f20ff279d7343ffc90f01d8 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:25:21 +0200
Subject: [PATCH 6/7] avcodec/apv_decode: Fix shadowing

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/apv_decode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/apv_decode.c b/libavcodec/apv_decode.c
index e28bc29c8f..3b638795ea 100644
--- a/libavcodec/apv_decode.c
+++ b/libavcodec/apv_decode.c
@@ -313,11 +313,11 @@ static int apv_decode_metadata(AVCodecContext *avctx, AVFrame *frame,
                     return err;
 
                 if (mdm) {
-                    for (int i = 0; i < 3; i++) {
-                        mdm->display_primaries[i][0] =
-                            av_make_q(mdcv->primary_chromaticity_x[i], 1 << 16);
-                        mdm->display_primaries[i][1] =
-                            av_make_q(mdcv->primary_chromaticity_y[i], 1 << 16);
+                    for (int j = 0; j < 3; j++) {
+                        mdm->display_primaries[j][0] =
+                            av_make_q(mdcv->primary_chromaticity_x[j], 1 << 16);
+                        mdm->display_primaries[j][1] =
+                            av_make_q(mdcv->primary_chromaticity_y[j], 1 << 16);
                     }
 
                     mdm->white_point[0] =
-- 
2.45.2


[-- Attachment #8: 0007-avcodec-apv_decode-Remove-redundant-log-message.patch --]
[-- Type: text/x-patch, Size: 932 bytes --]

From 1b608bef36141eb6cef0d98042a2db1b9234ed08 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 27 Apr 2025 20:29:53 +0200
Subject: [PATCH 7/7] avcodec/apv_decode: Remove redundant log message

ff_thread_get_buffer() already emits its own logmessage.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/apv_decode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/apv_decode.c b/libavcodec/apv_decode.c
index 3b638795ea..6fe52ffd84 100644
--- a/libavcodec/apv_decode.c
+++ b/libavcodec/apv_decode.c
@@ -277,10 +277,8 @@ static int apv_decode(AVCodecContext *avctx, AVFrame *output,
     }
 
     err = ff_thread_get_buffer(avctx, output, 0);
-    if (err) {
-        av_log(avctx, AV_LOG_ERROR, "No output frame supplied.\n");
+    if (err < 0)
         return err;
-    }
 
     apv->output_frame = output;
 
-- 
2.45.2


[-- Attachment #9: 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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] avformat/apvenc: Only allow APV
  2025-04-27 18:42 [FFmpeg-devel] [PATCH 1/7] avformat/apvenc: Only allow APV Andreas Rheinhardt
@ 2025-04-27 19:41 ` Mark Thompson
  2025-04-27 20:48   ` Andreas Rheinhardt
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Thompson @ 2025-04-27 19:41 UTC (permalink / raw)
  To: ffmpeg-devel

On 27/04/2025 19:42, Andreas Rheinhardt wrote:
> Patches attached.
> 
> - Andreas

> [PATCH 1/7] avformat/apvenc: Only allow APV

Oops, sure.

> [PATCH 2/7] avformat/apvenc: Remove unused header

Sure.

> [PATCH 3/7] avformat/apvdec: Use ffio_read_size()

Is there a cleaner way to discard very short files without reading them?  The minimum size of a valid is significantly larger than this, and an early failure would be nice rather than it get packetised and something later has to realise it's bad.

> [PATCH 4/7] avformat/apvdec: Remove inappropriate flags

What does the GENERIC_INDEX flag affect here?

Currently mpv does successfully seek in a raw file (to already-seen places), but this may or may not be related.

> [PATCH 5/7] avformat/apvenc: Add AVFMT_NOTIMESTAMPS flag

Sure.

> [PATCH 6/7] avcodec/apv_decode: Fix shadowing

Ambivalent about whether this is an improvement, but no objection.

> [PATCH 7/7] avcodec/apv_decode: Remove redundant log message

Sure.

Thanks,

- Mark

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] avformat/apvenc: Only allow APV
  2025-04-27 19:41 ` Mark Thompson
@ 2025-04-27 20:48   ` Andreas Rheinhardt
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-04-27 20:48 UTC (permalink / raw)
  To: ffmpeg-devel

Mark Thompson:
> On 27/04/2025 19:42, Andreas Rheinhardt wrote:
>> Patches attached.
>>
>> - Andreas
> 
>> [PATCH 1/7] avformat/apvenc: Only allow APV
> 
> Oops, sure.
> 
>> [PATCH 2/7] avformat/apvenc: Remove unused header
> 
> Sure.
> 
>> [PATCH 3/7] avformat/apvdec: Use ffio_read_size()
> 
> Is there a cleaner way to discard very short files without reading them?  The minimum size of a valid is significantly larger than this, and an early failure would be nice rather than it get packetised and something later has to realise it's bad.

There is avio_size(). But I know of no demuxer that uses it to discard
small files.
(What is the minimum size of a valid file?)

> 
>> [PATCH 4/7] avformat/apvdec: Remove inappropriate flags
> 
> What does the GENERIC_INDEX flag affect here?
> 

With the flag set, the demux code adds index entries for keyframes based
on AVPacket.pos. For this demuxer, AVPacket.pos points to the position
of the signature, not of the access unit size field which is where the
read_packet() code expects to be when called. So with the current code,
seeking to an already encountered place will lead to an APV_SIGNATURE
being mistaken for an access unit size. You can see this for yourself with
ffmpeg -stream_loop 50 -i $(FATE_SUITE)/apv/profile_422-10.apv -c copy
-f null -
An alternative would be to decrement AVPacket.pos by four.

> Currently mpv does successfully seek in a raw file (to already-seen places), but this may or may not be related.

IIRC mpv caches a certain amount of data (in the form of AVPackets IIRC)
in order to enable short seeks backwards and forwards from the current
position. I don't think it calls the avformat seek functions for your seeks.

- Andreas

_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2025-04-27 20:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-27 18:42 [FFmpeg-devel] [PATCH 1/7] avformat/apvenc: Only allow APV Andreas Rheinhardt
2025-04-27 19:41 ` Mark Thompson
2025-04-27 20:48   ` Andreas Rheinhardt

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