[patch] 6 channel raw audio input results in invalid PCM packet error
Raw audio input fails with SVN- r15760 when the number of channels times the number of bytes per sample isn't an integer divisor of 1024. Example: $ ffmpeg -ac 6 -ar 48000 -f s16le -i /dev/zero -t 10 silence.wav FFmpeg version SVN-r15760, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: --enable-postproc --enable-libfaac --enable-libx264 --enable-pt hreads --enable-pthreads --enable-gpl --enable-libfaad --extra-libs=-L/usr/local /lib --enable-libmp3lame libavutil 49.12. 0 / 49.12. 0 libavcodec 52. 1. 0 / 52. 1. 0 libavformat 52.23. 1 / 52.23. 1 libavdevice 52. 1. 0 / 52. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 built on Oct 31 2008 11:11:46, gcc: 4.1.2 20071124 (Red Hat 4.1.2-42) Input #0, s16le, from '/dev/zero': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0.0: Audio: pcm_s16le, 48000 Hz, 5:1, s16, 4608 kb/s Output #0, wav, to 'silence.wav': Stream #0.0: Audio: pcm_s16le, 48000 Hz, 5:1, s16, 4608 kb/s Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding [pcm_s16le @ 0xa53b410]invalid PCM packet Error while decoding stream #0.0 [pcm_s16le @ 0xa53b410]invalid PCM packet Error while decoding stream #0.0 [pcm_s16le @ 0xa53b410]invalid PCM packet Error while decoding stream #0.0 (repeats) The problem seems to be that raw_read_audio_packet in libavformat/raw.c always uses a 1024-byte packet size (RAW_PACKET_SIZE), but pcm_decode_frame in libavcodec/pcm.c expects a whole number of audio frames in the packet. With 6 input channels of 16 bit samples this is 12 bytes, which doesn't divide evenly into 1024. I took a first stab at a patch to raw_read_audio_packet which peeks inside the AVFormatContext to get the number of channels and bytes per sample from the codec structure and adjusts the packet size to be an integer multiple of bytes*channels. It fixes the problem for me, but I'm not at all familiar with the code base so I don't know if this is a legitimate operation or the best way to fix this. Feedback on a better approach would be welcome.
-----Original Message----- From: ffmpeg-devel-bounces at mplayerhq.hu [mailto:ffmpeg-devel- bounces at mplayerhq.hu] On Behalf Of Phil Rutschman Sent: Friday, October 31, 2008 11:21 AM To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [patch] 6 channel raw audio input results in invalidPCM packet error
Raw audio input fails with SVN- r15760 when the number of channels times the number of bytes per sample isn't an integer divisor of 1024.
Example:
$ ffmpeg -ac 6 -ar 48000 -f s16le -i /dev/zero -t 10 silence.wav
FFmpeg version SVN-r15760, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-postproc --enable-libfaac --enable-libx264 -- enable-pt
hreads --enable-pthreads --enable-gpl --enable-libfaad --extra-libs=- L/usr/local
/lib --enable-libmp3lame
libavutil 49.12. 0 / 49.12. 0
libavcodec 52. 1. 0 / 52. 1. 0
libavformat 52.23. 1 / 52.23. 1
libavdevice 52. 1. 0 / 52. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
built on Oct 31 2008 11:11:46, gcc: 4.1.2 20071124 (Red Hat 4.1.2-42)
Input #0, s16le, from '/dev/zero':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Audio: pcm_s16le, 48000 Hz, 5:1, s16, 4608 kb/s
Output #0, wav, to 'silence.wav':
Stream #0.0: Audio: pcm_s16le, 48000 Hz, 5:1, s16, 4608 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
[pcm_s16le @ 0xa53b410]invalid PCM packet
Error while decoding stream #0.0
[pcm_s16le @ 0xa53b410]invalid PCM packet
Error while decoding stream #0.0
[pcm_s16le @ 0xa53b410]invalid PCM packet
Error while decoding stream #0.0
(repeats)
The problem seems to be that raw_read_audio_packet in
Any feedback on this patch? Phil Rutschman <philr at modsystems.com> libavformat/raw.c
always uses a 1024-byte packet size (RAW_PACKET_SIZE), but pcm_decode_frame in libavcodec/pcm.c expects a whole number of audio frames in the packet. With 6 input channels of 16 bit samples this is 12 bytes, which doesn't divide evenly into 1024.
I took a first stab at a patch to raw_read_audio_packet which peeks inside the AVFormatContext to get the number of channels and bytes per sample from the codec structure and adjusts the packet size to be an integer multiple of bytes*channels. It fixes the problem for me, but I'm not at all familiar with the code base so I don't know if this is a legitimate operation or the best way to fix this. Feedback on a better approach would be welcome.
On Fri, Oct 31, 2008 at 11:21:22AM -0700, Phil Rutschman wrote:
Raw audio input fails with SVN- r15760 when the number of channels times the number of bytes per sample isn't an integer divisor of 1024.
Example:
[...]
The problem seems to be that raw_read_audio_packet in libavformat/raw.c always uses a 1024-byte packet size (RAW_PACKET_SIZE), but pcm_decode_frame in libavcodec/pcm.c expects a whole number of audio frames in the packet. With 6 input channels of 16 bit samples this is 12 bytes, which doesn't divide evenly into 1024.
I took a first stab at a patch to raw_read_audio_packet which peeks inside the AVFormatContext to get the number of channels and bytes per sample from the codec structure and adjusts the packet size to be an integer multiple of bytes*channels. It fixes the problem for me, but I'm not at all familiar with the code base so I don't know if this is a legitimate operation or the best way to fix this. Feedback on a better approach would be welcome.
Content-Description: raw_audio_6_channels.diff
Index: libavformat/raw.c =================================================================== --- libavformat/raw.c (revision 15760) +++ libavformat/raw.c (working copy) @@ -138,11 +138,17 @@
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { - int ret, size, bps; - // AVStream *st = s->streams[0]; + int ret, size, bps, sample_size; + AVStream *st = s->streams[0];
size= RAW_PACKET_SIZE;
if(channels>0 && channels<20) size *= channels; seems like a simpler solution [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you really think that XML is the answer, then you definitly missunderstood the question -- Attila Kinali
Content-Description: raw_audio_6_channels.diff
Index: libavformat/raw.c =================================================================== --- libavformat/raw.c (revision 15760) +++ libavformat/raw.c (working copy) @@ -138,11 +138,17 @@
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { - int ret, size, bps; - // AVStream *st = s->streams[0]; + int ret, size, bps, sample_size; + AVStream *st = s->streams[0];
size= RAW_PACKET_SIZE;
if(channels>0 && channels<20) size *= channels;
seems like a simpler solution
I believe that would fail for 1-channel 24-bit audio since 3 doesn't divide evenly into 1024*1.
Index: libavformat/raw.c
===================================================================
--- libavformat/raw.c (revision 15760) +++ libavformat/raw.c (working copy) @@ -138,11 +138,17 @@
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { - int ret, size, bps; - // AVStream *st = s->streams[0]; + int ret, size, bps, sample_size; + AVStream *st = s->streams[0];
size= RAW_PACKET_SIZE;
if(channels>0 && channels<20) size *= channels;
seems like a simpler solution
I believe that would fail for 1-channel 24-bit audio since 3 doesn't divide evenly into 1024*1.
Updated patch to remove the division operation, and just let the packet size grow. Added the limit of 20, but pulled it into a #define.
On Fri, Nov 07, 2008 at 02:10:57PM -0800, Phil Rutschman wrote:
Index: libavformat/raw.c
===================================================================
--- libavformat/raw.c (revision 15760) +++ libavformat/raw.c (working copy) @@ -138,11 +138,17 @@
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { - int ret, size, bps; - // AVStream *st = s->streams[0]; + int ret, size, bps, sample_size; + AVStream *st = s->streams[0];
size= RAW_PACKET_SIZE;
if(channels>0 && channels<20) size *= channels;
seems like a simpler solution
I believe that would fail for 1-channel 24-bit audio since 3 doesn't divide evenly into 1024*1.
Updated patch to remove the division operation, and just let the packet size grow. Added the limit of 20, but pulled it into a #define.
[...]
+ sample_size = av_get_bits_per_sample(st->codec->codec_id)/8;
why is this needed? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Breaking DRM is a little like attempting to break through a door even though the window is wide open and the only thing in the house is a bunch of things you dont want and which you would get tomorrow for free anyway
[...]
+ sample_size = av_get_bits_per_sample(st->codec->codec_id)/8;
why is this needed?
As I explained in my original bug report, pcm_decode_frame in libavcodec/pcm.c expects the size of the audio packet to be an integer multiple of the number of channels and the number of bytes per sample. If it isn't, it reports "invalid PCM packet" and returns with an error. If the input is mono or stereo 16-bit, it will work because 2 and 4 divide into 1024. Anything with 24-bit audio (3 bytes * number of channels) or a channel count that isn't a power of two will fail.
From libavcodec/pcm.c in pcm_decode_frame:
sample_size = av_get_bits_per_sample(avctx->codec_id)/8; /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */ if (CODEC_ID_PCM_DVD == avctx->codec_id) /* 2 samples are interleaved per block in PCM_DVD */ sample_size = avctx->bits_per_coded_sample * 2 / 8; n = avctx->channels * sample_size; if(n && buf_size % n){ av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); return -1; } I omitted the CODEC_ID_PCM_DVD case from my patch because CODEC_ID_PCM_DVD doesn't use the raw audio demuxer.
On Fri, Nov 07, 2008 at 02:58:45PM -0800, Phil Rutschman wrote:
[...]
+ sample_size = av_get_bits_per_sample(st->codec->codec_id)/8;
why is this needed?
As I explained in my original bug report, pcm_decode_frame in libavcodec/pcm.c expects the size of the audio packet to be an integer multiple of the number of channels and the number of bytes per sample. If it isn't, it reports "invalid PCM packet" and returns with an error. If the input is mono or stereo 16-bit, it will work because 2 and 4 divide into 1024. Anything with 24-bit audio (3 bytes * number of channels) or a channel count that isn't a power of two will fail.
AVCodecContext.block_align or bits_per_coded_sample should be useable to simplify this ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates
As I explained in my original bug report, pcm_decode_frame in libavcodec/pcm.c expects the size of the audio packet to be an integer multiple of the number of channels and the number of bytes per sample. If it isn't, it reports "invalid PCM packet" and returns with an error. If the input is mono or stereo 16-bit, it will work because 2 and 4 divide into 1024. Anything with 24-bit audio (3 bytes * number of channels) or a channel count that isn't a power of two will fail.
AVCodecContext.block_align or bits_per_coded_sample should be useable to simplify this ...
I added code to print those values in raw_read_packet. AVCodecContext.block_align is zero in this case. AVCodecContext.bits_per_coded_sample is zero at the time of the first call to raw_read_packet. Thus, neither is appropriate.
On Fri, Nov 07, 2008 at 04:30:40PM -0800, Phil Rutschman wrote:
As I explained in my original bug report, pcm_decode_frame in libavcodec/pcm.c expects the size of the audio packet to be an integer multiple of the number of channels and the number of bytes per sample. If it isn't, it reports "invalid PCM packet" and returns with an error. If the input is mono or stereo 16-bit, it will work because 2 and 4 divide into 1024. Anything with 24-bit audio (3 bytes * number of channels) or a channel count that isn't a power of two will fail.
AVCodecContext.block_align or bits_per_coded_sample should be useable to simplify this ...
I added code to print those values in raw_read_packet. AVCodecContext.block_align is zero in this case. AVCodecContext.bits_per_coded_sample is zero at the time of the first call to raw_read_packet. Thus, neither is appropriate.
bits_per_coded_sample could be set in raw_read_header() it would at least avoid recalculating its value in every packet [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA
bits_per_coded_sample could be set in raw_read_header() it would at least avoid recalculating its value in every packet
Done. bits_per_coded_sample is set to av_get_bits_per_sample() unless the latter returns zero, in which case it's set to 8. Alternatively I could error or assert on a zero return value, which should never happen with raw audio.
On Mon, Nov 10, 2008 at 09:57:03AM -0800, Phil Rutschman wrote:
bits_per_coded_sample could be set in raw_read_header() it would at least avoid recalculating its value in every packet
Done. bits_per_coded_sample is set to av_get_bits_per_sample() unless the latter returns zero, in which case it's set to 8. Alternatively I could error or assert on a zero return value, which should never happen with raw audio.
setting it to 8 if av_get_bits_per_sample() returns 0 does seem rather wrong. [...]
@@ -135,14 +137,19 @@ }
#define RAW_PACKET_SIZE 1024 +#define RAW_MAX_CHANNELS 20
static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size, bps; - // AVStream *st = s->streams[0]; + AVStream *st = s->streams[0];
size= RAW_PACKET_SIZE;
+ if (st->codec->channels > 0 && st->codec->channels <= RAW_MAX_CHANNELS) {
+ size *= st->codec->bits_per_coded_sample*st->codec->channels / 8;
tabs are forbiden in ffmpeg svn [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle
setting it to 8 if av_get_bits_per_sample() returns 0 does seem rather wrong.
Fixed. The value is now simply assigned. Let me know if you prefer an error message and return to the assert, but it is IMHO a bug for av_get_bits_per_sample to return zero when passed the ID of a raw PCM codec, so an assert seemed appropriate.
tabs are forbiden in ffmpeg svn
Fixed. I also added a comment explaining why the packet size needs manipulating in the first place.
On Mon, Nov 10, 2008 at 12:42:23PM -0800, Phil Rutschman wrote:
setting it to 8 if av_get_bits_per_sample() returns 0 does seem rather wrong.
Fixed. The value is now simply assigned. Let me know if you prefer an error message and return to the assert, but it is IMHO a bug for av_get_bits_per_sample to return zero when passed the ID of a raw PCM codec, so an assert seemed appropriate.
tabs are forbiden in ffmpeg svn
Fixed.
I also added a comment explaining why the packet size needs manipulating in the first place.
ok if it passes the regression tests [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes
Michael Niedermayer wrote:
On Mon, Nov 10, 2008 at 12:42:23PM -0800, Phil Rutschman wrote:
setting it to 8 if av_get_bits_per_sample() returns 0 does seem rather wrong. Fixed. The value is now simply assigned. Let me know if you prefer an error message and return to the assert, but it is IMHO a bug for av_get_bits_per_sample to return zero when passed the ID of a raw PCM codec, so an assert seemed appropriate.
tabs are forbiden in ffmpeg svn Fixed.
I also added a comment explaining why the packet size needs manipulating in the first place.
ok if it passes the regression tests
It doesn't. I have not investigated further... +++ tests/data/vsynth.regression 2008-11-11 21:10:10.000000000 +0100 @@ -177,10 +177,10 @@ stddev: 4394.71 PSNR: 23.46 bytes: 1053352/ 1058444 aefe11ab5067621a1c674859d6413891 *./tests/data/a-ac3.rm 98203 ./tests/data/a-ac3.rm -39878597b1d65cce473639a7d8c93b02 *./tests/data/a-g726.wav -24279 ./tests/data/a-g726.wav -888f2f016e608d044a1bacbca5497ed2 *./tests/data/g726.vsynth.out.wav -stddev: 8364.40 PSNR: 17.87 bytes: 96936/ 1058444 +5d8cce28f83dd33c3c7eaf43a5db5294 *./tests/data/a-g726.wav +24082 ./tests/data/a-g726.wav +4f1ba1af75dee64625a1c852e6cd01d3 *./tests/data/g726.vsynth.out.wav +stddev: 8506.46 PSNR: 17.72 bytes: 96148/ 1058444 3b969c43e45582f713e3c35faee9e0cc *./tests/data/a-adpcm_ima.wav 266300 ./tests/data/a-adpcm_ima.wav 947196b1739a9d6fe0c29424cf61cd8c *./tests/data/adpcm_ima_wav.vsynth.out.wav @@ -221,40 +221,40 @@ 529256 ./tests/data/a-pcm_mulaw.wav 1c3eeaa8814ebd4916780dff80ed6dc5 *./tests/data/pcm.vsynth.out.wav stddev: 103.38 PSNR: 56.03 bytes: 1058444/ 1058444 -9b883ee7a5256b26e16c419b76f373d7 *./tests/data/a-pcm_s8.mov -533937 ./tests/data/a-pcm_s8.mov +b7936d7170e0efefb379349d81aed360 *./tests/data/a-pcm_s8.mov +530837 ./tests/data/a-pcm_s8.mov 652edf30f35ad89bf27bcc9d2f9c7b53 *./tests/data/pcm.vsynth.out.wav stddev: 147.89 PSNR: 52.92 bytes: 1058444/ 1058444 98cadb3502dbdc99e6e077c28b1a036c *./tests/data/a-pcm_u8.wav 529244 ./tests/data/a-pcm_u8.wav 652edf30f35ad89bf27bcc9d2f9c7b53 *./tests/data/pcm.vsynth.out.wav stddev: 147.89 PSNR: 52.92 bytes: 1058444/ 1058444 -5c8718508599b5c87af8e9a7158a9e66 *./tests/data/a-pcm_s16be.mov -1063137 ./tests/data/a-pcm_s16be.mov +c42b9c04305455250366c84e17c1023f *./tests/data/a-pcm_s16be.mov +1060037 ./tests/data/a-pcm_s16be.mov 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.vsynth.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/a-pcm_s16le.wav 1058444 ./tests/data/a-pcm_s16le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.vsynth.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 -5a2c3500cf180e8f5fa47f725d635767 *./tests/data/a-pcm_s16be.mkv -1066121 ./tests/data/a-pcm_s16be.mkv +338e2623c797acadea35f6de539e2eb6 *./tests/data/a-pcm_s16be.mkv +1060696 ./tests/data/a-pcm_s16be.mkv 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.vsynth.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 -2cc0a1fb4553d29cccfa99d8f4f2d6e8 *./tests/data/a-pcm_s16le.mkv -1066121 ./tests/data/a-pcm_s16le.mkv +3c35ca5d2e11b54a7646c2a22f03c01f *./tests/data/a-pcm_s16le.mkv +1060696 ./tests/data/a-pcm_s16le.mkv 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.vsynth.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 -4bc4cd19722f6456fd0e9b51ee0c30cf *./tests/data/a-pcm_s24be.mov -1592337 ./tests/data/a-pcm_s24be.mov +07ffe7ffb78f3648b6524debdde5aec1 *./tests/data/a-pcm_s24be.mov +1589237 ./tests/data/a-pcm_s24be.mov 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.vsynth.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 aaba3cf534ddddf5bcf663bc8c5b5331 *./tests/data/a-pcm_s24le.wav 1587644 ./tests/data/a-pcm_s24le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.vsynth.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 -e60d8004d926d5f27beeb92a9bdd4b3d *./tests/data/a-pcm_s32be.mov -2121537 ./tests/data/a-pcm_s32be.mov +d7792f0343cd66fda8b50b569e2bcc48 *./tests/data/a-pcm_s32be.mov +2118437 ./tests/data/a-pcm_s32be.mov 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.vsynth.out.wav stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 7661c9b6f221d9f57985a9e4d92c4e63 *./tests/data/a-pcm_s32le.wav @@ -281,7 +281,7 @@ 529256 ./tests/data/a-pcm_zork.wav 864c8c866ac25642c29a13b122c70709 *./tests/data/pcm.vsynth.out.wav stddev: 633.10 PSNR: 40.29 bytes: 1058444/ 1058444 -f0c1c9bae445267d4ab8fb91d4f56071 *./tests/data/a-pcm_s24daud.302 -10371830 ./tests/data/a-pcm_s24daud.302 +8168a5c1343553ef027541830f2cb879 *./tests/data/a-pcm_s24daud.302 +10368730 ./tests/data/a-pcm_s24daud.302 fff1dc03aa2750031203a7d72b832fad *./tests/data/pcm.vsynth.out.wav stddev: 9416.45 PSNR: 16.84 bytes: 6911840/ 1058444
ok if it passes the regression tests
It doesn't.
I have not investigated further...
The regression failure appears to be due solely to a change in the raw audio packet size. This can be confirmed in two ways. First, revert to SVN head. Run make test. Edit libavformat/raw.c to change the #define of RAW_PACKET_SIZE to 2048, for example. Rerun make test, and observe which files fail. Second, revert the change of RAW_PACKET_SIZE and apply this version of the patch which restores my original logic, which kept the RAW_PACKET_SIZE the same if possible. Rerun make test, and observe that the files no longer fail.
On Wed, Nov 12, 2008 at 10:54:44AM -0800, Phil Rutschman wrote:
ok if it passes the regression tests
It doesn't.
I have not investigated further...
The regression failure appears to be due solely to a change in the raw audio packet size.
This can be confirmed in two ways. First, revert to SVN head. Run make test. Edit libavformat/raw.c to change the #define of RAW_PACKET_SIZE to 2048, for example. Rerun make test, and observe which files fail.
Second, revert the change of RAW_PACKET_SIZE and apply this version of the patch which restores my original logic, which kept the RAW_PACKET_SIZE the same if possible. Rerun make test, and observe that the files no longer fail.
your original logic generates packets that are not a multiple of 512 or 1024 thus not a multiple of disk sectors, this seems not ideal in principle updating the regression test checksums would be fine, but why does g726 change? this looks like there is something wrong in g726 which has to be found and fixed ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
your original logic generates packets that are not a multiple of 512 or 1024 thus not a multiple of disk sectors, this seems not ideal
It generates these packets only in cases which currently fail entirely. While this may not be ideal (at least, if there is neither OS nor C library caching going on), it has the virtue of solving the problem at hand without changing current behavior.
in principle updating the regression test checksums would be fine, but why does g726 change? this looks like there is something wrong in g726 which has to be found and fixed ...
It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long. Reducing RAW_PACKET_SIZE increases the size of the resulting mov file, and conversely increasing it results in a smaller mov. Something odd overall is clearly happening related to RAW_PACKET_SIZE, which may or may not be related to the g726 issue, but I don't currently have the time to investigate the specifics of either. The most recent version of the patch I sent to the list should pass regression.
On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote:
your original logic generates packets that are not a multiple of 512 or 1024 thus not a multiple of disk sectors, this seems not ideal
It generates these packets only in cases which currently fail entirely. While this may not be ideal (at least, if there is neither OS nor C library caching going on), it has the virtue of solving the problem at hand without changing current behavior.
in principle updating the regression test checksums would be fine, but why does g726 change? this looks like there is something wrong in g726 which has to be found and fixed ...
It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long. Reducing RAW_PACKET_SIZE increases the size of the resulting mov file, and conversely increasing it results in a smaller mov.
Something odd overall is clearly happening related to RAW_PACKET_SIZE, which may or may not be related to the g726 issue, but I don't currently have the time to investigate the specifics of either.
so the summary is we need some volunteer to fix 1. g726 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE after that pcm can be fixed and regression checksums updated. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator
Michael Niedermayer wrote:
On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote:
your original logic generates packets that are not a multiple of 512 or 1024 thus not a multiple of disk sectors, this seems not ideal It generates these packets only in cases which currently fail entirely. While this may not be ideal (at least, if there is neither OS nor C library caching going on), it has the virtue of solving the problem at hand without changing current behavior.
in principle updating the regression test checksums would be fine, but why does g726 change? this looks like there is something wrong in g726 which has to be found and fixed ... It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long. Reducing RAW_PACKET_SIZE increases the size of the resulting mov file, and conversely increasing it results in a smaller mov.
Something odd overall is clearly happening related to RAW_PACKET_SIZE, which may or may not be related to the g726 issue, but I don't currently have the time to investigate the specifics of either.
so the summary is we need some volunteer to fix 1. g726 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE
Huh ? If there is a problem with mov I'll fix it right now. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no
On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote:
your original logic generates packets that are not a multiple of 512 or 1024 thus not a multiple of disk sectors, this seems not ideal It generates these packets only in cases which currently fail entirely. While this may not be ideal (at least, if there is neither OS nor C library caching going on), it has the virtue of solving the problem at hand without changing current behavior.
in principle updating the regression test checksums would be fine, but why does g726 change? this looks like there is something wrong in g726 which has to be found and fixed ... It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long. Reducing RAW_PACKET_SIZE increases the size of the resulting mov file, and conversely increasing it results in a smaller mov.
Something odd overall is clearly happening related to RAW_PACKET_SIZE, which may or may not be related to the g726 issue, but I don't currently have the time to investigate the specifics of either.
so the summary is we need some volunteer to fix 1. g726 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE
Huh ? If there is a problem with mov I'll fix it right now.
I dont know if there is, i just added mov because phil said: "It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ive not confirmed this or investigated at all ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I count him braver who overcomes his desires than him who conquers his enemies for the hardest victory is over self. -- Aristotle
Michael Niedermayer wrote: > On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote: >> Michael Niedermayer wrote: >>> On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote: >>>>> your original logic generates packets that are not a multiple of 512 >>>> or >>>>> 1024 thus not a multiple of disk sectors, this seems not ideal >>>> It generates these packets only in cases which currently fail entirely. >>>> While this may not be ideal (at least, if there is neither OS nor C >>>> library caching going on), it has the virtue of solving the problem at >>>> hand without changing current behavior. >>>> >>>>> in principle updating the regression test checksums would be fine, but >>>>> why does g726 change? this looks like there is something wrong in g726 >>>>> which has to be found and fixed ... >>>> It is worth observing that the size of the mov and mkv files change, not >>>> just their checksum. When I extract the raw audio data from >>>> tests/data/a-pcm_s16be.mov and strip the header, the file matches the >>>> original asynth1.sw file except that it is not quite as long. Reducing >>>> RAW_PACKET_SIZE increases the size of the resulting mov file, and >>>> conversely increasing it results in a smaller mov. >>>> >>>> Something odd overall is clearly happening related to RAW_PACKET_SIZE, >>>> which may or may not be related to the g726 issue, but I don't currently >>>> have the time to investigate the specifics of either. >>> so the summary is we need some volunteer to fix >>> 1. g726 >>> 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE >>> >> Huh ? If there is a problem with mov I'll fix it right now. > > I dont know if there is, i just added mov because phil said: > "It is worth observing that the size of the mov and mkv files change, not > just their checksum. When I extract the raw audio data from > tests/data/a-pcm_s16be.mov and strip the header, the file matches the > original asynth1.sw file except that it is not quite as long." > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > ive not confirmed this or investigated at all ... > What about this patch ? Regression tests pass. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no
On Fri, Nov 14, 2008 at 02:28:50PM -0800, Baptiste Coudurier wrote:
> Michael Niedermayer wrote:
> > On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote:
> >> Michael Niedermayer wrote:
> >>> On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote:
> >>>>> your original logic generates packets that are not a multiple of 512
> >>>> or
> >>>>> 1024 thus not a multiple of disk sectors, this seems not ideal
> >>>> It generates these packets only in cases which currently fail entirely.
> >>>> While this may not be ideal (at least, if there is neither OS nor C
> >>>> library caching going on), it has the virtue of solving the problem at
> >>>> hand without changing current behavior.
> >>>>
> >>>>> in principle updating the regression test checksums would be fine, but
> >>>>> why does g726 change? this looks like there is something wrong in g726
> >>>>> which has to be found and fixed ...
> >>>> It is worth observing that the size of the mov and mkv files change, not
> >>>> just their checksum. When I extract the raw audio data from
> >>>> tests/data/a-pcm_s16be.mov and strip the header, the file matches the
> >>>> original asynth1.sw file except that it is not quite as long. Reducing
> >>>> RAW_PACKET_SIZE increases the size of the resulting mov file, and
> >>>> conversely increasing it results in a smaller mov.
> >>>>
> >>>> Something odd overall is clearly happening related to RAW_PACKET_SIZE,
> >>>> which may or may not be related to the g726 issue, but I don't currently
> >>>> have the time to investigate the specifics of either.
> >>> so the summary is we need some volunteer to fix
> >>> 1. g726
> >>> 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE
> >>>
> >> Huh ? If there is a problem with mov I'll fix it right now.
> >
> > I dont know if there is, i just added mov because phil said:
> > "It is worth observing that the size of the mov and mkv files change, not
> > just their checksum. When I extract the raw audio data from
> > tests/data/a-pcm_s16be.mov and strip the header, the file matches the
> > original asynth1.sw file except that it is not quite as long."
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > ive not confirmed this or investigated at all ...
> >
>
> What about this patch ? Regression tests pass.
[...]
> Index: libavformat/raw.c
> ===================================================================
> --- libavformat/raw.c (revision 15823)
> +++ libavformat/raw.c (working copy)
> @@ -115,6 +115,13 @@
> st->codec->sample_rate = ap->sample_rate;
> if(ap->channels) st->codec->channels = ap->channels;
> else st->codec->channels = 1;
> + st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
> + assert(st->codec->bits_per_coded_sample > 0);
> + if (!st->codec->channels) {
> + av_log(s, AV_LOG_ERROR, "channels is not set\n");
> + return -1;
> + }
i dont see how this if() could be true
> + st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8;
> av_set_pts_info(st, 64, 1, st->codec->sample_rate);
> break;
> case CODEC_TYPE_VIDEO:
> @@ -139,9 +146,9 @@
> static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
> {
> int ret, size, bps;
> - // AVStream *st = s->streams[0];
> + AVStream *st = s->streams[0];
>
> - size= RAW_PACKET_SIZE;
> + size= (RAW_PACKET_SIZE/st->codec->block_align)*st->codec->block_align;
i think i prefer if the packet size contains a constant number of samples
across channels.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
Hi,
Michael Niedermayer wrote:
> On Fri, Nov 14, 2008 at 02:28:50PM -0800, Baptiste Coudurier wrote:
>> Michael Niedermayer wrote:
>>> On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote:
>>>> Michael Niedermayer wrote:
>>>>> On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote:
>>>>>>> your original logic generates packets that are not a multiple of 512
>>>>>> or
>>>>>>> 1024 thus not a multiple of disk sectors, this seems not ideal
>>>>>> It generates these packets only in cases which currently fail entirely.
>>>>>> While this may not be ideal (at least, if there is neither OS nor C
>>>>>> library caching going on), it has the virtue of solving the problem at
>>>>>> hand without changing current behavior.
>>>>>>
>>>>>>> in principle updating the regression test checksums would be fine, but
>>>>>>> why does g726 change? this looks like there is something wrong in g726
>>>>>>> which has to be found and fixed ...
>>>>>> It is worth observing that the size of the mov and mkv files change, not
>>>>>> just their checksum. When I extract the raw audio data from
>>>>>> tests/data/a-pcm_s16be.mov and strip the header, the file matches the
>>>>>> original asynth1.sw file except that it is not quite as long. Reducing
>>>>>> RAW_PACKET_SIZE increases the size of the resulting mov file, and
>>>>>> conversely increasing it results in a smaller mov.
>>>>>>
>>>>>> Something odd overall is clearly happening related to RAW_PACKET_SIZE,
>>>>>> which may or may not be related to the g726 issue, but I don't currently
>>>>>> have the time to investigate the specifics of either.
>>>>> so the summary is we need some volunteer to fix
>>>>> 1. g726
>>>>> 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE
>>>>>
>>>> Huh ? If there is a problem with mov I'll fix it right now.
>>> I dont know if there is, i just added mov because phil said:
>>> "It is worth observing that the size of the mov and mkv files change, not
>>> just their checksum. When I extract the raw audio data from
>>> tests/data/a-pcm_s16be.mov and strip the header, the file matches the
>>> original asynth1.sw file except that it is not quite as long."
>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>
>>> ive not confirmed this or investigated at all ...
>>>
>> What about this patch ? Regression tests pass.
> [...]
>> Index: libavformat/raw.c
>> ===================================================================
>> --- libavformat/raw.c (revision 15823)
>> +++ libavformat/raw.c (working copy)
>> @@ -115,6 +115,13 @@
>> st->codec->sample_rate = ap->sample_rate;
>> if(ap->channels) st->codec->channels = ap->channels;
>> else st->codec->channels = 1;
>> + st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
>> + assert(st->codec->bits_per_coded_sample > 0);
>> + if (!st->codec->channels) {
>> + av_log(s, AV_LOG_ERROR, "channels is not set\n");
>> + return -1;
>> + }
>
> i dont see how this if() could be true
Humm, right, leftover.
>
>> + st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8;
>> av_set_pts_info(st, 64, 1, st->codec->sample_rate);
>> break;
>> case CODEC_TYPE_VIDEO:
>> @@ -139,9 +146,9 @@
>> static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
>> {
>> int ret, size, bps;
>> - // AVStream *st = s->streams[0];
>> + AVStream *st = s->streams[0];
>>
>> - size= RAW_PACKET_SIZE;
>> + size= (RAW_PACKET_SIZE/st->codec->block_align)*st->codec->block_align;
>
> i think i prefer if the packet size contains a constant number of samples
> across channels.
I don't see what you mean here.
Also this is the way it is done in wav demuxer.
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no
On Sun, Nov 16, 2008 at 01:48:21PM -0800, Baptiste Coudurier wrote:
Hi,
Michael Niedermayer wrote:
On Fri, Nov 14, 2008 at 02:28:50PM -0800, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote: >> your original logic generates packets that are not a multiple of 512 > or >> 1024 thus not a multiple of disk sectors, this seems not ideal > It generates these packets only in cases which currently fail entirely. > While this may not be ideal (at least, if there is neither OS nor C > library caching going on), it has the virtue of solving the problem at > hand without changing current behavior. > >> in principle updating the regression test checksums would be fine, but >> why does g726 change? this looks like there is something wrong in g726 >> which has to be found and fixed ... > It is worth observing that the size of the mov and mkv files change, not > just their checksum. When I extract the raw audio data from > tests/data/a-pcm_s16be.mov and strip the header, the file matches the > original asynth1.sw file except that it is not quite as long. Reducing > RAW_PACKET_SIZE increases the size of the resulting mov file, and > conversely increasing it results in a smaller mov. > > Something odd overall is clearly happening related to RAW_PACKET_SIZE, > which may or may not be related to the g726 issue, but I don't currently > have the time to investigate the specifics of either. so the summary is we need some volunteer to fix 1. g726 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE
Huh ? If there is a problem with mov I'll fix it right now. I dont know if there is, i just added mov because phil said: "It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ive not confirmed this or investigated at all ...
What about this patch ? Regression tests pass. [...] [...]
+ st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8; av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; case CODEC_TYPE_VIDEO: @@ -139,9 +146,9 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size, bps; - // AVStream *st = s->streams[0]; + AVStream *st = s->streams[0];
- size= RAW_PACKET_SIZE; + size= (RAW_PACKET_SIZE/st->codec->block_align)*st->codec->block_align;
i think i prefer if the packet size contains a constant number of samples across channels.
I don't see what you mean here.
i mean that i would prefer if packets with 6 channels would be 3 times as large as 2 channel packets. That way the duration (ignoring samplerate) would be constant. Also if 1 channel 1 byte packets are a multiple of 512 bytes then all others also would have "nice" sizes. Besides i feel that picking one choice instead of the other because the other triggers a bunch of unrelated bugs is not ideal. And this really is the main reason for my preferance. On its own i am fine with your patch but i feel that we are making this decission in front of the background that the other cant be taken without some bugfixing, thus our decission might be sub-optimal. IMHO the bugs uncovered here should be investigated and fixed then we can look again which of the 2 variants is better. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle
Michael Niedermayer wrote:
On Sun, Nov 16, 2008 at 01:48:21PM -0800, Baptiste Coudurier wrote:
Hi,
Michael Niedermayer wrote:
On Fri, Nov 14, 2008 at 02:28:50PM -0800, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote:
Michael Niedermayer wrote: > On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote: >>> your original logic generates packets that are not a multiple of 512 >> or >>> 1024 thus not a multiple of disk sectors, this seems not ideal >> It generates these packets only in cases which currently fail entirely. >> While this may not be ideal (at least, if there is neither OS nor C >> library caching going on), it has the virtue of solving the problem at >> hand without changing current behavior. >> >>> in principle updating the regression test checksums would be fine, but >>> why does g726 change? this looks like there is something wrong in g726 >>> which has to be found and fixed ... >> It is worth observing that the size of the mov and mkv files change, not >> just their checksum. When I extract the raw audio data from >> tests/data/a-pcm_s16be.mov and strip the header, the file matches the >> original asynth1.sw file except that it is not quite as long. Reducing >> RAW_PACKET_SIZE increases the size of the resulting mov file, and >> conversely increasing it results in a smaller mov. >> >> Something odd overall is clearly happening related to RAW_PACKET_SIZE, >> which may or may not be related to the g726 issue, but I don't currently >> have the time to investigate the specifics of either. > so the summary is we need some volunteer to fix > 1. g726 > 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE > Huh ? If there is a problem with mov I'll fix it right now. I dont know if there is, i just added mov because phil said: "It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ive not confirmed this or investigated at all ...
What about this patch ? Regression tests pass. [...] [...] + st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8; av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; case CODEC_TYPE_VIDEO: @@ -139,9 +146,9 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size, bps; - // AVStream *st = s->streams[0]; + AVStream *st = s->streams[0];
- size= RAW_PACKET_SIZE; + size= (RAW_PACKET_SIZE/st->codec->block_align)*st->codec->block_align; i think i prefer if the packet size contains a constant number of samples across channels. I don't see what you mean here.
i mean that i would prefer if packets with 6 channels would be 3 times as large as 2 channel packets. That way the duration (ignoring samplerate) would be constant. Also if 1 channel 1 byte packets are a multiple of 512 bytes then all others also would have "nice" sizes.
Besides i feel that picking one choice instead of the other because the other triggers a bunch of unrelated bugs is not ideal. And this really is the main reason for my preferance. On its own i am fine with your patch but i feel that we are making this decission in front of the background that the other cant be taken without some bugfixing, thus our decission might be sub-optimal. IMHO the bugs uncovered here should be investigated and fixed then we can look again which of the 2 variants is better.
What about this ? -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no FFmpeg maintainer http://www.ffmpeg.org
On Wed, Apr 01, 2009 at 10:05:04PM -0700, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
On Sun, Nov 16, 2008 at 01:48:21PM -0800, Baptiste Coudurier wrote:
Hi,
Michael Niedermayer wrote:
On Fri, Nov 14, 2008 at 02:28:50PM -0800, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote: > Michael Niedermayer wrote: >> On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote: >>>> your original logic generates packets that are not a multiple of 512 >>> or >>>> 1024 thus not a multiple of disk sectors, this seems not ideal >>> It generates these packets only in cases which currently fail entirely. >>> While this may not be ideal (at least, if there is neither OS nor C >>> library caching going on), it has the virtue of solving the problem at >>> hand without changing current behavior. >>> >>>> in principle updating the regression test checksums would be fine, but >>>> why does g726 change? this looks like there is something wrong in g726 >>>> which has to be found and fixed ... >>> It is worth observing that the size of the mov and mkv files change, not >>> just their checksum. When I extract the raw audio data from >>> tests/data/a-pcm_s16be.mov and strip the header, the file matches the >>> original asynth1.sw file except that it is not quite as long. Reducing >>> RAW_PACKET_SIZE increases the size of the resulting mov file, and >>> conversely increasing it results in a smaller mov. >>> >>> Something odd overall is clearly happening related to RAW_PACKET_SIZE, >>> which may or may not be related to the g726 issue, but I don't currently >>> have the time to investigate the specifics of either. >> so the summary is we need some volunteer to fix >> 1. g726 >> 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE >> > Huh ? If there is a problem with mov I'll fix it right now. I dont know if there is, i just added mov because phil said: "It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long." ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ive not confirmed this or investigated at all ...
What about this patch ? Regression tests pass. [...] [...] + st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8; av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; case CODEC_TYPE_VIDEO: @@ -139,9 +146,9 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size, bps; - // AVStream *st = s->streams[0]; + AVStream *st = s->streams[0];
- size= RAW_PACKET_SIZE; + size= (RAW_PACKET_SIZE/st->codec->block_align)*st->codec->block_align; i think i prefer if the packet size contains a constant number of samples across channels. I don't see what you mean here.
i mean that i would prefer if packets with 6 channels would be 3 times as large as 2 channel packets. That way the duration (ignoring samplerate) would be constant. Also if 1 channel 1 byte packets are a multiple of 512 bytes then all others also would have "nice" sizes.
Besides i feel that picking one choice instead of the other because the other triggers a bunch of unrelated bugs is not ideal. And this really is the main reason for my preferance. On its own i am fine with your patch but i feel that we are making this decission in front of the background that the other cant be taken without some bugfixing, thus our decission might be sub-optimal. IMHO the bugs uncovered here should be investigated and fixed then we can look again which of the 2 variants is better.
What about this ?
probably ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire
On Thu, Apr 02, 2009 at 02:32:27PM +0200, Michael Niedermayer wrote:
On Wed, Apr 01, 2009 at 10:05:04PM -0700, Baptiste Coudurier wrote:
Michael Niedermayer wrote:
On Sun, Nov 16, 2008 at 01:48:21PM -0800, Baptiste Coudurier wrote:
Hi,
Michael Niedermayer wrote:
On Fri, Nov 14, 2008 at 02:28:50PM -0800, Baptiste Coudurier wrote:
Michael Niedermayer wrote: > On Fri, Nov 14, 2008 at 10:52:37AM -0800, Baptiste Coudurier wrote: >> Michael Niedermayer wrote: >>> On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote: >>>>> your original logic generates packets that are not a multiple of 512 >>>> or >>>>> 1024 thus not a multiple of disk sectors, this seems not ideal >>>> It generates these packets only in cases which currently fail entirely. >>>> While this may not be ideal (at least, if there is neither OS nor C >>>> library caching going on), it has the virtue of solving the problem at >>>> hand without changing current behavior. >>>> >>>>> in principle updating the regression test checksums would be fine, but >>>>> why does g726 change? this looks like there is something wrong in g726 >>>>> which has to be found and fixed ... >>>> It is worth observing that the size of the mov and mkv files change, not >>>> just their checksum. When I extract the raw audio data from >>>> tests/data/a-pcm_s16be.mov and strip the header, the file matches the >>>> original asynth1.sw file except that it is not quite as long. Reducing >>>> RAW_PACKET_SIZE increases the size of the resulting mov file, and >>>> conversely increasing it results in a smaller mov. >>>> >>>> Something odd overall is clearly happening related to RAW_PACKET_SIZE, >>>> which may or may not be related to the g726 issue, but I don't currently >>>> have the time to investigate the specifics of either. >>> so the summary is we need some volunteer to fix >>> 1. g726 >>> 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE >>> >> Huh ? If there is a problem with mov I'll fix it right now. > I dont know if there is, i just added mov because phil said: > "It is worth observing that the size of the mov and mkv files change, not > just their checksum. When I extract the raw audio data from > tests/data/a-pcm_s16be.mov and strip the header, the file matches the > original asynth1.sw file except that it is not quite as long." > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > ive not confirmed this or investigated at all ... > What about this patch ? Regression tests pass. [...] [...] + st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8; av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; case CODEC_TYPE_VIDEO: @@ -139,9 +146,9 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size, bps; - // AVStream *st = s->streams[0]; + AVStream *st = s->streams[0];
- size= RAW_PACKET_SIZE; + size= (RAW_PACKET_SIZE/st->codec->block_align)*st->codec->block_align; i think i prefer if the packet size contains a constant number of samples across channels. I don't see what you mean here.
i mean that i would prefer if packets with 6 channels would be 3 times as large as 2 channel packets. That way the duration (ignoring samplerate) would be constant. Also if 1 channel 1 byte packets are a multiple of 512 bytes then all others also would have "nice" sizes.
Besides i feel that picking one choice instead of the other because the other triggers a bunch of unrelated bugs is not ideal. And this really is the main reason for my preferance. On its own i am fine with your patch but i feel that we are making this decission in front of the background that the other cant be taken without some bugfixing, thus our decission might be sub-optimal. IMHO the bugs uncovered here should be investigated and fixed then we can look again which of the 2 variants is better.
What about this ?
probably ok
Applied and updated regression refs. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no FFmpeg maintainer http://www.ffmpeg.org
Michael Niedermayer wrote:
On Wed, Nov 12, 2008 at 04:30:12PM -0800, Phil Rutschman wrote:
your original logic generates packets that are not a multiple of 512 or 1024 thus not a multiple of disk sectors, this seems not ideal It generates these packets only in cases which currently fail entirely. While this may not be ideal (at least, if there is neither OS nor C library caching going on), it has the virtue of solving the problem at hand without changing current behavior.
in principle updating the regression test checksums would be fine, but why does g726 change? this looks like there is something wrong in g726 which has to be found and fixed ... It is worth observing that the size of the mov and mkv files change, not just their checksum. When I extract the raw audio data from tests/data/a-pcm_s16be.mov and strip the header, the file matches the original asynth1.sw file except that it is not quite as long. Reducing RAW_PACKET_SIZE increases the size of the resulting mov file, and conversely increasing it results in a smaller mov.
Something odd overall is clearly happening related to RAW_PACKET_SIZE, which may or may not be related to the g726 issue, but I don't currently have the time to investigate the specifics of either.
so the summary is we need some volunteer to fix 1. g726 2. mov/mkv loosing some samples depending on RAW_PACKET_SIZE
after that pcm can be fixed and regression checksums updated.
I investigated, problem is that regression tests are run with -t so it stops the encoding after 1 sec, during this time, and depending on RAW_PACKET_SIZE a different number of samples is read, therefore explaining the difference. The way to fix this is to read a fixed number of samples in raw.c like you suggested, I will try to cook something. I don't know about g726, I didn't check. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no FFmpeg maintainer http://www.ffmpeg.org
Michael Niedermayer wrote: [...]
in principle updating the regression test checksums would be fine, but why does g726 change? this looks like there is something wrong in g726 which has to be found and fixed ...
[...]
I have noticed this g726 issue also. I think the problem is the last sample but I'm not sure. MvH Benjamin Larsson
participants (5)
-
andreas@lonelycoder.com -
banan@ludd.ltu.se -
baptiste.coudurier@gmail.com -
michaelni@gmx.at -
philr@modsystems.com