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] trailing padding
@ 2023-01-12  9:41 Paul B Mahol
  2023-01-15 10:23 ` Paul B Mahol
  2023-01-16 13:10 ` Tobias Rapp
  0 siblings, 2 replies; 4+ messages in thread
From: Paul B Mahol @ 2023-01-12  9:41 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

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

Patches attached, ffmpeg.c should really not ignore initial padding
and trailing padding.

[-- Attachment #2: 0001-avformat-dtshddec-also-read-trailing-padding-in-samp.patch --]
[-- Type: text/x-patch, Size: 1594 bytes --]

From 6fc1c0dfcfe5203355423d658f21a8f6c7cbfe83 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Thu, 12 Jan 2023 09:56:57 +0100
Subject: [PATCH 1/2] avformat/dtshddec: also read trailing padding in samples

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/dtshddec.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c
index edd02b4561..a3dea0668f 100644
--- a/libavformat/dtshddec.c
+++ b/libavformat/dtshddec.c
@@ -55,7 +55,7 @@ static int dtshd_read_header(AVFormatContext *s)
     DTSHDDemuxContext *dtshd = s->priv_data;
     AVIOContext *pb = s->pb;
     uint64_t chunk_type, chunk_size;
-    int64_t duration, data_start;
+    int64_t duration, orig_nb_samples, data_start;
     AVStream *st;
     int ret;
     char *value;
@@ -103,9 +103,12 @@ static int dtshd_read_header(AVFormatContext *s)
             duration  = avio_rb32(pb); // num_frames
             duration *= avio_rb16(pb); // samples_per_frames
             st->duration = duration;
-            avio_skip(pb, 5);
+            orig_nb_samples  = avio_rb32(pb);
+            orig_nb_samples <<= 8;
+            orig_nb_samples |= avio_r8(pb);
             st->codecpar->ch_layout.nb_channels = ff_dca_count_chs_for_mask(avio_rb16(pb));
             st->codecpar->initial_padding = avio_rb16(pb);
+            st->codecpar->trailing_padding = FFMAX(st->duration - orig_nb_samples - st->codecpar->initial_padding, 0);
             avio_skip(pb, chunk_size - 21);
             break;
         case FILEINFO:
-- 
2.37.2


[-- Attachment #3: 0002-fftools-ffprobe-show-trailing_padding-too.patch --]
[-- Type: text/x-patch, Size: 826 bytes --]

From 65df8c3945445c0bf80e947b02ef57df7ee34bb5 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Thu, 12 Jan 2023 10:07:15 +0100
Subject: [PATCH 2/2] fftools/ffprobe: show trailing_padding too

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 fftools/ffprobe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index c18aee9846..30b786d074 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3055,6 +3055,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
         print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id));
 
         print_int("initial_padding", par->initial_padding);
+        print_int("trailing_padding", par->trailing_padding);
         break;
 
     case AVMEDIA_TYPE_SUBTITLE:
-- 
2.37.2


[-- Attachment #4: 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:[~2023-01-21 16:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12  9:41 [FFmpeg-devel] [PATCH] trailing padding Paul B Mahol
2023-01-15 10:23 ` Paul B Mahol
2023-01-16 13:10 ` Tobias Rapp
2023-01-21 16:17   ` 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