Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul B Mahol <onemda@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] trailing padding
Date: Thu, 12 Jan 2023 10:41:11 +0100
Message-ID: <CAPYw7P7GAg2mn0kk0-SwuweTBPah4t6K0A+Jo51ahB7t1S4P-Q@mail.gmail.com> (raw)

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

             reply	other threads:[~2023-01-12  9:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12  9:41 Paul B Mahol [this message]
2023-01-15 10:23 ` Paul B Mahol
2023-01-16 13:10 ` Tobias Rapp
2023-01-21 16:17   ` Paul B Mahol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPYw7P7GAg2mn0kk0-SwuweTBPah4t6K0A+Jo51ahB7t1S4P-Q@mail.gmail.com \
    --to=onemda@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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