* [FFmpeg-devel] [PATCH] oss: account for sample size when computing timestamp
@ 2022-06-01 9:06 Matt Jacobson
2022-06-15 20:08 ` Matt Jacobson
0 siblings, 1 reply; 3+ messages in thread
From: Matt Jacobson @ 2022-06-01 9:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Matt Jacobson
This is my first patch to ffmpeg; please let me know if I've made any process
errors. Thanks!
---
Don't assume each sample is one byte in size. Doing so results in wrong and
occasionally non-monotonically-increasing timestamps.
Fix nearby cosmetic typo.
Signed-off-by: Matt Jacobson <mhjacobson@me.com>
---
libavdevice/oss.c | 4 +++-
libavdevice/oss.h | 1 +
libavdevice/oss_dec.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavdevice/oss.c b/libavdevice/oss.c
index eddc2ddf1a..b042f58875 100644
--- a/libavdevice/oss.c
+++ b/libavdevice/oss.c
@@ -102,9 +102,11 @@ int ff_oss_audio_open(AVFormatContext *s1, int is_output,
switch(tmp) {
case AFMT_S16_LE:
s->codec_id = AV_CODEC_ID_PCM_S16LE;
+ s->sample_size = 2;
break;
case AFMT_S16_BE:
s->codec_id = AV_CODEC_ID_PCM_S16BE;
+ s->sample_size = 2;
break;
default:
av_log(s1, AV_LOG_ERROR, "Soundcard does not support 16 bit sample format\n");
@@ -112,7 +114,7 @@ int ff_oss_audio_open(AVFormatContext *s1, int is_output,
return AVERROR(EIO);
}
err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp);
- CHECK_IOCTL_ERROR(SNDCTL_DSP_SETFMTS)
+ CHECK_IOCTL_ERROR(SNDCTL_DSP_SETFMT)
tmp = (s->channels == 2);
err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
diff --git a/libavdevice/oss.h b/libavdevice/oss.h
index 66d1a34cf6..f1da2b1bec 100644
--- a/libavdevice/oss.h
+++ b/libavdevice/oss.h
@@ -30,6 +30,7 @@ typedef struct OSSAudioData {
AVClass *class;
int fd;
int sample_rate;
+ int sample_size; /* in bytes ! */
int channels;
int frame_size; /* in bytes ! */
enum AVCodecID codec_id;
diff --git a/libavdevice/oss_dec.c b/libavdevice/oss_dec.c
index d3dbe77cf9..2cdc4324e8 100644
--- a/libavdevice/oss_dec.c
+++ b/libavdevice/oss_dec.c
@@ -91,7 +91,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
bdelay += abufi.bytes;
}
/* subtract time represented by the number of bytes in the audio fifo */
- cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels);
+ cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->sample_size * s->channels);
/* convert to wanted units */
pkt->pts = cur_time;
--
2.24.3 (Apple Git-128)
_______________________________________________
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] oss: account for sample size when computing timestamp
2022-06-01 9:06 [FFmpeg-devel] [PATCH] oss: account for sample size when computing timestamp Matt Jacobson
@ 2022-06-15 20:08 ` Matt Jacobson
2022-06-19 20:08 ` Marton Balint
0 siblings, 1 reply; 3+ messages in thread
From: Matt Jacobson @ 2022-06-15 20:08 UTC (permalink / raw)
To: ffmpeg-devel
Hi,
> On Jun 1, 2022, at 5:06 AM, Matt Jacobson <mhjacobson@me.com> wrote:
>
> Don't assume each sample is one byte in size. Doing so results in wrong and
> occasionally non-monotonically-increasing timestamps.
>
> Fix nearby cosmetic typo.
Friendly ping on this patch. Original mail:
<https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297066.html>
Please let me know if any changes are desired. If not, could someone please
help me commit it? (Is there a process to request access?)
Thank you,
Matt
_______________________________________________
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] oss: account for sample size when computing timestamp
2022-06-15 20:08 ` Matt Jacobson
@ 2022-06-19 20:08 ` Marton Balint
0 siblings, 0 replies; 3+ messages in thread
From: Marton Balint @ 2022-06-19 20:08 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Wed, 15 Jun 2022, Matt Jacobson wrote:
> Hi,
>
>> On Jun 1, 2022, at 5:06 AM, Matt Jacobson <mhjacobson@me.com> wrote:
>>
>> Don't assume each sample is one byte in size. Doing so results in wrong and
>> occasionally non-monotonically-increasing timestamps.
>>
>> Fix nearby cosmetic typo.
>
> Friendly ping on this patch. Original mail:
>
> <https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297066.html>
>
> Please let me know if any changes are desired. If not, could someone please
> help me commit it? (Is there a process to request access?)
Thanks, will apply.
Regards,
Marton
_______________________________________________
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:[~2022-06-19 20:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 9:06 [FFmpeg-devel] [PATCH] oss: account for sample size when computing timestamp Matt Jacobson
2022-06-15 20:08 ` Matt Jacobson
2022-06-19 20:08 ` Marton Balint
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