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

Michael Niedermayer michaelni
Fri Jul 16 05:22:46 CEST 2010


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?



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

probably unneeded


[...]
> +static int rso_read_header(AVFormatContext *s, AVFormatParameters *ap)
> +{
> +    ByteIOContext *pb = s->pb;
> +    unsigned int id, rate, size, bpp;
> +    enum CodecID codec;
> +    AVStream *st;
> +
> +    id =    get_be16(pb);
> +    size =  get_be16(pb);
> +    rate =  get_be16(pb);
> +
> +    get_be16(pb);   /* play mode ? (0x0000 = don't loop) */
> +
> +    codec = ff_codec_get_id(codec_rso_tags, id);
> +
> +    if (codec == CODEC_ID_ADPCM_IMA_WAV) {
> +        av_log(s, AV_LOG_ERROR, "ADPCM in RSO not implemented\n");
> +        return -1;
> +    }
> +
> +    bpp = av_get_bits_per_sample(codec);
> +    if (!bpp) {
> +        av_log_ask_for_sample(s, "could not determine bits per sample\n");
> +        return AVERROR_INVALIDDATA;
> +    }
> +
> +    /* now we are ready: build format streams */
> +    st = av_new_stream(s, 0);
> +    if (!st)
> +        return -1;

> +    st->duration = size << 3 / bpp;

is this correct?


[...]
> +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 ?

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100716/f20ad1c9/attachment.pgp>



More information about the ffmpeg-devel mailing list