[FFmpeg-devel] [PATCH] Lego Mindstorms RSO de/muxer (copied from au.c)

Rafaël Carré rafael.carre
Fri Jul 16 06:22:35 CEST 2010


On Fri, 16 Jul 2010 05:22:46 +0200
Michael Niedermayer <michaelni at gmx.at> wrote:

> On Thu, Jul 15, 2010 at 04:44:49PM +0200, Rafa?l Carr? wrote:
> [...]
> > + * You should have received a copy of the GNU Lesser General Public
> > + * License along with FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> > 02110-1301 USA
> > + */
> > +
> > +#include "libavutil/intreadwrite.h"
> > +#include "avformat.h"
> > +#include "raw.h"
> > +#include "riff.h"
> > +#include "rso.h"
> > +
> 
> > +static int rso_probe(AVProbeData *p)
> > +{
> > +    uint16_t rate, loop;
> 
> why uint16_t?

Those are 16 bits values, do you suggest using int instead?

> > +
> > +    if (p->buf_size < RSO_HEADER_SIZE)
> > +        return 0;
> 
> probably unneeded

Reading ff_probe_input_buffer() it seems the buffer will be at least
AVPROBE_PADDING_SIZE (== 32) bytes so it could be removed


> > +    bpp = av_get_bits_per_sample(codec);

> > +    st->duration = size << 3 / bpp;
> 
> is this correct?

Yes, number of samples = size in bytes * 8 / bits per sample

Although the variable should be named bps and not bpp

Also since bits per sample is 8 (PCM_U8) or 4 (ADPCM_IMA_WAV) I think it
should use av_log2() + shift, e.g. (size << 3) >> av_log2(bps)

> [...]
> > +static int rso_write_header(AVFormatContext *s)
> > +{
> > +    ByteIOContext  *pb  = s->pb;
> > +    AVCodecContext *enc = s->streams[0]->codec;
> > +
> > +    if (!enc->codec_tag)
> > +        return -1;
> > +
> > +    if (enc->channels != 1) {
> > +        av_log(s, AV_LOG_ERROR, "RSO only supports mono\n");
> > +        return -1;
> > +    }
> > +
> > +    if (url_is_streamed(s->pb)) {
> > +        av_log(s, AV_LOG_ERROR, "muxer does not support non
> > seekable output\n");
> > +        return -1;
> > +    }
> > +
> > +    /* XXX: find legal sample rates */
> > +    if (enc->sample_rate >= 1u<<16) {
> > +        av_log(s, AV_LOG_ERROR, "Sample rate must be < 65536\n");
> > +        return -1;
> > +    }
> > +
> > +    if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
> > +        av_log(s, AV_LOG_ERROR, "ADPCM in RSO not implemented\n");
> > +        return -1;
> > +    }
> > +
> > +    s->priv_data = NULL;
> 
> how did it become non null ?

Dunno, I copied it straight from au.c and didn't check if it was needed.

I'll check and send another patch

-- 
Rafa?l Carr?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100716/1515b05c/attachment.pgp>



More information about the ffmpeg-devel mailing list